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 C83C6A00C2; Tue, 3 Jan 2023 14:32:26 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 6702240693; Tue, 3 Jan 2023 14:32:26 +0100 (CET) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mails.dpdk.org (Postfix) with ESMTP id 95FF040689 for ; Tue, 3 Jan 2023 14:32:25 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1672752745; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=jwVaDJwgR589rW+QGkOyhk2lRZmclFQSNFw5HlasoWM=; b=B0ypSC+vhJIZZ9sPwcdMMxpbPddoHfDbapvELTxuQOTNsqbLeS19xzivsAK94+GVoPc1tH Bg2z68yeGFg9BDbVCbbvwY53RzR6XK9UH0ZX4gxGRSz9LjmZwGLRQp0r3agrCevDeB5WcF 2QzyqodDGZhtlosY5kk8OKfi/ozhE3o= Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-316-nENtOZw2OJyibbsUfXDN5w-1; Tue, 03 Jan 2023 08:32:22 -0500 X-MC-Unique: nENtOZw2OJyibbsUfXDN5w-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id C22A6382C98F; Tue, 3 Jan 2023 13:32:21 +0000 (UTC) Received: from dmarchan.redhat.com (ovpn-193-100.brq.redhat.com [10.40.193.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id A2237C15E7F; Tue, 3 Jan 2023 13:32:19 +0000 (UTC) From: David Marchand To: dev@dpdk.org Cc: olivier.matz@6wind.com, ferruh.yigit@amd.com, kaisenx.you@intel.com, zhoumin@loongson.cn, Anatoly Burakov Subject: [PATCH v3] malloc: enhance NUMA affinity heuristic Date: Tue, 3 Jan 2023 14:32:16 +0100 Message-Id: <20230103133216.961495-1-david.marchand@redhat.com> In-Reply-To: <20221221104858.296530-1-david.marchand@redhat.com> References: <20221221104858.296530-1-david.marchand@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.8 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset="US-ASCII"; x-default=true 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 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). Signed-off-by: David Marchand --- 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/malloc_heap.c | 4 ++++ 1 file changed, 4 insertions(+) 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.39.0