diff options
| author | Srivatsa Vaddagiri <vatsa@codeaurora.org> | 2014-07-28 20:44:12 -0700 |
|---|---|---|
| committer | David Keitel <dkeitel@codeaurora.org> | 2016-03-23 20:00:01 -0700 |
| commit | 730e262d6a58608572eec74ea7eb37c0e4d8d11f (patch) | |
| tree | 4484c9d79bf02f8315ca0cff146a7231a8807621 /kernel | |
| parent | f41fd0eca9950970d7e16f4fdfa84aba77c77b19 (diff) | |
sched: window-stats: Additional error checking in sched_set_window()
Check for invalid window size passed as argument to sched_set_window()
Also move up local_irq_disable() call to avoid thread from being
preempted during calculation of window_start and its comparison
against sched_clock(). Use right macro to evluate whether window_start
argument is ahead in time or not.
Change-Id: Idc0d3ab17ede08471ae63b72a2d55e7f84868fd6
Signed-off-by: Srivatsa Vaddagiri <vatsa@codeaurora.org>
Diffstat (limited to 'kernel')
| -rw-r--r-- | kernel/sched/core.c | 17 |
1 files changed, 8 insertions, 9 deletions
diff --git a/kernel/sched/core.c b/kernel/sched/core.c index f6492a1755fc..1b6839ecdf1d 100644 --- a/kernel/sched/core.c +++ b/kernel/sched/core.c @@ -1517,19 +1517,20 @@ unsigned long sched_get_busy(int cpu) int sched_set_window(u64 window_start, unsigned int window_size) { int cpu; - u64 ws; - u64 now = get_jiffies_64(); + u64 wallclock, ws, now; int delta; unsigned long flags; - u64 wallclock; struct task_struct *g, *p; - if (sched_use_pelt) - return -EINVAL; + if (sched_use_pelt || + (window_size * TICK_NSEC < MIN_SCHED_RAVG_WINDOW)) + return -EINVAL; - delta = window_start - now; /* how many jiffies ahead */ + local_irq_save(flags); - if (delta > 0) { + now = get_jiffies_64(); + if (time_after64(window_start, now)) { + delta = window_start - now; /* how many jiffies ahead */ delta /= window_size; /* # of windows to roll back */ delta += 1; window_start -= (delta * window_size); @@ -1541,8 +1542,6 @@ int sched_set_window(u64 window_start, unsigned int window_size) BUG_ON(sched_clock() < ws); - local_irq_save(flags); - for_each_online_cpu(cpu) { struct rq *rq = cpu_rq(cpu); raw_spin_lock(&rq->lock); |
