From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 96751A04B6 for ; Mon, 12 Oct 2020 21:23:07 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 8ED141D995; Mon, 12 Oct 2020 21:23:06 +0200 (CEST) Received: from mail-wr1-f68.google.com (mail-wr1-f68.google.com [209.85.221.68]) by dpdk.org (Postfix) with ESMTP id C80831D995 for ; Mon, 12 Oct 2020 21:23:05 +0200 (CEST) Received: by mail-wr1-f68.google.com with SMTP id n18so20537066wrs.5 for ; Mon, 12 Oct 2020 12:23:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mayadata-io.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=azNjTOpKOEHIgF0hOEAWjXHDFivKHd2GKaHJtT/Zpzk=; b=T09/ygHvhii74jOy6bVsT8Uoq/2wSyqfgNQZ6zXQunnl7H6QN2wbGuezTy5KXrgevN jYZ2ssyVDlhQVzdnVEbBk7MBDVaQ7rkLSiF2OMFzwY5T6KPEkEFjAMimsoqU5Cil5Xkg wu9bsWfu1d8lXa6jhljpKDm4LhHJnjm7XeJSnyCW+rHy3DC7Uz3fHJCJHPo0zWTnPaXc CcQZzn96Y6IeNZ4+XIla8vH5zr6TlnNJoN3D/Yw0eO7EyxpAxzjY9/t22U4zz5SThQZo TFFqBGf1dNpSuWy6Z70ztgriE4XC7RLdWXNqQckeooNvzWcqLgM2Pm+yeLQf+Tzq8lFs Hnrg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=azNjTOpKOEHIgF0hOEAWjXHDFivKHd2GKaHJtT/Zpzk=; b=VjF8/p+TbkDXkmU3Lhwo3aGMT70JgcSexECJtoYoT475weIpwN5BOyzu8HfkoVDyaO mXabVZhif/RzneG5LIiGkMHDZ2BOdtLBZD76bfVTFkUCJ9iRSkVhMzyMun/ldj5reNh+ ya36Fe+o/UIucquAnzZ8decftQ41x/kT48GjnaqHWX79JN/4sIbH5l3uiSGoP/dLAjrm HAKxYmEesY8VE+m9IgLPU0AgV8ncGh2CUDFCaXb5foKjV5Oki6nYMfzigcQ1WT1O4dYr PxUVIzVniRTwqBVSbDdoeoFz8La7/r2tH196+bimy3qyLGGfR1n4Vnhb0ESyGvA726or DuFw== X-Gm-Message-State: AOAM531qJekxBHHJTWc5LxyCiWKRhW85wzuCB2bUEIZbN9FRiP10+4Rq rK11PHjGbm/5E4FH5C3tjCc6aA== X-Google-Smtp-Source: ABdhPJwF9rrMCl0gG8VHhuya0w28oDhaXu5IDQ9kGktbxavwwrrqNkoCffTr+EpW7MNWeAgHkzFPgQ== X-Received: by 2002:adf:bbcb:: with SMTP id z11mr31274994wrg.130.1602530584551; Mon, 12 Oct 2020 12:23:04 -0700 (PDT) Received: from FENIX.localdomain (cpc98320-croy25-2-0-cust77.19-2.cable.virginm.net. [80.235.134.78]) by smtp.gmail.com with ESMTPSA id d4sm25978221wrp.47.2020.10.12.12.23.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Oct 2020 12:23:03 -0700 (PDT) From: Nick Connolly To: Anatoly Burakov , David Marchand , Olivier Matz , Didier Pallard , Nicolas Dichtel Cc: dev@dpdk.org, Nick Connolly , stable@dpdk.org Date: Mon, 12 Oct 2020 20:22:56 +0100 Message-Id: <20201012192256.3651-1-nick.connolly@mayadata.io> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-stable] [PATCH v2] mem: fix allocation failure on non-NUMA kernel X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.15 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 Sender: "stable" Running dpdk-helloworld on Linux with lib numa present, but no kernel support for NUMA (CONFIG_NUMA=n) causes ret_service_init() to fail with EAL: error allocating rte services array. alloc_seg() calls get_mempolicy to verify that the allocation has happened on the correct socket, but receives ENOSYS from the kernel and fails the allocation. The allocated socket should only be verified if check_numa() is true. Fixes: 2a96c88be83e ("mem: ease init in a docker container") Cc: nicolas.dichtel@6wind.com Cc: stable@dpdk.org Signed-off-by: Nick Connolly --- v2: * Remove unnecessary debug message and add explanatory comment lib/librte_eal/linux/eal_memalloc.c | 30 ++++++++++++++++++----------- 1 file changed, 19 insertions(+), 11 deletions(-) diff --git a/lib/librte_eal/linux/eal_memalloc.c b/lib/librte_eal/linux/eal_memalloc.c index 40a5c4aa1..6dc1b2bae 100644 --- a/lib/librte_eal/linux/eal_memalloc.c +++ b/lib/librte_eal/linux/eal_memalloc.c @@ -625,17 +625,25 @@ alloc_seg(struct rte_memseg *ms, void *addr, int socket_id, } #ifdef RTE_EAL_NUMA_AWARE_HUGEPAGES - ret = get_mempolicy(&cur_socket_id, NULL, 0, addr, - MPOL_F_NODE | MPOL_F_ADDR); - if (ret < 0) { - RTE_LOG(DEBUG, EAL, "%s(): get_mempolicy: %s\n", - __func__, strerror(errno)); - goto mapped; - } else if (cur_socket_id != socket_id) { - RTE_LOG(DEBUG, EAL, - "%s(): allocation happened on wrong socket (wanted %d, got %d)\n", - __func__, socket_id, cur_socket_id); - goto mapped; + /* + * If the kernel has been built without NUMA support, get_mempolicy() + * will return an error. If check_numa() returns false, memory + * allocation is not NUMA aware and the socket_id should not be + * checked. + */ + if (check_numa()) { + ret = get_mempolicy(&cur_socket_id, NULL, 0, addr, + MPOL_F_NODE | MPOL_F_ADDR); + if (ret < 0) { + RTE_LOG(DEBUG, EAL, "%s(): get_mempolicy: %s\n", + __func__, strerror(errno)); + goto mapped; + } else if (cur_socket_id != socket_id) { + RTE_LOG(DEBUG, EAL, + "%s(): allocation happened on wrong socket (wanted %d, got %d)\n", + __func__, socket_id, cur_socket_id); + goto mapped; + } } #else if (rte_socket_count() > 1) -- 2.25.1