From patchwork Wed Nov 13 06:53:28 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Baolin Wang X-Patchwork-Id: 13873206 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 B6515D41C0B for ; Wed, 13 Nov 2024 06:53:46 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 025B28D0005; Wed, 13 Nov 2024 01:53:46 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id F17938D0003; Wed, 13 Nov 2024 01:53:45 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id DB8C08D0005; Wed, 13 Nov 2024 01:53:45 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id BB2808D0003 for ; Wed, 13 Nov 2024 01:53:45 -0500 (EST) Received: from smtpin16.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 6F846A0871 for ; Wed, 13 Nov 2024 06:53:45 +0000 (UTC) X-FDA: 82780155570.16.B76D882 Received: from out30-132.freemail.mail.aliyun.com (out30-132.freemail.mail.aliyun.com [115.124.30.132]) by imf12.hostedemail.com (Postfix) with ESMTP id AD5E640006 for ; Wed, 13 Nov 2024 06:53:21 +0000 (UTC) Authentication-Results: imf12.hostedemail.com; dkim=pass header.d=linux.alibaba.com header.s=default header.b=Gx+FAw0j; dmarc=pass (policy=none) header.from=linux.alibaba.com; spf=pass (imf12.hostedemail.com: domain of baolin.wang@linux.alibaba.com designates 115.124.30.132 as permitted sender) smtp.mailfrom=baolin.wang@linux.alibaba.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1731480694; a=rsa-sha256; cv=none; b=SRiBjOKNcFuYopRWeYjA1fy6gBLXU0EeSq8CHqLviVndVyxoAYCV07qov0Ihpk1rD94R31 Bp4ey8i3Fy2QsLQys2iUqFBUOn2XEp4LiSmBURj3inqcNdyw5UyLKG9XC/LDTeiC7Zk+Gr t+NiaBzOItJYbTPhbh++VWtn0/JRBS8= ARC-Authentication-Results: i=1; imf12.hostedemail.com; dkim=pass header.d=linux.alibaba.com header.s=default header.b=Gx+FAw0j; dmarc=pass (policy=none) header.from=linux.alibaba.com; spf=pass (imf12.hostedemail.com: domain of baolin.wang@linux.alibaba.com designates 115.124.30.132 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=1731480694; 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=rke6BBoCSHEi6qXFioYD5L856RErh718Aq4eT0sMXjI=; b=lpQneFTr/ZQ1jZ1pJQm9CZJQUDauHuHmFsRqzfBF8iWOvkU45mkdn8XLn4bEe7nDhat4/e lWVB8tfuGOEzrspmWUd5kAKZNPLqmBxSopvjkROQltwG80gubJyrZ3bWxJr7hYU8zgF+Zz JS+GRjuGr9Hoc2dbzyfruapKYChe4AE= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.alibaba.com; s=default; t=1731480816; h=From:To:Subject:Date:Message-Id:MIME-Version; bh=rke6BBoCSHEi6qXFioYD5L856RErh718Aq4eT0sMXjI=; b=Gx+FAw0jpkK04Uco3xyp3SMh4b+LHUrRmlm9/PF/c9I6PaDkdafMuTPsqoLbzhFjvVTFd3glq7xuGVxp164+R+kfMmaTNrZE5WSv5QG3yFaBhUmDGNhm2m2wieKxmqrSJmCCxriClyma31R7DhPK7Vkxskhywy8o4g4VRYATRCM= Received: from localhost(mailfrom:baolin.wang@linux.alibaba.com fp:SMTPD_---0WJK6noe_1731480814 cluster:ay36) by smtp.aliyun-inc.com; Wed, 13 Nov 2024 14:53:35 +0800 From: Baolin Wang To: baolin.wang@linux.alibaba.com Cc: 21cnbao@gmail.com, akpm@linux-foundation.org, da.gomez@samsung.com, david@redhat.com, hughd@google.com, ioworker0@gmail.com, linux-kernel@vger.kernel.org, linux-mm@kvack.org, ryan.roberts@arm.com, wangkefeng.wang@huawei.com, willy@infradead.org Subject: [PATCH] mm: shmem: add large folio support for tmpfs fix Date: Wed, 13 Nov 2024 14:53:28 +0800 Message-Id: X-Mailer: git-send-email 2.39.3 In-Reply-To: References: MIME-Version: 1.0 X-Rspamd-Queue-Id: AD5E640006 X-Stat-Signature: htjpzq4f54azikj63p3gqmt8pzunwh9y X-Rspam-User: X-Rspamd-Server: rspam05 X-HE-Tag: 1731480801-745115 X-HE-Meta: U2FsdGVkX1+QfBh6q/gjgaqzwxpa5EujuAAY5J4MlvxtkbjRCVoQBF7cEwt3T6wtaRJcIUMPZy1+1JVmBtehyQPxNME7Gfc1bGoZV2ywFlDDrxC4MPs33wYbI+8OwfV91fbV+OixkGmBXJHb6rBqv50FwWWtdxZnwiw2Mz96MDG09D80FWUoYB5dqs/3ZVDWDPENuPKcT/MKKmXf5JOXbYwAM8uwoHAPtjZAGorDJGyxJPvOx/5ad+xukdLxq8V3iuQHiUXv/w9xdNuQ6XXJxalWqxL9NkLyhnahiqnngTTZRbWwH719f6qxvAP9k6p3giK5FpwVAusFYMWXszxKwuBNKB6h7qtCq9wrlLh5/2J2SrGkE8FdkcJoAypvs9qoJCoLJPKUiN3y2CArbns6EkAMK7gIf3Xx3edeOBFxs0AtbBA/pn7FKt7TvXSoyJwOWWobhOphS4DI0xt1ZORQFpVGILWwAu1LjV/rdVGlfgIGNnU4DQ+1wczV8hXV+RsYJW09ys8TxK+7bH79Wq03tfaKXLLgP9wp8IrLeJTY5m4ELC3aDgBhs+hyHjqCpV/omsC9p7L6qC+ocBcv87vCQ9fwwX+x75necgCcxUOrYPq43ydkTHPCBNAsm3XzC0Ac91WdBI0knEELKjHrKq74Jk1s7NLLgLPI3Onb7sbVEtbchGNdmd+NKipEu3kbH9oNr24GEkpdFQ3RitV4A/5TA1qhCD84Z1Z3Uf50FVeOgZ9cT423Y6VJrXtt2gWI85rUtXoWLeFNoSV70Oo2rN09MXjHytuja2ls954bcENjZdHsoDNY6/1Eg/Y8vwvdr7Merdu5AXUG1pw1VZbH9TD/cPzV9vOjpEnJc/Dwu+fwQ8WfiAYs7tOr0tC63BLA2VLcjWRk49/n5/lqIkmpqWzR5i8lqvgEB0Ah656tixiugbBY240XGATiZZZ/HVATI7KfFWkC7i/1HL+gPay08+C rH3FqrD9 Uoj7Xjm9bmytvA7cnmCMIV2xjooMhZh8iwZXMYmxG+ifxYqiWOwYYT5lY9I66vo0BaHxgG/QuKyiOnglL3B0RDN65Y20C9Qyuml0VDdLrO98nSssAsR+kcOkA7DK6dfmq89XK2Wwmxr6iLsKZhUsvOVvrha3ogIE8dQMVOqUE/hBngFw4/qppTnL6j5eBbdbSv+kfDFym3H0h8lAo8PPvgaJSBYMjpe9dGhDG 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: As David suggested: "We can allow all orders up to MAX_PAGECACHE_ORDER, since shmem_mapping_size_orders() handles it properly", therefore we can drop the 'MAX_PAGECACHE_ORDER' condition. Signed-off-by: Baolin Wang --- mm/shmem.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/mm/shmem.c b/mm/shmem.c index a3203cf8860f..d54b24d65193 100644 --- a/mm/shmem.c +++ b/mm/shmem.c @@ -590,19 +590,19 @@ static unsigned int shmem_huge_global_enabled(struct inode *inode, pgoff_t index 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 @@ -619,12 +619,12 @@ static unsigned int shmem_huge_global_enabled(struct inode *inode, pgoff_t index switch (SHMEM_SB(inode->i_sb)->huge) { case SHMEM_HUGE_ALWAYS: if (vma) - return BIT(HPAGE_PMD_ORDER); + return maybe_pmd_order; return shmem_mapping_size_orders(inode->i_mapping, index, write_end); case SHMEM_HUGE_WITHIN_SIZE: if (vma) - within_size_orders = BIT(HPAGE_PMD_ORDER); + within_size_orders = maybe_pmd_order; else within_size_orders = shmem_mapping_size_orders(inode->i_mapping, index, write_end); @@ -642,7 +642,7 @@ static unsigned int shmem_huge_global_enabled(struct inode *inode, pgoff_t index fallthrough; case SHMEM_HUGE_ADVISE: if (vm_flags & VM_HUGEPAGE) - return BIT(HPAGE_PMD_ORDER); + return maybe_pmd_order; fallthrough; default: return 0;