All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] rcu: Use IRQ_WORK_INIT_HARD for srcu's irq_work
@ 2026-08-20 11:00 Sebastian Andrzej Siewior
  2026-08-20 12:40 ` Frederic Weisbecker
  0 siblings, 1 reply; 3+ messages in thread
From: Sebastian Andrzej Siewior @ 2026-08-20 11:00 UTC (permalink / raw)
  To: rcu, linux-rt-devel
  Cc: Lai Jiangshan, Paul E. McKenney, Josh Triplett, Steven Rostedt,
	Mathieu Desnoyers, Clark Williams

The irq_work in srcu is used to schedule a delayed work. The work item
is not scheduled directly because it is not always possible wake a
thread directly.

On PREEMPT_RT the default irq_work is initialized with IRQ_WORK_LAZY and
is delayed to the irq_work thread. A system booted with the command line
"trace_event=…" will freeze during boot because the irq_work thread is
not yet deployed (and tracing uses synchronize_srcu() in
tp_rcu_cond_sync()).

The irq_work performs just a wakeup a thread, there is nothing wrong
with doing this from hardirq context on PREEMPT_RT.

Use IRQ_WORK_INIT_HARD for srcu's irq_work.

Fixes: 7c405fb3279b3 ("rcu: Use an intermediate irq_work to start process_srcu()")
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
---
 kernel/rcu/srcutree.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/kernel/rcu/srcutree.c b/kernel/rcu/srcutree.c
index 7c2f7cc131f7a..b703233d4a63f 100644
--- a/kernel/rcu/srcutree.c
+++ b/kernel/rcu/srcutree.c
@@ -218,7 +218,7 @@ static int init_srcu_struct_fields(struct srcu_struct *ssp, bool is_static)
 	mutex_init(&ssp->srcu_sup->srcu_barrier_mutex);
 	atomic_set(&ssp->srcu_sup->srcu_barrier_cpu_cnt, 0);
 	INIT_DELAYED_WORK(&ssp->srcu_sup->work, process_srcu);
-	init_irq_work(&ssp->srcu_sup->irq_work, srcu_irq_work);
+	ssp->srcu_sup->irq_work = IRQ_WORK_INIT_HARD(srcu_irq_work);
 	ssp->srcu_sup->sda_is_static = is_static;
 	if (!is_static) {
 		ssp->sda = alloc_percpu(struct srcu_data);
-- 
2.55.0


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

* Re: [PATCH] rcu: Use IRQ_WORK_INIT_HARD for srcu's irq_work
  2026-08-20 11:00 [PATCH] rcu: Use IRQ_WORK_INIT_HARD for srcu's irq_work Sebastian Andrzej Siewior
@ 2026-08-20 12:40 ` Frederic Weisbecker
  2026-08-20 13:55   ` Sebastian Andrzej Siewior
  0 siblings, 1 reply; 3+ messages in thread
From: Frederic Weisbecker @ 2026-08-20 12:40 UTC (permalink / raw)
  To: Sebastian Andrzej Siewior
  Cc: rcu, linux-rt-devel, Lai Jiangshan, Paul E. McKenney,
	Josh Triplett, Steven Rostedt, Mathieu Desnoyers, Clark Williams

Le Thu, Aug 20, 2026 at 01:00:08PM +0200, Sebastian Andrzej Siewior a écrit :
> The irq_work in srcu is used to schedule a delayed work. The work item
> is not scheduled directly because it is not always possible wake a
> thread directly.
> 
> On PREEMPT_RT the default irq_work is initialized with IRQ_WORK_LAZY and
> is delayed to the irq_work thread. A system booted with the command line
> "trace_event=…" will freeze during boot because the irq_work thread is
> not yet deployed (and tracing uses synchronize_srcu() in
> tp_rcu_cond_sync()).
> 
> The irq_work performs just a wakeup a thread, there is nothing wrong
> with doing this from hardirq context on PREEMPT_RT.
> 
> Use IRQ_WORK_INIT_HARD for srcu's irq_work.
> 
> Fixes: 7c405fb3279b3 ("rcu: Use an intermediate irq_work to start process_srcu()")
> Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
> ---
>  kernel/rcu/srcutree.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/kernel/rcu/srcutree.c b/kernel/rcu/srcutree.c
> index 7c2f7cc131f7a..b703233d4a63f 100644
> --- a/kernel/rcu/srcutree.c
> +++ b/kernel/rcu/srcutree.c
> @@ -218,7 +218,7 @@ static int init_srcu_struct_fields(struct srcu_struct *ssp, bool is_static)
>  	mutex_init(&ssp->srcu_sup->srcu_barrier_mutex);
>  	atomic_set(&ssp->srcu_sup->srcu_barrier_cpu_cnt, 0);
>  	INIT_DELAYED_WORK(&ssp->srcu_sup->work, process_srcu);
> -	init_irq_work(&ssp->srcu_sup->irq_work, srcu_irq_work);
> +	ssp->srcu_sup->irq_work = IRQ_WORK_INIT_HARD(srcu_irq_work);

It may need a comment to not lose that.

>  	ssp->srcu_sup->sda_is_static = is_static;
>  	if (!is_static) {
>  		ssp->sda = alloc_percpu(struct srcu_data);
> -- 
> 2.55.0
> 
>

Perhaps all irq works queued before the relevant kthread is started should
temporarily be queued as hard?

Thanks.

-- 
Frederic Weisbecker
SUSE Labs

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

* Re: [PATCH] rcu: Use IRQ_WORK_INIT_HARD for srcu's irq_work
  2026-08-20 12:40 ` Frederic Weisbecker
@ 2026-08-20 13:55   ` Sebastian Andrzej Siewior
  0 siblings, 0 replies; 3+ messages in thread
From: Sebastian Andrzej Siewior @ 2026-08-20 13:55 UTC (permalink / raw)
  To: Frederic Weisbecker
  Cc: rcu, linux-rt-devel, Lai Jiangshan, Paul E. McKenney,
	Josh Triplett, Steven Rostedt, Mathieu Desnoyers, Clark Williams

On 2026-08-20 14:40:57 [+0200], Frederic Weisbecker wrote:
> Le Thu, Aug 20, 2026 at 01:00:08PM +0200, Sebastian Andrzej Siewior a écrit :
> > The irq_work in srcu is used to schedule a delayed work. The work item
> > is not scheduled directly because it is not always possible wake a
> > thread directly.
> > 
> > On PREEMPT_RT the default irq_work is initialized with IRQ_WORK_LAZY and
> > is delayed to the irq_work thread. A system booted with the command line
> > "trace_event=…" will freeze during boot because the irq_work thread is
> > not yet deployed (and tracing uses synchronize_srcu() in
> > tp_rcu_cond_sync()).
> > 
> > The irq_work performs just a wakeup a thread, there is nothing wrong
> > with doing this from hardirq context on PREEMPT_RT.
> > 
> > Use IRQ_WORK_INIT_HARD for srcu's irq_work.
> > 
> > Fixes: 7c405fb3279b3 ("rcu: Use an intermediate irq_work to start process_srcu()")
> > Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
> > ---
> >  kernel/rcu/srcutree.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> > 
> > diff --git a/kernel/rcu/srcutree.c b/kernel/rcu/srcutree.c
> > index 7c2f7cc131f7a..b703233d4a63f 100644
> > --- a/kernel/rcu/srcutree.c
> > +++ b/kernel/rcu/srcutree.c
> > @@ -218,7 +218,7 @@ static int init_srcu_struct_fields(struct srcu_struct *ssp, bool is_static)
> >  	mutex_init(&ssp->srcu_sup->srcu_barrier_mutex);
> >  	atomic_set(&ssp->srcu_sup->srcu_barrier_cpu_cnt, 0);
> >  	INIT_DELAYED_WORK(&ssp->srcu_sup->work, process_srcu);
> > -	init_irq_work(&ssp->srcu_sup->irq_work, srcu_irq_work);
> > +	ssp->srcu_sup->irq_work = IRQ_WORK_INIT_HARD(srcu_irq_work);
> 
> It may need a comment to not lose that.

We could also make irq_work.o earlier in the Makefile, right at the top
so it comes before tracing. This was one of the first ideas and makes
the issue also go away. But given that it is just a wake we avoid waking
the irq_work/ thread just to schedule a timer/ wake workqueue.

> >  	ssp->srcu_sup->sda_is_static = is_static;
> >  	if (!is_static) {
> >  		ssp->sda = alloc_percpu(struct srcu_data);
> > -- 
> > 2.55.0
> > 
> >
> 
> Perhaps all irq works queued before the relevant kthread is started should
> temporarily be queued as hard?

Urgh. irq_work shouldn't become a widespread user ;)
If the scheduler is up but irq_work thread is not yet created and the
irq_work uses sleeping locks then it would create warnings.
In testing right now I see just wake_up_klogd_work_func() which is
always LAZY but would qualify otherwise for a warning. We wouldn't
trigger anything yet but you get the idea.

> Thanks.

Sebastian

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

end of thread, other threads:[~2026-08-20 13:55 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-08-20 11:00 [PATCH] rcu: Use IRQ_WORK_INIT_HARD for srcu's irq_work Sebastian Andrzej Siewior
2026-08-20 12:40 ` Frederic Weisbecker
2026-08-20 13:55   ` Sebastian Andrzej Siewior

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.