diff options
author | Peter Zijlstra <a.p.zijlstra@chello.nl> | 2008-12-04 03:00:17 -0500 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2008-12-04 04:08:18 -0500 |
commit | 00ef9f7348dfd2fc223ec42aceb30836e86b367f (patch) | |
tree | 14c33d878bec717179a6916232e118dbfbf7d65f /kernel/lockdep.c | |
parent | cb9c34e6d090d376b77becaa5d29a65dec7f4272 (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>
Diffstat (limited to 'kernel/lockdep.c')
-rw-r--r-- | kernel/lockdep.c | 24 |
1 files changed, 9 insertions, 15 deletions
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 | |||
295 | EXPORT_SYMBOL(lockdep_off); | 294 | EXPORT_SYMBOL(lockdep_off); |
296 | 295 | ||
297 | void lockdep_on(void) | 296 | void lockdep_on(void) |
298 | { | 297 | { |
299 | current->lockdep_recursion--; | 298 | current->lockdep_recursion--; |
300 | } | 299 | } |
301 | |||
302 | EXPORT_SYMBOL(lockdep_on); | 300 | EXPORT_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 | |||
2517 | EXPORT_SYMBOL_GPL(lockdep_init_map); | 2514 | EXPORT_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 | ||
2696 | static int | 2693 | static 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 | ||
2724 | found_it: | 2722 | found_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 | ||
2909 | void | 2908 | void lock_set_class(struct lockdep_map *lock, const char *name, |
2910 | lock_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 | 2925 | EXPORT_SYMBOL_GPL(lock_set_class); | |
2927 | EXPORT_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 | |||
2952 | EXPORT_SYMBOL_GPL(lock_acquire); | 2949 | EXPORT_SYMBOL_GPL(lock_acquire); |
2953 | 2950 | ||
2954 | void lock_release(struct lockdep_map *lock, int nested, | 2951 | void 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 | |||
2970 | EXPORT_SYMBOL_GPL(lock_release); | 2966 | EXPORT_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 | |||
3455 | EXPORT_SYMBOL_GPL(debug_show_all_locks); | 3450 | EXPORT_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 | |||
3476 | EXPORT_SYMBOL_GPL(debug_show_held_locks); | 3470 | EXPORT_SYMBOL_GPL(debug_show_held_locks); |
3477 | 3471 | ||
3478 | void lockdep_sys_exit(void) | 3472 | void lockdep_sys_exit(void) |