lockdep_proc.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675
  1. /*
  2. * kernel/lockdep_proc.c
  3. *
  4. * Runtime locking correctness validator
  5. *
  6. * Started by Ingo Molnar:
  7. *
  8. * Copyright (C) 2006,2007 Red Hat, Inc., Ingo Molnar <mingo@redhat.com>
  9. * Copyright (C) 2007 Red Hat, Inc., Peter Zijlstra <pzijlstr@redhat.com>
  10. *
  11. * Code for /proc/lockdep and /proc/lockdep_stats:
  12. *
  13. */
  14. #include <linux/module.h>
  15. #include <linux/proc_fs.h>
  16. #include <linux/seq_file.h>
  17. #include <linux/kallsyms.h>
  18. #include <linux/debug_locks.h>
  19. #include <linux/vmalloc.h>
  20. #include <linux/sort.h>
  21. #include <asm/uaccess.h>
  22. #include <asm/div64.h>
  23. #include "lockdep_internals.h"
  24. static void *l_next(struct seq_file *m, void *v, loff_t *pos)
  25. {
  26. struct lock_class *class;
  27. (*pos)++;
  28. if (v == SEQ_START_TOKEN)
  29. class = m->private;
  30. else {
  31. class = v;
  32. if (class->lock_entry.next != &all_lock_classes)
  33. class = list_entry(class->lock_entry.next,
  34. struct lock_class, lock_entry);
  35. else
  36. class = NULL;
  37. }
  38. return class;
  39. }
  40. static void *l_start(struct seq_file *m, loff_t *pos)
  41. {
  42. struct lock_class *class;
  43. loff_t i = 0;
  44. if (*pos == 0)
  45. return SEQ_START_TOKEN;
  46. list_for_each_entry(class, &all_lock_classes, lock_entry) {
  47. if (++i == *pos)
  48. return class;
  49. }
  50. return NULL;
  51. }
  52. static void l_stop(struct seq_file *m, void *v)
  53. {
  54. }
  55. static unsigned long count_forward_deps(struct lock_class *class)
  56. {
  57. struct lock_list *entry;
  58. unsigned long ret = 1;
  59. /*
  60. * Recurse this class's dependency list:
  61. */
  62. list_for_each_entry(entry, &class->locks_after, entry)
  63. ret += count_forward_deps(entry->class);
  64. return ret;
  65. }
  66. static unsigned long count_backward_deps(struct lock_class *class)
  67. {
  68. struct lock_list *entry;
  69. unsigned long ret = 1;
  70. /*
  71. * Recurse this class's dependency list:
  72. */
  73. list_for_each_entry(entry, &class->locks_before, entry)
  74. ret += count_backward_deps(entry->class);
  75. return ret;
  76. }
  77. static void print_name(struct seq_file *m, struct lock_class *class)
  78. {
  79. char str[128];
  80. const char *name = class->name;
  81. if (!name) {
  82. name = __get_key_name(class->key, str);
  83. seq_printf(m, "%s", name);
  84. } else{
  85. seq_printf(m, "%s", name);
  86. if (class->name_version > 1)
  87. seq_printf(m, "#%d", class->name_version);
  88. if (class->subclass)
  89. seq_printf(m, "/%d", class->subclass);
  90. }
  91. }
  92. static int l_show(struct seq_file *m, void *v)
  93. {
  94. unsigned long nr_forward_deps, nr_backward_deps;
  95. struct lock_class *class = v;
  96. struct lock_list *entry;
  97. char c1, c2, c3, c4;
  98. if (v == SEQ_START_TOKEN) {
  99. seq_printf(m, "all lock classes:\n");
  100. return 0;
  101. }
  102. seq_printf(m, "%p", class->key);
  103. #ifdef CONFIG_DEBUG_LOCKDEP
  104. seq_printf(m, " OPS:%8ld", class->ops);
  105. #endif
  106. nr_forward_deps = count_forward_deps(class);
  107. seq_printf(m, " FD:%5ld", nr_forward_deps);
  108. nr_backward_deps = count_backward_deps(class);
  109. seq_printf(m, " BD:%5ld", nr_backward_deps);
  110. get_usage_chars(class, &c1, &c2, &c3, &c4);
  111. seq_printf(m, " %c%c%c%c", c1, c2, c3, c4);
  112. seq_printf(m, ": ");
  113. print_name(m, class);
  114. seq_puts(m, "\n");
  115. list_for_each_entry(entry, &class->locks_after, entry) {
  116. if (entry->distance == 1) {
  117. seq_printf(m, " -> [%p] ", entry->class);
  118. print_name(m, entry->class);
  119. seq_puts(m, "\n");
  120. }
  121. }
  122. seq_puts(m, "\n");
  123. return 0;
  124. }
  125. static const struct seq_operations lockdep_ops = {
  126. .start = l_start,
  127. .next = l_next,
  128. .stop = l_stop,
  129. .show = l_show,
  130. };
  131. static int lockdep_open(struct inode *inode, struct file *file)
  132. {
  133. int res = seq_open(file, &lockdep_ops);
  134. if (!res) {
  135. struct seq_file *m = file->private_data;
  136. if (!list_empty(&all_lock_classes))
  137. m->private = list_entry(all_lock_classes.next,
  138. struct lock_class, lock_entry);
  139. else
  140. m->private = NULL;
  141. }
  142. return res;
  143. }
  144. static const struct file_operations proc_lockdep_operations = {
  145. .open = lockdep_open,
  146. .read = seq_read,
  147. .llseek = seq_lseek,
  148. .release = seq_release,
  149. };
  150. static void lockdep_stats_debug_show(struct seq_file *m)
  151. {
  152. #ifdef CONFIG_DEBUG_LOCKDEP
  153. unsigned int hi1 = debug_atomic_read(&hardirqs_on_events),
  154. hi2 = debug_atomic_read(&hardirqs_off_events),
  155. hr1 = debug_atomic_read(&redundant_hardirqs_on),
  156. hr2 = debug_atomic_read(&redundant_hardirqs_off),
  157. si1 = debug_atomic_read(&softirqs_on_events),
  158. si2 = debug_atomic_read(&softirqs_off_events),
  159. sr1 = debug_atomic_read(&redundant_softirqs_on),
  160. sr2 = debug_atomic_read(&redundant_softirqs_off);
  161. seq_printf(m, " chain lookup misses: %11u\n",
  162. debug_atomic_read(&chain_lookup_misses));
  163. seq_printf(m, " chain lookup hits: %11u\n",
  164. debug_atomic_read(&chain_lookup_hits));
  165. seq_printf(m, " cyclic checks: %11u\n",
  166. debug_atomic_read(&nr_cyclic_checks));
  167. seq_printf(m, " cyclic-check recursions: %11u\n",
  168. debug_atomic_read(&nr_cyclic_check_recursions));
  169. seq_printf(m, " find-mask forwards checks: %11u\n",
  170. debug_atomic_read(&nr_find_usage_forwards_checks));
  171. seq_printf(m, " find-mask forwards recursions: %11u\n",
  172. debug_atomic_read(&nr_find_usage_forwards_recursions));
  173. seq_printf(m, " find-mask backwards checks: %11u\n",
  174. debug_atomic_read(&nr_find_usage_backwards_checks));
  175. seq_printf(m, " find-mask backwards recursions:%11u\n",
  176. debug_atomic_read(&nr_find_usage_backwards_recursions));
  177. seq_printf(m, " hardirq on events: %11u\n", hi1);
  178. seq_printf(m, " hardirq off events: %11u\n", hi2);
  179. seq_printf(m, " redundant hardirq ons: %11u\n", hr1);
  180. seq_printf(m, " redundant hardirq offs: %11u\n", hr2);
  181. seq_printf(m, " softirq on events: %11u\n", si1);
  182. seq_printf(m, " softirq off events: %11u\n", si2);
  183. seq_printf(m, " redundant softirq ons: %11u\n", sr1);
  184. seq_printf(m, " redundant softirq offs: %11u\n", sr2);
  185. #endif
  186. }
  187. static int lockdep_stats_show(struct seq_file *m, void *v)
  188. {
  189. struct lock_class *class;
  190. unsigned long nr_unused = 0, nr_uncategorized = 0,
  191. nr_irq_safe = 0, nr_irq_unsafe = 0,
  192. nr_softirq_safe = 0, nr_softirq_unsafe = 0,
  193. nr_hardirq_safe = 0, nr_hardirq_unsafe = 0,
  194. nr_irq_read_safe = 0, nr_irq_read_unsafe = 0,
  195. nr_softirq_read_safe = 0, nr_softirq_read_unsafe = 0,
  196. nr_hardirq_read_safe = 0, nr_hardirq_read_unsafe = 0,
  197. sum_forward_deps = 0, factor = 0;
  198. list_for_each_entry(class, &all_lock_classes, lock_entry) {
  199. if (class->usage_mask == 0)
  200. nr_unused++;
  201. if (class->usage_mask == LOCKF_USED)
  202. nr_uncategorized++;
  203. if (class->usage_mask & LOCKF_USED_IN_IRQ)
  204. nr_irq_safe++;
  205. if (class->usage_mask & LOCKF_ENABLED_IRQS)
  206. nr_irq_unsafe++;
  207. if (class->usage_mask & LOCKF_USED_IN_SOFTIRQ)
  208. nr_softirq_safe++;
  209. if (class->usage_mask & LOCKF_ENABLED_SOFTIRQS)
  210. nr_softirq_unsafe++;
  211. if (class->usage_mask & LOCKF_USED_IN_HARDIRQ)
  212. nr_hardirq_safe++;
  213. if (class->usage_mask & LOCKF_ENABLED_HARDIRQS)
  214. nr_hardirq_unsafe++;
  215. if (class->usage_mask & LOCKF_USED_IN_IRQ_READ)
  216. nr_irq_read_safe++;
  217. if (class->usage_mask & LOCKF_ENABLED_IRQS_READ)
  218. nr_irq_read_unsafe++;
  219. if (class->usage_mask & LOCKF_USED_IN_SOFTIRQ_READ)
  220. nr_softirq_read_safe++;
  221. if (class->usage_mask & LOCKF_ENABLED_SOFTIRQS_READ)
  222. nr_softirq_read_unsafe++;
  223. if (class->usage_mask & LOCKF_USED_IN_HARDIRQ_READ)
  224. nr_hardirq_read_safe++;
  225. if (class->usage_mask & LOCKF_ENABLED_HARDIRQS_READ)
  226. nr_hardirq_read_unsafe++;
  227. sum_forward_deps += count_forward_deps(class);
  228. }
  229. #ifdef CONFIG_DEBUG_LOCKDEP
  230. DEBUG_LOCKS_WARN_ON(debug_atomic_read(&nr_unused_locks) != nr_unused);
  231. #endif
  232. seq_printf(m, " lock-classes: %11lu [max: %lu]\n",
  233. nr_lock_classes, MAX_LOCKDEP_KEYS);
  234. seq_printf(m, " direct dependencies: %11lu [max: %lu]\n",
  235. nr_list_entries, MAX_LOCKDEP_ENTRIES);
  236. seq_printf(m, " indirect dependencies: %11lu\n",
  237. sum_forward_deps);
  238. /*
  239. * Total number of dependencies:
  240. *
  241. * All irq-safe locks may nest inside irq-unsafe locks,
  242. * plus all the other known dependencies:
  243. */
  244. seq_printf(m, " all direct dependencies: %11lu\n",
  245. nr_irq_unsafe * nr_irq_safe +
  246. nr_hardirq_unsafe * nr_hardirq_safe +
  247. nr_list_entries);
  248. /*
  249. * Estimated factor between direct and indirect
  250. * dependencies:
  251. */
  252. if (nr_list_entries)
  253. factor = sum_forward_deps / nr_list_entries;
  254. #ifdef CONFIG_PROVE_LOCKING
  255. seq_printf(m, " dependency chains: %11lu [max: %lu]\n",
  256. nr_lock_chains, MAX_LOCKDEP_CHAINS);
  257. #endif
  258. #ifdef CONFIG_TRACE_IRQFLAGS
  259. seq_printf(m, " in-hardirq chains: %11u\n",
  260. nr_hardirq_chains);
  261. seq_printf(m, " in-softirq chains: %11u\n",
  262. nr_softirq_chains);
  263. #endif
  264. seq_printf(m, " in-process chains: %11u\n",
  265. nr_process_chains);
  266. seq_printf(m, " stack-trace entries: %11lu [max: %lu]\n",
  267. nr_stack_trace_entries, MAX_STACK_TRACE_ENTRIES);
  268. seq_printf(m, " combined max dependencies: %11u\n",
  269. (nr_hardirq_chains + 1) *
  270. (nr_softirq_chains + 1) *
  271. (nr_process_chains + 1)
  272. );
  273. seq_printf(m, " hardirq-safe locks: %11lu\n",
  274. nr_hardirq_safe);
  275. seq_printf(m, " hardirq-unsafe locks: %11lu\n",
  276. nr_hardirq_unsafe);
  277. seq_printf(m, " softirq-safe locks: %11lu\n",
  278. nr_softirq_safe);
  279. seq_printf(m, " softirq-unsafe locks: %11lu\n",
  280. nr_softirq_unsafe);
  281. seq_printf(m, " irq-safe locks: %11lu\n",
  282. nr_irq_safe);
  283. seq_printf(m, " irq-unsafe locks: %11lu\n",
  284. nr_irq_unsafe);
  285. seq_printf(m, " hardirq-read-safe locks: %11lu\n",
  286. nr_hardirq_read_safe);
  287. seq_printf(m, " hardirq-read-unsafe locks: %11lu\n",
  288. nr_hardirq_read_unsafe);
  289. seq_printf(m, " softirq-read-safe locks: %11lu\n",
  290. nr_softirq_read_safe);
  291. seq_printf(m, " softirq-read-unsafe locks: %11lu\n",
  292. nr_softirq_read_unsafe);
  293. seq_printf(m, " irq-read-safe locks: %11lu\n",
  294. nr_irq_read_safe);
  295. seq_printf(m, " irq-read-unsafe locks: %11lu\n",
  296. nr_irq_read_unsafe);
  297. seq_printf(m, " uncategorized locks: %11lu\n",
  298. nr_uncategorized);
  299. seq_printf(m, " unused locks: %11lu\n",
  300. nr_unused);
  301. seq_printf(m, " max locking depth: %11u\n",
  302. max_lockdep_depth);
  303. seq_printf(m, " max recursion depth: %11u\n",
  304. max_recursion_depth);
  305. lockdep_stats_debug_show(m);
  306. seq_printf(m, " debug_locks: %11u\n",
  307. debug_locks);
  308. return 0;
  309. }
  310. static int lockdep_stats_open(struct inode *inode, struct file *file)
  311. {
  312. return single_open(file, lockdep_stats_show, NULL);
  313. }
  314. static const struct file_operations proc_lockdep_stats_operations = {
  315. .open = lockdep_stats_open,
  316. .read = seq_read,
  317. .llseek = seq_lseek,
  318. .release = single_release,
  319. };
  320. #ifdef CONFIG_LOCK_STAT
  321. struct lock_stat_data {
  322. struct lock_class *class;
  323. struct lock_class_stats stats;
  324. };
  325. struct lock_stat_seq {
  326. struct lock_stat_data *iter;
  327. struct lock_stat_data *iter_end;
  328. struct lock_stat_data stats[MAX_LOCKDEP_KEYS];
  329. };
  330. /*
  331. * sort on absolute number of contentions
  332. */
  333. static int lock_stat_cmp(const void *l, const void *r)
  334. {
  335. const struct lock_stat_data *dl = l, *dr = r;
  336. unsigned long nl, nr;
  337. nl = dl->stats.read_waittime.nr + dl->stats.write_waittime.nr;
  338. nr = dr->stats.read_waittime.nr + dr->stats.write_waittime.nr;
  339. return nr - nl;
  340. }
  341. static void seq_line(struct seq_file *m, char c, int offset, int length)
  342. {
  343. int i;
  344. for (i = 0; i < offset; i++)
  345. seq_puts(m, " ");
  346. for (i = 0; i < length; i++)
  347. seq_printf(m, "%c", c);
  348. seq_puts(m, "\n");
  349. }
  350. static void snprint_time(char *buf, size_t bufsiz, s64 nr)
  351. {
  352. unsigned long rem;
  353. rem = do_div(nr, 1000); /* XXX: do_div_signed */
  354. snprintf(buf, bufsiz, "%lld.%02d", (long long)nr, ((int)rem+5)/10);
  355. }
  356. static void seq_time(struct seq_file *m, s64 time)
  357. {
  358. char num[15];
  359. snprint_time(num, sizeof(num), time);
  360. seq_printf(m, " %14s", num);
  361. }
  362. static void seq_lock_time(struct seq_file *m, struct lock_time *lt)
  363. {
  364. seq_printf(m, "%14lu", lt->nr);
  365. seq_time(m, lt->min);
  366. seq_time(m, lt->max);
  367. seq_time(m, lt->total);
  368. }
  369. static void seq_stats(struct seq_file *m, struct lock_stat_data *data)
  370. {
  371. char name[39];
  372. struct lock_class *class;
  373. struct lock_class_stats *stats;
  374. int i, namelen;
  375. class = data->class;
  376. stats = &data->stats;
  377. namelen = 38;
  378. if (class->name_version > 1)
  379. namelen -= 2; /* XXX truncates versions > 9 */
  380. if (class->subclass)
  381. namelen -= 2;
  382. if (!class->name) {
  383. char str[KSYM_NAME_LEN];
  384. const char *key_name;
  385. key_name = __get_key_name(class->key, str);
  386. snprintf(name, namelen, "%s", key_name);
  387. } else {
  388. snprintf(name, namelen, "%s", class->name);
  389. }
  390. namelen = strlen(name);
  391. if (class->name_version > 1) {
  392. snprintf(name+namelen, 3, "#%d", class->name_version);
  393. namelen += 2;
  394. }
  395. if (class->subclass) {
  396. snprintf(name+namelen, 3, "/%d", class->subclass);
  397. namelen += 2;
  398. }
  399. if (stats->write_holdtime.nr) {
  400. if (stats->read_holdtime.nr)
  401. seq_printf(m, "%38s-W:", name);
  402. else
  403. seq_printf(m, "%40s:", name);
  404. seq_printf(m, "%14lu ", stats->bounces[bounce_contended_write]);
  405. seq_lock_time(m, &stats->write_waittime);
  406. seq_printf(m, " %14lu ", stats->bounces[bounce_acquired_write]);
  407. seq_lock_time(m, &stats->write_holdtime);
  408. seq_puts(m, "\n");
  409. }
  410. if (stats->read_holdtime.nr) {
  411. seq_printf(m, "%38s-R:", name);
  412. seq_printf(m, "%14lu ", stats->bounces[bounce_contended_read]);
  413. seq_lock_time(m, &stats->read_waittime);
  414. seq_printf(m, " %14lu ", stats->bounces[bounce_acquired_read]);
  415. seq_lock_time(m, &stats->read_holdtime);
  416. seq_puts(m, "\n");
  417. }
  418. if (stats->read_waittime.nr + stats->write_waittime.nr == 0)
  419. return;
  420. if (stats->read_holdtime.nr)
  421. namelen += 2;
  422. for (i = 0; i < ARRAY_SIZE(class->contention_point); i++) {
  423. char sym[KSYM_SYMBOL_LEN];
  424. char ip[32];
  425. if (class->contention_point[i] == 0)
  426. break;
  427. if (!i)
  428. seq_line(m, '-', 40-namelen, namelen);
  429. sprint_symbol(sym, class->contention_point[i]);
  430. snprintf(ip, sizeof(ip), "[<%p>]",
  431. (void *)class->contention_point[i]);
  432. seq_printf(m, "%40s %14lu %29s %s\n", name,
  433. stats->contention_point[i],
  434. ip, sym);
  435. }
  436. if (i) {
  437. seq_puts(m, "\n");
  438. seq_line(m, '.', 0, 40 + 1 + 10 * (14 + 1));
  439. seq_puts(m, "\n");
  440. }
  441. }
  442. static void seq_header(struct seq_file *m)
  443. {
  444. seq_printf(m, "lock_stat version 0.2\n");
  445. seq_line(m, '-', 0, 40 + 1 + 10 * (14 + 1));
  446. seq_printf(m, "%40s %14s %14s %14s %14s %14s %14s %14s %14s "
  447. "%14s %14s\n",
  448. "class name",
  449. "con-bounces",
  450. "contentions",
  451. "waittime-min",
  452. "waittime-max",
  453. "waittime-total",
  454. "acq-bounces",
  455. "acquisitions",
  456. "holdtime-min",
  457. "holdtime-max",
  458. "holdtime-total");
  459. seq_line(m, '-', 0, 40 + 1 + 10 * (14 + 1));
  460. seq_printf(m, "\n");
  461. }
  462. static void *ls_start(struct seq_file *m, loff_t *pos)
  463. {
  464. struct lock_stat_seq *data = m->private;
  465. if (*pos == 0)
  466. return SEQ_START_TOKEN;
  467. data->iter = data->stats + *pos;
  468. if (data->iter >= data->iter_end)
  469. data->iter = NULL;
  470. return data->iter;
  471. }
  472. static void *ls_next(struct seq_file *m, void *v, loff_t *pos)
  473. {
  474. struct lock_stat_seq *data = m->private;
  475. (*pos)++;
  476. if (v == SEQ_START_TOKEN)
  477. data->iter = data->stats;
  478. else {
  479. data->iter = v;
  480. data->iter++;
  481. }
  482. if (data->iter == data->iter_end)
  483. data->iter = NULL;
  484. return data->iter;
  485. }
  486. static void ls_stop(struct seq_file *m, void *v)
  487. {
  488. }
  489. static int ls_show(struct seq_file *m, void *v)
  490. {
  491. if (v == SEQ_START_TOKEN)
  492. seq_header(m);
  493. else
  494. seq_stats(m, v);
  495. return 0;
  496. }
  497. static struct seq_operations lockstat_ops = {
  498. .start = ls_start,
  499. .next = ls_next,
  500. .stop = ls_stop,
  501. .show = ls_show,
  502. };
  503. static int lock_stat_open(struct inode *inode, struct file *file)
  504. {
  505. int res;
  506. struct lock_class *class;
  507. struct lock_stat_seq *data = vmalloc(sizeof(struct lock_stat_seq));
  508. if (!data)
  509. return -ENOMEM;
  510. res = seq_open(file, &lockstat_ops);
  511. if (!res) {
  512. struct lock_stat_data *iter = data->stats;
  513. struct seq_file *m = file->private_data;
  514. data->iter = iter;
  515. list_for_each_entry(class, &all_lock_classes, lock_entry) {
  516. iter->class = class;
  517. iter->stats = lock_stats(class);
  518. iter++;
  519. }
  520. data->iter_end = iter;
  521. sort(data->stats, data->iter_end - data->iter,
  522. sizeof(struct lock_stat_data),
  523. lock_stat_cmp, NULL);
  524. m->private = data;
  525. } else
  526. vfree(data);
  527. return res;
  528. }
  529. static ssize_t lock_stat_write(struct file *file, const char __user *buf,
  530. size_t count, loff_t *ppos)
  531. {
  532. struct lock_class *class;
  533. char c;
  534. if (count) {
  535. if (get_user(c, buf))
  536. return -EFAULT;
  537. if (c != '0')
  538. return count;
  539. list_for_each_entry(class, &all_lock_classes, lock_entry)
  540. clear_lock_stats(class);
  541. }
  542. return count;
  543. }
  544. static int lock_stat_release(struct inode *inode, struct file *file)
  545. {
  546. struct seq_file *seq = file->private_data;
  547. vfree(seq->private);
  548. seq->private = NULL;
  549. return seq_release(inode, file);
  550. }
  551. static const struct file_operations proc_lock_stat_operations = {
  552. .open = lock_stat_open,
  553. .write = lock_stat_write,
  554. .read = seq_read,
  555. .llseek = seq_lseek,
  556. .release = lock_stat_release,
  557. };
  558. #endif /* CONFIG_LOCK_STAT */
  559. static int __init lockdep_proc_init(void)
  560. {
  561. proc_create("lockdep", S_IRUSR, NULL, &proc_lockdep_operations);
  562. proc_create("lockdep_stats", S_IRUSR, NULL,
  563. &proc_lockdep_stats_operations);
  564. #ifdef CONFIG_LOCK_STAT
  565. proc_create("lock_stat", S_IRUSR, NULL, &proc_lock_stat_operations);
  566. #endif
  567. return 0;
  568. }
  569. __initcall(lockdep_proc_init);