OSDN Git Service

net: gro: minor optimization for dev_gro_receive()
authorPaolo Abeni <pabeni@redhat.com>
Fri, 4 Feb 2022 11:28:37 +0000 (12:28 +0100)
committerDavid S. Miller <davem@davemloft.net>
Sat, 5 Feb 2022 15:13:52 +0000 (15:13 +0000)
commitde5a1f3ce4c862150dc442530dba19e1d1dc6bc2
treee17d79dcb5e9da6ab7fa80a4e506c1437415648b
parent7881453e4adf497cf9109c84fa21eedda9ac6164
net: gro: minor optimization for dev_gro_receive()

While inspecting some perf report, I noticed that the compiler
emits suboptimal code for the napi CB initialization, fetching
and storing multiple times the memory for flags bitfield.
This is with gcc 10.3.1, but I observed the same with older compiler
versions.

We can help the compiler to do a nicer work clearing several
fields at once using an u32 alias. The generated code is quite
smaller, with the same number of conditional.

Before:
objdump -t net/core/gro.o | grep " F .text"
0000000000000bb0 l     F .text 0000000000000357 dev_gro_receive

After:
0000000000000bb0 l     F .text 000000000000033c dev_gro_receive

v1  -> v2:
 - use struct_group (Alexander and Alex)

RFC -> v1:
 - use __struct_group to delimit the zeroed area (Alexander)

Signed-off-by: Paolo Abeni <pabeni@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
include/net/gro.h
net/core/gro.c