From patchwork Tue Sep 12 16:34:03 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Fischetti, Antonio" X-Patchwork-Id: 812963 X-Patchwork-Delegate: dlu998@gmail.com 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=) 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 3xs9P10thLz9s7g for ; Wed, 13 Sep 2017 02:34:28 +1000 (AEST) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id CD9B5900; Tue, 12 Sep 2017 16:34:25 +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 266F389E for ; Tue, 12 Sep 2017 16:34:24 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id 7DF00124 for ; Tue, 12 Sep 2017 16:34:23 +0000 (UTC) Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by orsmga102.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 12 Sep 2017 09:34:13 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.42,383,1500966000"; d="scan'208";a="310839044" Received: from sivswdev01.ir.intel.com (HELO localhost.localdomain) ([10.237.217.45]) by fmsmga004.fm.intel.com with ESMTP; 12 Sep 2017 09:34:10 -0700 From: antonio.fischetti@intel.com To: dev@openvswitch.org Date: Tue, 12 Sep 2017 17:34:03 +0100 Message-Id: <1505234043-13966-1-git-send-email-antonio.fischetti@intel.com> X-Mailer: git-send-email 1.7.0.7 X-Spam-Status: No, score=-5.0 required=5.0 tests=RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD autolearn=disabled version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on smtp1.linux-foundation.org Subject: [ovs-dev] [PATCH v5] dpif-netdev: Avoid reading RSS hash when EMC is disabled 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 When EMC is disabled the reading of RSS hash is skipped. Also, for packets that are not recirculated it retrieves the hash value without considering the recirc id. CC: Darrell Ball CC: Billy O Mahony Signed-off-by: Antonio Fischetti Acked-by: Billy O'Mahony --- V5 - Removed OVS_LIKELY when checking cur_min. - I see a performance improvement for P2P and PVP tescases when EMC is disabled, measurements are below. - I also tried different solutions, eg passing md_is_valid to dpif_netdev_packet_get_rss_hash - or even the recirc_id computed inside dp_execute_cb - as suggested by Billy but I didn't see any performance benefit. - Rebased on Commit id b9fedfa61f000f49500973d2a51e99a80d9cf9b8 - Each measurement was repeated 5 times and an average was computed. P2P testcase ------------ Flow setup: table=0, in_port=dpdk0 actions=output:dpdk1 table=0, in_port=dpdk1 actions=output:dpdk0 Mono-directional, 64B UDP packets. Traffic sent at line-rate. PMD threads: 2 Built with "-O2 -march=native -g" Measurements and average are in Mpps. Orig | 5 Measurments | Avg ---------+------------------------------------------+--------- With EMC | 11.39 11.37 11.46 11.35 11.39 | 11.39 no EMC | 8.23 8.22 8.26 8.20 8.22 | 8.23 + patch | 5 Measurments | Avg ---------+------------------------------------------+--------- With EMC | 11.46 11.39 11.40 11.45 11.38 | 11.42 no EMC | 8.42 8.41 8.37 8.43 8.37 | 8.40 PVP testcase ------------ Flow setup: table=0, in_port=dpdk0 actions=output:dpdkvhostuser0 table=0, in_port=dpdkvhostuser0 actions=output:dpdk0 table=0, in_port=dpdkvhostuser1 actions=output:dpdk1 table=0, in_port=dpdk1 actions=output:dpdkvhostuser1 Bi-directional, 64B UDP packets. Traffic sent at line-rate. PMD threads: 2 Built with "-O2 -march=native -g" Measurements and average are in Mpps. Orig | 5 Measurments | Avg ---------+------------------------------------------+--------- With EMC | 4.59 4.60 4.46 4.59 4.59 | 4.57 no EMC | 3.72 3.72 3.64 3.72 3.72 | 3.70 + patch | 5 Measurments | Avg ---------+------------------------------------------+--------- With EMC | 4.50 4.62 4.60 4.60 4.58 | 4.58 no EMC | 3.78 3.86 3.84 3.84 3.83 | 3.83 Recirculation testcase ---------------------- In a test setup with a firewall I didn't see any performance difference between the original and the patch. V4 - reworked to remove dependencies from other patches in patchset "Skip EMC for recirc pkts and other optimizations." https://mail.openvswitch.org/pipermail/ovs-dev/2017-August/337320.html - measurements were repeated with the latest head of master. --- lib/dpif-netdev.c | 32 ++++++++++++++++++++++++++++---- 1 file changed, 28 insertions(+), 4 deletions(-) diff --git a/lib/dpif-netdev.c b/lib/dpif-netdev.c index 0ceef9d..baf65e8 100644 --- a/lib/dpif-netdev.c +++ b/lib/dpif-netdev.c @@ -4765,6 +4765,22 @@ dp_netdev_upcall(struct dp_netdev_pmd_thread *pmd, struct dp_packet *packet_, } static inline uint32_t +dpif_netdev_packet_get_rss_hash_orig_pkt(struct dp_packet *packet, + const struct miniflow *mf) +{ + uint32_t hash; + + if (OVS_LIKELY(dp_packet_rss_valid(packet))) { + hash = dp_packet_get_rss_hash(packet); + } else { + hash = miniflow_hash_5tuple(mf, 0); + dp_packet_set_rss_hash(packet, hash); + } + + return hash; +} + +static inline uint32_t dpif_netdev_packet_get_rss_hash(struct dp_packet *packet, const struct miniflow *mf) { @@ -4899,10 +4915,18 @@ emc_processing(struct dp_netdev_pmd_thread *pmd, } miniflow_extract(packet, &key->mf); key->len = 0; /* Not computed yet. */ - key->hash = dpif_netdev_packet_get_rss_hash(packet, &key->mf); - - /* If EMC is disabled skip emc_lookup */ - flow = (cur_min == 0) ? NULL: emc_lookup(flow_cache, key); + /* If EMC is disabled skip hash computation and emc_lookup */ + if (cur_min) { + if (!md_is_valid) { + key->hash = dpif_netdev_packet_get_rss_hash_orig_pkt(packet, + &key->mf); + } else { + key->hash = dpif_netdev_packet_get_rss_hash(packet, &key->mf); + } + flow = emc_lookup(flow_cache, key); + } else { + flow = NULL; + } if (OVS_LIKELY(flow)) { dp_netdev_queue_batches(packet, flow, &key->mf, batches, n_batches);