Lock torture-test updates for v5.7
Subsystems (4)
Paul E. McKenney
maintainercover Lock torture-test updates for v5.7
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(-)
[email protected]
maintainerPATCH 1/4 locktorture: Print ratio of acquisitions, not failures
From: "Paul E. McKenney" <[email protected]>
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!
--- kernel/locking/locktorture.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
kernel/locking/locktorture.c +4 -4
@@ -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",
Signature · 1 line
2.9.5
[email protected]
maintainerPATCH 2/4 locktorture: Allow CPU-hotplug to be disabled via --bootargs
In reply to Paul E. McKenneyFrom: "Paul E. McKenney" <[email protected]>
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.
--- tools/testing/selftests/rcutorture/bin/functions.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/testing/selftests/rcutorture/bin/functions.sh +1 -1
@@ -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
Signature · 1 line
2.9.5
[email protected]
maintainerPATCH 3/4 locktorture: Use private random-number generators
In reply to Paul E. McKenneyFrom: "Paul E. McKenney" <[email protected]>
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.
--- kernel/locking/locktorture.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
kernel/locking/locktorture.c +2 -2
@@ -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 );
Signature · 1 line
2.9.5
[email protected]
maintainerPATCH 4/4 locktorture: Forgive apparent unfairness if CPU hotplug
In reply to Paul E. McKenneyFrom: "Paul E. McKenney" <[email protected]>
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.
--- kernel/locking/locktorture.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
kernel/locking/locktorture.c +2 -1
@@ -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);
Signature · 1 line
2.9.5