From mboxrd@z Thu Jan 1 00:00:00 1970 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 89F60CF11C4 for ; Thu, 10 Oct 2024 09:58:26 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D39DA6B008A; Thu, 10 Oct 2024 05:58:25 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id CBD9E6B0088; Thu, 10 Oct 2024 05:58:25 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B43146B0089; Thu, 10 Oct 2024 05:58:25 -0400 (EDT) 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 940656B0085 for ; Thu, 10 Oct 2024 05:58:25 -0400 (EDT) Received: from smtpin03.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id CFFC9160C8D for ; Thu, 10 Oct 2024 09:58:21 +0000 (UTC) X-FDA: 82657242570.03.7BD62DE Received: from out30-113.freemail.mail.aliyun.com (out30-113.freemail.mail.aliyun.com [115.124.30.113]) by imf13.hostedemail.com (Postfix) with ESMTP id 3901B20010 for ; Thu, 10 Oct 2024 09:58:20 +0000 (UTC) Authentication-Results: imf13.hostedemail.com; dkim=pass header.d=linux.alibaba.com header.s=default header.b=mf2nisBB; dmarc=pass (policy=none) header.from=linux.alibaba.com; spf=pass (imf13.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=1728554202; a=rsa-sha256; cv=none; b=3lCQGCTYxmg0Ot5+L/0RTRM14MYc4DT2dAB7NX6ZeYFVwUsew05tpHgI2Ltq7EopfsDPcG Ya7zOBz+pKyvKgd0gB/EHEZQoZX5duRUtLvP8GwmCMxqWvc2kIVhSDtH/un66uAOKthaK7 8auFQojM2cgXHcKKdOGr8EaKyFACZz4= ARC-Authentication-Results: i=1; imf13.hostedemail.com; dkim=pass header.d=linux.alibaba.com header.s=default header.b=mf2nisBB; dmarc=pass (policy=none) header.from=linux.alibaba.com; spf=pass (imf13.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=1728554202; 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=68SYjty2xW+7Wyn01Un2urytR1FCalqpR1eIGlQg1ks=; b=CQKI+y1dGL7oKiyTqb6k75llFv8T6qv3dRE9u2TDQIO5YcnkjRABc0sQmQkC/ujIzIQqNZ Uu6K4hSaVemx5cfO0+0/s/HJCwIpeR+GT3fvejTjy2VzSsniGqEKdgpSIeehxgRtg/IeIB ARhuxHNbOIaxifBPA61tG3zjnsVVM5Q= DKIM-Signature:v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.alibaba.com; s=default; t=1728554299; h=From:To:Subject:Date:Message-Id:MIME-Version; bh=68SYjty2xW+7Wyn01Un2urytR1FCalqpR1eIGlQg1ks=; b=mf2nisBBG10nKgUqhSMsAwLO+Q6nDcI2GCYKBRftJ45PRSRxmDMa+2qFTjBwBcpvT1GeVXp6zalabZHx4gNKuUDESFDBEvrzQ3jmagCREvh9o4gTzCiMNFQXQhljXSiCF2fwDPTuEi41ZL8YRgHKRO3vwRvNUot2aMvwUvBn/N8= Received: from localhost(mailfrom:baolin.wang@linux.alibaba.com fp:SMTPD_---0WGlzQXW_1728554297 cluster:ay36) by smtp.aliyun-inc.com; Thu, 10 Oct 2024 17:58:18 +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: [RFC PATCH v3 0/4] Support large folios for tmpfs Date: Thu, 10 Oct 2024 17:58:10 +0800 Message-Id: X-Mailer: git-send-email 2.39.3 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 3901B20010 X-Rspam-User: X-Rspamd-Server: rspam05 X-Stat-Signature: 479r6xhdcfzuwak8yiwdm64u51ajd6m3 X-HE-Tag: 1728554300-400776 X-HE-Meta: U2FsdGVkX1+nzlJUH3Fpb0+77slLGbbbeRr33fnOo5n3jxXlYEiKDARS2Rx5IXSXGRHQvJLxsoqxe+FvNRxJVErrAxH8263BTACa04wszm2Y972PkRC/Ko90pLNNKclEy8yx+tC0YzJAXop2BAu5Pq28NLmuW/M0eLm5ebgrIbJumMwgtADcYQTS48Tuf+W0T4OSYQQEut5buLpA2lT3UMs6m+PyxXGLMHpAO0b61nSBYYixB+T5wE5uHMvE3ZS0UjmMoBUOosJguAPIcCTzLoB6u+5a2Wnutfs0kFbDMuyMyyFxUs5HKtgXSHjhrZOl2ca0jdCgusWpBFTO6fGth3AIzlxO40ZzrtQ+cXo47sMzE5ywVchcCDM9gEa67wyPaD1OxdUOTgt8tkPrX6z7030joBl3i77ItWjJxxT4pCOlHeyx0XPL5k66PqpFcu5+KECZWqfQWjnhL+fMr9+STqVlLsdcFi1MxGAETmtFgFRpKKYIpdz1zwKltwYGZwWBCocSPPHxsCyjUvzWjJr1VYiwVGu8ho5KhMBhpMO3KhpLQgBq+o4I6R2cXiXY5KOOMDj18c681232eN02bTnHvXSzHF6/yD8yrUqbElG+7ERHgLWt5UzrYHJ0so8hnjiHCKG0lCo36PGk18elnh6bcDYhCsh56LGNARCfSrajYOF7uFKB4T+ks6152RhAqI/RHz9YYNeNs8rIDUcKJutFjleUIj/kYa2fDQ1LqrRBidAQEP2kOQQ+kvcI7g7j94cZ8lPwAjYDSJ07vX7b03B5+zU9N9j1JEPf+U6Lv/kyTJF5IzMSJkXxJaGGyUfxNOMO000Y8/ouYTGDu6dyQVkT6hOZovzmMOu8yGewlavtA5F/eLrwd+oi300LAfZ7G57ncgbQ6lf+qefgacZj4wmjHTEKc/djV4Okapjg2Xx4b6EkpXXjrqJU0USNcx1zvvPF3vyjSTj4YXbWleJ+7cF 4aCFAhhS q1RrgmhZAEh1FqRNT4HgkDsVFKHBciVL6UcX58FMzqNRvmjvXColX7vuEOZtlK7fy/3wgIOybODk7p3+QP2/v9PpD2ZzOEc1bARjWU/ifOi1dUgoOxQDp1KwqipHDdIpw079NCP8gDY9iOI0s+q/0mFkQw3sFf0tYuSrH5v+46IBHFdNFJ7A98d3ugr792nD5fdoEI8aWCtyTnEo= 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: Hi, This RFC patch series attempts to support large folios for tmpfs. Considering that tmpfs already has the 'huge=' option to control the THP allocation, it is necessary to maintain compatibility with the 'huge=' option, as well as considering the 'deny' and 'force' option controlled by '/sys/kernel/mm/transparent_hugepage/shmem_enabled'. Add a new huge option 'write_size' to support large folio allocation based on the write size for tmpfs write and fallocate paths. So the huge pages allocation strategy for tmpfs is that, if the 'huge=' option (huge=always/within_size/advise) is enabled or the 'shmem_enabled' option is 'force', it need just allow PMD sized THP to keep backward compatibility for tmpfs. While 'huge=' option is disabled (huge=never) or the 'shmem_enabled' option is 'deny', it will still disable any large folio allocations. Only when the 'huge=' option is 'write_size', it will allow allocating large folios based on the write size. And I think the 'huge=write_size' option should be the default behavior for tmpfs in future. Any comments and suggestions are appreciated. Thanks. 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 (4): 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 to the write and fallocate paths for tmpfs docs: tmpfs: add documention for 'write_size' huge option Documentation/filesystems/tmpfs.rst | 7 +- include/linux/pagemap.h | 16 ++++- mm/shmem.c | 105 ++++++++++++++++++++-------- 3 files changed, 94 insertions(+), 34 deletions(-) -- 2.39.3