Commit 8e60e05fdc7344415fa69a3883b11f65db967b47

Authored by Oleg Nesterov
Committed by Thomas Gleixner
1 parent 0d180406f2

hrtimers: simplify lockdep handling

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>

Showing 2 changed files with 4 additions and 7 deletions Side-by-side Diff

include/linux/hrtimer.h
... ... @@ -173,7 +173,6 @@
173 173 * struct hrtimer_cpu_base - the per cpu clock bases
174 174 * @lock: lock protecting the base and associated clock bases
175 175 * and timers
176   - * @lock_key: the lock_class_key for use with lockdep
177 176 * @clock_base: array of clock bases for this cpu
178 177 * @curr_timer: the timer which is executing a callback right now
179 178 * @expires_next: absolute time of the next event which was scheduled
... ... @@ -189,7 +188,6 @@
189 188 */
190 189 struct hrtimer_cpu_base {
191 190 spinlock_t lock;
192   - struct lock_class_key lock_key;
193 191 struct hrtimer_clock_base clock_base[HRTIMER_MAX_CLOCK_BASES];
194 192 struct list_head cb_pending;
195 193 #ifdef CONFIG_HIGH_RES_TIMERS
... ... @@ -1424,7 +1424,6 @@
1424 1424 int i;
1425 1425  
1426 1426 spin_lock_init(&cpu_base->lock);
1427   - lockdep_set_class(&cpu_base->lock, &cpu_base->lock_key);
1428 1427  
1429 1428 for (i = 0; i < HRTIMER_MAX_CLOCK_BASES; i++)
1430 1429 cpu_base->clock_base[i].cpu_base = cpu_base;
1431 1430  
... ... @@ -1465,16 +1464,16 @@
1465 1464 tick_cancel_sched_timer(cpu);
1466 1465  
1467 1466 local_irq_disable();
1468   - double_spin_lock(&new_base->lock, &old_base->lock,
1469   - smp_processor_id() < cpu);
  1467 + spin_lock(&new_base->lock);
  1468 + spin_lock_nested(&old_base->lock, SINGLE_DEPTH_NESTING);
1470 1469  
1471 1470 for (i = 0; i < HRTIMER_MAX_CLOCK_BASES; i++) {
1472 1471 migrate_hrtimer_list(&old_base->clock_base[i],
1473 1472 &new_base->clock_base[i]);
1474 1473 }
1475 1474  
1476   - double_spin_unlock(&new_base->lock, &old_base->lock,
1477   - smp_processor_id() < cpu);
  1475 + spin_unlock(&old_base->lock);
  1476 + spin_unlock(&new_base->lock);
1478 1477 local_irq_enable();
1479 1478 put_cpu_var(hrtimer_bases);
1480 1479 }