LKML Archive mirror
 help / color / mirror / Atom feed
* Question about in_interrupt() semantics with regard to softirqs.
@ 2010-12-29 20:27 Justin Seyster
  2010-12-30  2:15 ` Yong Zhang
  0 siblings, 1 reply; 2+ messages in thread
From: Justin Seyster @ 2010-12-29 20:27 UTC (permalink / raw
  To: linux-kernel

I'm trying to understand the in_interrupt() function, and it seems
that it will return true for normal, non-interrupt code that disables
bottom half processing.  It looks like that behavior is intentional,
but I don't understand why it's designed that way.  I'm sorry if I'm
stating something obvious here; it would help me a lot if somebody
double checked my reasoning!

in_interrupt() checks a hardirq count and a softirq count, but I found
out that these two counts behave very differently.  The hardirq count
tracks the nesting depth of hardware interrupts (which is what I would
expect), but the softirq count behaves like the preempt count,
tracking whether softirqs are currently enabled.

So if normal code (executing on behalf of a user process) disables
softirqs with local_bh_disable(), it will get a true return value from
in_interrupt() until it finally reenables them.  But disabling
hardirqs will not have the same effect: the hardirq count is
unchanged, and in_interrupt() will still return false.

My question is: is there a design decision for this asymmetry between
hard and softirqs?  Also, is there a function that does what I really
wanted, which is to return true iff execution is actually in
bottom-half context?  Thanks!
        --Justin

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

* Re: Question about in_interrupt() semantics with regard to softirqs.
  2010-12-29 20:27 Question about in_interrupt() semantics with regard to softirqs Justin Seyster
@ 2010-12-30  2:15 ` Yong Zhang
  0 siblings, 0 replies; 2+ messages in thread
From: Yong Zhang @ 2010-12-30  2:15 UTC (permalink / raw
  To: Justin Seyster; +Cc: linux-kernel

On Thu, Dec 30, 2010 at 4:27 AM, Justin Seyster <jrseys@gmail.com> wrote:
> I'm trying to understand the in_interrupt() function, and it seems
> that it will return true for normal, non-interrupt code that disables
> bottom half processing.  It looks like that behavior is intentional,
> but I don't understand why it's designed that way.  I'm sorry if I'm
> stating something obvious here; it would help me a lot if somebody
> double checked my reasoning!
>
> in_interrupt() checks a hardirq count and a softirq count, but I found
> out that these two counts behave very differently.  The hardirq count
> tracks the nesting depth of hardware interrupts (which is what I would
> expect), but the softirq count behaves like the preempt count,
> tracking whether softirqs are currently enabled.
>
> So if normal code (executing on behalf of a user process) disables
> softirqs with local_bh_disable(), it will get a true return value from
> in_interrupt() until it finally reenables them.  But disabling
> hardirqs will not have the same effect: the hardirq count is
> unchanged, and in_interrupt() will still return false.
>
> My question is: is there a design decision for this asymmetry between
> hard and softirqs?  Also, is there a function that does what I really
> wanted, which is to return true iff execution is actually in
> bottom-half context?

For the function you want, you can take a look at commit:
75e1056f5c57050415b64cb761a3acc35d91f013

Thanks,
Yong

-- 
Only stand for myself

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

end of thread, other threads:[~2010-12-30  2:15 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-12-29 20:27 Question about in_interrupt() semantics with regard to softirqs Justin Seyster
2010-12-30  2:15 ` Yong Zhang

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 read-only IMAP folder(s) and NNTP newsgroup(s).