Commit 4ae5544f authored by Herbert Xu's avatar Herbert Xu Committed by David S. Miller

gro: Remember number of held packets instead of counting every time

This patch prepares for the move of the same_flow checks out of
dev_gro_receive.  As such we need to remember the number of held
packets since doing a loop just to count them every time is silly.
Signed-off-by: default avatarHerbert Xu <herbert@gondor.apana.org.au>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent d6301d3d
...@@ -314,6 +314,9 @@ struct napi_struct { ...@@ -314,6 +314,9 @@ struct napi_struct {
spinlock_t poll_lock; spinlock_t poll_lock;
int poll_owner; int poll_owner;
#endif #endif
unsigned int gro_count;
struct net_device *dev; struct net_device *dev;
struct list_head dev_list; struct list_head dev_list;
struct sk_buff *gro_list; struct sk_buff *gro_list;
......
...@@ -2372,6 +2372,7 @@ void napi_gro_flush(struct napi_struct *napi) ...@@ -2372,6 +2372,7 @@ void napi_gro_flush(struct napi_struct *napi)
napi_gro_complete(skb); napi_gro_complete(skb);
} }
napi->gro_count = 0;
napi->gro_list = NULL; napi->gro_list = NULL;
} }
EXPORT_SYMBOL(napi_gro_flush); EXPORT_SYMBOL(napi_gro_flush);
...@@ -2402,7 +2403,6 @@ int dev_gro_receive(struct napi_struct *napi, struct sk_buff *skb) ...@@ -2402,7 +2403,6 @@ int dev_gro_receive(struct napi_struct *napi, struct sk_buff *skb)
struct packet_type *ptype; struct packet_type *ptype;
__be16 type = skb->protocol; __be16 type = skb->protocol;
struct list_head *head = &ptype_base[ntohs(type) & PTYPE_HASH_MASK]; struct list_head *head = &ptype_base[ntohs(type) & PTYPE_HASH_MASK];
int count = 0;
int same_flow; int same_flow;
int mac_len; int mac_len;
int ret; int ret;
...@@ -2430,8 +2430,6 @@ int dev_gro_receive(struct napi_struct *napi, struct sk_buff *skb) ...@@ -2430,8 +2430,6 @@ int dev_gro_receive(struct napi_struct *napi, struct sk_buff *skb)
NAPI_GRO_CB(skb)->free = 0; NAPI_GRO_CB(skb)->free = 0;
for (p = napi->gro_list; p; p = p->next) { for (p = napi->gro_list; p; p = p->next) {
count++;
if (!NAPI_GRO_CB(p)->same_flow) if (!NAPI_GRO_CB(p)->same_flow)
continue; continue;
...@@ -2457,15 +2455,16 @@ int dev_gro_receive(struct napi_struct *napi, struct sk_buff *skb) ...@@ -2457,15 +2455,16 @@ int dev_gro_receive(struct napi_struct *napi, struct sk_buff *skb)
*pp = nskb->next; *pp = nskb->next;
nskb->next = NULL; nskb->next = NULL;
napi_gro_complete(nskb); napi_gro_complete(nskb);
count--; napi->gro_count--;
} }
if (same_flow) if (same_flow)
goto ok; goto ok;
if (NAPI_GRO_CB(skb)->flush || count >= MAX_GRO_SKBS) if (NAPI_GRO_CB(skb)->flush || napi->gro_count >= MAX_GRO_SKBS)
goto normal; goto normal;
napi->gro_count++;
NAPI_GRO_CB(skb)->count = 1; NAPI_GRO_CB(skb)->count = 1;
skb_shinfo(skb)->gso_size = skb_gro_len(skb); skb_shinfo(skb)->gso_size = skb_gro_len(skb);
skb->next = napi->gro_list; skb->next = napi->gro_list;
...@@ -2713,6 +2712,7 @@ void netif_napi_add(struct net_device *dev, struct napi_struct *napi, ...@@ -2713,6 +2712,7 @@ void netif_napi_add(struct net_device *dev, struct napi_struct *napi,
int (*poll)(struct napi_struct *, int), int weight) int (*poll)(struct napi_struct *, int), int weight)
{ {
INIT_LIST_HEAD(&napi->poll_list); INIT_LIST_HEAD(&napi->poll_list);
napi->gro_count = 0;
napi->gro_list = NULL; napi->gro_list = NULL;
napi->skb = NULL; napi->skb = NULL;
napi->poll = poll; napi->poll = poll;
...@@ -2741,6 +2741,7 @@ void netif_napi_del(struct napi_struct *napi) ...@@ -2741,6 +2741,7 @@ void netif_napi_del(struct napi_struct *napi)
} }
napi->gro_list = NULL; napi->gro_list = NULL;
napi->gro_count = 0;
} }
EXPORT_SYMBOL(netif_napi_del); EXPORT_SYMBOL(netif_napi_del);
...@@ -5246,6 +5247,7 @@ static int __init net_dev_init(void) ...@@ -5246,6 +5247,7 @@ static int __init net_dev_init(void)
queue->backlog.poll = process_backlog; queue->backlog.poll = process_backlog;
queue->backlog.weight = weight_p; queue->backlog.weight = weight_p;
queue->backlog.gro_list = NULL; queue->backlog.gro_list = NULL;
queue->backlog.gro_count = 0;
} }
dev_boot_phase = 0; dev_boot_phase = 0;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment