Skip to content

Commit

Permalink
sched/deadline: Test for CPU's presence explicitly
Browse files Browse the repository at this point in the history
A hot-removed CPU may have ID that is numerically larger than the number of
existing CPUs in the system (e.g. we can unplug CPU 4 from a system that
has CPUs 0, 1 and 4).

Thus the WARN_ONs should check whether the CPU in question is currently
present, not whether its ID value is less than num_present_cpus().

Cc: Ingo Molnar <mingo@kernel.org>
Cc: Juri Lelli <juri.lelli@gmail.com>
Cc: Steven Rostedt <rostedt@goodmis.org>
Reported-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Signed-off-by: Boris Ostrovsky <boris.ostrovsky@oracle.com>
Signed-off-by: Peter Zijlstra <peterz@infradead.org>
Link: http://lkml.kernel.org/r/1392646353-1874-1-git-send-email-boris.ostrovsky@oracle.com
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
  • Loading branch information
Boris Ostrovsky authored and Thomas Gleixner committed Feb 21, 2014
1 parent 6d35ab4 commit 82b9580
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions kernel/sched/cpudeadline.c
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ static void cpudl_heapify(struct cpudl *cp, int idx)

static void cpudl_change_key(struct cpudl *cp, int idx, u64 new_dl)
{
WARN_ON(idx > num_present_cpus() || idx == IDX_INVALID);
WARN_ON(!cpu_present(idx) || idx == IDX_INVALID);

if (dl_time_before(new_dl, cp->elements[idx].dl)) {
cp->elements[idx].dl = new_dl;
Expand Down Expand Up @@ -117,7 +117,7 @@ int cpudl_find(struct cpudl *cp, struct task_struct *p,
}

out:
WARN_ON(best_cpu > num_present_cpus() && best_cpu != -1);
WARN_ON(!cpu_present(best_cpu) && best_cpu != -1);

return best_cpu;
}
Expand All @@ -137,7 +137,7 @@ void cpudl_set(struct cpudl *cp, int cpu, u64 dl, int is_valid)
int old_idx, new_cpu;
unsigned long flags;

WARN_ON(cpu > num_present_cpus());
WARN_ON(!cpu_present(cpu));

raw_spin_lock_irqsave(&cp->lock, flags);
old_idx = cp->cpu_to_idx[cpu];
Expand Down

0 comments on commit 82b9580

Please sign in to comment.