datapath: Eliminate memset() from flow_extract.
authorJesse Gross <jesse@nicira.com>
Tue, 10 Jun 2014 01:00:18 +0000 (18:00 -0700)
committerJesse Gross <jesse@nicira.com>
Fri, 20 Jun 2014 01:33:27 +0000 (18:33 -0700)
commit9cef26ac6a71aa9cb02f1f515a2f6038e02ae9c7
tree3cfd1792a3b77c4117e73f109d9c0fcc60a3f271
parent6ddb63134def5509640e5b7713eea39095e1d17f
datapath: 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>
Acked-by: Thomas Graf <tgraf@suug.ch>
Acked-by: Pravin B Shelar <pshelar@nicira.com>
datapath/flow.c