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 9F56BA00C2; Tue, 3 Jan 2023 11:58:36 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 876E340698; Tue, 3 Jan 2023 11:58:36 +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 D753A40693 for ; Tue, 3 Jan 2023 11:58:34 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1672743514; 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=lymx0E9piVJE60o+m3TewCvUuJL2HIrFhHDj6/o4RDE=; b=Op9Kr7Ib4UmKckW22pDI0DI2R3nIHfHOFsUZioUKTfctLIDp80MkDs3EE7l2CKrfQoympY dzrjJVkNff+PCsflCQZVZNTmnsTzngwCIfFSdNryiMyF0nYuUBlDqSpaKqLwghOkiK6DsM FDneiteSSL9bw+dmUJsLFMH0V0d4tSE= 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-164-Ym0CO-_LMXCm0-JgYzAlvA-1; Tue, 03 Jan 2023 05:58:31 -0500 X-MC-Unique: Ym0CO-_LMXCm0-JgYzAlvA-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 8EE0F1C0A583; Tue, 3 Jan 2023 10:58:30 +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 E4289C15BA0; Tue, 3 Jan 2023 10:58:28 +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 v2] malloc: enhance NUMA affinity heuristic Date: Tue, 3 Jan 2023 11:58:25 +0100 Message-Id: <20230103105825.616810-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 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..fcb3fbebb9 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(rte_get_main_lcore()); + if (socket_id != (unsigned int)SOCKET_ID_ANY) + return socket_id; + return rte_socket_id_by_idx(0); } -- 2.38.1