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,