]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/commitdiff
locktorture: Print ratio of acquisitions, not failures
authorPaul E. McKenney <paulmck@kernel.org>
Thu, 23 Jan 2020 17:19:01 +0000 (09:19 -0800)
committerPaul E. McKenney <paulmck@kernel.org>
Thu, 20 Feb 2020 23:59:59 +0000 (15:59 -0800)
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

index 99475a66c94f82f6e44e5a5bd1574409198ace5e..687c1d83dc204a06d9c7c67eec3caefb1eedd443 100644 (file)
@@ -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",