From patchwork Thu Oct 10 06:10:24 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kefeng Wang X-Patchwork-Id: 13829520 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 0CEF5CF07A9 for ; Thu, 10 Oct 2024 06:10:45 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 19E776B0088; Thu, 10 Oct 2024 02:10:39 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id D4B766B008A; Thu, 10 Oct 2024 02:10:38 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B04A66B0088; Thu, 10 Oct 2024 02:10:38 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 5274A6B0089 for ; Thu, 10 Oct 2024 02:10:38 -0400 (EDT) Received: from smtpin17.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 479BEA1548 for ; Thu, 10 Oct 2024 06:10:32 +0000 (UTC) X-FDA: 82656668514.17.65584BB Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by imf13.hostedemail.com (Postfix) with ESMTP id 66CC92000E for ; Thu, 10 Oct 2024 06:10:34 +0000 (UTC) Authentication-Results: imf13.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf13.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.187 as permitted sender) smtp.mailfrom=wangkefeng.wang@huawei.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1728540485; 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-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=gUPt4Bg031gVM3Ie3763fCM/7ZrTJzPDchf7D+BzA1Q=; b=q/oI8oeeG7E7JbkAe1kjVKdsYIBbQY4xz7NLrErTtG0FDJ1WTfpdvOU//CdWooJ6vqBjLt TtRt/t0dIQ/JyLTy/jgiZRwy17LcoK8qHo+i+QaZh65FfmLYSDFa1H28g0B98G4YAG+tnP U9DwvuJefNx8VWqTFG0W+y5j+Rq9Ygw= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1728540485; a=rsa-sha256; cv=none; b=oDd99Ftcr+QJBwDDqtIqEHscsPzJyTEQjHzclz70py1V+xG3+d9OxVr/GUJPS9WF567AXZ d8obumSYWkxIkU12fdDtpIhkH6rrC9QKZVd11fG3T8WSN+SIUjhBkm9gr/to37ZjHWtKbN jA7WQRyOKFpJ/AHFuMJvHDAdZT2tjK8= ARC-Authentication-Results: i=1; imf13.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf13.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.187 as permitted sender) smtp.mailfrom=wangkefeng.wang@huawei.com Received: from mail.maildlp.com (unknown [172.19.88.194]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4XPK8W19QNzyT1V; Thu, 10 Oct 2024 14:09:15 +0800 (CST) Received: from dggpemf100008.china.huawei.com (unknown [7.185.36.138]) by mail.maildlp.com (Postfix) with ESMTPS id 58EE31401E9; Thu, 10 Oct 2024 14:10:32 +0800 (CST) Received: from localhost.localdomain (10.175.112.125) by dggpemf100008.china.huawei.com (7.185.36.138) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.11; Thu, 10 Oct 2024 14:10:31 +0800 From: Kefeng Wang To: Andrew Morton CC: Hugh Dickins , David Hildenbrand , Barry Song , Ryan Roberts , Baolin Wang , Matthew Wilcox , , Kefeng Wang Subject: [PATCH 3/3] mm: shmem: remove __shmem_huge_global_enabled() Date: Thu, 10 Oct 2024 14:10:24 +0800 Message-ID: <20241010061024.1846220-4-wangkefeng.wang@huawei.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20241010061024.1846220-1-wangkefeng.wang@huawei.com> References: <20241010061024.1846220-1-wangkefeng.wang@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.112.125] X-ClientProxiedBy: dggems706-chm.china.huawei.com (10.3.19.183) To dggpemf100008.china.huawei.com (7.185.36.138) X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: 66CC92000E X-Stat-Signature: wiixaipzjszxcbuzcxpyunsrqj9cw7km X-Rspam-User: X-HE-Tag: 1728540634-188385 X-HE-Meta: U2FsdGVkX1+wNxw3IdqUMMiQ5nibw22PI7pPn3HrrsemylPJnOx5/inU7DYmKkuBNNkf2j/thGya2GYvW5XIlnxlG1yMQndv6GQN2Er3h1a80uyEIuZHPja2U1KH02cYUQv5SUQagxJaF/pcPqcXL2aiKbFqLeqI7i0BbOM3OovB3LZaoOapSacshbhh+0EI51RUbuEAyJe/7/9UoIpwrQ9Je4nr2qY2Dg3lR0QQS74Cj60nPs1DAEFoxWY8bnqpvdhyf9GPSVAQXpoycMhP/HySrvPOOcWxATFdpfW5iv+KyOpfXrBMka8pQd9XMLi5csc8lCsMFsOQeJ/uz1Q3kkIlK7B0urrT17ZfgxmW+GJa5XZEGWINu/LY/p5vXxHhk3Ugv8f8ka7Sf2pO5UtmOUlfpQ3fLx8VrCqkmEimyUOnZ90jDPO9oadZEp361u2JPVRPLgfbzX4JiLJQQOhtknleHIpQRHIZmW3bDTC/9mo2fzaJ8soFXHZAnFdbgb9acNLWvgKJ0yBtwAt87gbCzx4yM+sWQDwn+lvi2kHRu94LypRD2uPvqAqcAQjMIxl/i+oA+3ALXqS0vg73PfKc2aI9rB9cPSMhSQ28wYYHtNE4z2FbPnAKzbgNWy5ZyODR7Dl72oftANzJmwjg5c7yx8fuLp7MjyF7LVuK5CveXCwBKl/1PEjmXHU5erxhS6mS4R5FhVswEhKPcjL1+ZUhNePfvVOevaWCmNSuVeJdPDLEuOU0HJQ4FS10JmqlxEP5NHJjJ+9uEsK6wJGYh2/ogApNy1RqYravi8OGIHLFlOM8bB72xwGBs+N1XCQyvgonC7ADABBBgNlGSQvGr0iIIpMuXn9fw8znTxINTVYsI8zbj2QJXXH7ClKEyXjucE+LMxpJ217Q0XqOpM25mHwF1IGTwM4aBmNP9LvhiOd6LfZa5KPNdD5iWlfXdRNkDBnjPr9F2ss5w+zKnKCufln oeJgKFwN kOPSxT8tiHohOh3lQxvzLaKcOt2LbPiRXQ8Z/ZhqguZUOZa1jBCbnK4Rng7LkXYzE9ryCURcOS85ysmCf/innY1eU5GXlDHNwv/b+09K0WzqMIEWXzEGYj/uWjjRk0hCOu8gE6WA0YO2gGkxF9fraryZVJZj3BMbCtBo3POnqFC81ldNEbix7AdnhlB54Lb0MKmlN 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: Remove __shmem_huge_global_enabled() since only one caller, and remove repeated check of VM_NOHUGEPAGE/MMF_DISABLE_THP as they are checked in shmem_allowable_huge_orders(), also remove unnecessary vma parameter. Signed-off-by: Kefeng Wang Reviewed-by: Baolin Wang --- mm/shmem.c | 33 ++++++++++----------------------- 1 file changed, 10 insertions(+), 23 deletions(-) diff --git a/mm/shmem.c b/mm/shmem.c index 34a31e7e527c..36ac51d55867 100644 --- a/mm/shmem.c +++ b/mm/shmem.c @@ -548,17 +548,15 @@ 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, - struct vm_area_struct *vma, - unsigned long vm_flags) +static bool shmem_huge_global_enabled(struct inode *inode, pgoff_t index, + loff_t write_end, bool shmem_huge_force, + unsigned long vm_flags) { - struct mm_struct *mm = vma ? vma->vm_mm : NULL; loff_t i_size; - if (!S_ISREG(inode->i_mode)) + if (HPAGE_PMD_ORDER > MAX_PAGECACHE_ORDER) return false; - if (mm && ((vm_flags & VM_NOHUGEPAGE) || test_bit(MMF_DISABLE_THP, &mm->flags))) + if (!S_ISREG(inode->i_mode)) return false; if (shmem_huge == SHMEM_HUGE_DENY) return false; @@ -576,7 +574,7 @@ static bool __shmem_huge_global_enabled(struct inode *inode, pgoff_t index, return true; fallthrough; case SHMEM_HUGE_ADVISE: - if (mm && (vm_flags & VM_HUGEPAGE)) + if (vm_flags & VM_HUGEPAGE) return true; fallthrough; default: @@ -584,17 +582,6 @@ static bool __shmem_huge_global_enabled(struct inode *inode, pgoff_t index, } } -static bool 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) -{ - if (HPAGE_PMD_ORDER > MAX_PAGECACHE_ORDER) - return false; - - return __shmem_huge_global_enabled(inode, index, write_end, - shmem_huge_force, vma, vm_flags); -} - #if defined(CONFIG_SYSFS) static int shmem_parse_huge(const char *str) { @@ -772,8 +759,8 @@ static unsigned long shmem_unused_huge_shrink(struct shmem_sb_info *sbinfo, } static bool 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) + loff_t write_end, bool shmem_huge_force, + unsigned long vm_flags) { return false; } @@ -1170,7 +1157,7 @@ static int shmem_getattr(struct mnt_idmap *idmap, generic_fillattr(idmap, request_mask, inode, stat); inode_unlock_shared(inode); - if (shmem_huge_global_enabled(inode, 0, 0, false, NULL, 0)) + if (shmem_huge_global_enabled(inode, 0, 0, false, 0)) stat->blksize = HPAGE_PMD_SIZE; if (request_mask & STATX_BTIME) { @@ -1687,7 +1674,7 @@ unsigned long shmem_allowable_huge_orders(struct inode *inode, return 0; global_huge = shmem_huge_global_enabled(inode, index, write_end, - shmem_huge_force, vma, vm_flags); + shmem_huge_force, vm_flags); if (!vma || !vma_is_anon_shmem(vma)) { /* * For tmpfs, we now only support PMD sized THP if huge page