Re: [PATCH] hazptrtorture: Fix inverted sleep condition in do_pending kthread

"Paul E. McKenney" <[email protected]> Mon, 3 Aug 2026 20:46:05 -0700
Newsgroups org.kernel.vger.rcu,org.kernel.vger.linux-kernel
Message-ID <089b21e8-4bd6-4517-b36b-d18452260302@paulmck-laptop>
On Tue, Aug 04, 2026 at 12:03:39AM +0000, Bradley Morgan wrote:
> The do_pending kthread never sleeps. Its supposed to.
> kthread_do_pending_ms sets the gap between cleanups, and the docs
> say so too. But the sleep sits behind torture_must_stop(), and thats
> false while the test runs. So the kthread never sleeps. It just loops.
> It drains the pending lists over and over, no pause, and burns a full
> CPU for the whole test.
> 
> Flip the check. With !torture_must_stop() it sleeps for
> kthread_do_pending_ms between passes. When the test stops it does one
> last cleanup and exits. Nothing left to do, so no sleep needed then.
> 
> Fixes: 94d2e93c222e ("hazptrtorture: Add kthread to release deferred hazard pointers")
> Signed-off-by: Bradley Morgan <[email protected]>

Good catch, applied, thank you!

							Thanx, Paul

> ---
>  kernel/rcu/hazptrtorture.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/kernel/rcu/hazptrtorture.c b/kernel/rcu/hazptrtorture.c
> index 72aeb50668e9..7c8b5899fb01 100644
> --- a/kernel/rcu/hazptrtorture.c
> +++ b/kernel/rcu/hazptrtorture.c
> @@ -555,7 +555,7 @@ static int hazptr_torture_do_pending(void *arg)
>  			cpu = cpumask_next_wrap(cpu, cpu_possible_mask);
>  			hazptr_torture_do_one_pending(cpu, &rand);
>  		}
> -		if (torture_must_stop())
> +		if (!torture_must_stop())
>  			torture_hrtimeout_ms(kthread_do_pending_ms, USEC_PER_MSEC, &rand);
>  		// Omit stutter_wait() because this function needs to do cleanup.
>  	} while (!torture_must_stop());
> -- 
> 2.47.3
>