Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

fix raw_spinlock_t vs lockdep

Use the lockdep infrastructure to track lock contention and other lock
statistics.

It tracks lock contention events, and the first four unique call-sites that
encountered contention.

It also measures lock wait-time and hold-time in nanoseconds. The minimum and
maximum times are tracked, as well as a total (which together with the number
of event can give the avg).

All statistics are done per lock class, per write (exclusive state) and per read
(shared state).

The statistics are collected per-cpu, so that the collection overhead is
minimized via having no global cachemisses.

This new lock statistics feature is independent of the lock dependency checking
traditionally done by lockdep; it just shares the lock tracking code. It is
also possible to enable both and runtime disabled either component - thereby
avoiding the O(n^2) lock chain walks for instance.

This patch:

raw_spinlock_t should not use lockdep (and doesn't) since lockdep itself
relies on it.

Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
Acked-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

authored by

Peter Zijlstra and committed by
Linus Torvalds
21f8ca3b 5b7f13bd

+3 -10
+2 -2
include/linux/spinlock_types.h
··· 9 9 * Released under the General Public License (GPL). 10 10 */ 11 11 12 - #include <linux/lockdep.h> 13 - 14 12 #if defined(CONFIG_SMP) 15 13 # include <asm/spinlock_types.h> 16 14 #else 17 15 # include <linux/spinlock_types_up.h> 18 16 #endif 17 + 18 + #include <linux/lockdep.h> 19 19 20 20 typedef struct { 21 21 raw_spinlock_t raw_lock;
+1 -8
include/linux/spinlock_types_up.h
··· 12 12 * Released under the General Public License (GPL). 13 13 */ 14 14 15 - #if defined(CONFIG_DEBUG_SPINLOCK) || \ 16 - defined(CONFIG_DEBUG_LOCK_ALLOC) 15 + #ifdef CONFIG_DEBUG_SPINLOCK 17 16 18 17 typedef struct { 19 18 volatile unsigned int slock; 20 - #ifdef CONFIG_DEBUG_LOCK_ALLOC 21 - struct lockdep_map dep_map; 22 - #endif 23 19 } raw_spinlock_t; 24 20 25 21 #define __RAW_SPIN_LOCK_UNLOCKED { 1 } ··· 30 34 31 35 typedef struct { 32 36 /* no debug version on UP */ 33 - #ifdef CONFIG_DEBUG_LOCK_ALLOC 34 - struct lockdep_map dep_map; 35 - #endif 36 37 } raw_rwlock_t; 37 38 38 39 #define __RAW_RW_LOCK_UNLOCKED { }