aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPeter Zijlstra <a.p.zijlstra@chello.nl>2008-12-04 03:00:17 -0500
committerIngo Molnar <mingo@elte.hu>2008-12-04 04:08:18 -0500
commit00ef9f7348dfd2fc223ec42aceb30836e86b367f (patch)
tree14c33d878bec717179a6916232e118dbfbf7d65f
parentcb9c34e6d090d376b77becaa5d29a65dec7f4272 (diff)
lockdep: change a held lock's class
Impact: introduce new lockdep API Allow to change a held lock's class. Basically the same as the existing code to change a subclass therefore reuse all that. The XFS code will be able to use this to annotate their inode locking. Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl> Signed-off-by: Ingo Molnar <mingo@elte.hu>
-rw-r--r--include/linux/lockdep.h12
-rw-r--r--kernel/lockdep.c24
2 files changed, 19 insertions, 17 deletions
diff --git a/include/linux/lockdep.h b/include/linux/lockdep.h
index 8956daf64abd..37a0361f4685 100644
--- a/include/linux/lockdep.h
+++ b/include/linux/lockdep.h
@@ -314,8 +314,15 @@ extern void lock_acquire(struct lockdep_map *lock, unsigned int subclass,
314extern void lock_release(struct lockdep_map *lock, int nested, 314extern void lock_release(struct lockdep_map *lock, int nested,
315 unsigned long ip); 315 unsigned long ip);
316 316
317extern void lock_set_subclass(struct lockdep_map *lock, unsigned int subclass, 317extern void lock_set_class(struct lockdep_map *lock, const char *name,
318 unsigned long ip); 318 struct lock_class_key *key, unsigned int subclass,
319 unsigned long ip);
320
321static inline void lock_set_subclass(struct lockdep_map *lock,
322 unsigned int subclass, unsigned long ip)
323{
324 lock_set_class(lock, lock->name, lock->key, subclass, ip);
325}
319 326
320# define INIT_LOCKDEP .lockdep_recursion = 0, 327# define INIT_LOCKDEP .lockdep_recursion = 0,
321 328
@@ -333,6 +340,7 @@ static inline void lockdep_on(void)
333 340
334# define lock_acquire(l, s, t, r, c, n, i) do { } while (0) 341# define lock_acquire(l, s, t, r, c, n, i) do { } while (0)
335# define lock_release(l, n, i) do { } while (0) 342# define lock_release(l, n, i) do { } while (0)
343# define lock_set_class(l, n, k, s, i) do { } while (0)
336# define lock_set_subclass(l, s, i) do { } while (0) 344# define lock_set_subclass(l, s, i) do { } while (0)
337# define lockdep_init() do { } while (0) 345# define lockdep_init() do { } while (0)
338# define lockdep_info() do { } while (0) 346# define lockdep_info() do { } while (0)
diff --git a/kernel/lockdep.c b/kernel/lockdep.c
index 90f3fb64dbce..4fa6eeb4e8a7 100644
--- a/kernel/lockdep.c
+++ b/kernel/lockdep.c
@@ -291,14 +291,12 @@ void lockdep_off(void)
291{ 291{
292 current->lockdep_recursion++; 292 current->lockdep_recursion++;
293} 293}
294
295EXPORT_SYMBOL(lockdep_off); 294EXPORT_SYMBOL(lockdep_off);
296 295
297void lockdep_on(void) 296void lockdep_on(void)
298{ 297{
299 current->lockdep_recursion--; 298 current->lockdep_recursion--;
300} 299}
301
302EXPORT_SYMBOL(lockdep_on); 300EXPORT_SYMBOL(lockdep_on);
303 301
304/* 302/*
@@ -2513,7 +2511,6 @@ void lockdep_init_map(struct lockdep_map *lock, const char *name,
2513 if (subclass) 2511 if (subclass)
2514 register_lock_class(lock, subclass, 1); 2512 register_lock_class(lock, subclass, 1);
2515} 2513}
2516
2517EXPORT_SYMBOL_GPL(lockdep_init_map); 2514EXPORT_SYMBOL_GPL(lockdep_init_map);
2518 2515
2519/* 2516/*
@@ -2694,8 +2691,9 @@ static int check_unlock(struct task_struct *curr, struct lockdep_map *lock,
2694} 2691}
2695 2692
2696static int 2693static int
2697__lock_set_subclass(struct lockdep_map *lock, 2694__lock_set_class(struct lockdep_map *lock, const char *name,
2698 unsigned int subclass, unsigned long ip) 2695 struct lock_class_key *key, unsigned int subclass,
2696 unsigned long ip)
2699{ 2697{
2700 struct task_struct *curr = current; 2698 struct task_struct *curr = current;
2701 struct held_lock *hlock, *prev_hlock; 2699 struct held_lock *hlock, *prev_hlock;
@@ -2722,6 +2720,7 @@ __lock_set_subclass(struct lockdep_map *lock,
2722 return print_unlock_inbalance_bug(curr, lock, ip); 2720 return print_unlock_inbalance_bug(curr, lock, ip);
2723 2721
2724found_it: 2722found_it:
2723 lockdep_init_map(lock, name, key, 0);
2725 class = register_lock_class(lock, subclass, 0); 2724 class = register_lock_class(lock, subclass, 0);
2726 hlock->class_idx = class - lock_classes + 1; 2725 hlock->class_idx = class - lock_classes + 1;
2727 2726
@@ -2906,9 +2905,9 @@ static void check_flags(unsigned long flags)
2906#endif 2905#endif
2907} 2906}
2908 2907
2909void 2908void lock_set_class(struct lockdep_map *lock, const char *name,
2910lock_set_subclass(struct lockdep_map *lock, 2909 struct lock_class_key *key, unsigned int subclass,
2911 unsigned int subclass, unsigned long ip) 2910 unsigned long ip)
2912{ 2911{
2913 unsigned long flags; 2912 unsigned long flags;
2914 2913
@@ -2918,13 +2917,12 @@ lock_set_subclass(struct lockdep_map *lock,
2918 raw_local_irq_save(flags); 2917 raw_local_irq_save(flags);
2919 current->lockdep_recursion = 1; 2918 current->lockdep_recursion = 1;
2920 check_flags(flags); 2919 check_flags(flags);
2921 if (__lock_set_subclass(lock, subclass, ip)) 2920 if (__lock_set_class(lock, name, key, subclass, ip))
2922 check_chain_key(current); 2921 check_chain_key(current);
2923 current->lockdep_recursion = 0; 2922 current->lockdep_recursion = 0;
2924 raw_local_irq_restore(flags); 2923 raw_local_irq_restore(flags);
2925} 2924}
2926 2925EXPORT_SYMBOL_GPL(lock_set_class);
2927EXPORT_SYMBOL_GPL(lock_set_subclass);
2928 2926
2929/* 2927/*
2930 * We are not always called with irqs disabled - do that here, 2928 * We are not always called with irqs disabled - do that here,
@@ -2948,7 +2946,6 @@ void lock_acquire(struct lockdep_map *lock, unsigned int subclass,
2948 current->lockdep_recursion = 0; 2946 current->lockdep_recursion = 0;
2949 raw_local_irq_restore(flags); 2947 raw_local_irq_restore(flags);
2950} 2948}
2951
2952EXPORT_SYMBOL_GPL(lock_acquire); 2949EXPORT_SYMBOL_GPL(lock_acquire);
2953 2950
2954void lock_release(struct lockdep_map *lock, int nested, 2951void lock_release(struct lockdep_map *lock, int nested,
@@ -2966,7 +2963,6 @@ void lock_release(struct lockdep_map *lock, int nested,
2966 current->lockdep_recursion = 0; 2963 current->lockdep_recursion = 0;
2967 raw_local_irq_restore(flags); 2964 raw_local_irq_restore(flags);
2968} 2965}
2969
2970EXPORT_SYMBOL_GPL(lock_release); 2966EXPORT_SYMBOL_GPL(lock_release);
2971 2967
2972#ifdef CONFIG_LOCK_STAT 2968#ifdef CONFIG_LOCK_STAT
@@ -3451,7 +3447,6 @@ retry:
3451 if (unlock) 3447 if (unlock)
3452 read_unlock(&tasklist_lock); 3448 read_unlock(&tasklist_lock);
3453} 3449}
3454
3455EXPORT_SYMBOL_GPL(debug_show_all_locks); 3450EXPORT_SYMBOL_GPL(debug_show_all_locks);
3456 3451
3457/* 3452/*
@@ -3472,7 +3467,6 @@ void debug_show_held_locks(struct task_struct *task)
3472{ 3467{
3473 __debug_show_held_locks(task); 3468 __debug_show_held_locks(task);
3474} 3469}
3475
3476EXPORT_SYMBOL_GPL(debug_show_held_locks); 3470EXPORT_SYMBOL_GPL(debug_show_held_locks);
3477 3471
3478void lockdep_sys_exit(void) 3472void lockdep_sys_exit(void)