linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH tip/core/rcu 0/4] Lock torture-test updates for v5.7
@ 2020-02-15  0:03 Paul E. McKenney
  2020-02-15  0:03 ` [PATCH tip/core/rcu 1/4] locktorture: Print ratio of acquisitions, not failures paulmck
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Paul E. McKenney @ 2020-02-15  0:03 UTC (permalink / raw)
  To: rcu
  Cc: linux-kernel, kernel-team, mingo, jiangshanlai, dipankar, akpm,
	mathieu.desnoyers, josh, tglx, peterz, rostedt, dhowells,
	edumazet, fweisbec, oleg, joel

Hello!

This series provides locktorture updates.

1.	Print ratio of acquisitions, not failures.

2.	Allow CPU-hotplug to be disabled via --bootargs.

3.	Use private random-number generators.

4.	Forgive apparent unfairness if CPU hotplug.

							Thanx, Paul

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

 kernel/locking/locktorture.c                        |   15 ++++++++-------
 tools/testing/selftests/rcutorture/bin/functions.sh |    2 +-
 2 files changed, 9 insertions(+), 8 deletions(-)

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH tip/core/rcu 1/4] locktorture: Print ratio of acquisitions, not failures
  2020-02-15  0:03 [PATCH tip/core/rcu 0/4] Lock torture-test updates for v5.7 Paul E. McKenney
@ 2020-02-15  0:03 ` paulmck
  2020-02-15  0:03 ` [PATCH tip/core/rcu 2/4] locktorture: Allow CPU-hotplug to be disabled via --bootargs paulmck
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: paulmck @ 2020-02-15  0:03 UTC (permalink / raw)
  To: rcu
  Cc: linux-kernel, kernel-team, mingo, jiangshanlai, dipankar, akpm,
	mathieu.desnoyers, josh, tglx, peterz, rostedt, dhowells,
	edumazet, fweisbec, oleg, joel, Paul E. McKenney,
	Davidlohr Bueso

From: "Paul E. McKenney" <paulmck@kernel.org>

The __torture_print_stats() function in locktorture.c carefully
initializes local variable "min" to statp[0].n_lock_acquired, but
then compares it to statp[i].n_lock_fail.  Given that the .n_lock_fail
field should normally be zero, and given the initialization, it seems
reasonable to display the maximum and minimum number acquisitions
instead of miscomputing the maximum and minimum number of failures.
This commit therefore switches from failures to acquisitions.

And this turns out to be not only a day-zero bug, but entirely my
own fault.  I hate it when that happens!

Fixes: 0af3fe1efa53 ("locktorture: Add a lock-torture kernel module")
Reported-by: Will Deacon <will@kernel.org>
Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
Acked-by: Will Deacon <will@kernel.org>
Cc: Davidlohr Bueso <dave@stgolabs.net>
Cc: Josh Triplett <josh@joshtriplett.org>
Cc: Peter Zijlstra <peterz@infradead.org>
---
 kernel/locking/locktorture.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/kernel/locking/locktorture.c b/kernel/locking/locktorture.c
index 99475a6..687c1d8 100644
--- a/kernel/locking/locktorture.c
+++ b/kernel/locking/locktorture.c
@@ -696,10 +696,10 @@ static void __torture_print_stats(char *page,
 		if (statp[i].n_lock_fail)
 			fail = true;
 		sum += statp[i].n_lock_acquired;
-		if (max < statp[i].n_lock_fail)
-			max = statp[i].n_lock_fail;
-		if (min > statp[i].n_lock_fail)
-			min = statp[i].n_lock_fail;
+		if (max < statp[i].n_lock_acquired)
+			max = statp[i].n_lock_acquired;
+		if (min > statp[i].n_lock_acquired)
+			min = statp[i].n_lock_acquired;
 	}
 	page += sprintf(page,
 			"%s:  Total: %lld  Max/Min: %ld/%ld %s  Fail: %d %s\n",
-- 
2.9.5


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH tip/core/rcu 2/4] locktorture: Allow CPU-hotplug to be disabled via --bootargs
  2020-02-15  0:03 [PATCH tip/core/rcu 0/4] Lock torture-test updates for v5.7 Paul E. McKenney
  2020-02-15  0:03 ` [PATCH tip/core/rcu 1/4] locktorture: Print ratio of acquisitions, not failures paulmck
@ 2020-02-15  0:03 ` paulmck
  2020-02-15  0:03 ` [PATCH tip/core/rcu 3/4] locktorture: Use private random-number generators paulmck
  2020-02-15  0:03 ` [PATCH tip/core/rcu 4/4] locktorture: Forgive apparent unfairness if CPU hotplug paulmck
  3 siblings, 0 replies; 5+ messages in thread
From: paulmck @ 2020-02-15  0:03 UTC (permalink / raw)
  To: rcu
  Cc: linux-kernel, kernel-team, mingo, jiangshanlai, dipankar, akpm,
	mathieu.desnoyers, josh, tglx, peterz, rostedt, dhowells,
	edumazet, fweisbec, oleg, joel, Paul E. McKenney

From: "Paul E. McKenney" <paulmck@kernel.org>

The bootparam_hotplug_cpu() bash function was checking for CPU-hotplug
kernel-boot parameters from --bootargs, but that check was specific to
rcutorture ("rcutorture\.onoff_").  This commit therefore makes this
check also work for locktorture ("torture\.onoff_").

Note that rcuperf does not do CPU-hotplug operations, so it is not
necessary to make a similar change for rcuperf.

Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
---
 tools/testing/selftests/rcutorture/bin/functions.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/testing/selftests/rcutorture/bin/functions.sh b/tools/testing/selftests/rcutorture/bin/functions.sh
index c3a49fb..1281022 100644
--- a/tools/testing/selftests/rcutorture/bin/functions.sh
+++ b/tools/testing/selftests/rcutorture/bin/functions.sh
@@ -12,7 +12,7 @@
 # Returns 1 if the specified boot-parameter string tells rcutorture to
 # test CPU-hotplug operations.
 bootparam_hotplug_cpu () {
-	echo "$1" | grep -q "rcutorture\.onoff_"
+	echo "$1" | grep -q "torture\.onoff_"
 }
 
 # checkarg --argname argtype $# arg mustmatch cannotmatch
-- 
2.9.5


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH tip/core/rcu 3/4] locktorture: Use private random-number generators
  2020-02-15  0:03 [PATCH tip/core/rcu 0/4] Lock torture-test updates for v5.7 Paul E. McKenney
  2020-02-15  0:03 ` [PATCH tip/core/rcu 1/4] locktorture: Print ratio of acquisitions, not failures paulmck
  2020-02-15  0:03 ` [PATCH tip/core/rcu 2/4] locktorture: Allow CPU-hotplug to be disabled via --bootargs paulmck
@ 2020-02-15  0:03 ` paulmck
  2020-02-15  0:03 ` [PATCH tip/core/rcu 4/4] locktorture: Forgive apparent unfairness if CPU hotplug paulmck
  3 siblings, 0 replies; 5+ messages in thread
From: paulmck @ 2020-02-15  0:03 UTC (permalink / raw)
  To: rcu
  Cc: linux-kernel, kernel-team, mingo, jiangshanlai, dipankar, akpm,
	mathieu.desnoyers, josh, tglx, peterz, rostedt, dhowells,
	edumazet, fweisbec, oleg, joel, Paul E. McKenney

From: "Paul E. McKenney" <paulmck@kernel.org>

Both lock_torture_writer() and lock_torture_reader() use the "static"
keyword on their DEFINE_TORTURE_RANDOM(rand) declarations, which means
that a single instance of a random-number generator are shared among all
the writers and another is shared among all the readers.  Unfortunately,
this random-number generator was not designed for concurrent access.
This commit therefore removes both "static" keywords so that each reader
and each writer gets its own random-number generator.

Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
---
 kernel/locking/locktorture.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/kernel/locking/locktorture.c b/kernel/locking/locktorture.c
index 687c1d8..5baf904 100644
--- a/kernel/locking/locktorture.c
+++ b/kernel/locking/locktorture.c
@@ -618,7 +618,7 @@ static struct lock_torture_ops percpu_rwsem_lock_ops = {
 static int lock_torture_writer(void *arg)
 {
 	struct lock_stress_stats *lwsp = arg;
-	static DEFINE_TORTURE_RANDOM(rand);
+	DEFINE_TORTURE_RANDOM(rand);
 
 	VERBOSE_TOROUT_STRING("lock_torture_writer task started");
 	set_user_nice(current, MAX_NICE);
@@ -655,7 +655,7 @@ static int lock_torture_writer(void *arg)
 static int lock_torture_reader(void *arg)
 {
 	struct lock_stress_stats *lrsp = arg;
-	static DEFINE_TORTURE_RANDOM(rand);
+	DEFINE_TORTURE_RANDOM(rand);
 
 	VERBOSE_TOROUT_STRING("lock_torture_reader task started");
 	set_user_nice(current, MAX_NICE);
-- 
2.9.5


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH tip/core/rcu 4/4] locktorture: Forgive apparent unfairness if CPU hotplug
  2020-02-15  0:03 [PATCH tip/core/rcu 0/4] Lock torture-test updates for v5.7 Paul E. McKenney
                   ` (2 preceding siblings ...)
  2020-02-15  0:03 ` [PATCH tip/core/rcu 3/4] locktorture: Use private random-number generators paulmck
@ 2020-02-15  0:03 ` paulmck
  3 siblings, 0 replies; 5+ messages in thread
From: paulmck @ 2020-02-15  0:03 UTC (permalink / raw)
  To: rcu
  Cc: linux-kernel, kernel-team, mingo, jiangshanlai, dipankar, akpm,
	mathieu.desnoyers, josh, tglx, peterz, rostedt, dhowells,
	edumazet, fweisbec, oleg, joel, Paul E. McKenney

From: "Paul E. McKenney" <paulmck@kernel.org>

If CPU hotplug testing is enabled, a lock might appear to be maximally
unfair just because one of the CPUs was offline almost all the time.
This commit therefore forgives unfairness if CPU hotplug testing was
enabled.

Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
---
 kernel/locking/locktorture.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/kernel/locking/locktorture.c b/kernel/locking/locktorture.c
index 5baf904..5efbfc6 100644
--- a/kernel/locking/locktorture.c
+++ b/kernel/locking/locktorture.c
@@ -704,7 +704,8 @@ static void __torture_print_stats(char *page,
 	page += sprintf(page,
 			"%s:  Total: %lld  Max/Min: %ld/%ld %s  Fail: %d %s\n",
 			write ? "Writes" : "Reads ",
-			sum, max, min, max / 2 > min ? "???" : "",
+			sum, max, min,
+			!onoff_interval && max / 2 > min ? "???" : "",
 			fail, fail ? "!!!" : "");
 	if (fail)
 		atomic_inc(&cxt.n_lock_torture_errors);
-- 
2.9.5


^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2020-02-15  0:03 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-02-15  0:03 [PATCH tip/core/rcu 0/4] Lock torture-test updates for v5.7 Paul E. McKenney
2020-02-15  0:03 ` [PATCH tip/core/rcu 1/4] locktorture: Print ratio of acquisitions, not failures paulmck
2020-02-15  0:03 ` [PATCH tip/core/rcu 2/4] locktorture: Allow CPU-hotplug to be disabled via --bootargs paulmck
2020-02-15  0:03 ` [PATCH tip/core/rcu 3/4] locktorture: Use private random-number generators paulmck
2020-02-15  0:03 ` [PATCH tip/core/rcu 4/4] locktorture: Forgive apparent unfairness if CPU hotplug paulmck

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).