From patchwork Tue Aug 13 15:30:07 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ilya Maximets X-Patchwork-Id: 1146412 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=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=samsung.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=samsung.com header.i=@samsung.com header.b="Ou5bAETL"; dkim-atps=neutral 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 467GtC1z72z9sN1 for ; Wed, 14 Aug 2019 01:32:19 +1000 (AEST) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id 06DB2D4B; Tue, 13 Aug 2019 15:30:29 +0000 (UTC) X-Original-To: ovs-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 6F438D4F for ; Tue, 13 Aug 2019 15:30:27 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mailout1.w1.samsung.com (mailout1.w1.samsung.com [210.118.77.11]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id C99FC8AB for ; Tue, 13 Aug 2019 15:30:26 +0000 (UTC) Received: from eucas1p2.samsung.com (unknown [182.198.249.207]) by mailout1.w1.samsung.com (KnoxPortal) with ESMTP id 20190813153025euoutp01a3a2daa7bf1562c6ae67ee8263a170b6~6hSd4pIKg0999909999euoutp01d for ; Tue, 13 Aug 2019 15:30:25 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.w1.samsung.com 20190813153025euoutp01a3a2daa7bf1562c6ae67ee8263a170b6~6hSd4pIKg0999909999euoutp01d DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1565710225; bh=QTHUst9RT8ylBOoy5ricPJOrr/4lK3O1syoSJjIuAxA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Ou5bAETLq1TqSKR2gn/3IeyjT2UGmeL2PCW6DKd3A2Ut50hqz+Vu0BPpyyLTSH34i hR3jmqVKzWlL630Jrd9+evvBzAmqTFfgtXe3VZIgPi3kk/S9kP6yMFZKQk56i/xBst U4XQTPmy3u6BeViXXmqyjmfcLHKyNRSgdUSSRDxg= Received: from eusmges2new.samsung.com (unknown [203.254.199.244]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20190813153024eucas1p11e1603ab04a8ea4afbca098c24e1b561~6hSdbqk3T1487414874eucas1p1V; Tue, 13 Aug 2019 15:30:24 +0000 (GMT) Received: from eucas1p1.samsung.com ( [182.198.249.206]) by eusmges2new.samsung.com (EUCPMTA) with SMTP id 45.40.04309.097D25D5; Tue, 13 Aug 2019 16:30:24 +0100 (BST) Received: from eusmtrp2.samsung.com (unknown [182.198.249.139]) by eucas1p2.samsung.com (KnoxPortal) with ESMTPA id 20190813153023eucas1p27213f4f18327515251b66bea7ec4ee6d~6hScZBq2s0050700507eucas1p2Q; Tue, 13 Aug 2019 15:30:23 +0000 (GMT) Received: from eusmgms1.samsung.com (unknown [182.198.249.179]) by eusmtrp2.samsung.com (KnoxPortal) with ESMTP id 20190813153023eusmtrp2b32cace9537d6c31cc1873c1f0b71f1e~6hScI25Qv0716707167eusmtrp2s; Tue, 13 Aug 2019 15:30:23 +0000 (GMT) X-AuditID: cbfec7f4-ae1ff700000010d5-94-5d52d790231f Received: from eusmtip2.samsung.com ( [203.254.199.222]) by eusmgms1.samsung.com (EUCPMTA) with SMTP id 18.73.04166.F87D25D5; Tue, 13 Aug 2019 16:30:23 +0100 (BST) Received: from imaximets.rnd.samsung.ru (unknown [106.109.129.180]) by eusmtip2.samsung.com (KnoxPortal) with ESMTPA id 20190813153022eusmtip2de4d98fcfed6cfb9e77386b8d470c7a2~6hSbs_4ME1702317023eusmtip2a; Tue, 13 Aug 2019 15:30:22 +0000 (GMT) From: Ilya Maximets To: ovs-dev@openvswitch.org Date: Tue, 13 Aug 2019 18:30:07 +0300 Message-Id: <20190813153007.32305-4-i.maximets@samsung.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190813153007.32305-1-i.maximets@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrGIsWRmVeSWpSXmKPExsWy7djPc7oTrgfFGjRP47PYvqKLzeJK+092 i40Pz7JarD30gd1i7qfnjBbXL/E4sHnsnHWX3WPxnpdMHs9u/mf0eL/vKptH35ZVjAGsUVw2 Kak5mWWpRfp2CVwZl062shfsF6mYOWU3UwPjJ94uRg4OCQETienHS7oYuTiEBFYwSqw585EN wvnCKPH0zGV2COczo8Sr69+AHE6wjoez17JCJJYzSlzbt48RwvnBKLHp+3NGkCo2AR2JU6uP gNkiAtISr3vfgHUwCxxmlNjV+5ANJCEsEC7xpvEGmM0ioCqxblsLWAOvgLXE5sNfmSHWyUus 3nAAzOYUsJFY23CfCWSQhMBzNon+ff3MEF+4SGw+5ANRLyzx6vgWqFNlJP7vnM8EYddL3G95 yQjR28EoMf3QP6iEvcSW1+fYQeYwC2hKrN+lDxF2lNg88SILxHg+iRtvBUHCzEDmpG3Tobby SnS0CUFUq0j8Prgc6mIpiZvvPkNd4CHx69Z0aPj0M0os27WOeQKj/CyEZQsYGVcxiqeWFuem pxYb5aWW6xUn5haX5qXrJefnbmIEpobT/45/2cG460/SIUYBDkYlHt6ALUGxQqyJZcWVuYcY JTiYlUR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QAWpulnmsCAAA= X-CMS-MailID: 20190813153023eucas1p27213f4f18327515251b66bea7ec4ee6d X-Msg-Generator: CA X-RootMTR: 20190813153023eucas1p27213f4f18327515251b66bea7ec4ee6d X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20190813153023eucas1p27213f4f18327515251b66bea7ec4ee6d References: <20190813153007.32305-1-i.maximets@samsung.com> X-Spam-Status: No, score=-7.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on smtp1.linux-foundation.org Cc: Ilya Maximets , David Marchand Subject: [ovs-dev] [PATCH 3/3] dpdk: Use ovs-numa provided functions to manage thread affinity. 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 This allows to decrease code duplication and avoid using Linux-specific functions (this might be useful in the future if we'll try to allow running OvS+DPDK on FreeBSD). Signed-off-by: Ilya Maximets Acked-by: William Tu --- lib/dpdk.c | 27 ++++++++++++--------------- 1 file changed, 12 insertions(+), 15 deletions(-) diff --git a/lib/dpdk.c b/lib/dpdk.c index fc58de55a..6f297d918 100644 --- a/lib/dpdk.c +++ b/lib/dpdk.c @@ -275,7 +275,7 @@ dpdk_init__(const struct smap *ovs_other_config) int result; bool auto_determine = true; int err = 0; - cpu_set_t cpuset; + struct ovs_numa_dump *affinity = NULL; struct svec args = SVEC_EMPTY_INITIALIZER; log_stream = fopencookie(NULL, "w+", dpdk_log_func); @@ -357,22 +357,22 @@ dpdk_init__(const struct smap *ovs_other_config) * lcore for the DPDK Master. */ if (auto_determine) { + const struct ovs_numa_info_core *core; int cpu = 0; /* Get the main thread affinity */ - CPU_ZERO(&cpuset); - err = pthread_getaffinity_np(pthread_self(), sizeof(cpu_set_t), - &cpuset); - if (!err) { - for (cpu = 0; cpu < CPU_SETSIZE; cpu++) { - if (CPU_ISSET(cpu, &cpuset)) { - break; + affinity = ovs_numa_thread_getaffinity_dump(); + if (affinity) { + cpu = INT_MAX; + FOR_EACH_CORE_ON_DUMP (core, affinity) { + if (cpu > core->core_id) { + cpu = core->core_id; } } } else { /* User did not set dpdk-lcore-mask and unable to get current * thread affintity - default to core #0 */ - VLOG_ERR("Thread getaffinity error %d. Using core #0", err); + VLOG_ERR("Thread getaffinity failed. Using core #0"); } svec_add(&args, "-l"); svec_add_nocopy(&args, xasprintf("%d", cpu)); @@ -403,12 +403,9 @@ dpdk_init__(const struct smap *ovs_other_config) svec_destroy(&args); /* Set the main thread affinity back to pre rte_eal_init() value */ - if (auto_determine && !err) { - err = pthread_setaffinity_np(pthread_self(), sizeof(cpu_set_t), - &cpuset); - if (err) { - VLOG_ERR("Thread setaffinity error %d", err); - } + if (affinity) { + ovs_numa_thread_setaffinity_dump(affinity); + ovs_numa_dump_destroy(affinity); } if (result < 0) {