From patchwork Fri Aug 11 15:52:43 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Fischetti, Antonio" X-Patchwork-Id: 800624 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 3xTV0W5JFTz9t2h for ; Sat, 12 Aug 2017 01:53:31 +1000 (AEST) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id 4DA2AB1F; Fri, 11 Aug 2017 15:52:52 +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 652D18E3 for ; Fri, 11 Aug 2017 15:52:49 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id 5287115C for ; Fri, 11 Aug 2017 15:52:49 +0000 (UTC) Received: from orsmga003.jf.intel.com ([10.7.209.27]) by orsmga101.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 11 Aug 2017 08:52:48 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos; i="5.41,358,1498546800"; d="scan'208"; a="1002648541" Received: from sivswdev01.ir.intel.com (HELO localhost.localdomain) ([10.237.217.45]) by orsmga003.jf.intel.com with ESMTP; 11 Aug 2017 08:52:47 -0700 From: antonio.fischetti@intel.com To: dev@openvswitch.org Date: Fri, 11 Aug 2017 16:52:43 +0100 Message-Id: <1502466766-17370-2-git-send-email-antonio.fischetti@intel.com> X-Mailer: git-send-email 1.7.0.7 In-Reply-To: <1502466766-17370-1-git-send-email-antonio.fischetti@intel.com> References: <1502466766-17370-1-git-send-email-antonio.fischetti@intel.com> Subject: [ovs-dev] [PATCH v3 1/4] dpif-netdev: Skip EMC lookup/insert for recirc packets 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 OVS is configured as a firewall, with thousands of active concurrent connections, the EMC gets quicly saturated and may come under heavy thrashing for the reason that original and recirculated packets keep overwriting the existing active EMC entries due to its limited size (8k). This thrashing causes the EMC to be less efficient than the dcpls in terms of lookups and insertions. This patch allows to use the EMC efficiently by allowing only the 'original' packets to hit EMC. All recirculated packets are sent to the classifier directly. An empirical threshold EMC_RECIRCT_NO_INSERT_THRESHOLD - of 50% - for EMC occupancy is set to trigger this logic. By doing so when EMC utilization exceeds EMC_RECIRCT_NO_INSERT_THRESHOLD: - EMC Insertions are allowed just for original packets. EMC insertion and look up are skipped for recirculated packets. - Recirculated packets are sent to the classifier. This patch is based on patch "dpif-netdev: add EMC entry count and %full figure to pmd-stats-show" at: https://mail.openvswitch.org/pipermail/ovs-dev/2017-January/327570.html CC: Jan Scheurich Signed-off-by: Antonio Fischetti Signed-off-by: Bhanuprakash Bodireddy Co-authored-by: Bhanuprakash Bodireddy --- Connection Tracker testbench set up with table=0, priority=1 actions=drop table=0, priority=10,arp actions=NORMAL table=0, priority=100,ct_state=-trk,ip actions=ct(table=1) table=1, ct_state=+new+trk,ip,in_port=1 actions=ct(commit),output:2 table=1, ct_state=+est+trk,ip,in_port=1 actions=output:2 table=1, ct_state=+new+trk,ip,in_port=2 actions=drop table=1, ct_state=+est+trk,ip,in_port=2 actions=output:1 2 PMDs, 3 Tx queues. I measured packet Rx rate (regardless of packet loss). Bidirectional test with 64B UDP packets. Each row is a test with a different number of traffic streams. The traffic generator is set so that each stream establishes one UDP connection. Mpps columns reports the Rx rates on the 2 sides. I set up the generator to loop on the dest IP addr on one side, and loop instead on the source IP addr on the other side. For example to generate 10 different flows, I was sending to phy port #1 UDP, IPsrc:10.10.10.10, IPdest: 20.20.20.[20-29], PortSrc: 63, PortDest: 63 Instead to phy port #2 (source and dest IPs are now swapped): UDP, IPsrc: 20.20.20.[20-29], IPdest: 10.10.10.10, PortSrc: 63, PortDest: 63 I saw the following performance improvement. Original OvS-DPDK means at Commit ID: 6b1babacc3ca0488e07596bf822fe356c9bab646 +----------------------+-----------------------+ | Original OvS-DPDK | Original OvS-DPDK | | | + this patch | ---------+------------+---------+------------+----------+ Traffic | Rx | EMC | Rx | EMC | Streams | [Mpps] | entries | [Mpps] | entries | ---------+------------+---------+------------+----------+ 100 | 2.43, 2.49 | 200 | 2.55, 2.57 | 201 | 1,000 | 2.01, 2.02 | 2007 | 2.12, 2.12 | 2006 | 2,000 | 1.93, 1.95 | 3868 | 1.98, 1.96 | 3884 | 3,000 | 1.87, 1.91 | 5086 | 1.97, 1.97 | 4757 | 4,000 | 1.83, 1.82 | 6173 | 1.94, 1.93 | 5280 | 10,000 | 1.67, 1.69 | 7826 | 1.82, 1.81 | 7090 | 30,000 | 1.57, 1.59 | 8192 | 1.66, 1.67 | 8192 | ---------+------------+---------+------------+----------+ This test setup implies 1 recirculation on each received packet. We didn't check this patch in a test scenario where more than 1 recirculation is occurring per packet. --- lib/dpif-netdev.c | 65 +++++++++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 61 insertions(+), 4 deletions(-) diff --git a/lib/dpif-netdev.c b/lib/dpif-netdev.c index bea1c3f..8f6b96b 100644 --- a/lib/dpif-netdev.c +++ b/lib/dpif-netdev.c @@ -4663,6 +4663,9 @@ dp_netdev_queue_batches(struct dp_packet *pkt, packet_batch_per_flow_update(batch, pkt, mf); } +/* Threshold to skip EMC for recirculated packets. */ +#define EMC_RECIRCT_NO_INSERT_THRESHOLD 0xFFFFF000 + /* Try to process all ('cnt') the 'packets' using only the exact match cache * 'pmd->flow_cache'. If a flow is not found for a packet 'packets[i]', the * miniflow is copied into 'keys' and the packet pointer is moved at the @@ -4714,8 +4717,36 @@ emc_processing(struct dp_netdev_pmd_thread *pmd, 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); + /* + * EMC lookup is skipped when one or both of the following + * two cases occurs: + * + * - EMC is disabled. This is detected from cur_min. + * + * - The EMC occupancy exceeds EMC_RECIRCT_NO_INSERT_THRESHOLD and + * the packet to be classified is being recirculated. When this + * happens also EMC insertions are skipped for recirculated + * packets. So that EMC is used just to store entries which + * are hit from the 'original' packets. This way the EMC + * thrashing is mitigated with a benefit on performance. + */ + if (OVS_LIKELY(cur_min)) { + if (!md_is_valid) { + flow = emc_lookup(flow_cache, key); + } else { + /* Recirculated packet. */ + if (flow_cache->n_entries & EMC_RECIRCT_NO_INSERT_THRESHOLD) { + /* EMC occupancy is over the threshold. We skip EMC + * lookup for recirculated packets. */ + flow = NULL; + } else { + flow = emc_lookup(flow_cache, key); + } + } + } else { + flow = NULL; + } + if (OVS_LIKELY(flow)) { dp_netdev_queue_batches(packet, flow, &key->mf, batches, n_batches); @@ -4800,7 +4831,20 @@ handle_packet_upcall(struct dp_netdev_pmd_thread *pmd, add_actions->size); } ovs_mutex_unlock(&pmd->flow_mutex); - emc_probabilistic_insert(pmd, key, netdev_flow); + /* EMC insertion can be skipped by a probabilistic criteria or + * - in case of recirculated packets - depending on the number of + * EMC entries. */ + if (!packet->md.recirc_id) { + emc_probabilistic_insert(pmd, key, netdev_flow); + } else { + /* Recirculated packets. When EMC occupancy goes over + * a threshold we avoid inserting new entries. */ + if (!(pmd->flow_cache.n_entries & + EMC_RECIRCT_NO_INSERT_THRESHOLD)) { + /* Still under the threshold. */ + emc_probabilistic_insert(pmd, key, netdev_flow); + } + } } } @@ -4893,7 +4937,20 @@ fast_path_processing(struct dp_netdev_pmd_thread *pmd, flow = dp_netdev_flow_cast(rules[i]); - emc_probabilistic_insert(pmd, &keys[i], flow); + /* EMC insertion can be skipped by a probabilistic criteria or + * - in case of recirculated packets - depending on the number of + * EMC entries. */ + if (!packet->md.recirc_id) { + emc_probabilistic_insert(pmd, &keys[i], flow); + } else { + /* Recirculated packets. When EMC occupancy goes over + * a threshold we avoid inserting new entries. */ + if (!(pmd->flow_cache.n_entries & + EMC_RECIRCT_NO_INSERT_THRESHOLD)) { + /* Still under the threshold. */ + emc_probabilistic_insert(pmd, &keys[i], flow); + } + } dp_netdev_queue_batches(packet, flow, &keys[i].mf, batches, n_batches); }