refscale: Allow summarization of verbose output
authorPaul E. McKenney <paulmck@kernel.org>
Sun, 15 Nov 2020 18:24:52 +0000 (10:24 -0800)
committerPaul E. McKenney <paulmck@kernel.org>
Thu, 7 Jan 2021 01:08:09 +0000 (17:08 -0800)
The refscale test prints enough per-kthread console output to provoke RCU
CPU stall warnings on large systems.  This commit therefore allows this
output to be summarized.  For example, the refscale.verbose_batched=32
boot parameter would causes only every 32nd line of output to be logged.

Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
Documentation/admin-guide/kernel-parameters.txt
kernel/rcu/refscale.c

index c722ec1..3244f9e 100644 (file)
        refscale.verbose= [KNL]
                        Enable additional printk() statements.
 
+       refscale.verbose_batched= [KNL]
+                       Batch the additional printk() statements.  If zero
+                       (the default) or negative, print everything.  Otherwise,
+                       print every Nth verbose statement, where N is the value
+                       specified.
+
        relax_domain_level=
                        [KNL, SMP] Set scheduler's default relax_domain_level.
                        See Documentation/admin-guide/cgroup-v1/cpusets.rst.
index 23ff36a..3da246f 100644 (file)
 #define VERBOSE_SCALEOUT(s, x...) \
        do { if (verbose) pr_alert("%s" SCALE_FLAG s, scale_type, ## x); } while (0)
 
+static atomic_t verbose_batch_ctr;
+
+#define VERBOSE_SCALEOUT_BATCH(s, x...)                                                        \
+do {                                                                                   \
+       if (verbose &&                                                                  \
+           (verbose_batched <= 0 ||                                                    \
+            !(atomic_inc_return(&verbose_batch_ctr) % verbose_batched)))               \
+               pr_alert("%s" SCALE_FLAG s, scale_type, ## x);                          \
+} while (0)
+
 #define VERBOSE_SCALEOUT_ERRSTRING(s, x...) \
        do { if (verbose) pr_alert("%s" SCALE_FLAG "!!! " s, scale_type, ## x); } while (0)
 
@@ -57,6 +67,7 @@ module_param(scale_type, charp, 0444);
 MODULE_PARM_DESC(scale_type, "Type of test (rcu, srcu, refcnt, rwsem, rwlock.");
 
 torture_param(int, verbose, 0, "Enable verbose debugging printk()s");
+torture_param(int, verbose_batched, 0, "Batch verbose debugging printk()s");
 
 // Wait until there are multiple CPUs before starting test.
 torture_param(int, holdoff, IS_BUILTIN(CONFIG_RCU_REF_SCALE_TEST) ? 10 : 0,
@@ -368,14 +379,14 @@ ref_scale_reader(void *arg)
        u64 start;
        s64 duration;
 
-       VERBOSE_SCALEOUT("ref_scale_reader %ld: task started", me);
+       VERBOSE_SCALEOUT_BATCH("ref_scale_reader %ld: task started", me);
        set_cpus_allowed_ptr(current, cpumask_of(me % nr_cpu_ids));
        set_user_nice(current, MAX_NICE);
        atomic_inc(&n_init);
        if (holdoff)
                schedule_timeout_interruptible(holdoff * HZ);
 repeat:
-       VERBOSE_SCALEOUT("ref_scale_reader %ld: waiting to start next experiment on cpu %d", me, smp_processor_id());
+       VERBOSE_SCALEOUT_BATCH("ref_scale_reader %ld: waiting to start next experiment on cpu %d", me, smp_processor_id());
 
        // Wait for signal that this reader can start.
        wait_event(rt->wq, (atomic_read(&nreaders_exp) && smp_load_acquire(&rt->start_reader)) ||
@@ -392,7 +403,7 @@ repeat:
                while (atomic_read_acquire(&n_started))
                        cpu_relax();
 
-       VERBOSE_SCALEOUT("ref_scale_reader %ld: experiment %d started", me, exp_idx);
+       VERBOSE_SCALEOUT_BATCH("ref_scale_reader %ld: experiment %d started", me, exp_idx);
 
 
        // To reduce noise, do an initial cache-warming invocation, check
@@ -421,8 +432,8 @@ repeat:
        if (atomic_dec_and_test(&nreaders_exp))
                wake_up(&main_wq);
 
-       VERBOSE_SCALEOUT("ref_scale_reader %ld: experiment %d ended, (readers remaining=%d)",
-                       me, exp_idx, atomic_read(&nreaders_exp));
+       VERBOSE_SCALEOUT_BATCH("ref_scale_reader %ld: experiment %d ended, (readers remaining=%d)",
+                               me, exp_idx, atomic_read(&nreaders_exp));
 
        if (!torture_must_stop())
                goto repeat;