* [PATCH net-next] gro: small napi_get_frags() optim
@ 2013-12-06 5:44 Eric Dumazet
2013-12-06 6:11 ` Joe Perches
2013-12-06 17:52 ` David Miller
0 siblings, 2 replies; 4+ messages in thread
From: Eric Dumazet @ 2013-12-06 5:44 UTC (permalink / raw)
To: David Miller; +Cc: netdev
From: Eric Dumazet <edumazet@google.com>
Remove one useless conditional branch :
napi->skb is NULL, so nothing bad can happen.
Signed-off-by: Eric Dumazet <edumazet@google.com>
---
net/core/dev.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/net/core/dev.c b/net/core/dev.c
index ba3b7ea5ebb3..c98052487e98 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -3981,8 +3981,7 @@ struct sk_buff *napi_get_frags(struct napi_struct *napi)
if (!skb) {
skb = netdev_alloc_skb_ip_align(napi->dev, GRO_MAX_HEAD);
- if (skb)
- napi->skb = skb;
+ napi->skb = skb;
}
return skb;
}
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH net-next] gro: small napi_get_frags() optim
2013-12-06 5:44 [PATCH net-next] gro: small napi_get_frags() optim Eric Dumazet
@ 2013-12-06 6:11 ` Joe Perches
2013-12-06 6:26 ` Eric Dumazet
2013-12-06 17:52 ` David Miller
1 sibling, 1 reply; 4+ messages in thread
From: Joe Perches @ 2013-12-06 6:11 UTC (permalink / raw)
To: Eric Dumazet; +Cc: David Miller, netdev
On Thu, 2013-12-05 at 21:44 -0800, Eric Dumazet wrote:
> Remove one useless conditional branch :
> napi->skb is NULL, so nothing bad can happen.
[]
> diff --git a/net/core/dev.c b/net/core/dev.c
[]
> @@ -3981,8 +3981,7 @@ struct sk_buff *napi_get_frags(struct napi_struct *napi)
>
> if (!skb) {
> skb = netdev_alloc_skb_ip_align(napi->dev, GRO_MAX_HEAD);
> - if (skb)
> - napi->skb = skb;
> + napi->skb = skb;
Thanks, I agree this patch is appropriate as skb is unlikely
to be NULL in normal cases.
But just for thought: isn't the test expense essentially
free when skb is in a register vs the member set cost?
Also, netdev_alloc_skb_ip_align is static inline and it has
a test of
if (NET_IP_ALIGN && skb)
just before the return so this "if (skb)" test could already
be elided by a good compiler but this change requires an
unconditional set.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH net-next] gro: small napi_get_frags() optim
2013-12-06 6:11 ` Joe Perches
@ 2013-12-06 6:26 ` Eric Dumazet
0 siblings, 0 replies; 4+ messages in thread
From: Eric Dumazet @ 2013-12-06 6:26 UTC (permalink / raw)
To: Joe Perches; +Cc: David Miller, netdev
On Thu, 2013-12-05 at 22:11 -0800, Joe Perches wrote:
> Thanks, I agree this patch is appropriate as skb is unlikely
> to be NULL in normal cases.
We do not care if skb is NULL or not.
>
> But just for thought: isn't the test expense essentially
> free when skb is in a register vs the member set cost?
>
Test is not 'free', even if predicted.
Study the generated assembly code if you are interested, you'll see this
makes a difference.
> Also, netdev_alloc_skb_ip_align is static inline and it has
> a test of
> if (NET_IP_ALIGN && skb)
> just before the return so this "if (skb)" test could already
> be elided by a good compiler but this change requires an
> unconditional set.
NET_IP_ALIGN is 0 on x86, even a 'bad' compiler zaps the whole thing.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH net-next] gro: small napi_get_frags() optim
2013-12-06 5:44 [PATCH net-next] gro: small napi_get_frags() optim Eric Dumazet
2013-12-06 6:11 ` Joe Perches
@ 2013-12-06 17:52 ` David Miller
1 sibling, 0 replies; 4+ messages in thread
From: David Miller @ 2013-12-06 17:52 UTC (permalink / raw)
To: eric.dumazet; +Cc: netdev
From: Eric Dumazet <eric.dumazet@gmail.com>
Date: Thu, 05 Dec 2013 21:44:27 -0800
> From: Eric Dumazet <edumazet@google.com>
>
> Remove one useless conditional branch :
> napi->skb is NULL, so nothing bad can happen.
>
> Signed-off-by: Eric Dumazet <edumazet@google.com>
Applied.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2013-12-06 17:52 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-12-06 5:44 [PATCH net-next] gro: small napi_get_frags() optim Eric Dumazet
2013-12-06 6:11 ` Joe Perches
2013-12-06 6:26 ` Eric Dumazet
2013-12-06 17:52 ` David Miller
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).