Subject: Re: [PATCH] pkt_sched: Control group classifier

From: Thomas Graf <[email-masked]>
Date: Fri, 17 Oct 2008 22:09:16 +0200

* Andi Kleen <[email-masked]> 2008-10-17 20:32
> > softirq_count() simply counts the levels of bh disable.
> 
> softirqs always have bh disabled.  So it's always true inside them.
> And you should know what _bh locks you hold.

I actually tried "softirq_count() == SOFTIRQ_OFFSET" to see if the
call is made form user context. It works pretty well because all
callers of dev_queue_xmit() are required to disable bh. Nevertheless
I think it's quite fragile. If a dev_queue_xmit() caller from softirq
does not disable bh explicitely on its own but instead relies on
do_softirq() to have disabled bh already, the softirq count of such
a call may be equal to the one of a user context call to dev_queue_xmit().

I found explicitely counting softirq_enter() to be more reliable
without having much of a performance impact. I'm happy with both
solutions though.