rcuperf.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660
  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, s)
  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, false, "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. static int perf_runnable = IS_ENABLED(MODULE);
  91. module_param(perf_runnable, int, 0444);
  92. MODULE_PARM_DESC(perf_runnable, "Start rcuperf at boot");
  93. /*
  94. * Operations vector for selecting different types of tests.
  95. */
  96. struct rcu_perf_ops {
  97. int ptype;
  98. void (*init)(void);
  99. void (*cleanup)(void);
  100. int (*readlock)(void);
  101. void (*readunlock)(int idx);
  102. unsigned long (*started)(void);
  103. unsigned long (*completed)(void);
  104. unsigned long (*exp_completed)(void);
  105. void (*sync)(void);
  106. void (*exp_sync)(void);
  107. const char *name;
  108. };
  109. static struct rcu_perf_ops *cur_ops;
  110. /*
  111. * Definitions for rcu perf testing.
  112. */
  113. static int rcu_perf_read_lock(void) __acquires(RCU)
  114. {
  115. rcu_read_lock();
  116. return 0;
  117. }
  118. static void rcu_perf_read_unlock(int idx) __releases(RCU)
  119. {
  120. rcu_read_unlock();
  121. }
  122. static unsigned long __maybe_unused rcu_no_completed(void)
  123. {
  124. return 0;
  125. }
  126. static void rcu_sync_perf_init(void)
  127. {
  128. }
  129. static struct rcu_perf_ops rcu_ops = {
  130. .ptype = RCU_FLAVOR,
  131. .init = rcu_sync_perf_init,
  132. .readlock = rcu_perf_read_lock,
  133. .readunlock = rcu_perf_read_unlock,
  134. .started = rcu_batches_started,
  135. .completed = rcu_batches_completed,
  136. .exp_completed = rcu_exp_batches_completed,
  137. .sync = synchronize_rcu,
  138. .exp_sync = synchronize_rcu_expedited,
  139. .name = "rcu"
  140. };
  141. /*
  142. * Definitions for rcu_bh perf testing.
  143. */
  144. static int rcu_bh_perf_read_lock(void) __acquires(RCU_BH)
  145. {
  146. rcu_read_lock_bh();
  147. return 0;
  148. }
  149. static void rcu_bh_perf_read_unlock(int idx) __releases(RCU_BH)
  150. {
  151. rcu_read_unlock_bh();
  152. }
  153. static struct rcu_perf_ops rcu_bh_ops = {
  154. .ptype = RCU_BH_FLAVOR,
  155. .init = rcu_sync_perf_init,
  156. .readlock = rcu_bh_perf_read_lock,
  157. .readunlock = rcu_bh_perf_read_unlock,
  158. .started = rcu_batches_started_bh,
  159. .completed = rcu_batches_completed_bh,
  160. .exp_completed = rcu_exp_batches_completed_sched,
  161. .sync = synchronize_rcu_bh,
  162. .exp_sync = synchronize_rcu_bh_expedited,
  163. .name = "rcu_bh"
  164. };
  165. /*
  166. * Definitions for srcu perf testing.
  167. */
  168. DEFINE_STATIC_SRCU(srcu_ctl_perf);
  169. static struct srcu_struct *srcu_ctlp = &srcu_ctl_perf;
  170. static int srcu_perf_read_lock(void) __acquires(srcu_ctlp)
  171. {
  172. return srcu_read_lock(srcu_ctlp);
  173. }
  174. static void srcu_perf_read_unlock(int idx) __releases(srcu_ctlp)
  175. {
  176. srcu_read_unlock(srcu_ctlp, idx);
  177. }
  178. static unsigned long srcu_perf_completed(void)
  179. {
  180. return srcu_batches_completed(srcu_ctlp);
  181. }
  182. static void srcu_perf_synchronize(void)
  183. {
  184. synchronize_srcu(srcu_ctlp);
  185. }
  186. static void srcu_perf_synchronize_expedited(void)
  187. {
  188. synchronize_srcu_expedited(srcu_ctlp);
  189. }
  190. static struct rcu_perf_ops srcu_ops = {
  191. .ptype = SRCU_FLAVOR,
  192. .init = rcu_sync_perf_init,
  193. .readlock = srcu_perf_read_lock,
  194. .readunlock = srcu_perf_read_unlock,
  195. .started = NULL,
  196. .completed = srcu_perf_completed,
  197. .exp_completed = srcu_perf_completed,
  198. .sync = srcu_perf_synchronize,
  199. .exp_sync = srcu_perf_synchronize_expedited,
  200. .name = "srcu"
  201. };
  202. /*
  203. * Definitions for sched perf testing.
  204. */
  205. static int sched_perf_read_lock(void)
  206. {
  207. preempt_disable();
  208. return 0;
  209. }
  210. static void sched_perf_read_unlock(int idx)
  211. {
  212. preempt_enable();
  213. }
  214. static struct rcu_perf_ops sched_ops = {
  215. .ptype = RCU_SCHED_FLAVOR,
  216. .init = rcu_sync_perf_init,
  217. .readlock = sched_perf_read_lock,
  218. .readunlock = sched_perf_read_unlock,
  219. .started = rcu_batches_started_sched,
  220. .completed = rcu_batches_completed_sched,
  221. .exp_completed = rcu_exp_batches_completed_sched,
  222. .sync = synchronize_sched,
  223. .exp_sync = synchronize_sched_expedited,
  224. .name = "sched"
  225. };
  226. #ifdef CONFIG_TASKS_RCU
  227. /*
  228. * Definitions for RCU-tasks perf testing.
  229. */
  230. static int tasks_perf_read_lock(void)
  231. {
  232. return 0;
  233. }
  234. static void tasks_perf_read_unlock(int idx)
  235. {
  236. }
  237. static struct rcu_perf_ops tasks_ops = {
  238. .ptype = RCU_TASKS_FLAVOR,
  239. .init = rcu_sync_perf_init,
  240. .readlock = tasks_perf_read_lock,
  241. .readunlock = tasks_perf_read_unlock,
  242. .started = rcu_no_completed,
  243. .completed = rcu_no_completed,
  244. .sync = synchronize_rcu_tasks,
  245. .exp_sync = synchronize_rcu_tasks,
  246. .name = "tasks"
  247. };
  248. #define RCUPERF_TASKS_OPS &tasks_ops,
  249. static bool __maybe_unused torturing_tasks(void)
  250. {
  251. return cur_ops == &tasks_ops;
  252. }
  253. #else /* #ifdef CONFIG_TASKS_RCU */
  254. #define RCUPERF_TASKS_OPS
  255. static bool __maybe_unused torturing_tasks(void)
  256. {
  257. return false;
  258. }
  259. #endif /* #else #ifdef CONFIG_TASKS_RCU */
  260. /*
  261. * If performance tests complete, wait for shutdown to commence.
  262. */
  263. static void rcu_perf_wait_shutdown(void)
  264. {
  265. cond_resched_rcu_qs();
  266. if (atomic_read(&n_rcu_perf_writer_finished) < nrealwriters)
  267. return;
  268. while (!torture_must_stop())
  269. schedule_timeout_uninterruptible(1);
  270. }
  271. /*
  272. * RCU perf reader kthread. Repeatedly does empty RCU read-side
  273. * critical section, minimizing update-side interference.
  274. */
  275. static int
  276. rcu_perf_reader(void *arg)
  277. {
  278. unsigned long flags;
  279. int idx;
  280. long me = (long)arg;
  281. VERBOSE_PERFOUT_STRING("rcu_perf_reader task started");
  282. set_cpus_allowed_ptr(current, cpumask_of(me % nr_cpu_ids));
  283. set_user_nice(current, MAX_NICE);
  284. atomic_inc(&n_rcu_perf_reader_started);
  285. do {
  286. local_irq_save(flags);
  287. idx = cur_ops->readlock();
  288. cur_ops->readunlock(idx);
  289. local_irq_restore(flags);
  290. rcu_perf_wait_shutdown();
  291. } while (!torture_must_stop());
  292. torture_kthread_stopping("rcu_perf_reader");
  293. return 0;
  294. }
  295. /*
  296. * RCU perf writer kthread. Repeatedly does a grace period.
  297. */
  298. static int
  299. rcu_perf_writer(void *arg)
  300. {
  301. int i = 0;
  302. int i_max;
  303. long me = (long)arg;
  304. struct sched_param sp;
  305. bool started = false, done = false, alldone = false;
  306. u64 t;
  307. u64 *wdp;
  308. u64 *wdpp = writer_durations[me];
  309. VERBOSE_PERFOUT_STRING("rcu_perf_writer task started");
  310. WARN_ON(!wdpp);
  311. set_cpus_allowed_ptr(current, cpumask_of(me % nr_cpu_ids));
  312. sp.sched_priority = 1;
  313. sched_setscheduler_nocheck(current, SCHED_FIFO, &sp);
  314. if (holdoff)
  315. schedule_timeout_uninterruptible(holdoff * HZ);
  316. t = ktime_get_mono_fast_ns();
  317. if (atomic_inc_return(&n_rcu_perf_writer_started) >= nrealwriters) {
  318. t_rcu_perf_writer_started = t;
  319. if (gp_exp) {
  320. b_rcu_perf_writer_started =
  321. cur_ops->exp_completed() / 2;
  322. } else {
  323. b_rcu_perf_writer_started =
  324. cur_ops->completed();
  325. }
  326. }
  327. do {
  328. wdp = &wdpp[i];
  329. *wdp = ktime_get_mono_fast_ns();
  330. if (gp_exp) {
  331. rcu_perf_writer_state = RTWS_EXP_SYNC;
  332. cur_ops->exp_sync();
  333. } else {
  334. rcu_perf_writer_state = RTWS_SYNC;
  335. cur_ops->sync();
  336. }
  337. rcu_perf_writer_state = RTWS_IDLE;
  338. t = ktime_get_mono_fast_ns();
  339. *wdp = t - *wdp;
  340. i_max = i;
  341. if (!started &&
  342. atomic_read(&n_rcu_perf_writer_started) >= nrealwriters)
  343. started = true;
  344. if (!done && i >= MIN_MEAS) {
  345. done = true;
  346. sp.sched_priority = 0;
  347. sched_setscheduler_nocheck(current,
  348. SCHED_NORMAL, &sp);
  349. pr_alert("%s%s rcu_perf_writer %ld has %d measurements\n",
  350. perf_type, PERF_FLAG, me, MIN_MEAS);
  351. if (atomic_inc_return(&n_rcu_perf_writer_finished) >=
  352. nrealwriters) {
  353. schedule_timeout_interruptible(10);
  354. rcu_ftrace_dump(DUMP_ALL);
  355. PERFOUT_STRING("Test complete");
  356. t_rcu_perf_writer_finished = t;
  357. if (gp_exp) {
  358. b_rcu_perf_writer_finished =
  359. cur_ops->exp_completed() / 2;
  360. } else {
  361. b_rcu_perf_writer_finished =
  362. cur_ops->completed();
  363. }
  364. if (shutdown) {
  365. smp_mb(); /* Assign before wake. */
  366. wake_up(&shutdown_wq);
  367. }
  368. }
  369. }
  370. if (done && !alldone &&
  371. atomic_read(&n_rcu_perf_writer_finished) >= nrealwriters)
  372. alldone = true;
  373. if (started && !alldone && i < MAX_MEAS - 1)
  374. i++;
  375. rcu_perf_wait_shutdown();
  376. } while (!torture_must_stop());
  377. rcu_perf_writer_state = RTWS_STOPPING;
  378. writer_n_durations[me] = i_max;
  379. torture_kthread_stopping("rcu_perf_writer");
  380. return 0;
  381. }
  382. static inline void
  383. rcu_perf_print_module_parms(struct rcu_perf_ops *cur_ops, const char *tag)
  384. {
  385. pr_alert("%s" PERF_FLAG
  386. "--- %s: nreaders=%d nwriters=%d verbose=%d shutdown=%d\n",
  387. perf_type, tag, nrealreaders, nrealwriters, verbose, shutdown);
  388. }
  389. static void
  390. rcu_perf_cleanup(void)
  391. {
  392. int i;
  393. int j;
  394. int ngps = 0;
  395. u64 *wdp;
  396. u64 *wdpp;
  397. if (torture_cleanup_begin())
  398. return;
  399. if (reader_tasks) {
  400. for (i = 0; i < nrealreaders; i++)
  401. torture_stop_kthread(rcu_perf_reader,
  402. reader_tasks[i]);
  403. kfree(reader_tasks);
  404. }
  405. if (writer_tasks) {
  406. for (i = 0; i < nrealwriters; i++) {
  407. torture_stop_kthread(rcu_perf_writer,
  408. writer_tasks[i]);
  409. if (!writer_n_durations)
  410. continue;
  411. j = writer_n_durations[i];
  412. pr_alert("%s%s writer %d gps: %d\n",
  413. perf_type, PERF_FLAG, i, j);
  414. ngps += j;
  415. }
  416. pr_alert("%s%s start: %llu end: %llu duration: %llu gps: %d batches: %ld\n",
  417. perf_type, PERF_FLAG,
  418. t_rcu_perf_writer_started, t_rcu_perf_writer_finished,
  419. t_rcu_perf_writer_finished -
  420. t_rcu_perf_writer_started,
  421. ngps,
  422. b_rcu_perf_writer_finished -
  423. b_rcu_perf_writer_started);
  424. for (i = 0; i < nrealwriters; i++) {
  425. if (!writer_durations)
  426. break;
  427. if (!writer_n_durations)
  428. continue;
  429. wdpp = writer_durations[i];
  430. if (!wdpp)
  431. continue;
  432. for (j = 0; j <= writer_n_durations[i]; j++) {
  433. wdp = &wdpp[j];
  434. pr_alert("%s%s %4d writer-duration: %5d %llu\n",
  435. perf_type, PERF_FLAG,
  436. i, j, *wdp);
  437. if (j % 100 == 0)
  438. schedule_timeout_uninterruptible(1);
  439. }
  440. kfree(writer_durations[i]);
  441. }
  442. kfree(writer_tasks);
  443. kfree(writer_durations);
  444. kfree(writer_n_durations);
  445. }
  446. /* Do flavor-specific cleanup operations. */
  447. if (cur_ops->cleanup != NULL)
  448. cur_ops->cleanup();
  449. torture_cleanup_end();
  450. }
  451. /*
  452. * Return the number if non-negative. If -1, the number of CPUs.
  453. * If less than -1, that much less than the number of CPUs, but
  454. * at least one.
  455. */
  456. static int compute_real(int n)
  457. {
  458. int nr;
  459. if (n >= 0) {
  460. nr = n;
  461. } else {
  462. nr = num_online_cpus() + 1 + n;
  463. if (nr <= 0)
  464. nr = 1;
  465. }
  466. return nr;
  467. }
  468. /*
  469. * RCU perf shutdown kthread. Just waits to be awakened, then shuts
  470. * down system.
  471. */
  472. static int
  473. rcu_perf_shutdown(void *arg)
  474. {
  475. do {
  476. wait_event(shutdown_wq,
  477. atomic_read(&n_rcu_perf_writer_finished) >=
  478. nrealwriters);
  479. } while (atomic_read(&n_rcu_perf_writer_finished) < nrealwriters);
  480. smp_mb(); /* Wake before output. */
  481. rcu_perf_cleanup();
  482. kernel_power_off();
  483. return -EINVAL;
  484. }
  485. static int __init
  486. rcu_perf_init(void)
  487. {
  488. long i;
  489. int firsterr = 0;
  490. static struct rcu_perf_ops *perf_ops[] = {
  491. &rcu_ops, &rcu_bh_ops, &srcu_ops, &sched_ops,
  492. RCUPERF_TASKS_OPS
  493. };
  494. if (!torture_init_begin(perf_type, verbose, &perf_runnable))
  495. return -EBUSY;
  496. /* Process args and tell the world that the perf'er is on the job. */
  497. for (i = 0; i < ARRAY_SIZE(perf_ops); i++) {
  498. cur_ops = perf_ops[i];
  499. if (strcmp(perf_type, cur_ops->name) == 0)
  500. break;
  501. }
  502. if (i == ARRAY_SIZE(perf_ops)) {
  503. pr_alert("rcu-perf: invalid perf type: \"%s\"\n",
  504. perf_type);
  505. pr_alert("rcu-perf types:");
  506. for (i = 0; i < ARRAY_SIZE(perf_ops); i++)
  507. pr_alert(" %s", perf_ops[i]->name);
  508. pr_alert("\n");
  509. firsterr = -EINVAL;
  510. goto unwind;
  511. }
  512. if (cur_ops->init)
  513. cur_ops->init();
  514. nrealwriters = compute_real(nwriters);
  515. nrealreaders = compute_real(nreaders);
  516. atomic_set(&n_rcu_perf_reader_started, 0);
  517. atomic_set(&n_rcu_perf_writer_started, 0);
  518. atomic_set(&n_rcu_perf_writer_finished, 0);
  519. rcu_perf_print_module_parms(cur_ops, "Start of test");
  520. /* Start up the kthreads. */
  521. if (shutdown) {
  522. init_waitqueue_head(&shutdown_wq);
  523. firsterr = torture_create_kthread(rcu_perf_shutdown, NULL,
  524. shutdown_task);
  525. if (firsterr)
  526. goto unwind;
  527. schedule_timeout_uninterruptible(1);
  528. }
  529. reader_tasks = kcalloc(nrealreaders, sizeof(reader_tasks[0]),
  530. GFP_KERNEL);
  531. if (reader_tasks == NULL) {
  532. VERBOSE_PERFOUT_ERRSTRING("out of memory");
  533. firsterr = -ENOMEM;
  534. goto unwind;
  535. }
  536. for (i = 0; i < nrealreaders; i++) {
  537. firsterr = torture_create_kthread(rcu_perf_reader, (void *)i,
  538. reader_tasks[i]);
  539. if (firsterr)
  540. goto unwind;
  541. }
  542. while (atomic_read(&n_rcu_perf_reader_started) < nrealreaders)
  543. schedule_timeout_uninterruptible(1);
  544. writer_tasks = kcalloc(nrealwriters, sizeof(reader_tasks[0]),
  545. GFP_KERNEL);
  546. writer_durations = kcalloc(nrealwriters, sizeof(*writer_durations),
  547. GFP_KERNEL);
  548. writer_n_durations =
  549. kcalloc(nrealwriters, sizeof(*writer_n_durations),
  550. GFP_KERNEL);
  551. if (!writer_tasks || !writer_durations || !writer_n_durations) {
  552. VERBOSE_PERFOUT_ERRSTRING("out of memory");
  553. firsterr = -ENOMEM;
  554. goto unwind;
  555. }
  556. if (rcu_gp_is_expedited() && !rcu_gp_is_normal() && !gp_exp) {
  557. VERBOSE_PERFOUT_ERRSTRING("All grace periods expedited, no normal ones to measure!");
  558. firsterr = -EINVAL;
  559. goto unwind;
  560. }
  561. if (rcu_gp_is_normal() && gp_exp) {
  562. VERBOSE_PERFOUT_ERRSTRING("All grace periods normal, no expedited ones to measure!");
  563. firsterr = -EINVAL;
  564. goto unwind;
  565. }
  566. for (i = 0; i < nrealwriters; i++) {
  567. writer_durations[i] =
  568. kcalloc(MAX_MEAS, sizeof(*writer_durations[i]),
  569. GFP_KERNEL);
  570. if (!writer_durations[i]) {
  571. firsterr = -ENOMEM;
  572. goto unwind;
  573. }
  574. firsterr = torture_create_kthread(rcu_perf_writer, (void *)i,
  575. writer_tasks[i]);
  576. if (firsterr)
  577. goto unwind;
  578. }
  579. torture_init_end();
  580. return 0;
  581. unwind:
  582. torture_init_end();
  583. rcu_perf_cleanup();
  584. return firsterr;
  585. }
  586. module_init(rcu_perf_init);
  587. module_exit(rcu_perf_cleanup);