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 2BB77A04B6 for ; Mon, 12 Oct 2020 21:28:18 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id F2D7A1D997; Mon, 12 Oct 2020 21:28:16 +0200 (CEST) Received: from mail-wr1-f66.google.com (mail-wr1-f66.google.com [209.85.221.66]) by dpdk.org (Postfix) with ESMTP id D7F871D997 for ; Mon, 12 Oct 2020 21:28:15 +0200 (CEST) Received: by mail-wr1-f66.google.com with SMTP id y12so15186359wrp.6 for ; Mon, 12 Oct 2020 12:28:15 -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:in-reply-to:references :mime-version:content-transfer-encoding; bh=azNjTOpKOEHIgF0hOEAWjXHDFivKHd2GKaHJtT/Zpzk=; b=AASUHrILFCIF1HkWtInuyohaOl8zNlJdhHEoU9xxfPqRudVlEEKoTrTdBx+CC8nFnf nr12bSMMb1ah1Z8PXN04rCbaMiK8Gq6MUiWfcMvqOsE5Qnm5nJ1x6xRbaN1bJYfHs7Rc 90hZDYbJ6XS6ei8UwsNUwm24V+uvH0U+pe0jjmKAHNxn0iMMijEIzLaTwAMsZeKyB0T4 Ut3YpfpAchxdTNsU4gCA681sIw2vUSAOkz4N3fnHxRMsJtVvOo50rEndKLXUm8/X+rBE UU43bFYqnzCfaGRUegEVpk3TSv4gmA3GLihXT4Mpvfb6YysMw2XKCrjzyuSpC1m1oWmj 1MUQ== 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=azNjTOpKOEHIgF0hOEAWjXHDFivKHd2GKaHJtT/Zpzk=; b=EfDdQK92EGX8Td3SgQM7Oi/NEzjGdAX7935XwyMdL3SNa1dPnPcyyDRRj6gzsEuyBF 5K714mTa6u2RWRG16P62OD2W0QfJN3sMwJJDeFcMTbY3TZ3Ot/xHbQ4uU34Ku+X5zTcc WQzt+cSyv+sVEaVXDqaIAEguV/OfB5zoe2pgLVufSoEz+QT5ICr+AjLInTOU8gNlfgQ2 5mOhdKFLP0+Mzm3yheu+kn817suKr4Qp2j616pbmG3N3ce2x4igTdF+wZtlGd4IZb4xQ kTcTL5qqXua3tHo58/b4wAqagNKTCp9976SZGIZVsoG5m95eQnQmFluGJPoRxFC5JtBQ KjSw== X-Gm-Message-State: AOAM530KdE+YzNYzjrOOtrSBG9CPpJQjRxbUF/OernTnMA9F7Y9FHN09 4hDyxh7oACMv0xegFJoI0UGFQA== X-Google-Smtp-Source: ABdhPJwxTZaPuDMNLhAroTIpIUuoAnZxPxjbUdgUltH7NWKarjELbond/DZ4xYTjaT+djwy4/1nTEw== X-Received: by 2002:adf:8285:: with SMTP id 5mr30625204wrc.330.1602530894334; Mon, 12 Oct 2020 12:28:14 -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 b7sm1478285wrp.16.2020.10.12.12.28.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Oct 2020 12:28:13 -0700 (PDT) From: Nick Connolly To: Anatoly Burakov , Didier Pallard , Olivier Matz , Nicolas Dichtel , David Marchand Cc: dev@dpdk.org, Nick Connolly , stable@dpdk.org Date: Mon, 12 Oct 2020 20:28:03 +0100 Message-Id: <20201012192803.3741-1-nick.connolly@mayadata.io> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200805122640.13884-1-nick.connolly@mayadata.io> References: <20200805122640.13884-1-nick.connolly@mayadata.io> 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