mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Vincent Whitchurch <Vincent.Whitchurch@axis.com>
To: "tglx@linutronix.de" <tglx@linutronix.de>,
	Vincent Whitchurch <Vincent.Whitchurch@axis.com>
Cc: "linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	kernel <kernel@axis.com>
Subject: Re: [PATCH v2] genirq: Fix nested thread vs synchronize_hardirq() deadlock
Date: Mon, 3 Jul 2023 09:28:52 +0000	[thread overview]
Message-ID: <e52e4b71611c984281352d2fb1ab746ff09f4d10.camel@axis.com> (raw)
In-Reply-To: <87leg1z5c3.ffs@tglx>

On Fri, 2023-06-30 at 11:07 +0200, Thomas Gleixner wrote:
> On Tue, Jun 20 2023 at 13:16, Vincent Whitchurch wrote:
> > --- a/kernel/irq/chip.c
> > +++ b/kernel/irq/chip.c
> > @@ -476,7 +476,7 @@ void handle_nested_irq(unsigned int irq)
> >  	}
> >  
> > 
> >  	kstat_incr_irqs_this_cpu(desc);
> > -	irqd_set(&desc->irq_data, IRQD_IRQ_INPROGRESS);
> > +	atomic_inc(&desc->threads_active);
> >  	raw_spin_unlock_irq(&desc->lock);
> >  
> > 
> >  	action_ret = IRQ_NONE;
> > @@ -487,7 +487,8 @@ void handle_nested_irq(unsigned int irq)
> >  		note_interrupt(desc, action_ret);
> >  
> > 
> >  	raw_spin_lock_irq(&desc->lock);
> > -	irqd_clear(&desc->irq_data, IRQD_IRQ_INPROGRESS);
> > +	if (atomic_dec_and_test(&desc->threads_active))
> > +		wake_up(&desc->wait_for_threads);
> 
> This breaks on RT. The wakeup cannot be inside the raw spin-locked
> region.

OK.  I will remove the acquisition of the spin lock at the end of this
function since it was only used for protecting the irqd flags.

> Also this is open coding wake_threads_waitq().

OK, that's in manage.c so I'll make it non-static and add it to
internals.h and use it from here.

> > +static void __synchronize_irq(struct irq_desc *desc)
> > +{
> > +	__synchronize_hardirq(desc, true);
> > +	/*
> > +	 * We made sure that no hardirq handler is
> > +	 * running. Now verify that no threaded handlers are
> > +	 * active.
> > +	 */
> > +	wait_event(desc->wait_for_threads,
> > +		   !atomic_read(&desc->threads_active));
> 
> Splitting this out is fine. Not reformatting it not so much.

Will fix.

      reply	other threads:[~2023-07-03  9:29 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-06-20 11:16 Vincent Whitchurch
2023-06-30  9:07 ` Thomas Gleixner
2023-07-03  9:28   ` Vincent Whitchurch [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=e52e4b71611c984281352d2fb1ab746ff09f4d10.camel@axis.com \
    --to=vincent.whitchurch@axis.com \
    --cc=kernel@axis.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=tglx@linutronix.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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®