xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
* [question] will softirq handler potentially be called many times?
@ 2012-02-17  4:47 Kai Huang
  2012-02-17  9:20 ` Keir Fraser
  0 siblings, 1 reply; 2+ messages in thread
From: Kai Huang @ 2012-02-17  4:47 UTC (permalink / raw)
  To: Xen-devel

Hi,

I see the __do_softirq is called when ! in_atomic(), which means
potentially __do_softirq may be interrupted by trap, exception,
interrupt, etc, so seems softirq handler may be executed many times?

For example, if interrupt happens after i =
find_first_set_bit(pending), the same softirq hander will be called
twice as the do_softriq will be called after all interrupt handler
returned, and the pending bit has not been cleared yet when first
do_softirq was called.

static void __do_softirq(unsigned long ignore_mask)
{
    ......
    for ( ; ; )
    {
        ......
        i = find_first_set_bit(pending);
                                                   <- interrupt happens
        clear_bit(i, &softirq_pending(cpu));
        (*softirq_handlers[i])();
    }
}

-cody

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

* Re: [question] will softirq handler potentially be called many times?
  2012-02-17  4:47 [question] will softirq handler potentially be called many times? Kai Huang
@ 2012-02-17  9:20 ` Keir Fraser
  0 siblings, 0 replies; 2+ messages in thread
From: Keir Fraser @ 2012-02-17  9:20 UTC (permalink / raw)
  To: Kai Huang, Xen-devel

On 17/02/2012 04:47, "Kai Huang" <mail.kai.huang@gmail.com> wrote:

> Hi,
> 
> I see the __do_softirq is called when ! in_atomic(), which means
> potentially __do_softirq may be interrupted by trap, exception,
> interrupt, etc, so seems softirq handler may be executed many times?
> 
> For example, if interrupt happens after i =
> find_first_set_bit(pending), the same softirq hander will be called
> twice as the do_softriq will be called after all interrupt handler
> returned, and the pending bit has not been cleared yet when first
> do_softirq was called.

Can't happen, we only call do_softirq() when returning from an interrupt
back to guest context. Therefore a nested interrupt call does not cause
do_softirq to run.

  -- Keir

> static void __do_softirq(unsigned long ignore_mask)
> {
>     ......
>     for ( ; ; )
>     {
>         ......
>         i = find_first_set_bit(pending);
>                                                    <- interrupt happens
>         clear_bit(i, &softirq_pending(cpu));
>         (*softirq_handlers[i])();
>     }
> }
> 
> -cody
> 
> _______________________________________________
> Xen-devel mailing list
> Xen-devel@lists.xensource.com
> http://lists.xensource.com/xen-devel

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

end of thread, other threads:[~2012-02-17  9:20 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-02-17  4:47 [question] will softirq handler potentially be called many times? Kai Huang
2012-02-17  9:20 ` Keir Fraser

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