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 0269542D46 for ; Sun, 25 Jun 2023 08:38:35 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id F1CB640ED8; Sun, 25 Jun 2023 08:38:34 +0200 (CEST) Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on2058.outbound.protection.outlook.com [40.107.93.58]) by mails.dpdk.org (Postfix) with ESMTP id 3BE3A40A7F for ; Sun, 25 Jun 2023 08:38:33 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=FAhRDk0GoU0A/22m8KkVMuUNN0cvkQxrDWtCIiC4zpTTHoBwRYUJlsj+4GfM75+c1G5PVU9PSoRDnFGw6obB0PVmNmxH14a23UPMch1RUdtg+C56rzejgY1yaEznFFeCIyqB3L81bF30X69Zsjqe/Kyx3gXqks0f6/SPAqKhZU11al3Bc2Hz93jWUOHC2SSjFf58qert4UZdfwga8daPcWM310b60xmIerzh4eEWy+tGI0jFM0oBupfEvVShHXgibnZcfZxhMoaESpzeflzlHQXcB2KvQ4UfljtQfflhs9YaDXP5sGUEd3qMKIibgzH0Kq8xp1O5nfppjS3ej4jPjg== 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=W2FCMf8fXIbaS5HCL7JnMSefjBhc0d4h1jSV8sK0eKk=; b=CjfQDiRDPPzJ0UkRw8yudprXXqH6fNgwAOocLvX6VjeHy1jibJYhloy2Vp3f3rU718jk5nl8WgKPSTNYPrRKpksdhCuJCDH/J73KW4VrAMrrDUDyTv8794AzHjdX4/kjWIdEbMXq5XMFqnjhSJcIWSpt3Zpz7VLkFEoABnxvaGsglypVYhZ2NMK6lS27lSziIGY8DmqIwyMELx0T0sbcimOHY9mBHdhTUUGK5PGSVDtiEvr8aJBu6f40SlJEdvJimASLPh5Zvf4Xpbd+MmNnrYeeEvlz7Suy50sBuJjR3rBU4ncMmAS/+UCFOFWYpytKAWsmqBxAKbmCpJz8Ef5RkA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.161) smtp.rcpttodomain=bytedance.com smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject 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=W2FCMf8fXIbaS5HCL7JnMSefjBhc0d4h1jSV8sK0eKk=; b=SeXjSw1aPMBKUFmysrALZbvt7LB+XX8grfKz3wLvQxUZmRXV4S5dMahwTVlTCv1h9kkFEfhAAKjn4ch9wQdo4fcawJhsYTw0sg8mXO76nUTMDb4B1Litdltc05IO+RPTPmksfd5kirrNVDwdaIHZHKJiLuTRe8G5S3DdltI9SAtx9yAbRKZs6UA2vTX44v2AjYnRIPnD0EtCKF76clFl9SqKd/KiEwZgvBwG5R6DkkW2s5pUKnoJfFn+2D6ThVaFXjdq+svM2LsA3rD2kM0O3jvkA4L0AHjcKzqgAQljABw/mqYlqcUr7KMcMAqdzLqcqSNIJfCr85jewYZBmKL1rQ== Received: from DM6PR06CA0032.namprd06.prod.outlook.com (2603:10b6:5:120::45) by CYYPR12MB8891.namprd12.prod.outlook.com (2603:10b6:930:c0::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6521.23; Sun, 25 Jun 2023 06:38:30 +0000 Received: from DM6NAM11FT003.eop-nam11.prod.protection.outlook.com (2603:10b6:5:120:cafe::69) by DM6PR06CA0032.outlook.office365.com (2603:10b6:5:120::45) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6521.32 via Frontend Transport; Sun, 25 Jun 2023 06:38:30 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.161) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.117.161 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.161; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.161) by DM6NAM11FT003.mail.protection.outlook.com (10.13.173.162) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6500.42 via Frontend Transport; Sun, 25 Jun 2023 06:38:30 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) by mail.nvidia.com (10.129.200.67) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.5; Sat, 24 Jun 2023 23:38:16 -0700 Received: from nvidia.com (10.126.230.35) by rnnvmail201.nvidia.com (10.129.68.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.37; Sat, 24 Jun 2023 23:38:15 -0700 From: Xueming Li To: Fengnan Chang CC: Lin Li , Anatoly Burakov , dpdk stable Subject: patch 'eal/linux: fix legacy mem init with many segments' has been queued to stable release 22.11.3 Date: Sun, 25 Jun 2023 14:34:03 +0800 Message-ID: <20230625063544.11183-26-xuemingl@nvidia.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230625063544.11183-1-xuemingl@nvidia.com> References: <20230625063544.11183-1-xuemingl@nvidia.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Originating-IP: [10.126.230.35] X-ClientProxiedBy: rnnvmail202.nvidia.com (10.129.68.7) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM6NAM11FT003:EE_|CYYPR12MB8891:EE_ X-MS-Office365-Filtering-Correlation-Id: 7975e04e-2b78-464c-156d-08db7546ca73 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: OYgNPBle8ErKhikWoGwsDrze8KAvoACgkHTyEQPJ9U1qcZ/iKPS5Telws5MkTDHdIfiZlSPYmNvzDmN6/LBdgY9PP+ctOnMKtSaS4QLKrZjp2TGLorSYUxktlVafQd3xdjOUJLFkR2kCO3mnZVe9lB7LyH9sNjEVGWt1TMLbQJhqpfnnBdeswNLlCU/N/NHX3fuMxj90PrXTm7qUyab4Hk/okq2GSSnWUeEtv9ZIK9+EkquTV8lS3/JkZKadcgrHpEMvZZvVesIe61XzkVevuaQCs8UHh1p4ByyI5rNEOH++xCYWW5kENetAboWiGobZzaFGFtFPIv8+GkPqDwiRPytq2sOGmaf8LvIaSiz2YfzTkpecOAE+yz7uVV1eRsdZuD2IYi5WHmWw+DmQuhEG8/LTEgV2FQNgFLyX2CFbcqueHya9d1vE3W7wZpZjOKCMV+CSb0LjTncYoxCeB4u7hTw22xJkM4AxoqSD5qsXNPL6msk7aK82CQOpP9lwrK4HYntf0b4m1G5O3fFFlpaIpp5JMIchsyyIe1VDmAyv12OEjScUePUrNS5Y8/x78zEaVolpi3tH2evohFi4fsNtP33mFLCjHb96FnKP3wT9ixXDrtpIKO4KfabbkzhhJPN/47j92dKREVTv/9K2+6sxu4KQUC1cP5RZRw310s67pmgo9JA045ir7HbPPelanVUdB/HLyXQ09AhR5U1pxShxLC4kNLv8o3tmgy91ikae8yUiU4CHo9QuIhnK/MLbCSFReOP7fCQb/SZ2RivULv+uyw== X-Forefront-Antispam-Report: CIP:216.228.117.161; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:mail.nvidia.com; PTR:dc6edge2.nvidia.com; CAT:NONE; SFS:(13230028)(4636009)(39860400002)(136003)(376002)(396003)(346002)(451199021)(40470700004)(36840700001)(46966006)(2906002)(82310400005)(7696005)(478600001)(70206006)(4326008)(70586007)(6666004)(36756003)(54906003)(40460700003)(316002)(86362001)(6916009)(2616005)(83380400001)(1076003)(55016003)(426003)(47076005)(186003)(16526019)(7636003)(356005)(82740400003)(5660300002)(53546011)(41300700001)(966005)(8676002)(36860700001)(8936002)(40480700001)(26005)(336012)(6286002); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Jun 2023 06:38:30.6195 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 7975e04e-2b78-464c-156d-08db7546ca73 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a; Ip=[216.228.117.161]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: DM6NAM11FT003.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CYYPR12MB8891 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 Hi, FYI, your patch has been queued to stable release 22.11.3 Note it hasn't been pushed to http://dpdk.org/browse/dpdk-stable yet. It will be pushed if I get no objections before 06/27/23. 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://git.dpdk.org/dpdk-stable/log/?h=22.11-staging This queued commit can be viewed at: https://git.dpdk.org/dpdk-stable/commit/?h=22.11-staging&id=10a2ee0333a41f1e9b40f9807dd93b3d51693ce6 Thanks. Xueming Li --- >From 10a2ee0333a41f1e9b40f9807dd93b3d51693ce6 Mon Sep 17 00:00:00 2001 From: Fengnan Chang Date: Mon, 29 May 2023 19:21:30 +0800 Subject: [PATCH] eal/linux: fix legacy mem init with many segments Cc: Xueming Li [ upstream commit 51a5a72e2a82986b02244fcdd89c6571bc503de3 ] Under legacy mode, if the number of continuous memsegs greater than RTE_MAX_MEMSEG_PER_LIST, eal init will failed even though another memseg list is empty, because only one memseg list used to check in remap_needed_hugepages. Fix this by make remap_segment return how many segments mapped, remap_segment try to map most contiguous segments it can, if it exceed its capacity, remap_needed_hugepages will continue to map other left pages. For example: hugepage configure: cat /sys/devices/system/node/node*/hugepages/hugepages-2048kB/nr_hugepages 10241 10239 startup log: EAL: Detected memory type: socket_id:0 hugepage_sz:2097152 EAL: Detected memory type: socket_id:1 hugepage_sz:2097152 EAL: Creating 4 segment lists: n_segs:8192 socket_id:0 hugepage_sz:2097152 EAL: Creating 4 segment lists: n_segs:8192 socket_id:1 hugepage_sz:2097152 EAL: Requesting 13370 pages of size 2MB from socket 0 EAL: Requesting 7110 pages of size 2MB from socket 1 EAL: Attempting to map 14220M on socket 1 EAL: Allocated 14220M on socket 1 EAL: Attempting to map 26740M on socket 0 EAL: Could not find space for memseg. Please increase 32768 and/or 65536 in configuration. EAL: Couldn't remap hugepage files into memseg lists EAL: FATAL: Cannot init memory EAL: Cannot init memory Fixes: 66cc45e293ed ("mem: replace memseg with memseg lists") Signed-off-by: Fengnan Chang Signed-off-by: Lin Li Reviewed-by: Anatoly Burakov --- .mailmap | 2 +- lib/eal/linux/eal_memory.c | 51 +++++++++++++++++++++++++++----------- 2 files changed, 37 insertions(+), 16 deletions(-) diff --git a/.mailmap b/.mailmap index 12939e3bff..e9b5482002 100644 --- a/.mailmap +++ b/.mailmap @@ -755,7 +755,7 @@ Liming Sun Linfan Hu Lingli Chen Lingyu Liu -Lin Li +Lin Li Linsi Yuan Lior Margalit Li Qiang diff --git a/lib/eal/linux/eal_memory.c b/lib/eal/linux/eal_memory.c index 60fc8cc6ca..0876974631 100644 --- a/lib/eal/linux/eal_memory.c +++ b/lib/eal/linux/eal_memory.c @@ -681,6 +681,7 @@ remap_segment(struct hugepage_file *hugepages, int seg_start, int seg_end) /* find free space in memseg lists */ for (msl_idx = 0; msl_idx < RTE_MAX_MEMSEG_LISTS; msl_idx++) { + int free_len; bool empty; msl = &mcfg->memsegs[msl_idx]; arr = &msl->memseg_arr; @@ -692,18 +693,26 @@ remap_segment(struct hugepage_file *hugepages, int seg_start, int seg_end) /* leave space for a hole if array is not empty */ empty = arr->count == 0; - ms_idx = rte_fbarray_find_next_n_free(arr, 0, - seg_len + (empty ? 0 : 1)); - - /* memseg list is full? */ + /* find start of the biggest contiguous block and its size */ + ms_idx = rte_fbarray_find_biggest_free(arr, 0); if (ms_idx < 0) continue; - + /* hole is 1 segment long, so at least two segments long. */ + free_len = rte_fbarray_find_contig_free(arr, ms_idx); + if (free_len < 2) + continue; /* leave some space between memsegs, they are not IOVA * contiguous, so they shouldn't be VA contiguous either. */ - if (!empty) + if (!empty) { ms_idx++; + free_len--; + } + + /* we might not get all of the space we wanted */ + free_len = RTE_MIN(seg_len, free_len); + seg_end = seg_start + free_len; + seg_len = seg_end - seg_start; break; } if (msl_idx == RTE_MAX_MEMSEG_LISTS) { @@ -787,7 +796,7 @@ remap_segment(struct hugepage_file *hugepages, int seg_start, int seg_end) } RTE_LOG(DEBUG, EAL, "Allocated %" PRIu64 "M on socket %i\n", (seg_len * page_sz) >> 20, socket_id); - return 0; + return seg_len; } static uint64_t @@ -1022,10 +1031,16 @@ remap_needed_hugepages(struct hugepage_file *hugepages, int n_pages) if (new_memseg) { /* if this isn't the first time, remap segment */ if (cur_page != 0) { - ret = remap_segment(hugepages, seg_start_page, - cur_page); - if (ret != 0) - return -1; + int n_remapped = 0; + int n_needed = cur_page - seg_start_page; + while (n_remapped < n_needed) { + ret = remap_segment(hugepages, seg_start_page, + cur_page); + if (ret < 0) + return -1; + n_remapped += ret; + seg_start_page += ret; + } } /* remember where we started */ seg_start_page = cur_page; @@ -1034,10 +1049,16 @@ remap_needed_hugepages(struct hugepage_file *hugepages, int n_pages) } /* we were stopped, but we didn't remap the last segment, do it now */ if (cur_page != 0) { - ret = remap_segment(hugepages, seg_start_page, - cur_page); - if (ret != 0) - return -1; + int n_remapped = 0; + int n_needed = cur_page - seg_start_page; + while (n_remapped < n_needed) { + ret = remap_segment(hugepages, seg_start_page, + cur_page); + if (ret < 0) + return -1; + n_remapped += ret; + seg_start_page += ret; + } } return 0; } -- 2.25.1 --- Diff of the applied patch vs upstream commit (please double-check if non-empty: --- --- - 2023-06-25 14:31:59.203715500 +0800 +++ 0025-eal-linux-fix-legacy-mem-init-with-many-segments.patch 2023-06-25 14:31:58.305773900 +0800 @@ -1 +1 @@ -From 51a5a72e2a82986b02244fcdd89c6571bc503de3 Mon Sep 17 00:00:00 2001 +From 10a2ee0333a41f1e9b40f9807dd93b3d51693ce6 Mon Sep 17 00:00:00 2001 @@ -4,0 +5,3 @@ +Cc: Xueming Li + +[ upstream commit 51a5a72e2a82986b02244fcdd89c6571bc503de3 ] @@ -38 +40,0 @@ -Cc: stable@dpdk.org @@ -49 +51 @@ -index 13167dc28b..853a89e9a4 100644 +index 12939e3bff..e9b5482002 100644 @@ -52 +54 @@ -@@ -766,7 +766,7 @@ Liming Sun +@@ -755,7 +755,7 @@ Liming Sun