mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] hazptrtorture: Fix inverted sleep condition in do_pending kthread
@ 2026-08-04  0:03 Bradley Morgan
  2026-08-04  3:46 ` Paul E. McKenney
  2026-09-04 13:01 ` Mathieu Desnoyers
  0 siblings, 2 replies; 6+ messages in thread
From: Bradley Morgan @ 2026-08-04  0:03 UTC (permalink / raw)
  To: Paul E . McKenney, Frederic Weisbecker, Neeraj Upadhyay,
	Joel Fernandes, Josh Triplett, Boqun Feng, Uladzislau Rezki
  Cc: Steven Rostedt, Mathieu Desnoyers, Lai Jiangshan, Zqiang, rcu,
	linux-kernel

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 <include@grrlz.net>
---
 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


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

* Re: [PATCH] hazptrtorture: Fix inverted sleep condition in do_pending kthread
  2026-08-04  0:03 [PATCH] hazptrtorture: Fix inverted sleep condition in do_pending kthread Bradley Morgan
@ 2026-08-04  3:46 ` Paul E. McKenney
  2026-09-04 13:01 ` Mathieu Desnoyers
  1 sibling, 0 replies; 6+ messages in thread
From: Paul E. McKenney @ 2026-08-04  3:46 UTC (permalink / raw)
  To: Bradley Morgan
  Cc: Frederic Weisbecker, Neeraj Upadhyay, Joel Fernandes,
	Josh Triplett, Boqun Feng, Uladzislau Rezki, Steven Rostedt,
	Mathieu Desnoyers, Lai Jiangshan, Zqiang, rcu, linux-kernel

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 <include@grrlz.net>

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
> 

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

* Re: [PATCH] hazptrtorture: Fix inverted sleep condition in do_pending kthread
  2026-08-04  0:03 [PATCH] hazptrtorture: Fix inverted sleep condition in do_pending kthread Bradley Morgan
  2026-08-04  3:46 ` Paul E. McKenney
@ 2026-09-04 13:01 ` Mathieu Desnoyers
  2026-09-04 16:00   ` Paul E. McKenney
  1 sibling, 1 reply; 6+ messages in thread
From: Mathieu Desnoyers @ 2026-09-04 13:01 UTC (permalink / raw)
  To: Bradley Morgan, Paul E . McKenney, Frederic Weisbecker,
	Neeraj Upadhyay, Joel Fernandes, Josh Triplett, Boqun Feng,
	Uladzislau Rezki
  Cc: Steven Rostedt, Lai Jiangshan, Zqiang, rcu, linux-kernel

On 2026-08-03 20:03, 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.

Paul, I just found this patch in my junk email folder. Maybe relevant
for you ?

Thanks,

Mathieu

> 
> 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 <include@grrlz.net>
> ---
>   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());


-- 
Mathieu Desnoyers
EfficiOS Inc.
https://www.efficios.com

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

* Re: [PATCH] hazptrtorture: Fix inverted sleep condition in do_pending kthread
  2026-09-04 13:01 ` Mathieu Desnoyers
@ 2026-09-04 16:00   ` Paul E. McKenney
  2026-09-04 17:28     ` Bradley Morgan
  0 siblings, 1 reply; 6+ messages in thread
From: Paul E. McKenney @ 2026-09-04 16:00 UTC (permalink / raw)
  To: Mathieu Desnoyers
  Cc: Bradley Morgan, Frederic Weisbecker, Neeraj Upadhyay,
	Joel Fernandes, Josh Triplett, Boqun Feng, Uladzislau Rezki,
	Steven Rostedt, Lai Jiangshan, Zqiang, rcu, linux-kernel

On Fri, Sep 04, 2026 at 09:01:05AM -0400, Mathieu Desnoyers wrote:
> On 2026-08-03 20:03, 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.
> 
> Paul, I just found this patch in my junk email folder. Maybe relevant
> for you ?

We got it in my -rcu tree:

15b9fca2f5ce ("hazptrtorture: Fix inverted sleep condition in do_pending kthread")

But I do appreciate your checking for missed patches, thank you!

							Thanx, Paul

> Thanks,
> 
> Mathieu
> 
> > 
> > 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 <include@grrlz.net>
> > ---
> >   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());
> 
> 
> -- 
> Mathieu Desnoyers
> EfficiOS Inc.
> https://www.efficios.com

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

* Re: [PATCH] hazptrtorture: Fix inverted sleep condition in do_pending kthread
  2026-09-04 16:00   ` Paul E. McKenney
@ 2026-09-04 17:28     ` Bradley Morgan
  2026-09-05 20:40       ` Paul E. McKenney
  0 siblings, 1 reply; 6+ messages in thread
From: Bradley Morgan @ 2026-09-04 17:28 UTC (permalink / raw)
  To: paulmck
  Cc: boqun, frederic, include, jiangshanlai, joelagnelf, josh,
	linux-kernel, mathieu.desnoyers, neeraj.upadhyay, qiang.zhang,
	rcu, rostedt, urezki

On 4 September 2026 17:00:22 BST, "Paul E. McKenney" <paulmck@kernel.org>
wrote:
>On Fri, Sep 04, 2026 at 09:01:05AM -0400, Mathieu Desnoyers wrote:
>> On 2026-08-03 20:03, 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.
>> 
>> Paul, I just found this patch in my junk email folder. Maybe relevant
>> for you ?
>
>We got it in my -rcu tree:
>
>15b9fca2f5ce ("hazptrtorture: Fix inverted sleep condition in do_pending
>kthread")
>
>But I do appreciate your checking for missed patches, thank you!
>
>							Thanx, Paul
>
>> Thanks,
>> 
>> Mathieu
>> 
>> > 
>> > 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 <include@grrlz.net>
>> > ---
>> >   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());
>> 
>> 
>> -- 
>> Mathieu Desnoyers
>> EfficiOS Inc.
>> https://www.efficios.com
>
>
Hi, new email.

Could I ask where the heck hazptr is? Its not in next, would you like,
help???

--- Thanks!
https://lore.kernel.org/all/EE579805-42F2-4C58-B752-F28779EEB717@grrlz.net/

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

* Re: [PATCH] hazptrtorture: Fix inverted sleep condition in do_pending kthread
  2026-09-04 17:28     ` Bradley Morgan
@ 2026-09-05 20:40       ` Paul E. McKenney
  0 siblings, 0 replies; 6+ messages in thread
From: Paul E. McKenney @ 2026-09-05 20:40 UTC (permalink / raw)
  To: Bradley Morgan
  Cc: boqun, frederic, include, jiangshanlai, joelagnelf, josh,
	linux-kernel, mathieu.desnoyers, neeraj.upadhyay, qiang.zhang,
	rcu, rostedt, urezki

On Fri, Sep 04, 2026 at 06:28:45PM +0100, Bradley Morgan wrote:
> On 4 September 2026 17:00:22 BST, "Paul E. McKenney" <paulmck@kernel.org>
> wrote:
> >On Fri, Sep 04, 2026 at 09:01:05AM -0400, Mathieu Desnoyers wrote:
> >> On 2026-08-03 20:03, 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.
> >> 
> >> Paul, I just found this patch in my junk email folder. Maybe relevant
> >> for you ?
> >
> >We got it in my -rcu tree:
> >
> >15b9fca2f5ce ("hazptrtorture: Fix inverted sleep condition in do_pending
> >kthread")
> >
> >But I do appreciate your checking for missed patches, thank you!
> >
> >							Thanx, Paul
> >
> >> Thanks,
> >> 
> >> Mathieu
> >> 
> >> > 
> >> > 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 <include@grrlz.net>
> >> > ---
> >> >   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());
> >> 
> >> 
> >> -- 
> >> Mathieu Desnoyers
> >> EfficiOS Inc.
> >> https://www.efficios.com
> >
> >
> Hi, new email.
> 
> Could I ask where the heck hazptr is? Its not in next, would you like,
> help???
> 
> --- Thanks!
> https://lore.kernel.org/all/EE579805-42F2-4C58-B752-F28779EEB717@grrlz.net/

It is still in my -rcu tree.

I would not say "no" to a fix for this issue:

https://lore.kernel.org/all/EE579805-42F2-4C58-B752-F28779EEB717@grrlz.net/

Once that is in place, I would be happy to put this back into -next.

At some point, we will need to get rid of the concept of wildcard hazard
pointers, as those end up instead emulating RCU, but I don't see that
as an immediate obstacle.

							Thanx, Paul

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

end of thread, other threads:[~2026-09-05 20:40 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-08-04  0:03 [PATCH] hazptrtorture: Fix inverted sleep condition in do_pending kthread Bradley Morgan
2026-08-04  3:46 ` Paul E. McKenney
2026-09-04 13:01 ` Mathieu Desnoyers
2026-09-04 16:00   ` Paul E. McKenney
2026-09-04 17:28     ` Bradley Morgan
2026-09-05 20:40       ` Paul E. McKenney

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®