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