From patchwork Thu Nov 28 07:40:38 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Baolin Wang X-Patchwork-Id: 13887732 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 3F171D690E4 for ; Thu, 28 Nov 2024 07:41:02 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 9E06C6B0083; Thu, 28 Nov 2024 02:41:01 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 9901D6B0085; Thu, 28 Nov 2024 02:41:01 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 858616B0088; Thu, 28 Nov 2024 02:41:01 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 61E2F6B0083 for ; Thu, 28 Nov 2024 02:41:01 -0500 (EST) Received: from smtpin12.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id EF1D6ACBCD for ; Thu, 28 Nov 2024 07:41:00 +0000 (UTC) X-FDA: 82834707312.12.85FFB5E Received: from out30-100.freemail.mail.aliyun.com (out30-100.freemail.mail.aliyun.com [115.124.30.100]) by imf20.hostedemail.com (Postfix) with ESMTP id E50051C0004 for ; Thu, 28 Nov 2024 07:40:50 +0000 (UTC) Authentication-Results: imf20.hostedemail.com; dkim=pass header.d=linux.alibaba.com header.s=default header.b=mjTshkSJ; spf=pass (imf20.hostedemail.com: domain of baolin.wang@linux.alibaba.com designates 115.124.30.100 as permitted sender) smtp.mailfrom=baolin.wang@linux.alibaba.com; dmarc=pass (policy=none) header.from=linux.alibaba.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1732779655; 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:references:dkim-signature; bh=l/8YEYXsPcAmCqwYYFhuOOdFVbEqO8knORxafeXmAJ4=; b=BhuEzL5t+jez1e9yEXeB6/PLoNMoDt4ubO41MqUViBxcO9rRJhJURe5NACkWbcaPSSuerD IUWjiDDblnPAyMouXzfTJh7OPBR84QxdXyFkabiPHrGhZk5U6FH50jgVCbKJeAOEfwihcj FRshFzCqZe99dnK0J0kFffrG+W1VwX4= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1732779655; a=rsa-sha256; cv=none; b=kPDAItps32cQDw2fwbQdrNW4vL2z/i+kfAVrpT4BYAmWqdqAa5Cs7gdc1psKEuND5bGVEf Fad5bX5g9AtNu4N0/1Z3sme1IjIpwbSFrKwHz8/4+H2wI0m/MT8dOsq6xoZ/5BK9nf3C/f krNe0rkC9+bHBYttdLZ2/rmG3X3oOA8= ARC-Authentication-Results: i=1; imf20.hostedemail.com; dkim=pass header.d=linux.alibaba.com header.s=default header.b=mjTshkSJ; spf=pass (imf20.hostedemail.com: domain of baolin.wang@linux.alibaba.com designates 115.124.30.100 as permitted sender) smtp.mailfrom=baolin.wang@linux.alibaba.com; dmarc=pass (policy=none) header.from=linux.alibaba.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.alibaba.com; s=default; t=1732779656; h=From:To:Subject:Date:Message-Id:MIME-Version; bh=l/8YEYXsPcAmCqwYYFhuOOdFVbEqO8knORxafeXmAJ4=; b=mjTshkSJ6G1z8dkZrT+cAhPc0/qzGoFawe3OudBiAAdiqGcB/hMnzCAfNdcq7O+Z6P15AvQbYdEVNYDtjPTqgOyod4PlU/+MZdQ2LJN83pR4JpMOUIj8j/eclPI3N5ssKPrfiBNC9pm1JQ8z6Mgumwn5Yd2gUeKENjT22pUt0o8= Received: from localhost(mailfrom:baolin.wang@linux.alibaba.com fp:SMTPD_---0WKP.Wj5_1732779653 cluster:ay36) by smtp.aliyun-inc.com; Thu, 28 Nov 2024 15:40:54 +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 v3 0/6] Support large folios for tmpfs Date: Thu, 28 Nov 2024 15:40:38 +0800 Message-Id: X-Mailer: git-send-email 2.39.3 MIME-Version: 1.0 X-Rspamd-Server: rspam02 X-Rspamd-Queue-Id: E50051C0004 X-Stat-Signature: gcy5jfdk3gzm7r5cmhddue5c8m895qgy X-Rspam-User: X-HE-Tag: 1732779650-748475 X-HE-Meta: U2FsdGVkX18/STTm4GrQL3XS4wyU7O8bdoJ30QzxpYSS66rxKUkwIKkp8H2yZRYHJalGp7JYKsB5VKf3oeNAZATutEwELK4SSNm3z7ZDzaKkPKeKZz13OqdgqB5T+dMxW7E40+thw9YUYrHwo8PR5852K88NV9jTCkKqwP5Tbex3E62pTuXCsK4jEy3+HtdDAnkZ5x3ay6DAWscUzwDSjpy047ecwN5t2Djq4gOum6ikss8K9gOQOGRmlXdQI5rdLglBZ6S4SV6OHXOgTx8SgeIaTKRhAr0rQaCDktYKBgrjXlMf+EWOgQ4GCOSi7pHfbqo0u7GGIoYG4MIu2BMue12ZpL1kLFvmVaddg5+JmhzyYYSrLfGnRI8VjZsY1Z9E0gRgr7eviQrqoYfc/OQAOSDsi1Stqshbaf5JSg1ZZS5fuEnQWMR5r6OcMUhhsLy7xZEFbP9o50AptVrTBzUynhNpUir1frpp1Jri+AdAp3YADnpjh/G3zF1GXrxBGXDiz/APjUuN596eKDPb/Rxszp/qa2XyUjNQaiVd+FDaNFzlCZl7hZo5Shfrueo0x3NGyyQ8xpZ1LZkhfVO7Ny2yc6mAAdYG/wGSyyUzSjHvILYA2u04qwHFZtxAZYiWONnAiIjFa5s4GLsjq4C3SsYnUA8VlE3tGY1D3rgw1n5P3lXiT6xZkLoFqP07ck2vIi2ejQDMJiSGqtQFFJg5A0uLKgpCaSE9WA1W2Ict/oWqVEGJ+el2P96Bkxft7gwn3APlRkMNhtzzBBH+XGJGR3ULRIoKPZk4a9nUtPFW9CRhJAlMNXtm0Wq/ESgyw9hf2NWkmj0D0T2TBSg8Qs8z8C0v8I5yOAx8F2hBVF3JKg71oTpdIuZlw0f97u1imddnszq1/dGOAA/rYv0lWIVjMEYDUNQeCTc8gLDTVRpwvv5xaW3z1KrvBrZFA5sBlr8mv7NerBLOhB1BAxKpcs5FuCU Xem4hvGP BNnHH6p5UMTd+DRAPGWZAOpZN1zAdvYpWRrDZT4Sq8T4KkcA0Hjhal/+IBZDZQt9cNakhDJiSj1PIqjhsZ0/Iu2yFAqQaDJJ5sQuGKw18aV5YPM1lu6+iSnEwV0ka5lZxr4T7Sk5dvG1CE5NuE36Fj//Hd8XPkAL2AcJWYOQ84X5BMnDPlRl+b0puSwUHDDejnVAjAxE/2kjcwA8= 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: Traditionally, tmpfs only supported PMD-sized large folios. However nowadays with other file systems supporting any sized large folios, and extending anonymous to support mTHP, we should not restrict tmpfs to allocating only PMD-sized large folios, making it more special. Instead, we should allow tmpfs can allocate any sized large folios. Considering that tmpfs already has the 'huge=' option to control the PMD-sized large folios allocation, we can extend the 'huge=' option to allow any sized large folios. The semantics of the 'huge=' mount option are: huge=never: no any sized large folios huge=always: any sized large folios huge=within_size: like 'always' but respect the i_size huge=advise: like 'always' if requested with madvise() Note: for tmpfs mmap() faults, due to the lack of a write size hint, still allocate the PMD-sized large folios if huge=always/within_size/advise is set. Moreover, the 'deny' and 'force' testing options controlled by '/sys/kernel/mm/transparent_hugepage/shmem_enabled', still retain the same semantics. The 'deny' can disable any sized large folios for tmpfs, while the 'force' can enable PMD sized large folios for tmpfs. Any comments and suggestions are appreciated. Thanks. Changes from v2: - Collect reviewed tags. Thanks. - Add a new patch to drop fadvise from the docs. - Drop the 'MAX_PAGECACHE_ORDER' check in shmem_huge_global_enabled(), per David. - Update the commit message, per Daniel. - Rebase on the latest mm-unstable branch. Changes from v1: - Add reviewed tag from Barry and David. Thanks. - Fix building warnings reported by kernel test robot. - Add a new patch to control the default huge policy for tmpfs. Changes from RFC v3: - Drop the huge=write_size option. - Allow any sized huge folios for 'hgue' option. - Update the documentation, per David. Changes from RFC v2: - Drop mTHP interfaces to control huge page allocation, per Matthew. - Add a new helper to calculate the order, suggested by Matthew. - Add a new huge=write_size option to allocate large folios based on the write size. - Add a new patch to update the documentation. Changes from RFC v1: - Drop patch 1. - Use 'write_end' to calculate the length in shmem_allowable_huge_orders(). - Update shmem_mapping_size_order() per Daniel. Baolin Wang (5): mm: factor out the order calculation into a new helper mm: shmem: change shmem_huge_global_enabled() to return huge order bitmap mm: shmem: add large folio support for tmpfs mm: shmem: add a kernel command line to change the default huge policy for tmpfs docs: tmpfs: drop 'fadvise()' from the documentation David Hildenbrand (1): docs: tmpfs: update the large folios policy for tmpfs and shmem .../admin-guide/kernel-parameters.txt | 7 + Documentation/admin-guide/mm/transhuge.rst | 72 ++++++--- include/linux/pagemap.h | 16 +- mm/shmem.c | 150 ++++++++++++++---- 4 files changed, 188 insertions(+), 57 deletions(-)