linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* question about irq_enter()/irq_exit() calling policy
@ 2016-11-29 23:47 Grygorii Strashko
  2016-11-30 10:21 ` Russell King - ARM Linux
  0 siblings, 1 reply; 3+ messages in thread
From: Grygorii Strashko @ 2016-11-29 23:47 UTC (permalink / raw)
  To: linux-arm-kernel, linux-kernel, linux-rt-users

Hi All,

Sorry for the may be dumb question, but what is the calling policy for irq_enter()/irq_exit()?

1) Should these function be called each time system enter/exit IRQ context?

HW IRQ:
 switch (IRQ mode)
  ...
  irq_enter()
	handle irq - execute hw_irq_hadler
  irq_exit()
  ...
 switch

2) Should these function be called for each processed irq?


HW IRQ:
 switch (IRQ mode)
  ...
  while (irq = get_pending_irq()) {
  	...
  	irq_enter()
		handle(irq) - execute hw_irq_hadler
  	irq_exit()
 }
 ...
 switch

-- 
regards,
-grygorii

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

* Re: question about irq_enter()/irq_exit() calling policy
  2016-11-29 23:47 question about irq_enter()/irq_exit() calling policy Grygorii Strashko
@ 2016-11-30 10:21 ` Russell King - ARM Linux
  2016-11-30 17:07   ` Grygorii Strashko
  0 siblings, 1 reply; 3+ messages in thread
From: Russell King - ARM Linux @ 2016-11-30 10:21 UTC (permalink / raw)
  To: Grygorii Strashko; +Cc: linux-arm-kernel, linux-kernel, linux-rt-users

On Tue, Nov 29, 2016 at 05:47:12PM -0600, Grygorii Strashko wrote:
> 2) Should these function be called for each processed irq?
> 
> 
> HW IRQ:
>  switch (IRQ mode)
>   ...
>   while (irq = get_pending_irq()) {
>   	...
>   	irq_enter()
> 		handle(irq) - execute hw_irq_hadler
>   	irq_exit()
>  }
>  ...
>  switch

We tend to do (2) as a general rule, which isn't much different from what
other architectures do - even if they have a method to directly enter
through vectors (eg, x86) the effect of two pending interrupts is that one
will run after each other, and there will be an intervening exit -> entry.

In the case of ARM CPUs, if the interrupt signal is active, you vector
back to the interrupt handler as soon as you exit back to the parent
context without executing any parent context instructions.

So, we have the choice of going through all the IRQ entry code, processing
one interrupt, and returning only to then re-vector back through the IRQ
entry code, or we can process all the pending IRQs that we can see at that
time.

The former method wastes all the CPU cycles getting from the parent context
to the IRQ context for each and every interrupt.

-- 
RMK's Patch system: http://www.armlinux.org.uk/developer/patches/
FTTC broadband for 0.8mile line: currently at 9.6Mbps down 400kbps up
according to speedtest.net.

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

* Re: question about irq_enter()/irq_exit() calling policy
  2016-11-30 10:21 ` Russell King - ARM Linux
@ 2016-11-30 17:07   ` Grygorii Strashko
  0 siblings, 0 replies; 3+ messages in thread
From: Grygorii Strashko @ 2016-11-30 17:07 UTC (permalink / raw)
  To: Russell King - ARM Linux; +Cc: linux-arm-kernel, linux-kernel, linux-rt-users

Hi Russell,

On 11/30/2016 04:21 AM, Russell King - ARM Linux wrote:
> On Tue, Nov 29, 2016 at 05:47:12PM -0600, Grygorii Strashko wrote:
>> 2) Should these function be called for each processed irq?
>>
>>
>> HW IRQ:
>>  switch (IRQ mode)
>>   ...
>>   while (irq = get_pending_irq()) {
>>   	...
>>   	irq_enter()
>> 		handle(irq) - execute hw_irq_hadler
>>   	irq_exit()
>>  }
>>  ...
>>  switch
> 
> We tend to do (2) as a general rule, which isn't much different from what
> other architectures do - even if they have a method to directly enter
> through vectors (eg, x86) the effect of two pending interrupts is that one
> will run after each other, and there will be an intervening exit -> entry.
> 
> In the case of ARM CPUs, if the interrupt signal is active, you vector
> back to the interrupt handler as soon as you exit back to the parent
> context without executing any parent context instructions.
> 
> So, we have the choice of going through all the IRQ entry code, processing
> one interrupt, and returning only to then re-vector back through the IRQ
> entry code, or we can process all the pending IRQs that we can see at that
> time.
> 
> The former method wastes all the CPU cycles getting from the parent context
> to the IRQ context for each and every interrupt.
> 

Thanks a lot for your detailed explanation.
When I've asked this question my intention was to understand possibility of calling 
irq_enter()/irq_exit() only once for the case (2), like:
 HW IRQ:
  switch (IRQ mode)
   ...
  irq_enter()
   while (irq = get_pending_irq()) {
   	...
 	handle(irq) - execute hw_irq_hadler
  }
  irq_exit()
  ...
  switch

-- 
regards,
-grygorii

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

end of thread, other threads:[~2016-11-30 17:08 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-11-29 23:47 question about irq_enter()/irq_exit() calling policy Grygorii Strashko
2016-11-30 10:21 ` Russell King - ARM Linux
2016-11-30 17:07   ` Grygorii Strashko

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).