diff options
Diffstat (limited to 'kernel/lockdep.c')
-rw-r--r-- | kernel/lockdep.c | 65 |
1 files changed, 35 insertions, 30 deletions
diff --git a/kernel/lockdep.c b/kernel/lockdep.c index 06e157119d2b..06b0c3568f0b 100644 --- a/kernel/lockdep.c +++ b/kernel/lockdep.c | |||
@@ -25,6 +25,7 @@ | |||
25 | * Thanks to Arjan van de Ven for coming up with the initial idea of | 25 | * Thanks to Arjan van de Ven for coming up with the initial idea of |
26 | * mapping lock dependencies runtime. | 26 | * mapping lock dependencies runtime. |
27 | */ | 27 | */ |
28 | #define DISABLE_BRANCH_PROFILING | ||
28 | #include <linux/mutex.h> | 29 | #include <linux/mutex.h> |
29 | #include <linux/sched.h> | 30 | #include <linux/sched.h> |
30 | #include <linux/delay.h> | 31 | #include <linux/delay.h> |
@@ -136,16 +137,16 @@ static inline struct lock_class *hlock_class(struct held_lock *hlock) | |||
136 | #ifdef CONFIG_LOCK_STAT | 137 | #ifdef CONFIG_LOCK_STAT |
137 | static DEFINE_PER_CPU(struct lock_class_stats[MAX_LOCKDEP_KEYS], lock_stats); | 138 | static DEFINE_PER_CPU(struct lock_class_stats[MAX_LOCKDEP_KEYS], lock_stats); |
138 | 139 | ||
139 | static int lock_contention_point(struct lock_class *class, unsigned long ip) | 140 | static int lock_point(unsigned long points[], unsigned long ip) |
140 | { | 141 | { |
141 | int i; | 142 | int i; |
142 | 143 | ||
143 | for (i = 0; i < ARRAY_SIZE(class->contention_point); i++) { | 144 | for (i = 0; i < LOCKSTAT_POINTS; i++) { |
144 | if (class->contention_point[i] == 0) { | 145 | if (points[i] == 0) { |
145 | class->contention_point[i] = ip; | 146 | points[i] = ip; |
146 | break; | 147 | break; |
147 | } | 148 | } |
148 | if (class->contention_point[i] == ip) | 149 | if (points[i] == ip) |
149 | break; | 150 | break; |
150 | } | 151 | } |
151 | 152 | ||
@@ -185,6 +186,9 @@ struct lock_class_stats lock_stats(struct lock_class *class) | |||
185 | for (i = 0; i < ARRAY_SIZE(stats.contention_point); i++) | 186 | for (i = 0; i < ARRAY_SIZE(stats.contention_point); i++) |
186 | stats.contention_point[i] += pcs->contention_point[i]; | 187 | stats.contention_point[i] += pcs->contention_point[i]; |
187 | 188 | ||
189 | for (i = 0; i < ARRAY_SIZE(stats.contending_point); i++) | ||
190 | stats.contending_point[i] += pcs->contending_point[i]; | ||
191 | |||
188 | lock_time_add(&pcs->read_waittime, &stats.read_waittime); | 192 | lock_time_add(&pcs->read_waittime, &stats.read_waittime); |
189 | lock_time_add(&pcs->write_waittime, &stats.write_waittime); | 193 | lock_time_add(&pcs->write_waittime, &stats.write_waittime); |
190 | 194 | ||
@@ -209,6 +213,7 @@ void clear_lock_stats(struct lock_class *class) | |||
209 | memset(cpu_stats, 0, sizeof(struct lock_class_stats)); | 213 | memset(cpu_stats, 0, sizeof(struct lock_class_stats)); |
210 | } | 214 | } |
211 | memset(class->contention_point, 0, sizeof(class->contention_point)); | 215 | memset(class->contention_point, 0, sizeof(class->contention_point)); |
216 | memset(class->contending_point, 0, sizeof(class->contending_point)); | ||
212 | } | 217 | } |
213 | 218 | ||
214 | static struct lock_class_stats *get_lock_stats(struct lock_class *class) | 219 | static struct lock_class_stats *get_lock_stats(struct lock_class *class) |
@@ -287,14 +292,12 @@ void lockdep_off(void) | |||
287 | { | 292 | { |
288 | current->lockdep_recursion++; | 293 | current->lockdep_recursion++; |
289 | } | 294 | } |
290 | |||
291 | EXPORT_SYMBOL(lockdep_off); | 295 | EXPORT_SYMBOL(lockdep_off); |
292 | 296 | ||
293 | void lockdep_on(void) | 297 | void lockdep_on(void) |
294 | { | 298 | { |
295 | current->lockdep_recursion--; | 299 | current->lockdep_recursion--; |
296 | } | 300 | } |
297 | |||
298 | EXPORT_SYMBOL(lockdep_on); | 301 | EXPORT_SYMBOL(lockdep_on); |
299 | 302 | ||
300 | /* | 303 | /* |
@@ -576,7 +579,8 @@ static void print_lock_class_header(struct lock_class *class, int depth) | |||
576 | /* | 579 | /* |
577 | * printk all lock dependencies starting at <entry>: | 580 | * printk all lock dependencies starting at <entry>: |
578 | */ | 581 | */ |
579 | static void print_lock_dependencies(struct lock_class *class, int depth) | 582 | static void __used |
583 | print_lock_dependencies(struct lock_class *class, int depth) | ||
580 | { | 584 | { |
581 | struct lock_list *entry; | 585 | struct lock_list *entry; |
582 | 586 | ||
@@ -2508,7 +2512,6 @@ void lockdep_init_map(struct lockdep_map *lock, const char *name, | |||
2508 | if (subclass) | 2512 | if (subclass) |
2509 | register_lock_class(lock, subclass, 1); | 2513 | register_lock_class(lock, subclass, 1); |
2510 | } | 2514 | } |
2511 | |||
2512 | EXPORT_SYMBOL_GPL(lockdep_init_map); | 2515 | EXPORT_SYMBOL_GPL(lockdep_init_map); |
2513 | 2516 | ||
2514 | /* | 2517 | /* |
@@ -2689,8 +2692,9 @@ static int check_unlock(struct task_struct *curr, struct lockdep_map *lock, | |||
2689 | } | 2692 | } |
2690 | 2693 | ||
2691 | static int | 2694 | static int |
2692 | __lock_set_subclass(struct lockdep_map *lock, | 2695 | __lock_set_class(struct lockdep_map *lock, const char *name, |
2693 | unsigned int subclass, unsigned long ip) | 2696 | struct lock_class_key *key, unsigned int subclass, |
2697 | unsigned long ip) | ||
2694 | { | 2698 | { |
2695 | struct task_struct *curr = current; | 2699 | struct task_struct *curr = current; |
2696 | struct held_lock *hlock, *prev_hlock; | 2700 | struct held_lock *hlock, *prev_hlock; |
@@ -2717,6 +2721,7 @@ __lock_set_subclass(struct lockdep_map *lock, | |||
2717 | return print_unlock_inbalance_bug(curr, lock, ip); | 2721 | return print_unlock_inbalance_bug(curr, lock, ip); |
2718 | 2722 | ||
2719 | found_it: | 2723 | found_it: |
2724 | lockdep_init_map(lock, name, key, 0); | ||
2720 | class = register_lock_class(lock, subclass, 0); | 2725 | class = register_lock_class(lock, subclass, 0); |
2721 | hlock->class_idx = class - lock_classes + 1; | 2726 | hlock->class_idx = class - lock_classes + 1; |
2722 | 2727 | ||
@@ -2901,9 +2906,9 @@ static void check_flags(unsigned long flags) | |||
2901 | #endif | 2906 | #endif |
2902 | } | 2907 | } |
2903 | 2908 | ||
2904 | void | 2909 | void lock_set_class(struct lockdep_map *lock, const char *name, |
2905 | lock_set_subclass(struct lockdep_map *lock, | 2910 | struct lock_class_key *key, unsigned int subclass, |
2906 | unsigned int subclass, unsigned long ip) | 2911 | unsigned long ip) |
2907 | { | 2912 | { |
2908 | unsigned long flags; | 2913 | unsigned long flags; |
2909 | 2914 | ||
@@ -2913,13 +2918,12 @@ lock_set_subclass(struct lockdep_map *lock, | |||
2913 | raw_local_irq_save(flags); | 2918 | raw_local_irq_save(flags); |
2914 | current->lockdep_recursion = 1; | 2919 | current->lockdep_recursion = 1; |
2915 | check_flags(flags); | 2920 | check_flags(flags); |
2916 | if (__lock_set_subclass(lock, subclass, ip)) | 2921 | if (__lock_set_class(lock, name, key, subclass, ip)) |
2917 | check_chain_key(current); | 2922 | check_chain_key(current); |
2918 | current->lockdep_recursion = 0; | 2923 | current->lockdep_recursion = 0; |
2919 | raw_local_irq_restore(flags); | 2924 | raw_local_irq_restore(flags); |
2920 | } | 2925 | } |
2921 | 2926 | EXPORT_SYMBOL_GPL(lock_set_class); | |
2922 | EXPORT_SYMBOL_GPL(lock_set_subclass); | ||
2923 | 2927 | ||
2924 | /* | 2928 | /* |
2925 | * We are not always called with irqs disabled - do that here, | 2929 | * We are not always called with irqs disabled - do that here, |
@@ -2943,7 +2947,6 @@ void lock_acquire(struct lockdep_map *lock, unsigned int subclass, | |||
2943 | current->lockdep_recursion = 0; | 2947 | current->lockdep_recursion = 0; |
2944 | raw_local_irq_restore(flags); | 2948 | raw_local_irq_restore(flags); |
2945 | } | 2949 | } |
2946 | |||
2947 | EXPORT_SYMBOL_GPL(lock_acquire); | 2950 | EXPORT_SYMBOL_GPL(lock_acquire); |
2948 | 2951 | ||
2949 | void lock_release(struct lockdep_map *lock, int nested, | 2952 | void lock_release(struct lockdep_map *lock, int nested, |
@@ -2961,7 +2964,6 @@ void lock_release(struct lockdep_map *lock, int nested, | |||
2961 | current->lockdep_recursion = 0; | 2964 | current->lockdep_recursion = 0; |
2962 | raw_local_irq_restore(flags); | 2965 | raw_local_irq_restore(flags); |
2963 | } | 2966 | } |
2964 | |||
2965 | EXPORT_SYMBOL_GPL(lock_release); | 2967 | EXPORT_SYMBOL_GPL(lock_release); |
2966 | 2968 | ||
2967 | #ifdef CONFIG_LOCK_STAT | 2969 | #ifdef CONFIG_LOCK_STAT |
@@ -2999,7 +3001,7 @@ __lock_contended(struct lockdep_map *lock, unsigned long ip) | |||
2999 | struct held_lock *hlock, *prev_hlock; | 3001 | struct held_lock *hlock, *prev_hlock; |
3000 | struct lock_class_stats *stats; | 3002 | struct lock_class_stats *stats; |
3001 | unsigned int depth; | 3003 | unsigned int depth; |
3002 | int i, point; | 3004 | int i, contention_point, contending_point; |
3003 | 3005 | ||
3004 | depth = curr->lockdep_depth; | 3006 | depth = curr->lockdep_depth; |
3005 | if (DEBUG_LOCKS_WARN_ON(!depth)) | 3007 | if (DEBUG_LOCKS_WARN_ON(!depth)) |
@@ -3023,18 +3025,22 @@ __lock_contended(struct lockdep_map *lock, unsigned long ip) | |||
3023 | found_it: | 3025 | found_it: |
3024 | hlock->waittime_stamp = sched_clock(); | 3026 | hlock->waittime_stamp = sched_clock(); |
3025 | 3027 | ||
3026 | point = lock_contention_point(hlock_class(hlock), ip); | 3028 | contention_point = lock_point(hlock_class(hlock)->contention_point, ip); |
3029 | contending_point = lock_point(hlock_class(hlock)->contending_point, | ||
3030 | lock->ip); | ||
3027 | 3031 | ||
3028 | stats = get_lock_stats(hlock_class(hlock)); | 3032 | stats = get_lock_stats(hlock_class(hlock)); |
3029 | if (point < ARRAY_SIZE(stats->contention_point)) | 3033 | if (contention_point < LOCKSTAT_POINTS) |
3030 | stats->contention_point[point]++; | 3034 | stats->contention_point[contention_point]++; |
3035 | if (contending_point < LOCKSTAT_POINTS) | ||
3036 | stats->contending_point[contending_point]++; | ||
3031 | if (lock->cpu != smp_processor_id()) | 3037 | if (lock->cpu != smp_processor_id()) |
3032 | stats->bounces[bounce_contended + !!hlock->read]++; | 3038 | stats->bounces[bounce_contended + !!hlock->read]++; |
3033 | put_lock_stats(stats); | 3039 | put_lock_stats(stats); |
3034 | } | 3040 | } |
3035 | 3041 | ||
3036 | static void | 3042 | static void |
3037 | __lock_acquired(struct lockdep_map *lock) | 3043 | __lock_acquired(struct lockdep_map *lock, unsigned long ip) |
3038 | { | 3044 | { |
3039 | struct task_struct *curr = current; | 3045 | struct task_struct *curr = current; |
3040 | struct held_lock *hlock, *prev_hlock; | 3046 | struct held_lock *hlock, *prev_hlock; |
@@ -3083,6 +3089,7 @@ found_it: | |||
3083 | put_lock_stats(stats); | 3089 | put_lock_stats(stats); |
3084 | 3090 | ||
3085 | lock->cpu = cpu; | 3091 | lock->cpu = cpu; |
3092 | lock->ip = ip; | ||
3086 | } | 3093 | } |
3087 | 3094 | ||
3088 | void lock_contended(struct lockdep_map *lock, unsigned long ip) | 3095 | void lock_contended(struct lockdep_map *lock, unsigned long ip) |
@@ -3104,7 +3111,7 @@ void lock_contended(struct lockdep_map *lock, unsigned long ip) | |||
3104 | } | 3111 | } |
3105 | EXPORT_SYMBOL_GPL(lock_contended); | 3112 | EXPORT_SYMBOL_GPL(lock_contended); |
3106 | 3113 | ||
3107 | void lock_acquired(struct lockdep_map *lock) | 3114 | void lock_acquired(struct lockdep_map *lock, unsigned long ip) |
3108 | { | 3115 | { |
3109 | unsigned long flags; | 3116 | unsigned long flags; |
3110 | 3117 | ||
@@ -3117,7 +3124,7 @@ void lock_acquired(struct lockdep_map *lock) | |||
3117 | raw_local_irq_save(flags); | 3124 | raw_local_irq_save(flags); |
3118 | check_flags(flags); | 3125 | check_flags(flags); |
3119 | current->lockdep_recursion = 1; | 3126 | current->lockdep_recursion = 1; |
3120 | __lock_acquired(lock); | 3127 | __lock_acquired(lock, ip); |
3121 | current->lockdep_recursion = 0; | 3128 | current->lockdep_recursion = 0; |
3122 | raw_local_irq_restore(flags); | 3129 | raw_local_irq_restore(flags); |
3123 | } | 3130 | } |
@@ -3276,10 +3283,10 @@ void __init lockdep_info(void) | |||
3276 | { | 3283 | { |
3277 | printk("Lock dependency validator: Copyright (c) 2006 Red Hat, Inc., Ingo Molnar\n"); | 3284 | printk("Lock dependency validator: Copyright (c) 2006 Red Hat, Inc., Ingo Molnar\n"); |
3278 | 3285 | ||
3279 | printk("... MAX_LOCKDEP_SUBCLASSES: %lu\n", MAX_LOCKDEP_SUBCLASSES); | 3286 | printk("... MAX_LOCKDEP_SUBCLASSES: %lu\n", MAX_LOCKDEP_SUBCLASSES); |
3280 | printk("... MAX_LOCK_DEPTH: %lu\n", MAX_LOCK_DEPTH); | 3287 | printk("... MAX_LOCK_DEPTH: %lu\n", MAX_LOCK_DEPTH); |
3281 | printk("... MAX_LOCKDEP_KEYS: %lu\n", MAX_LOCKDEP_KEYS); | 3288 | printk("... MAX_LOCKDEP_KEYS: %lu\n", MAX_LOCKDEP_KEYS); |
3282 | printk("... CLASSHASH_SIZE: %lu\n", CLASSHASH_SIZE); | 3289 | printk("... CLASSHASH_SIZE: %lu\n", CLASSHASH_SIZE); |
3283 | printk("... MAX_LOCKDEP_ENTRIES: %lu\n", MAX_LOCKDEP_ENTRIES); | 3290 | printk("... MAX_LOCKDEP_ENTRIES: %lu\n", MAX_LOCKDEP_ENTRIES); |
3284 | printk("... MAX_LOCKDEP_CHAINS: %lu\n", MAX_LOCKDEP_CHAINS); | 3291 | printk("... MAX_LOCKDEP_CHAINS: %lu\n", MAX_LOCKDEP_CHAINS); |
3285 | printk("... CHAINHASH_SIZE: %lu\n", CHAINHASH_SIZE); | 3292 | printk("... CHAINHASH_SIZE: %lu\n", CHAINHASH_SIZE); |
@@ -3441,7 +3448,6 @@ retry: | |||
3441 | if (unlock) | 3448 | if (unlock) |
3442 | read_unlock(&tasklist_lock); | 3449 | read_unlock(&tasklist_lock); |
3443 | } | 3450 | } |
3444 | |||
3445 | EXPORT_SYMBOL_GPL(debug_show_all_locks); | 3451 | EXPORT_SYMBOL_GPL(debug_show_all_locks); |
3446 | 3452 | ||
3447 | /* | 3453 | /* |
@@ -3462,7 +3468,6 @@ void debug_show_held_locks(struct task_struct *task) | |||
3462 | { | 3468 | { |
3463 | __debug_show_held_locks(task); | 3469 | __debug_show_held_locks(task); |
3464 | } | 3470 | } |
3465 | |||
3466 | EXPORT_SYMBOL_GPL(debug_show_held_locks); | 3471 | EXPORT_SYMBOL_GPL(debug_show_held_locks); |
3467 | 3472 | ||
3468 | void lockdep_sys_exit(void) | 3473 | void lockdep_sys_exit(void) |