From patchwork Mon Sep 5 23:42:57 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xu Binbin X-Patchwork-Id: 665783 X-Patchwork-Delegate: diproiettod@vmware.com 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 3sSSMY3XFzz9rxv for ; Mon, 5 Sep 2016 21:35:21 +1000 (AEST) Received: from archives.nicira.com (localhost [127.0.0.1]) by archives.nicira.com (Postfix) with ESMTP id 924631059C; Mon, 5 Sep 2016 04:35:18 -0700 (PDT) X-Original-To: dev@openvswitch.org Delivered-To: dev@openvswitch.org Received: from mx1e3.cudamail.com (mx1.cudamail.com [69.90.118.67]) by archives.nicira.com (Postfix) with ESMTPS id B1A491059A for ; Mon, 5 Sep 2016 04:35:17 -0700 (PDT) Received: from bar5.cudamail.com (localhost [127.0.0.1]) by mx1e3.cudamail.com (Postfix) with ESMTPS id 49CB8420301 for ; Mon, 5 Sep 2016 05:35:16 -0600 (MDT) X-ASG-Debug-ID: 1473075315-09eadd33566253f0001-byXFYA Received: from mx1-pf1.cudamail.com ([192.168.24.1]) by bar5.cudamail.com with ESMTP id w8Md9yc51pvxur63 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO) for ; Mon, 05 Sep 2016 05:35:15 -0600 (MDT) X-Barracuda-Envelope-From: xu.binbin1@zte.com.cn X-Barracuda-RBL-Trusted-Forwarder: 192.168.24.1 Received: from unknown (HELO zte.com.cn) (202.103.147.169) by mx1-pf1.cudamail.com with SMTP; 5 Sep 2016 11:35:15 -0000 Received-SPF: pass (mx1-pf1.cudamail.com: SPF record at zte.com.cn designates 202.103.147.169 as permitted sender) X-Barracuda-Apparent-Source-IP: 202.103.147.169 X-Barracuda-RBL-IP: 202.103.147.169 Received: from mse01.zte.com.cn (unknown [10.30.3.20]) by Websense Email Security Gateway with ESMTP id 34D584482F8BF for ; Mon, 5 Sep 2016 19:35:07 +0800 (CST) Received: from notes_smtp.zte.com.cn ([10.30.1.239]) by mse01.zte.com.cn with ESMTP id u85BYvE3028420 for ; Mon, 5 Sep 2016 19:34:57 +0800 (GMT-8) (envelope-from xu.binbin1@zte.com.cn) Received: from host146.localdomain ([10.43.166.146]) by szsmtp06.zte.com.cn (Lotus Domino Release 8.5.3FP6) with ESMTP id 2016090519350044-241801 ; Mon, 5 Sep 2016 19:35:00 +0800 X-CudaMail-Envelope-Sender: xu.binbin1@zte.com.cn From: Binbin Xu To: dev@openvswitch.org X-CudaMail-MID: CM-E1-904005607 X-CudaMail-DTE: 090516 X-CudaMail-Originating-IP: 202.103.147.169 Date: Tue, 6 Sep 2016 07:42:57 +0800 X-ASG-Orig-Subj: [##CM-E1-904005607##][ovs-dev] [PATCH] netdev-dpdk: in some case, needn't reconfigure pmd threads when changing MTU Message-Id: <20160905234257.29211-1-xu.binbin1@zte.com.cn> X-Mailer: git-send-email 2.9.3 X-MIMETrack: Itemize by SMTP Server on SZSMTP06/server/zte_ltd(Release 8.5.3FP6|November 21, 2013) at 2016-09-05 19:35:00, Serialize by Router on notes_smtp/zte_ltd(Release 8.5.3FP6|November 21, 2013) at 2016-09-05 19:34:46, Serialize complete at 2016-09-05 19:34:46 X-MAIL: mse01.zte.com.cn u85BYvE3028420 X-Barracuda-Connect: UNKNOWN[192.168.24.1] X-Barracuda-Start-Time: 1473075315 X-Barracuda-Encrypted: ECDHE-RSA-AES256-GCM-SHA384 X-Barracuda-URL: https://web.cudamail.com:443/cgi-mod/mark.cgi X-Virus-Scanned: by bsmtpd at cudamail.com X-Barracuda-BRTS-Status: 1 X-Barracuda-Spam-Score: 3.81 X-Barracuda-Spam-Status: Yes, SCORE=3.81 using global scores of TAG_LEVEL=3.5 QUARANTINE_LEVEL=1000.0 KILL_LEVEL=4.0 tests=BSF_SC0_MV0713, DATE_IN_FUTURE_12_24, DATE_IN_FUTURE_12_24_2 X-Barracuda-Spam-Report: Code version 3.2, rules version 3.2.3.32629 Rule breakdown below pts rule name description ---- ---------------------- -------------------------------------------------- 0.01 DATE_IN_FUTURE_12_24 Date: is 12 to 24 hours after Received: date 3.30 DATE_IN_FUTURE_12_24_2 DATE_IN_FUTURE_12_24_2 0.50 BSF_SC0_MV0713 Custom rule MV0713 X-Priority: 5 (Lowest) X-MSMail-Priority: Low Importance: Low X-Barracuda-Spam-Flag: YES Subject: [ovs-dev] [CudaMailTagged] [PATCH] netdev-dpdk: in some case, needn't reconfigure pmd threads when changing MTU 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: , MIME-Version: 1.0 Errors-To: dev-bounces@openvswitch.org Sender: "dev" 1. The MTU configuration changes, but the size of aligned mempool of new MTU doesn't change. What we have to do is to update the netdev's MTU and max_packet_len. 2. The MTU configuration changes, and the size of aligned mempool of new MTU changes too. The mempool needed by the new MTU has already been allocated, and the mempool used for the old MTU is referenced by other netdev meantime. What we have to do is to reduce the reference count of old mempool, increase the reference count of new mempool, update the netdev's mempool, MTU and max_packet_len. Signed-off-by: Binbin Xu --- lib/netdev-dpdk.c | 31 ++++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/lib/netdev-dpdk.c b/lib/netdev-dpdk.c index 6d334db..86dd5df 100644 --- a/lib/netdev-dpdk.c +++ b/lib/netdev-dpdk.c @@ -1723,6 +1723,8 @@ netdev_dpdk_get_mtu(const struct netdev *netdev, int *mtup) static int netdev_dpdk_set_mtu(struct netdev *netdev, int mtu) { + struct dpdk_mp *dmp = NULL; + struct dpdk_mp *dmp_node = NULL; struct netdev_dpdk *dev = netdev_dpdk_cast(netdev); if (MTU_TO_FRAME_LEN(mtu) > NETDEV_DPDK_MAX_PKT_LEN @@ -1731,12 +1733,39 @@ netdev_dpdk_set_mtu(struct netdev *netdev, int mtu) return EINVAL; } + ovs_mutex_lock(&dpdk_mutex); ovs_mutex_lock(&dev->mutex); if (dev->requested_mtu != mtu) { + VLOG_INFO("%s: cur MTU %d, req MTU %d, " + "cur buf len %d, req buf len %d\n", + dev->up.name, dev->mtu, mtu, + dpdk_buf_size(dev->mtu), dpdk_buf_size(mtu)); + dev->requested_mtu = mtu; - netdev_request_reconfigure(netdev); + + LIST_FOR_EACH (dmp_node, list_node, &dpdk_mp_list) { + if (dmp_node->mtu == FRAME_LEN_TO_MTU(dpdk_buf_size(mtu))) { + dmp = dmp_node; + break; + } + } + + if ((dpdk_buf_size(dev->mtu) != dpdk_buf_size(mtu) + && 1 == dev->dpdk_mp->refcount) + || dmp == NULL) { + netdev_request_reconfigure(netdev); + } else { + if (dpdk_buf_size(dev->mtu) != dpdk_buf_size(mtu)) { + dev->dpdk_mp->refcount--; + dmp->refcount++; + dev->dpdk_mp = dmp; + } + dev->mtu = mtu; + dev->max_packet_len = MTU_TO_FRAME_LEN(dev->mtu); + } } ovs_mutex_unlock(&dev->mutex); + ovs_mutex_unlock(&dpdk_mutex); return 0; }