Skip to content

Commit

Permalink
hrtimers: simplify lockdep handling
Browse files Browse the repository at this point in the history
In order to avoid the false positive from lockdep, each per-cpu base->lock has
the separate lock class and migrate_hrtimers() uses double_spin_lock().

This is overcomplicated: except for migrate_hrtimers() we never take 2 locks
at once, and migrate_hrtimers() can use spin_lock_nested().

Signed-off-by: Oleg Nesterov <oleg@tv-sign.ru>
Cc: Arjan van de Ven <arjan@linux.intel.com>
Cc: Heiko Carstens <heiko.carstens@de.ibm.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
  • Loading branch information
Oleg Nesterov authored and KAGA-KOKO committed Apr 17, 2008
1 parent 0d18040 commit 8e60e05
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 7 deletions.
2 changes: 0 additions & 2 deletions include/linux/hrtimer.h
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,6 @@ struct hrtimer_clock_base {
* struct hrtimer_cpu_base - the per cpu clock bases
* @lock: lock protecting the base and associated clock bases
* and timers
* @lock_key: the lock_class_key for use with lockdep
* @clock_base: array of clock bases for this cpu
* @curr_timer: the timer which is executing a callback right now
* @expires_next: absolute time of the next event which was scheduled
Expand All @@ -189,7 +188,6 @@ struct hrtimer_clock_base {
*/
struct hrtimer_cpu_base {
spinlock_t lock;
struct lock_class_key lock_key;
struct hrtimer_clock_base clock_base[HRTIMER_MAX_CLOCK_BASES];
struct list_head cb_pending;
#ifdef CONFIG_HIGH_RES_TIMERS
Expand Down
9 changes: 4 additions & 5 deletions kernel/hrtimer.c
Original file line number Diff line number Diff line change
Expand Up @@ -1424,7 +1424,6 @@ static void __cpuinit init_hrtimers_cpu(int cpu)
int i;

spin_lock_init(&cpu_base->lock);
lockdep_set_class(&cpu_base->lock, &cpu_base->lock_key);

for (i = 0; i < HRTIMER_MAX_CLOCK_BASES; i++)
cpu_base->clock_base[i].cpu_base = cpu_base;
Expand Down Expand Up @@ -1465,16 +1464,16 @@ static void migrate_hrtimers(int cpu)
tick_cancel_sched_timer(cpu);

local_irq_disable();
double_spin_lock(&new_base->lock, &old_base->lock,
smp_processor_id() < cpu);
spin_lock(&new_base->lock);
spin_lock_nested(&old_base->lock, SINGLE_DEPTH_NESTING);

for (i = 0; i < HRTIMER_MAX_CLOCK_BASES; i++) {
migrate_hrtimer_list(&old_base->clock_base[i],
&new_base->clock_base[i]);
}

double_spin_unlock(&new_base->lock, &old_base->lock,
smp_processor_id() < cpu);
spin_unlock(&old_base->lock);
spin_unlock(&new_base->lock);
local_irq_enable();
put_cpu_var(hrtimer_bases);
}
Expand Down

0 comments on commit 8e60e05

Please sign in to comment.