From patchwork Thu Nov 28 07:40:39 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Baolin Wang X-Patchwork-Id: 13887733 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 16FEBD690E5 for ; Thu, 28 Nov 2024 07:41:05 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 88C086B0088; Thu, 28 Nov 2024 02:41:04 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 87E936B0092; Thu, 28 Nov 2024 02:41:04 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 6A9EB6B0089; Thu, 28 Nov 2024 02:41:04 -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 48AB46B0085 for ; Thu, 28 Nov 2024 02:41:04 -0500 (EST) Received: from smtpin09.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id BE1A71C70C4 for ; Thu, 28 Nov 2024 07:41:03 +0000 (UTC) X-FDA: 82834707228.09.CEE5A3E Received: from out30-113.freemail.mail.aliyun.com (out30-113.freemail.mail.aliyun.com [115.124.30.113]) by imf27.hostedemail.com (Postfix) with ESMTP id EDBB140011 for ; Thu, 28 Nov 2024 07:40:51 +0000 (UTC) Authentication-Results: imf27.hostedemail.com; dkim=pass header.d=linux.alibaba.com header.s=default header.b=eYIlcs7R; dmarc=pass (policy=none) header.from=linux.alibaba.com; spf=pass (imf27.hostedemail.com: domain of baolin.wang@linux.alibaba.com designates 115.124.30.113 as permitted sender) smtp.mailfrom=baolin.wang@linux.alibaba.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1732779655; a=rsa-sha256; cv=none; b=OFVHJHAH//cnqb0odS8D1QfU3JYnD0CEnxjU+muQnZu4SYilphlWNhRmHawSEulJwxdc/a 9CTufX7y2MyIJG4pzgZomEhIfPEJCzNjs3pcqHYsUUUv6w/qa6mJXWzVVULxgMvEUFjaQn HbSkoAmUG8ynArOctcxw6NGc6j+UIks= ARC-Authentication-Results: i=1; imf27.hostedemail.com; dkim=pass header.d=linux.alibaba.com header.s=default header.b=eYIlcs7R; dmarc=pass (policy=none) header.from=linux.alibaba.com; spf=pass (imf27.hostedemail.com: domain of baolin.wang@linux.alibaba.com designates 115.124.30.113 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=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:in-reply-to:references:references:dkim-signature; bh=0V6hY79A/2+E7HEAAM4p9j6HrltNCMws+8O8dcahOFU=; b=J7G94qVzy4zhUB0KuSY34A2cnSYAmbzDdpxg5NIH9+45z3WmzLESrTrKpyF/qNNjxvnffG ZSzIQ1bddNpRrrx6VmKOrkDmDNrx3FSCQak2BLq4S+kLzhFqqNbEZs1CWSUJtU+abF1tAR loCQRbFICVCJZiU2TDwEmApt8Ou8JlM= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.alibaba.com; s=default; t=1732779657; h=From:To:Subject:Date:Message-Id:MIME-Version; bh=0V6hY79A/2+E7HEAAM4p9j6HrltNCMws+8O8dcahOFU=; b=eYIlcs7RWD17JIYC1eaHR4T6dRSLr5s1M4+5TP3RRus1/DlSLoksuCswGkJMO9a0sHx/x6hfhUpBLkqLiQVr2UycUzhVGT/Vz1z5cjRZIMHOrNdpQ1D+d24J3CJdVUCy8AYCy9w8SE+mBBi52+ARsoh8iDBoTkBkeoHqM5msCAs= Received: from localhost(mailfrom:baolin.wang@linux.alibaba.com fp:SMTPD_---0WKOx1pU_1732779654 cluster:ay36) by smtp.aliyun-inc.com; Thu, 28 Nov 2024 15:40:55 +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 1/6] mm: factor out the order calculation into a new helper Date: Thu, 28 Nov 2024 15:40:39 +0800 Message-Id: <5505f9ea50942820c1924d1803bfdd3a524e54f6.1732779148.git.baolin.wang@linux.alibaba.com> X-Mailer: git-send-email 2.39.3 In-Reply-To: References: MIME-Version: 1.0 X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: EDBB140011 X-Stat-Signature: oezok6zjrrwxxpp7xzyu6qezkrox6yfo X-Rspam-User: X-HE-Tag: 1732779651-912465 X-HE-Meta: U2FsdGVkX19bqA/rYgsp+ZVMWCkIva9xOFH3NJ66FkRM4/mOgLjG9ACTVMDaLRRMZv8GtKQg30BdkBiY7m8EGXRJzFoKS/czpXNzGvx9ad1nMwQA6V3+gUSxev1qismjhNpizYMlX3ZiNa+0TNybKJBmkoi8YbVdynw28qDHggaoAHp+teo+fgKScFRZRdMwH452EgegeoNfo5M4mLR7YtPbiQQoDxhZn38MC9JXS+KEdE+OOnonb9f2b8a0AI6+o04IeNFDxMDox5wRISBsc84XneSZA15bmmAMNtntmHbbcpx4dqhOJsTbv+4xDyb+W0QANUPLrLG8OhEvE+vhWYdDJv1udO8bI8NfDIfnxxio6L/eKwZyEpxPYAwZA7AV8SyAJcezTNqU1VgUZ9DiJptirE3ZCKcbiRdQ5b5O/nXNE6w0zTSgNOE78nAIAnyD91LnmRIj+bADC8ICj1Zyv7tCNQseyNZVhfTzhnKb5/k3U/KWAavl868MOdDqYud2Z/IAc98dqiWnLKbb6YFIvNC9M5N/suTO5OeyMpDVTrUqqk5WKUKwTrAT4ooioqnUdxmAZTCLFLnQaJHS2deY3D3aAChuFX7gXF9Gbk9wKrFqqLq2r4AhKfOUzUO1iAFt8H2t7MiKM0IjB3FOvbpBLIVQX+tPZVgH5sco6a2yZqwAUoanIwU23NQS/ONBMWaaP5TfBwxX8RRmcUKiy6OxZB2ig9z5pkKMncd0pb2EZgLVCiaezgiz3IyP3rUzKNoeJPfGjaylvTUsx5/IaQQYlzrZiBGjiCnG/ximnNPwzsCU4Ms66oR4/yVCogyoeNzqDk0pxul5zhYy8eLI/MZnJGhCboygkHD6O4mmLTdkVh2hyiJOk3Sa3MkSoBM3t0/jqR6DEYD0e0z0BnrWFFDNxsnhRt+MFc1W+exIDEI3IIOAhx4Iby446CACqHKZ/1uRop8BcPzPOBECIkJ2UNI AdvrjzJD ktOPoQz4j6FKQkIukt27w9gQfyvV1ZEy1J1XGSyHvQx5cOUDtmjRMx9yENJRJzt/3k6joq0g6c95yuBsRQV0n8GNWb9PgfHClANO1yMEvWhuTyPDPzWG/thXMNpQcEFtH/KfDWanH5VQGCHV85QxBBmv9Yh6wTAZxnv7qe/I8pfOc+Wr38hYKvXGbLQsUWSlhWiIoH5ddciotCrsXwreoncFjpyxhesWu+l2iP+gANtjlJiAPj3m1THBniGngOkCAgLzU/FNWZNZ4VkEWA6vQJyZTQWQowKQSW5SEa0qV8AB61on99YcSbyNXtYlnY8fvH+F+N6PgP9YN2kCpOo4bdSsTk9OvU1LPFwd4 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: Factor out the order calculation into a new helper, which can be reused by shmem in the following patch. Suggested-by: Matthew Wilcox Signed-off-by: Baolin Wang Reviewed-by: Barry Song Reviewed-by: David Hildenbrand Reviewed-by: Daniel Gomez --- include/linux/pagemap.h | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/include/linux/pagemap.h b/include/linux/pagemap.h index bcf0865a38ae..d796c8a33647 100644 --- a/include/linux/pagemap.h +++ b/include/linux/pagemap.h @@ -727,6 +727,16 @@ typedef unsigned int __bitwise fgf_t; #define FGP_WRITEBEGIN (FGP_LOCK | FGP_WRITE | FGP_CREAT | FGP_STABLE) +static inline unsigned int filemap_get_order(size_t size) +{ + unsigned int shift = ilog2(size); + + if (shift <= PAGE_SHIFT) + return 0; + + return shift - PAGE_SHIFT; +} + /** * fgf_set_order - Encode a length in the fgf_t flags. * @size: The suggested size of the folio to create. @@ -740,11 +750,11 @@ typedef unsigned int __bitwise fgf_t; */ static inline fgf_t fgf_set_order(size_t size) { - unsigned int shift = ilog2(size); + unsigned int order = filemap_get_order(size); - if (shift <= PAGE_SHIFT) + if (!order) return 0; - return (__force fgf_t)((shift - PAGE_SHIFT) << 26); + return (__force fgf_t)(order << 26); } void *filemap_get_entry(struct address_space *mapping, pgoff_t index); From patchwork Thu Nov 28 07:40:40 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Baolin Wang X-Patchwork-Id: 13887734 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 C6912D690E2 for ; Thu, 28 Nov 2024 07:41:06 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D15796B008C; Thu, 28 Nov 2024 02:41:04 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id C9E2E6B0089; Thu, 28 Nov 2024 02:41:04 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A7A986B0093; Thu, 28 Nov 2024 02:41:04 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 6F3476B0085 for ; Thu, 28 Nov 2024 02:41:04 -0500 (EST) Received: from smtpin14.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 1F98B121465 for ; Thu, 28 Nov 2024 07:41:04 +0000 (UTC) X-FDA: 82834707564.14.213B147 Received: from out30-130.freemail.mail.aliyun.com (out30-130.freemail.mail.aliyun.com [115.124.30.130]) by imf12.hostedemail.com (Postfix) with ESMTP id 274674000C for ; Thu, 28 Nov 2024 07:40:58 +0000 (UTC) Authentication-Results: imf12.hostedemail.com; dkim=pass header.d=linux.alibaba.com header.s=default header.b=pSVpRjf6; spf=pass (imf12.hostedemail.com: domain of baolin.wang@linux.alibaba.com designates 115.124.30.130 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:in-reply-to:references:references:dkim-signature; bh=6HM6mcd3kWqgluzVJQFUY15MBVLtFMN3usvJqqfXf8k=; b=yF0lW8AXY0ajoFbahK+DptOHr6mYOtAs3c3PlS6PB044ppsQLO7H3Fw9mYiRF5HacDG3xz XVnkYC5WzkG2kKAm5KK7A5++iJHBR6ipdjYbn/SK/uGiksk0nSkgfQWhsYchAJA3ZmrcXs vckDqd1PHcPOhLwnibiar/+MlUrC+XU= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1732779655; a=rsa-sha256; cv=none; b=lu9TAA8TeW0YL/3n7J7KKWxx1VasUdPTQTO6zEuIs9DmH8QRY+lG7oO7ZAP+dQH/CXyYti JMjUOx9BAbgJsEQW7HfKyHLNTECxJyRVZRu2As7o3CC1H8t4qT83VyAyHgiA6wCB0LtC/Y 5QYkkQUE2OKFGpEYcrKNImoi0kB/wyM= ARC-Authentication-Results: i=1; imf12.hostedemail.com; dkim=pass header.d=linux.alibaba.com header.s=default header.b=pSVpRjf6; spf=pass (imf12.hostedemail.com: domain of baolin.wang@linux.alibaba.com designates 115.124.30.130 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=1732779657; h=From:To:Subject:Date:Message-Id:MIME-Version; bh=6HM6mcd3kWqgluzVJQFUY15MBVLtFMN3usvJqqfXf8k=; b=pSVpRjf64qYcay/O+uKnEs9ZlLACDcC3LJ/+o5h7ijQCETZ8TBByQgskk5qbrGobVExRpxL2AcZ2z1A5ggVHoSpqaHtbeP5MODLw1c18NJ38SxutNGbVILbgbp81k7NvZDnOu8cAdx3LlNMgy7oUDUTqFTZZzXoL+UnxU/veC7A= Received: from localhost(mailfrom:baolin.wang@linux.alibaba.com fp:SMTPD_---0WKP.Wk0_1732779655 cluster:ay36) by smtp.aliyun-inc.com; Thu, 28 Nov 2024 15:40:56 +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 2/6] mm: shmem: change shmem_huge_global_enabled() to return huge order bitmap Date: Thu, 28 Nov 2024 15:40:40 +0800 Message-Id: <9dce1cfad3e9c1587cf1a0ea782ddbebd0e92984.1732779148.git.baolin.wang@linux.alibaba.com> X-Mailer: git-send-email 2.39.3 In-Reply-To: References: MIME-Version: 1.0 X-Rspamd-Queue-Id: 274674000C X-Rspam-User: X-Rspamd-Server: rspam07 X-Stat-Signature: r9uq9rcymdnrassejtoqkmcm3rxmt8jo X-HE-Tag: 1732779658-323765 X-HE-Meta: U2FsdGVkX19uYaNg/Mzafa+2knDCqG1N5ksv/BQ/wNEWiGkftajH6UzXIOmluJqa9OUjPZtrE8nuFGk2kST5Cb1lOYlJEf5nY/6+DGc9gfpVoJ5ItQ/v/qe2ZO7VbZ3Q+tdsxTEcWcOJ6rO0S/udbiBvxSmO+ZwwmzXoe9lza/I71lC6nYQlIGMaUPLgG1nNXapFCw/SgbCf+Rr56IY4R+W7ObHqXRw25vmaVwLJIV+HWbEGv+QO0KcDKcl8+5NwU+bXoLlLV25mx5SVBvGb/msdH8He5pS/X01LafZN55A/wZlxE4Lo0D8OtZr8ajz0RubnbFYXbIVuJex+iQ8/Mkdg89dTIUSnb3PQGuVvF8fO6wHuy4eguIjyYIE4bA8OS5rUALFKIvxT/RDx/qbetgjs1GNna/7VdBPATRLZT2NmUSQol+TE9cf7PNnIcfm9me0K8IPUlLTKVPXkt+Gg+L70W328cNlfWiTWBcIGttauFl3RUxA+n/SY9MrXiyu8HioZ2sd4edcxetmjvKled/35bVYGGkoAGkH1F8zG1be3EOBHl5U5Kjc8XwIdhsKa2hJkn2TmPzM5c30UKgCCu2PR+Wbb+pe3t9hok7okclZfRXklr9BrKltsFuQy3fV+6nqVzN91Yh/16MpEPAkeZQncWnW6bs6Nzm52SgoPgrtu0uzfMVENeCVqTJ6t4w/d+I6/3AB5VQYXWJG3NoVz4Tmmm1H9jmCAJJDL64QmzvPru/E7A7yy9j0cBJkIToP8MuJivbhbwVdZh6AwRjTIyOKxGj+4hFIiJ7VBzH1eq95/bpp34DxzCDKI5ie+9vYfEFTiERYfJT06iKA8oSi9fEpkwVD3QLNktE7qlOtjMZNbfIZangGyBr4L0FVfRK3AntF7i4OkcW/w3dG3az7XikIjCN+OulP81kE/jUkWizS2FFOxJtaKPTz6FYLuAhr/DOhKEcEJHpnmjFw5Xn2 7iCze3cg hhmlykvrL60+TFjfDP+wRQTbtdjqPZZ5iKRJ3tLlKeWn9HfhsRsZKD6xjEjDweoPbqgeCvDZUKWRThC6v5ZRS3qBwA0X7cHPZ08TShuDjiVd1YH7rqvyM0/7SYwghCojWuHa2JfCtjqkjjwfwNglibj6EEbzNuvxGmXtVQqPfwLdo52gvsszlUFgoI7nC3jOzUKrDuOrJd+zJ2KGpsNxd0So+wALtK6ds1c/SVM2twJAssD9PVomNev4fI+vy26021V9jq076WgOcQbw6NStzDZ0uyLt+um5oT83kgLT1nA1EFuw= 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: Change the shmem_huge_global_enabled() to return the suitable huge order bitmap, and return 0 if huge pages are not allowed. This is a preparation for supporting various huge orders allocation of tmpfs in the following patches. No functional changes. Signed-off-by: Baolin Wang Acked-by: David Hildenbrand --- mm/shmem.c | 40 ++++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/mm/shmem.c b/mm/shmem.c index ccb9629a0f70..7595c3db4c1c 100644 --- a/mm/shmem.c +++ b/mm/shmem.c @@ -554,37 +554,37 @@ static bool shmem_confirm_swap(struct address_space *mapping, static int shmem_huge __read_mostly = SHMEM_HUGE_NEVER; -static bool shmem_huge_global_enabled(struct inode *inode, pgoff_t index, - loff_t write_end, bool shmem_huge_force, - unsigned long vm_flags) +static unsigned int shmem_huge_global_enabled(struct inode *inode, pgoff_t index, + loff_t write_end, bool shmem_huge_force, + unsigned long vm_flags) { loff_t i_size; if (HPAGE_PMD_ORDER > MAX_PAGECACHE_ORDER) - return false; + return 0; if (!S_ISREG(inode->i_mode)) - return false; + return 0; if (shmem_huge == SHMEM_HUGE_DENY) - return false; + return 0; if (shmem_huge_force || shmem_huge == SHMEM_HUGE_FORCE) - return true; + return BIT(HPAGE_PMD_ORDER); switch (SHMEM_SB(inode->i_sb)->huge) { case SHMEM_HUGE_ALWAYS: - return true; + return BIT(HPAGE_PMD_ORDER); case SHMEM_HUGE_WITHIN_SIZE: index = round_up(index + 1, HPAGE_PMD_NR); i_size = max(write_end, i_size_read(inode)); i_size = round_up(i_size, PAGE_SIZE); if (i_size >> PAGE_SHIFT >= index) - return true; + return BIT(HPAGE_PMD_ORDER); fallthrough; case SHMEM_HUGE_ADVISE: if (vm_flags & VM_HUGEPAGE) - return true; + return BIT(HPAGE_PMD_ORDER); fallthrough; default: - return false; + return 0; } } @@ -779,11 +779,11 @@ static unsigned long shmem_unused_huge_shrink(struct shmem_sb_info *sbinfo, return 0; } -static bool shmem_huge_global_enabled(struct inode *inode, pgoff_t index, - loff_t write_end, bool shmem_huge_force, - unsigned long vm_flags) +static unsigned int shmem_huge_global_enabled(struct inode *inode, pgoff_t index, + loff_t write_end, bool shmem_huge_force, + unsigned long vm_flags) { - return false; + return 0; } #endif /* CONFIG_TRANSPARENT_HUGEPAGE */ @@ -1685,21 +1685,21 @@ unsigned long shmem_allowable_huge_orders(struct inode *inode, unsigned long mask = READ_ONCE(huge_shmem_orders_always); unsigned long within_size_orders = READ_ONCE(huge_shmem_orders_within_size); unsigned long vm_flags = vma ? vma->vm_flags : 0; - bool global_huge; + unsigned int global_orders; loff_t i_size; int order; if (thp_disabled_by_hw() || (vma && vma_thp_disabled(vma, vm_flags))) return 0; - global_huge = shmem_huge_global_enabled(inode, index, write_end, - shmem_huge_force, vm_flags); + global_orders = shmem_huge_global_enabled(inode, index, write_end, + shmem_huge_force, vm_flags); if (!vma || !vma_is_anon_shmem(vma)) { /* * For tmpfs, we now only support PMD sized THP if huge page * is enabled, otherwise fallback to order 0. */ - return global_huge ? BIT(HPAGE_PMD_ORDER) : 0; + return global_orders; } /* @@ -1732,7 +1732,7 @@ unsigned long shmem_allowable_huge_orders(struct inode *inode, if (vm_flags & VM_HUGEPAGE) mask |= READ_ONCE(huge_shmem_orders_madvise); - if (global_huge) + if (global_orders > 0) mask |= READ_ONCE(huge_shmem_orders_inherit); return THP_ORDERS_ALL_FILE_DEFAULT & mask; From patchwork Thu Nov 28 07:40:41 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Baolin Wang X-Patchwork-Id: 13887737 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 6A690D690E3 for ; Thu, 28 Nov 2024 07:41:15 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 96AEF6B0089; Thu, 28 Nov 2024 02:41:05 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 91B786B0092; Thu, 28 Nov 2024 02:41:05 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 6F9D16B0098; Thu, 28 Nov 2024 02:41:05 -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 20E3A6B0092 for ; Thu, 28 Nov 2024 02:41:05 -0500 (EST) Received: from smtpin09.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id D487EAE489 for ; Thu, 28 Nov 2024 07:41:04 +0000 (UTC) X-FDA: 82834707270.09.E0DEA14 Received: from out30-99.freemail.mail.aliyun.com (out30-99.freemail.mail.aliyun.com [115.124.30.99]) by imf08.hostedemail.com (Postfix) with ESMTP id 20A2B160006 for ; Thu, 28 Nov 2024 07:40:57 +0000 (UTC) Authentication-Results: imf08.hostedemail.com; dkim=pass header.d=linux.alibaba.com header.s=default header.b=NPCB91RI; spf=pass (imf08.hostedemail.com: domain of baolin.wang@linux.alibaba.com designates 115.124.30.99 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=1732779656; 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=iizzfiOOXmZS6eNQ3u5p12da/SLq6MpmcF9cZtSAll0=; b=O6RWq9Wm+VRRRbVeKR5h/JGG8VSVx/6jt1uE26z8tYFvzBzyp3ua+YawBGcA+J705RItKy 6I1kvg9SuKZrklI/szC2Lv7Bo3dYIZEC6Hrp4SnuicgFlECGSEdf7dHpUhxocUxqjPTLil 7Qino82hbybjLzTQAdd5yN2z2D2mAIY= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1732779656; a=rsa-sha256; cv=none; b=PT3oSGosDqz3gLfxHN52S6QfW6/62NBNV4nxFPNs0P/hDDThbYx1JTdLdKn3AfPW0yrEX/ mb9ssD+L8mvYGRClRAd0i2LomqfcjDlXzhjlGzDi2xWEJughoe9ncciMD+JQYC4LCMqX2C FxU/LOVj/eMz5X432xcuJX+J4TKWJ38= ARC-Authentication-Results: i=1; imf08.hostedemail.com; dkim=pass header.d=linux.alibaba.com header.s=default header.b=NPCB91RI; spf=pass (imf08.hostedemail.com: domain of baolin.wang@linux.alibaba.com designates 115.124.30.99 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=1732779658; h=From:To:Subject:Date:Message-Id:MIME-Version; bh=iizzfiOOXmZS6eNQ3u5p12da/SLq6MpmcF9cZtSAll0=; b=NPCB91RILtWDRolRp3Qh02fMEBEIpbBnuC9OIOC3V2h27fuYA7NJpidVS04q4J8bZBNldFLXoPNY64AeZDqu084mtfZsl5VIYgQqTfhesA2tYQVN3CshcV+gzHaAMv0KbixopXEQNBp0fMPy4+mKOjEs5FvYiYoVGM5Y2kRJjmA= Received: from localhost(mailfrom:baolin.wang@linux.alibaba.com fp:SMTPD_---0WKOx1q3_1732779656 cluster:ay36) by smtp.aliyun-inc.com; Thu, 28 Nov 2024 15:40:57 +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 3/6] mm: shmem: add large folio support for tmpfs Date: Thu, 28 Nov 2024 15:40:41 +0800 Message-Id: <035bf55fbdebeff65f5cb2cdb9907b7d632c3228.1732779148.git.baolin.wang@linux.alibaba.com> X-Mailer: git-send-email 2.39.3 In-Reply-To: References: MIME-Version: 1.0 X-Rspamd-Queue-Id: 20A2B160006 X-Rspam-User: X-Rspamd-Server: rspam07 X-Stat-Signature: yhecyfd6axnbsyt9mqgwa1jqifg6chc4 X-HE-Tag: 1732779657-146476 X-HE-Meta: U2FsdGVkX19nHJVTdxHpdR5Gc+uBM68ZWw0PnKN17cGwW7n+EcCYlMGCVpEaiKp+WLylqqSpk3oyq0jQyz/Rl5RjG3MDfp+/bEDsGxh/k/W/HwNDvfu+EXX7fbTWybCKAPFpOVO88bH1ue9mwscj6XNKWfeYKYf4XkNrptzF+KnWLJjGTLWPb5jOIwXfclzA0uvDip5ySior2zDHBKOwgr2W76mxlMZkZFx5bOBimhTHm4vWXWhvK7iQyTEDprj4LQofg/mRiAl0u7B4kRX5QsipjcdUCfFyPQSybboETdviizeKNpkI0x6RhjkZ7S/0h7H2sNMYBJkgrbO++jK30Bz2ttQNqMG2ATWkSX7GrBGazz7CBfYcvrVSNEiTq2YwmBROxGCoc61XhSMAffI8ZRuwU+qaoglFZ/5botIpyWThb+b//LJcla2OwhVCRg3Rl2MngnsNH9h/qcZgyB1fpPzv/qnDL+FCmJ8thpE+2ZkZ46MROWk49O3zx5SmH1vKDap55P5lUnzT4EElboOZdBz5hEtZSzj2XpbYienRjp+O2NBUEmeqlbLIC2uKSVGfpSkwBV/x8Hq323JNpvztseVR1TnrpKQ3AHFP2f2uOViuoI6BefPdWn/2T786JzuO+vc3NG9Ge7yowOsXQ7C/cD4wI4X9Zfp3D/mqy+fH2i2/cO1JyTXP2pi6Y/mRSIws+4Gii6SakrAaAg7iccZ6y+ygNZKTpHHGBOGRbh950p4WKXBgZXusLQZZ/yKt1jNHmhM4CYFPAGC4kizwkaNgt0au/Zewexd1Y/jW9AR/zTY++0onc3qaKhaEOQ40o3EOTqJWg2FYp+3KgP4Mm8p7fg04mIYIspUqMWpCMz/m+7saQ0ti5ossw77UBdM4/eRjDh/ieL0VYBGaPsY5Tgfz1dP5jlBDpQs1k3mmPRV+DSi3T0TdZiFq8EF6kS1MvRkhZgoN3HW+jwmMnwBqakE ZKf2FWas DNxo9rbct++Y0kjniW4Gi4JA9A4646SotpjNgE+d5D2xIkzJbtdEqYIovIsTMta/I9Qqy7+P0bdvW+wH2LXQHcgxJZ+eOMz5E1S/JXI1+D1JfgadPztrSaV0R681dvgDLuMaEJCrls/UtsUELkhC0aJxY3FlX7R6gkCn+ziV43hoXab9UoUkIaJ4NzenFwgsVGrAxO7fJ0+rh4qsKsqtzhVsf0n9a3mOOh5ofRpsQStp96f8AU65oyBHq20ZKwF2CvcfY 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: Add large folio support for tmpfs write and fallocate paths matching the same high order preference mechanism used in the iomap buffered IO path as used in __filemap_get_folio(). Add shmem_mapping_size_orders() to get a hint for the orders of the folio based on the file size which takes care of the mapping requirements. 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 huge 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. Co-developed-by: Daniel Gomez Signed-off-by: Daniel Gomez Signed-off-by: Baolin Wang --- mm/shmem.c | 99 ++++++++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 81 insertions(+), 18 deletions(-) diff --git a/mm/shmem.c b/mm/shmem.c index 7595c3db4c1c..54eaa724c153 100644 --- a/mm/shmem.c +++ b/mm/shmem.c @@ -554,34 +554,100 @@ static bool shmem_confirm_swap(struct address_space *mapping, static int shmem_huge __read_mostly = SHMEM_HUGE_NEVER; +/** + * shmem_mapping_size_orders - Get allowable folio orders for the given file size. + * @mapping: Target address_space. + * @index: The page index. + * @write_end: end of a write, could extend inode size. + * + * This returns huge orders for folios (when supported) based on the file size + * which the mapping currently allows at the given index. The index is relevant + * due to alignment considerations the mapping might have. The returned order + * may be less than the size passed. + * + * Return: The orders. + */ +static inline unsigned int +shmem_mapping_size_orders(struct address_space *mapping, pgoff_t index, loff_t write_end) +{ + unsigned int order; + size_t size; + + if (!mapping_large_folio_support(mapping) || !write_end) + return 0; + + /* Calculate the write size based on the write_end */ + size = write_end - (index << PAGE_SHIFT); + order = filemap_get_order(size); + if (!order) + return 0; + + /* If we're not aligned, allocate a smaller folio */ + if (index & ((1UL << order) - 1)) + order = __ffs(index); + + order = min_t(size_t, order, MAX_PAGECACHE_ORDER); + return order > 0 ? BIT(order + 1) - 1 : 0; +} + static unsigned int shmem_huge_global_enabled(struct inode *inode, pgoff_t index, loff_t write_end, bool shmem_huge_force, + struct vm_area_struct *vma, unsigned long vm_flags) { + unsigned int maybe_pmd_order = HPAGE_PMD_ORDER > MAX_PAGECACHE_ORDER ? + 0 : BIT(HPAGE_PMD_ORDER); + unsigned long within_size_orders; + unsigned int order; + pgoff_t aligned_index; loff_t i_size; - if (HPAGE_PMD_ORDER > MAX_PAGECACHE_ORDER) - return 0; if (!S_ISREG(inode->i_mode)) return 0; if (shmem_huge == SHMEM_HUGE_DENY) return 0; if (shmem_huge_force || shmem_huge == SHMEM_HUGE_FORCE) - return BIT(HPAGE_PMD_ORDER); + return maybe_pmd_order; + /* + * The huge order allocation for anon shmem is controlled through + * the mTHP interface, so we still use PMD-sized huge order to + * check whether global control is enabled. + * + * For tmpfs mmap()'s huge order, we still use PMD-sized order to + * allocate huge pages due to lack of a write size hint. + * + * Otherwise, tmpfs will allow getting a highest order hint based on + * the size of write and fallocate paths, then will try each allowable + * huge orders. + */ switch (SHMEM_SB(inode->i_sb)->huge) { case SHMEM_HUGE_ALWAYS: - return BIT(HPAGE_PMD_ORDER); + if (vma) + return maybe_pmd_order; + + return shmem_mapping_size_orders(inode->i_mapping, index, write_end); case SHMEM_HUGE_WITHIN_SIZE: - index = round_up(index + 1, HPAGE_PMD_NR); - i_size = max(write_end, i_size_read(inode)); - i_size = round_up(i_size, PAGE_SIZE); - if (i_size >> PAGE_SHIFT >= index) - return BIT(HPAGE_PMD_ORDER); + if (vma) + within_size_orders = maybe_pmd_order; + else + within_size_orders = shmem_mapping_size_orders(inode->i_mapping, + index, write_end); + + order = highest_order(within_size_orders); + while (within_size_orders) { + aligned_index = round_up(index + 1, 1 << order); + i_size = max(write_end, i_size_read(inode)); + i_size = round_up(i_size, PAGE_SIZE); + if (i_size >> PAGE_SHIFT >= aligned_index) + return within_size_orders; + + order = next_order(&within_size_orders, order); + } fallthrough; case SHMEM_HUGE_ADVISE: if (vm_flags & VM_HUGEPAGE) - return BIT(HPAGE_PMD_ORDER); + return maybe_pmd_order; fallthrough; default: return 0; @@ -781,6 +847,7 @@ static unsigned long shmem_unused_huge_shrink(struct shmem_sb_info *sbinfo, static unsigned int shmem_huge_global_enabled(struct inode *inode, pgoff_t index, loff_t write_end, bool shmem_huge_force, + struct vm_area_struct *vma, unsigned long vm_flags) { return 0; @@ -1176,7 +1243,7 @@ static int shmem_getattr(struct mnt_idmap *idmap, STATX_ATTR_NODUMP); generic_fillattr(idmap, request_mask, inode, stat); - if (shmem_huge_global_enabled(inode, 0, 0, false, 0)) + if (shmem_huge_global_enabled(inode, 0, 0, false, NULL, 0)) stat->blksize = HPAGE_PMD_SIZE; if (request_mask & STATX_BTIME) { @@ -1693,14 +1760,10 @@ unsigned long shmem_allowable_huge_orders(struct inode *inode, return 0; global_orders = shmem_huge_global_enabled(inode, index, write_end, - shmem_huge_force, vm_flags); - if (!vma || !vma_is_anon_shmem(vma)) { - /* - * For tmpfs, we now only support PMD sized THP if huge page - * is enabled, otherwise fallback to order 0. - */ + shmem_huge_force, vma, vm_flags); + /* Tmpfs huge pages allocation */ + if (!vma || !vma_is_anon_shmem(vma)) return global_orders; - } /* * Following the 'deny' semantics of the top level, force the huge From patchwork Thu Nov 28 07:40:42 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Baolin Wang X-Patchwork-Id: 13887736 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 35954D690E3 for ; Thu, 28 Nov 2024 07:41:12 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 516D56B0085; Thu, 28 Nov 2024 02:41:05 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 267B56B0093; Thu, 28 Nov 2024 02:41:05 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id F14396B0098; Thu, 28 Nov 2024 02:41:04 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id AD1876B0085 for ; Thu, 28 Nov 2024 02:41:04 -0500 (EST) Received: from smtpin02.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 61D2E1A15AF for ; Thu, 28 Nov 2024 07:41:04 +0000 (UTC) X-FDA: 82834707564.02.3655D4F Received: from out30-119.freemail.mail.aliyun.com (out30-119.freemail.mail.aliyun.com [115.124.30.119]) by imf04.hostedemail.com (Postfix) with ESMTP id 784DA40004 for ; Thu, 28 Nov 2024 07:40:54 +0000 (UTC) Authentication-Results: imf04.hostedemail.com; dkim=pass header.d=linux.alibaba.com header.s=default header.b=VZi5KW16; spf=pass (imf04.hostedemail.com: domain of baolin.wang@linux.alibaba.com designates 115.124.30.119 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=1732779659; 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=UjYAYqlkSGfPZJ/FlT3GkxA+JCX542ZQmJh945HHSHc=; b=s/8e5wftI7Q28jvGqtpB/DSUJ47pcSemdXapqPxIz+qWHNBjfk7M6dc/zbn9CydOrkyRDE 9kDLzytuQ/gHakoZeD+FSob2YuwRFX32Tb1DXhb8GWVEdyhY1Q/4RVsqpofcaovyeFWsCg 3ovOs00VstvnolZBiPhIL7n1C6mt8TA= ARC-Authentication-Results: i=1; imf04.hostedemail.com; dkim=pass header.d=linux.alibaba.com header.s=default header.b=VZi5KW16; spf=pass (imf04.hostedemail.com: domain of baolin.wang@linux.alibaba.com designates 115.124.30.119 as permitted sender) smtp.mailfrom=baolin.wang@linux.alibaba.com; dmarc=pass (policy=none) header.from=linux.alibaba.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1732779659; a=rsa-sha256; cv=none; b=CpQA1naO1RkEjJfRahEYozh1hJJ5cAkvGLdhrFSmHZTq1yTfDM4fHPEA1TUpxdmq/cexqq Wvot+L0LmCv22krKK4v2Lu8lrJEsfU7FQHM9nUfwLhiU3hvGYxvFNdyBilwS2pv+1Yu4tG OAuLmfaw4cphhmxfa3zrj7yPAb/JDA0= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.alibaba.com; s=default; t=1732779659; h=From:To:Subject:Date:Message-Id:MIME-Version; bh=UjYAYqlkSGfPZJ/FlT3GkxA+JCX542ZQmJh945HHSHc=; b=VZi5KW16nfnP/meeoupv4HZEf3oQKHma8eZykUmqdysyawBens3s5v63TdskS+LhxBPGFtcxTvGTby5ix/BifNVEqqJ9QgG+48xNbLwzIIX2aPCCV5vW14evxv8PF1qUo+e3Q5vAuJDfe6hUecH0mbu+thPiLO+HKDqVHuw39R8= Received: from localhost(mailfrom:baolin.wang@linux.alibaba.com fp:SMTPD_---0WKP.Wl-_1732779657 cluster:ay36) by smtp.aliyun-inc.com; Thu, 28 Nov 2024 15:40:58 +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 4/6] mm: shmem: add a kernel command line to change the default huge policy for tmpfs Date: Thu, 28 Nov 2024 15:40:42 +0800 Message-Id: X-Mailer: git-send-email 2.39.3 In-Reply-To: References: MIME-Version: 1.0 X-Rspamd-Queue-Id: 784DA40004 X-Stat-Signature: boqfpf75z5cfkrstyfcmnkshbss3gayk X-Rspam-User: X-Rspamd-Server: rspam11 X-HE-Tag: 1732779654-170581 X-HE-Meta: U2FsdGVkX18KTB/X8wrrmzaDNE847AHiuxo8JRi48MS/5kbrHfXLEpYNfvd02FNpzocEPVwEC0IhXYNot6BZkr56E+FNo8ImJF9XE1L59Wk4YXvTbEFoXf4ZwzDEF9b/wyevnBDU4yZkIfDV2D0WD0lahFRfU8oMnUnFCQ2JXa3MSu5wX5jJmQfOvnY2JLmv+OYlZpUexOBLHK+KI633tCBwhbmzGI96cVI3Q++fpuLMUDvFkL/aO/7Ixq+5IXL6s4LjOSBGCfj2fDJ24Ro8l7hl4v4pejoXdN2CIoa/j9e10d/2FsHmqcUhVh0I5tzvV+j/lTuUz/8eh+XhlswZGGPa+7TiwQUKdmHQeX+9j8iJ7Gl1SuJtbMbT8hzQJr+2hjJ36xZh+gTZ0PV+SY+72c8Bru+5w87wASCdfr/OcKtoFvDWtJ7rRSQTvbA4rImSqUKD1totIYHieaNPlY4I+pQAE4SnyiOTwn8V8EWBD1nhhgzI1j9UZOEaX7haGb9BKdkcnP6PrvHcTkwpmDj//75ir0i9W8L2d/f58N1j6HTW/04fbG7iUiaiQZorhtROIZBWCKOX08Q2Y2uQJkZ1RELqTYpkTp8Q1JD2dCzS9Cpav2i6nRsBHtfEaf6jfp8kXsqrHW45J1bsO9aFW0pokKJfv/dSZ+nRQ047Omx1aC7roe9ZFcNTyHQYOxHLquKz9rRYB2J8Dt/hQYaz+e+pAXClIp91d7Gm7LAEIKHwyvtBH+yLorjfuOmLmrJGK3zKHwBaG4FOTbDhKf9mqQ1HS3Ac6SkbFQYalC7vomeaR0nE88P6P4Rra3BLZHVOxV13+pb+WQD9By7Pp2VpF+KQeAx02qX3/ql/vw6h2FHYv7kSyFbWNKCRg05Vs4d8Q9kQaRmJghOGdogGmot9XRA0irszXcRL/6LJUFMpT75XCfi4VYhjzXqRVg0kz0B+OG5tvDIs53/K3ZYT/mshxQP kO5j0o1a O24OS158mEZ89ecq8bEJIA2f1ii2ol/o/HseLfIbEkfyVkYusctSH6jIxvo8z+cyUIAP29WpbwCo2bIdRLZY3QMpjyf9QolNgFNd3HvixQgv6xTLj//Ghrj6z9L0zgn0YL33/6wf4DX3V3KMNQDC4aD2DTltqji4xOJNXxjeggtrRdouuBOqpnBPnzzHICNqLSxndM+rTA0Ikz+cFaeLtbOGWqFWF0RAw3RBHz3UT6z+fVoN4Y44QW9RO7TObsw8BtiZrjll4Uusxqwx7g9Hzd29m3EPdN37172r18IT4nqKx/GrrPLNGKfoLNw== 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: Now the tmpfs can allow to allocate any sized large folios, and the default huge policy is still preferred to be 'never'. Due to tmpfs not behaving like other file systems in some cases as previously explained by David[1]: " I think I raised this in the past, but tmpfs/shmem is just like any other file system .. except it sometimes really isn't and behaves much more like (swappable) anonymous memory. (or mlocked files) There are many systems out there that run without swap enabled, or with extremely minimal swap (IIRC until recently kubernetes was completely incompatible with swapping). Swap can even be disabled today for shmem using a mount option. That's a big difference to all other file systems where you are guaranteed to have backend storage where you can simply evict under memory pressure (might temporarily fail, of course). I *think* that's the reason why we have the "huge=" parameter that also controls the THP allocations during page faults (IOW possible memory over-allocation). Maybe also because it was a new feature, and we only had a single THP size. " Thus adding a new command line to change the default huge policy will be helpful to use the large folios for tmpfs, which is similar to the 'transparent_hugepage_shmem' cmdline for shmem. [1] https://lore.kernel.org/all/cbadd5fe-69d5-4c21-8eb8-3344ed36c721@redhat.com/ Signed-off-by: Baolin Wang --- .../admin-guide/kernel-parameters.txt | 7 ++++++ Documentation/admin-guide/mm/transhuge.rst | 6 +++++ mm/shmem.c | 23 ++++++++++++++++++- 3 files changed, 35 insertions(+), 1 deletion(-) diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentation/admin-guide/kernel-parameters.txt index dc663c0ca670..e73383450240 100644 --- a/Documentation/admin-guide/kernel-parameters.txt +++ b/Documentation/admin-guide/kernel-parameters.txt @@ -6987,6 +6987,13 @@ See Documentation/admin-guide/mm/transhuge.rst for more details. + transparent_hugepage_tmpfs= [KNL] + Format: [always|within_size|advise|never] + Can be used to control the default hugepage allocation policy + for the tmpfs mount. + See Documentation/admin-guide/mm/transhuge.rst + for more details. + trusted.source= [KEYS] Format: This parameter identifies the trust source as a backend diff --git a/Documentation/admin-guide/mm/transhuge.rst b/Documentation/admin-guide/mm/transhuge.rst index 5034915f4e8e..9ae775eaacbe 100644 --- a/Documentation/admin-guide/mm/transhuge.rst +++ b/Documentation/admin-guide/mm/transhuge.rst @@ -332,6 +332,12 @@ allocation policy for the internal shmem mount by using the kernel parameter seven valid policies for shmem (``always``, ``within_size``, ``advise``, ``never``, ``deny``, and ``force``). +Similarly to ``transparent_hugepage_shmem``, you can control the default +hugepage allocation policy for the tmpfs mount by using the kernel parameter +``transparent_hugepage_tmpfs=``, where ```` is one of the +four valid policies for tmpfs (``always``, ``within_size``, ``advise``, +``never``). The tmpfs mount default policy is ``never``. + In the same manner as ``thp_anon`` controls each supported anonymous THP size, ``thp_shmem`` controls each supported shmem THP size. ``thp_shmem`` has the same format as ``thp_anon``, but also supports the policy diff --git a/mm/shmem.c b/mm/shmem.c index 54eaa724c153..8a602fc61edb 100644 --- a/mm/shmem.c +++ b/mm/shmem.c @@ -553,6 +553,7 @@ static bool shmem_confirm_swap(struct address_space *mapping, /* ifdef here to avoid bloating shmem.o when not necessary */ static int shmem_huge __read_mostly = SHMEM_HUGE_NEVER; +static int tmpfs_huge __read_mostly = SHMEM_HUGE_NEVER; /** * shmem_mapping_size_orders - Get allowable folio orders for the given file size. @@ -4951,7 +4952,12 @@ static int shmem_fill_super(struct super_block *sb, struct fs_context *fc) sbinfo->gid = ctx->gid; sbinfo->full_inums = ctx->full_inums; sbinfo->mode = ctx->mode; - sbinfo->huge = ctx->huge; +#ifdef CONFIG_TRANSPARENT_HUGEPAGE + if (ctx->seen & SHMEM_SEEN_HUGE) + sbinfo->huge = ctx->huge; + else + sbinfo->huge = tmpfs_huge; +#endif sbinfo->mpol = ctx->mpol; ctx->mpol = NULL; @@ -5502,6 +5508,21 @@ static int __init setup_transparent_hugepage_shmem(char *str) } __setup("transparent_hugepage_shmem=", setup_transparent_hugepage_shmem); +static int __init setup_transparent_hugepage_tmpfs(char *str) +{ + int huge; + + huge = shmem_parse_huge(str); + if (huge < 0) { + pr_warn("transparent_hugepage_tmpfs= cannot parse, ignored\n"); + return huge; + } + + tmpfs_huge = huge; + return 1; +} +__setup("transparent_hugepage_tmpfs=", setup_transparent_hugepage_tmpfs); + static char str_dup[PAGE_SIZE] __initdata; static int __init setup_thp_shmem(char *str) { From patchwork Thu Nov 28 07:40:43 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Baolin Wang X-Patchwork-Id: 13887735 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 B512AD690E2 for ; Thu, 28 Nov 2024 07:41:09 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 26B406B0096; Thu, 28 Nov 2024 02:41:05 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 12F9B6B0085; Thu, 28 Nov 2024 02:41:04 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id BB32F6B0092; Thu, 28 Nov 2024 02:41:04 -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 87DE46B008C for ; Thu, 28 Nov 2024 02:41:04 -0500 (EST) Received: from smtpin12.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 268ABC1996 for ; Thu, 28 Nov 2024 07:41:04 +0000 (UTC) X-FDA: 82834707438.12.1603158 Received: from out30-130.freemail.mail.aliyun.com (out30-130.freemail.mail.aliyun.com [115.124.30.130]) by imf30.hostedemail.com (Postfix) with ESMTP id 8335780004 for ; Thu, 28 Nov 2024 07:40:49 +0000 (UTC) Authentication-Results: imf30.hostedemail.com; dkim=pass header.d=linux.alibaba.com header.s=default header.b=SfIC1BK3; spf=pass (imf30.hostedemail.com: domain of baolin.wang@linux.alibaba.com designates 115.124.30.130 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=1732779659; 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=4geB5O7mEfI/X7677yTwrrvC9HQS1VjRPAOpYyMK/zg=; b=8aqqq80DwFRqYcGymlqU7hUkSIhx3LA3/HIaQdqcW2R/OCEUTvztJq+tgV/dWWIoVi3U1C YGTDZqqA0WO8l2w7PvIwTvBqldExmefZkf+URVEqN+lCXWB/zSPvZtPp2efSpZOZmEl7Pt +o07vnkmCXJo1cTjbVf3CmDwhDR8JAs= ARC-Authentication-Results: i=1; imf30.hostedemail.com; dkim=pass header.d=linux.alibaba.com header.s=default header.b=SfIC1BK3; spf=pass (imf30.hostedemail.com: domain of baolin.wang@linux.alibaba.com designates 115.124.30.130 as permitted sender) smtp.mailfrom=baolin.wang@linux.alibaba.com; dmarc=pass (policy=none) header.from=linux.alibaba.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1732779659; a=rsa-sha256; cv=none; b=LZWqD0CaVt2tGe58NB1dV3Xv6HwFjTz9Vw3RkJzbm49xUewhZfXHWY0Ili895mUR2wPKA3 jO+gCtqliN9Lre1gP1XSV6gTaO+CLLUpDP+M4mpZlMPPqI3ihSEfUO2W6R+Ani0OR4xSAW OBw43IjWgZKmm1iwtvtcYvLaG6Fq/8s= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.alibaba.com; s=default; t=1732779659; h=From:To:Subject:Date:Message-Id:MIME-Version; bh=4geB5O7mEfI/X7677yTwrrvC9HQS1VjRPAOpYyMK/zg=; b=SfIC1BK3Ys7utCEX+QZcyL9qxn+Tf7MT0G92Fqd6ZtasU2u4lzolEdOIn0LuQxpUJCROA4ED+6P3sGuhYIwCAJyCZy2rb9RXmk2Rktd4w6wO8j6N2RyH3Ugo8BAWVj1j0o1B+jusOnTMdpEsyTH16l/HQYzshn3OAHh2gyEGTjQ= Received: from localhost(mailfrom:baolin.wang@linux.alibaba.com fp:SMTPD_---0WKOx1qd_1732779658 cluster:ay36) by smtp.aliyun-inc.com; Thu, 28 Nov 2024 15:40:59 +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 5/6] docs: tmpfs: update the large folios policy for tmpfs and shmem Date: Thu, 28 Nov 2024 15:40:43 +0800 Message-Id: <9b7418af30e300d1eb05721b81d79074d0bb0ec9.1732779148.git.baolin.wang@linux.alibaba.com> X-Mailer: git-send-email 2.39.3 In-Reply-To: References: MIME-Version: 1.0 X-Rspamd-Queue-Id: 8335780004 X-Stat-Signature: hb9dnu1zksmo3rgh3t9s9jynukb7y31s X-Rspam-User: X-Rspamd-Server: rspam11 X-HE-Tag: 1732779649-253679 X-HE-Meta: U2FsdGVkX1/cl3gmBHstUsolT/DLwQnr95mINNjnBNa+8VAxsgNOEeinkZQxYczdzhL0lQhp+7QeJYsMZkUYYR6HfhzT4hLBiewkRg6sv2D3rXpgnrOw24cE7gUtDzSia4BIUfDKhCzFx6tgW1JfHT0YZyQk/fubgO/otO+yhJU0g6qO2sjUlivuwfwN4AHzLV8v3k+KJ6ltgaLOscwi/d1gjcdANUWuBs4lA6SfFY+YoxWsJF9kBwrmiZU2shQfIh2YDpLlCKYuDT8KLdYayWgR/oH8FLPTYa8kBySFnkznDnRio83O7vCgtlDN1aKBrZsy4YwEJO343yfGRwC2kt8W2GuGMELF5g4barATHUmDsrcEeobZZQZDl0li7wt9Ok3LNu9lcn0yCstF83H2htKbYNj9/BKn7sHio67lkSDzluzc4cuGzbhx3jtB090Peca4+wAeyc3e7w6IvoB7Wd9CPsO314BlCkxm+bsvihtw+OXLkmiwDgrjSz0tJnGU0BRT1BFDjeFtM39LHtA2rXMvCewyG9tUlDLd3fyKrJpRh/8pWIC29OEARJlWhoOVrtub62bGYQA5wZ34V8aKMhjFicpQ1zAjZb/iyyTvsx7GAbJDddB4nOjPQH9XTijJna2LXfjkCeza0hgMseUxblhSuoKMDJi2cg+YAiP2angXy3PNJvdLWI+ia6JahNlVLlgeiVvOXgTHLTgIJ+R40MHNgNRVDQSSzt1dMxumdVUFFPuLrDRTu/rtK+zCg5Vj1aRr5lVcOfXdtsFUs/X3Nr+gEig4ooSvCxP05F/ZsFam05uE/Q04U4QuugDmWlIsyNKxR+bVfJg3yDiTWDdRUs1P+59EqQmLXf6qbN6WMD6nHqV/dOSl+7NnFH7kmgtS8NLY2/pOdyBUKelMEsUH7W+W5+o7aIyML+dHwVS/R4XI1FLmQXopL9iBsbr7yJ/CwOgEtLp8U2Coel1zR0S 6HHDFzbw xfzJEXXeB0flRWadbCjsWkb5FEoDiU5IHqFWQPlV8CWaMENjcnrUG/gHkKiWlORukui69OEyBbKa7Q4p3DuVt9M9TVoPK2HayqNL1WxO0xnBwBSJ+/QIgPamq+wugXOApzPOUzTn1FPrDbxGCik6g+VurTVxNhICD+UvYO5QXZQdUpIj8TTlQm6JCQT5ZjHKoXREWMzgtdTRnlBL6gyRXjJcPADTmIiY3wt+CZBv9esipKYeP2z2a/CU+5n1O7ZD4l+2R 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 large folios policy for tmpfs and shmem. Signed-off-by: David Hildenbrand Signed-off-by: Baolin Wang --- Documentation/admin-guide/mm/transhuge.rst | 58 +++++++++++++++------- 1 file changed, 41 insertions(+), 17 deletions(-) diff --git a/Documentation/admin-guide/mm/transhuge.rst b/Documentation/admin-guide/mm/transhuge.rst index 9ae775eaacbe..ba6edff728ed 100644 --- a/Documentation/admin-guide/mm/transhuge.rst +++ b/Documentation/admin-guide/mm/transhuge.rst @@ -358,8 +358,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,19 +387,19 @@ within_size advise Only allocate huge pages if requested with fadvise()/madvise(); -The default policy is ``never``. +Remember, that the kernel may use huge pages of all available sizes, and +that no fine control as for the internal tmpfs mount is available. + +The default policy in the past was ``never``, but it can now be adjusted +using the kernel parameter ``transparent_hugepage_tmpfs=``. ``mount -o remount,huge= /mountpoint`` works fine after mount: remounting ``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 @@ -394,13 +407,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; From patchwork Thu Nov 28 07:40:44 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Baolin Wang X-Patchwork-Id: 13887738 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 826E2D690E3 for ; Thu, 28 Nov 2024 07:41:18 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 8A88A6B0092; Thu, 28 Nov 2024 02:41:06 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 8305E6B0093; Thu, 28 Nov 2024 02:41:06 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 6D1E66B0098; Thu, 28 Nov 2024 02:41:06 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 49A116B0092 for ; Thu, 28 Nov 2024 02:41:06 -0500 (EST) Received: from smtpin15.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 04480121A58 for ; Thu, 28 Nov 2024 07:41:05 +0000 (UTC) X-FDA: 82834707564.15.BB29902 Received: from out30-132.freemail.mail.aliyun.com (out30-132.freemail.mail.aliyun.com [115.124.30.132]) by imf07.hostedemail.com (Postfix) with ESMTP id 0E9AD40007 for ; Thu, 28 Nov 2024 07:40:56 +0000 (UTC) Authentication-Results: imf07.hostedemail.com; dkim=pass header.d=linux.alibaba.com header.s=default header.b=OAfM195T; spf=pass (imf07.hostedemail.com: domain of baolin.wang@linux.alibaba.com designates 115.124.30.132 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=1732779659; 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=YBH1XlSLL2miO3wN2ZfU4NokzBeaXtPrx3UOtdhUk6w=; b=JSWNLz9Z1J7lbhlZVWFg4+fizzJiKypdaSxA7HD/Fmn6IoMI7kZvekLSh5gSQG0a0JIsWz Zt3w2OMr9570ISAIU5GD0BOP83xw5jpHb3cdMTC0BLRlA5pSebcogIjwFohNnWqiXULrYV 0usyC1BlzYnWBLybkRlp9INON1iMZEk= ARC-Authentication-Results: i=1; imf07.hostedemail.com; dkim=pass header.d=linux.alibaba.com header.s=default header.b=OAfM195T; spf=pass (imf07.hostedemail.com: domain of baolin.wang@linux.alibaba.com designates 115.124.30.132 as permitted sender) smtp.mailfrom=baolin.wang@linux.alibaba.com; dmarc=pass (policy=none) header.from=linux.alibaba.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1732779659; a=rsa-sha256; cv=none; b=mMRmdFUaGvNAKwZt7Umv3LAIlfbVtfKKPQ/znyqpTbefV9FYnramg0wneAOMOsH/1qMLXP dN7mkCf7z23OTSViVjDyo3cFlc4YM+6Gzxgc1/UZYg1PEHWqk1R8rEF0yevihJwx4+H7+S +SIR416+m4HALGn8FngN56JB6kOHXVU= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.alibaba.com; s=default; t=1732779660; h=From:To:Subject:Date:Message-Id:MIME-Version; bh=YBH1XlSLL2miO3wN2ZfU4NokzBeaXtPrx3UOtdhUk6w=; b=OAfM195TByoWRUXBMsU/V8Cey2170MZdtGm46N8z+suE+te8rj7FsQpLPTVRb+ZKg6q0zb4MDb+X52uitEXGBfPKJKAug8nWlEqpjOemZctM8980eAysNwTd49ijk6cEnjEdOLeXP+Vjzcdir8zxgcayk/On9zCQFlvu5tMOGnA= Received: from localhost(mailfrom:baolin.wang@linux.alibaba.com fp:SMTPD_---0WKOunGS_1732779659 cluster:ay36) by smtp.aliyun-inc.com; Thu, 28 Nov 2024 15:41:00 +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 6/6] docs: tmpfs: drop 'fadvise()' from the documentation Date: Thu, 28 Nov 2024 15:40:44 +0800 Message-Id: <3a10bb49832f6d9827dc2c76aec0bf43a892876b.1732779148.git.baolin.wang@linux.alibaba.com> X-Mailer: git-send-email 2.39.3 In-Reply-To: References: MIME-Version: 1.0 X-Rspamd-Server: rspam05 X-Stat-Signature: juq3rjcfb4mgeqk7q6xpn5r15y7nxmox X-Rspamd-Queue-Id: 0E9AD40007 X-Rspam-User: X-HE-Tag: 1732779656-247649 X-HE-Meta: U2FsdGVkX1/M+2JLNDDcq2dPmjo51nbq/WcBghz+FSHZfMfHO+4oc+lFtnmiygEyB7uFUPmfK5Ef9t0hrl1d/mbcPkwDPME/mGI8nxghUn440IqIFh0C87E+l7o1BF+c24MHKY78/1Cm4grzSsj0NfwcoWkQyY8mtvjfJsXJ6WWhzYhqQAPhYea8s/6IIYeFzaW7wx+O9dJ+WYPBTO5U96LzQtfsEqueuGbPF0684XT2Bur8g8S1mnPwVqR/dbFOBXYbjfyMm7X9c9kwggrI7wWmAa8ubUT3rKfCiygZuqM72SVx+svGo0pBlgSLCSXiLomthpK0++QXIo4t22s9o48N6w9Vy3/dIIDW8vlYMszsfpfltmmf/l8t6n7meOJAVBaNdx5bBA6+1I3lJg3N8rh3ebZ9Qd+1GrQDkdH3FUg0KHGSpdMkevWZPkOl8hTMd8Ul2mg1n3r6fW1YBm9dDsk799Z6J93U9rMLMgjmXfxcifZITLv+9Ywnczy0+khyO4I8hWz19XF1alD5ME2d/QWnQK+PnAS1FNQQ5zLLONhMyVu4e+EBVA5g+glHE7b8FZfahCxZJM+spNag5WcxUWJ6+4oaqlis6HB8ub8yJgGA6sflQyDd/bnk2Mon2TzU0f/Ygw2uFUO8gDZH3pwuNoYlFjNMTiNNX28AfBuJ4XKnL4RRflo8QkmA0c6AfcYElqu/SUYLZeZw9DsGPalLQNZkca73Fw4oGJyQDPFHI+bX6dK3l1h1a+PsZlSY2S9VQbKNoaq51zu1VQYZFBay4T23Xh2lfRhQ7TI033wZwhNhklApd3CL5E4zOv0lNyBviyltdYlNIvzN1qKQQ5CNGWn4jY8X2w9LTSMBuNL5irVB8UVqq9Pe9I0x2A+w26F+hAAlulvjxP7zV6U1kWmK46y5M0BMbtZkPu54hwddlaPbEjtchXWFoN9Ps9Rt/Uja8oNsEPej7/qeB/7f5mj ACGjtGlT Wk7ubjSwJ8sXIIUFUZN+Q+hBOtIQU3ZMsOWJHNlOUOUPB/lDctKY8sWYf3998DywdMUoP4CJSSdG0BW41h+ycVG7fcUMehgqEYqxE8Wu5OTwDqLVT+1vjiaT3B2Kj0sKCbO+a5EQRgSU8l5ZeIvZPTWy5fNlB509O3QK3qHEtCdIs2bnnsTPWVC0vHbguxs6xaQTx/salnHLVmGxxCjiETE6dvgP0Oo4PnRoYMNYGGxpIgXh8wIuzBNdh2cgqO1rjgmWS61qw7smGvYWdudi0E0CVHw== 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: Drop 'fadvise()' from the doc, since fadvise() has no HUGEPAGE advise currently. Signed-off-by: Baolin Wang Reviewed-by: Barry Song Acked-by: David Hildenbrand --- Documentation/admin-guide/mm/transhuge.rst | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Documentation/admin-guide/mm/transhuge.rst b/Documentation/admin-guide/mm/transhuge.rst index ba6edff728ed..333958ef0d5f 100644 --- a/Documentation/admin-guide/mm/transhuge.rst +++ b/Documentation/admin-guide/mm/transhuge.rst @@ -382,10 +382,10 @@ never within_size Only allocate huge page if it will be fully within i_size. - Also respect fadvise()/madvise() hints; + Also respect madvise() hints; advise - Only allocate huge pages if requested with fadvise()/madvise(); + Only allocate huge pages if requested with madvise(); Remember, that the kernel may use huge pages of all available sizes, and that no fine control as for the internal tmpfs mount is available. @@ -438,10 +438,10 @@ never within_size Only allocate huge page if it will be fully within i_size. - Also respect fadvise()/madvise() hints; + Also respect madvise() hints; advise - Only allocate huge pages if requested with fadvise()/madvise(); + Only allocate huge pages if requested with madvise(); Need of application restart ===========================