Re: [PATCH v3 2/3] genirq: introduce update_irq_devid()

From: Thomas Gleixner
Date: Mon Aug 19 2019 - 04:18:48 EST


Ben,

On Mon, 19 Aug 2019, luoben wrote:
> å 2019/8/15 äå10:58, Thomas Gleixner åé:
> > > This narrows the gap for setting up new irq (and irte, if has)
> > What does that mean: "narrows the gap"
> >
> > What's the gap and why is it only made smaller and not closed?
>
> Sorry for confusing. The so called 'gap' is a time window between free_irq()
> and request_irq().

And exactly this information wants to be in the changelog.

> > function please. Also it does not matter whether the time is short or
> > not. The point is:
> >
> > Ensure that an interrupt in flight on another CPU which uses
> > the
> > old 'dev_id' has completed because the caller can free the
> > memory
> > to which it points after this function returns.
> >
> > But this has another twist:
> >
> > CPU0 CPU1
> >
> > interrupt
> > primary_handler(old_dev_id)
> > do_stuff_on(old_dev_id)
> > return WAKE_THREAD; update_dev_id()
> > wakeup_thread();
> > action->dev_id = new_dev_id;
> > irq_thread()
> > secondary_handler(new_dev_id)
> >
> > That's broken and synchronize_irq() does not protect against it.
>
> Thanks to point it out, I will change to the following in next version, is
> that ok?
>
> ...
>
> ÂÂÂ /*

^^^
Please use a mail client which does not insert random wierd characters.

> ÂÂÂÂ * Ensure that an interrupt in flight on another CPU which uses the
> ÂÂÂÂ * old 'dev_id' has completed because the caller can free the memory
> ÂÂÂÂ * to which it points after this function returns. And also void to

s/void/avoid/

> ÂÂÂÂ * update 'dev_id' in the middle of a threaded interrupt process, it
> ÂÂÂÂ * can lead to a twist that primary handler uses old 'dev_id' but new
> ÂÂÂÂ * 'dev_id' is used by secondary handler.
> ÂÂÂÂ */
> ÂÂÂ disable_irq(irq);

Yes, that works.

Thanks,

tglx