blob: 5489ff7f478e4372858693a56be3e95fd148e577 [file] [log] [blame]
Joel Fernandes (Google)653ed642020-05-25 00:36:48 -04001// SPDX-License-Identifier: GPL-2.0+
2//
Paul E. McKenney8e4ec3d2020-06-17 11:33:54 -07003// Scalability test comparing RCU vs other mechanisms
Joel Fernandes (Google)653ed642020-05-25 00:36:48 -04004// for acquiring references on objects.
5//
6// Copyright (C) Google, 2020.
7//
8// Author: Joel Fernandes <joel@joelfernandes.org>
9
10#define pr_fmt(fmt) fmt
11
12#include <linux/atomic.h>
13#include <linux/bitops.h>
14#include <linux/completion.h>
15#include <linux/cpu.h>
16#include <linux/delay.h>
17#include <linux/err.h>
18#include <linux/init.h>
19#include <linux/interrupt.h>
20#include <linux/kthread.h>
21#include <linux/kernel.h>
22#include <linux/mm.h>
23#include <linux/module.h>
24#include <linux/moduleparam.h>
25#include <linux/notifier.h>
26#include <linux/percpu.h>
27#include <linux/rcupdate.h>
Paul E. McKenney72bb7492020-06-02 08:34:41 -070028#include <linux/rcupdate_trace.h>
Joel Fernandes (Google)653ed642020-05-25 00:36:48 -040029#include <linux/reboot.h>
30#include <linux/sched.h>
31#include <linux/spinlock.h>
32#include <linux/smp.h>
33#include <linux/stat.h>
34#include <linux/srcu.h>
35#include <linux/slab.h>
36#include <linux/torture.h>
37#include <linux/types.h>
38
39#include "rcu.h"
40
Paul E. McKenney1fbeb3a2020-06-17 11:53:53 -070041#define SCALE_FLAG "-ref-scale: "
Joel Fernandes (Google)653ed642020-05-25 00:36:48 -040042
Paul E. McKenney1fbeb3a2020-06-17 11:53:53 -070043#define SCALEOUT(s, x...) \
44 pr_alert("%s" SCALE_FLAG s, scale_type, ## x)
Joel Fernandes (Google)653ed642020-05-25 00:36:48 -040045
Paul E. McKenney1fbeb3a2020-06-17 11:53:53 -070046#define VERBOSE_SCALEOUT(s, x...) \
Li Zhijianf71f22b2021-10-29 17:40:24 +080047 do { \
48 if (verbose) \
49 pr_alert("%s" SCALE_FLAG s "\n", scale_type, ## x); \
50 } while (0)
Joel Fernandes (Google)653ed642020-05-25 00:36:48 -040051
Paul E. McKenneye76506f2020-11-15 10:24:52 -080052static atomic_t verbose_batch_ctr;
53
54#define VERBOSE_SCALEOUT_BATCH(s, x...) \
55do { \
56 if (verbose && \
57 (verbose_batched <= 0 || \
Paul E. McKenney414c1162020-11-25 10:50:35 -080058 !(atomic_inc_return(&verbose_batch_ctr) % verbose_batched))) { \
59 schedule_timeout_uninterruptible(1); \
Li Zhijianf71f22b2021-10-29 17:40:24 +080060 pr_alert("%s" SCALE_FLAG s "\n", scale_type, ## x); \
Paul E. McKenney414c1162020-11-25 10:50:35 -080061 } \
Paul E. McKenneye76506f2020-11-15 10:24:52 -080062} while (0)
63
Li Zhijianf71f22b2021-10-29 17:40:24 +080064#define SCALEOUT_ERRSTRING(s, x...) pr_alert("%s" SCALE_FLAG "!!! " s "\n", scale_type, ## x)
Joel Fernandes (Google)653ed642020-05-25 00:36:48 -040065
66MODULE_LICENSE("GPL");
67MODULE_AUTHOR("Joel Fernandes (Google) <joel@joelfernandes.org>");
68
Paul E. McKenney1fbeb3a2020-06-17 11:53:53 -070069static char *scale_type = "rcu";
70module_param(scale_type, charp, 0444);
71MODULE_PARM_DESC(scale_type, "Type of test (rcu, srcu, refcnt, rwsem, rwlock.");
Joel Fernandes (Google)653ed642020-05-25 00:36:48 -040072
73torture_param(int, verbose, 0, "Enable verbose debugging printk()s");
Paul E. McKenneye76506f2020-11-15 10:24:52 -080074torture_param(int, verbose_batched, 0, "Batch verbose debugging printk()s");
Joel Fernandes (Google)653ed642020-05-25 00:36:48 -040075
Paul E. McKenney777a54c2020-05-25 14:16:44 -070076// Wait until there are multiple CPUs before starting test.
Paul E. McKenney8e4ec3d2020-06-17 11:33:54 -070077torture_param(int, holdoff, IS_BUILTIN(CONFIG_RCU_REF_SCALE_TEST) ? 10 : 0,
Paul E. McKenney777a54c2020-05-25 14:16:44 -070078 "Holdoff time before test start (s)");
79// Number of loops per experiment, all readers execute operations concurrently.
Paul E. McKenney4dd72a32020-05-29 13:11:26 -070080torture_param(long, loops, 10000, "Number of loops per experiment.");
Paul E. McKenney8fc28782020-05-25 15:48:38 -070081// Number of readers, with -1 defaulting to about 75% of the CPUs.
82torture_param(int, nreaders, -1, "Number of readers, -1 for 75% of CPUs.");
83// Number of runs.
84torture_param(int, nruns, 30, "Number of experiments to run.");
Paul E. McKenney918b3512020-05-31 18:14:57 -070085// Reader delay in nanoseconds, 0 for no delay.
86torture_param(int, readdelay, 0, "Read-side delay in nanoseconds.");
Joel Fernandes (Google)653ed642020-05-25 00:36:48 -040087
88#ifdef MODULE
Paul E. McKenney1fbeb3a2020-06-17 11:53:53 -070089# define REFSCALE_SHUTDOWN 0
Joel Fernandes (Google)653ed642020-05-25 00:36:48 -040090#else
Paul E. McKenney1fbeb3a2020-06-17 11:53:53 -070091# define REFSCALE_SHUTDOWN 1
Joel Fernandes (Google)653ed642020-05-25 00:36:48 -040092#endif
93
Paul E. McKenney1fbeb3a2020-06-17 11:53:53 -070094torture_param(bool, shutdown, REFSCALE_SHUTDOWN,
95 "Shutdown at end of scalability tests.");
Joel Fernandes (Google)653ed642020-05-25 00:36:48 -040096
97struct reader_task {
98 struct task_struct *task;
Paul E. McKenneyaf2789d2020-05-26 11:22:03 -070099 int start_reader;
Joel Fernandes (Google)653ed642020-05-25 00:36:48 -0400100 wait_queue_head_t wq;
101 u64 last_duration_ns;
Joel Fernandes (Google)653ed642020-05-25 00:36:48 -0400102};
103
104static struct task_struct *shutdown_task;
105static wait_queue_head_t shutdown_wq;
106
107static struct task_struct *main_task;
108static wait_queue_head_t main_wq;
109static int shutdown_start;
110
111static struct reader_task *reader_tasks;
Joel Fernandes (Google)653ed642020-05-25 00:36:48 -0400112
113// Number of readers that are part of the current experiment.
114static atomic_t nreaders_exp;
115
116// Use to wait for all threads to start.
117static atomic_t n_init;
Paul E. McKenney86e0da22020-05-26 11:40:52 -0700118static atomic_t n_started;
Paul E. McKenney2db0bda2020-05-26 12:34:57 -0700119static atomic_t n_warmedup;
120static atomic_t n_cooleddown;
Joel Fernandes (Google)653ed642020-05-25 00:36:48 -0400121
122// Track which experiment is currently running.
123static int exp_idx;
124
125// Operations vector for selecting different types of tests.
Paul E. McKenney1fbeb3a2020-06-17 11:53:53 -0700126struct ref_scale_ops {
Joel Fernandes (Google)653ed642020-05-25 00:36:48 -0400127 void (*init)(void);
128 void (*cleanup)(void);
Paul E. McKenney75dd8ef2020-05-25 14:59:06 -0700129 void (*readsection)(const int nloops);
Paul E. McKenney918b3512020-05-31 18:14:57 -0700130 void (*delaysection)(const int nloops, const int udl, const int ndl);
Joel Fernandes (Google)653ed642020-05-25 00:36:48 -0400131 const char *name;
132};
133
Paul E. McKenney1fbeb3a2020-06-17 11:53:53 -0700134static struct ref_scale_ops *cur_ops;
Joel Fernandes (Google)653ed642020-05-25 00:36:48 -0400135
Paul E. McKenney918b3512020-05-31 18:14:57 -0700136static void un_delay(const int udl, const int ndl)
137{
138 if (udl)
139 udelay(udl);
140 if (ndl)
141 ndelay(ndl);
142}
143
Paul E. McKenney75dd8ef2020-05-25 14:59:06 -0700144static void ref_rcu_read_section(const int nloops)
Joel Fernandes (Google)653ed642020-05-25 00:36:48 -0400145{
Paul E. McKenney75dd8ef2020-05-25 14:59:06 -0700146 int i;
Joel Fernandes (Google)653ed642020-05-25 00:36:48 -0400147
Paul E. McKenney75dd8ef2020-05-25 14:59:06 -0700148 for (i = nloops; i >= 0; i--) {
149 rcu_read_lock();
150 rcu_read_unlock();
151 }
Joel Fernandes (Google)653ed642020-05-25 00:36:48 -0400152}
153
Paul E. McKenney918b3512020-05-31 18:14:57 -0700154static void ref_rcu_delay_section(const int nloops, const int udl, const int ndl)
Paul E. McKenneyb4d1e342020-05-28 16:37:35 -0700155{
156 int i;
157
158 for (i = nloops; i >= 0; i--) {
159 rcu_read_lock();
Paul E. McKenney918b3512020-05-31 18:14:57 -0700160 un_delay(udl, ndl);
Paul E. McKenneyb4d1e342020-05-28 16:37:35 -0700161 rcu_read_unlock();
162 }
163}
164
Paul E. McKenney1fbeb3a2020-06-17 11:53:53 -0700165static void rcu_sync_scale_init(void)
Joel Fernandes (Google)653ed642020-05-25 00:36:48 -0400166{
167}
168
Paul E. McKenney1fbeb3a2020-06-17 11:53:53 -0700169static struct ref_scale_ops rcu_ops = {
170 .init = rcu_sync_scale_init,
Paul E. McKenney75dd8ef2020-05-25 14:59:06 -0700171 .readsection = ref_rcu_read_section,
Paul E. McKenneyb4d1e342020-05-28 16:37:35 -0700172 .delaysection = ref_rcu_delay_section,
Joel Fernandes (Google)653ed642020-05-25 00:36:48 -0400173 .name = "rcu"
174};
175
Paul E. McKenney1fbeb3a2020-06-17 11:53:53 -0700176// Definitions for SRCU ref scale testing.
177DEFINE_STATIC_SRCU(srcu_refctl_scale);
178static struct srcu_struct *srcu_ctlp = &srcu_refctl_scale;
Joel Fernandes (Google)653ed642020-05-25 00:36:48 -0400179
Paul E. McKenney1fbeb3a2020-06-17 11:53:53 -0700180static void srcu_ref_scale_read_section(const int nloops)
Joel Fernandes (Google)653ed642020-05-25 00:36:48 -0400181{
Paul E. McKenney75dd8ef2020-05-25 14:59:06 -0700182 int i;
183 int idx;
Joel Fernandes (Google)653ed642020-05-25 00:36:48 -0400184
Paul E. McKenney75dd8ef2020-05-25 14:59:06 -0700185 for (i = nloops; i >= 0; i--) {
186 idx = srcu_read_lock(srcu_ctlp);
187 srcu_read_unlock(srcu_ctlp, idx);
188 }
Joel Fernandes (Google)653ed642020-05-25 00:36:48 -0400189}
190
Paul E. McKenney1fbeb3a2020-06-17 11:53:53 -0700191static void srcu_ref_scale_delay_section(const int nloops, const int udl, const int ndl)
Paul E. McKenneyb4d1e342020-05-28 16:37:35 -0700192{
193 int i;
194 int idx;
195
196 for (i = nloops; i >= 0; i--) {
197 idx = srcu_read_lock(srcu_ctlp);
Paul E. McKenney918b3512020-05-31 18:14:57 -0700198 un_delay(udl, ndl);
Paul E. McKenneyb4d1e342020-05-28 16:37:35 -0700199 srcu_read_unlock(srcu_ctlp, idx);
200 }
201}
202
Paul E. McKenney1fbeb3a2020-06-17 11:53:53 -0700203static struct ref_scale_ops srcu_ops = {
204 .init = rcu_sync_scale_init,
205 .readsection = srcu_ref_scale_read_section,
206 .delaysection = srcu_ref_scale_delay_section,
Joel Fernandes (Google)653ed642020-05-25 00:36:48 -0400207 .name = "srcu"
208};
209
Paul E. McKenney1fbeb3a2020-06-17 11:53:53 -0700210// Definitions for RCU Tasks ref scale testing: Empty read markers.
Paul E. McKenneye13ef442020-06-03 11:56:34 -0700211// These definitions also work for RCU Rude readers.
Paul E. McKenney1fbeb3a2020-06-17 11:53:53 -0700212static void rcu_tasks_ref_scale_read_section(const int nloops)
Paul E. McKenneye13ef442020-06-03 11:56:34 -0700213{
214 int i;
215
216 for (i = nloops; i >= 0; i--)
217 continue;
218}
219
Paul E. McKenney1fbeb3a2020-06-17 11:53:53 -0700220static void rcu_tasks_ref_scale_delay_section(const int nloops, const int udl, const int ndl)
Paul E. McKenneye13ef442020-06-03 11:56:34 -0700221{
222 int i;
223
224 for (i = nloops; i >= 0; i--)
225 un_delay(udl, ndl);
226}
227
Paul E. McKenney1fbeb3a2020-06-17 11:53:53 -0700228static struct ref_scale_ops rcu_tasks_ops = {
229 .init = rcu_sync_scale_init,
230 .readsection = rcu_tasks_ref_scale_read_section,
231 .delaysection = rcu_tasks_ref_scale_delay_section,
Paul E. McKenneye13ef442020-06-03 11:56:34 -0700232 .name = "rcu-tasks"
233};
234
Paul E. McKenney1fbeb3a2020-06-17 11:53:53 -0700235// Definitions for RCU Tasks Trace ref scale testing.
236static void rcu_trace_ref_scale_read_section(const int nloops)
Paul E. McKenney72bb7492020-06-02 08:34:41 -0700237{
238 int i;
239
240 for (i = nloops; i >= 0; i--) {
241 rcu_read_lock_trace();
242 rcu_read_unlock_trace();
243 }
244}
245
Paul E. McKenney1fbeb3a2020-06-17 11:53:53 -0700246static void rcu_trace_ref_scale_delay_section(const int nloops, const int udl, const int ndl)
Paul E. McKenney72bb7492020-06-02 08:34:41 -0700247{
248 int i;
249
250 for (i = nloops; i >= 0; i--) {
251 rcu_read_lock_trace();
252 un_delay(udl, ndl);
253 rcu_read_unlock_trace();
254 }
255}
256
Paul E. McKenney1fbeb3a2020-06-17 11:53:53 -0700257static struct ref_scale_ops rcu_trace_ops = {
258 .init = rcu_sync_scale_init,
259 .readsection = rcu_trace_ref_scale_read_section,
260 .delaysection = rcu_trace_ref_scale_delay_section,
Paul E. McKenney72bb7492020-06-02 08:34:41 -0700261 .name = "rcu-trace"
262};
263
Joel Fernandes (Google)653ed642020-05-25 00:36:48 -0400264// Definitions for reference count
265static atomic_t refcnt;
266
Paul E. McKenneyb4d1e342020-05-28 16:37:35 -0700267static void ref_refcnt_section(const int nloops)
Joel Fernandes (Google)653ed642020-05-25 00:36:48 -0400268{
Paul E. McKenney75dd8ef2020-05-25 14:59:06 -0700269 int i;
Joel Fernandes (Google)653ed642020-05-25 00:36:48 -0400270
Paul E. McKenney75dd8ef2020-05-25 14:59:06 -0700271 for (i = nloops; i >= 0; i--) {
272 atomic_inc(&refcnt);
273 atomic_dec(&refcnt);
274 }
Joel Fernandes (Google)653ed642020-05-25 00:36:48 -0400275}
276
Paul E. McKenney918b3512020-05-31 18:14:57 -0700277static void ref_refcnt_delay_section(const int nloops, const int udl, const int ndl)
Paul E. McKenneyb4d1e342020-05-28 16:37:35 -0700278{
279 int i;
280
281 for (i = nloops; i >= 0; i--) {
282 atomic_inc(&refcnt);
Paul E. McKenney918b3512020-05-31 18:14:57 -0700283 un_delay(udl, ndl);
Paul E. McKenneyb4d1e342020-05-28 16:37:35 -0700284 atomic_dec(&refcnt);
285 }
286}
287
Paul E. McKenney1fbeb3a2020-06-17 11:53:53 -0700288static struct ref_scale_ops refcnt_ops = {
289 .init = rcu_sync_scale_init,
Paul E. McKenneyb4d1e342020-05-28 16:37:35 -0700290 .readsection = ref_refcnt_section,
291 .delaysection = ref_refcnt_delay_section,
Joel Fernandes (Google)653ed642020-05-25 00:36:48 -0400292 .name = "refcnt"
293};
294
295// Definitions for rwlock
296static rwlock_t test_rwlock;
297
Paul E. McKenneyb4d1e342020-05-28 16:37:35 -0700298static void ref_rwlock_init(void)
Joel Fernandes (Google)653ed642020-05-25 00:36:48 -0400299{
300 rwlock_init(&test_rwlock);
301}
302
Paul E. McKenneyb4d1e342020-05-28 16:37:35 -0700303static void ref_rwlock_section(const int nloops)
Joel Fernandes (Google)653ed642020-05-25 00:36:48 -0400304{
Paul E. McKenney75dd8ef2020-05-25 14:59:06 -0700305 int i;
Joel Fernandes (Google)653ed642020-05-25 00:36:48 -0400306
Paul E. McKenney75dd8ef2020-05-25 14:59:06 -0700307 for (i = nloops; i >= 0; i--) {
308 read_lock(&test_rwlock);
309 read_unlock(&test_rwlock);
310 }
Joel Fernandes (Google)653ed642020-05-25 00:36:48 -0400311}
312
Paul E. McKenney918b3512020-05-31 18:14:57 -0700313static void ref_rwlock_delay_section(const int nloops, const int udl, const int ndl)
Paul E. McKenneyb4d1e342020-05-28 16:37:35 -0700314{
315 int i;
316
317 for (i = nloops; i >= 0; i--) {
318 read_lock(&test_rwlock);
Paul E. McKenney918b3512020-05-31 18:14:57 -0700319 un_delay(udl, ndl);
Paul E. McKenneyb4d1e342020-05-28 16:37:35 -0700320 read_unlock(&test_rwlock);
321 }
322}
323
Paul E. McKenney1fbeb3a2020-06-17 11:53:53 -0700324static struct ref_scale_ops rwlock_ops = {
Paul E. McKenneyb4d1e342020-05-28 16:37:35 -0700325 .init = ref_rwlock_init,
326 .readsection = ref_rwlock_section,
327 .delaysection = ref_rwlock_delay_section,
Joel Fernandes (Google)653ed642020-05-25 00:36:48 -0400328 .name = "rwlock"
329};
330
331// Definitions for rwsem
332static struct rw_semaphore test_rwsem;
333
Paul E. McKenneyb4d1e342020-05-28 16:37:35 -0700334static void ref_rwsem_init(void)
Joel Fernandes (Google)653ed642020-05-25 00:36:48 -0400335{
336 init_rwsem(&test_rwsem);
337}
338
Paul E. McKenneyb4d1e342020-05-28 16:37:35 -0700339static void ref_rwsem_section(const int nloops)
Joel Fernandes (Google)653ed642020-05-25 00:36:48 -0400340{
Paul E. McKenney75dd8ef2020-05-25 14:59:06 -0700341 int i;
Joel Fernandes (Google)653ed642020-05-25 00:36:48 -0400342
Paul E. McKenney75dd8ef2020-05-25 14:59:06 -0700343 for (i = nloops; i >= 0; i--) {
344 down_read(&test_rwsem);
345 up_read(&test_rwsem);
346 }
Joel Fernandes (Google)653ed642020-05-25 00:36:48 -0400347}
348
Paul E. McKenney918b3512020-05-31 18:14:57 -0700349static void ref_rwsem_delay_section(const int nloops, const int udl, const int ndl)
Paul E. McKenneyb4d1e342020-05-28 16:37:35 -0700350{
351 int i;
352
353 for (i = nloops; i >= 0; i--) {
354 down_read(&test_rwsem);
Paul E. McKenney918b3512020-05-31 18:14:57 -0700355 un_delay(udl, ndl);
Paul E. McKenneyb4d1e342020-05-28 16:37:35 -0700356 up_read(&test_rwsem);
357 }
358}
359
Paul E. McKenney1fbeb3a2020-06-17 11:53:53 -0700360static struct ref_scale_ops rwsem_ops = {
Paul E. McKenneyb4d1e342020-05-28 16:37:35 -0700361 .init = ref_rwsem_init,
362 .readsection = ref_rwsem_section,
363 .delaysection = ref_rwsem_delay_section,
Joel Fernandes (Google)653ed642020-05-25 00:36:48 -0400364 .name = "rwsem"
365};
366
Paul E. McKenneye9b800d2021-03-10 18:02:36 -0800367// Definitions for global spinlock
368static DEFINE_SPINLOCK(test_lock);
369
370static void ref_lock_section(const int nloops)
371{
372 int i;
373
374 preempt_disable();
375 for (i = nloops; i >= 0; i--) {
376 spin_lock(&test_lock);
377 spin_unlock(&test_lock);
378 }
379 preempt_enable();
380}
381
382static void ref_lock_delay_section(const int nloops, const int udl, const int ndl)
383{
384 int i;
385
386 preempt_disable();
387 for (i = nloops; i >= 0; i--) {
388 spin_lock(&test_lock);
389 un_delay(udl, ndl);
390 spin_unlock(&test_lock);
391 }
392 preempt_enable();
393}
394
395static struct ref_scale_ops lock_ops = {
396 .readsection = ref_lock_section,
397 .delaysection = ref_lock_delay_section,
398 .name = "lock"
399};
400
401// Definitions for global irq-save spinlock
402
403static void ref_lock_irq_section(const int nloops)
404{
405 unsigned long flags;
406 int i;
407
408 preempt_disable();
409 for (i = nloops; i >= 0; i--) {
410 spin_lock_irqsave(&test_lock, flags);
411 spin_unlock_irqrestore(&test_lock, flags);
412 }
413 preempt_enable();
414}
415
416static void ref_lock_irq_delay_section(const int nloops, const int udl, const int ndl)
417{
418 unsigned long flags;
419 int i;
420
421 preempt_disable();
422 for (i = nloops; i >= 0; i--) {
423 spin_lock_irqsave(&test_lock, flags);
424 un_delay(udl, ndl);
425 spin_unlock_irqrestore(&test_lock, flags);
426 }
427 preempt_enable();
428}
429
430static struct ref_scale_ops lock_irq_ops = {
431 .readsection = ref_lock_irq_section,
432 .delaysection = ref_lock_irq_delay_section,
433 .name = "lock-irq"
434};
435
436// Definitions acquire-release.
437static DEFINE_PER_CPU(unsigned long, test_acqrel);
438
439static void ref_acqrel_section(const int nloops)
440{
441 unsigned long x;
442 int i;
443
444 preempt_disable();
445 for (i = nloops; i >= 0; i--) {
446 x = smp_load_acquire(this_cpu_ptr(&test_acqrel));
447 smp_store_release(this_cpu_ptr(&test_acqrel), x + 1);
448 }
449 preempt_enable();
450}
451
452static void ref_acqrel_delay_section(const int nloops, const int udl, const int ndl)
453{
454 unsigned long x;
455 int i;
456
457 preempt_disable();
458 for (i = nloops; i >= 0; i--) {
459 x = smp_load_acquire(this_cpu_ptr(&test_acqrel));
460 un_delay(udl, ndl);
461 smp_store_release(this_cpu_ptr(&test_acqrel), x + 1);
462 }
463 preempt_enable();
464}
465
466static struct ref_scale_ops acqrel_ops = {
467 .readsection = ref_acqrel_section,
468 .delaysection = ref_acqrel_delay_section,
469 .name = "acqrel"
470};
471
Paul E. McKenney25f6fa52021-05-03 17:04:57 -0700472static volatile u64 stopopts;
473
474static void ref_clock_section(const int nloops)
475{
476 u64 x = 0;
477 int i;
478
479 preempt_disable();
480 for (i = nloops; i >= 0; i--)
481 x += ktime_get_real_fast_ns();
482 preempt_enable();
483 stopopts = x;
484}
485
486static void ref_clock_delay_section(const int nloops, const int udl, const int ndl)
487{
488 u64 x = 0;
489 int i;
490
491 preempt_disable();
492 for (i = nloops; i >= 0; i--) {
493 x += ktime_get_real_fast_ns();
494 un_delay(udl, ndl);
495 }
496 preempt_enable();
497 stopopts = x;
498}
499
500static struct ref_scale_ops clock_ops = {
501 .readsection = ref_clock_section,
502 .delaysection = ref_clock_delay_section,
503 .name = "clock"
504};
505
Paul E. McKenney1fbeb3a2020-06-17 11:53:53 -0700506static void rcu_scale_one_reader(void)
Paul E. McKenneyb4d1e342020-05-28 16:37:35 -0700507{
508 if (readdelay <= 0)
509 cur_ops->readsection(loops);
510 else
Paul E. McKenney918b3512020-05-31 18:14:57 -0700511 cur_ops->delaysection(loops, readdelay / 1000, readdelay % 1000);
Paul E. McKenneyb4d1e342020-05-28 16:37:35 -0700512}
513
Joel Fernandes (Google)653ed642020-05-25 00:36:48 -0400514// Reader kthread. Repeatedly does empty RCU read-side
515// critical section, minimizing update-side interference.
516static int
Paul E. McKenney1fbeb3a2020-06-17 11:53:53 -0700517ref_scale_reader(void *arg)
Joel Fernandes (Google)653ed642020-05-25 00:36:48 -0400518{
519 unsigned long flags;
520 long me = (long)arg;
521 struct reader_task *rt = &(reader_tasks[me]);
Joel Fernandes (Google)653ed642020-05-25 00:36:48 -0400522 u64 start;
523 s64 duration;
524
Paul E. McKenneye76506f2020-11-15 10:24:52 -0800525 VERBOSE_SCALEOUT_BATCH("ref_scale_reader %ld: task started", me);
Paul E. McKenney05bc2762021-06-10 09:24:43 -0700526 WARN_ON_ONCE(set_cpus_allowed_ptr(current, cpumask_of(me % nr_cpu_ids)));
Joel Fernandes (Google)653ed642020-05-25 00:36:48 -0400527 set_user_nice(current, MAX_NICE);
528 atomic_inc(&n_init);
Paul E. McKenney777a54c2020-05-25 14:16:44 -0700529 if (holdoff)
530 schedule_timeout_interruptible(holdoff * HZ);
Joel Fernandes (Google)653ed642020-05-25 00:36:48 -0400531repeat:
Paul E. McKenney05bc2762021-06-10 09:24:43 -0700532 VERBOSE_SCALEOUT_BATCH("ref_scale_reader %ld: waiting to start next experiment on cpu %d", me, raw_smp_processor_id());
Joel Fernandes (Google)653ed642020-05-25 00:36:48 -0400533
534 // Wait for signal that this reader can start.
Paul E. McKenneyaf2789d2020-05-26 11:22:03 -0700535 wait_event(rt->wq, (atomic_read(&nreaders_exp) && smp_load_acquire(&rt->start_reader)) ||
Joel Fernandes (Google)653ed642020-05-25 00:36:48 -0400536 torture_must_stop());
537
538 if (torture_must_stop())
539 goto end;
540
541 // Make sure that the CPU is affinitized appropriately during testing.
Paul E. McKenney05bc2762021-06-10 09:24:43 -0700542 WARN_ON_ONCE(raw_smp_processor_id() != me);
Joel Fernandes (Google)653ed642020-05-25 00:36:48 -0400543
Paul E. McKenneyaf2789d2020-05-26 11:22:03 -0700544 WRITE_ONCE(rt->start_reader, 0);
Paul E. McKenney86e0da22020-05-26 11:40:52 -0700545 if (!atomic_dec_return(&n_started))
546 while (atomic_read_acquire(&n_started))
547 cpu_relax();
Joel Fernandes (Google)653ed642020-05-25 00:36:48 -0400548
Paul E. McKenneye76506f2020-11-15 10:24:52 -0800549 VERBOSE_SCALEOUT_BATCH("ref_scale_reader %ld: experiment %d started", me, exp_idx);
Paul E. McKenneyb864f892020-05-26 10:57:34 -0700550
Paul E. McKenney2db0bda2020-05-26 12:34:57 -0700551
552 // To reduce noise, do an initial cache-warming invocation, check
553 // in, and then keep warming until everyone has checked in.
Paul E. McKenney1fbeb3a2020-06-17 11:53:53 -0700554 rcu_scale_one_reader();
Paul E. McKenney2db0bda2020-05-26 12:34:57 -0700555 if (!atomic_dec_return(&n_warmedup))
556 while (atomic_read_acquire(&n_warmedup))
Paul E. McKenney1fbeb3a2020-06-17 11:53:53 -0700557 rcu_scale_one_reader();
Paul E. McKenney2db0bda2020-05-26 12:34:57 -0700558 // Also keep interrupts disabled. This also has the effect
559 // of preventing entries into slow path for rcu_read_unlock().
Joel Fernandes (Google)653ed642020-05-25 00:36:48 -0400560 local_irq_save(flags);
561 start = ktime_get_mono_fast_ns();
562
Paul E. McKenney1fbeb3a2020-06-17 11:53:53 -0700563 rcu_scale_one_reader();
Joel Fernandes (Google)653ed642020-05-25 00:36:48 -0400564
565 duration = ktime_get_mono_fast_ns() - start;
566 local_irq_restore(flags);
567
568 rt->last_duration_ns = WARN_ON_ONCE(duration < 0) ? 0 : duration;
Paul E. McKenney2db0bda2020-05-26 12:34:57 -0700569 // To reduce runtime-skew noise, do maintain-load invocations until
570 // everyone is done.
571 if (!atomic_dec_return(&n_cooleddown))
572 while (atomic_read_acquire(&n_cooleddown))
Paul E. McKenney1fbeb3a2020-06-17 11:53:53 -0700573 rcu_scale_one_reader();
Joel Fernandes (Google)653ed642020-05-25 00:36:48 -0400574
Paul E. McKenneyb864f892020-05-26 10:57:34 -0700575 if (atomic_dec_and_test(&nreaders_exp))
576 wake_up(&main_wq);
Joel Fernandes (Google)653ed642020-05-25 00:36:48 -0400577
Paul E. McKenneye76506f2020-11-15 10:24:52 -0800578 VERBOSE_SCALEOUT_BATCH("ref_scale_reader %ld: experiment %d ended, (readers remaining=%d)",
579 me, exp_idx, atomic_read(&nreaders_exp));
Joel Fernandes (Google)653ed642020-05-25 00:36:48 -0400580
Joel Fernandes (Google)653ed642020-05-25 00:36:48 -0400581 if (!torture_must_stop())
582 goto repeat;
583end:
Paul E. McKenney1fbeb3a2020-06-17 11:53:53 -0700584 torture_kthread_stopping("ref_scale_reader");
Joel Fernandes (Google)653ed642020-05-25 00:36:48 -0400585 return 0;
586}
587
Paul E. McKenney29907502020-05-26 09:32:57 -0700588static void reset_readers(void)
Joel Fernandes (Google)653ed642020-05-25 00:36:48 -0400589{
590 int i;
591 struct reader_task *rt;
592
Paul E. McKenneydbf28ef2020-05-25 17:22:24 -0700593 for (i = 0; i < nreaders; i++) {
Joel Fernandes (Google)653ed642020-05-25 00:36:48 -0400594 rt = &(reader_tasks[i]);
595
596 rt->last_duration_ns = 0;
597 }
598}
599
600// Print the results of each reader and return the sum of all their durations.
Paul E. McKenney29907502020-05-26 09:32:57 -0700601static u64 process_durations(int n)
Joel Fernandes (Google)653ed642020-05-25 00:36:48 -0400602{
603 int i;
604 struct reader_task *rt;
605 char buf1[64];
Paul E. McKenney2e90de72020-05-25 17:45:03 -0700606 char *buf;
Joel Fernandes (Google)653ed642020-05-25 00:36:48 -0400607 u64 sum = 0;
608
Li Zhijian9880eb82021-10-25 11:26:57 +0800609 buf = kmalloc(800 + 64, GFP_KERNEL);
Paul E. McKenney2e90de72020-05-25 17:45:03 -0700610 if (!buf)
611 return 0;
Joel Fernandes (Google)653ed642020-05-25 00:36:48 -0400612 buf[0] = 0;
613 sprintf(buf, "Experiment #%d (Format: <THREAD-NUM>:<Total loop time in ns>)",
614 exp_idx);
615
Paul E. McKenneydbf28ef2020-05-25 17:22:24 -0700616 for (i = 0; i < n && !torture_must_stop(); i++) {
Joel Fernandes (Google)653ed642020-05-25 00:36:48 -0400617 rt = &(reader_tasks[i]);
618 sprintf(buf1, "%d: %llu\t", i, rt->last_duration_ns);
619
620 if (i % 5 == 0)
621 strcat(buf, "\n");
Li Zhijian9880eb82021-10-25 11:26:57 +0800622 if (strlen(buf) >= 800) {
623 pr_alert("%s", buf);
624 buf[0] = 0;
625 }
Joel Fernandes (Google)653ed642020-05-25 00:36:48 -0400626 strcat(buf, buf1);
627
628 sum += rt->last_duration_ns;
629 }
Li Zhijian9880eb82021-10-25 11:26:57 +0800630 pr_alert("%s\n", buf);
Joel Fernandes (Google)653ed642020-05-25 00:36:48 -0400631
Paul E. McKenney2e90de72020-05-25 17:45:03 -0700632 kfree(buf);
Joel Fernandes (Google)653ed642020-05-25 00:36:48 -0400633 return sum;
634}
635
636// The main_func is the main orchestrator, it performs a bunch of
637// experiments. For every experiment, it orders all the readers
638// involved to start and waits for them to finish the experiment. It
639// then reads their timestamps and starts the next experiment. Each
640// experiment progresses from 1 concurrent reader to N of them at which
641// point all the timestamps are printed.
642static int main_func(void *arg)
643{
644 int exp, r;
645 char buf1[64];
Paul E. McKenneyf518f152020-05-25 17:32:56 -0700646 char *buf;
Paul E. McKenneydbf28ef2020-05-25 17:22:24 -0700647 u64 *result_avg;
Joel Fernandes (Google)653ed642020-05-25 00:36:48 -0400648
649 set_cpus_allowed_ptr(current, cpumask_of(nreaders % nr_cpu_ids));
650 set_user_nice(current, MAX_NICE);
651
Paul E. McKenney1fbeb3a2020-06-17 11:53:53 -0700652 VERBOSE_SCALEOUT("main_func task started");
Paul E. McKenneydbf28ef2020-05-25 17:22:24 -0700653 result_avg = kzalloc(nruns * sizeof(*result_avg), GFP_KERNEL);
Li Zhijian9880eb82021-10-25 11:26:57 +0800654 buf = kzalloc(800 + 64, GFP_KERNEL);
Paul E. McKenneyf518f152020-05-25 17:32:56 -0700655 if (!result_avg || !buf) {
Li Zhijian4feeb9d2021-10-25 11:26:58 +0800656 SCALEOUT_ERRSTRING("out of memory");
Li Zhijianc30c8762021-10-25 11:26:56 +0800657 goto oom_exit;
Paul E. McKenneyf518f152020-05-25 17:32:56 -0700658 }
Paul E. McKenney777a54c2020-05-25 14:16:44 -0700659 if (holdoff)
660 schedule_timeout_interruptible(holdoff * HZ);
Joel Fernandes (Google)653ed642020-05-25 00:36:48 -0400661
Paul E. McKenney96af8662020-05-27 16:46:56 -0700662 // Wait for all threads to start.
663 atomic_inc(&n_init);
664 while (atomic_read(&n_init) < nreaders + 1)
665 schedule_timeout_uninterruptible(1);
666
Joel Fernandes (Google)653ed642020-05-25 00:36:48 -0400667 // Start exp readers up per experiment
Paul E. McKenneydbf28ef2020-05-25 17:22:24 -0700668 for (exp = 0; exp < nruns && !torture_must_stop(); exp++) {
Joel Fernandes (Google)653ed642020-05-25 00:36:48 -0400669 if (torture_must_stop())
670 goto end;
671
Paul E. McKenneydbf28ef2020-05-25 17:22:24 -0700672 reset_readers();
673 atomic_set(&nreaders_exp, nreaders);
Paul E. McKenney86e0da22020-05-26 11:40:52 -0700674 atomic_set(&n_started, nreaders);
Paul E. McKenney2db0bda2020-05-26 12:34:57 -0700675 atomic_set(&n_warmedup, nreaders);
676 atomic_set(&n_cooleddown, nreaders);
Joel Fernandes (Google)653ed642020-05-25 00:36:48 -0400677
678 exp_idx = exp;
679
Paul E. McKenneydbf28ef2020-05-25 17:22:24 -0700680 for (r = 0; r < nreaders; r++) {
Paul E. McKenneyaf2789d2020-05-26 11:22:03 -0700681 smp_store_release(&reader_tasks[r].start_reader, 1);
Joel Fernandes (Google)653ed642020-05-25 00:36:48 -0400682 wake_up(&reader_tasks[r].wq);
683 }
684
Paul E. McKenney1fbeb3a2020-06-17 11:53:53 -0700685 VERBOSE_SCALEOUT("main_func: experiment started, waiting for %d readers",
Paul E. McKenneydbf28ef2020-05-25 17:22:24 -0700686 nreaders);
Joel Fernandes (Google)653ed642020-05-25 00:36:48 -0400687
688 wait_event(main_wq,
689 !atomic_read(&nreaders_exp) || torture_must_stop());
690
Paul E. McKenney1fbeb3a2020-06-17 11:53:53 -0700691 VERBOSE_SCALEOUT("main_func: experiment ended");
Joel Fernandes (Google)653ed642020-05-25 00:36:48 -0400692
693 if (torture_must_stop())
694 goto end;
695
Arnd Bergmann7c944d72020-05-29 14:36:26 -0700696 result_avg[exp] = div_u64(1000 * process_durations(nreaders), nreaders * loops);
Joel Fernandes (Google)653ed642020-05-25 00:36:48 -0400697 }
698
699 // Print the average of all experiments
Paul E. McKenney1fbeb3a2020-06-17 11:53:53 -0700700 SCALEOUT("END OF TEST. Calculating average duration per loop (nanoseconds)...\n");
Joel Fernandes (Google)653ed642020-05-25 00:36:48 -0400701
Li Zhijian9880eb82021-10-25 11:26:57 +0800702 pr_alert("Runs\tTime(ns)\n");
Paul E. McKenneydbf28ef2020-05-25 17:22:24 -0700703 for (exp = 0; exp < nruns; exp++) {
Arnd Bergmann7c944d72020-05-29 14:36:26 -0700704 u64 avg;
705 u32 rem;
706
Arnd Bergmann7c944d72020-05-29 14:36:26 -0700707 avg = div_u64_rem(result_avg[exp], 1000, &rem);
708 sprintf(buf1, "%d\t%llu.%03u\n", exp + 1, avg, rem);
Joel Fernandes (Google)653ed642020-05-25 00:36:48 -0400709 strcat(buf, buf1);
Li Zhijian9880eb82021-10-25 11:26:57 +0800710 if (strlen(buf) >= 800) {
711 pr_alert("%s", buf);
712 buf[0] = 0;
713 }
Joel Fernandes (Google)653ed642020-05-25 00:36:48 -0400714 }
715
Li Zhijian9880eb82021-10-25 11:26:57 +0800716 pr_alert("%s", buf);
Joel Fernandes (Google)653ed642020-05-25 00:36:48 -0400717
Li Zhijianc30c8762021-10-25 11:26:56 +0800718oom_exit:
Joel Fernandes (Google)653ed642020-05-25 00:36:48 -0400719 // This will shutdown everything including us.
720 if (shutdown) {
721 shutdown_start = 1;
722 wake_up(&shutdown_wq);
723 }
724
725 // Wait for torture to stop us
726 while (!torture_must_stop())
727 schedule_timeout_uninterruptible(1);
728
729end:
730 torture_kthread_stopping("main_func");
Paul E. McKenneyf518f152020-05-25 17:32:56 -0700731 kfree(result_avg);
732 kfree(buf);
Joel Fernandes (Google)653ed642020-05-25 00:36:48 -0400733 return 0;
734}
735
736static void
Paul E. McKenney1fbeb3a2020-06-17 11:53:53 -0700737ref_scale_print_module_parms(struct ref_scale_ops *cur_ops, const char *tag)
Joel Fernandes (Google)653ed642020-05-25 00:36:48 -0400738{
Paul E. McKenney1fbeb3a2020-06-17 11:53:53 -0700739 pr_alert("%s" SCALE_FLAG
740 "--- %s: verbose=%d shutdown=%d holdoff=%d loops=%ld nreaders=%d nruns=%d readdelay=%d\n", scale_type, tag,
Paul E. McKenneyb4d1e342020-05-28 16:37:35 -0700741 verbose, shutdown, holdoff, loops, nreaders, nruns, readdelay);
Joel Fernandes (Google)653ed642020-05-25 00:36:48 -0400742}
743
744static void
Paul E. McKenney1fbeb3a2020-06-17 11:53:53 -0700745ref_scale_cleanup(void)
Joel Fernandes (Google)653ed642020-05-25 00:36:48 -0400746{
747 int i;
748
749 if (torture_cleanup_begin())
750 return;
751
752 if (!cur_ops) {
753 torture_cleanup_end();
754 return;
755 }
756
757 if (reader_tasks) {
758 for (i = 0; i < nreaders; i++)
Paul E. McKenney1fbeb3a2020-06-17 11:53:53 -0700759 torture_stop_kthread("ref_scale_reader",
Joel Fernandes (Google)653ed642020-05-25 00:36:48 -0400760 reader_tasks[i].task);
761 }
762 kfree(reader_tasks);
763
764 torture_stop_kthread("main_task", main_task);
765 kfree(main_task);
766
Paul E. McKenney1fbeb3a2020-06-17 11:53:53 -0700767 // Do scale-type-specific cleanup operations.
Joel Fernandes (Google)653ed642020-05-25 00:36:48 -0400768 if (cur_ops->cleanup != NULL)
769 cur_ops->cleanup();
770
771 torture_cleanup_end();
772}
773
774// Shutdown kthread. Just waits to be awakened, then shuts down system.
775static int
Paul E. McKenney1fbeb3a2020-06-17 11:53:53 -0700776ref_scale_shutdown(void *arg)
Joel Fernandes (Google)653ed642020-05-25 00:36:48 -0400777{
778 wait_event(shutdown_wq, shutdown_start);
779
780 smp_mb(); // Wake before output.
Paul E. McKenney1fbeb3a2020-06-17 11:53:53 -0700781 ref_scale_cleanup();
Joel Fernandes (Google)653ed642020-05-25 00:36:48 -0400782 kernel_power_off();
783
784 return -EINVAL;
785}
786
787static int __init
Paul E. McKenney1fbeb3a2020-06-17 11:53:53 -0700788ref_scale_init(void)
Joel Fernandes (Google)653ed642020-05-25 00:36:48 -0400789{
790 long i;
791 int firsterr = 0;
Paul E. McKenney1fbeb3a2020-06-17 11:53:53 -0700792 static struct ref_scale_ops *scale_ops[] = {
Paul E. McKenneye9b800d2021-03-10 18:02:36 -0800793 &rcu_ops, &srcu_ops, &rcu_trace_ops, &rcu_tasks_ops, &refcnt_ops, &rwlock_ops,
Paul E. McKenney25f6fa52021-05-03 17:04:57 -0700794 &rwsem_ops, &lock_ops, &lock_irq_ops, &acqrel_ops, &clock_ops,
Joel Fernandes (Google)653ed642020-05-25 00:36:48 -0400795 };
796
Paul E. McKenney1fbeb3a2020-06-17 11:53:53 -0700797 if (!torture_init_begin(scale_type, verbose))
Joel Fernandes (Google)653ed642020-05-25 00:36:48 -0400798 return -EBUSY;
799
Paul E. McKenney1fbeb3a2020-06-17 11:53:53 -0700800 for (i = 0; i < ARRAY_SIZE(scale_ops); i++) {
801 cur_ops = scale_ops[i];
802 if (strcmp(scale_type, cur_ops->name) == 0)
Joel Fernandes (Google)653ed642020-05-25 00:36:48 -0400803 break;
804 }
Paul E. McKenney1fbeb3a2020-06-17 11:53:53 -0700805 if (i == ARRAY_SIZE(scale_ops)) {
806 pr_alert("rcu-scale: invalid scale type: \"%s\"\n", scale_type);
807 pr_alert("rcu-scale types:");
808 for (i = 0; i < ARRAY_SIZE(scale_ops); i++)
809 pr_cont(" %s", scale_ops[i]->name);
Joel Fernandes (Google)653ed642020-05-25 00:36:48 -0400810 pr_cont("\n");
Joel Fernandes (Google)653ed642020-05-25 00:36:48 -0400811 firsterr = -EINVAL;
812 cur_ops = NULL;
813 goto unwind;
814 }
815 if (cur_ops->init)
816 cur_ops->init();
817
Paul E. McKenney1fbeb3a2020-06-17 11:53:53 -0700818 ref_scale_print_module_parms(cur_ops, "Start of test");
Joel Fernandes (Google)653ed642020-05-25 00:36:48 -0400819
820 // Shutdown task
821 if (shutdown) {
822 init_waitqueue_head(&shutdown_wq);
Paul E. McKenney1fbeb3a2020-06-17 11:53:53 -0700823 firsterr = torture_create_kthread(ref_scale_shutdown, NULL,
Joel Fernandes (Google)653ed642020-05-25 00:36:48 -0400824 shutdown_task);
Paul E. McKenneyed60ad72021-08-05 15:57:12 -0700825 if (torture_init_error(firsterr))
Joel Fernandes (Google)653ed642020-05-25 00:36:48 -0400826 goto unwind;
827 schedule_timeout_uninterruptible(1);
828 }
829
Paul E. McKenney8fc28782020-05-25 15:48:38 -0700830 // Reader tasks (default to ~75% of online CPUs).
831 if (nreaders < 0)
832 nreaders = (num_online_cpus() >> 1) + (num_online_cpus() >> 2);
Paul E. McKenney0c6d18d2020-08-27 09:58:19 -0700833 if (WARN_ONCE(loops <= 0, "%s: loops = %ld, adjusted to 1\n", __func__, loops))
834 loops = 1;
835 if (WARN_ONCE(nreaders <= 0, "%s: nreaders = %d, adjusted to 1\n", __func__, nreaders))
836 nreaders = 1;
837 if (WARN_ONCE(nruns <= 0, "%s: nruns = %d, adjusted to 1\n", __func__, nruns))
838 nruns = 1;
Joel Fernandes (Google)653ed642020-05-25 00:36:48 -0400839 reader_tasks = kcalloc(nreaders, sizeof(reader_tasks[0]),
840 GFP_KERNEL);
841 if (!reader_tasks) {
Li Zhijian4feeb9d2021-10-25 11:26:58 +0800842 SCALEOUT_ERRSTRING("out of memory");
Joel Fernandes (Google)653ed642020-05-25 00:36:48 -0400843 firsterr = -ENOMEM;
844 goto unwind;
845 }
846
Li Zhijianf71f22b2021-10-29 17:40:24 +0800847 VERBOSE_SCALEOUT("Starting %d reader threads", nreaders);
Joel Fernandes (Google)653ed642020-05-25 00:36:48 -0400848
849 for (i = 0; i < nreaders; i++) {
Paul E. McKenney1fbeb3a2020-06-17 11:53:53 -0700850 firsterr = torture_create_kthread(ref_scale_reader, (void *)i,
Joel Fernandes (Google)653ed642020-05-25 00:36:48 -0400851 reader_tasks[i].task);
Paul E. McKenneyed60ad72021-08-05 15:57:12 -0700852 if (torture_init_error(firsterr))
Joel Fernandes (Google)653ed642020-05-25 00:36:48 -0400853 goto unwind;
854
855 init_waitqueue_head(&(reader_tasks[i].wq));
856 }
857
858 // Main Task
859 init_waitqueue_head(&main_wq);
860 firsterr = torture_create_kthread(main_func, NULL, main_task);
Paul E. McKenneyed60ad72021-08-05 15:57:12 -0700861 if (torture_init_error(firsterr))
Joel Fernandes (Google)653ed642020-05-25 00:36:48 -0400862 goto unwind;
Joel Fernandes (Google)653ed642020-05-25 00:36:48 -0400863
864 torture_init_end();
865 return 0;
866
867unwind:
868 torture_init_end();
Paul E. McKenney1fbeb3a2020-06-17 11:53:53 -0700869 ref_scale_cleanup();
Paul E. McKenneybc80d352020-09-17 10:37:10 -0700870 if (shutdown) {
871 WARN_ON(!IS_MODULE(CONFIG_RCU_REF_SCALE_TEST));
872 kernel_power_off();
873 }
Joel Fernandes (Google)653ed642020-05-25 00:36:48 -0400874 return firsterr;
875}
876
Paul E. McKenney1fbeb3a2020-06-17 11:53:53 -0700877module_init(ref_scale_init);
878module_exit(ref_scale_cleanup);