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 B51EDA0C41 for ; Wed, 10 Nov 2021 07:55:31 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id A73134111A; Wed, 10 Nov 2021 07:55:31 +0100 (CET) Received: from NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11on2074.outbound.protection.outlook.com [40.107.236.74]) by mails.dpdk.org (Postfix) with ESMTP id A7FDC410E0 for ; Wed, 10 Nov 2021 07:55:30 +0100 (CET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=A+o0phGkCUmN4rtaQ9vhwsICbkeS0hXlD/nMuwS7nX61uopAr61TEHvUixmoBAHaMWGWhVsBrY8c5fnZiTbZHLPKpcnkB3Pr6vPXiwWFcDVHdwpAxY3dAiDqHP43Rpz/RalRBStF9J/Y7uddxlr9viu2R7knBWbqbYzPakDE7ReplratQOTz+rJnY+trFu1f8no7ZlixqNwYNKHIrfzfy/+lynWNCHZMCbd+EAf8gEC+vtRsUhd+bZtavO0ZsAU5/YnsMW0PzQfM4QLWQTq8YxRu3HkJ3AZuKCv7p07xdiWZmIvmJ8dLXKcShHNTzX/O9KasQSnJjtMKduPmrBXj4A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=1xtUNp3aKFR6RrsM23p/UXzaRVPAZZUJv2fYxu7t3JM=; b=R9C/r/1QBgxxLD9/Ss0ENvfjecG5HnHJW/5Op3lnsgiOwq/XNDES0/xydglOpSjuyWcqlSxEt2FcZw/Ervy9f9Phy8nkuGNIWmRXaerlzCw5dyrTnF+Pv2BiuknLkqF5w92yoVH+eBaf3tvp1up/QKdT/iXg8HRUyo/h57mdd8/9sdFUgeM5L+SgR85i1BSwQ9KzbcFC/ZI/8RP1XWl1V6p3XTQDui5arg82Fksa3XiQviqwaLwG95QTMAIezttOEVP426ggKeEwFRDpX1LdMFCYfJbvWmWf2BWCOYmHqd1rtcEt3gOiSJ5ORYxqqPOgvXtro6fP4do39Y60v2CD7Q== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.112.34) smtp.rcpttodomain=redhat.com smtp.mailfrom=nvidia.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=1xtUNp3aKFR6RrsM23p/UXzaRVPAZZUJv2fYxu7t3JM=; b=YMZ+uGWEVgHO7RSwIiy5Mpz/oUi9c0KhP90LXNtUcD2xKVwENwBve1usFt2+3BvuljSogA9FZzgt3/zbgmMnqE7BsjzXBOnHm4S2Qc1F8ZmATCHMRxVWesR0ZSEREVsY2VGeKxYh8ZcCP50cnWC6vbFIfY5P2DMNPJMUUyGhirFgDEGxAP7hHIrbHvCdv75pZLMh5XeQKpVJ2g5J1ImLRnLLSqmVpyRdhGGILEWZ2y50sfAfA3j5l9WxeGPVnoWJ/ahZI7mK6eK3WpR4JQqFCtduGDLFnJCUa3djMN+15hM3Vxn6y/9OAgxz2Ok5F5oHJ0MlgzcgeqoXA9pBBqewLA== Received: from DM6PR02CA0153.namprd02.prod.outlook.com (2603:10b6:5:332::20) by BN8PR12MB4626.namprd12.prod.outlook.com (2603:10b6:408:72::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4669.15; Wed, 10 Nov 2021 06:55:29 +0000 Received: from DM6NAM11FT030.eop-nam11.prod.protection.outlook.com (2603:10b6:5:332:cafe::83) by DM6PR02CA0153.outlook.office365.com (2603:10b6:5:332::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4690.15 via Frontend Transport; Wed, 10 Nov 2021 06:55:29 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.112.34) smtp.mailfrom=nvidia.com; redhat.com; dkim=none (message not signed) header.d=none;redhat.com; dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.112.34 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.112.34; helo=mail.nvidia.com; Received: from mail.nvidia.com (216.228.112.34) by DM6NAM11FT030.mail.protection.outlook.com (10.13.172.146) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.4690.15 via Frontend Transport; Wed, 10 Nov 2021 06:55:29 +0000 Received: from nvidia.com (172.20.187.6) by HQMAIL107.nvidia.com (172.20.187.13) with Microsoft SMTP Server (TLS) id 15.0.1497.18; Wed, 10 Nov 2021 06:55:26 +0000 From: Xueming Li To: Ilyes Ben Hamouda CC: Luca Boccassi , Olivier Matz , David Marchand , dpdk stable Date: Wed, 10 Nov 2021 14:31:33 +0800 Message-ID: <20211110063216.2744012-210-xuemingl@nvidia.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20211110063216.2744012-1-xuemingl@nvidia.com> References: <20211110063216.2744012-1-xuemingl@nvidia.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Originating-IP: [172.20.187.6] X-ClientProxiedBy: HQMAIL101.nvidia.com (172.20.187.10) To HQMAIL107.nvidia.com (172.20.187.13) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: e5a1cb2a-bf9f-47c5-4d70-08d9a41714ed X-MS-TrafficTypeDiagnostic: BN8PR12MB4626: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:10000; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 7MxxNjXTqRmDjOJ2Rvr8ihCfz5T5lMTQfunjgu/fL7H89erOVKkPfTa3Rzvpk72YquGbxciDJyGXOOWYeXfRAHK/55DzB1U8c2RxdbMFEAKpNSvUZ/7Wut2VtQKRHOz+cr5HIeSlg9+Ro3LvJ3DSE/B3Vb8eQtiaT0f7VUFioZkRDVQRc5x/Ez3AVOyNy0aBu+JbkXCy9YERbvXWdGVQR6Y7KRgMS24Fh2fTVWoVpQj5I68bDY7nIuRI8p78pI3PIZdyut48NNidoUT8WfUuBLla5Jb+UNcBa9g/q5H2cKKJndBOpeUe4Gn+1FeqzQABrk3Q0FLTpmr5M2DwS8HklzGkD3OQuW/TvmY8vbr4mRAGGV+0X9GmmmTVHJLV/D2TmIvVmaH3y0oo0BozjxtSrVcXs6MCZb02+mTO7vec4W+h8BHH6IqK6HuVC2iuUyPpzviAUQ/LQdoFeQ4NxDKZE6RYXRX0KSxj57aBRojK+5dkvztmdrPZgligfVop1pC9ssY80OfKuTOHKtEIWdbbV5BB21KyvBbZg3CEpdti8bV4etAfFTWOFuyLqbtT3wAYheQ/okEfBxRsMILmsFK/puIBJd1OqhB3YnLdUq4mYswugtX+YtesK+ydq3yzjaYr3G7BHD0fhnkbUwQ+zp1TwB9c34dpnHeTR4GI8wx3naqC4wYz8nmiAeGVYP/aHeDLye/eREFDrAFhWgRk3hUFHYri65qZrak3Gqw/3UcDkW4DqeiGMUkd3Q2UwBpfPPqi0rKNxta13CrUtYGtlQlnuUXzNfxeNzJWSZLYBSCd2FxoqEP/b8PlhoNmUbDvwUvKj6BX67kwnX6XRHkqTQ3wYA== X-Forefront-Antispam-Report: CIP:216.228.112.34; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:mail.nvidia.com; PTR:schybrid03.nvidia.com; CAT:NONE; SFS:(4636009)(46966006)(36840700001)(54906003)(1076003)(4326008)(83380400001)(16526019)(2616005)(53546011)(6666004)(5660300002)(356005)(8676002)(316002)(47076005)(82310400003)(8936002)(2906002)(7636003)(426003)(6916009)(4001150100001)(36860700001)(36906005)(6286002)(26005)(336012)(70586007)(86362001)(55016002)(508600001)(70206006)(966005)(186003)(7696005)(36756003); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Nov 2021 06:55:29.0715 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: e5a1cb2a-bf9f-47c5-4d70-08d9a41714ed X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a; Ip=[216.228.112.34]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: DM6NAM11FT030.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN8PR12MB4626 Subject: [dpdk-stable] patch 'malloc: fix allocation with unknown socket ID' has been queued to stable release 20.11.4 X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.29 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" Hi, FYI, your patch has been queued to stable release 20.11.4 Note it hasn't been pushed to http://dpdk.org/browse/dpdk-stable yet. It will be pushed if I get no objections before 11/12/21. So please shout if anyone has objections. Also note that after the patch there's a diff of the upstream commit vs the patch applied to the branch. This will indicate if there was any rebasing needed to apply to the stable branch. If there were code changes for rebasing (ie: not only metadata diffs), please double check that the rebase was correctly done. Queued patches are on a temporary branch at: https://github.com/steevenlee/dpdk This queued commit can be viewed at: https://github.com/steevenlee/dpdk/commit/3f1ba3396e6701e20eb4b2eead4ca4c36629e5fb Thanks. Xueming Li --- >From 3f1ba3396e6701e20eb4b2eead4ca4c36629e5fb Mon Sep 17 00:00:00 2001 From: Ilyes Ben Hamouda Date: Fri, 29 Oct 2021 11:49:29 +0200 Subject: [PATCH] malloc: fix allocation with unknown socket ID Cc: Xueming Li [ upstream commit 770d41bf33090462319c765c86a4c1979dc2a148 ] When using rte_malloc() from a thread which is not bound to a numa socket (the typical case is a control thread, but it can also happen on a dataplane thread if its cpu affinity is on cores attached to several sockets), the used heap is the one from numa socket 0, which may not have available memory. Fix this by selecting the first socket which has available memory. Note: malloc_get_numa_socket() is only used from one .c file, so move it there, and remove the inline keyword. Fixes: b94580d6887e ("malloc: avoid unknown socket id") Signed-off-by: Ilyes Ben Hamouda Signed-off-by: Olivier Matz Acked-by: David Marchand --- lib/librte_eal/common/malloc_heap.c | 20 ++++++++++++++++++++ lib/librte_eal/common/malloc_heap.h | 11 ----------- 2 files changed, 20 insertions(+), 11 deletions(-) diff --git a/lib/librte_eal/common/malloc_heap.c b/lib/librte_eal/common/malloc_heap.c index 5a09247a65..350ff97ee0 100644 --- a/lib/librte_eal/common/malloc_heap.c +++ b/lib/librte_eal/common/malloc_heap.c @@ -693,6 +693,26 @@ alloc_unlock: return ret; } +static unsigned int +malloc_get_numa_socket(void) +{ + const struct internal_config *conf = eal_get_internal_configuration(); + unsigned int socket_id = rte_socket_id(); + unsigned int idx; + + if (socket_id != (unsigned int)SOCKET_ID_ANY) + return socket_id; + + /* for control threads, return first socket where memory is available */ + for (idx = 0; idx < rte_socket_count(); idx++) { + socket_id = rte_socket_id_by_idx(idx); + if (conf->socket_mem[socket_id] != 0) + return socket_id; + } + + return rte_socket_id_by_idx(0); +} + void * malloc_heap_alloc(const char *type, size_t size, int socket_arg, unsigned int flags, size_t align, size_t bound, bool contig) diff --git a/lib/librte_eal/common/malloc_heap.h b/lib/librte_eal/common/malloc_heap.h index 772736b53f..dfd57e6a56 100644 --- a/lib/librte_eal/common/malloc_heap.h +++ b/lib/librte_eal/common/malloc_heap.h @@ -37,17 +37,6 @@ struct malloc_heap { extern "C" { #endif -static inline unsigned -malloc_get_numa_socket(void) -{ - unsigned socket_id = rte_socket_id(); - - if (socket_id == (unsigned)SOCKET_ID_ANY) - return 0; - - return socket_id; -} - void * malloc_heap_alloc(const char *type, size_t size, int socket, unsigned int flags, size_t align, size_t bound, bool contig); -- 2.33.0 --- Diff of the applied patch vs upstream commit (please double-check if non-empty: --- --- - 2021-11-10 14:17:11.145362466 +0800 +++ 0209-malloc-fix-allocation-with-unknown-socket-ID.patch 2021-11-10 14:17:02.017411557 +0800 @@ -1 +1 @@ -From 770d41bf33090462319c765c86a4c1979dc2a148 Mon Sep 17 00:00:00 2001 +From 3f1ba3396e6701e20eb4b2eead4ca4c36629e5fb Mon Sep 17 00:00:00 2001 @@ -4,0 +5,3 @@ +Cc: Xueming Li + +[ upstream commit 770d41bf33090462319c765c86a4c1979dc2a148 ] @@ -18 +20,0 @@ -Cc: stable@dpdk.org @@ -24,2 +26,2 @@ - lib/eal/common/malloc_heap.c | 20 ++++++++++++++++++++ - lib/eal/common/malloc_heap.h | 11 ----------- + lib/librte_eal/common/malloc_heap.c | 20 ++++++++++++++++++++ + lib/librte_eal/common/malloc_heap.h | 11 ----------- @@ -28,5 +30,5 @@ -diff --git a/lib/eal/common/malloc_heap.c b/lib/eal/common/malloc_heap.c -index 775d6789df..55aad2711b 100644 ---- a/lib/eal/common/malloc_heap.c -+++ b/lib/eal/common/malloc_heap.c -@@ -699,6 +699,26 @@ alloc_unlock: +diff --git a/lib/librte_eal/common/malloc_heap.c b/lib/librte_eal/common/malloc_heap.c +index 5a09247a65..350ff97ee0 100644 +--- a/lib/librte_eal/common/malloc_heap.c ++++ b/lib/librte_eal/common/malloc_heap.c +@@ -693,6 +693,26 @@ alloc_unlock: @@ -59,7 +61,7 @@ -diff --git a/lib/eal/common/malloc_heap.h b/lib/eal/common/malloc_heap.h -index 3a6ec6ecf0..3a29d024b4 100644 ---- a/lib/eal/common/malloc_heap.h -+++ b/lib/eal/common/malloc_heap.h -@@ -33,17 +33,6 @@ struct malloc_heap { - char name[RTE_HEAP_NAME_MAX_LEN]; - } __rte_cache_aligned; +diff --git a/lib/librte_eal/common/malloc_heap.h b/lib/librte_eal/common/malloc_heap.h +index 772736b53f..dfd57e6a56 100644 +--- a/lib/librte_eal/common/malloc_heap.h ++++ b/lib/librte_eal/common/malloc_heap.h +@@ -37,17 +37,6 @@ struct malloc_heap { + extern "C" { + #endif