Commit fb7275a
locking/lockdep: Iterate lock_classes directly when reading lockdep files
When dumping lock_classes information via /proc/lockdep, we can't take
the lockdep lock as the lock hold time is indeterminate. Iterating
over all_lock_classes without holding lock can be dangerous as there
is a slight chance that it may branch off to other lists leading to
infinite loop or even access invalid memory if changes are made to
all_lock_classes list in parallel.
To avoid this problem, iteration of lock classes is now done directly
on the lock_classes array itself. The lock_classes_in_use bitmap is
checked to see if the lock class is being used. To avoid iterating
the full array all the times, a new max_lock_class_idx value is added
to track the maximum lock_class index that is currently being used.
We can theoretically take the lockdep lock for iterating all_lock_classes
when other lockdep files (lockdep_stats and lock_stat) are accessed as
the lock hold time will be shorter for them. For consistency, they are
also modified to iterate the lock_classes array directly.
Signed-off-by: Waiman Long <[email protected]>
Signed-off-by: Peter Zijlstra (Intel) <[email protected]>
Link: https://lkml.kernel.org/r/[email protected]1 parent b008893 commit fb7275a
3 files changed
+56
-15
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
183 | 183 | | |
184 | 184 | | |
185 | 185 | | |
186 | | - | |
187 | | - | |
188 | | - | |
| 186 | + | |
189 | 187 | | |
190 | | - | |
| 188 | + | |
191 | 189 | | |
192 | 190 | | |
193 | 191 | | |
| |||
338 | 336 | | |
339 | 337 | | |
340 | 338 | | |
341 | | - | |
| 339 | + | |
342 | 340 | | |
343 | 341 | | |
344 | 342 | | |
| |||
1252 | 1250 | | |
1253 | 1251 | | |
1254 | 1252 | | |
| 1253 | + | |
1255 | 1254 | | |
1256 | 1255 | | |
1257 | 1256 | | |
| |||
1317 | 1316 | | |
1318 | 1317 | | |
1319 | 1318 | | |
| 1319 | + | |
| 1320 | + | |
| 1321 | + | |
1320 | 1322 | | |
1321 | 1323 | | |
1322 | 1324 | | |
| |||
6000 | 6002 | | |
6001 | 6003 | | |
6002 | 6004 | | |
| 6005 | + | |
| 6006 | + | |
6003 | 6007 | | |
6004 | 6008 | | |
6005 | 6009 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
121 | 121 | | |
122 | 122 | | |
123 | 123 | | |
124 | | - | |
125 | 124 | | |
126 | 125 | | |
127 | 126 | | |
| |||
151 | 150 | | |
152 | 151 | | |
153 | 152 | | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
154 | 157 | | |
155 | 158 | | |
156 | 159 | | |
| |||
205 | 208 | | |
206 | 209 | | |
207 | 210 | | |
208 | | - | |
209 | 211 | | |
210 | 212 | | |
211 | 213 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
24 | 24 | | |
25 | 25 | | |
26 | 26 | | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
27 | 38 | | |
28 | 39 | | |
29 | | - | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
30 | 45 | | |
31 | 46 | | |
32 | 47 | | |
33 | 48 | | |
34 | | - | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
35 | 54 | | |
36 | 55 | | |
37 | 56 | | |
| |||
57 | 76 | | |
58 | 77 | | |
59 | 78 | | |
60 | | - | |
| 79 | + | |
61 | 80 | | |
62 | 81 | | |
| 82 | + | |
63 | 83 | | |
64 | | - | |
| 84 | + | |
65 | 85 | | |
| 86 | + | |
| 87 | + | |
66 | 88 | | |
67 | | - | |
68 | 89 | | |
69 | 90 | | |
70 | 91 | | |
| |||
220 | 241 | | |
221 | 242 | | |
222 | 243 | | |
| 244 | + | |
223 | 245 | | |
224 | | - | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
225 | 249 | | |
226 | 250 | | |
227 | 251 | | |
| |||
254 | 278 | | |
255 | 279 | | |
256 | 280 | | |
| 281 | + | |
257 | 282 | | |
258 | 283 | | |
259 | 284 | | |
| |||
345 | 370 | | |
346 | 371 | | |
347 | 372 | | |
| 373 | + | |
| 374 | + | |
348 | 375 | | |
349 | 376 | | |
350 | 377 | | |
| |||
622 | 649 | | |
623 | 650 | | |
624 | 651 | | |
| 652 | + | |
625 | 653 | | |
626 | | - | |
| 654 | + | |
| 655 | + | |
| 656 | + | |
627 | 657 | | |
628 | 658 | | |
629 | 659 | | |
630 | 660 | | |
| 661 | + | |
631 | 662 | | |
632 | 663 | | |
633 | 664 | | |
| |||
645 | 676 | | |
646 | 677 | | |
647 | 678 | | |
| 679 | + | |
648 | 680 | | |
649 | 681 | | |
650 | 682 | | |
| |||
654 | 686 | | |
655 | 687 | | |
656 | 688 | | |
657 | | - | |
| 689 | + | |
| 690 | + | |
| 691 | + | |
658 | 692 | | |
| 693 | + | |
659 | 694 | | |
660 | 695 | | |
661 | 696 | | |
| |||
0 commit comments