Skip to contentSkip to conversation

Torture-test updates

PATCH In review Paul E. McKenney 3 participants 15 messages Oct 3, 2019 – Oct 5, 2019

Subsystems (4)
lore
Share & tools
lore

Paul E. McKenney

author maintainer
#0 lore raw

cover Torture-test updates

Hello!

This series provides torture-test updates.

1. Remove unused function rcutorture_record_progress(), courtesy
of Ethan Hansen.

2. Replace strncmp() with str_has_prefix(), courtesy of Chuhong Yuan.

3. Remove CONFIG_HOTPLUG_CPU=n from scenarios.

4. Emulate dyntick aspect of userspace nohz_full sojourn.

5. Remove unused variable rcu_perf_writer_state, courtesy of
Ethan Hansen.

6. Separate warnings for each failure type.

7. Make in-kernel-loop testing more brutal.

8. locktorture: Do not include rwlock.h directly, courtesy of
Wolfgang M. Reimer.

9. Suppress levelspread uninitialized messages.

Thanx, Paul

------------------------------------------------------------------------

 include/linux/rcutiny.h                                     |    1 
 kernel/locking/locktorture.c                                |    9 +--
 kernel/rcu/rcu.h                                            |    4 -
 kernel/rcu/rcuperf.c                                        |   16 ------
 kernel/rcu/rcutorture.c                                     |   28 +++++++++---
 kernel/rcu/tree.c                                           |    1 
 tools/testing/selftests/rcutorture/configs/rcu/TASKS03      |    3 -
 tools/testing/selftests/rcutorture/configs/rcu/TREE02       |    3 -
 tools/testing/selftests/rcutorture/configs/rcu/TREE04       |    3 -
 tools/testing/selftests/rcutorture/configs/rcu/TREE06       |    3 -
 tools/testing/selftests/rcutorture/configs/rcu/TREE08       |    3 -
 tools/testing/selftests/rcutorture/configs/rcu/TREE09       |    3 -
 tools/testing/selftests/rcutorture/configs/rcu/TRIVIAL      |    3 -
 tools/testing/selftests/rcutorture/doc/TREE_RCU-kconfig.txt |    1 
 14 files changed, 29 insertions(+), 52 deletions(-)
author maintainer
#1 lore raw

PATCH 1/9 rcu: Remove unused function rcutorture_record_progress()

From: Ethan Hansen <[email protected]>

The function rcutorture_record_progress() is declared in rcu.h, but is never used. This commit therefore removes rcutorture_record_progress() to clean code.

---
 kernel/rcu/rcu.h | 2 --
 1 file changed, 2 deletions(-)
kernel/rcu/rcu.h +0 -2
index 8fd4f82..aeec70f 100644
@@ -455,7 +455,6 @@ enum rcutorture_type {
 #if defined(CONFIG_TREE_RCU) || defined(CONFIG_PREEMPT_RCU)
 void rcutorture_get_gp_data(enum rcutorture_type test_type, int *flags,
 			    unsigned long *gp_seq);
-void rcutorture_record_progress(unsigned long vernum);
 void do_trace_rcu_torture_read(const char *rcutorturename,
 			       struct rcu_head *rhp,
 			       unsigned long secs,
@@ -468,7 +467,6 @@ static inline void rcutorture_get_gp_data(enum rcutorture_type test_type,
 	*flags = 0;
 	*gp_seq = 0;
 }
-static inline void rcutorture_record_progress(unsigned long vernum) { }
 #ifdef CONFIG_RCU_TRACE
 void do_trace_rcu_torture_read(const char *rcutorturename,
 			       struct rcu_head *rhp,
Signature · 1 line
2.9.5
author maintainer
#2 lore raw

PATCH 2/9 locktorture: Replace strncmp() with str_has_prefix()

In reply to Paul E. McKenney

From: Chuhong Yuan <[email protected]>

The strncmp() function is error-prone because it is easy to get the length wrong, especially if the string is subject to change, especially given the need to account for the terminating nul byte. This commit therefore substitutes the newly introduced str_has_prefix(), which does not require a separately specified length.

---
 kernel/locking/locktorture.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
kernel/locking/locktorture.c +4 -4
index c513031..8dd9002 100644
@@ -889,16 +889,16 @@ static int __init lock_torture_init(void)
 		cxt.nrealwriters_stress = 2 * num_online_cpus();
 
 #ifdef CONFIG_DEBUG_MUTEXES
-	if (strncmp(torture_type, "mutex", 5) == 0)
+	if (str_has_prefix(torture_type, "mutex"))
 		cxt.debug_lock = true;
 #endif
 #ifdef CONFIG_DEBUG_RT_MUTEXES
-	if (strncmp(torture_type, "rtmutex", 7) == 0)
+	if (str_has_prefix(torture_type, "rtmutex"))
 		cxt.debug_lock = true;
 #endif
 #ifdef CONFIG_DEBUG_SPINLOCK
-	if ((strncmp(torture_type, "spin", 4) == 0) ||
-	    (strncmp(torture_type, "rw_lock", 7) == 0))
+	if ((str_has_prefix(torture_type, "spin")) ||
+	    (str_has_prefix(torture_type, "rw_lock")))
 		cxt.debug_lock = true;
 #endif
 
Signature · 1 line
2.9.5
author maintainer
#3 lore raw

PATCH 3/9 rcutorture: Remove CONFIG_HOTPLUG_CPU=n from scenarios

In reply to Paul E. McKenney

From: "Paul E. McKenney" <[email protected]>

A number of mainstream CPU families are no longer capable of building kernels having CONFIG_SMP=y and CONFIG_HOTPLUG_CPU=n, so this commit removes this combination from the rcutorture scenarios having it. People wishing to try out this combination may still do so using the "--kconfig CONFIG_HOTPLUG_CPU=n CONFIG_SUSPEND=n CONFIG_HIBERNATION=n" argument to the tools/testing/selftests/rcutorture/bin/kvm.sh script that is used to run rcutorture.

---
 tools/testing/selftests/rcutorture/configs/rcu/TASKS03      | 3 ---
 tools/testing/selftests/rcutorture/configs/rcu/TREE02       | 3 ---
 tools/testing/selftests/rcutorture/configs/rcu/TREE04       | 3 ---
 tools/testing/selftests/rcutorture/configs/rcu/TREE06       | 3 ---
 tools/testing/selftests/rcutorture/configs/rcu/TREE08       | 3 ---
 tools/testing/selftests/rcutorture/configs/rcu/TREE09       | 3 ---
 tools/testing/selftests/rcutorture/configs/rcu/TRIVIAL      | 3 ---
 tools/testing/selftests/rcutorture/doc/TREE_RCU-kconfig.txt | 1 -
 8 files changed, 22 deletions(-)
tools/testing/selftests/rcutorture/configs/rcu/TASKS03 +0 -3
index 28568b7..ea43990 100644
@@ -1,8 +1,5 @@
 CONFIG_SMP=y
 CONFIG_NR_CPUS=2
-CONFIG_HOTPLUG_CPU=n
-CONFIG_SUSPEND=n
-CONFIG_HIBERNATION=n
 CONFIG_PREEMPT_NONE=n
 CONFIG_PREEMPT_VOLUNTARY=n
 CONFIG_PREEMPT=y
tools/testing/selftests/rcutorture/configs/rcu/TREE02 +0 -3
index 35e639e..65daee4 100644
@@ -9,9 +9,6 @@ CONFIG_NO_HZ_IDLE=y
 CONFIG_NO_HZ_FULL=n
 CONFIG_RCU_FAST_NO_HZ=n
 CONFIG_RCU_TRACE=n
-CONFIG_HOTPLUG_CPU=n
-CONFIG_SUSPEND=n
-CONFIG_HIBERNATION=n
 CONFIG_RCU_FANOUT=3
 CONFIG_RCU_FANOUT_LEAF=3
 CONFIG_RCU_NOCB_CPU=n
tools/testing/selftests/rcutorture/configs/rcu/TREE04 +0 -3
index 24c9f60..f6d6a40 100644
@@ -9,9 +9,6 @@ CONFIG_NO_HZ_IDLE=n
 CONFIG_NO_HZ_FULL=y
 CONFIG_RCU_FAST_NO_HZ=y
 CONFIG_RCU_TRACE=y
-CONFIG_HOTPLUG_CPU=n
-CONFIG_SUSPEND=n
-CONFIG_HIBERNATION=n
 CONFIG_RCU_FANOUT=4
 CONFIG_RCU_FANOUT_LEAF=3
 CONFIG_DEBUG_LOCK_ALLOC=n
tools/testing/selftests/rcutorture/configs/rcu/TREE06 +0 -3
index 05a4eec..bf4980d 100644
@@ -9,9 +9,6 @@ CONFIG_NO_HZ_IDLE=y
 CONFIG_NO_HZ_FULL=n
 CONFIG_RCU_FAST_NO_HZ=n
 CONFIG_RCU_TRACE=n
-CONFIG_HOTPLUG_CPU=n
-CONFIG_SUSPEND=n
-CONFIG_HIBERNATION=n
 CONFIG_RCU_FANOUT=6
 CONFIG_RCU_FANOUT_LEAF=6
 CONFIG_RCU_NOCB_CPU=n
tools/testing/selftests/rcutorture/configs/rcu/TREE08 +0 -3
index fb1c763..c810c52 100644
@@ -9,9 +9,6 @@ CONFIG_NO_HZ_IDLE=y
 CONFIG_NO_HZ_FULL=n
 CONFIG_RCU_FAST_NO_HZ=n
 CONFIG_RCU_TRACE=n
-CONFIG_HOTPLUG_CPU=n
-CONFIG_SUSPEND=n
-CONFIG_HIBERNATION=n
 CONFIG_RCU_FANOUT=3
 CONFIG_RCU_FANOUT_LEAF=2
 CONFIG_RCU_NOCB_CPU=y
tools/testing/selftests/rcutorture/configs/rcu/TREE09 +0 -3
index 6710e74..8523a75 100644
@@ -8,9 +8,6 @@ CONFIG_HZ_PERIODIC=n
 CONFIG_NO_HZ_IDLE=y
 CONFIG_NO_HZ_FULL=n
 CONFIG_RCU_TRACE=n
-CONFIG_HOTPLUG_CPU=n
-CONFIG_SUSPEND=n
-CONFIG_HIBERNATION=n
 CONFIG_RCU_NOCB_CPU=n
 CONFIG_DEBUG_LOCK_ALLOC=n
 CONFIG_RCU_BOOST=n
tools/testing/selftests/rcutorture/configs/rcu/TRIVIAL +0 -3
index 4d8eb5b..5d546ef 100644
@@ -6,9 +6,6 @@ CONFIG_PREEMPT=n
 CONFIG_HZ_PERIODIC=n
 CONFIG_NO_HZ_IDLE=y
 CONFIG_NO_HZ_FULL=n
-CONFIG_HOTPLUG_CPU=n
-CONFIG_SUSPEND=n
-CONFIG_HIBERNATION=n
 CONFIG_DEBUG_LOCK_ALLOC=n
 CONFIG_DEBUG_OBJECTS_RCU_HEAD=n
 CONFIG_RCU_EXPERT=y
tools/testing/selftests/rcutorture/doc/TREE_RCU-kconfig.txt +0 -1
index af6fca0..1b96d68 100644
@@ -6,7 +6,6 @@ Kconfig Parameters:
 
 CONFIG_DEBUG_LOCK_ALLOC -- Do three, covering CONFIG_PROVE_LOCKING & not.
 CONFIG_DEBUG_OBJECTS_RCU_HEAD -- Do one.
-CONFIG_HOTPLUG_CPU -- Do half.  (Every second.)
 CONFIG_HZ_PERIODIC -- Do one.
 CONFIG_NO_HZ_IDLE -- Do those not otherwise specified. (Groups of two.)
 CONFIG_NO_HZ_FULL -- Do two, one with partial CPU enablement.
Signature · 1 line
2.9.5
author maintainer
#4 lore raw

PATCH 4/9 rcutorture: Emulate dyntick aspect of userspace nohz_full sojourn

In reply to Paul E. McKenney

From: "Paul E. McKenney" <[email protected]>

During an actual call_rcu() flood, there would be frequent trips to userspace (in-kernel call_rcu() floods must be otherwise housebroken). Userspace execution on nohz_full CPUs implies an RCU dyntick idle/not-idle transition pair, so this commit adds emulation of that pair.

---
 include/linux/rcutiny.h |  1 +
 kernel/rcu/rcutorture.c | 11 +++++++++++
 kernel/rcu/tree.c       |  1 +
 3 files changed, 13 insertions(+)
include/linux/rcutiny.h +1 -0
index 9bf1dfe..37b6f0c 100644
@@ -84,6 +84,7 @@ static inline void rcu_scheduler_starting(void) { }
 #endif /* #else #ifndef CONFIG_SRCU */
 static inline void rcu_end_inkernel_boot(void) { }
 static inline bool rcu_is_watching(void) { return true; }
+static inline void rcu_momentary_dyntick_idle(void) { }
 
 /* Avoid RCU read-side critical sections leaking across. */
 static inline void rcu_all_qs(void) { barrier(); }
kernel/rcu/rcutorture.c +11 -0
index 3c9feca..7dcb2b8 100644
@@ -1759,6 +1759,11 @@ static unsigned long rcu_torture_fwd_prog_cbfree(void)
 		kfree(rfcp);
 		freed++;
 		rcu_torture_fwd_prog_cond_resched(freed);
+		if (tick_nohz_full_enabled()) {
+			local_irq_save(flags);
+			rcu_momentary_dyntick_idle();
+			local_irq_restore(flags);
+		}
 	}
 	return freed;
 }
@@ -1833,6 +1838,7 @@ static void rcu_torture_fwd_prog_nr(int *tested, int *tested_tries)
 static void rcu_torture_fwd_prog_cr(void)
 {
 	unsigned long cver;
+	unsigned long flags;
 	unsigned long gps;
 	int i;
 	long n_launders;
@@ -1891,6 +1897,11 @@ static void rcu_torture_fwd_prog_cr(void)
 		}
 		cur_ops->call(&rfcp->rh, rcu_torture_fwd_cb_cr);
 		rcu_torture_fwd_prog_cond_resched(n_launders + n_max_cbs);
+		if (tick_nohz_full_enabled()) {
+			local_irq_save(flags);
+			rcu_momentary_dyntick_idle();
+			local_irq_restore(flags);
+		}
 	}
 	stoppedat = jiffies;
 	n_launders_cb_snap = READ_ONCE(n_launders_cb);
kernel/rcu/tree.c +1 -0
index 8110514..5692db5 100644
@@ -375,6 +375,7 @@ static void __maybe_unused rcu_momentary_dyntick_idle(void)
 	WARN_ON_ONCE(!(special & RCU_DYNTICK_CTRL_CTR));
 	rcu_preempt_deferred_qs(current);
 }
+EXPORT_SYMBOL_GPL(rcu_momentary_dyntick_idle);
 
 /**
  * rcu_is_cpu_rrupt_from_idle - see if interrupted from idle
Signature · 1 line
2.9.5
#5 lore raw

Re: [PATCH tip/core/rcu 4/9] rcutorture: Emulate dyntick aspect of userspace nohz_full sojourn

I love your patch! Yet something to improve:

Hi,

I love your patch! Yet something to improve:

[auto build test ERROR on tip/core/rcu]

url: https://github.com/0day-ci/linux/commits/paulmck-kernel-org/rcu-Remove-unused-function-rcutorture_record_progress/20191003-095557
config: sh-allmodconfig (attached as .config)
compiler: sh4-linux-gcc (GCC) 7.4.0
reproduce:
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# save the attached .config to linux build tree
GCC_VERSION=7.4.0 make.cross ARCH=sh

If you fix the issue, kindly add following tag

All errors (new ones prefixed by >>):

kernel/rcu/rcutorture.c: In function 'rcu_torture_fwd_prog_cbfree':

>> kernel/rcu/rcutorture.c:1762:7: error: implicit declaration of function 'tick_nohz_full_enabled'; did you mean 'trace_softirqs_enabled'? [-Werror=implicit-function-declaration]
      if (tick_nohz_full_enabled()) {
          ^~~~~~~~~~~~~~~~~~~~~~
          trace_softirqs_enabled

cc1: some warnings being treated as errors

vim +1762 kernel/rcu/rcutorture.c

1737
1738 /*
1739 * Free all callbacks on the rcu_fwd_cb_head list, either because the
1740 * test is over or because we hit an OOM event.
1741 */
1742 static unsigned long rcu_torture_fwd_prog_cbfree(void)
1743 {
1744 unsigned long flags;
1745 unsigned long freed = 0;
1746 struct rcu_fwd_cb *rfcp;
1747
1748 for (;;) {
1749 spin_lock_irqsave(&rcu_fwd_lock, flags);
1750 rfcp = rcu_fwd_cb_head;
1751 if (!rfcp) {
1752 spin_unlock_irqrestore(&rcu_fwd_lock, flags);
1753 break;
1754 }
1755 rcu_fwd_cb_head = rfcp->rfc_next;
1756 if (!rcu_fwd_cb_head)
1757 rcu_fwd_cb_tail = &rcu_fwd_cb_head;
1758 spin_unlock_irqrestore(&rcu_fwd_lock, flags);
1759 kfree(rfcp);
1760 freed++;
1761 rcu_torture_fwd_prog_cond_resched(freed);

> 1762			if (tick_nohz_full_enabled()) {

1763 local_irq_save(flags);
1764 rcu_momentary_dyntick_idle();
1765 local_irq_restore(flags);
1766 }
1767 }
1768 return freed;
1769 }
1770

---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation

author maintainer
#6 lore raw

Re: [PATCH tip/core/rcu 4/9] rcutorture: Emulate dyntick aspect of userspace nohz_full sojourn

Quoted 15 lines · kbuild test robot

Hi,

I love your patch! Yet something to improve:

[auto build test ERROR on tip/core/rcu]

url: https://github.com/0day-ci/linux/commits/paulmck-kernel-org/rcu-Remove-unused-function-rcutorture_record_progress/20191003-095557
config: sh-allmodconfig (attached as .config)
compiler: sh4-linux-gcc (GCC) 7.4.0
reproduce:
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# save the attached .config to linux build tree
GCC_VERSION=7.4.0 make.cross ARCH=sh

Quoted 2 lines

If you fix the issue, kindly add following tag

Good catch, I placed this commit in the wrong branch. I pushed the fix out, so it is hopefully better now.

Thanx, Paul

Quoted 49 lines

All errors (new ones prefixed by >>):

kernel/rcu/rcutorture.c: In function 'rcu_torture_fwd_prog_cbfree':

Quoted 1 line
Quoted 1 line

kernel/rcu/rcutorture.c:1762:7: error: implicit declaration of function 'tick_nohz_full_enabled'; did you mean 'trace_softirqs_enabled'? [-Werror=implicit-function-declaration]

      if (tick_nohz_full_enabled()) {
          ^~~~~~~~~~~~~~~~~~~~~~
          trace_softirqs_enabled

cc1: some warnings being treated as errors

vim +1762 kernel/rcu/rcutorture.c

1737
1738 /*
1739 * Free all callbacks on the rcu_fwd_cb_head list, either because the
1740 * test is over or because we hit an OOM event.
1741 */
1742 static unsigned long rcu_torture_fwd_prog_cbfree(void)
1743 {
1744 unsigned long flags;
1745 unsigned long freed = 0;
1746 struct rcu_fwd_cb *rfcp;
1747
1748 for (;;) {
1749 spin_lock_irqsave(&rcu_fwd_lock, flags);
1750 rfcp = rcu_fwd_cb_head;
1751 if (!rfcp) {
1752 spin_unlock_irqrestore(&rcu_fwd_lock, flags);
1753 break;
1754 }
1755 rcu_fwd_cb_head = rfcp->rfc_next;
1756 if (!rcu_fwd_cb_head)
1757 rcu_fwd_cb_tail = &rcu_fwd_cb_head;
1758 spin_unlock_irqrestore(&rcu_fwd_lock, flags);
1759 kfree(rfcp);
1760 freed++;
1761 rcu_torture_fwd_prog_cond_resched(freed);

Quoted 1 line

1762 if (tick_nohz_full_enabled()) {

1763 local_irq_save(flags);
1764 rcu_momentary_dyntick_idle();
1765 local_irq_restore(flags);
1766 }
1767 }
1768 return freed;
1769 }
1770

---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation

#7 lore raw

Re: [PATCH tip/core/rcu 4/9] rcutorture: Emulate dyntick aspect of userspace nohz_full sojourn

In reply to [email protected]
I love your patch! Yet something to improve:

Hi,

I love your patch! Yet something to improve:

[auto build test ERROR on tip/core/rcu]

url: https://github.com/0day-ci/linux/commits/paulmck-kernel-org/rcu-Remove-unused-function-rcutorture_record_progress/20191003-095557
config: sparc64-allmodconfig (attached as .config)
compiler: sparc64-linux-gcc (GCC) 7.4.0
reproduce:
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# save the attached .config to linux build tree
GCC_VERSION=7.4.0 make.cross ARCH=sparc64

If you fix the issue, kindly add following tag

All errors (new ones prefixed by >>):

kernel/rcu/rcutorture.c: In function 'rcu_torture_fwd_prog_cbfree':

>> kernel/rcu/rcutorture.c:1762:7: error: implicit declaration of function 'tick_nohz_full_enabled'; did you mean 'trace_rcu_fqs_enabled'? [-Werror=implicit-function-declaration]
      if (tick_nohz_full_enabled()) {
          ^~~~~~~~~~~~~~~~~~~~~~
          trace_rcu_fqs_enabled
>> kernel/rcu/rcutorture.c:1764:4: error: implicit declaration of function 'rcu_momentary_dyntick_idle' [-Werror=implicit-function-declaration]
       rcu_momentary_dyntick_idle();
       ^~~~~~~~~~~~~~~~~~~~~~~~~~

cc1: some warnings being treated as errors

vim +1762 kernel/rcu/rcutorture.c

1737
1738 /*
1739 * Free all callbacks on the rcu_fwd_cb_head list, either because the
1740 * test is over or because we hit an OOM event.
1741 */
1742 static unsigned long rcu_torture_fwd_prog_cbfree(void)
1743 {
1744 unsigned long flags;
1745 unsigned long freed = 0;
1746 struct rcu_fwd_cb *rfcp;
1747
1748 for (;;) {
1749 spin_lock_irqsave(&rcu_fwd_lock, flags);
1750 rfcp = rcu_fwd_cb_head;
1751 if (!rfcp) {
1752 spin_unlock_irqrestore(&rcu_fwd_lock, flags);
1753 break;
1754 }
1755 rcu_fwd_cb_head = rfcp->rfc_next;
1756 if (!rcu_fwd_cb_head)
1757 rcu_fwd_cb_tail = &rcu_fwd_cb_head;
1758 spin_unlock_irqrestore(&rcu_fwd_lock, flags);
1759 kfree(rfcp);
1760 freed++;
1761 rcu_torture_fwd_prog_cond_resched(freed);

> 1762			if (tick_nohz_full_enabled()) {
  1763				local_irq_save(flags);
> 1764				rcu_momentary_dyntick_idle();

1765 local_irq_restore(flags);
1766 }
1767 }
1768 return freed;
1769 }
1770

---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation

author maintainer
#8 lore raw

PATCH 5/9 rcu: Remove unused variable rcu_perf_writer_state

In reply to Paul E. McKenney

From: Ethan Hansen <[email protected]>

The variable rcu_perf_writer_state is declared and initialized, but is never actually referenced. Remove it to clean code.

[ ethansen: Also removed unused macros assigned to that variable. ]
---
 kernel/rcu/rcuperf.c | 16 ----------------
 1 file changed, 16 deletions(-)
kernel/rcu/rcuperf.c +0 -16
index 5a879d0..5f884d5 100644
@@ -109,15 +109,6 @@ static unsigned long b_rcu_perf_writer_started;
 static unsigned long b_rcu_perf_writer_finished;
 static DEFINE_PER_CPU(atomic_t, n_async_inflight);
 
-static int rcu_perf_writer_state;
-#define RTWS_INIT		0
-#define RTWS_ASYNC		1
-#define RTWS_BARRIER		2
-#define RTWS_EXP_SYNC		3
-#define RTWS_SYNC		4
-#define RTWS_IDLE		5
-#define RTWS_STOPPING		6
-
 #define MAX_MEAS 10000
 #define MIN_MEAS 100
 
@@ -404,25 +395,20 @@ rcu_perf_writer(void *arg)
 			if (!rhp)
 				rhp = kmalloc(sizeof(*rhp), GFP_KERNEL);
 			if (rhp && atomic_read(this_cpu_ptr(&n_async_inflight)) < gp_async_max) {
-				rcu_perf_writer_state = RTWS_ASYNC;
 				atomic_inc(this_cpu_ptr(&n_async_inflight));
 				cur_ops->async(rhp, rcu_perf_async_cb);
 				rhp = NULL;
 			} else if (!kthread_should_stop()) {
-				rcu_perf_writer_state = RTWS_BARRIER;
 				cur_ops->gp_barrier();
 				goto retry;
 			} else {
 				kfree(rhp); /* Because we are stopping. */
 			}
 		} else if (gp_exp) {
-			rcu_perf_writer_state = RTWS_EXP_SYNC;
 			cur_ops->exp_sync();
 		} else {
-			rcu_perf_writer_state = RTWS_SYNC;
 			cur_ops->sync();
 		}
-		rcu_perf_writer_state = RTWS_IDLE;
 		t = ktime_get_mono_fast_ns();
 		*wdp = t - *wdp;
 		i_max = i;
@@ -463,10 +449,8 @@ rcu_perf_writer(void *arg)
 		rcu_perf_wait_shutdown();
 	} while (!torture_must_stop());
 	if (gp_async) {
-		rcu_perf_writer_state = RTWS_BARRIER;
 		cur_ops->gp_barrier();
 	}
-	rcu_perf_writer_state = RTWS_STOPPING;
 	writer_n_durations[me] = i_max;
 	torture_kthread_stopping("rcu_perf_writer");
 	return 0;
Signature · 1 line
2.9.5
author maintainer
#9 lore raw

PATCH 6/9 rcutorture: Separate warnings for each failure type

In reply to Paul E. McKenney

From: "Paul E. McKenney" <[email protected]>

Currently, each of six different types of failure triggers a single WARN_ON_ONCE(), and it is then necessary to stare at the rcu_torture_stats(), Reader Pipe, and Reader Batch lines looking for inappropriately non-zero values. This can be annoying and error-prone, so this commit provides a separate WARN_ON_ONCE() for each of the six error conditions and adds short comments to each to ease error identification.

---
 kernel/rcu/rcutorture.c | 15 +++++++++------
 1 file changed, 9 insertions(+), 6 deletions(-)
kernel/rcu/rcutorture.c +9 -6
index 7dcb2b8..a9e97c3 100644
@@ -1442,15 +1442,18 @@ rcu_torture_stats_print(void)
 		n_rcu_torture_barrier_error);
 
 	pr_alert("%s%s ", torture_type, TORTURE_FLAG);
-	if (atomic_read(&n_rcu_torture_mberror) != 0 ||
-	    n_rcu_torture_barrier_error != 0 ||
-	    n_rcu_torture_boost_ktrerror != 0 ||
-	    n_rcu_torture_boost_rterror != 0 ||
-	    n_rcu_torture_boost_failure != 0 ||
+	if (atomic_read(&n_rcu_torture_mberror) ||
+	    n_rcu_torture_barrier_error || n_rcu_torture_boost_ktrerror ||
+	    n_rcu_torture_boost_rterror || n_rcu_torture_boost_failure ||
 	    i > 1) {
 		pr_cont("%s", "!!! ");
 		atomic_inc(&n_rcu_torture_error);
-		WARN_ON_ONCE(1);
+		WARN_ON_ONCE(atomic_read(&n_rcu_torture_mberror));
+		WARN_ON_ONCE(n_rcu_torture_barrier_error);  // rcu_barrier()
+		WARN_ON_ONCE(n_rcu_torture_boost_ktrerror); // no boost kthread
+		WARN_ON_ONCE(n_rcu_torture_boost_rterror); // can't set RT prio
+		WARN_ON_ONCE(n_rcu_torture_boost_failure); // RCU boost failed
+		WARN_ON_ONCE(i > 1); // Too-short grace period
 	}
 	pr_cont("Reader Pipe: ");
 	for (i = 0; i < RCU_TORTURE_PIPE_LEN + 1; i++)
Signature · 1 line
2.9.5
author maintainer
#10 lore raw

PATCH 7/9 rcutorture: Make in-kernel-loop testing more brutal

In reply to Paul E. McKenney

From: "Paul E. McKenney" <[email protected]>

The rcu_torture_fwd_prog_nr() tests the ability of RCU to tolerate in-kernel busy loops. It invokes rcu_torture_fwd_prog_cond_resched() within its delay loop, which, in PREEMPT && NO_HZ_FULL kernels results in the occasional direct call to schedule(). Now, this direct call to schedule() is appropriate for call_rcu() flood testing, in which either the kernel should restrain itself or userspace transitions will supply the needed restraint. But in pure in-kernel loops, the occasional cond_resched() should do the job.

This commit therefore makes rcu_torture_fwd_prog_nr() use cond_resched() instead of rcu_torture_fwd_prog_cond_resched() in order to increase the brutality of this aspect of rcutorture testing.

---
 kernel/rcu/rcutorture.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/rcu/rcutorture.c +1 -1
index a9e97c3..f1339ee 100644
@@ -1811,7 +1811,7 @@ static void rcu_torture_fwd_prog_nr(int *tested, int *tested_tries)
 		udelay(10);
 		cur_ops->readunlock(idx);
 		if (!fwd_progress_need_resched || need_resched())
-			rcu_torture_fwd_prog_cond_resched(1);
+			cond_resched();
 	}
 	(*tested_tries)++;
 	if (!time_before(jiffies, stopat) &&
Signature · 1 line
2.9.5
author maintainer
#11 lore raw

PATCH 8/9 locking: locktorture: Do not include rwlock.h directly

In reply to Paul E. McKenney

From: "Wolfgang M. Reimer" <[email protected]>

Including rwlock.h directly will cause kernel builds to fail if CONFIG_PREEMPT_RT is defined. The correct header file (rwlock_rt.h OR rwlock.h) will be included by spinlock.h which is included by locktorture.c anyway.

Remove the include of linux/rwlock.h.

---
 kernel/locking/locktorture.c | 1 -
 1 file changed, 1 deletion(-)
kernel/locking/locktorture.c +0 -1
index 8dd9002..99475a6 100644
@@ -16,7 +16,6 @@
 #include <linux/kthread.h>
 #include <linux/sched/rt.h>
 #include <linux/spinlock.h>
-#include <linux/rwlock.h>
 #include <linux/mutex.h>
 #include <linux/rwsem.h>
 #include <linux/smp.h>
Signature · 1 line
2.9.5
author maintainer
#12 lore raw

PATCH 9/9 rcu: Suppress levelspread uninitialized messages

In reply to Paul E. McKenney

From: "Paul E. McKenney" <[email protected]>

New tools bring new warnings, and with v5.3 comes:

kernel/rcu/srcutree.c: warning: 'levelspread[<U aa0>]' may be used uninitialized in this function [-Wuninitialized]: => 121:34

This commit suppresses this warning by initializing the full array to INT_MIN, which will result in failures should any out-of-bounds references appear.

---
 kernel/rcu/rcu.h | 2 ++
 1 file changed, 2 insertions(+)
kernel/rcu/rcu.h +2 -0
index aeec70f..ab504fb 100644
@@ -299,6 +299,8 @@ static inline void rcu_init_levelspread(int *levelspread, const int *levelcnt)
 {
 	int i;
 
+	for (i = 0; i < RCU_NUM_LVLS; i++)
+		levelspread[i] = INT_MIN;
 	if (rcu_fanout_exact) {
 		levelspread[rcu_num_lvls - 1] = rcu_fanout_leaf;
 		for (i = rcu_num_lvls - 2; i >= 0; i--)
Signature · 1 line
2.9.5
Reviewed-by on v1 9/9
#13 lore raw

Re: [PATCH tip/core/rcu 9/9] rcu: Suppress levelspread uninitialized messages

Hi Paul,

Quoted 3 lines · On Thu, Oct 3, 2019 at 3:49 AM <[email protected]> wrote:

From: "Paul E. McKenney" <[email protected]>

New tools bring new warnings, and with v5.3 comes:

According to the kisskb build logs, it happens with gcc 4.6.3 only ;-)

Quoted 9 lines

kernel/rcu/srcutree.c: warning: 'levelspread[<U aa0>]' may be used uninitialized in this function [-Wuninitialized]: => 121:34

This commit suppresses this warning by initializing the full array to INT_MIN, which will result in failures should any out-of-bounds references appear.

Thanks for your patch!

(for the initialization loop, not for the actual INT_MIN value)

Unfortunately I don't have a gcc-4.6.3 Linux cross-compiler anymore. I tried with msp430-gcc-4.6.3 and some hackery to get it to compile, but that didn't let me reproduce the warning.

Gr{oetje,eeting}s,

Geert

Signature · 5 lines
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds
author maintainer Applied
#14 lore raw

Re: [PATCH tip/core/rcu 9/9] rcu: Suppress levelspread uninitialized messages

Quoted 15 lines · Geert Uytterhoeven

Hi Paul,

Quoted 3 lines · On Thu, Oct 3, 2019 at 3:49 AM <[email protected]> wrote:

From: "Paul E. McKenney" <[email protected]>

New tools bring new warnings, and with v5.3 comes:

According to the kisskb build logs, it happens with gcc 4.6.3 only ;-)

Quoted 6 lines

kernel/rcu/srcutree.c: warning: 'levelspread[<U aa0>]' may be used uninitialized in this function [-Wuninitialized]: => 121:34

This commit suppresses this warning by initializing the full array to INT_MIN, which will result in failures should any out-of-bounds references appear.

Quoted 8 lines
Quoted 3 lines

Thanks for your patch!

(for the initialization loop, not for the actual INT_MIN value)

Applied, thank you!

Quoted 3 lines

Unfortunately I don't have a gcc-4.6.3 Linux cross-compiler anymore. I tried with msp430-gcc-4.6.3 and some hackery to get it to compile, but that didn't let me reproduce the warning.

OK, please let me know when gcc-4.6.3 is old enough that this patch should be reverted. Or just submit the revert at that point, as the case may be. ;-)

Thanx, Paul