mac80211: refine ieee80211_rx() context requirement
PATCH 1/1 mac80211: refine ieee80211_rx() context requirement
From: Wei Yang <[email protected]>
In case of RT kernel, the return value of softirq_count() always equal to 0, we need to use in_serving_softirq to decide whether the current context is in softirq context.
--- net/mac80211/rx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/mac80211/rx.c +1 -1
@@ -3226,7 +3226,7 @@ void ieee80211_rx(struct ieee80211_hw *hw, struct sk_buff *skb)struct ieee80211_supported_band *sband;struct ieee80211_rx_status *status =IEEE80211_SKB_RXCB (skb); -WARN_ON_ONCE (softirq_count () ==0 ); +WARN_ON_ONCE (!in_serving_softirq ());if (WARN_ON (status->band >=IEEE80211_NUM_BANDS )) goto drop;
Signature · 1 line
1.7.9.5
Johannes Berg
maintainernet/mac80211/rx.c void ieee80211_rx(struct ieee80211_hw *hw, struct sk_buff *skb) · line 3229
Quoted 8 lines · On Wed, 2013-05-08 at 16:31 +0800, [email protected] wrote:
From: Wei Yang <[email protected]>
In case of RT kernel, the return value of
softirq_count()always equal to 0, we need to usein_serving_softirqto decide whether the current context is in softirq context.net/mac80211/rx.c +1
-1-WARN_ON_ONCE (softirq_count () ==0 ); +WARN_ON_ONCE (!in_serving_softirq ());
As I understand the code, I don't believe this change to be correct. The function can happily run with softirqs disabled (e.g. local_bh_disable()), for example by being called via ieee80211_rx_ni(). As I understand in_serving_softirq(), it checks that it's actually inside handling a softirq, no?
johannes
Johannes Berg
maintainerQuoted 7 lines · Johannes Berg
Quoted 5 lines · On Wed, 2013-05-08 at 16:31 +0800, [email protected] wrote:
From: Wei Yang <[email protected]>
In case of RT kernel, the return value of
softirq_count()always equal to 0, we need to usein_serving_softirqto decide whether the current context is in softirq context.
Quoted 8 lines
net/mac80211/rx.c void ieee80211_rx(struct ieee80211_hw *hw, struct sk_buff *skb) · line 3229
Quoted 2 lines
net/mac80211/rx.c +1
-1-WARN_ON_ONCE (softirq_count () ==0 ); +WARN_ON_ONCE (!in_serving_softirq ());As I understand the code, I don't believe this change to be correct. The function can happily run with softirqs disabled (e.g.
local_bh_disable()), for example by being called viaieee80211_rx_ni(). As I understandin_serving_softirq(), it checks that it's actually inside handling a softirq, no?
Arguably, it should be
WARN_ON_ONCE(!in_softirq());
but that's equivalent:
include/linux/hardirq.h
* in_softirq - Are we currently processing softirq or have bh disabled?
#define in_softirq() (softirq_count())
johannes
Quoted 13 lines · Johannes Berg
net/mac80211/rx.c void ieee80211_rx(struct ieee80211_hw *hw, struct sk_buff *skb) · line 3229
Quoted 7 lines · On Wed, 2013-05-08 at 16:31 +0800, [email protected] wrote:
From: Wei Yang <[email protected]>
In case of RT kernel, the return value of
softirq_count()always equal to 0, we need to usein_serving_softirqto decide whether the current context is in softirq context.net/mac80211/rx.c +1
-1-WARN_ON_ONCE (softirq_count () ==0 ); +WARN_ON_ONCE (!in_serving_softirq ());As I understand the code, I don't believe this change to be correct. The function can happily run with softirqs disabled (e.g.
local_bh_disable()), for example by being called viaieee80211_rx_ni(). As I understandin_serving_softirq(), it checks that it's actually inside handling a softirq, no?
Yes, I am not an expert on wireless, so I am not sure whether ieee80211_rx will be called with softirqs disabled. Just as you said, if it can run with softirqs diabled, the fix is not correct. sorry for it.
Thanks
Wei
Quoted 5 lines
johannes
Quoted 14 lines · Johannes Berg
Quoted 13 lines · Johannes Berg
net/mac80211/rx.c void ieee80211_rx(struct ieee80211_hw *hw, struct sk_buff *skb) · line 3229
Quoted 7 lines · On Wed, 2013-05-08 at 16:31 +0800, [email protected] wrote:
From: Wei Yang <[email protected]>
In case of RT kernel, the return value of
softirq_count()always equal to 0, we need to usein_serving_softirqto decide whether the current context is in softirq context.net/mac80211/rx.c +1
-1-WARN_ON_ONCE (softirq_count () ==0 ); +WARN_ON_ONCE (!in_serving_softirq ());As I understand the code, I don't believe this change to be correct. The function can happily run with softirqs disabled (e.g.
local_bh_disable()), for example by being called viaieee80211_rx_ni(). As I understandin_serving_softirq(), it checks that it's actually inside handling a softirq, no?
Quoted 4 lines
Arguably, it should be
WARN_ON_ONCE(!in_softirq());but that's equivalent:
Yeah, but the softirq is threaded in rt kernel, the softirq_count always return 0. The warning should always happen with rt kernel.
Wei
Quoted 11 lines
include/linux/hardirq.h*
in_softirq- Are we currently processing softirq or have bh disabled?#define in_softirq() (softirq_count())johannes
Johannes Berg
maintainerQuoted 15 lines · On Wed, 2013-05-08 at 16:47 +0800, wyang1 wrote:
Quoted 14 lines · Johannes Berg
Quoted 13 lines · Johannes Berg
net/mac80211/rx.c void ieee80211_rx(struct ieee80211_hw *hw, struct sk_buff *skb) · line 3229
Quoted 7 lines · On Wed, 2013-05-08 at 16:31 +0800, [email protected] wrote:
From: Wei Yang <[email protected]>
In case of RT kernel, the return value of
softirq_count()always equal to 0, we need to usein_serving_softirqto decide whether the current context is in softirq context.net/mac80211/rx.c +1
-1-WARN_ON_ONCE (softirq_count () ==0 ); +WARN_ON_ONCE (!in_serving_softirq ());As I understand the code, I don't believe this change to be correct. The function can happily run with softirqs disabled (e.g.
local_bh_disable()), for example by being called viaieee80211_rx_ni(). As I understandin_serving_softirq(), it checks that it's actually inside handling a softirq, no?
Quoted 7 lines
Quoted 4 lines
Arguably, it should be
WARN_ON_ONCE(!in_softirq());but that's equivalent:
Yeah, but the softirq is threaded in rt kernel, the
softirq_countalways return 0. The warning should always happen with rt kernel.
So maybe then the RT kernel defines in_softirq() appropriately and you should submit a patch to change to using that? I find it hard to believe that the RT kernel breaks _all_ the softirq APIs, but hey, I know nothing about RT :-)
johannes