From patchwork Thu Oct 17 14:14:56 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kefeng Wang X-Patchwork-Id: 13840106 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 3FE62D374A0 for ; Thu, 17 Oct 2024 14:15:21 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 079656B0089; Thu, 17 Oct 2024 10:15:20 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id F1CEB6B0095; 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 D73EE6B0098; Thu, 17 Oct 2024 10:15:19 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 9EE986B0089 for ; Thu, 17 Oct 2024 10:15:19 -0400 (EDT) Received: from smtpin08.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 5AF731A0C1B for ; Thu, 17 Oct 2024 14:14:59 +0000 (UTC) X-FDA: 82683291138.08.1F4599E Received: from szxga05-in.huawei.com (szxga05-in.huawei.com [45.249.212.191]) by imf05.hostedemail.com (Postfix) with ESMTP id 6AC89100027 for ; Thu, 17 Oct 2024 14:14:57 +0000 (UTC) Authentication-Results: imf05.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf05.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.191 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: references; bh=VIJflB/6+BG8+AdWFh8yAYIPT+e0GUbMSvWLYNryz8Y=; b=RpThWSmHSAsW/8rcSKj4F53lYdcwiRkgDFG4JuCFtwTT5mZOLeFXC03t5G2Qa9rgpwU5lv e6Icrs+KflvEmx4hGgigtSjiP+lEBctAGbl68zD8kVG4EXPIOuHVZlW2aUAtYmRNmJesqP peebcZFiCPPqn0bj22ZoHcezxWWhqwc= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1729174373; a=rsa-sha256; cv=none; b=TkmzJhOQS3nT4qhYEGpAURhfcPbQ/5SZ8k93Si88xVZ/Xk1ipDUvKdY8stc3mjX7KMSB3Z i4CBXoxxXL/iPLkXGI+SIjjLqGva0+6P02YI+qtEbo9gW4wppyb+8IEIb80WcrLTV1bC32 15ixsrAu51Kd8NrB5dNstEK51z+TXEA= ARC-Authentication-Results: i=1; imf05.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf05.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.191 as permitted sender) smtp.mailfrom=wangkefeng.wang@huawei.com Received: from mail.maildlp.com (unknown [172.19.163.44]) by szxga05-in.huawei.com (SkyGuard) with ESMTP id 4XTqZX10q9z1jB0d; Thu, 17 Oct 2024 22:13:56 +0800 (CST) Received: from dggpemf100008.china.huawei.com (unknown [7.185.36.138]) by mail.maildlp.com (Postfix) with ESMTPS id A1BC3140360; Thu, 17 Oct 2024 22:15:11 +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: huge_memory: move file_thp_enabled() into huge_memory.c Date: Thu, 17 Oct 2024 22:14:56 +0800 Message-ID: <20241017141457.1169092-1-wangkefeng.wang@huawei.com> X-Mailer: git-send-email 2.27.0 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: 6AC89100027 X-Stat-Signature: b84h7s9uuwqjzko6t3uhy78hoshcahu9 X-Rspamd-Server: rspam09 X-Rspam-User: X-HE-Tag: 1729174497-702119 X-HE-Meta: U2FsdGVkX19yj8jzil5E0ACE6cEbqigQV2JzRaHVNlvPVtBSaDwWSjTPXK2yDU5MfmAURK2sazBifKb9fFdWIKV0yyVH0Z1JNufjzbINTrTmWsEwIzulYYwmlayntVRaaeSXRG0cKJ3nda60MWxzBQLOEAKU3yDHj5mEZvA+3vJWBU+xTyPFA6TfBVJx7MZVho4ddN0d0ENia/JFGLNVu0zp77CJETyli3FBnnhylFi+saaASFghfjwfF2Ceq4p6s/QCo8EAWRi/ud0IhORiDHUURn5Gs16E5DEBg+nOFOWBrI/CCCSSnyv3JzcWKtqX6q+d/jDHXhe9nCq9PGPswUTCZjmbbGoAtJEP/nUPN+5WD2P75CRN8T6pOiITTSN/L/4ZMnBA5Zos1nFZZkAhu0nVjWuXJnTcPKVMnXOJ6T+tySprKbhAfLvtMmCSvQcSJkGsFM4uLw1TuCVHcN9ZEe30tgTedqtd+DHD+cHuoxrLQEnegS/LFU5ZYivj9g0tzwSJ8/UNAM3aZbVNqtcnggurbL4wQzoAkqjU6N0T2vb2n0sArUNfjp+1mpSwapqXMZR66CymmbcsypjfG8LqM00N7mWazJevAo3JFK87n+ea5TP7H6igYRVH1ZJQLzYo22kwq66cVtdQOKvTI8ekHvrVgUgZAi4tiiBdhbtQe+Csv9OvVqBQkwO3tXn+KegSrrXRr375BGxhIKHGhiLoUefOE8HKA/Xfvn3weqPmFYThEJuPlBfHQXmfLnhQnUhu48J85WUHb/RGzKCF0LFaTbh4Y/WX30aEdSOuAcYD9skl6yiTcFKWbd1vSQIM0fuFGW5c1NvCfcWYIN+5YJE9NqYsinAyTiBtkJAPzLtVdf5ANC0E84kkuSskPt5bityL8li0C90gOR04MpsKV7E0rsce0Yj/7SB46jK9lYGBRbp6DWAE1RugvGhjgsoNJSbE/+oxoLtVXx7bAhZC0nb 1sQ/CTaj TQopc61bVAFeg4i2/rSbPzfsJEqztEHHvA4ipLs4LUNCS0C4qY1u05X21zUzfr9drNiL45jCcY87E6HETdN5/ze+DxVcLzrpc6V/iPXmNmYStf4E8RQwEBNahk5oL0ku50+1obVMBsATF4gyAUZu/pcpPj+w5MRLIspv4gHbp3MjDm72mNitK9C3tE7ZwRX5WihzP72dmqkMSYE5eEMe2fYjaWCcYbTWQAm0sZMlgpktLxn0= 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. Acked-by: David Hildenbrand Reviewed-by: Baolin Wang Signed-off-by: Kefeng Wang --- v2: - Add ACK/RB and send separately 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 d5f824d5e1c5..c59e5aa9b081 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 589876d14bb8..830d6aa5bf97 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,