locking-selftest.c 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218
  1. /*
  2. * lib/locking-selftest.c
  3. *
  4. * Testsuite for various locking APIs: spinlocks, rwlocks,
  5. * mutexes and rw-semaphores.
  6. *
  7. * It is checking both false positives and false negatives.
  8. *
  9. * Started by Ingo Molnar:
  10. *
  11. * Copyright (C) 2006 Red Hat, Inc., Ingo Molnar <mingo@redhat.com>
  12. */
  13. #include <linux/rwsem.h>
  14. #include <linux/mutex.h>
  15. #include <linux/sched.h>
  16. #include <linux/delay.h>
  17. #include <linux/module.h>
  18. #include <linux/lockdep.h>
  19. #include <linux/spinlock.h>
  20. #include <linux/kallsyms.h>
  21. #include <linux/interrupt.h>
  22. #include <linux/debug_locks.h>
  23. #include <linux/irqflags.h>
  24. /*
  25. * Change this to 1 if you want to see the failure printouts:
  26. */
  27. static unsigned int debug_locks_verbose;
  28. static int __init setup_debug_locks_verbose(char *str)
  29. {
  30. get_option(&str, &debug_locks_verbose);
  31. return 1;
  32. }
  33. __setup("debug_locks_verbose=", setup_debug_locks_verbose);
  34. #define FAILURE 0
  35. #define SUCCESS 1
  36. #define LOCKTYPE_SPIN 0x1
  37. #define LOCKTYPE_RWLOCK 0x2
  38. #define LOCKTYPE_MUTEX 0x4
  39. #define LOCKTYPE_RWSEM 0x8
  40. /*
  41. * Normal standalone locks, for the circular and irq-context
  42. * dependency tests:
  43. */
  44. static DEFINE_SPINLOCK(lock_A);
  45. static DEFINE_SPINLOCK(lock_B);
  46. static DEFINE_SPINLOCK(lock_C);
  47. static DEFINE_SPINLOCK(lock_D);
  48. static DEFINE_RWLOCK(rwlock_A);
  49. static DEFINE_RWLOCK(rwlock_B);
  50. static DEFINE_RWLOCK(rwlock_C);
  51. static DEFINE_RWLOCK(rwlock_D);
  52. static DEFINE_MUTEX(mutex_A);
  53. static DEFINE_MUTEX(mutex_B);
  54. static DEFINE_MUTEX(mutex_C);
  55. static DEFINE_MUTEX(mutex_D);
  56. static DECLARE_RWSEM(rwsem_A);
  57. static DECLARE_RWSEM(rwsem_B);
  58. static DECLARE_RWSEM(rwsem_C);
  59. static DECLARE_RWSEM(rwsem_D);
  60. /*
  61. * Locks that we initialize dynamically as well so that
  62. * e.g. X1 and X2 becomes two instances of the same class,
  63. * but X* and Y* are different classes. We do this so that
  64. * we do not trigger a real lockup:
  65. */
  66. static DEFINE_SPINLOCK(lock_X1);
  67. static DEFINE_SPINLOCK(lock_X2);
  68. static DEFINE_SPINLOCK(lock_Y1);
  69. static DEFINE_SPINLOCK(lock_Y2);
  70. static DEFINE_SPINLOCK(lock_Z1);
  71. static DEFINE_SPINLOCK(lock_Z2);
  72. static DEFINE_RWLOCK(rwlock_X1);
  73. static DEFINE_RWLOCK(rwlock_X2);
  74. static DEFINE_RWLOCK(rwlock_Y1);
  75. static DEFINE_RWLOCK(rwlock_Y2);
  76. static DEFINE_RWLOCK(rwlock_Z1);
  77. static DEFINE_RWLOCK(rwlock_Z2);
  78. static DEFINE_MUTEX(mutex_X1);
  79. static DEFINE_MUTEX(mutex_X2);
  80. static DEFINE_MUTEX(mutex_Y1);
  81. static DEFINE_MUTEX(mutex_Y2);
  82. static DEFINE_MUTEX(mutex_Z1);
  83. static DEFINE_MUTEX(mutex_Z2);
  84. static DECLARE_RWSEM(rwsem_X1);
  85. static DECLARE_RWSEM(rwsem_X2);
  86. static DECLARE_RWSEM(rwsem_Y1);
  87. static DECLARE_RWSEM(rwsem_Y2);
  88. static DECLARE_RWSEM(rwsem_Z1);
  89. static DECLARE_RWSEM(rwsem_Z2);
  90. /*
  91. * non-inlined runtime initializers, to let separate locks share
  92. * the same lock-class:
  93. */
  94. #define INIT_CLASS_FUNC(class) \
  95. static noinline void \
  96. init_class_##class(spinlock_t *lock, rwlock_t *rwlock, struct mutex *mutex, \
  97. struct rw_semaphore *rwsem) \
  98. { \
  99. spin_lock_init(lock); \
  100. rwlock_init(rwlock); \
  101. mutex_init(mutex); \
  102. init_rwsem(rwsem); \
  103. }
  104. INIT_CLASS_FUNC(X)
  105. INIT_CLASS_FUNC(Y)
  106. INIT_CLASS_FUNC(Z)
  107. static void init_shared_classes(void)
  108. {
  109. init_class_X(&lock_X1, &rwlock_X1, &mutex_X1, &rwsem_X1);
  110. init_class_X(&lock_X2, &rwlock_X2, &mutex_X2, &rwsem_X2);
  111. init_class_Y(&lock_Y1, &rwlock_Y1, &mutex_Y1, &rwsem_Y1);
  112. init_class_Y(&lock_Y2, &rwlock_Y2, &mutex_Y2, &rwsem_Y2);
  113. init_class_Z(&lock_Z1, &rwlock_Z1, &mutex_Z1, &rwsem_Z1);
  114. init_class_Z(&lock_Z2, &rwlock_Z2, &mutex_Z2, &rwsem_Z2);
  115. }
  116. /*
  117. * For spinlocks and rwlocks we also do hardirq-safe / softirq-safe tests.
  118. * The following functions use a lock from a simulated hardirq/softirq
  119. * context, causing the locks to be marked as hardirq-safe/softirq-safe:
  120. */
  121. #define HARDIRQ_DISABLE local_irq_disable
  122. #define HARDIRQ_ENABLE local_irq_enable
  123. #define HARDIRQ_ENTER() \
  124. local_irq_disable(); \
  125. irq_enter(); \
  126. WARN_ON(!in_irq());
  127. #define HARDIRQ_EXIT() \
  128. __irq_exit(); \
  129. local_irq_enable();
  130. #define SOFTIRQ_DISABLE local_bh_disable
  131. #define SOFTIRQ_ENABLE local_bh_enable
  132. #define SOFTIRQ_ENTER() \
  133. local_bh_disable(); \
  134. local_irq_disable(); \
  135. trace_softirq_enter(); \
  136. WARN_ON(!in_softirq());
  137. #define SOFTIRQ_EXIT() \
  138. trace_softirq_exit(); \
  139. local_irq_enable(); \
  140. local_bh_enable();
  141. /*
  142. * Shortcuts for lock/unlock API variants, to keep
  143. * the testcases compact:
  144. */
  145. #define L(x) spin_lock(&lock_##x)
  146. #define U(x) spin_unlock(&lock_##x)
  147. #define LU(x) L(x); U(x)
  148. #define SI(x) spin_lock_init(&lock_##x)
  149. #define WL(x) write_lock(&rwlock_##x)
  150. #define WU(x) write_unlock(&rwlock_##x)
  151. #define WLU(x) WL(x); WU(x)
  152. #define RL(x) read_lock(&rwlock_##x)
  153. #define RU(x) read_unlock(&rwlock_##x)
  154. #define RLU(x) RL(x); RU(x)
  155. #define RWI(x) rwlock_init(&rwlock_##x)
  156. #define ML(x) mutex_lock(&mutex_##x)
  157. #define MU(x) mutex_unlock(&mutex_##x)
  158. #define MI(x) mutex_init(&mutex_##x)
  159. #define WSL(x) down_write(&rwsem_##x)
  160. #define WSU(x) up_write(&rwsem_##x)
  161. #define RSL(x) down_read(&rwsem_##x)
  162. #define RSU(x) up_read(&rwsem_##x)
  163. #define RWSI(x) init_rwsem(&rwsem_##x)
  164. #define LOCK_UNLOCK_2(x,y) LOCK(x); LOCK(y); UNLOCK(y); UNLOCK(x)
  165. /*
  166. * Generate different permutations of the same testcase, using
  167. * the same basic lock-dependency/state events:
  168. */
  169. #define GENERATE_TESTCASE(name) \
  170. \
  171. static void name(void) { E(); }
  172. #define GENERATE_PERMUTATIONS_2_EVENTS(name) \
  173. \
  174. static void name##_12(void) { E1(); E2(); } \
  175. static void name##_21(void) { E2(); E1(); }
  176. #define GENERATE_PERMUTATIONS_3_EVENTS(name) \
  177. \
  178. static void name##_123(void) { E1(); E2(); E3(); } \
  179. static void name##_132(void) { E1(); E3(); E2(); } \
  180. static void name##_213(void) { E2(); E1(); E3(); } \
  181. static void name##_231(void) { E2(); E3(); E1(); } \
  182. static void name##_312(void) { E3(); E1(); E2(); } \
  183. static void name##_321(void) { E3(); E2(); E1(); }
  184. /*
  185. * AA deadlock:
  186. */
  187. #define E() \
  188. \
  189. LOCK(X1); \
  190. LOCK(X2); /* this one should fail */
  191. /*
  192. * 6 testcases:
  193. */
  194. #include "locking-selftest-spin.h"
  195. GENERATE_TESTCASE(AA_spin)
  196. #include "locking-selftest-wlock.h"
  197. GENERATE_TESTCASE(AA_wlock)
  198. #include "locking-selftest-rlock.h"
  199. GENERATE_TESTCASE(AA_rlock)
  200. #include "locking-selftest-mutex.h"
  201. GENERATE_TESTCASE(AA_mutex)
  202. #include "locking-selftest-wsem.h"
  203. GENERATE_TESTCASE(AA_wsem)
  204. #include "locking-selftest-rsem.h"
  205. GENERATE_TESTCASE(AA_rsem)
  206. #undef E
  207. /*
  208. * Special-case for read-locking, they are
  209. * allowed to recurse on the same lock class:
  210. */
  211. static void rlock_AA1(void)
  212. {
  213. RL(X1);
  214. RL(X1); // this one should NOT fail
  215. }
  216. static void rlock_AA1B(void)
  217. {
  218. RL(X1);
  219. RL(X2); // this one should NOT fail
  220. }
  221. static void rsem_AA1(void)
  222. {
  223. RSL(X1);
  224. RSL(X1); // this one should fail
  225. }
  226. static void rsem_AA1B(void)
  227. {
  228. RSL(X1);
  229. RSL(X2); // this one should fail
  230. }
  231. /*
  232. * The mixing of read and write locks is not allowed:
  233. */
  234. static void rlock_AA2(void)
  235. {
  236. RL(X1);
  237. WL(X2); // this one should fail
  238. }
  239. static void rsem_AA2(void)
  240. {
  241. RSL(X1);
  242. WSL(X2); // this one should fail
  243. }
  244. static void rlock_AA3(void)
  245. {
  246. WL(X1);
  247. RL(X2); // this one should fail
  248. }
  249. static void rsem_AA3(void)
  250. {
  251. WSL(X1);
  252. RSL(X2); // this one should fail
  253. }
  254. /*
  255. * ABBA deadlock:
  256. */
  257. #define E() \
  258. \
  259. LOCK_UNLOCK_2(A, B); \
  260. LOCK_UNLOCK_2(B, A); /* fail */
  261. /*
  262. * 6 testcases:
  263. */
  264. #include "locking-selftest-spin.h"
  265. GENERATE_TESTCASE(ABBA_spin)
  266. #include "locking-selftest-wlock.h"
  267. GENERATE_TESTCASE(ABBA_wlock)
  268. #include "locking-selftest-rlock.h"
  269. GENERATE_TESTCASE(ABBA_rlock)
  270. #include "locking-selftest-mutex.h"
  271. GENERATE_TESTCASE(ABBA_mutex)
  272. #include "locking-selftest-wsem.h"
  273. GENERATE_TESTCASE(ABBA_wsem)
  274. #include "locking-selftest-rsem.h"
  275. GENERATE_TESTCASE(ABBA_rsem)
  276. #undef E
  277. /*
  278. * AB BC CA deadlock:
  279. */
  280. #define E() \
  281. \
  282. LOCK_UNLOCK_2(A, B); \
  283. LOCK_UNLOCK_2(B, C); \
  284. LOCK_UNLOCK_2(C, A); /* fail */
  285. /*
  286. * 6 testcases:
  287. */
  288. #include "locking-selftest-spin.h"
  289. GENERATE_TESTCASE(ABBCCA_spin)
  290. #include "locking-selftest-wlock.h"
  291. GENERATE_TESTCASE(ABBCCA_wlock)
  292. #include "locking-selftest-rlock.h"
  293. GENERATE_TESTCASE(ABBCCA_rlock)
  294. #include "locking-selftest-mutex.h"
  295. GENERATE_TESTCASE(ABBCCA_mutex)
  296. #include "locking-selftest-wsem.h"
  297. GENERATE_TESTCASE(ABBCCA_wsem)
  298. #include "locking-selftest-rsem.h"
  299. GENERATE_TESTCASE(ABBCCA_rsem)
  300. #undef E
  301. /*
  302. * AB CA BC deadlock:
  303. */
  304. #define E() \
  305. \
  306. LOCK_UNLOCK_2(A, B); \
  307. LOCK_UNLOCK_2(C, A); \
  308. LOCK_UNLOCK_2(B, C); /* fail */
  309. /*
  310. * 6 testcases:
  311. */
  312. #include "locking-selftest-spin.h"
  313. GENERATE_TESTCASE(ABCABC_spin)
  314. #include "locking-selftest-wlock.h"
  315. GENERATE_TESTCASE(ABCABC_wlock)
  316. #include "locking-selftest-rlock.h"
  317. GENERATE_TESTCASE(ABCABC_rlock)
  318. #include "locking-selftest-mutex.h"
  319. GENERATE_TESTCASE(ABCABC_mutex)
  320. #include "locking-selftest-wsem.h"
  321. GENERATE_TESTCASE(ABCABC_wsem)
  322. #include "locking-selftest-rsem.h"
  323. GENERATE_TESTCASE(ABCABC_rsem)
  324. #undef E
  325. /*
  326. * AB BC CD DA deadlock:
  327. */
  328. #define E() \
  329. \
  330. LOCK_UNLOCK_2(A, B); \
  331. LOCK_UNLOCK_2(B, C); \
  332. LOCK_UNLOCK_2(C, D); \
  333. LOCK_UNLOCK_2(D, A); /* fail */
  334. /*
  335. * 6 testcases:
  336. */
  337. #include "locking-selftest-spin.h"
  338. GENERATE_TESTCASE(ABBCCDDA_spin)
  339. #include "locking-selftest-wlock.h"
  340. GENERATE_TESTCASE(ABBCCDDA_wlock)
  341. #include "locking-selftest-rlock.h"
  342. GENERATE_TESTCASE(ABBCCDDA_rlock)
  343. #include "locking-selftest-mutex.h"
  344. GENERATE_TESTCASE(ABBCCDDA_mutex)
  345. #include "locking-selftest-wsem.h"
  346. GENERATE_TESTCASE(ABBCCDDA_wsem)
  347. #include "locking-selftest-rsem.h"
  348. GENERATE_TESTCASE(ABBCCDDA_rsem)
  349. #undef E
  350. /*
  351. * AB CD BD DA deadlock:
  352. */
  353. #define E() \
  354. \
  355. LOCK_UNLOCK_2(A, B); \
  356. LOCK_UNLOCK_2(C, D); \
  357. LOCK_UNLOCK_2(B, D); \
  358. LOCK_UNLOCK_2(D, A); /* fail */
  359. /*
  360. * 6 testcases:
  361. */
  362. #include "locking-selftest-spin.h"
  363. GENERATE_TESTCASE(ABCDBDDA_spin)
  364. #include "locking-selftest-wlock.h"
  365. GENERATE_TESTCASE(ABCDBDDA_wlock)
  366. #include "locking-selftest-rlock.h"
  367. GENERATE_TESTCASE(ABCDBDDA_rlock)
  368. #include "locking-selftest-mutex.h"
  369. GENERATE_TESTCASE(ABCDBDDA_mutex)
  370. #include "locking-selftest-wsem.h"
  371. GENERATE_TESTCASE(ABCDBDDA_wsem)
  372. #include "locking-selftest-rsem.h"
  373. GENERATE_TESTCASE(ABCDBDDA_rsem)
  374. #undef E
  375. /*
  376. * AB CD BC DA deadlock:
  377. */
  378. #define E() \
  379. \
  380. LOCK_UNLOCK_2(A, B); \
  381. LOCK_UNLOCK_2(C, D); \
  382. LOCK_UNLOCK_2(B, C); \
  383. LOCK_UNLOCK_2(D, A); /* fail */
  384. /*
  385. * 6 testcases:
  386. */
  387. #include "locking-selftest-spin.h"
  388. GENERATE_TESTCASE(ABCDBCDA_spin)
  389. #include "locking-selftest-wlock.h"
  390. GENERATE_TESTCASE(ABCDBCDA_wlock)
  391. #include "locking-selftest-rlock.h"
  392. GENERATE_TESTCASE(ABCDBCDA_rlock)
  393. #include "locking-selftest-mutex.h"
  394. GENERATE_TESTCASE(ABCDBCDA_mutex)
  395. #include "locking-selftest-wsem.h"
  396. GENERATE_TESTCASE(ABCDBCDA_wsem)
  397. #include "locking-selftest-rsem.h"
  398. GENERATE_TESTCASE(ABCDBCDA_rsem)
  399. #undef E
  400. /*
  401. * Double unlock:
  402. */
  403. #define E() \
  404. \
  405. LOCK(A); \
  406. UNLOCK(A); \
  407. UNLOCK(A); /* fail */
  408. /*
  409. * 6 testcases:
  410. */
  411. #include "locking-selftest-spin.h"
  412. GENERATE_TESTCASE(double_unlock_spin)
  413. #include "locking-selftest-wlock.h"
  414. GENERATE_TESTCASE(double_unlock_wlock)
  415. #include "locking-selftest-rlock.h"
  416. GENERATE_TESTCASE(double_unlock_rlock)
  417. #include "locking-selftest-mutex.h"
  418. GENERATE_TESTCASE(double_unlock_mutex)
  419. #include "locking-selftest-wsem.h"
  420. GENERATE_TESTCASE(double_unlock_wsem)
  421. #include "locking-selftest-rsem.h"
  422. GENERATE_TESTCASE(double_unlock_rsem)
  423. #undef E
  424. /*
  425. * Bad unlock ordering:
  426. */
  427. #define E() \
  428. \
  429. LOCK(A); \
  430. LOCK(B); \
  431. UNLOCK(A); /* fail */ \
  432. UNLOCK(B);
  433. /*
  434. * 6 testcases:
  435. */
  436. #include "locking-selftest-spin.h"
  437. GENERATE_TESTCASE(bad_unlock_order_spin)
  438. #include "locking-selftest-wlock.h"
  439. GENERATE_TESTCASE(bad_unlock_order_wlock)
  440. #include "locking-selftest-rlock.h"
  441. GENERATE_TESTCASE(bad_unlock_order_rlock)
  442. #include "locking-selftest-mutex.h"
  443. GENERATE_TESTCASE(bad_unlock_order_mutex)
  444. #include "locking-selftest-wsem.h"
  445. GENERATE_TESTCASE(bad_unlock_order_wsem)
  446. #include "locking-selftest-rsem.h"
  447. GENERATE_TESTCASE(bad_unlock_order_rsem)
  448. #undef E
  449. /*
  450. * initializing a held lock:
  451. */
  452. #define E() \
  453. \
  454. LOCK(A); \
  455. INIT(A); /* fail */
  456. /*
  457. * 6 testcases:
  458. */
  459. #include "locking-selftest-spin.h"
  460. GENERATE_TESTCASE(init_held_spin)
  461. #include "locking-selftest-wlock.h"
  462. GENERATE_TESTCASE(init_held_wlock)
  463. #include "locking-selftest-rlock.h"
  464. GENERATE_TESTCASE(init_held_rlock)
  465. #include "locking-selftest-mutex.h"
  466. GENERATE_TESTCASE(init_held_mutex)
  467. #include "locking-selftest-wsem.h"
  468. GENERATE_TESTCASE(init_held_wsem)
  469. #include "locking-selftest-rsem.h"
  470. GENERATE_TESTCASE(init_held_rsem)
  471. #undef E
  472. /*
  473. * locking an irq-safe lock with irqs enabled:
  474. */
  475. #define E1() \
  476. \
  477. IRQ_ENTER(); \
  478. LOCK(A); \
  479. UNLOCK(A); \
  480. IRQ_EXIT();
  481. #define E2() \
  482. \
  483. LOCK(A); \
  484. UNLOCK(A);
  485. /*
  486. * Generate 24 testcases:
  487. */
  488. #include "locking-selftest-spin-hardirq.h"
  489. GENERATE_PERMUTATIONS_2_EVENTS(irqsafe1_hard_spin)
  490. #include "locking-selftest-rlock-hardirq.h"
  491. GENERATE_PERMUTATIONS_2_EVENTS(irqsafe1_hard_rlock)
  492. #include "locking-selftest-wlock-hardirq.h"
  493. GENERATE_PERMUTATIONS_2_EVENTS(irqsafe1_hard_wlock)
  494. #include "locking-selftest-spin-softirq.h"
  495. GENERATE_PERMUTATIONS_2_EVENTS(irqsafe1_soft_spin)
  496. #include "locking-selftest-rlock-softirq.h"
  497. GENERATE_PERMUTATIONS_2_EVENTS(irqsafe1_soft_rlock)
  498. #include "locking-selftest-wlock-softirq.h"
  499. GENERATE_PERMUTATIONS_2_EVENTS(irqsafe1_soft_wlock)
  500. #undef E1
  501. #undef E2
  502. /*
  503. * Enabling hardirqs with a softirq-safe lock held:
  504. */
  505. #define E1() \
  506. \
  507. SOFTIRQ_ENTER(); \
  508. LOCK(A); \
  509. UNLOCK(A); \
  510. SOFTIRQ_EXIT();
  511. #define E2() \
  512. \
  513. HARDIRQ_DISABLE(); \
  514. LOCK(A); \
  515. HARDIRQ_ENABLE(); \
  516. UNLOCK(A);
  517. /*
  518. * Generate 12 testcases:
  519. */
  520. #include "locking-selftest-spin.h"
  521. GENERATE_PERMUTATIONS_2_EVENTS(irqsafe2A_spin)
  522. #include "locking-selftest-wlock.h"
  523. GENERATE_PERMUTATIONS_2_EVENTS(irqsafe2A_wlock)
  524. #include "locking-selftest-rlock.h"
  525. GENERATE_PERMUTATIONS_2_EVENTS(irqsafe2A_rlock)
  526. #undef E1
  527. #undef E2
  528. /*
  529. * Enabling irqs with an irq-safe lock held:
  530. */
  531. #define E1() \
  532. \
  533. IRQ_ENTER(); \
  534. LOCK(A); \
  535. UNLOCK(A); \
  536. IRQ_EXIT();
  537. #define E2() \
  538. \
  539. IRQ_DISABLE(); \
  540. LOCK(A); \
  541. IRQ_ENABLE(); \
  542. UNLOCK(A);
  543. /*
  544. * Generate 24 testcases:
  545. */
  546. #include "locking-selftest-spin-hardirq.h"
  547. GENERATE_PERMUTATIONS_2_EVENTS(irqsafe2B_hard_spin)
  548. #include "locking-selftest-rlock-hardirq.h"
  549. GENERATE_PERMUTATIONS_2_EVENTS(irqsafe2B_hard_rlock)
  550. #include "locking-selftest-wlock-hardirq.h"
  551. GENERATE_PERMUTATIONS_2_EVENTS(irqsafe2B_hard_wlock)
  552. #include "locking-selftest-spin-softirq.h"
  553. GENERATE_PERMUTATIONS_2_EVENTS(irqsafe2B_soft_spin)
  554. #include "locking-selftest-rlock-softirq.h"
  555. GENERATE_PERMUTATIONS_2_EVENTS(irqsafe2B_soft_rlock)
  556. #include "locking-selftest-wlock-softirq.h"
  557. GENERATE_PERMUTATIONS_2_EVENTS(irqsafe2B_soft_wlock)
  558. #undef E1
  559. #undef E2
  560. /*
  561. * Acquiring a irq-unsafe lock while holding an irq-safe-lock:
  562. */
  563. #define E1() \
  564. \
  565. LOCK(A); \
  566. LOCK(B); \
  567. UNLOCK(B); \
  568. UNLOCK(A); \
  569. #define E2() \
  570. \
  571. LOCK(B); \
  572. UNLOCK(B);
  573. #define E3() \
  574. \
  575. IRQ_ENTER(); \
  576. LOCK(A); \
  577. UNLOCK(A); \
  578. IRQ_EXIT();
  579. /*
  580. * Generate 36 testcases:
  581. */
  582. #include "locking-selftest-spin-hardirq.h"
  583. GENERATE_PERMUTATIONS_3_EVENTS(irqsafe3_hard_spin)
  584. #include "locking-selftest-rlock-hardirq.h"
  585. GENERATE_PERMUTATIONS_3_EVENTS(irqsafe3_hard_rlock)
  586. #include "locking-selftest-wlock-hardirq.h"
  587. GENERATE_PERMUTATIONS_3_EVENTS(irqsafe3_hard_wlock)
  588. #include "locking-selftest-spin-softirq.h"
  589. GENERATE_PERMUTATIONS_3_EVENTS(irqsafe3_soft_spin)
  590. #include "locking-selftest-rlock-softirq.h"
  591. GENERATE_PERMUTATIONS_3_EVENTS(irqsafe3_soft_rlock)
  592. #include "locking-selftest-wlock-softirq.h"
  593. GENERATE_PERMUTATIONS_3_EVENTS(irqsafe3_soft_wlock)
  594. #undef E1
  595. #undef E2
  596. #undef E3
  597. /*
  598. * If a lock turns into softirq-safe, but earlier it took
  599. * a softirq-unsafe lock:
  600. */
  601. #define E1() \
  602. IRQ_DISABLE(); \
  603. LOCK(A); \
  604. LOCK(B); \
  605. UNLOCK(B); \
  606. UNLOCK(A); \
  607. IRQ_ENABLE();
  608. #define E2() \
  609. LOCK(B); \
  610. UNLOCK(B);
  611. #define E3() \
  612. IRQ_ENTER(); \
  613. LOCK(A); \
  614. UNLOCK(A); \
  615. IRQ_EXIT();
  616. /*
  617. * Generate 36 testcases:
  618. */
  619. #include "locking-selftest-spin-hardirq.h"
  620. GENERATE_PERMUTATIONS_3_EVENTS(irqsafe4_hard_spin)
  621. #include "locking-selftest-rlock-hardirq.h"
  622. GENERATE_PERMUTATIONS_3_EVENTS(irqsafe4_hard_rlock)
  623. #include "locking-selftest-wlock-hardirq.h"
  624. GENERATE_PERMUTATIONS_3_EVENTS(irqsafe4_hard_wlock)
  625. #include "locking-selftest-spin-softirq.h"
  626. GENERATE_PERMUTATIONS_3_EVENTS(irqsafe4_soft_spin)
  627. #include "locking-selftest-rlock-softirq.h"
  628. GENERATE_PERMUTATIONS_3_EVENTS(irqsafe4_soft_rlock)
  629. #include "locking-selftest-wlock-softirq.h"
  630. GENERATE_PERMUTATIONS_3_EVENTS(irqsafe4_soft_wlock)
  631. #undef E1
  632. #undef E2
  633. #undef E3
  634. /*
  635. * read-lock / write-lock irq inversion.
  636. *
  637. * Deadlock scenario:
  638. *
  639. * CPU#1 is at #1, i.e. it has write-locked A, but has not
  640. * taken B yet.
  641. *
  642. * CPU#2 is at #2, i.e. it has locked B.
  643. *
  644. * Hardirq hits CPU#2 at point #2 and is trying to read-lock A.
  645. *
  646. * The deadlock occurs because CPU#1 will spin on B, and CPU#2
  647. * will spin on A.
  648. */
  649. #define E1() \
  650. \
  651. IRQ_DISABLE(); \
  652. WL(A); \
  653. LOCK(B); \
  654. UNLOCK(B); \
  655. WU(A); \
  656. IRQ_ENABLE();
  657. #define E2() \
  658. \
  659. LOCK(B); \
  660. UNLOCK(B);
  661. #define E3() \
  662. \
  663. IRQ_ENTER(); \
  664. RL(A); \
  665. RU(A); \
  666. IRQ_EXIT();
  667. /*
  668. * Generate 36 testcases:
  669. */
  670. #include "locking-selftest-spin-hardirq.h"
  671. GENERATE_PERMUTATIONS_3_EVENTS(irq_inversion_hard_spin)
  672. #include "locking-selftest-rlock-hardirq.h"
  673. GENERATE_PERMUTATIONS_3_EVENTS(irq_inversion_hard_rlock)
  674. #include "locking-selftest-wlock-hardirq.h"
  675. GENERATE_PERMUTATIONS_3_EVENTS(irq_inversion_hard_wlock)
  676. #include "locking-selftest-spin-softirq.h"
  677. GENERATE_PERMUTATIONS_3_EVENTS(irq_inversion_soft_spin)
  678. #include "locking-selftest-rlock-softirq.h"
  679. GENERATE_PERMUTATIONS_3_EVENTS(irq_inversion_soft_rlock)
  680. #include "locking-selftest-wlock-softirq.h"
  681. GENERATE_PERMUTATIONS_3_EVENTS(irq_inversion_soft_wlock)
  682. #undef E1
  683. #undef E2
  684. #undef E3
  685. /*
  686. * read-lock / write-lock recursion that is actually safe.
  687. */
  688. #define E1() \
  689. \
  690. IRQ_DISABLE(); \
  691. WL(A); \
  692. WU(A); \
  693. IRQ_ENABLE();
  694. #define E2() \
  695. \
  696. RL(A); \
  697. RU(A); \
  698. #define E3() \
  699. \
  700. IRQ_ENTER(); \
  701. RL(A); \
  702. L(B); \
  703. U(B); \
  704. RU(A); \
  705. IRQ_EXIT();
  706. /*
  707. * Generate 12 testcases:
  708. */
  709. #include "locking-selftest-hardirq.h"
  710. GENERATE_PERMUTATIONS_3_EVENTS(irq_read_recursion_hard)
  711. #include "locking-selftest-softirq.h"
  712. GENERATE_PERMUTATIONS_3_EVENTS(irq_read_recursion_soft)
  713. #undef E1
  714. #undef E2
  715. #undef E3
  716. /*
  717. * read-lock / write-lock recursion that is unsafe.
  718. */
  719. #define E1() \
  720. \
  721. IRQ_DISABLE(); \
  722. L(B); \
  723. WL(A); \
  724. WU(A); \
  725. U(B); \
  726. IRQ_ENABLE();
  727. #define E2() \
  728. \
  729. RL(A); \
  730. RU(A); \
  731. #define E3() \
  732. \
  733. IRQ_ENTER(); \
  734. L(B); \
  735. U(B); \
  736. IRQ_EXIT();
  737. /*
  738. * Generate 12 testcases:
  739. */
  740. #include "locking-selftest-hardirq.h"
  741. // GENERATE_PERMUTATIONS_3_EVENTS(irq_read_recursion2_hard)
  742. #include "locking-selftest-softirq.h"
  743. // GENERATE_PERMUTATIONS_3_EVENTS(irq_read_recursion2_soft)
  744. #ifdef CONFIG_DEBUG_LOCK_ALLOC
  745. # define I_SPINLOCK(x) lockdep_reset_lock(&lock_##x.dep_map)
  746. # define I_RWLOCK(x) lockdep_reset_lock(&rwlock_##x.dep_map)
  747. # define I_MUTEX(x) lockdep_reset_lock(&mutex_##x.dep_map)
  748. # define I_RWSEM(x) lockdep_reset_lock(&rwsem_##x.dep_map)
  749. #else
  750. # define I_SPINLOCK(x)
  751. # define I_RWLOCK(x)
  752. # define I_MUTEX(x)
  753. # define I_RWSEM(x)
  754. #endif
  755. #define I1(x) \
  756. do { \
  757. I_SPINLOCK(x); \
  758. I_RWLOCK(x); \
  759. I_MUTEX(x); \
  760. I_RWSEM(x); \
  761. } while (0)
  762. #define I2(x) \
  763. do { \
  764. spin_lock_init(&lock_##x); \
  765. rwlock_init(&rwlock_##x); \
  766. mutex_init(&mutex_##x); \
  767. init_rwsem(&rwsem_##x); \
  768. } while (0)
  769. static void reset_locks(void)
  770. {
  771. local_irq_disable();
  772. I1(A); I1(B); I1(C); I1(D);
  773. I1(X1); I1(X2); I1(Y1); I1(Y2); I1(Z1); I1(Z2);
  774. lockdep_reset();
  775. I2(A); I2(B); I2(C); I2(D);
  776. init_shared_classes();
  777. local_irq_enable();
  778. }
  779. #undef I
  780. static int testcase_total;
  781. static int testcase_successes;
  782. static int expected_testcase_failures;
  783. static int unexpected_testcase_failures;
  784. static void dotest(void (*testcase_fn)(void), int expected, int lockclass_mask)
  785. {
  786. unsigned long saved_preempt_count = preempt_count();
  787. int expected_failure = 0;
  788. WARN_ON(irqs_disabled());
  789. testcase_fn();
  790. /*
  791. * Filter out expected failures:
  792. */
  793. #ifndef CONFIG_PROVE_LOCKING
  794. if ((lockclass_mask & LOCKTYPE_SPIN) && debug_locks != expected)
  795. expected_failure = 1;
  796. if ((lockclass_mask & LOCKTYPE_RWLOCK) && debug_locks != expected)
  797. expected_failure = 1;
  798. if ((lockclass_mask & LOCKTYPE_MUTEX) && debug_locks != expected)
  799. expected_failure = 1;
  800. if ((lockclass_mask & LOCKTYPE_RWSEM) && debug_locks != expected)
  801. expected_failure = 1;
  802. #endif
  803. if (debug_locks != expected) {
  804. if (expected_failure) {
  805. expected_testcase_failures++;
  806. printk("failed|");
  807. } else {
  808. unexpected_testcase_failures++;
  809. printk("FAILED|");
  810. dump_stack();
  811. }
  812. } else {
  813. testcase_successes++;
  814. printk(" ok |");
  815. }
  816. testcase_total++;
  817. if (debug_locks_verbose)
  818. printk(" lockclass mask: %x, debug_locks: %d, expected: %d\n",
  819. lockclass_mask, debug_locks, expected);
  820. /*
  821. * Some tests (e.g. double-unlock) might corrupt the preemption
  822. * count, so restore it:
  823. */
  824. preempt_count() = saved_preempt_count;
  825. #ifdef CONFIG_TRACE_IRQFLAGS
  826. if (softirq_count())
  827. current->softirqs_enabled = 0;
  828. else
  829. current->softirqs_enabled = 1;
  830. #endif
  831. reset_locks();
  832. }
  833. static inline void print_testname(const char *testname)
  834. {
  835. printk("%33s:", testname);
  836. }
  837. #define DO_TESTCASE_1(desc, name, nr) \
  838. print_testname(desc"/"#nr); \
  839. dotest(name##_##nr, SUCCESS, LOCKTYPE_RWLOCK); \
  840. printk("\n");
  841. #define DO_TESTCASE_1B(desc, name, nr) \
  842. print_testname(desc"/"#nr); \
  843. dotest(name##_##nr, FAILURE, LOCKTYPE_RWLOCK); \
  844. printk("\n");
  845. #define DO_TESTCASE_3(desc, name, nr) \
  846. print_testname(desc"/"#nr); \
  847. dotest(name##_spin_##nr, FAILURE, LOCKTYPE_SPIN); \
  848. dotest(name##_wlock_##nr, FAILURE, LOCKTYPE_RWLOCK); \
  849. dotest(name##_rlock_##nr, SUCCESS, LOCKTYPE_RWLOCK); \
  850. printk("\n");
  851. #define DO_TESTCASE_3RW(desc, name, nr) \
  852. print_testname(desc"/"#nr); \
  853. dotest(name##_spin_##nr, FAILURE, LOCKTYPE_SPIN|LOCKTYPE_RWLOCK);\
  854. dotest(name##_wlock_##nr, FAILURE, LOCKTYPE_RWLOCK); \
  855. dotest(name##_rlock_##nr, SUCCESS, LOCKTYPE_RWLOCK); \
  856. printk("\n");
  857. #define DO_TESTCASE_6(desc, name) \
  858. print_testname(desc); \
  859. dotest(name##_spin, FAILURE, LOCKTYPE_SPIN); \
  860. dotest(name##_wlock, FAILURE, LOCKTYPE_RWLOCK); \
  861. dotest(name##_rlock, FAILURE, LOCKTYPE_RWLOCK); \
  862. dotest(name##_mutex, FAILURE, LOCKTYPE_MUTEX); \
  863. dotest(name##_wsem, FAILURE, LOCKTYPE_RWSEM); \
  864. dotest(name##_rsem, FAILURE, LOCKTYPE_RWSEM); \
  865. printk("\n");
  866. #define DO_TESTCASE_6_SUCCESS(desc, name) \
  867. print_testname(desc); \
  868. dotest(name##_spin, SUCCESS, LOCKTYPE_SPIN); \
  869. dotest(name##_wlock, SUCCESS, LOCKTYPE_RWLOCK); \
  870. dotest(name##_rlock, SUCCESS, LOCKTYPE_RWLOCK); \
  871. dotest(name##_mutex, SUCCESS, LOCKTYPE_MUTEX); \
  872. dotest(name##_wsem, SUCCESS, LOCKTYPE_RWSEM); \
  873. dotest(name##_rsem, SUCCESS, LOCKTYPE_RWSEM); \
  874. printk("\n");
  875. /*
  876. * 'read' variant: rlocks must not trigger.
  877. */
  878. #define DO_TESTCASE_6R(desc, name) \
  879. print_testname(desc); \
  880. dotest(name##_spin, FAILURE, LOCKTYPE_SPIN); \
  881. dotest(name##_wlock, FAILURE, LOCKTYPE_RWLOCK); \
  882. dotest(name##_rlock, SUCCESS, LOCKTYPE_RWLOCK); \
  883. dotest(name##_mutex, FAILURE, LOCKTYPE_MUTEX); \
  884. dotest(name##_wsem, FAILURE, LOCKTYPE_RWSEM); \
  885. dotest(name##_rsem, FAILURE, LOCKTYPE_RWSEM); \
  886. printk("\n");
  887. #define DO_TESTCASE_2I(desc, name, nr) \
  888. DO_TESTCASE_1("hard-"desc, name##_hard, nr); \
  889. DO_TESTCASE_1("soft-"desc, name##_soft, nr);
  890. #define DO_TESTCASE_2IB(desc, name, nr) \
  891. DO_TESTCASE_1B("hard-"desc, name##_hard, nr); \
  892. DO_TESTCASE_1B("soft-"desc, name##_soft, nr);
  893. #define DO_TESTCASE_6I(desc, name, nr) \
  894. DO_TESTCASE_3("hard-"desc, name##_hard, nr); \
  895. DO_TESTCASE_3("soft-"desc, name##_soft, nr);
  896. #define DO_TESTCASE_6IRW(desc, name, nr) \
  897. DO_TESTCASE_3RW("hard-"desc, name##_hard, nr); \
  898. DO_TESTCASE_3RW("soft-"desc, name##_soft, nr);
  899. #define DO_TESTCASE_2x3(desc, name) \
  900. DO_TESTCASE_3(desc, name, 12); \
  901. DO_TESTCASE_3(desc, name, 21);
  902. #define DO_TESTCASE_2x6(desc, name) \
  903. DO_TESTCASE_6I(desc, name, 12); \
  904. DO_TESTCASE_6I(desc, name, 21);
  905. #define DO_TESTCASE_6x2(desc, name) \
  906. DO_TESTCASE_2I(desc, name, 123); \
  907. DO_TESTCASE_2I(desc, name, 132); \
  908. DO_TESTCASE_2I(desc, name, 213); \
  909. DO_TESTCASE_2I(desc, name, 231); \
  910. DO_TESTCASE_2I(desc, name, 312); \
  911. DO_TESTCASE_2I(desc, name, 321);
  912. #define DO_TESTCASE_6x2B(desc, name) \
  913. DO_TESTCASE_2IB(desc, name, 123); \
  914. DO_TESTCASE_2IB(desc, name, 132); \
  915. DO_TESTCASE_2IB(desc, name, 213); \
  916. DO_TESTCASE_2IB(desc, name, 231); \
  917. DO_TESTCASE_2IB(desc, name, 312); \
  918. DO_TESTCASE_2IB(desc, name, 321);
  919. #define DO_TESTCASE_6x6(desc, name) \
  920. DO_TESTCASE_6I(desc, name, 123); \
  921. DO_TESTCASE_6I(desc, name, 132); \
  922. DO_TESTCASE_6I(desc, name, 213); \
  923. DO_TESTCASE_6I(desc, name, 231); \
  924. DO_TESTCASE_6I(desc, name, 312); \
  925. DO_TESTCASE_6I(desc, name, 321);
  926. #define DO_TESTCASE_6x6RW(desc, name) \
  927. DO_TESTCASE_6IRW(desc, name, 123); \
  928. DO_TESTCASE_6IRW(desc, name, 132); \
  929. DO_TESTCASE_6IRW(desc, name, 213); \
  930. DO_TESTCASE_6IRW(desc, name, 231); \
  931. DO_TESTCASE_6IRW(desc, name, 312); \
  932. DO_TESTCASE_6IRW(desc, name, 321);
  933. void locking_selftest(void)
  934. {
  935. /*
  936. * Got a locking failure before the selftest ran?
  937. */
  938. if (!debug_locks) {
  939. printk("----------------------------------\n");
  940. printk("| Locking API testsuite disabled |\n");
  941. printk("----------------------------------\n");
  942. return;
  943. }
  944. /*
  945. * Run the testsuite:
  946. */
  947. printk("------------------------\n");
  948. printk("| Locking API testsuite:\n");
  949. printk("----------------------------------------------------------------------------\n");
  950. printk(" | spin |wlock |rlock |mutex | wsem | rsem |\n");
  951. printk(" --------------------------------------------------------------------------\n");
  952. init_shared_classes();
  953. debug_locks_silent = !debug_locks_verbose;
  954. DO_TESTCASE_6R("A-A deadlock", AA);
  955. DO_TESTCASE_6R("A-B-B-A deadlock", ABBA);
  956. DO_TESTCASE_6R("A-B-B-C-C-A deadlock", ABBCCA);
  957. DO_TESTCASE_6R("A-B-C-A-B-C deadlock", ABCABC);
  958. DO_TESTCASE_6R("A-B-B-C-C-D-D-A deadlock", ABBCCDDA);
  959. DO_TESTCASE_6R("A-B-C-D-B-D-D-A deadlock", ABCDBDDA);
  960. DO_TESTCASE_6R("A-B-C-D-B-C-D-A deadlock", ABCDBCDA);
  961. DO_TESTCASE_6("double unlock", double_unlock);
  962. DO_TESTCASE_6("initialize held", init_held);
  963. DO_TESTCASE_6_SUCCESS("bad unlock order", bad_unlock_order);
  964. printk(" --------------------------------------------------------------------------\n");
  965. print_testname("recursive read-lock");
  966. printk(" |");
  967. dotest(rlock_AA1, SUCCESS, LOCKTYPE_RWLOCK);
  968. printk(" |");
  969. dotest(rsem_AA1, FAILURE, LOCKTYPE_RWSEM);
  970. printk("\n");
  971. print_testname("recursive read-lock #2");
  972. printk(" |");
  973. dotest(rlock_AA1B, SUCCESS, LOCKTYPE_RWLOCK);
  974. printk(" |");
  975. dotest(rsem_AA1B, FAILURE, LOCKTYPE_RWSEM);
  976. printk("\n");
  977. print_testname("mixed read-write-lock");
  978. printk(" |");
  979. dotest(rlock_AA2, FAILURE, LOCKTYPE_RWLOCK);
  980. printk(" |");
  981. dotest(rsem_AA2, FAILURE, LOCKTYPE_RWSEM);
  982. printk("\n");
  983. print_testname("mixed write-read-lock");
  984. printk(" |");
  985. dotest(rlock_AA3, FAILURE, LOCKTYPE_RWLOCK);
  986. printk(" |");
  987. dotest(rsem_AA3, FAILURE, LOCKTYPE_RWSEM);
  988. printk("\n");
  989. printk(" --------------------------------------------------------------------------\n");
  990. /*
  991. * irq-context testcases:
  992. */
  993. DO_TESTCASE_2x6("irqs-on + irq-safe-A", irqsafe1);
  994. DO_TESTCASE_2x3("sirq-safe-A => hirqs-on", irqsafe2A);
  995. DO_TESTCASE_2x6("safe-A + irqs-on", irqsafe2B);
  996. DO_TESTCASE_6x6("safe-A + unsafe-B #1", irqsafe3);
  997. DO_TESTCASE_6x6("safe-A + unsafe-B #2", irqsafe4);
  998. DO_TESTCASE_6x6RW("irq lock-inversion", irq_inversion);
  999. DO_TESTCASE_6x2("irq read-recursion", irq_read_recursion);
  1000. // DO_TESTCASE_6x2B("irq read-recursion #2", irq_read_recursion2);
  1001. if (unexpected_testcase_failures) {
  1002. printk("-----------------------------------------------------------------\n");
  1003. debug_locks = 0;
  1004. printk("BUG: %3d unexpected failures (out of %3d) - debugging disabled! |\n",
  1005. unexpected_testcase_failures, testcase_total);
  1006. printk("-----------------------------------------------------------------\n");
  1007. } else if (expected_testcase_failures && testcase_successes) {
  1008. printk("--------------------------------------------------------\n");
  1009. printk("%3d out of %3d testcases failed, as expected. |\n",
  1010. expected_testcase_failures, testcase_total);
  1011. printk("----------------------------------------------------\n");
  1012. debug_locks = 1;
  1013. } else if (expected_testcase_failures && !testcase_successes) {
  1014. printk("--------------------------------------------------------\n");
  1015. printk("All %3d testcases failed, as expected. |\n",
  1016. expected_testcase_failures);
  1017. printk("----------------------------------------\n");
  1018. debug_locks = 1;
  1019. } else {
  1020. printk("-------------------------------------------------------\n");
  1021. printk("Good, all %3d testcases passed! |\n",
  1022. testcase_successes);
  1023. printk("---------------------------------\n");
  1024. debug_locks = 1;
  1025. }
  1026. debug_locks_silent = 0;
  1027. }