From patchwork Wed Oct 5 01:22:16 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniele Di Proietto X-Patchwork-Id: 678332 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from archives.nicira.com (archives.nicira.com [96.126.127.54]) by ozlabs.org (Postfix) with ESMTP id 3spdMf2k8pz9ryZ for ; Wed, 5 Oct 2016 12:23:26 +1100 (AEDT) Received: from archives.nicira.com (localhost [127.0.0.1]) by archives.nicira.com (Postfix) with ESMTP id 28B46106A3; Tue, 4 Oct 2016 18:23:01 -0700 (PDT) X-Original-To: dev@openvswitch.org Delivered-To: dev@openvswitch.org Received: from mx3v3.cudamail.com (mx3.cudamail.com [64.34.241.5]) by archives.nicira.com (Postfix) with ESMTPS id C7C5010694 for ; Tue, 4 Oct 2016 18:22:59 -0700 (PDT) Received: from bar6.cudamail.com (localhost [127.0.0.1]) by mx3v3.cudamail.com (Postfix) with ESMTPS id 589C816144D for ; Tue, 4 Oct 2016 19:22:59 -0600 (MDT) X-ASG-Debug-ID: 1475630578-0b3237531666340001-byXFYA Received: from mx3-pf2.cudamail.com ([192.168.14.1]) by bar6.cudamail.com with ESMTP id H3MoinaebQs1bXir (version=TLSv1 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Tue, 04 Oct 2016 19:22:58 -0600 (MDT) X-Barracuda-Envelope-From: diproiettod@vmware.com X-Barracuda-RBL-Trusted-Forwarder: 192.168.14.1 Received: from unknown (HELO EX13-EDG-OU-002.vmware.com) (208.91.0.190) by mx3-pf2.cudamail.com with ESMTPS (AES256-SHA encrypted); 5 Oct 2016 01:22:58 -0000 Received-SPF: error (mx3-pf2.cudamail.com: error in processing during lookup of vmware.com: DNS problem) Received: from sc9-mailhost1.vmware.com (10.113.161.71) by EX13-EDG-OU-002.vmware.com (10.113.208.156) with Microsoft SMTP Server id 15.0.1156.6; Tue, 4 Oct 2016 18:22:23 -0700 Received: from sc9-mailhost2.vmware.com (htb-1n-eng-dhcp102.eng.vmware.com [10.33.74.102]) by sc9-mailhost1.vmware.com (Postfix) with ESMTP id A3A7418709; Tue, 4 Oct 2016 18:22:57 -0700 (PDT) X-CudaMail-Envelope-Sender: diproiettod@vmware.com From: Daniele Di Proietto To: X-CudaMail-Whitelist-To: dev@openvswitch.org X-CudaMail-MID: CM-V2-1003065737 X-CudaMail-DTE: 100416 X-CudaMail-Originating-IP: 208.91.0.190 Date: Tue, 4 Oct 2016 18:22:16 -0700 X-ASG-Orig-Subj: [##CM-V2-1003065737##][PATCH 05/13] netdev-dpdk: Acquire dev->stats_lock only once. Message-ID: <20161005012224.107729-6-diproiettod@vmware.com> X-Mailer: git-send-email 2.9.3 In-Reply-To: <20161005012224.107729-1-diproiettod@vmware.com> References: <20161005012224.107729-1-diproiettod@vmware.com> MIME-Version: 1.0 Received-SPF: None (EX13-EDG-OU-002.vmware.com: diproiettod@vmware.com does not designate permitted sender hosts) X-Barracuda-Connect: UNKNOWN[192.168.14.1] X-Barracuda-Start-Time: 1475630578 X-Barracuda-Encrypted: DHE-RSA-AES256-SHA X-Barracuda-URL: https://web.cudamail.com:443/cgi-mod/mark.cgi X-ASG-Whitelist: Header =?UTF-8?B?eFwtY3VkYW1haWxcLXdoaXRlbGlzdFwtdG8=?= X-Virus-Scanned: by bsmtpd at cudamail.com X-Barracuda-BRTS-Status: 1 Subject: [ovs-dev] [PATCH 05/13] netdev-dpdk: Acquire dev->stats_lock only once. X-BeenThere: dev@openvswitch.org X-Mailman-Version: 2.1.16 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@openvswitch.org Sender: "dev" Signed-off-by: Daniele Di Proietto Acked-by: Ben Pfaff --- lib/netdev-dpdk.c | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/lib/netdev-dpdk.c b/lib/netdev-dpdk.c index f3f0b27..fec3e68 100644 --- a/lib/netdev-dpdk.c +++ b/lib/netdev-dpdk.c @@ -1261,9 +1261,13 @@ netdev_dpdk_rxq_dealloc(struct netdev_rxq *rxq) rte_free(rx); } -static inline void +/* Tries to transmit 'pkts' to txq 'qid' of device 'dev'. Takes ownership of + * 'pkts', even in case of failure. + * + * Returns the number of packets that weren't transmitted. */ +static inline int netdev_dpdk_eth_tx_burst(struct netdev_dpdk *dev, int qid, - struct rte_mbuf **pkts, int cnt) + struct rte_mbuf **pkts, int cnt) { uint32_t nb_tx = 0; @@ -1279,17 +1283,16 @@ netdev_dpdk_eth_tx_burst(struct netdev_dpdk *dev, int qid, } if (OVS_UNLIKELY(nb_tx != cnt)) { - /* free buffers, which we couldn't transmit, one at a time (each + /* Free buffers, which we couldn't transmit, one at a time (each * packet could come from a different mempool) */ int i; for (i = nb_tx; i < cnt; i++) { rte_pktmbuf_free(pkts[i]); } - rte_spinlock_lock(&dev->stats_lock); - dev->stats.tx_dropped += cnt - nb_tx; - rte_spinlock_unlock(&dev->stats_lock); } + + return cnt - nb_tx; } static inline bool @@ -1666,7 +1669,7 @@ dpdk_do_tx_copy(struct netdev *netdev, int qid, struct dp_packet_batch *batch) newcnt = netdev_dpdk_qos_run(dev, pkts, newcnt); dropped += qos_pkts - newcnt; - netdev_dpdk_eth_tx_burst(dev, qid, pkts, newcnt); + dropped += netdev_dpdk_eth_tx_burst(dev, qid, pkts, newcnt); } if (OVS_UNLIKELY(dropped)) { @@ -1723,7 +1726,7 @@ netdev_dpdk_send__(struct netdev_dpdk *dev, int qid, cnt = netdev_dpdk_qos_run(dev, pkts, cnt); dropped = batch->count - cnt; - netdev_dpdk_eth_tx_burst(dev, qid, pkts, cnt); + dropped += netdev_dpdk_eth_tx_burst(dev, qid, pkts, cnt); if (OVS_UNLIKELY(dropped)) { rte_spinlock_lock(&dev->stats_lock);