rcuperf.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655
  1. /*
  2. * Read-Copy Update module-based performance-test facility
  3. *
  4. * This program is free software; you can redistribute it and/or modify
  5. * it under the terms of the GNU General Public License as published by
  6. * the Free Software Foundation; either version 2 of the License, or
  7. * (at your option) any later version.
  8. *
  9. * This program is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. * GNU General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU General Public License
  15. * along with this program; if not, you can access it online at
  16. * http://www.gnu.org/licenses/gpl-2.0.html.
  17. *
  18. * Copyright (C) IBM Corporation, 2015
  19. *
  20. * Authors: Paul E. McKenney <paulmck@us.ibm.com>
  21. */
  22. #include <linux/types.h>
  23. #include <linux/kernel.h>
  24. #include <linux/init.h>
  25. #include <linux/module.h>
  26. #include <linux/kthread.h>
  27. #include <linux/err.h>
  28. #include <linux/spinlock.h>
  29. #include <linux/smp.h>
  30. #include <linux/rcupdate.h>
  31. #include <linux/interrupt.h>
  32. #include <linux/sched.h>
  33. #include <linux/atomic.h>
  34. #include <linux/bitops.h>
  35. #include <linux/completion.h>
  36. #include <linux/moduleparam.h>
  37. #include <linux/percpu.h>
  38. #include <linux/notifier.h>
  39. #include <linux/reboot.h>
  40. #include <linux/freezer.h>
  41. #include <linux/cpu.h>
  42. #include <linux/delay.h>
  43. #include <linux/stat.h>
  44. #include <linux/srcu.h>
  45. #include <linux/slab.h>
  46. #include <asm/byteorder.h>
  47. #include <linux/torture.h>
  48. #include <linux/vmalloc.h>
  49. MODULE_LICENSE("GPL");
  50. MODULE_AUTHOR("Paul E. McKenney <paulmck@linux.vnet.ibm.com>");
  51. #define PERF_FLAG "-perf:"
  52. #define PERFOUT_STRING(s) \
  53. pr_alert("%s" PERF_FLAG s "\n", perf_type)
  54. #define VERBOSE_PERFOUT_STRING(s) \
  55. do { if (verbose) pr_alert("%s" PERF_FLAG " %s\n", perf_type, s); } while (0)
  56. #define VERBOSE_PERFOUT_ERRSTRING(s) \
  57. do { if (verbose) pr_alert("%s" PERF_FLAG "!!! %s\n", perf_type, s); } while (0)
  58. torture_param(bool, gp_exp, true, "Use expedited GP wait primitives");
  59. torture_param(int, holdoff, 10, "Holdoff time before test start (s)");
  60. torture_param(int, nreaders, -1, "Number of RCU reader threads");
  61. torture_param(int, nwriters, -1, "Number of RCU updater threads");
  62. torture_param(bool, shutdown, false, "Shutdown at end of performance tests.");
  63. torture_param(bool, verbose, true, "Enable verbose debugging printk()s");
  64. static char *perf_type = "rcu";
  65. module_param(perf_type, charp, 0444);
  66. MODULE_PARM_DESC(perf_type, "Type of RCU to performance-test (rcu, rcu_bh, ...)");
  67. static int nrealreaders;
  68. static int nrealwriters;
  69. static struct task_struct **writer_tasks;
  70. static struct task_struct **reader_tasks;
  71. static struct task_struct *shutdown_task;
  72. static u64 **writer_durations;
  73. static int *writer_n_durations;
  74. static atomic_t n_rcu_perf_reader_started;
  75. static atomic_t n_rcu_perf_writer_started;
  76. static atomic_t n_rcu_perf_writer_finished;
  77. static wait_queue_head_t shutdown_wq;
  78. static u64 t_rcu_perf_writer_started;
  79. static u64 t_rcu_perf_writer_finished;
  80. static unsigned long b_rcu_perf_writer_started;
  81. static unsigned long b_rcu_perf_writer_finished;
  82. static int rcu_perf_writer_state;
  83. #define RTWS_INIT 0
  84. #define RTWS_EXP_SYNC 1
  85. #define RTWS_SYNC 2
  86. #define RTWS_IDLE 2
  87. #define RTWS_STOPPING 3
  88. #define MAX_MEAS 10000
  89. #define MIN_MEAS 100
  90. #if defined(MODULE) || defined(CONFIG_RCU_PERF_TEST_RUNNABLE)
  91. #define RCUPERF_RUNNABLE_INIT 1
  92. #else
  93. #define RCUPERF_RUNNABLE_INIT 0
  94. #endif
  95. static int perf_runnable = RCUPERF_RUNNABLE_INIT;
  96. module_param(perf_runnable, int, 0444);
  97. MODULE_PARM_DESC(perf_runnable, "Start rcuperf at boot");
  98. /*
  99. * Operations vector for selecting different types of tests.
  100. */
  101. struct rcu_perf_ops {
  102. int ptype;
  103. void (*init)(void);
  104. void (*cleanup)(void);
  105. int (*readlock)(void);
  106. void (*readunlock)(int idx);
  107. unsigned long (*started)(void);
  108. unsigned long (*completed)(void);
  109. unsigned long (*exp_completed)(void);
  110. void (*sync)(void);
  111. void (*exp_sync)(void);
  112. const char *name;
  113. };
  114. static struct rcu_perf_ops *cur_ops;
  115. /*
  116. * Definitions for rcu perf testing.
  117. */
  118. static int rcu_perf_read_lock(void) __acquires(RCU)
  119. {
  120. rcu_read_lock();
  121. return 0;
  122. }
  123. static void rcu_perf_read_unlock(int idx) __releases(RCU)
  124. {
  125. rcu_read_unlock();
  126. }
  127. static unsigned long __maybe_unused rcu_no_completed(void)
  128. {
  129. return 0;
  130. }
  131. static void rcu_sync_perf_init(void)
  132. {
  133. }
  134. static struct rcu_perf_ops rcu_ops = {
  135. .ptype = RCU_FLAVOR,
  136. .init = rcu_sync_perf_init,
  137. .readlock = rcu_perf_read_lock,
  138. .readunlock = rcu_perf_read_unlock,
  139. .started = rcu_batches_started,
  140. .completed = rcu_batches_completed,
  141. .exp_completed = rcu_exp_batches_completed,
  142. .sync = synchronize_rcu,
  143. .exp_sync = synchronize_rcu_expedited,
  144. .name = "rcu"
  145. };
  146. /*
  147. * Definitions for rcu_bh perf testing.
  148. */
  149. static int rcu_bh_perf_read_lock(void) __acquires(RCU_BH)
  150. {
  151. rcu_read_lock_bh();
  152. return 0;
  153. }
  154. static void rcu_bh_perf_read_unlock(int idx) __releases(RCU_BH)
  155. {
  156. rcu_read_unlock_bh();
  157. }
  158. static struct rcu_perf_ops rcu_bh_ops = {
  159. .ptype = RCU_BH_FLAVOR,
  160. .init = rcu_sync_perf_init,
  161. .readlock = rcu_bh_perf_read_lock,
  162. .readunlock = rcu_bh_perf_read_unlock,
  163. .started = rcu_batches_started_bh,
  164. .completed = rcu_batches_completed_bh,
  165. .exp_completed = rcu_exp_batches_completed_sched,
  166. .sync = synchronize_rcu_bh,
  167. .exp_sync = synchronize_rcu_bh_expedited,
  168. .name = "rcu_bh"
  169. };
  170. /*
  171. * Definitions for srcu perf testing.
  172. */
  173. DEFINE_STATIC_SRCU(srcu_ctl_perf);
  174. static struct srcu_struct *srcu_ctlp = &srcu_ctl_perf;
  175. static int srcu_perf_read_lock(void) __acquires(srcu_ctlp)
  176. {
  177. return srcu_read_lock(srcu_ctlp);
  178. }
  179. static void srcu_perf_read_unlock(int idx) __releases(srcu_ctlp)
  180. {
  181. srcu_read_unlock(srcu_ctlp, idx);
  182. }
  183. static unsigned long srcu_perf_completed(void)
  184. {
  185. return srcu_batches_completed(srcu_ctlp);
  186. }
  187. static void srcu_perf_synchronize(void)
  188. {
  189. synchronize_srcu(srcu_ctlp);
  190. }
  191. static void srcu_perf_synchronize_expedited(void)
  192. {
  193. synchronize_srcu_expedited(srcu_ctlp);
  194. }
  195. static struct rcu_perf_ops srcu_ops = {
  196. .ptype = SRCU_FLAVOR,
  197. .init = rcu_sync_perf_init,
  198. .readlock = srcu_perf_read_lock,
  199. .readunlock = srcu_perf_read_unlock,
  200. .started = NULL,
  201. .completed = srcu_perf_completed,
  202. .exp_completed = srcu_perf_completed,
  203. .sync = srcu_perf_synchronize,
  204. .exp_sync = srcu_perf_synchronize_expedited,
  205. .name = "srcu"
  206. };
  207. /*
  208. * Definitions for sched perf testing.
  209. */
  210. static int sched_perf_read_lock(void)
  211. {
  212. preempt_disable();
  213. return 0;
  214. }
  215. static void sched_perf_read_unlock(int idx)
  216. {
  217. preempt_enable();
  218. }
  219. static struct rcu_perf_ops sched_ops = {
  220. .ptype = RCU_SCHED_FLAVOR,
  221. .init = rcu_sync_perf_init,
  222. .readlock = sched_perf_read_lock,
  223. .readunlock = sched_perf_read_unlock,
  224. .started = rcu_batches_started_sched,
  225. .completed = rcu_batches_completed_sched,
  226. .exp_completed = rcu_exp_batches_completed_sched,
  227. .sync = synchronize_sched,
  228. .exp_sync = synchronize_sched_expedited,
  229. .name = "sched"
  230. };
  231. #ifdef CONFIG_TASKS_RCU
  232. /*
  233. * Definitions for RCU-tasks perf testing.
  234. */
  235. static int tasks_perf_read_lock(void)
  236. {
  237. return 0;
  238. }
  239. static void tasks_perf_read_unlock(int idx)
  240. {
  241. }
  242. static struct rcu_perf_ops tasks_ops = {
  243. .ptype = RCU_TASKS_FLAVOR,
  244. .init = rcu_sync_perf_init,
  245. .readlock = tasks_perf_read_lock,
  246. .readunlock = tasks_perf_read_unlock,
  247. .started = rcu_no_completed,
  248. .completed = rcu_no_completed,
  249. .sync = synchronize_rcu_tasks,
  250. .exp_sync = synchronize_rcu_tasks,
  251. .name = "tasks"
  252. };
  253. #define RCUPERF_TASKS_OPS &tasks_ops,
  254. static bool __maybe_unused torturing_tasks(void)
  255. {
  256. return cur_ops == &tasks_ops;
  257. }
  258. #else /* #ifdef CONFIG_TASKS_RCU */
  259. #define RCUPERF_TASKS_OPS
  260. static bool __maybe_unused torturing_tasks(void)
  261. {
  262. return false;
  263. }
  264. #endif /* #else #ifdef CONFIG_TASKS_RCU */
  265. /*
  266. * If performance tests complete, wait for shutdown to commence.
  267. */
  268. static void rcu_perf_wait_shutdown(void)
  269. {
  270. cond_resched_rcu_qs();
  271. if (atomic_read(&n_rcu_perf_writer_finished) < nrealwriters)
  272. return;
  273. while (!torture_must_stop())
  274. schedule_timeout_uninterruptible(1);
  275. }
  276. /*
  277. * RCU perf reader kthread. Repeatedly does empty RCU read-side
  278. * critical section, minimizing update-side interference.
  279. */
  280. static int
  281. rcu_perf_reader(void *arg)
  282. {
  283. unsigned long flags;
  284. int idx;
  285. long me = (long)arg;
  286. VERBOSE_PERFOUT_STRING("rcu_perf_reader task started");
  287. set_cpus_allowed_ptr(current, cpumask_of(me % nr_cpu_ids));
  288. set_user_nice(current, MAX_NICE);
  289. atomic_inc(&n_rcu_perf_reader_started);
  290. do {
  291. local_irq_save(flags);
  292. idx = cur_ops->readlock();
  293. cur_ops->readunlock(idx);
  294. local_irq_restore(flags);
  295. rcu_perf_wait_shutdown();
  296. } while (!torture_must_stop());
  297. torture_kthread_stopping("rcu_perf_reader");
  298. return 0;
  299. }
  300. /*
  301. * RCU perf writer kthread. Repeatedly does a grace period.
  302. */
  303. static int
  304. rcu_perf_writer(void *arg)
  305. {
  306. int i = 0;
  307. int i_max;
  308. long me = (long)arg;
  309. struct sched_param sp;
  310. bool started = false, done = false, alldone = false;
  311. u64 t;
  312. u64 *wdp;
  313. u64 *wdpp = writer_durations[me];
  314. VERBOSE_PERFOUT_STRING("rcu_perf_writer task started");
  315. WARN_ON(rcu_gp_is_expedited() && !rcu_gp_is_normal() && !gp_exp);
  316. WARN_ON(rcu_gp_is_normal() && gp_exp);
  317. WARN_ON(!wdpp);
  318. set_cpus_allowed_ptr(current, cpumask_of(me % nr_cpu_ids));
  319. sp.sched_priority = 1;
  320. sched_setscheduler_nocheck(current, SCHED_FIFO, &sp);
  321. if (holdoff)
  322. schedule_timeout_uninterruptible(holdoff * HZ);
  323. t = ktime_get_mono_fast_ns();
  324. if (atomic_inc_return(&n_rcu_perf_writer_started) >= nrealwriters) {
  325. t_rcu_perf_writer_started = t;
  326. if (gp_exp) {
  327. b_rcu_perf_writer_started =
  328. cur_ops->exp_completed() / 2;
  329. } else {
  330. b_rcu_perf_writer_started =
  331. cur_ops->completed();
  332. }
  333. }
  334. do {
  335. wdp = &wdpp[i];
  336. *wdp = ktime_get_mono_fast_ns();
  337. if (gp_exp) {
  338. rcu_perf_writer_state = RTWS_EXP_SYNC;
  339. cur_ops->exp_sync();
  340. } else {
  341. rcu_perf_writer_state = RTWS_SYNC;
  342. cur_ops->sync();
  343. }
  344. rcu_perf_writer_state = RTWS_IDLE;
  345. t = ktime_get_mono_fast_ns();
  346. *wdp = t - *wdp;
  347. i_max = i;
  348. if (!started &&
  349. atomic_read(&n_rcu_perf_writer_started) >= nrealwriters)
  350. started = true;
  351. if (!done && i >= MIN_MEAS) {
  352. done = true;
  353. sp.sched_priority = 0;
  354. sched_setscheduler_nocheck(current,
  355. SCHED_NORMAL, &sp);
  356. pr_alert("%s" PERF_FLAG
  357. "rcu_perf_writer %ld has %d measurements\n",
  358. perf_type, me, MIN_MEAS);
  359. if (atomic_inc_return(&n_rcu_perf_writer_finished) >=
  360. nrealwriters) {
  361. schedule_timeout_interruptible(10);
  362. rcu_ftrace_dump(DUMP_ALL);
  363. PERFOUT_STRING("Test complete");
  364. t_rcu_perf_writer_finished = t;
  365. if (gp_exp) {
  366. b_rcu_perf_writer_finished =
  367. cur_ops->exp_completed() / 2;
  368. } else {
  369. b_rcu_perf_writer_finished =
  370. cur_ops->completed();
  371. }
  372. if (shutdown) {
  373. smp_mb(); /* Assign before wake. */
  374. wake_up(&shutdown_wq);
  375. }
  376. }
  377. }
  378. if (done && !alldone &&
  379. atomic_read(&n_rcu_perf_writer_finished) >= nrealwriters)
  380. alldone = true;
  381. if (started && !alldone && i < MAX_MEAS - 1)
  382. i++;
  383. rcu_perf_wait_shutdown();
  384. } while (!torture_must_stop());
  385. rcu_perf_writer_state = RTWS_STOPPING;
  386. writer_n_durations[me] = i_max;
  387. torture_kthread_stopping("rcu_perf_writer");
  388. return 0;
  389. }
  390. static inline void
  391. rcu_perf_print_module_parms(struct rcu_perf_ops *cur_ops, const char *tag)
  392. {
  393. pr_alert("%s" PERF_FLAG
  394. "--- %s: nreaders=%d nwriters=%d verbose=%d shutdown=%d\n",
  395. perf_type, tag, nrealreaders, nrealwriters, verbose, shutdown);
  396. }
  397. static void
  398. rcu_perf_cleanup(void)
  399. {
  400. int i;
  401. int j;
  402. int ngps = 0;
  403. u64 *wdp;
  404. u64 *wdpp;
  405. if (torture_cleanup_begin())
  406. return;
  407. if (reader_tasks) {
  408. for (i = 0; i < nrealreaders; i++)
  409. torture_stop_kthread(rcu_perf_reader,
  410. reader_tasks[i]);
  411. kfree(reader_tasks);
  412. }
  413. if (writer_tasks) {
  414. for (i = 0; i < nrealwriters; i++) {
  415. torture_stop_kthread(rcu_perf_writer,
  416. writer_tasks[i]);
  417. if (!writer_n_durations)
  418. continue;
  419. j = writer_n_durations[i];
  420. pr_alert("%s%s writer %d gps: %d\n",
  421. perf_type, PERF_FLAG, i, j);
  422. ngps += j;
  423. }
  424. pr_alert("%s%s start: %llu end: %llu duration: %llu gps: %d batches: %ld\n",
  425. perf_type, PERF_FLAG,
  426. t_rcu_perf_writer_started, t_rcu_perf_writer_finished,
  427. t_rcu_perf_writer_finished -
  428. t_rcu_perf_writer_started,
  429. ngps,
  430. b_rcu_perf_writer_finished -
  431. b_rcu_perf_writer_started);
  432. for (i = 0; i < nrealwriters; i++) {
  433. if (!writer_durations)
  434. break;
  435. if (!writer_n_durations)
  436. continue;
  437. wdpp = writer_durations[i];
  438. if (!wdpp)
  439. continue;
  440. for (j = 0; j <= writer_n_durations[i]; j++) {
  441. wdp = &wdpp[j];
  442. pr_alert("%s%s %4d writer-duration: %5d %llu\n",
  443. perf_type, PERF_FLAG,
  444. i, j, *wdp);
  445. if (j % 100 == 0)
  446. schedule_timeout_uninterruptible(1);
  447. }
  448. kfree(writer_durations[i]);
  449. }
  450. kfree(writer_tasks);
  451. kfree(writer_durations);
  452. kfree(writer_n_durations);
  453. }
  454. /* Do flavor-specific cleanup operations. */
  455. if (cur_ops->cleanup != NULL)
  456. cur_ops->cleanup();
  457. torture_cleanup_end();
  458. }
  459. /*
  460. * Return the number if non-negative. If -1, the number of CPUs.
  461. * If less than -1, that much less than the number of CPUs, but
  462. * at least one.
  463. */
  464. static int compute_real(int n)
  465. {
  466. int nr;
  467. if (n >= 0) {
  468. nr = n;
  469. } else {
  470. nr = num_online_cpus() + 1 + n;
  471. if (nr <= 0)
  472. nr = 1;
  473. }
  474. return nr;
  475. }
  476. /*
  477. * RCU perf shutdown kthread. Just waits to be awakened, then shuts
  478. * down system.
  479. */
  480. static int
  481. rcu_perf_shutdown(void *arg)
  482. {
  483. do {
  484. wait_event(shutdown_wq,
  485. atomic_read(&n_rcu_perf_writer_finished) >=
  486. nrealwriters);
  487. } while (atomic_read(&n_rcu_perf_writer_finished) < nrealwriters);
  488. smp_mb(); /* Wake before output. */
  489. rcu_perf_cleanup();
  490. kernel_power_off();
  491. return -EINVAL;
  492. }
  493. static int __init
  494. rcu_perf_init(void)
  495. {
  496. long i;
  497. int firsterr = 0;
  498. static struct rcu_perf_ops *perf_ops[] = {
  499. &rcu_ops, &rcu_bh_ops, &srcu_ops, &sched_ops,
  500. RCUPERF_TASKS_OPS
  501. };
  502. if (!torture_init_begin(perf_type, verbose, &perf_runnable))
  503. return -EBUSY;
  504. /* Process args and tell the world that the perf'er is on the job. */
  505. for (i = 0; i < ARRAY_SIZE(perf_ops); i++) {
  506. cur_ops = perf_ops[i];
  507. if (strcmp(perf_type, cur_ops->name) == 0)
  508. break;
  509. }
  510. if (i == ARRAY_SIZE(perf_ops)) {
  511. pr_alert("rcu-perf: invalid perf type: \"%s\"\n",
  512. perf_type);
  513. pr_alert("rcu-perf types:");
  514. for (i = 0; i < ARRAY_SIZE(perf_ops); i++)
  515. pr_alert(" %s", perf_ops[i]->name);
  516. pr_alert("\n");
  517. firsterr = -EINVAL;
  518. goto unwind;
  519. }
  520. if (cur_ops->init)
  521. cur_ops->init();
  522. nrealwriters = compute_real(nwriters);
  523. nrealreaders = compute_real(nreaders);
  524. atomic_set(&n_rcu_perf_reader_started, 0);
  525. atomic_set(&n_rcu_perf_writer_started, 0);
  526. atomic_set(&n_rcu_perf_writer_finished, 0);
  527. rcu_perf_print_module_parms(cur_ops, "Start of test");
  528. /* Start up the kthreads. */
  529. if (shutdown) {
  530. init_waitqueue_head(&shutdown_wq);
  531. firsterr = torture_create_kthread(rcu_perf_shutdown, NULL,
  532. shutdown_task);
  533. if (firsterr)
  534. goto unwind;
  535. schedule_timeout_uninterruptible(1);
  536. }
  537. reader_tasks = kcalloc(nrealreaders, sizeof(reader_tasks[0]),
  538. GFP_KERNEL);
  539. if (reader_tasks == NULL) {
  540. VERBOSE_PERFOUT_ERRSTRING("out of memory");
  541. firsterr = -ENOMEM;
  542. goto unwind;
  543. }
  544. for (i = 0; i < nrealreaders; i++) {
  545. firsterr = torture_create_kthread(rcu_perf_reader, (void *)i,
  546. reader_tasks[i]);
  547. if (firsterr)
  548. goto unwind;
  549. }
  550. while (atomic_read(&n_rcu_perf_reader_started) < nrealreaders)
  551. schedule_timeout_uninterruptible(1);
  552. writer_tasks = kcalloc(nrealwriters, sizeof(reader_tasks[0]),
  553. GFP_KERNEL);
  554. writer_durations = kcalloc(nrealwriters, sizeof(*writer_durations),
  555. GFP_KERNEL);
  556. writer_n_durations =
  557. kcalloc(nrealwriters, sizeof(*writer_n_durations),
  558. GFP_KERNEL);
  559. if (!writer_tasks || !writer_durations || !writer_n_durations) {
  560. VERBOSE_PERFOUT_ERRSTRING("out of memory");
  561. firsterr = -ENOMEM;
  562. goto unwind;
  563. }
  564. for (i = 0; i < nrealwriters; i++) {
  565. writer_durations[i] =
  566. kcalloc(MAX_MEAS, sizeof(*writer_durations[i]),
  567. GFP_KERNEL);
  568. if (!writer_durations[i])
  569. goto unwind;
  570. firsterr = torture_create_kthread(rcu_perf_writer, (void *)i,
  571. writer_tasks[i]);
  572. if (firsterr)
  573. goto unwind;
  574. }
  575. torture_init_end();
  576. return 0;
  577. unwind:
  578. torture_init_end();
  579. rcu_perf_cleanup();
  580. return firsterr;
  581. }
  582. module_init(rcu_perf_init);
  583. module_exit(rcu_perf_cleanup);