From patchwork Fri Dec 18 18:27:54 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aaron Conole X-Patchwork-Id: 559042 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from archives.nicira.com (li376-54.members.linode.com [96.126.127.54]) by ozlabs.org (Postfix) with ESMTP id B5170140273 for ; Sat, 19 Dec 2015 05:28:13 +1100 (AEDT) Received: from archives.nicira.com (localhost [127.0.0.1]) by archives.nicira.com (Postfix) with ESMTP id 6DB00109FC; Fri, 18 Dec 2015 10:28:11 -0800 (PST) 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 5C893109F6 for ; Fri, 18 Dec 2015 10:28:10 -0800 (PST) Received: from bar5.cudamail.com (localhost [127.0.0.1]) by mx1e3.cudamail.com (Postfix) with ESMTPS id B0441420218 for ; Fri, 18 Dec 2015 11:28:09 -0700 (MST) X-ASG-Debug-ID: 1450463287-09eadd35e2160030001-byXFYA Received: from mx1-pf2.cudamail.com ([192.168.24.2]) by bar5.cudamail.com with ESMTP id AICH268D3zUqn42C (version=TLSv1 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Fri, 18 Dec 2015 11:28:07 -0700 (MST) X-Barracuda-Envelope-From: aconole@redhat.com X-Barracuda-RBL-Trusted-Forwarder: 192.168.24.2 Received: from unknown (HELO mx1.redhat.com) (209.132.183.28) by mx1-pf2.cudamail.com with ESMTPS (DHE-RSA-AES256-SHA encrypted); 18 Dec 2015 18:28:07 -0000 Received-SPF: pass (mx1-pf2.cudamail.com: SPF record at _spf1.redhat.com designates 209.132.183.28 as permitted sender) X-Barracuda-Apparent-Source-IP: 209.132.183.28 X-Barracuda-RBL-IP: 209.132.183.28 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (Postfix) with ESMTPS id AFD0C8CB55; Fri, 18 Dec 2015 18:28:06 +0000 (UTC) Received: from aconole.bos.com (vpn-238-90.phx2.redhat.com [10.3.238.90]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id tBIIS5Ae003412; Fri, 18 Dec 2015 13:28:06 -0500 X-CudaMail-Envelope-Sender: aconole@redhat.com From: Aaron Conole To: dev@openvswitch.org X-CudaMail-MID: CM-E2-1217053593 X-CudaMail-DTE: 121815 X-CudaMail-Originating-IP: 209.132.183.28 Date: Fri, 18 Dec 2015 13:27:54 -0500 X-ASG-Orig-Subj: [##CM-E2-1217053593##][PATCH 1/5] netdev-dpdk: Restore thread affinity after DPDK init Message-Id: <1450463278-7931-2-git-send-email-aconole@redhat.com> In-Reply-To: <1450463278-7931-1-git-send-email-aconole@redhat.com> References: <1450463278-7931-1-git-send-email-aconole@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 X-GBUdb-Analysis: 0, 209.132.183.28, Ugly c=0 p=0 Source New X-MessageSniffer-Rules: 0-0-0-4051-c X-Barracuda-Connect: UNKNOWN[192.168.24.2] X-Barracuda-Start-Time: 1450463287 X-Barracuda-Encrypted: DHE-RSA-AES256-SHA 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: 0.60 X-Barracuda-Spam-Status: No, SCORE=0.60 using per-user scores of TAG_LEVEL=3.5 QUARANTINE_LEVEL=1000.0 KILL_LEVEL=4.0 tests=BSF_SC5_MJ1963, RDNS_NONE X-Barracuda-Spam-Report: Code version 3.2, rules version 3.2.3.25381 Rule breakdown below pts rule name description ---- ---------------------- -------------------------------------------------- 0.10 RDNS_NONE Delivered to trusted network by a host with no rDNS 0.50 BSF_SC5_MJ1963 Custom Rule MJ1963 Cc: Flavio Leitner Subject: [ovs-dev] [PATCH 1/5] netdev-dpdk: Restore thread affinity after DPDK init 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" When the DPDK init function is called, it changes the executing thread's CPU affinity to a single core specified in -c. This will result in the userspace bridge configuration thread being rebound, even if that is not the intent. This change fixes that behavior by rebinding to the original thread affinity after calling dpdk_init(). Signed-off-by: Kevin Traynor Signed-off-by: Aaron Conole --- lib/netdev-dpdk.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/lib/netdev-dpdk.c b/lib/netdev-dpdk.c index e3a0771..9c302f0 100644 --- a/lib/netdev-dpdk.c +++ b/lib/netdev-dpdk.c @@ -2138,6 +2138,9 @@ dpdk_init(int argc, char **argv) int result; int base = 0; char *pragram_name = argv[0]; + int err; + int isset; + cpu_set_t cpuset; if (argc < 2 || strcmp(argv[1], "--dpdk")) return 0; @@ -2179,6 +2182,14 @@ dpdk_init(int argc, char **argv) base = 2; } + /* Get the main thread affinity */ + CPU_ZERO(&cpuset); + err = pthread_getaffinity_np(pthread_self(), sizeof(cpu_set_t), &cpuset); + if (err) { + VLOG_ERR("Thread getaffinity error %d.", err); + return err; + } + /* Keep the program name argument as this is needed for call to * rte_eal_init() */ @@ -2190,6 +2201,13 @@ dpdk_init(int argc, char **argv) ovs_abort(result, "Cannot init EAL"); } + /* Set the main thread affinity back to pre rte_eal_init() value */ + err = pthread_setaffinity_np(pthread_self(), sizeof(cpu_set_t), &cpuset); + if (err) { + VLOG_ERR("Thread setaffinity error %d", err); + return err; + } + rte_memzone_dump(stdout); rte_eal_init_ret = 0;