]> git.kernelconcepts.de Git - karo-tx-linux.git/commit
openvswitch: Eliminate memset() from flow_extract.
authorJesse Gross <jesse@nicira.com>
Fri, 3 Oct 2014 22:35:29 +0000 (15:35 -0700)
committerDavid S. Miller <davem@davemloft.net>
Mon, 6 Oct 2014 04:32:20 +0000 (00:32 -0400)
commit0714812134d7dcadeb7ecfbfeb18788aa7e1eaac
tree881bb28da2ca3882fd0a6a30574e98787d5feafb
parent0b5e8b8eeae40bae6ad7c7e91c97c3c0d0e57882
openvswitch: Eliminate memset() from flow_extract.

As new protocols are added, the size of the flow key tends to
increase although few protocols care about all of the fields. In
order to optimize this for hashing and matching, OVS uses a variable
length portion of the key. However, when fields are extracted from
the packet we must still zero out the entire key.

This is no longer necessary now that OVS implements masking. Any
fields (or holes in the structure) which are not part of a given
protocol will be by definition not part of the mask and zeroed out
during lookup. Furthermore, since masking already uses variable
length keys this zeroing operation automatically benefits as well.

In principle, the only thing that needs to be done at this point
is remove the memset() at the beginning of flow. However, some
fields assume that they are initialized to zero, which now must be
done explicitly. In addition, in the event of an error we must also
zero out corresponding fields to signal that there is no valid data
present. These increase the total amount of code but very little of
it is executed in non-error situations.

Removing the memset() reduces the profile of ovs_flow_extract()
from 0.64% to 0.56% when tested with large packets on a 10G link.

Suggested-by: Pravin Shelar <pshelar@nicira.com>
Signed-off-by: Jesse Gross <jesse@nicira.com>
Signed-off-by: Andy Zhou <azhou@nicira.com>
Acked-by: Pravin B Shelar <pshelar@nicira.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/openvswitch/flow.c