mac80211: make ieee80211_get_hdrlen_from_skb return unsigned
PATCH 4/7 mac80211: make ieee80211_get_hdrlen_from_skb return unsigned
Many callers already expect it to.
--- include/net/mac80211.h | 2 +- net/mac80211/util.c | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-)
include/net/mac80211.h +1 -1
@@ -1535,7 +1535,7 @@ ieee80211_get_buffered_bc(struct ieee80211_hw *hw, struct ieee80211_vif *vif);* * @skb: the frame */ -int ieee80211_get_hdrlen_from_skb (const struct sk_buff *skb); +unsigned int ieee80211_get_hdrlen_from_skb (const struct sk_buff *skb);/** * ieee80211_get_hdrlen - get header length from frame control
net/mac80211/util.c +5 -5
@@ -165,15 +165,15 @@ out: }EXPORT_SYMBOL (ieee80211_hdrlen); -int ieee80211_get_hdrlen_from_skb (const struct sk_buff *skb) +unsigned int ieee80211_get_hdrlen_from_skb (const struct sk_buff *skb) {const struct ieee80211_hdr *hdr = (const struct ieee80211_hdr *) skb->data; -int hdrlen; +unsigned int hdrlen; -if (unlikely (skb->len <10 )) +if (skb->len <10 )return 0 ; - hdrlen =ieee80211_get_hdrlen (le16_to_cpu (hdr->frame_control)); -if (unlikely (hdrlen > skb->len)) + hdrlen =ieee80211_hdrlen (hdr->frame_control); +if (hdrlen > skb->len)return 0 ;return hdrlen; }
Signature · 1 line
1.5.6.rc1.257.gba91d
Quoted 28 lines · On Friday 06 June 2008 19:51:12 Harvey Harrison wrote:
Many callers already expect it to.
Signed-off-by Harvey Harrison <[email protected]>--- include/net/mac80211.h | 2 +- net/mac80211/util.c | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-)include/net/mac80211.h +1
-1@@ -1535,7 +1535,7 @@ ieee80211_get_buffered_bc(struct ieee80211_hw *hw, struct ieee80211_vif *vif);* * @skb: the frame */ -int ieee80211_get_hdrlen_from_skb (const struct sk_buff *skb); +unsigned int ieee80211_get_hdrlen_from_skb (const struct sk_buff *skb);/** * ieee80211_get_hdrlen - get header length from frame control net/mac80211/util.c +0
-0@@ -165,15 +165,15 @@ out: }EXPORT_SYMBOL (ieee80211_hdrlen);
net/mac80211/util.c out: · line 173
Quoted 10 lines
net/mac80211/util.c +3
-3-int ieee80211_get_hdrlen_from_skb (const struct sk_buff *skb) +unsigned int ieee80211_get_hdrlen_from_skb (const struct sk_buff *skb) {const struct ieee80211_hdr *hdr = (const struct ieee80211_hdr *) skb->data; -int hdrlen; +unsigned int hdrlen; -if (unlikely (skb->len <10 )) +if (skb->len <10 )
Why are you removing the unlikely()? This should actually be pretty unlikely. Sane firmware will drop short packets, so the kernel won't ever see them.
net/mac80211/util.c out: · line 176
Quoted 5 lines
net/mac80211/util.c +2
-2return 0 ; - hdrlen =ieee80211_get_hdrlen (le16_to_cpu (hdr->frame_control)); -if (unlikely (hdrlen > skb->len)) + hdrlen =ieee80211_hdrlen (hdr->frame_control); +if (hdrlen > skb->len)
I think this also is unlikely, as it can only come from corrupted packets.
Quoted 3 lines
net/mac80211/util.c +0
-0return 0 ;return hdrlen; }
Signature · 1 line
Greetings Michael.
Quoted 8 lines · Michael Buesch
Quoted 7 lines · On Friday 06 June 2008 19:51:12 Harvey Harrison wrote:
net/mac80211/util.c +2
-2-int ieee80211_get_hdrlen_from_skb (const struct sk_buff *skb) +unsigned int ieee80211_get_hdrlen_from_skb (const struct sk_buff *skb) {const struct ieee80211_hdr *hdr = (const struct ieee80211_hdr *) skb->data; -int hdrlen; +unsigned int hdrlen;
Quoted 6 lines
net/mac80211/util.c out: · line 173
Quoted 2 lines
net/mac80211/util.c +1
-1-if (unlikely (skb->len <10 )) +if (skb->len <10 )Why are you removing the
unlikely()? This should actually be pretty unlikely. Sane firmware will drop short packets, so the kernel won't ever see them.
When all that is in the if-block is a return, there's not much point. It's a trivial test/return and gcc does a fine job with this.
Quoted 8 lines
net/mac80211/util.c out: · line 176
Quoted 5 lines
net/mac80211/util.c +2
-2return 0 ; - hdrlen =ieee80211_get_hdrlen (le16_to_cpu (hdr->frame_control)); -if (unlikely (hdrlen > skb->len)) + hdrlen =ieee80211_hdrlen (hdr->frame_control); +if (hdrlen > skb->len)I think this also is unlikely, as it can only come from corrupted packets.
unlikely() isn't some magic make-me-faster function, it just moves code to the end of the function to get it out of the icache and jumps to it in the unlikely case it is taken. When all there is is a return, I don't think it even makes any difference. In both these cases a comment is probably more appropriate.
Harvey
Quoted 1 line · Harvey Harrison
unlikely()isn't some magic make-me-faster function, it just moves co=
de
Quoted 1 line
to the end of the function to get it out of the icache and jumps to i=
t
Quoted 2 lines
in the unlikely case it is taken. When all there is is a return, I don't think it even makes any difference. In both these cases a comm=
ent
Quoted 1 line
is probably more appropriate.
If we don't more return to the end, we get something like:
compare skb->len to 10
if more or equal goto 1
return
1: <the likely case>
=EF=BB=BFI don't know much about modern processor design, but I remembe= r reading
that even a very short jump would flush the instruction pipeline and cause some delay.
I would keep unlikely() and let the compiler think what to do with it.
--=20
Regards,
Pavel Roskin
--
To unsubscribe from this list: send the line "unsubscribe linux-wireles= s" in
the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Quoted 3 lines · Pavel Roskin
On Fri, 2008-06-06 at 11:47 -0700, Harvey Harrison wrote:
=20Quoted 1 line
unlikely()isn't some magic make-me-faster function, it just moves =
code
Quoted 1 line
Quoted 1 line
to the end of the function to get it out of the icache and jumps to=
it
Quoted 2 lines
Quoted 2 lines
in the unlikely case it is taken. When all there is is a return, I don't think it even makes any difference. In both these cases a co=
mment
Quoted 10 lines
Quoted 1 line
is probably more appropriate.
=20
If we don't more return to the end, we get something like:
=20
compareskb->lento 10
if more or equal goto 1
return
1: <the likely case>
=20
=EF=BB=BFI don't know much about modern processor design, but I remem=
ber reading
Quoted 4 lines
that even a very short jump would flush the instruction pipeline and cause some delay.
=20
I would keepunlikely()and let the compiler think what to do with it=
=2E
Quoted 1 line
=20
On X86-32 at least the generated code is exactly the same with or without the unlikely()s. I'll put them back in a follow-on if people are really attached to them.
Harvey
--
To unsubscribe from this list: send the line "unsubscribe linux-wireles= s" in
the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Johannes Berg
maintainerQuoted 8 lines
unlikely()isn't some magic make-me-faster function, it just moves code
to the end of the function to get it out of the icache and jumps to it in the unlikely case it is taken. When all there is is a return, I don't think it even makes any difference. In both these cases a comment
is probably more appropriate.
That's not true on ppc where you can actually tell the processor about the jump likelyhood for its branch prediction.
Quoted 3 lines
On X86-32 at least the generated code is exactly the same with or without the unlikely()s. I'll put them back in a follow-on if people are really attached to them.
Please keep them there, I think they make sense for normal operation.
johannes
Quoted 10 lines · Johannes Berg
Quoted 7 lines
unlikely()isn't some magic make-me-faster function, it just moves code
to the end of the function to get it out of the icache and jumps to it in the unlikely case it is taken. When all there is is a return, I don't think it even makes any difference. In both these cases a comment
is probably more appropriate.That's not true on ppc where you can actually tell the processor about the jump likelyhood for its branch prediction.
I was unaware of that.
Quoted 6 lines
Quoted 4 lines
On X86-32 at least the generated code is exactly the same with or without the unlikely()s. I'll put them back in a follow-on if people are really attached to them.
Please keep them there, I think they make sense for normal operation.
Kept, will be in a v2.
Harvey