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 17AE741B98 for ; Wed, 1 Feb 2023 06:37:33 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 0D16E427E9; Wed, 1 Feb 2023 06:37:33 +0100 (CET) Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by mails.dpdk.org (Postfix) with ESMTP id EADC64021F; Wed, 1 Feb 2023 06:37:29 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1675229850; x=1706765850; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=EjkS1fk7/qNKy2pnvUC5jDv0nTkP7ShNSZgNt7dUJKg=; b=Er8qq26NfNvr2ZBoVqftn3fpzTOnmF6k5jz/GMxuAfv3ue6XbcpkOkNs dfiZZ1RKnwkmd07ucaNByrG1eJqxwx/9gX1n1aGZ8k+38HxfdK6YxMrZQ yc8HPFGhAyXPwWa81Y8gblDhMj2BqqgfAVDZhW95N1dH3eVg7+vygareo C2GaC3ifke9RO5JPFEyiMhpUtdAM4oo0BZW2O8+VRl76AS8wZ+f1OEInI PWUnx3PP+kCkdZWc/54oA8AJxmMs4lpQALh4O30ApdYT4cHPV32M/xLud EXpgp4qDswVECis6Nid6sjDokVq1HqXqZ5CalOrpqOD0RVAoMaRbiBcZD w==; X-IronPort-AV: E=McAfee;i="6500,9779,10607"; a="325752089" X-IronPort-AV: E=Sophos;i="5.97,263,1669104000"; d="scan'208";a="325752089" Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 31 Jan 2023 21:37:28 -0800 X-IronPort-AV: E=McAfee;i="6500,9779,10607"; a="773299140" X-IronPort-AV: E=Sophos;i="5.97,263,1669104000"; d="scan'208";a="773299140" Received: from unknown (HELO root..) ([10.239.252.66]) by fmsmga002-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 31 Jan 2023 21:37:26 -0800 From: Kaisen You To: dev@dpdk.org Cc: yidingx.zhou@intel.com, thomas@monjalon.net, david.marchand@redhat.com, olivier.matz@6wind.com, ferruh.yigit@amd.com, kaisenx.you@intel.com, zhoumin@loongson.cn, anatoly.burakov@intel.com, stable@dpdk.org Subject: [PATCH v5] enhance NUMA affinity heuristic Date: Wed, 1 Feb 2023 12:20:48 +0000 Message-Id: <20230201122048.1283392-1-kaisenx.you@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221221104858.296530-1-david.marchand@redhat.com> References: <20221221104858.296530-1-david.marchand@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: stable-bounces@dpdk.org Trying to allocate memory on the first detected numa node has less chance to find some memory actually available rather than on the main lcore numa node (especially when the DPDK application is started only on one numa node). Fixes: 705356f0811f ("eal: simplify control thread creation") Fixes: bb0bd346d5c1 ("eal: suggest using --lcores option") Cc: stable@dpdk.org Signed-off-by: David Marchand Signed-off-by: Kaisen You --- Changes since v4: - mod the patch title, Changes since v3: - add the assignment of socket_id in thread initialization, Changes since v2: - add uncommitted local change and fix compilation, Changes since v1: - accomodate for configurations with main lcore running on multiples physical cores belonging to different numa, --- lib/eal/common/eal_common_thread.c | 1 + lib/eal/common/malloc_heap.c | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/lib/eal/common/eal_common_thread.c b/lib/eal/common/eal_common_thread.c index 38d83a6885..21bff971f8 100644 --- a/lib/eal/common/eal_common_thread.c +++ b/lib/eal/common/eal_common_thread.c @@ -251,6 +251,7 @@ static void *ctrl_thread_init(void *arg) void *routine_arg = params->arg; __rte_thread_init(rte_lcore_id(), cpuset); + RTE_PER_LCORE(_socket_id) = SOCKET_ID_ANY; params->ret = rte_thread_set_affinity_by_id(rte_thread_self(), cpuset); if (params->ret != 0) { __atomic_store_n(¶ms->ctrl_thread_status, diff --git a/lib/eal/common/malloc_heap.c b/lib/eal/common/malloc_heap.c index d7c410b786..3ee19aee15 100644 --- a/lib/eal/common/malloc_heap.c +++ b/lib/eal/common/malloc_heap.c @@ -717,6 +717,10 @@ malloc_get_numa_socket(void) return socket_id; } + socket_id = rte_lcore_to_socket_id(rte_get_main_lcore()); + if (socket_id != (unsigned int)SOCKET_ID_ANY) + return socket_id; + return rte_socket_id_by_idx(0); } -- 2.34.1