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 0DA7FA09E4; Fri, 29 Jan 2021 16:29:56 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 7F9654067B; Fri, 29 Jan 2021 16:29:55 +0100 (CET) Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) by mails.dpdk.org (Postfix) with ESMTP id BD49740395 for ; Fri, 29 Jan 2021 16:29:54 +0100 (CET) IronPort-SDR: esN6ALK0NtF/ezkM6v8W0OMIND7Q4mWIEh/J5VXMAqqlv50tF5UpoS5EyjHbd1uFEAt3op6c7l sheDJYkGeK5w== X-IronPort-AV: E=McAfee;i="6000,8403,9878"; a="168104846" X-IronPort-AV: E=Sophos;i="5.79,385,1602572400"; d="scan'208";a="168104846" Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Jan 2021 07:29:53 -0800 IronPort-SDR: xKEOgWcEIMh2kQDaRkqoPzHgXJ5cRS1LiBbzFBReNJpx3xMcGiwPp2oBNtB5jUvsqNrNPwdbkl PWAqyBBKuEyA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.79,385,1602572400"; d="scan'208";a="411508803" Received: from silpixa00399498.ir.intel.com (HELO silpixa00399498.ger.corp.intel.com) ([10.237.222.179]) by FMSMGA003.fm.intel.com with ESMTP; 29 Jan 2021 07:29:52 -0800 From: Anatoly Burakov To: dev@dpdk.org Cc: thomas@monjalon.net, james.r.harris@intel.com Date: Fri, 29 Jan 2021 15:29:51 +0000 Message-Id: <4e0688f841f6ba2408fde949aabce8e36c0d46f0.1611934186.git.anatoly.burakov@intel.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-dev] [PATCH] mem: fix deadlock on secondary allocation 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" Previous fix used `rte_malloc_heap_socket_is_external()` to check if the heap was an external heap. However, that API is thread-safe, and when we're inside the allocation process, we're already write-locked, so calling `rte_malloc_heap_socket_is_external()` will result in a deadlock followed by a timeout. Fix it by replacing the API call with a check against maximum number of NUMA nodes, because external heaps always have higher socket ID's. Fixes: 7ac31e82bc8f ("mem: improve parameter checking on memory hotplug") Reported-by: Jim Harris Signed-off-by: Anatoly Burakov --- lib/librte_eal/common/malloc_mp.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/lib/librte_eal/common/malloc_mp.c b/lib/librte_eal/common/malloc_mp.c index 0b19d4d5fb..b1f7f7824b 100644 --- a/lib/librte_eal/common/malloc_mp.c +++ b/lib/librte_eal/common/malloc_mp.c @@ -241,8 +241,13 @@ handle_alloc_request(const struct malloc_mp_req *m, heap = &mcfg->malloc_heaps[ar->malloc_heap_idx]; - /* for allocations, we must only use internal heaps */ - if (rte_malloc_heap_socket_is_external(heap->socket_id)) { + /* + * for allocations, we must only use internal heaps, but since the + * rte_malloc_heap_socket_is_external() is thread-safe and we're already + * read-locked, we'll have to take advantage of the fac that internal + * socket ID's are always lower than RTE_MAX_NUMA_NODES. + */ + if (heap->socket_id >= RTE_MAX_NUMA_NODES) { RTE_LOG(ERR, EAL, "Attempting to allocate from external heap\n"); return -1; } -- 2.25.1