From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 32465A0550; Tue, 16 Feb 2021 10:43:13 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id ABA601606BB; Tue, 16 Feb 2021 10:43:12 +0100 (CET) Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by mails.dpdk.org (Postfix) with ESMTP id 8D34B40690 for ; Tue, 16 Feb 2021 10:43:10 +0100 (CET) IronPort-SDR: vx1BWobofWc7ebgO3wW0qu3nDAptbuB2fgh5YTo6wN6dZ2nqWMBA0OHL8CCMCux5dUYYfUErWa UTyOaVF7DDGg== X-IronPort-AV: E=McAfee;i="6000,8403,9896"; a="246908538" X-IronPort-AV: E=Sophos;i="5.81,183,1610438400"; d="scan'208";a="246908538" Received: from orsmga007.jf.intel.com ([10.7.209.58]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Feb 2021 01:43:08 -0800 IronPort-SDR: M8ZrZUj+vqSwRuUSbnTFPES0vN8THOa1Q/8wwbo5niLkqOBMWC8n8LgbinFgCQ6zkRKgEFjWp4 MmDqziNnTL6A== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.81,183,1610438400"; d="scan'208";a="400935631" Received: from silpixa00399126.ir.intel.com ([10.237.223.216]) by orsmga007.jf.intel.com with ESMTP; 16 Feb 2021 01:43:07 -0800 From: Bruce Richardson To: dev@dpdk.org Cc: Bruce Richardson Date: Tue, 16 Feb 2021 09:43:00 +0000 Message-Id: <20210216094300.27889-1-bruce.richardson@intel.com> X-Mailer: git-send-email 2.27.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-dev] [PATCH] eal: support using 0 as coremask for no-affinitization X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Allow the user to specify that they don't want any core pinning from DPDK by passing in the coremask of 0. --- lib/librte_eal/common/eal_common_options.c | 18 +++++++++++++++--- lib/librte_eal/common/eal_internal_cfg.h | 1 + lib/librte_eal/freebsd/eal.c | 5 +++-- lib/librte_eal/linux/eal.c | 5 +++-- 4 files changed, 22 insertions(+), 7 deletions(-) diff --git a/lib/librte_eal/common/eal_common_options.c b/lib/librte_eal/common/eal_common_options.c index 622c7bc429..94029bf7f1 100644 --- a/lib/librte_eal/common/eal_common_options.c +++ b/lib/librte_eal/common/eal_common_options.c @@ -1522,9 +1522,21 @@ eal_parse_common_option(int opt, const char *optarg, if (eal_service_cores_parsed()) RTE_LOG(WARNING, EAL, "Service cores parsed before dataplane cores. Please ensure -c is before -s or -S\n"); - if (eal_parse_coremask(optarg, lcore_indexes) < 0) { - RTE_LOG(ERR, EAL, "invalid coremask syntax\n"); - return -1; + + if (strcmp(optarg, "0") == 0 || strcmp(optarg, "0x0") == 0) { + /* if -c 0 passed, don't affinitize anything, so set + * up a single core 0 as active, but mark it not to have + * pthread_setaffinity called on it. + */ + memset(lcore_indexes, -1, sizeof(lcore_indexes)); + conf->no_main_affinity = 1; + lcore_indexes[0] = 0; + RTE_CPU_FILL(&lcore_config[0].cpuset); + } else { + if (eal_parse_coremask(optarg, lcore_indexes) < 0) { + RTE_LOG(ERR, EAL, "invalid coremask syntax\n"); + return -1; + } } if (update_lcore_config(lcore_indexes) < 0) { char *available = available_cores(); diff --git a/lib/librte_eal/common/eal_internal_cfg.h b/lib/librte_eal/common/eal_internal_cfg.h index 51dbe86e2b..db46c49b84 100644 --- a/lib/librte_eal/common/eal_internal_cfg.h +++ b/lib/librte_eal/common/eal_internal_cfg.h @@ -50,6 +50,7 @@ struct internal_config { unsigned hugepage_unlink; /**< true to unlink backing files */ volatile unsigned no_pci; /**< true to disable PCI */ volatile unsigned no_hpet; /**< true to disable HPET */ + volatile unsigned no_main_affinity; /**< disable main lcore CPU pinning */ volatile unsigned vmware_tsc_map; /**< true to use VMware TSC mapping * instead of native TSC */ volatile unsigned no_shconf; /**< true if there is no shared config */ diff --git a/lib/librte_eal/freebsd/eal.c b/lib/librte_eal/freebsd/eal.c index 51478358c7..a30a6e54d4 100644 --- a/lib/librte_eal/freebsd/eal.c +++ b/lib/librte_eal/freebsd/eal.c @@ -850,8 +850,9 @@ rte_eal_init(int argc, char **argv) eal_check_mem_on_local_socket(); - if (pthread_setaffinity_np(pthread_self(), sizeof(rte_cpuset_t), - &lcore_config[config->main_lcore].cpuset) != 0) { + if (!internal_conf->no_main_affinity && + pthread_setaffinity_np(pthread_self(), sizeof(rte_cpuset_t), + &lcore_config[config->main_lcore].cpuset) != 0) { rte_eal_init_alert("Cannot set affinity"); rte_errno = EINVAL; return -1; diff --git a/lib/librte_eal/linux/eal.c b/lib/librte_eal/linux/eal.c index 32b48c3de9..e3390766ca 100644 --- a/lib/librte_eal/linux/eal.c +++ b/lib/librte_eal/linux/eal.c @@ -1214,8 +1214,9 @@ rte_eal_init(int argc, char **argv) eal_check_mem_on_local_socket(); - if (pthread_setaffinity_np(pthread_self(), sizeof(rte_cpuset_t), - &lcore_config[config->main_lcore].cpuset) != 0) { + if (!internal_conf->no_main_affinity && + pthread_setaffinity_np(pthread_self(), sizeof(rte_cpuset_t), + &lcore_config[config->main_lcore].cpuset) != 0) { rte_eal_init_alert("Cannot set affinity"); rte_errno = EINVAL; return -1; -- 2.27.0