From patchwork Thu Feb 27 22:45:04 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Prescher via B4 Relay X-Patchwork-Id: 13995317 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9A89CC19F32 for ; Thu, 27 Feb 2025 22:45:20 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 9C4936B0098; Thu, 27 Feb 2025 17:45:16 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 950486B0099; Thu, 27 Feb 2025 17:45:16 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 6B58728000E; Thu, 27 Feb 2025 17:45:16 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 3E0FA6B009A for ; Thu, 27 Feb 2025 17:45:16 -0500 (EST) Received: from smtpin02.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 989EF81EDA for ; Thu, 27 Feb 2025 22:45:15 +0000 (UTC) X-FDA: 83167206990.02.F69D2FC Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf29.hostedemail.com (Postfix) with ESMTP id 9786A120016 for ; Thu, 27 Feb 2025 22:45:13 +0000 (UTC) Authentication-Results: imf29.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=JVRoFttn; spf=pass (imf29.hostedemail.com: domain of devnull+thomas.prescher.cyberus-technology.de@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=devnull+thomas.prescher.cyberus-technology.de@kernel.org; dmarc=pass (policy=quarantine) header.from=kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1740696313; h=from:from:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding:in-reply-to: references:dkim-signature; bh=OqOFKn9PE8EWnDLG4/cTCsceLyHIb1uO9jB0+C3ipS0=; b=ExP0PWkStb7PKUrpU66wu1blFrA2qiSZEsGNi1d5bypq0h82JvL5p/mI7ecog0y2oVkKWF 8q3nKsFV1pQ0J9bjRuBTJlEp52DHpWJKqBd3jlc/7MBtjMSMtHq+eOhaxUcUrR7xTJ5RTB fT1jIaKfAy1mefpDWgMrmmt+cHeekb4= ARC-Authentication-Results: i=1; imf29.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=JVRoFttn; spf=pass (imf29.hostedemail.com: domain of devnull+thomas.prescher.cyberus-technology.de@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=devnull+thomas.prescher.cyberus-technology.de@kernel.org; dmarc=pass (policy=quarantine) header.from=kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1740696313; a=rsa-sha256; cv=none; b=B1kH7qQ9xq9DBiSyqwe9OhRm+WrMG8wVPjILlb5SmlFAPmNUamGH4frZyL1sIJ1h51dCRs wUNz60axqZtTSLkYcXqKXrZ0hgLu5x3A1lQj6BOefv7Dis9e9LVM6sFowFaP9rwgPbLhH4 ITpV31Uw/iardLlsOu3wg3m/AcQBC5M= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id B58635C54E0; Thu, 27 Feb 2025 22:42:55 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPS id 348F5C4CEDD; Thu, 27 Feb 2025 22:45:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1740696312; bh=vyI324UstKdb+sPeA7ZVxzdeYYc4q0ETxwlx7afOJj0=; h=From:Subject:Date:To:Cc:Reply-To:From; b=JVRoFttntSy8BDnASQm2Yt1yzazAUyUMO7LKX5HhXubbciovrtvH1IAbPjqLTr82m aSoZF56CuEPseFzy3X98MbqtU7zwqTr3+jbEQSr7s2AqF3vjgUpjeOBZ6MYK9yTHD4 rTg+S241JSg+9lLgASju6UVJIEr6E+cyS4SeYmq9evTBOHUuESZAN2BLKmsN2OCKyw +NrO3GKqMDbcs3bYVeF+WJkaJHr6s5olZwihbLFV6bbcrAdiD1PW1FswPgRaNjfnIF /YOS1oP2Pq79S38BTTjB3B8q0WEvLCOLyEX5jsm2Uktzt4DA2LOMAECJbS659qobHP JZUzg6OcIuF5A== Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 24195C19F32; Thu, 27 Feb 2025 22:45:12 +0000 (UTC) From: Thomas Prescher via B4 Relay Subject: [PATCH v2 0/3] Add a command line option that enables control of how many threads should be used to allocate huge pages. Date: Thu, 27 Feb 2025 23:45:04 +0100 Message-Id: <20250227-hugepage-parameter-v2-0-7db8c6dc0453@cyberus-technology.de> MIME-Version: 1.0 X-B4-Tracking: v=1; b=H4sIAPDqwGcC/32NQQqDMBREr1L+uikxKNqueo/i4jdOTKA18qNSE e/e1AMUZvMG5s1GCRKQ6HbaSLCEFOKQwZxPZD0PPVToMpPRptLGFMrPPUbO/cjCb0wQhaYqjeu c1QzKw1HgwueQPtrMPqQpynp8LMWv/atbCqWV4/LKdW2bnLtdn5A5qQnWD/EV+/XSgdp937/Dc nztwAAAAA== X-Change-ID: 20250221-hugepage-parameter-e8542fdfc0ae To: Jonathan Corbet , Muchun Song , Andrew Morton Cc: linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, Thomas Prescher X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1740696310; l=2765; i=thomas.prescher@cyberus-technology.de; s=20250221; h=from:subject:message-id; bh=vyI324UstKdb+sPeA7ZVxzdeYYc4q0ETxwlx7afOJj0=; b=2E9xalrcukB26zkYXKEmd8MK9+5Hm2Nw6sahJY/gUgW5omPB2dru8Oglq0//8NXb4plBesUQX Ph+Ustmqi3KACr2cGPCLtUBNkcDy/KHnj7Nr7nZ54anKrENwDPbHKsa X-Developer-Key: i=thomas.prescher@cyberus-technology.de; a=ed25519; pk=T5MVdLVCc/0UUyv5IcSqGVvGcVkgWW/KtuEo2RRJwM8= X-Endpoint-Received: by B4 Relay for thomas.prescher@cyberus-technology.de/20250221 with auth_id=345 X-Original-From: Thomas Prescher Reply-To: thomas.prescher@cyberus-technology.de X-Rspam-User: X-Rspamd-Server: rspam10 X-Rspamd-Queue-Id: 9786A120016 X-Stat-Signature: nqms4naoiosdqm5sdncsp61cy7d73fry X-HE-Tag: 1740696313-123543 X-HE-Meta: U2FsdGVkX1/O6sgHoHhipVV0uQrLwkPr+HrNqnsIKC65yS2bq41Etaedny+h0tj01TQNCHX7K0gc+HhLZq9ZWnQp9trSczt+V4Zn5OFVI4KYyjLDkJLXAzv112LEXOG/8RD9v5MOjTsbsng8waLhQT/qCsSkzhdcNvx5dlyuRjzzdyUZihnzInrJ6452cEaVR4uDp3UK99KFdvxKewVrV5b8/cM1dhhgYzulso7FuownnuCmWNeJ6S3j4zNuTvIuxYA+DUNxkbAcNgetZVTivQ6LEL2ZduEUz4MMkZcPJnD86G/njeLC81N7LNpcPGHXiS4XWRJtFKdl1gt6+FmjghK6qv7/SXJtlVwgyzD/HFjkwdQthB4qnnhQtL9+rxDblifRi2/v9gR1IZO5uEHDrEwqhp2o8U2feppb4RMP3OTsb93dRyrSDe/Bt0+AGaoDQMr3CW6ZNsGA4lzJYAPGEIt00yhjBJQJg1UGA1aH+ygG0twkfVKKrcCOG3LLWt9MANFZUxhXlnEYo/CbwiFwjci00jpftDynj0/H/IomnxQuNZyQDFHsK1BASQWrXvluFfwQ9lONSvhtm8zfBB/bX+QoDuQzqmIElYYuzyD4qJMAJLsGM0c+kY8MUBPJMzjCB3/BTNoL6AqziiGB+t4osDGkuGvStR9yWoXc4n402RFHBgBXnxAKF0196uHg+BhZHjEy46FExtHOC1yEB1gq4l37R0tThWa29yEPZ4FtG2FDBSWhx6JzlZp4D/5rqOu9NYUMSXmsAEszEmT1T3pGZdeP6K1Za/crzrtVGC5mcHtMeFuWg3e1u9eBtcaqw2t+tc4IwaouNoqPjJ5aQa6YUt59LJeBFLHfssnBD1JjiGHFkkT0A7emrQ81Bw/WXocm/s/rJI8u/yMSVeQRokZ+YRN6jFFn1bajeSkJLBlUytX9AQXEnLNIbtj81cFvGObAYaLQHYwsQbiOfyGOis9 uC7m4jPz Qin2MiJDyXaD0O3thS4QkWnRoN+3SrHyFCZ/sMa6wpMWjsCSeySnWQosQTfdM2bSfsVXos8RHw9gH964KloL0hHookuZj2ibBLYfzZczaaJ4uDIvSxRlJHJFCdHf193ZNP2sXeGTc9jRFqA3RGlu7GSnQga08Mn2wi+45oGSro0JRPcf7legyDQq8nlUmnbDexLTYEey6D/r1Av+FDLWI/rY2vjnK5f3O4GsvhuR/Z+n5wI+nnfML+7M2Rs89NV2U4GS7Ww4xvik+P2xXQvNM2lQZ5Wpt+i1PRNyl9xXF4w0OznYVIRg5Nn+VUC4qJkIie3cLR+BmXlyOnL6IO0nQ3VVS2352hOkbENskBG1N14vdj+hranUsmkR7rLrvdI3HKoN3VulmhlP8i1H+NHBqBFB73BCuCl26UBFWLEKqT6WAdU+iBOHneZs+/PAiO3/q2TOm2R9hyj++FeXFIsi3gxIj+7vdqmvcYgMP4kK7cZJmt3A= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000048, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: Allocating huge pages can take a very long time on servers with terabytes of memory even when they are allocated at boot time where the allocation happens in parallel. Before this series, the kernel used a hard coded value of 2 threads per NUMA node for these allocations. This value might have been good enough in the past but it is not sufficient to fully utilize newer systems. This series changes the default so the kernel uses 25% of the available hardware threads for these allocations. In addition, we allow the user that wish to micro-optimize the allocation time to override this value via a new kernel parameter. We tested this on 2 generations of Xeon CPUs and the results show a big improvement of the overall allocation time. +-----------------------+-------+-------+-------+-------+-------+ | threads | 8 | 16 | 32 | 64 | 128 | +-----------------------+-------+-------+-------+-------+-------+ | skylake 144 cpus | 44s | 22s | 16s | 19s | 20s | | cascade lake 192 cpus | 39s | 20s | 11s | 10s | 9s | +-----------------------+-------+-------+-------+-------+-------+ On skylake, we see an improvment of 2.75x when using 32 threads, on cascade lake we can get even better at 4.3x when we use 128 threads. This speedup is quite significant and users of large machines like these should have the option to make the machines boot as fast as possible. Signed-off-by: Thomas Prescher --- Changes in v2: - the default thread value has been changed from 2 threads per node to 25% of the available hardware threads - the hugepage_alloc_threads parameter now specifies the total number of threads being used instead of threads per node - the kernel now logs the time needed to allocate the huge pages and the number of threads being used - update the documentation so that users are aware that this does not apply to non-gigantic huge pages - Link to v1: https://lore.kernel.org/r/20250221-hugepage-parameter-v1-0-fa49a77c87c8@cyberus-technology.de --- Thomas Prescher (3): mm: hugetlb: improve parallel huge page allocation time mm: hugetlb: add hugetlb_alloc_threads cmdline option mm: hugetlb: log time needed to allocate hugepages Documentation/admin-guide/kernel-parameters.txt | 9 ++++ Documentation/admin-guide/mm/hugetlbpage.rst | 10 ++++ mm/hugetlb.c | 67 +++++++++++++++++++------ 3 files changed, 70 insertions(+), 16 deletions(-) --- base-commit: dd83757f6e686a2188997cb58b5975f744bb7786 change-id: 20250221-hugepage-parameter-e8542fdfc0ae Best regards,