1 // SPDX-License-Identifier: GPL-2.0+
3 * Read-Copy Update module-based scalability-test facility
5 * Copyright (C) IBM Corporation, 2015
7 * Authors: Paul E. McKenney <paulmck@linux.ibm.com>
10 #define pr_fmt(fmt) fmt
12 #include <linux/types.h>
13 #include <linux/kernel.h>
14 #include <linux/init.h>
16 #include <linux/module.h>
17 #include <linux/kthread.h>
18 #include <linux/err.h>
19 #include <linux/spinlock.h>
20 #include <linux/smp.h>
21 #include <linux/rcupdate.h>
22 #include <linux/interrupt.h>
23 #include <linux/sched.h>
24 #include <uapi/linux/sched/types.h>
25 #include <linux/atomic.h>
26 #include <linux/bitops.h>
27 #include <linux/completion.h>
28 #include <linux/moduleparam.h>
29 #include <linux/percpu.h>
30 #include <linux/notifier.h>
31 #include <linux/reboot.h>
32 #include <linux/freezer.h>
33 #include <linux/cpu.h>
34 #include <linux/delay.h>
35 #include <linux/stat.h>
36 #include <linux/srcu.h>
37 #include <linux/slab.h>
38 #include <asm/byteorder.h>
39 #include <linux/torture.h>
40 #include <linux/vmalloc.h>
41 #include <linux/rcupdate_trace.h>
45 MODULE_LICENSE("GPL");
46 MODULE_AUTHOR("Paul E. McKenney <paulmck@linux.ibm.com>");
48 #define SCALE_FLAG "-scale:"
49 #define SCALEOUT_STRING(s) \
50 pr_alert("%s" SCALE_FLAG " %s\n", scale_type, s)
51 #define VERBOSE_SCALEOUT_STRING(s) \
52 do { if (verbose) pr_alert("%s" SCALE_FLAG " %s\n", scale_type, s); } while (0)
53 #define VERBOSE_SCALEOUT_ERRSTRING(s) \
54 do { if (verbose) pr_alert("%s" SCALE_FLAG "!!! %s\n", scale_type, s); } while (0)
57 * The intended use cases for the nreaders and nwriters module parameters
60 * 1. Specify only the nr_cpus kernel boot parameter. This will
61 * set both nreaders and nwriters to the value specified by
62 * nr_cpus for a mixed reader/writer test.
64 * 2. Specify the nr_cpus kernel boot parameter, but set
65 * rcuscale.nreaders to zero. This will set nwriters to the
66 * value specified by nr_cpus for an update-only test.
68 * 3. Specify the nr_cpus kernel boot parameter, but set
69 * rcuscale.nwriters to zero. This will set nreaders to the
70 * value specified by nr_cpus for a read-only test.
72 * Various other use cases may of course be specified.
74 * Note that this test's readers are intended only as a test load for
75 * the writers. The reader scalability statistics will be overly
76 * pessimistic due to the per-critical-section interrupt disabling,
77 * test-end checks, and the pair of calls through pointers.
81 # define RCUSCALE_SHUTDOWN 0
83 # define RCUSCALE_SHUTDOWN 1
86 torture_param(bool, gp_async
, false, "Use asynchronous GP wait primitives");
87 torture_param(int, gp_async_max
, 1000, "Max # outstanding waits per reader");
88 torture_param(bool, gp_exp
, false, "Use expedited GP wait primitives");
89 torture_param(int, holdoff
, 10, "Holdoff time before test start (s)");
90 torture_param(int, nreaders
, -1, "Number of RCU reader threads");
91 torture_param(int, nwriters
, -1, "Number of RCU updater threads");
92 torture_param(bool, shutdown
, RCUSCALE_SHUTDOWN
,
93 "Shutdown at end of scalability tests.");
94 torture_param(int, verbose
, 1, "Enable verbose debugging printk()s");
95 torture_param(int, writer_holdoff
, 0, "Holdoff (us) between GPs, zero to disable");
96 torture_param(int, kfree_rcu_test
, 0, "Do we run a kfree_rcu() scale test?");
97 torture_param(int, kfree_mult
, 1, "Multiple of kfree_obj size to allocate.");
99 static char *scale_type
= "rcu";
100 module_param(scale_type
, charp
, 0444);
101 MODULE_PARM_DESC(scale_type
, "Type of RCU to scalability-test (rcu, srcu, ...)");
103 static int nrealreaders
;
104 static int nrealwriters
;
105 static struct task_struct
**writer_tasks
;
106 static struct task_struct
**reader_tasks
;
107 static struct task_struct
*shutdown_task
;
109 static u64
**writer_durations
;
110 static int *writer_n_durations
;
111 static atomic_t n_rcu_scale_reader_started
;
112 static atomic_t n_rcu_scale_writer_started
;
113 static atomic_t n_rcu_scale_writer_finished
;
114 static wait_queue_head_t shutdown_wq
;
115 static u64 t_rcu_scale_writer_started
;
116 static u64 t_rcu_scale_writer_finished
;
117 static unsigned long b_rcu_gp_test_started
;
118 static unsigned long b_rcu_gp_test_finished
;
119 static DEFINE_PER_CPU(atomic_t
, n_async_inflight
);
121 #define MAX_MEAS 10000
125 * Operations vector for selecting different types of tests.
128 struct rcu_scale_ops
{
131 void (*cleanup
)(void);
132 int (*readlock
)(void);
133 void (*readunlock
)(int idx
);
134 unsigned long (*get_gp_seq
)(void);
135 unsigned long (*gp_diff
)(unsigned long new, unsigned long old
);
136 unsigned long (*exp_completed
)(void);
137 void (*async
)(struct rcu_head
*head
, rcu_callback_t func
);
138 void (*gp_barrier
)(void);
140 void (*exp_sync
)(void);
144 static struct rcu_scale_ops
*cur_ops
;
147 * Definitions for rcu scalability testing.
150 static int rcu_scale_read_lock(void) __acquires(RCU
)
156 static void rcu_scale_read_unlock(int idx
) __releases(RCU
)
161 static unsigned long __maybe_unused
rcu_no_completed(void)
166 static void rcu_sync_scale_init(void)
170 static struct rcu_scale_ops rcu_ops
= {
172 .init
= rcu_sync_scale_init
,
173 .readlock
= rcu_scale_read_lock
,
174 .readunlock
= rcu_scale_read_unlock
,
175 .get_gp_seq
= rcu_get_gp_seq
,
176 .gp_diff
= rcu_seq_diff
,
177 .exp_completed
= rcu_exp_batches_completed
,
179 .gp_barrier
= rcu_barrier
,
180 .sync
= synchronize_rcu
,
181 .exp_sync
= synchronize_rcu_expedited
,
186 * Definitions for srcu scalability testing.
189 DEFINE_STATIC_SRCU(srcu_ctl_scale
);
190 static struct srcu_struct
*srcu_ctlp
= &srcu_ctl_scale
;
192 static int srcu_scale_read_lock(void) __acquires(srcu_ctlp
)
194 return srcu_read_lock(srcu_ctlp
);
197 static void srcu_scale_read_unlock(int idx
) __releases(srcu_ctlp
)
199 srcu_read_unlock(srcu_ctlp
, idx
);
202 static unsigned long srcu_scale_completed(void)
204 return srcu_batches_completed(srcu_ctlp
);
207 static void srcu_call_rcu(struct rcu_head
*head
, rcu_callback_t func
)
209 call_srcu(srcu_ctlp
, head
, func
);
212 static void srcu_rcu_barrier(void)
214 srcu_barrier(srcu_ctlp
);
217 static void srcu_scale_synchronize(void)
219 synchronize_srcu(srcu_ctlp
);
222 static void srcu_scale_synchronize_expedited(void)
224 synchronize_srcu_expedited(srcu_ctlp
);
227 static struct rcu_scale_ops srcu_ops
= {
228 .ptype
= SRCU_FLAVOR
,
229 .init
= rcu_sync_scale_init
,
230 .readlock
= srcu_scale_read_lock
,
231 .readunlock
= srcu_scale_read_unlock
,
232 .get_gp_seq
= srcu_scale_completed
,
233 .gp_diff
= rcu_seq_diff
,
234 .exp_completed
= srcu_scale_completed
,
235 .async
= srcu_call_rcu
,
236 .gp_barrier
= srcu_rcu_barrier
,
237 .sync
= srcu_scale_synchronize
,
238 .exp_sync
= srcu_scale_synchronize_expedited
,
242 static struct srcu_struct srcud
;
244 static void srcu_sync_scale_init(void)
247 init_srcu_struct(srcu_ctlp
);
250 static void srcu_sync_scale_cleanup(void)
252 cleanup_srcu_struct(srcu_ctlp
);
255 static struct rcu_scale_ops srcud_ops
= {
256 .ptype
= SRCU_FLAVOR
,
257 .init
= srcu_sync_scale_init
,
258 .cleanup
= srcu_sync_scale_cleanup
,
259 .readlock
= srcu_scale_read_lock
,
260 .readunlock
= srcu_scale_read_unlock
,
261 .get_gp_seq
= srcu_scale_completed
,
262 .gp_diff
= rcu_seq_diff
,
263 .exp_completed
= srcu_scale_completed
,
264 .async
= srcu_call_rcu
,
265 .gp_barrier
= srcu_rcu_barrier
,
266 .sync
= srcu_scale_synchronize
,
267 .exp_sync
= srcu_scale_synchronize_expedited
,
272 * Definitions for RCU-tasks scalability testing.
275 static int tasks_scale_read_lock(void)
280 static void tasks_scale_read_unlock(int idx
)
284 static struct rcu_scale_ops tasks_ops
= {
285 .ptype
= RCU_TASKS_FLAVOR
,
286 .init
= rcu_sync_scale_init
,
287 .readlock
= tasks_scale_read_lock
,
288 .readunlock
= tasks_scale_read_unlock
,
289 .get_gp_seq
= rcu_no_completed
,
290 .gp_diff
= rcu_seq_diff
,
291 .async
= call_rcu_tasks
,
292 .gp_barrier
= rcu_barrier_tasks
,
293 .sync
= synchronize_rcu_tasks
,
294 .exp_sync
= synchronize_rcu_tasks
,
299 * Definitions for RCU-tasks-trace scalability testing.
302 static int tasks_trace_scale_read_lock(void)
304 rcu_read_lock_trace();
308 static void tasks_trace_scale_read_unlock(int idx
)
310 rcu_read_unlock_trace();
313 static struct rcu_scale_ops tasks_tracing_ops
= {
314 .ptype
= RCU_TASKS_FLAVOR
,
315 .init
= rcu_sync_scale_init
,
316 .readlock
= tasks_trace_scale_read_lock
,
317 .readunlock
= tasks_trace_scale_read_unlock
,
318 .get_gp_seq
= rcu_no_completed
,
319 .gp_diff
= rcu_seq_diff
,
320 .async
= call_rcu_tasks_trace
,
321 .gp_barrier
= rcu_barrier_tasks_trace
,
322 .sync
= synchronize_rcu_tasks_trace
,
323 .exp_sync
= synchronize_rcu_tasks_trace
,
324 .name
= "tasks-tracing"
327 static unsigned long rcuscale_seq_diff(unsigned long new, unsigned long old
)
329 if (!cur_ops
->gp_diff
)
331 return cur_ops
->gp_diff(new, old
);
335 * If scalability tests complete, wait for shutdown to commence.
337 static void rcu_scale_wait_shutdown(void)
339 cond_resched_tasks_rcu_qs();
340 if (atomic_read(&n_rcu_scale_writer_finished
) < nrealwriters
)
342 while (!torture_must_stop())
343 schedule_timeout_uninterruptible(1);
347 * RCU scalability reader kthread. Repeatedly does empty RCU read-side
348 * critical section, minimizing update-side interference. However, the
349 * point of this test is not to evaluate reader scalability, but instead
350 * to serve as a test load for update-side scalability testing.
353 rcu_scale_reader(void *arg
)
359 VERBOSE_SCALEOUT_STRING("rcu_scale_reader task started");
360 set_cpus_allowed_ptr(current
, cpumask_of(me
% nr_cpu_ids
));
361 set_user_nice(current
, MAX_NICE
);
362 atomic_inc(&n_rcu_scale_reader_started
);
365 local_irq_save(flags
);
366 idx
= cur_ops
->readlock();
367 cur_ops
->readunlock(idx
);
368 local_irq_restore(flags
);
369 rcu_scale_wait_shutdown();
370 } while (!torture_must_stop());
371 torture_kthread_stopping("rcu_scale_reader");
376 * Callback function for asynchronous grace periods from rcu_scale_writer().
378 static void rcu_scale_async_cb(struct rcu_head
*rhp
)
380 atomic_dec(this_cpu_ptr(&n_async_inflight
));
385 * RCU scale writer kthread. Repeatedly does a grace period.
388 rcu_scale_writer(void *arg
)
393 struct rcu_head
*rhp
= NULL
;
394 bool started
= false, done
= false, alldone
= false;
397 u64
*wdpp
= writer_durations
[me
];
399 VERBOSE_SCALEOUT_STRING("rcu_scale_writer task started");
401 set_cpus_allowed_ptr(current
, cpumask_of(me
% nr_cpu_ids
));
402 sched_set_fifo_low(current
);
405 schedule_timeout_uninterruptible(holdoff
* HZ
);
408 * Wait until rcu_end_inkernel_boot() is called for normal GP tests
409 * so that RCU is not always expedited for normal GP tests.
410 * The system_state test is approximate, but works well in practice.
412 while (!gp_exp
&& system_state
!= SYSTEM_RUNNING
)
413 schedule_timeout_uninterruptible(1);
415 t
= ktime_get_mono_fast_ns();
416 if (atomic_inc_return(&n_rcu_scale_writer_started
) >= nrealwriters
) {
417 t_rcu_scale_writer_started
= t
;
419 b_rcu_gp_test_started
=
420 cur_ops
->exp_completed() / 2;
422 b_rcu_gp_test_started
= cur_ops
->get_gp_seq();
428 udelay(writer_holdoff
);
430 *wdp
= ktime_get_mono_fast_ns();
434 rhp
= kmalloc(sizeof(*rhp
), GFP_KERNEL
);
435 if (rhp
&& atomic_read(this_cpu_ptr(&n_async_inflight
)) < gp_async_max
) {
436 atomic_inc(this_cpu_ptr(&n_async_inflight
));
437 cur_ops
->async(rhp
, rcu_scale_async_cb
);
439 } else if (!kthread_should_stop()) {
440 cur_ops
->gp_barrier();
443 kfree(rhp
); /* Because we are stopping. */
450 t
= ktime_get_mono_fast_ns();
454 atomic_read(&n_rcu_scale_writer_started
) >= nrealwriters
)
456 if (!done
&& i
>= MIN_MEAS
) {
458 sched_set_normal(current
, 0);
459 pr_alert("%s%s rcu_scale_writer %ld has %d measurements\n",
460 scale_type
, SCALE_FLAG
, me
, MIN_MEAS
);
461 if (atomic_inc_return(&n_rcu_scale_writer_finished
) >=
463 schedule_timeout_interruptible(10);
464 rcu_ftrace_dump(DUMP_ALL
);
465 SCALEOUT_STRING("Test complete");
466 t_rcu_scale_writer_finished
= t
;
468 b_rcu_gp_test_finished
=
469 cur_ops
->exp_completed() / 2;
471 b_rcu_gp_test_finished
=
472 cur_ops
->get_gp_seq();
475 smp_mb(); /* Assign before wake. */
476 wake_up(&shutdown_wq
);
480 if (done
&& !alldone
&&
481 atomic_read(&n_rcu_scale_writer_finished
) >= nrealwriters
)
483 if (started
&& !alldone
&& i
< MAX_MEAS
- 1)
485 rcu_scale_wait_shutdown();
486 } while (!torture_must_stop());
488 cur_ops
->gp_barrier();
490 writer_n_durations
[me
] = i_max
;
491 torture_kthread_stopping("rcu_scale_writer");
496 rcu_scale_print_module_parms(struct rcu_scale_ops
*cur_ops
, const char *tag
)
498 pr_alert("%s" SCALE_FLAG
499 "--- %s: nreaders=%d nwriters=%d verbose=%d shutdown=%d\n",
500 scale_type
, tag
, nrealreaders
, nrealwriters
, verbose
, shutdown
);
504 rcu_scale_cleanup(void)
513 * Would like warning at start, but everything is expedited
514 * during the mid-boot phase, so have to wait till the end.
516 if (rcu_gp_is_expedited() && !rcu_gp_is_normal() && !gp_exp
)
517 VERBOSE_SCALEOUT_ERRSTRING("All grace periods expedited, no normal ones to measure!");
518 if (rcu_gp_is_normal() && gp_exp
)
519 VERBOSE_SCALEOUT_ERRSTRING("All grace periods normal, no expedited ones to measure!");
520 if (gp_exp
&& gp_async
)
521 VERBOSE_SCALEOUT_ERRSTRING("No expedited async GPs, so went with async!");
523 if (torture_cleanup_begin())
526 torture_cleanup_end();
531 for (i
= 0; i
< nrealreaders
; i
++)
532 torture_stop_kthread(rcu_scale_reader
,
538 for (i
= 0; i
< nrealwriters
; i
++) {
539 torture_stop_kthread(rcu_scale_writer
,
541 if (!writer_n_durations
)
543 j
= writer_n_durations
[i
];
544 pr_alert("%s%s writer %d gps: %d\n",
545 scale_type
, SCALE_FLAG
, i
, j
);
548 pr_alert("%s%s start: %llu end: %llu duration: %llu gps: %d batches: %ld\n",
549 scale_type
, SCALE_FLAG
,
550 t_rcu_scale_writer_started
, t_rcu_scale_writer_finished
,
551 t_rcu_scale_writer_finished
-
552 t_rcu_scale_writer_started
,
554 rcuscale_seq_diff(b_rcu_gp_test_finished
,
555 b_rcu_gp_test_started
));
556 for (i
= 0; i
< nrealwriters
; i
++) {
557 if (!writer_durations
)
559 if (!writer_n_durations
)
561 wdpp
= writer_durations
[i
];
564 for (j
= 0; j
<= writer_n_durations
[i
]; j
++) {
566 pr_alert("%s%s %4d writer-duration: %5d %llu\n",
567 scale_type
, SCALE_FLAG
,
570 schedule_timeout_uninterruptible(1);
572 kfree(writer_durations
[i
]);
575 kfree(writer_durations
);
576 kfree(writer_n_durations
);
579 /* Do torture-type-specific cleanup operations. */
580 if (cur_ops
->cleanup
!= NULL
)
583 torture_cleanup_end();
587 * Return the number if non-negative. If -1, the number of CPUs.
588 * If less than -1, that much less than the number of CPUs, but
591 static int compute_real(int n
)
598 nr
= num_online_cpus() + 1 + n
;
606 * RCU scalability shutdown kthread. Just waits to be awakened, then shuts
610 rcu_scale_shutdown(void *arg
)
612 wait_event(shutdown_wq
,
613 atomic_read(&n_rcu_scale_writer_finished
) >= nrealwriters
);
614 smp_mb(); /* Wake before output. */
621 * kfree_rcu() scalability tests: Start a kfree_rcu() loop on all CPUs for number
622 * of iterations and measure total time and number of GP for all iterations to complete.
625 torture_param(int, kfree_nthreads
, -1, "Number of threads running loops of kfree_rcu().");
626 torture_param(int, kfree_alloc_num
, 8000, "Number of allocations and frees done in an iteration.");
627 torture_param(int, kfree_loops
, 10, "Number of loops doing kfree_alloc_num allocations and frees.");
629 static struct task_struct
**kfree_reader_tasks
;
630 static int kfree_nrealthreads
;
631 static atomic_t n_kfree_scale_thread_started
;
632 static atomic_t n_kfree_scale_thread_ended
;
640 kfree_scale_thread(void *arg
)
644 struct kfree_obj
*alloc_ptr
;
645 u64 start_time
, end_time
;
646 long long mem_begin
, mem_during
= 0;
648 VERBOSE_SCALEOUT_STRING("kfree_scale_thread task started");
649 set_cpus_allowed_ptr(current
, cpumask_of(me
% nr_cpu_ids
));
650 set_user_nice(current
, MAX_NICE
);
652 start_time
= ktime_get_mono_fast_ns();
654 if (atomic_inc_return(&n_kfree_scale_thread_started
) >= kfree_nrealthreads
) {
656 b_rcu_gp_test_started
= cur_ops
->exp_completed() / 2;
658 b_rcu_gp_test_started
= cur_ops
->get_gp_seq();
663 mem_during
= mem_begin
= si_mem_available();
664 } else if (loop
% (kfree_loops
/ 4) == 0) {
665 mem_during
= (mem_during
+ si_mem_available()) / 2;
668 for (i
= 0; i
< kfree_alloc_num
; i
++) {
669 alloc_ptr
= kmalloc(kfree_mult
* sizeof(struct kfree_obj
), GFP_KERNEL
);
673 kfree_rcu(alloc_ptr
, rh
);
677 } while (!torture_must_stop() && ++loop
< kfree_loops
);
679 if (atomic_inc_return(&n_kfree_scale_thread_ended
) >= kfree_nrealthreads
) {
680 end_time
= ktime_get_mono_fast_ns();
683 b_rcu_gp_test_finished
= cur_ops
->exp_completed() / 2;
685 b_rcu_gp_test_finished
= cur_ops
->get_gp_seq();
687 pr_alert("Total time taken by all kfree'ers: %llu ns, loops: %d, batches: %ld, memory footprint: %lldMB\n",
688 (unsigned long long)(end_time
- start_time
), kfree_loops
,
689 rcuscale_seq_diff(b_rcu_gp_test_finished
, b_rcu_gp_test_started
),
690 (mem_begin
- mem_during
) >> (20 - PAGE_SHIFT
));
693 smp_mb(); /* Assign before wake. */
694 wake_up(&shutdown_wq
);
698 torture_kthread_stopping("kfree_scale_thread");
703 kfree_scale_cleanup(void)
707 if (torture_cleanup_begin())
710 if (kfree_reader_tasks
) {
711 for (i
= 0; i
< kfree_nrealthreads
; i
++)
712 torture_stop_kthread(kfree_scale_thread
,
713 kfree_reader_tasks
[i
]);
714 kfree(kfree_reader_tasks
);
717 torture_cleanup_end();
721 * shutdown kthread. Just waits to be awakened, then shuts down system.
724 kfree_scale_shutdown(void *arg
)
726 wait_event(shutdown_wq
,
727 atomic_read(&n_kfree_scale_thread_ended
) >= kfree_nrealthreads
);
729 smp_mb(); /* Wake before output. */
731 kfree_scale_cleanup();
737 kfree_scale_init(void)
742 kfree_nrealthreads
= compute_real(kfree_nthreads
);
743 /* Start up the kthreads. */
745 init_waitqueue_head(&shutdown_wq
);
746 firsterr
= torture_create_kthread(kfree_scale_shutdown
, NULL
,
750 schedule_timeout_uninterruptible(1);
753 pr_alert("kfree object size=%zu\n", kfree_mult
* sizeof(struct kfree_obj
));
755 kfree_reader_tasks
= kcalloc(kfree_nrealthreads
, sizeof(kfree_reader_tasks
[0]),
757 if (kfree_reader_tasks
== NULL
) {
762 for (i
= 0; i
< kfree_nrealthreads
; i
++) {
763 firsterr
= torture_create_kthread(kfree_scale_thread
, (void *)i
,
764 kfree_reader_tasks
[i
]);
769 while (atomic_read(&n_kfree_scale_thread_started
) < kfree_nrealthreads
)
770 schedule_timeout_uninterruptible(1);
777 kfree_scale_cleanup();
786 static struct rcu_scale_ops
*scale_ops
[] = {
787 &rcu_ops
, &srcu_ops
, &srcud_ops
, &tasks_ops
, &tasks_tracing_ops
790 if (!torture_init_begin(scale_type
, verbose
))
793 /* Process args and announce that the scalability'er is on the job. */
794 for (i
= 0; i
< ARRAY_SIZE(scale_ops
); i
++) {
795 cur_ops
= scale_ops
[i
];
796 if (strcmp(scale_type
, cur_ops
->name
) == 0)
799 if (i
== ARRAY_SIZE(scale_ops
)) {
800 pr_alert("rcu-scale: invalid scale type: \"%s\"\n", scale_type
);
801 pr_alert("rcu-scale types:");
802 for (i
= 0; i
< ARRAY_SIZE(scale_ops
); i
++)
803 pr_cont(" %s", scale_ops
[i
]->name
);
813 return kfree_scale_init();
815 nrealwriters
= compute_real(nwriters
);
816 nrealreaders
= compute_real(nreaders
);
817 atomic_set(&n_rcu_scale_reader_started
, 0);
818 atomic_set(&n_rcu_scale_writer_started
, 0);
819 atomic_set(&n_rcu_scale_writer_finished
, 0);
820 rcu_scale_print_module_parms(cur_ops
, "Start of test");
822 /* Start up the kthreads. */
825 init_waitqueue_head(&shutdown_wq
);
826 firsterr
= torture_create_kthread(rcu_scale_shutdown
, NULL
,
830 schedule_timeout_uninterruptible(1);
832 reader_tasks
= kcalloc(nrealreaders
, sizeof(reader_tasks
[0]),
834 if (reader_tasks
== NULL
) {
835 VERBOSE_SCALEOUT_ERRSTRING("out of memory");
839 for (i
= 0; i
< nrealreaders
; i
++) {
840 firsterr
= torture_create_kthread(rcu_scale_reader
, (void *)i
,
845 while (atomic_read(&n_rcu_scale_reader_started
) < nrealreaders
)
846 schedule_timeout_uninterruptible(1);
847 writer_tasks
= kcalloc(nrealwriters
, sizeof(reader_tasks
[0]),
849 writer_durations
= kcalloc(nrealwriters
, sizeof(*writer_durations
),
852 kcalloc(nrealwriters
, sizeof(*writer_n_durations
),
854 if (!writer_tasks
|| !writer_durations
|| !writer_n_durations
) {
855 VERBOSE_SCALEOUT_ERRSTRING("out of memory");
859 for (i
= 0; i
< nrealwriters
; i
++) {
860 writer_durations
[i
] =
861 kcalloc(MAX_MEAS
, sizeof(*writer_durations
[i
]),
863 if (!writer_durations
[i
]) {
867 firsterr
= torture_create_kthread(rcu_scale_writer
, (void *)i
,
879 WARN_ON(!IS_MODULE(CONFIG_RCU_SCALE_TEST
));
885 module_init(rcu_scale_init
);
886 module_exit(rcu_scale_cleanup
);