[ovs-dev,v2] flow: save "vlan_hdrs" memset for untagged traffic
diff mbox series

Message ID 1566468590-21288-1-git-send-email-Yanqin.Wei@arm.com
State New
Headers show
Series
  • [ovs-dev,v2] flow: save "vlan_hdrs" memset for untagged traffic
Related show

Commit Message

Yanqin Wei Aug. 22, 2019, 10:09 a.m. UTC
For untagged traffic, it is unnecessary to clear vlan_hdrs as it costs 32B
memset. So the patch improves it by postponing to clear vlan_hdrs until
ethtype check. It can benefit both untagged and single-tagged traffic. From
testing, it does not impact performance of dual-tagged traffic.

Reviewed-by: Gavin Hu <Gavin.Hu@arm.com>
Signed-off-by: Yanqin Wei <Yanqin.Wei@arm.com>
---
 lib/flow.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Ben Pfaff Aug. 28, 2019, 9:47 p.m. UTC | #1
On Thu, Aug 22, 2019 at 06:09:50PM +0800, Yanqin Wei wrote:
> For untagged traffic, it is unnecessary to clear vlan_hdrs as it costs 32B
> memset. So the patch improves it by postponing to clear vlan_hdrs until
> ethtype check. It can benefit both untagged and single-tagged traffic. From
> testing, it does not impact performance of dual-tagged traffic.
> 
> Reviewed-by: Gavin Hu <Gavin.Hu@arm.com>
> Signed-off-by: Yanqin Wei <Yanqin.Wei@arm.com>

Thanks, applied to master.

Patch
diff mbox series

diff --git a/lib/flow.c b/lib/flow.c
index 1b21f51..4d895e5 100644
--- a/lib/flow.c
+++ b/lib/flow.c
@@ -343,7 +343,6 @@  parse_vlan(const void **datap, size_t *sizep, union flow_vlan_hdr *vlan_hdrs)
 {
     const ovs_be16 *eth_type;
 
-    memset(vlan_hdrs, 0, sizeof(union flow_vlan_hdr) * FLOW_MAX_VLAN_HEADERS);
     data_pull(datap, sizep, ETH_ADDR_LEN * 2);
 
     eth_type = *datap;
@@ -354,6 +353,7 @@  parse_vlan(const void **datap, size_t *sizep, union flow_vlan_hdr *vlan_hdrs)
             break;
         }
 
+        memset(vlan_hdrs + n, 0, sizeof(union flow_vlan_hdr));
         const ovs_16aligned_be32 *qp = data_pull(datap, sizep, sizeof *qp);
         vlan_hdrs[n].qtag = get_16aligned_be32(qp);
         vlan_hdrs[n].tci |= htons(VLAN_CFI);