From patchwork Fri Nov 8 04:12:58 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Baolin Wang X-Patchwork-Id: 13867522 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 92BD3D5E127 for ; Fri, 8 Nov 2024 04:13:40 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B8CCB6B00B4; Thu, 7 Nov 2024 23:13:32 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id B3F296B00B6; Thu, 7 Nov 2024 23:13:32 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 9E2A28E0001; Thu, 7 Nov 2024 23:13:32 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 80E5D8D0002 for ; Thu, 7 Nov 2024 23:13:32 -0500 (EST) Received: from smtpin02.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 4395BC08A7 for ; Fri, 8 Nov 2024 04:13:32 +0000 (UTC) X-FDA: 82761608244.02.6B76531 Received: from out30-131.freemail.mail.aliyun.com (out30-131.freemail.mail.aliyun.com [115.124.30.131]) by imf24.hostedemail.com (Postfix) with ESMTP id 1952918000A for ; Fri, 8 Nov 2024 04:13:24 +0000 (UTC) Authentication-Results: imf24.hostedemail.com; dkim=pass header.d=linux.alibaba.com header.s=default header.b="eTTbWeE/"; dmarc=pass (policy=none) header.from=linux.alibaba.com; spf=pass (imf24.hostedemail.com: domain of baolin.wang@linux.alibaba.com designates 115.124.30.131 as permitted sender) smtp.mailfrom=baolin.wang@linux.alibaba.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1731039150; a=rsa-sha256; cv=none; b=v3jCBQPy8CsOzobHtSq2QJFK79ov9QiBUCdx2401UXmOmWa+/mf7Fa2y7YexPwQboiB0lq tHE2o/V+bR2KmjmM4PhZk6GM/uBPastdrZq6D8O7kgPtF/SxKhfzf7MRMPc+AO2KiBTjn2 FGRqNcFAJl8aGIWRBNBZ1opkpMaaYHg= ARC-Authentication-Results: i=1; imf24.hostedemail.com; dkim=pass header.d=linux.alibaba.com header.s=default header.b="eTTbWeE/"; dmarc=pass (policy=none) header.from=linux.alibaba.com; spf=pass (imf24.hostedemail.com: domain of baolin.wang@linux.alibaba.com designates 115.124.30.131 as permitted sender) smtp.mailfrom=baolin.wang@linux.alibaba.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1731039150; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=ZMgQiGlmb/wE6nW4qxF+A3bZ7Id2I6Bajbakd8brhAI=; b=gPNbWz7xdtT2bJHQlo7ZGDBPeoA+flbe18bKHRc9Uk94844oWKyx/Xtut7gYGylu0qzOVW nzUY5EorMW9KdpaXNJQQUAFkXXkYoAkD/9iEnS70P8TlwpIUepXJp9DARx7D43dnjQmxJb XFR8K/FJxd9wvP5yWwCZSHXGXlzXgKc= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.alibaba.com; s=default; t=1731039207; h=From:To:Subject:Date:Message-Id:MIME-Version; bh=ZMgQiGlmb/wE6nW4qxF+A3bZ7Id2I6Bajbakd8brhAI=; b=eTTbWeE/Og09/TA5S1rB7dBdBCU8WCHWnJgeMsyEiV4k+RFFVSwYTwyejBpJ70cJQ1Q3LOX78MhoEOeZ4wEJCB1+F8NmYFeMEE4CB+mesUshR2iyAH7XJSF2BMebPQu07KiRSMof+kK4qbbT9lqltS5yvOw6tNpZP7xsLfeJFD4= Received: from localhost(mailfrom:baolin.wang@linux.alibaba.com fp:SMTPD_---0WIxRHWz_1731039206 cluster:ay36) by smtp.aliyun-inc.com; Fri, 08 Nov 2024 12:13:26 +0800 From: Baolin Wang To: akpm@linux-foundation.org, hughd@google.com Cc: willy@infradead.org, david@redhat.com, wangkefeng.wang@huawei.com, 21cnbao@gmail.com, ryan.roberts@arm.com, ioworker0@gmail.com, da.gomez@samsung.com, baolin.wang@linux.alibaba.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH 4/4] docs: tmpfs: update the huge folios policy for tmpfs and shmem Date: Fri, 8 Nov 2024 12:12:58 +0800 Message-Id: X-Mailer: git-send-email 2.39.3 In-Reply-To: References: MIME-Version: 1.0 X-Rspam-User: X-Rspamd-Queue-Id: 1952918000A X-Rspamd-Server: rspam11 X-Stat-Signature: ijoyq1ccy9gxcoxop7jw1haszrkgjq8a X-HE-Tag: 1731039204-873785 X-HE-Meta: U2FsdGVkX19DT4R4EyJ75pxXvFDC8ZOAXz+p7ZkKBzwLz2/629Q7TyYhgfLoi7Y7w2A9xOdtgBhuTXRBsEsnEldk+Aqav3vysaE6hYRI7TIeDUWVINE1JPM7G3W5f+eXYViT4H/tDsJN1KuaTgv7gY3UVXD/hnNx4GwDnFsQMOYI9Mugj3fz3M1jmgvwEtG7lrhIM9r09oviGggeooCLgSxExl6cAjRuYD3MCGFu2P5hOOXU8nd5robJbiYdHLnV4iWKlJ14yIAyKqp3WWlznqBhmIYB7MSi1F/sOFX5/ouzsI2LAkrJDwNBTCt8czxM56LcjEkphxROxP2LInePGN05KZCcTVBBRg3kD9pTt3DIO7wrn70LzXY+vD3DnKPK1OPIr+ACRAHy+atrOlQsOWfyX5rEpyEI2YFLqOZfrstZD5OGPWXaOdX5ZBBTLUTvpxE0zoXUjMPSmPvNTCLp2yYAJ/BZAtFeXrSAabZBHS2v1Yh5hQMGFqxogi5MJfFK1r2EKbZs3M7dp5suqua5DOW/QT3gSM92nk1K4Z8V5viHjRBuFO4HDcuOhl/sfxAvQySd+J69baTtcp2oR/twEMleBfoMrgiRr+eazcFbGKO3hVl1wRmJjzO84VylMSKvpQEvm94BkkQOM3nAHnh/U0GS96rMpno/fQdL21Y6NKnlq37GRgctaU8ukUbQLpnjOzCH6kObvFqCZNBYEcPAAaO7rguek/SSmFdKBuni44PMbCVY7nGFWeeeP8INNo+WB6UmhldTq6ePT2Qq184Ebszfo6lN7lEy/T+2BJ6IqMDNbKSqy0QWl5g17UsPaT8zEG/2MJdeh8bvkmTjLwkY1ZuarjcVXTAzJ4f2uTqpbKCYFYE2VbC4oZ4l6F/IRADoUdqQdsrGRlPKb8QFlGupWiv3hrF5nTP/1+cQHjgnwFSrD0uf0oM+wcfwyOYdNfKI1GGEhjo9ano8omRxWjW Kl8qzzYB 9yAbG9XsKI2/khQTF0/P34e4wcPGDHcjRGeP5jPNWwgR4vI3kQ8zjoNlhvwO0Fm/UtshmWogWqDnSPqNmTF6yq7MDz+DRvYu26eBr4HokGMTkQ6O6ZGrm+oTH7Xgo1Rqhe3b5B43edZ08VPrT8s2ZkoBNRpzfi6P5QyqVBRq0lWhXvNT6pn+oUGuHAgqI6x9KtsJD1DLQ/Ia5WFncHFhJoB+Txo1aD1z7T7gcVe5eoMvujdoT5KsMGSglGBFv62tDucHW X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: From: David Hildenbrand Update the huge folios policy for tmpfs and shmem. Signed-off-by: David Hildenbrand Signed-off-by: Baolin Wang --- Documentation/admin-guide/mm/transhuge.rst | 52 +++++++++++++++------- 1 file changed, 36 insertions(+), 16 deletions(-) diff --git a/Documentation/admin-guide/mm/transhuge.rst b/Documentation/admin-guide/mm/transhuge.rst index 5034915f4e8e..2a7705bf622d 100644 --- a/Documentation/admin-guide/mm/transhuge.rst +++ b/Documentation/admin-guide/mm/transhuge.rst @@ -352,8 +352,21 @@ default to ``never``. Hugepages in tmpfs/shmem ======================== -You can control hugepage allocation policy in tmpfs with mount option -``huge=``. It can have following values: +Traditionally, tmpfs only supported a single huge page size ("PMD"). Today, +it also supports smaller sizes just like anonymous memory, often referred +to as "multi-size THP" (mTHP). Huge pages of any size are commonly +represented in the kernel as "large folios". + +While there is fine control over the huge page sizes to use for the internal +shmem mount (see below), ordinary tmpfs mounts will make use of all available +huge page sizes without any control over the exact sizes, behaving more like +other file systems. + +tmpfs mounts +------------ + +The THP allocation policy for tmpfs mounts can be adjusted using the mount +option: ``huge=``. It can have following values: always Attempt to allocate huge pages every time we need a new page; @@ -374,13 +387,9 @@ The default policy is ``never``. ``huge=never`` will not attempt to break up huge pages at all, just stop more from being allocated. -There's also sysfs knob to control hugepage allocation policy for internal -shmem mount: /sys/kernel/mm/transparent_hugepage/shmem_enabled. The mount -is used for SysV SHM, memfds, shared anonymous mmaps (of /dev/zero or -MAP_ANONYMOUS), GPU drivers' DRM objects, Ashmem. - -In addition to policies listed above, shmem_enabled allows two further -values: +In addition to policies listed above, the sysfs knob +/sys/kernel/mm/transparent_hugepage/shmem_enabled will affect the +allocation policy of tmpfs mounts, when set to the following values: deny For use in emergencies, to force the huge option off from @@ -388,13 +397,24 @@ deny force Force the huge option on for all - very useful for testing; -Shmem can also use "multi-size THP" (mTHP) by adding a new sysfs knob to -control mTHP allocation: -'/sys/kernel/mm/transparent_hugepage/hugepages-kB/shmem_enabled', -and its value for each mTHP is essentially consistent with the global -setting. An 'inherit' option is added to ensure compatibility with these -global settings. Conversely, the options 'force' and 'deny' are dropped, -which are rather testing artifacts from the old ages. +shmem / internal tmpfs +---------------------- +The mount internal tmpfs mount is used for SysV SHM, memfds, shared anonymous +mmaps (of /dev/zero or MAP_ANONYMOUS), GPU drivers' DRM objects, Ashmem. + +To control the THP allocation policy for this internal tmpfs mount, the +sysfs knob /sys/kernel/mm/transparent_hugepage/shmem_enabled and the knobs +per THP size in +'/sys/kernel/mm/transparent_hugepage/hugepages-kB/shmem_enabled' +can be used. + +The global knob has the same semantics as the ``huge=`` mount options +for tmpfs mounts, except that the different huge page sizes can be controlled +individually, and will only use the setting of the global knob when the +per-size knob is set to 'inherit'. + +The options 'force' and 'deny' are dropped for the individual sizes, which +are rather testing artifacts from the old ages. always Attempt to allocate huge pages every time we need a new page;