diff options
Diffstat (limited to 'kernel/lockdep_proc.c')
| -rw-r--r-- | kernel/lockdep_proc.c | 128 |
1 files changed, 25 insertions, 103 deletions
diff --git a/kernel/lockdep_proc.c b/kernel/lockdep_proc.c index e94caa666dba..d4b3dbc79fdb 100644 --- a/kernel/lockdep_proc.c +++ b/kernel/lockdep_proc.c | |||
| @@ -25,38 +25,12 @@ | |||
| 25 | 25 | ||
| 26 | static void *l_next(struct seq_file *m, void *v, loff_t *pos) | 26 | static void *l_next(struct seq_file *m, void *v, loff_t *pos) |
| 27 | { | 27 | { |
| 28 | struct lock_class *class; | 28 | return seq_list_next(v, &all_lock_classes, pos); |
| 29 | |||
| 30 | (*pos)++; | ||
| 31 | |||
| 32 | if (v == SEQ_START_TOKEN) | ||
| 33 | class = m->private; | ||
| 34 | else { | ||
| 35 | class = v; | ||
| 36 | |||
| 37 | if (class->lock_entry.next != &all_lock_classes) | ||
| 38 | class = list_entry(class->lock_entry.next, | ||
| 39 | struct lock_class, lock_entry); | ||
| 40 | else | ||
| 41 | class = NULL; | ||
| 42 | } | ||
| 43 | |||
| 44 | return class; | ||
| 45 | } | 29 | } |
| 46 | 30 | ||
| 47 | static void *l_start(struct seq_file *m, loff_t *pos) | 31 | static void *l_start(struct seq_file *m, loff_t *pos) |
| 48 | { | 32 | { |
| 49 | struct lock_class *class; | 33 | return seq_list_start_head(&all_lock_classes, *pos); |
| 50 | loff_t i = 0; | ||
| 51 | |||
| 52 | if (*pos == 0) | ||
| 53 | return SEQ_START_TOKEN; | ||
| 54 | |||
| 55 | list_for_each_entry(class, &all_lock_classes, lock_entry) { | ||
| 56 | if (++i == *pos) | ||
| 57 | return class; | ||
| 58 | } | ||
| 59 | return NULL; | ||
| 60 | } | 34 | } |
| 61 | 35 | ||
| 62 | static void l_stop(struct seq_file *m, void *v) | 36 | static void l_stop(struct seq_file *m, void *v) |
| @@ -82,11 +56,11 @@ static void print_name(struct seq_file *m, struct lock_class *class) | |||
| 82 | 56 | ||
| 83 | static int l_show(struct seq_file *m, void *v) | 57 | static int l_show(struct seq_file *m, void *v) |
| 84 | { | 58 | { |
| 85 | struct lock_class *class = v; | 59 | struct lock_class *class = list_entry(v, struct lock_class, lock_entry); |
| 86 | struct lock_list *entry; | 60 | struct lock_list *entry; |
| 87 | char usage[LOCK_USAGE_CHARS]; | 61 | char usage[LOCK_USAGE_CHARS]; |
| 88 | 62 | ||
| 89 | if (v == SEQ_START_TOKEN) { | 63 | if (v == &all_lock_classes) { |
| 90 | seq_printf(m, "all lock classes:\n"); | 64 | seq_printf(m, "all lock classes:\n"); |
| 91 | return 0; | 65 | return 0; |
| 92 | } | 66 | } |
| @@ -128,17 +102,7 @@ static const struct seq_operations lockdep_ops = { | |||
| 128 | 102 | ||
| 129 | static int lockdep_open(struct inode *inode, struct file *file) | 103 | static int lockdep_open(struct inode *inode, struct file *file) |
| 130 | { | 104 | { |
| 131 | int res = seq_open(file, &lockdep_ops); | 105 | return seq_open(file, &lockdep_ops); |
| 132 | if (!res) { | ||
| 133 | struct seq_file *m = file->private_data; | ||
| 134 | |||
| 135 | if (!list_empty(&all_lock_classes)) | ||
| 136 | m->private = list_entry(all_lock_classes.next, | ||
| 137 | struct lock_class, lock_entry); | ||
| 138 | else | ||
| 139 | m->private = NULL; | ||
| 140 | } | ||
| 141 | return res; | ||
| 142 | } | 106 | } |
| 143 | 107 | ||
| 144 | static const struct file_operations proc_lockdep_operations = { | 108 | static const struct file_operations proc_lockdep_operations = { |
| @@ -149,37 +113,23 @@ static const struct file_operations proc_lockdep_operations = { | |||
| 149 | }; | 113 | }; |
| 150 | 114 | ||
| 151 | #ifdef CONFIG_PROVE_LOCKING | 115 | #ifdef CONFIG_PROVE_LOCKING |
| 152 | static void *lc_next(struct seq_file *m, void *v, loff_t *pos) | ||
| 153 | { | ||
| 154 | struct lock_chain *chain; | ||
| 155 | |||
| 156 | (*pos)++; | ||
| 157 | |||
| 158 | if (v == SEQ_START_TOKEN) | ||
| 159 | chain = m->private; | ||
| 160 | else { | ||
| 161 | chain = v; | ||
| 162 | |||
| 163 | if (*pos < nr_lock_chains) | ||
| 164 | chain = lock_chains + *pos; | ||
| 165 | else | ||
| 166 | chain = NULL; | ||
| 167 | } | ||
| 168 | |||
| 169 | return chain; | ||
| 170 | } | ||
| 171 | |||
| 172 | static void *lc_start(struct seq_file *m, loff_t *pos) | 116 | static void *lc_start(struct seq_file *m, loff_t *pos) |
| 173 | { | 117 | { |
| 174 | if (*pos == 0) | 118 | if (*pos == 0) |
| 175 | return SEQ_START_TOKEN; | 119 | return SEQ_START_TOKEN; |
| 176 | 120 | ||
| 177 | if (*pos < nr_lock_chains) | 121 | if (*pos - 1 < nr_lock_chains) |
| 178 | return lock_chains + *pos; | 122 | return lock_chains + (*pos - 1); |
| 179 | 123 | ||
| 180 | return NULL; | 124 | return NULL; |
| 181 | } | 125 | } |
| 182 | 126 | ||
| 127 | static void *lc_next(struct seq_file *m, void *v, loff_t *pos) | ||
| 128 | { | ||
| 129 | (*pos)++; | ||
| 130 | return lc_start(m, pos); | ||
| 131 | } | ||
| 132 | |||
| 183 | static void lc_stop(struct seq_file *m, void *v) | 133 | static void lc_stop(struct seq_file *m, void *v) |
| 184 | { | 134 | { |
| 185 | } | 135 | } |
| @@ -220,16 +170,7 @@ static const struct seq_operations lockdep_chains_ops = { | |||
| 220 | 170 | ||
| 221 | static int lockdep_chains_open(struct inode *inode, struct file *file) | 171 | static int lockdep_chains_open(struct inode *inode, struct file *file) |
| 222 | { | 172 | { |
| 223 | int res = seq_open(file, &lockdep_chains_ops); | 173 | return seq_open(file, &lockdep_chains_ops); |
| 224 | if (!res) { | ||
| 225 | struct seq_file *m = file->private_data; | ||
| 226 | |||
| 227 | if (nr_lock_chains) | ||
| 228 | m->private = lock_chains; | ||
| 229 | else | ||
| 230 | m->private = NULL; | ||
| 231 | } | ||
| 232 | return res; | ||
| 233 | } | 174 | } |
| 234 | 175 | ||
| 235 | static const struct file_operations proc_lockdep_chains_operations = { | 176 | static const struct file_operations proc_lockdep_chains_operations = { |
| @@ -258,16 +199,10 @@ static void lockdep_stats_debug_show(struct seq_file *m) | |||
| 258 | debug_atomic_read(&chain_lookup_hits)); | 199 | debug_atomic_read(&chain_lookup_hits)); |
| 259 | seq_printf(m, " cyclic checks: %11u\n", | 200 | seq_printf(m, " cyclic checks: %11u\n", |
| 260 | debug_atomic_read(&nr_cyclic_checks)); | 201 | debug_atomic_read(&nr_cyclic_checks)); |
| 261 | seq_printf(m, " cyclic-check recursions: %11u\n", | ||
| 262 | debug_atomic_read(&nr_cyclic_check_recursions)); | ||
| 263 | seq_printf(m, " find-mask forwards checks: %11u\n", | 202 | seq_printf(m, " find-mask forwards checks: %11u\n", |
| 264 | debug_atomic_read(&nr_find_usage_forwards_checks)); | 203 | debug_atomic_read(&nr_find_usage_forwards_checks)); |
| 265 | seq_printf(m, " find-mask forwards recursions: %11u\n", | ||
| 266 | debug_atomic_read(&nr_find_usage_forwards_recursions)); | ||
| 267 | seq_printf(m, " find-mask backwards checks: %11u\n", | 204 | seq_printf(m, " find-mask backwards checks: %11u\n", |
| 268 | debug_atomic_read(&nr_find_usage_backwards_checks)); | 205 | debug_atomic_read(&nr_find_usage_backwards_checks)); |
| 269 | seq_printf(m, " find-mask backwards recursions:%11u\n", | ||
| 270 | debug_atomic_read(&nr_find_usage_backwards_recursions)); | ||
| 271 | 206 | ||
| 272 | seq_printf(m, " hardirq on events: %11u\n", hi1); | 207 | seq_printf(m, " hardirq on events: %11u\n", hi1); |
| 273 | seq_printf(m, " hardirq off events: %11u\n", hi2); | 208 | seq_printf(m, " hardirq off events: %11u\n", hi2); |
| @@ -409,8 +344,10 @@ static int lockdep_stats_show(struct seq_file *m, void *v) | |||
| 409 | nr_unused); | 344 | nr_unused); |
| 410 | seq_printf(m, " max locking depth: %11u\n", | 345 | seq_printf(m, " max locking depth: %11u\n", |
| 411 | max_lockdep_depth); | 346 | max_lockdep_depth); |
| 412 | seq_printf(m, " max recursion depth: %11u\n", | 347 | #ifdef CONFIG_PROVE_LOCKING |
| 413 | max_recursion_depth); | 348 | seq_printf(m, " max bfs queue depth: %11u\n", |
| 349 | max_bfs_queue_depth); | ||
| 350 | #endif | ||
| 414 | lockdep_stats_debug_show(m); | 351 | lockdep_stats_debug_show(m); |
| 415 | seq_printf(m, " debug_locks: %11u\n", | 352 | seq_printf(m, " debug_locks: %11u\n", |
| 416 | debug_locks); | 353 | debug_locks); |
| @@ -438,7 +375,6 @@ struct lock_stat_data { | |||
| 438 | }; | 375 | }; |
| 439 | 376 | ||
| 440 | struct lock_stat_seq { | 377 | struct lock_stat_seq { |
| 441 | struct lock_stat_data *iter; | ||
| 442 | struct lock_stat_data *iter_end; | 378 | struct lock_stat_data *iter_end; |
| 443 | struct lock_stat_data stats[MAX_LOCKDEP_KEYS]; | 379 | struct lock_stat_data stats[MAX_LOCKDEP_KEYS]; |
| 444 | }; | 380 | }; |
| @@ -626,34 +562,22 @@ static void seq_header(struct seq_file *m) | |||
| 626 | static void *ls_start(struct seq_file *m, loff_t *pos) | 562 | static void *ls_start(struct seq_file *m, loff_t *pos) |
| 627 | { | 563 | { |
| 628 | struct lock_stat_seq *data = m->private; | 564 | struct lock_stat_seq *data = m->private; |
| 565 | struct lock_stat_data *iter; | ||
| 629 | 566 | ||
| 630 | if (*pos == 0) | 567 | if (*pos == 0) |
| 631 | return SEQ_START_TOKEN; | 568 | return SEQ_START_TOKEN; |
| 632 | 569 | ||
| 633 | data->iter = data->stats + *pos; | 570 | iter = data->stats + (*pos - 1); |
| 634 | if (data->iter >= data->iter_end) | 571 | if (iter >= data->iter_end) |
| 635 | data->iter = NULL; | 572 | iter = NULL; |
| 636 | 573 | ||
| 637 | return data->iter; | 574 | return iter; |
| 638 | } | 575 | } |
| 639 | 576 | ||
| 640 | static void *ls_next(struct seq_file *m, void *v, loff_t *pos) | 577 | static void *ls_next(struct seq_file *m, void *v, loff_t *pos) |
| 641 | { | 578 | { |
| 642 | struct lock_stat_seq *data = m->private; | ||
| 643 | |||
| 644 | (*pos)++; | 579 | (*pos)++; |
| 645 | 580 | return ls_start(m, pos); | |
| 646 | if (v == SEQ_START_TOKEN) | ||
| 647 | data->iter = data->stats; | ||
| 648 | else { | ||
| 649 | data->iter = v; | ||
| 650 | data->iter++; | ||
| 651 | } | ||
| 652 | |||
| 653 | if (data->iter == data->iter_end) | ||
| 654 | data->iter = NULL; | ||
| 655 | |||
| 656 | return data->iter; | ||
| 657 | } | 581 | } |
| 658 | 582 | ||
| 659 | static void ls_stop(struct seq_file *m, void *v) | 583 | static void ls_stop(struct seq_file *m, void *v) |
| @@ -691,7 +615,6 @@ static int lock_stat_open(struct inode *inode, struct file *file) | |||
| 691 | struct lock_stat_data *iter = data->stats; | 615 | struct lock_stat_data *iter = data->stats; |
| 692 | struct seq_file *m = file->private_data; | 616 | struct seq_file *m = file->private_data; |
| 693 | 617 | ||
| 694 | data->iter = iter; | ||
| 695 | list_for_each_entry(class, &all_lock_classes, lock_entry) { | 618 | list_for_each_entry(class, &all_lock_classes, lock_entry) { |
| 696 | iter->class = class; | 619 | iter->class = class; |
| 697 | iter->stats = lock_stats(class); | 620 | iter->stats = lock_stats(class); |
| @@ -699,7 +622,7 @@ static int lock_stat_open(struct inode *inode, struct file *file) | |||
| 699 | } | 622 | } |
| 700 | data->iter_end = iter; | 623 | data->iter_end = iter; |
| 701 | 624 | ||
| 702 | sort(data->stats, data->iter_end - data->iter, | 625 | sort(data->stats, data->iter_end - data->stats, |
| 703 | sizeof(struct lock_stat_data), | 626 | sizeof(struct lock_stat_data), |
| 704 | lock_stat_cmp, NULL); | 627 | lock_stat_cmp, NULL); |
| 705 | 628 | ||
| @@ -734,7 +657,6 @@ static int lock_stat_release(struct inode *inode, struct file *file) | |||
| 734 | struct seq_file *seq = file->private_data; | 657 | struct seq_file *seq = file->private_data; |
| 735 | 658 | ||
| 736 | vfree(seq->private); | 659 | vfree(seq->private); |
| 737 | seq->private = NULL; | ||
| 738 | return seq_release(inode, file); | 660 | return seq_release(inode, file); |
| 739 | } | 661 | } |
| 740 | 662 | ||
