linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* How to know if there is a pending interrupt when they are masked?
@ 2019-02-14 14:34 Daniel Lezcano
  2019-02-14 15:35 ` Thomas Gleixner
  0 siblings, 1 reply; 5+ messages in thread
From: Daniel Lezcano @ 2019-02-14 14:34 UTC (permalink / raw)
  To: Thomas Gleixner, Marc Zyngier
  Cc: Linux Kernel Mailing List, Rafael J. Wysocki


Hi,

today we have the possibility to mask the local interrupt with the
command local_irq_disable / local_irq_enable.

The power management path disables the local interrupt in order to
initiate a power down sequence. If there is a pending interrupt this one
will make the power down function to abort, thus exiting right after
calling the shutdown function after costly operations. It could be
interesting to check if there is a pending interrupt before initiating
the power down sequence.

Is there a way to know if there is a pending interrupt on the current
CPU when the local interrupt are disabled? Something like,
local_irq_pending() function ?

Thanks
  -- Daniel


-- 
 <http://www.linaro.org/> Linaro.org │ Open source software for ARM SoCs

Follow Linaro:  <http://www.facebook.com/pages/Linaro> Facebook |
<http://twitter.com/#!/linaroorg> Twitter |
<http://www.linaro.org/linaro-blog/> Blog


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

* Re: How to know if there is a pending interrupt when they are masked?
  2019-02-14 14:34 How to know if there is a pending interrupt when they are masked? Daniel Lezcano
@ 2019-02-14 15:35 ` Thomas Gleixner
  2019-02-14 15:47   ` Marc Zyngier
  2019-02-14 16:12   ` Daniel Lezcano
  0 siblings, 2 replies; 5+ messages in thread
From: Thomas Gleixner @ 2019-02-14 15:35 UTC (permalink / raw)
  To: Daniel Lezcano; +Cc: Marc Zyngier, Linux Kernel Mailing List, Rafael J. Wysocki

On Thu, 14 Feb 2019, Daniel Lezcano wrote:
> today we have the possibility to mask the local interrupt with the
> command local_irq_disable / local_irq_enable.
> 
> The power management path disables the local interrupt in order to
> initiate a power down sequence. If there is a pending interrupt this one
> will make the power down function to abort, thus exiting right after
> calling the shutdown function after costly operations. It could be
> interesting to check if there is a pending interrupt before initiating
> the power down sequence.
> 
> Is there a way to know if there is a pending interrupt on the current
> CPU when the local interrupt are disabled? Something like,
> local_irq_pending() function ?

We have nothing like that today, but it would be possible to implement this
at least on x86 by peeking the local APIC registers.

OTOH, the question is whether it's worth the trouble because the interrupt
could come in right after the query and the same issue which you want to
address persists. It only makes sense if it reduces the time window so
significantly that it actually matters.

Thanks,

	tglx

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

* Re: How to know if there is a pending interrupt when they are masked?
  2019-02-14 15:35 ` Thomas Gleixner
@ 2019-02-14 15:47   ` Marc Zyngier
  2019-02-14 16:16     ` Daniel Lezcano
  2019-02-14 16:12   ` Daniel Lezcano
  1 sibling, 1 reply; 5+ messages in thread
From: Marc Zyngier @ 2019-02-14 15:47 UTC (permalink / raw)
  To: Thomas Gleixner, Daniel Lezcano
  Cc: Linux Kernel Mailing List, Rafael J. Wysocki

On 14/02/2019 15:35, Thomas Gleixner wrote:
> On Thu, 14 Feb 2019, Daniel Lezcano wrote:
>> today we have the possibility to mask the local interrupt with the
>> command local_irq_disable / local_irq_enable.
>>
>> The power management path disables the local interrupt in order to
>> initiate a power down sequence. If there is a pending interrupt this one
>> will make the power down function to abort, thus exiting right after
>> calling the shutdown function after costly operations. It could be
>> interesting to check if there is a pending interrupt before initiating
>> the power down sequence.
>>
>> Is there a way to know if there is a pending interrupt on the current
>> CPU when the local interrupt are disabled? Something like,
>> local_irq_pending() function ?
> 
> We have nothing like that today, but it would be possible to implement this
> at least on x86 by peeking the local APIC registers.

On arm64, reading ISR_EL1 would give some indication of that, but...

> OTOH, the question is whether it's worth the trouble because the interrupt
> could come in right after the query and the same issue which you want to
> address persists. It only makes sense if it reduces the time window so
> significantly that it actually matters.

as Thomas explains, the potential race is pretty tight.

Thanks,

	M.
-- 
Jazz is not dead. It just smells funny...

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

* Re: How to know if there is a pending interrupt when they are masked?
  2019-02-14 15:35 ` Thomas Gleixner
  2019-02-14 15:47   ` Marc Zyngier
@ 2019-02-14 16:12   ` Daniel Lezcano
  1 sibling, 0 replies; 5+ messages in thread
From: Daniel Lezcano @ 2019-02-14 16:12 UTC (permalink / raw)
  To: Thomas Gleixner
  Cc: Marc Zyngier, Linux Kernel Mailing List, Rafael J. Wysocki


Hi Thomas,


On 14/02/2019 16:35, Thomas Gleixner wrote:
> On Thu, 14 Feb 2019, Daniel Lezcano wrote:
>> today we have the possibility to mask the local interrupt with the
>> command local_irq_disable / local_irq_enable.
>>
>> The power management path disables the local interrupt in order to
>> initiate a power down sequence. If there is a pending interrupt this one
>> will make the power down function to abort, thus exiting right after
>> calling the shutdown function after costly operations. It could be
>> interesting to check if there is a pending interrupt before initiating
>> the power down sequence.
>>
>> Is there a way to know if there is a pending interrupt on the current
>> CPU when the local interrupt are disabled? Something like,
>> local_irq_pending() function ?
> 
> We have nothing like that today, but it would be possible to implement this
> at least on x86 by peeking the local APIC registers.
> 
> OTOH, the question is whether it's worth the trouble because the interrupt
> could come in right after the query and the same issue which you want to
> address persists. It only makes sense if it reduces the time window so
> significantly that it actually matters.

Yes, I agree. It should be worth only if we can prove we enter the deep
idle sequence with pending interrupts much more often than what we expect.

Actually, we have a similar action when the need_resched() is true, we
abort the idle sequence and exit the loop.




-- 
 <http://www.linaro.org/> Linaro.org │ Open source software for ARM SoCs

Follow Linaro:  <http://www.facebook.com/pages/Linaro> Facebook |
<http://twitter.com/#!/linaroorg> Twitter |
<http://www.linaro.org/linaro-blog/> Blog


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

* Re: How to know if there is a pending interrupt when they are masked?
  2019-02-14 15:47   ` Marc Zyngier
@ 2019-02-14 16:16     ` Daniel Lezcano
  0 siblings, 0 replies; 5+ messages in thread
From: Daniel Lezcano @ 2019-02-14 16:16 UTC (permalink / raw)
  To: Marc Zyngier, Thomas Gleixner
  Cc: Linux Kernel Mailing List, Rafael J. Wysocki


Hi Thomas,

thanks for the answer,

On 14/02/2019 16:47, Marc Zyngier wrote:
> On 14/02/2019 15:35, Thomas Gleixner wrote:
>> On Thu, 14 Feb 2019, Daniel Lezcano wrote:
>>> today we have the possibility to mask the local interrupt with the
>>> command local_irq_disable / local_irq_enable.
>>>
>>> The power management path disables the local interrupt in order to
>>> initiate a power down sequence. If there is a pending interrupt this one
>>> will make the power down function to abort, thus exiting right after
>>> calling the shutdown function after costly operations. It could be
>>> interesting to check if there is a pending interrupt before initiating
>>> the power down sequence.
>>>
>>> Is there a way to know if there is a pending interrupt on the current
>>> CPU when the local interrupt are disabled? Something like,
>>> local_irq_pending() function ?
>>
>> We have nothing like that today, but it would be possible to implement this
>> at least on x86 by peeking the local APIC registers.
> 
> On arm64, reading ISR_EL1 would give some indication of that, but...

Does 'some indication' means as soon as we read the ISR_EL1 it may be
outdated right after ?

>> OTOH, the question is whether it's worth the trouble because the interrupt
>> could come in right after the query and the same issue which you want to
>> address persists. It only makes sense if it reduces the time window so
>> significantly that it actually matters.
> 
> as Thomas explains, the potential race is pretty tight.

Is a simple hack possible on ARM64 to check if it is worth or not?

-- 
 <http://www.linaro.org/> Linaro.org │ Open source software for ARM SoCs

Follow Linaro:  <http://www.facebook.com/pages/Linaro> Facebook |
<http://twitter.com/#!/linaroorg> Twitter |
<http://www.linaro.org/linaro-blog/> Blog


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

end of thread, other threads:[~2019-02-14 16:16 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-02-14 14:34 How to know if there is a pending interrupt when they are masked? Daniel Lezcano
2019-02-14 15:35 ` Thomas Gleixner
2019-02-14 15:47   ` Marc Zyngier
2019-02-14 16:16     ` Daniel Lezcano
2019-02-14 16:12   ` Daniel Lezcano

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).