From patchwork Thu Oct 17 14:14:57 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kefeng Wang X-Patchwork-Id: 13840105 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 4952ED3749A for ; Thu, 17 Oct 2024 14:15:20 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B4E1E6B0092; Thu, 17 Oct 2024 10:15:19 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id AFE0F6B0096; Thu, 17 Oct 2024 10:15:19 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 9C4E66B0095; Thu, 17 Oct 2024 10:15:19 -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 7FA6D6B0089 for ; Thu, 17 Oct 2024 10:15:19 -0400 (EDT) Received: from smtpin26.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 98FEF4155B for ; Thu, 17 Oct 2024 14:15:12 +0000 (UTC) X-FDA: 82683291222.26.DF03C11 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by imf27.hostedemail.com (Postfix) with ESMTP id 5E72940010 for ; Thu, 17 Oct 2024 14:15:05 +0000 (UTC) Authentication-Results: imf27.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf27.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=1729174373; 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=DQMlWgC60CDgseMH3QEdqtQS/2FUhNSLwTRykdVlUFg=; b=k1uuLXr6/n5XcLG6wgpZuJJQRL0ur5QDOWuLM7z+O8BlOwnj7BNiijqyZ6pYwXO46Mk3bg Kyxxm5XvNvx7ht1f1S/ibv+aZTEIIECNidpF0Z/eqkoc4jNyJTWECsTT4WoDi4aPxZp+of S8BmxRFrY8vMvw9vuHW+873Oxkcufps= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1729174373; a=rsa-sha256; cv=none; b=KIcKaQdp6zkLaTIew4/lvCqzHiHGw6qOZIYPldRdGz522TYIfrjVUSfzoCw5FYuJE3W8/N rwHUQYk4R6V9ckLBG1jTHsvFtXv1Ni+bSsIvxC9NO6JbwIjP93ZwfQEyjsW9p5Zm9BF6Ll /PdsZgP3e+Dk9mhzPfzO1YNA+mg2oq0= ARC-Authentication-Results: i=1; imf27.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf27.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.162.254]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4XTqYn6Vvnz10NYh; Thu, 17 Oct 2024 22:13:17 +0800 (CST) Received: from dggpemf100008.china.huawei.com (unknown [7.185.36.138]) by mail.maildlp.com (Postfix) with ESMTPS id 32D2F1800F2; Thu, 17 Oct 2024 22:15:12 +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, 17 Oct 2024 22:15:11 +0800 From: Kefeng Wang To: Andrew Morton , Hugh Dickins CC: David Hildenbrand , Barry Song , Ryan Roberts , Baolin Wang , Matthew Wilcox , , Kefeng Wang Subject: [PATCH v2] mm: shmem: remove __shmem_huge_global_enabled() Date: Thu, 17 Oct 2024 22:14:57 +0800 Message-ID: <20241017141457.1169092-2-wangkefeng.wang@huawei.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20241017141457.1169092-1-wangkefeng.wang@huawei.com> References: <20241017141457.1169092-1-wangkefeng.wang@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.112.125] X-ClientProxiedBy: dggems702-chm.china.huawei.com (10.3.19.179) To dggpemf100008.china.huawei.com (7.185.36.138) X-Rspamd-Queue-Id: 5E72940010 X-Stat-Signature: r74j5uxoog7o35i6amjk1kiynn9ygytf X-Rspamd-Server: rspam09 X-Rspam-User: X-HE-Tag: 1729174505-668646 X-HE-Meta: U2FsdGVkX1+2BVb0AKk/cJOuyo0S2ppwKsZCUbf4ETmIiSDI9bpfOCO0e1zGo3z3Ectrf7YfJpGuscafAFMFQ0cUde5/c5zbE/Fzw69NygoDgNmRUUFq7iRNGkzNoLLnulG2MiMKrCRGPdIqMM6ALtmhfXErDD0NDpQdvEWAd4truXf4tG14odHfUOosATdwHOYSyZ8Qdv/UcWdchTSurzJwfkBbvLn9If35CBLnM38P+gdykSykbXEExGa8ABdHwmswB6DHkXWeanDN+fTdQ6pTHYrG8xDrdCvLcKUM9ULektKToVLzIhdH+FdRnaIBel2ev23Ef5OIkcuyTeTt+0Iy7smkQX4+uVW02NDV/vG+75QX4efd5jCxtwzUpt8edyur4j8cchfgPfAi6aYB3kgjRtTZv3PyFb+Ry/o2cdxwIpHMJftnibWa67laqQzPV9qbx1iand8nSHUI01hjAGBVjdwF6dampc8XXBototXZVZT4mbO1BKVr5ACyc9B8nu/kphHx/YuFZOkzTjuelnNHU575p2bpKsYJ6ph0GJtsuwOsf+HqBldQKAtXFblHEhPcVducOMZ/BAsCkyplBvfu/y7mTf6bzTpB3FXqAjYYuDRZSGCI7oXuiKZ2qw7S8bAktpgu1mKzgwXznqbGaRcDvb19D4aCar5XidD5Lx+DxBNHScSR4PPDD6gHWVkzPRAXPuezG4w+fd4frjCLwqzo6RFfXyZzwirbSGpgl2ko5WtSbTW1BIrbNI+XeOBLzoySDixcXr4Yh9SvdNNXQxsZSTKP1wpZy8+tTtbIL6hPWS0DtGH4pCq0PwXLz9YzsoJ07WIkJGsXV0akgakaza5YO5vdkhyeFdqqPWSj50lvAA7Celj/dj8Kk9/if2metmKembnMKtQlZV9SaRPKoJUeVsBiTePPKZ6NuYy77erxLF98igrqHFHtoGpSELkj3d/jlsn2sTVwr2ByMXD jtcKXXt7 XUpHEfW5cium0tLtt6Zb3tAXQxFG+QM4G+HVeY5CcQm9PwpEKs5xagQnPplN8Cq+JOd9Cxrq1huEN1wbtHnyJGkIbMaLy9rms1Gw+tgPlmOR2yoiPEEAWgk8/l2OnRzxpEu2XE/bIWXqQOJ0tQ3FmKf532vWUmBTrtsyTXBB+ZoEZcPMMZY8i6Vflt/pJqo42TpdLTfvyqMpQXRBhzBZIK5zZfQ== 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. Reviewed-by: Baolin Wang Signed-off-by: Kefeng Wang Acked-by: David Hildenbrand --- v2: - Add RB and send separately mm/shmem.c | 33 ++++++++++----------------------- 1 file changed, 10 insertions(+), 23 deletions(-) diff --git a/mm/shmem.c b/mm/shmem.c index 247c0403af83..e933327d8dac 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) { @@ -1686,7 +1673,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