From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga06.intel.com (mga06.intel.com [134.134.136.31]) by dpdk.org (Postfix) with ESMTP id 6C9204C95 for ; Thu, 25 Oct 2018 13:06:37 +0200 (CEST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga104.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 25 Oct 2018 04:06:36 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.54,424,1534834800"; d="scan'208";a="91138227" Received: from irvmail001.ir.intel.com ([163.33.26.43]) by FMSMGA003.fm.intel.com with ESMTP; 25 Oct 2018 04:06:35 -0700 Received: from sivswdev01.ir.intel.com (sivswdev01.ir.intel.com [10.237.217.45]) by irvmail001.ir.intel.com (8.14.3/8.13.6/MailSET/Hub) with ESMTP id w9PB6YM3028349; Thu, 25 Oct 2018 12:06:34 +0100 Received: from sivswdev01.ir.intel.com (localhost [127.0.0.1]) by sivswdev01.ir.intel.com with ESMTP id w9PB6Yvu013789; Thu, 25 Oct 2018 12:06:34 +0100 Received: (from aburakov@localhost) by sivswdev01.ir.intel.com with LOCAL id w9PB6YQv013785; Thu, 25 Oct 2018 12:06:34 +0100 From: Anatoly Burakov To: dev@dpdk.org Cc: laszlo.madarassy@ericsson.com, janos.kobor@ericsson.com Date: Thu, 25 Oct 2018 12:06:34 +0100 Message-Id: <0a032f701099558dfbe4c9684df90874583a4544.1540465344.git.anatoly.burakov@intel.com> X-Mailer: git-send-email 1.7.0.7 Subject: [dpdk-dev] [PATCH] malloc: fix external heap allocation in no huge mode X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 25 Oct 2018 11:06:37 -0000 When no-huge mode is enabled, we always overwrite the socket ID to be SOCKET_ID_ANY in rte_malloc, because there is no NUMA awareness in no-huge mode. However, with external memory support, a socket ID may have other meaning, and we cannot overwrite the socket ID in those cases. Fixes: 65ff37b105f7 ("malloc: add function to check if socket is external") Signed-off-by: Anatoly Burakov --- lib/librte_eal/common/rte_malloc.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/librte_eal/common/rte_malloc.c b/lib/librte_eal/common/rte_malloc.c index b27a8ad2e..9e61dc41b 100644 --- a/lib/librte_eal/common/rte_malloc.c +++ b/lib/librte_eal/common/rte_malloc.c @@ -46,7 +46,13 @@ rte_malloc_socket(const char *type, size_t size, unsigned int align, if (size == 0 || (align && !rte_is_power_of_2(align))) return NULL; - if (!rte_eal_has_hugepages()) + /* if there are no hugepages and if we are not allocating from an + * external heap, use memory from any socket available. checking for + * socket being external may return -1 in case of invalid socket, but + * that's OK - if there are no hugepages, it doesn't matter. + */ + if (rte_malloc_heap_socket_is_external(socket_arg) != 1 && + !rte_eal_has_hugepages()) socket_arg = SOCKET_ID_ANY; return malloc_heap_alloc(type, size, socket_arg, 0, -- 2.17.1