From patchwork Thu Aug 22 09:30:28 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yanqin Wei X-Patchwork-Id: 1151404 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=openvswitch.org (client-ip=140.211.169.12; helo=mail.linuxfoundation.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=arm.com Received: from mail.linuxfoundation.org (mail.linuxfoundation.org [140.211.169.12]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 46DfRm6q5Xz9sN4 for ; Thu, 22 Aug 2019 19:31:32 +1000 (AEST) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id 37515105B; Thu, 22 Aug 2019 09:30:40 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@mail.linuxfoundation.org Received: from smtp1.linuxfoundation.org (smtp1.linux-foundation.org [172.17.192.35]) by mail.linuxfoundation.org (Postfix) with ESMTPS id 5E1B7103E for ; Thu, 22 Aug 2019 09:30:39 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp1.linuxfoundation.org (Postfix) with ESMTP id 3E1AD8A2 for ; Thu, 22 Aug 2019 09:30:38 +0000 (UTC) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id BDB521596; Thu, 22 Aug 2019 02:30:37 -0700 (PDT) Received: from net-arm-thunderx2-01.test.ast.arm.com (net-arm-thunderx2-01.shanghai.arm.com [10.169.40.40]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 5CD1A3F246; Thu, 22 Aug 2019 02:30:36 -0700 (PDT) From: Yanqin Wei To: dev@openvswitch.org Date: Thu, 22 Aug 2019 17:30:28 +0800 Message-Id: <1566466228-45378-1-git-send-email-Yanqin.Wei@arm.com> X-Mailer: git-send-email 2.7.4 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on smtp1.linux-foundation.org Cc: nd@arm.com, Gavin.Hu@arm.com Subject: [ovs-dev] [PATCH v1 ] flow: save "vlan_hdrs" memset for untagged traffic X-BeenThere: ovs-dev@openvswitch.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: ovs-dev-bounces@openvswitch.org Errors-To: ovs-dev-bounces@openvswitch.org 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. Change-Id: I6d503c904d0354c94882196d7720a574b2d07e44 Reviewed-by: Gavin Hu Signed-off-by: Yanqin Wei --- lib/flow.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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);