From patchwork Thu Oct 10 06:10:22 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kefeng Wang X-Patchwork-Id: 13829519 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 E0E6ECF07AA for ; Thu, 10 Oct 2024 06:10:42 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E69696B0085; Thu, 10 Oct 2024 02:10:38 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id C3EA16B008C; 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 92C826B0085; Thu, 10 Oct 2024 02:10:38 -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 51C8C6B0088 for ; Thu, 10 Oct 2024 02:10:38 -0400 (EDT) Received: from smtpin15.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id EEFFAA0E09 for ; Thu, 10 Oct 2024 06:10:31 +0000 (UTC) X-FDA: 82656668514.15.6C8D8DA Received: from szxga07-in.huawei.com (szxga07-in.huawei.com [45.249.212.35]) by imf05.hostedemail.com (Postfix) with ESMTP id A301C100008 for ; Thu, 10 Oct 2024 06:10:33 +0000 (UTC) Authentication-Results: imf05.hostedemail.com; dkim=none; spf=pass (imf05.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.35 as permitted sender) smtp.mailfrom=wangkefeng.wang@huawei.com; dmarc=pass (policy=quarantine) header.from=huawei.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1728540498; 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=lyLfcM7cgIVzdVCRNuLYy+ddyxUoyJfdyFy2IKmDSmg=; b=mhhfbceFIPR8D9c4ZkMJDR/MTj5vL2ULt0RI5nUVNtFmbFrugwZ5RfK03y3Z5hRclmJK/i 98iS/+jY9WANLx9cji19XIUbqQeJq20tMp/4ePSuVjV0BkR42iFN2JpoOrgIqH3Nd7P/OJ LRFDw8ZAQZPU29r1mwUZyNDysXe9q4A= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1728540498; a=rsa-sha256; cv=none; b=X3QKeD7LW2ApRVh5hfydyJ5fJnaakcm4DumBzQJvW9nEuh+ATJr07JqMw71XIzjPw4xi9B YYeDJQhl28EyumFLHQsRDJhOZZjH8wZn6mrv/FpxSWmbe6VppMSR5y+2bboAlKsu2rk+mb LhCdiz+7xwGmOcuVOXtMqdcjRLCk4WQ= ARC-Authentication-Results: i=1; imf05.hostedemail.com; dkim=none; spf=pass (imf05.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.35 as permitted sender) smtp.mailfrom=wangkefeng.wang@huawei.com; dmarc=pass (policy=quarantine) header.from=huawei.com Received: from mail.maildlp.com (unknown [172.19.162.112]) by szxga07-in.huawei.com (SkyGuard) with ESMTP id 4XPK8h3Wy2z1S9Cc; Thu, 10 Oct 2024 14:09:24 +0800 (CST) Received: from dggpemf100008.china.huawei.com (unknown [7.185.36.138]) by mail.maildlp.com (Postfix) with ESMTPS id 5FEFA140360; Thu, 10 Oct 2024 14:10:31 +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:30 +0800 From: Kefeng Wang To: Andrew Morton CC: Hugh Dickins , David Hildenbrand , Barry Song , Ryan Roberts , Baolin Wang , Matthew Wilcox , , Kefeng Wang Subject: [PATCH 1/3] mm: huge_memory: move file_thp_enabled() into huge_memory.c Date: Thu, 10 Oct 2024 14:10:22 +0800 Message-ID: <20241010061024.1846220-2-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-Rspam-User: X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: A301C100008 X-Stat-Signature: m6u11497bubexeqryk4yaudfgbut1ss4 X-HE-Tag: 1728540633-344143 X-HE-Meta: U2FsdGVkX18l8lGC8JOEBlCWTboXXt170WZIqw3q/DNXrSyBmUM4H/2kM8GLuombANwLCnQ4VDhTNzNBUvkvAejuFAUGYsUePm6Dh5rCuzUto37yBJ9f0+3lZVE8i4OTrrLeLl2cMBomEVlmHNck+b9FR/ij5Iiy6bh70Wdmk1sPFF//tcgdHvRcimdqggMMiJjeyqz6e1Nqmkaionx7SMoayIb5qaFaEILJXJYtxQoB/eCgANV9MFfTd02uXW+elOkQ4jkH2uoTttTgrrDvWUaFwMcdmjt08GKTtP9JUv+Tb03eCvVdmjKob6LCwim21jASBGh5BnX3hUnoJYHUpjePnKicEodwAmUtBnkl8wW6hmXa82zIcyhDScXSe23ENLr84CxnLKNiKBsY42AzTCHppyjN6sTbBCy+CN7z+5gM08qk8H/swfOBQcHbd2xdQA9ZlT7SziJy3wpOUldfl8KdFaB7E8+YzufD7oTRFRD2VHWmbtoYYKlkpdGxxcVXi3SUNdxpdtMxmtPdHgGHNwgw0c+4msMQi4PZ6fe3ekiJ5CrDVJbk5pC/Ju4ZqIWFwVIgLWkf/DA/Qw42MDEVsfMs+p5449VZa/Y2oMOPY9l/WlDVD8CgftWv779SgZSM/APPNb6E2aVoe0VUv8H2pCHc6/ULEf0IyGzTCwizSgiBGeAptg1LTJ5UH3204S1C2JOAkLhbTbt42LGiTmhv0b3SMlz1qt5ShhhOCbgRcbiVGYeqTH/9ejQgXfZ9qj1+C6vfsM8qli4dIOf3NH+U3Em+k2XS1oeqO/cPmv6AzrNr5j9u2ZEB+vDGGG7pCkm2T7apRYTEMQ9ckcL7r0eB9t8+hFjp7U7pH6wED7NvWLDrlrNw9yNcZ/X0wlLGJZwn4sb6EEnQSRsNA0Sgm4r/unIOk/ISkFClCRnGNOg+kzwiWrzWsJ4T0/wJCqGR46humc4HPZLpapDq82NHU0i 7M35ydh8 tnTnc4F9wNZv5vgcCL68Ze1ZYWsuQk7nmaEPOIRWbl9We31mnMrbzPb9Tn7rynvdwcP5rFnpsdcGtSCHH7upLhBqkGTEqMQvvlxO92fGAgejlg/fs3nBIX3QYd1QipQtYiPbsOS+RDaqveWvQTGKQU3E1Lw7et9Jpk5W+AQsW8ZKfLh0n48Kk/0QFq6aixz9WCJPn 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: The file_thp_enabled() only used in __thp_vma_allowable_orders(), so move it into huge_memory.c, also check READ_ONLY_THP_FOR_FS ahead to avoid unnecessary code if config disabled. Signed-off-by: Kefeng Wang Acked-by: David Hildenbrand Reviewed-by: Baolin Wang --- include/linux/huge_mm.h | 13 ------------- mm/huge_memory.c | 15 +++++++++++++++ 2 files changed, 15 insertions(+), 13 deletions(-) diff --git a/include/linux/huge_mm.h b/include/linux/huge_mm.h index 3eca60f3d512..795df660efa5 100644 --- a/include/linux/huge_mm.h +++ b/include/linux/huge_mm.h @@ -253,19 +253,6 @@ static inline unsigned long thp_vma_suitable_orders(struct vm_area_struct *vma, return orders; } -static inline bool file_thp_enabled(struct vm_area_struct *vma) -{ - struct inode *inode; - - if (!vma->vm_file) - return false; - - inode = vma->vm_file->f_inode; - - return (IS_ENABLED(CONFIG_READ_ONLY_THP_FOR_FS)) && - !inode_is_open_for_write(inode) && S_ISREG(inode->i_mode); -} - unsigned long __thp_vma_allowable_orders(struct vm_area_struct *vma, unsigned long vm_flags, unsigned long tva_flags, diff --git a/mm/huge_memory.c b/mm/huge_memory.c index cc346c771921..d23e4aab7511 100644 --- a/mm/huge_memory.c +++ b/mm/huge_memory.c @@ -83,6 +83,21 @@ unsigned long huge_anon_orders_madvise __read_mostly; unsigned long huge_anon_orders_inherit __read_mostly; static bool anon_orders_configured __initdata; +static inline bool file_thp_enabled(struct vm_area_struct *vma) +{ + struct inode *inode; + + if (!IS_ENABLED(CONFIG_READ_ONLY_THP_FOR_FS)) + return false; + + if (!vma->vm_file) + return false; + + inode = file_inode(vma->vm_file); + + return !inode_is_open_for_write(inode) && S_ISREG(inode->i_mode); +} + unsigned long __thp_vma_allowable_orders(struct vm_area_struct *vma, unsigned long vm_flags, unsigned long tva_flags, From patchwork Thu Oct 10 06:10:23 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kefeng Wang X-Patchwork-Id: 13829517 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 2C768CF07AA for ; Thu, 10 Oct 2024 06:10:39 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 9322E6B0093; Thu, 10 Oct 2024 02:10:38 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 8B84E6B008A; 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 730CF6B0092; Thu, 10 Oct 2024 02:10:38 -0400 (EDT) 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 530956B008A for ; Thu, 10 Oct 2024 02:10:38 -0400 (EDT) Received: from smtpin25.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id F4136140C1C for ; Thu, 10 Oct 2024 06:10:34 +0000 (UTC) X-FDA: 82656668514.25.AC00D7C Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by imf12.hostedemail.com (Postfix) with ESMTP id 9876A40002 for ; Thu, 10 Oct 2024 06:10:34 +0000 (UTC) Authentication-Results: imf12.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf12.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=vbxzBkF71Jj6QrOZLI0tKHBjDkIXQOuyWDX88kTEaQM=; b=idMy3BtFRqHyqkqEVyny2nvJtXt7a4RgITXisBQZtzi916636zUWCmS/95AM64lJxgdO0K B49K3z6X6y4VslzWfn6Ns+QVVPdpuW/ZYPCnAC/nvTu1EYLKMTfNEOmOk3jmHUf0CZYT0v mSQR2CpK/+OTtOZso9HQ286zPsYtfr4= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1728540485; a=rsa-sha256; cv=none; b=t1LC+OzcmV1f5SDhcvfyD5EMI4cO2Kka3eAJ+ey1NNrfS5PN3CYBXlO+1kDopYU3lNPAkE 14NI+wcfiLGQ+zyug+93vLofZJanoyTaFtiq9Sh0xe9F7Pa+lWGFeLXV7ss0zSiTzASqr9 PnpHMYSxHM173BhpxCG7FLgQc25J5N0= ARC-Authentication-Results: i=1; imf12.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf12.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 4XPK7z1M3Jz10N4N; Thu, 10 Oct 2024 14:08:47 +0800 (CST) Received: from dggpemf100008.china.huawei.com (unknown [7.185.36.138]) by mail.maildlp.com (Postfix) with ESMTPS id D5FD218010F; Thu, 10 Oct 2024 14:10:31 +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 2/3] mm: huge_memory: add thp_vma_disabled() Date: Thu, 10 Oct 2024 14:10:23 +0800 Message-ID: <20241010061024.1846220-3-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: 9876A40002 X-Stat-Signature: itx1owf5q8m6fch7fpewc4okydiwao9s X-Rspam-User: X-HE-Tag: 1728540634-915115 X-HE-Meta: U2FsdGVkX1+u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cHGR7OQL1e12ipXkG2BzWvOJfMz9niSsS+E2BXpq/Rd+cw233RwJD66A1Ae4flTPi8tu/MmQT42YwUMKxGxq8V13 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 thp_vma_disabled() helper to shared by shmem_allowable_huge_orders() and __thp_vma_allowable_orders(). Signed-off-by: Kefeng Wang Signed-off-by: Kefeng Wang Signed-off-by: David Hildenbrand --- include/linux/huge_mm.h | 19 +++++++++++++++++++ mm/huge_memory.c | 13 +------------ mm/shmem.c | 7 +------ 3 files changed, 21 insertions(+), 18 deletions(-) diff --git a/include/linux/huge_mm.h b/include/linux/huge_mm.h index 795df660efa5..d77891332b35 100644 --- a/include/linux/huge_mm.h +++ b/include/linux/huge_mm.h @@ -309,6 +309,25 @@ struct thpsize { (transparent_hugepage_flags & \ (1<vm_mm->flags))) + return true; + + /* If the hardware/firmware marked hugepage support disabled. */ + if (transparent_hugepage_flags & (1 << TRANSPARENT_HUGEPAGE_UNSUPPORTED)) + return true; + + return false; +} + unsigned long thp_get_unmapped_area(struct file *filp, unsigned long addr, unsigned long len, unsigned long pgoff, unsigned long flags); unsigned long thp_get_unmapped_area_vmflags(struct file *filp, unsigned long addr, diff --git a/mm/huge_memory.c b/mm/huge_memory.c index d23e4aab7511..30912a93f7dc 100644 --- a/mm/huge_memory.c +++ b/mm/huge_memory.c @@ -123,18 +123,7 @@ unsigned long __thp_vma_allowable_orders(struct vm_area_struct *vma, if (!vma->vm_mm) /* vdso */ return 0; - /* - * Explicitly disabled through madvise or prctl, or some - * architectures may disable THP for some mappings, for - * example, s390 kvm. - * */ - if ((vm_flags & VM_NOHUGEPAGE) || - test_bit(MMF_DISABLE_THP, &vma->vm_mm->flags)) - return 0; - /* - * If the hardware/firmware marked hugepage support disabled. - */ - if (transparent_hugepage_flags & (1 << TRANSPARENT_HUGEPAGE_UNSUPPORTED)) + if (thp_vma_disabled(vma, vm_flags)) return 0; /* khugepaged doesn't collapse DAX vma, but page fault is fine. */ diff --git a/mm/shmem.c b/mm/shmem.c index 0a2f78c2b919..34a31e7e527c 100644 --- a/mm/shmem.c +++ b/mm/shmem.c @@ -1683,12 +1683,7 @@ unsigned long shmem_allowable_huge_orders(struct inode *inode, loff_t i_size; int order; - if (vma && ((vm_flags & VM_NOHUGEPAGE) || - test_bit(MMF_DISABLE_THP, &vma->vm_mm->flags))) - return 0; - - /* If the hardware/firmware marked hugepage support disabled. */ - if (transparent_hugepage_flags & (1 << TRANSPARENT_HUGEPAGE_UNSUPPORTED)) + if (thp_vma_disabled(vma, vm_flags)) return 0; global_huge = shmem_huge_global_enabled(inode, index, write_end, 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/pcPqcXL2aiKbFqLeqI7i0BbOM3OovB3LZaoOapSacshbh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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