Skip to content

Commit

Permalink
net-gro: use ffs() to speedup napi_gro_flush()
Browse files Browse the repository at this point in the history
We very often have few flows/chains to look at, and we
might increase GRO_HASH_BUCKETS to 32 or 64 in the future.

Signed-off-by: Eric Dumazet <edumazet@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Eric Dumazet authored and David S. Miller committed Nov 23, 2018
1 parent d72ff4b commit 42519ed
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions net/core/dev.c
Original file line number Diff line number Diff line change
Expand Up @@ -5364,11 +5364,13 @@ static void __napi_gro_flush_chain(struct napi_struct *napi, u32 index,
*/
void napi_gro_flush(struct napi_struct *napi, bool flush_old)
{
u32 i;
unsigned long bitmask = napi->gro_bitmask;
unsigned int i, base = ~0U;

for (i = 0; i < GRO_HASH_BUCKETS; i++) {
if (test_bit(i, &napi->gro_bitmask))
__napi_gro_flush_chain(napi, i, flush_old);
while ((i = ffs(bitmask)) != 0) {
bitmask >>= i;
base += i;
__napi_gro_flush_chain(napi, base, flush_old);
}
}
EXPORT_SYMBOL(napi_gro_flush);
Expand Down

0 comments on commit 42519ed

Please sign in to comment.