From patchwork Thu Jan 5 23:04:17 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yann Droneaud X-Patchwork-Id: 13090664 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 D21BFC3DA7A for ; Thu, 5 Jan 2023 23:04:46 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 557A48E0002; Thu, 5 Jan 2023 18:04:46 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 507DF8E0001; Thu, 5 Jan 2023 18:04:46 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 3CE8B8E0002; Thu, 5 Jan 2023 18:04:46 -0500 (EST) 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 2BBAE8E0001 for ; Thu, 5 Jan 2023 18:04:46 -0500 (EST) Received: from smtpin28.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 06C93AAD35 for ; Thu, 5 Jan 2023 23:04:46 +0000 (UTC) X-FDA: 80322276972.28.07FE438 Received: from smtp3-g21.free.fr (smtp3-g21.free.fr [212.27.42.3]) by imf07.hostedemail.com (Postfix) with ESMTP id 26FF440017 for ; Thu, 5 Jan 2023 23:04:43 +0000 (UTC) Authentication-Results: imf07.hostedemail.com; dkim=none; dmarc=none; spf=pass (imf07.hostedemail.com: domain of ydroneaud@opteya.com designates 212.27.42.3 as permitted sender) smtp.mailfrom=ydroneaud@opteya.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1672959884; 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-transfer-encoding:content-transfer-encoding: in-reply-to:references; bh=lT/Za9UI5VMPlUELJMLsKwwOBGEarAKrskSzdn3KoRM=; b=w5Yp1CoHP/WpRn+EPeT5L3Aha1CG5wg/tSmzGDnmSMT8lIFjt8+P3zBb/NMGAaMzAhhUF0 BqecuCy6I12zU0y/gax/xOYCXRrDeKabuONC65u4lard7s8BNIor3beIrwTXisU0n1eoOH lm9x6sH2Qnoi4nx/DrCaVCfB2RNCS9s= ARC-Authentication-Results: i=1; imf07.hostedemail.com; dkim=none; dmarc=none; spf=pass (imf07.hostedemail.com: domain of ydroneaud@opteya.com designates 212.27.42.3 as permitted sender) smtp.mailfrom=ydroneaud@opteya.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1672959884; a=rsa-sha256; cv=none; b=HEzYAnJZ7NGtxAYN+i6vTwCoVrqLo03jmEIdVv8oqUbglszvQNtnOvg4CKnnD4hljgorlx TbvL7iunO/eli/z2EHFU0r8Rl7g8EROeA/kMRO6qz0q1HX7UL/I5kd3grOrG0VaKKscUqV Oh8zsHro9jaNZUXsHvihWtaznEQg1OY= Received: from localhost (unknown [IPv6:2a01:e35:39f2:1220:c70:c024:95ee:ebbb]) by smtp3-g21.free.fr (Postfix) with ESMTPS id 17FD613F838; Fri, 6 Jan 2023 00:04:37 +0100 (CET) From: Yann Droneaud To: Hugh Dickins , Andrew Morton Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, Yann Droneaud Subject: [PATCH] shmem: optimize shmem_huge_enabled() and shmem_is_huge() when !CONFIG_TRANSPARENT_HUGEPAGE Date: Fri, 6 Jan 2023 00:04:17 +0100 Message-Id: <20230105230417.966438-1-ydroneaud@opteya.com> X-Mailer: git-send-email 2.37.2 MIME-Version: 1.0 X-Rspamd-Queue-Id: 26FF440017 X-Stat-Signature: cegbktcsf9is3f3fgnpetc6pa98p1nba X-Rspam-User: X-Rspamd-Server: rspam08 X-HE-Tag: 1672959883-885284 X-HE-Meta: U2FsdGVkX19wCcRJ24PZc4w6r8Vz4FLQ3iSGJjD58l8Qya4Yk9IAzVcqOCjmHCKWeUvSRhTrTms66kpktSgnNAmD3L1pehS229vEwvf4gCRMY3yyzYsodRJ9bCPaASjJPHE4U4VosyFxfd2m7JIh5iAR92ycEzCw0gkTTIKr6mtGSIq9j/l3DpY3tF6zE7QXIWeuT/IumGFC5q0HXbO7puIaFMABaVxBtZMhjOrqGuV4z3srNu2Iv39MRztqWHDDc2IYZbmKEHq4YefBwWTy2/jZjas26vFsEG4KCmaOYR4HrsHqNRR97aghyvkdPhpQHGFOiRuqZjMbYR9i7SZz3zyN71PMbCQ0VLvMrDlHJizkoBIKezDu4l/hefM5klHSsowVulIz2Jut4GeOjYLDKoQhIkW+DsoSVV1txqvlT01pRt73KxbvQv7eXl94WSb1UHVlwuwq3hTGwzM64obXwYOt7LGESR4vyedaccreEhrfE7x95AqdcZ5LVTfT17iMX6sdmffEg7F1jvr66P8nur6p8f/Bv+ey8dmEAhJcJ5M/Rgf+bOa+43NSQ/py/OhJATSe25ZXvrrbqAvAsUiFNyTKMIbGOkqR6jDwNGU3cSbKi3jhRZwrffmZPwuPeMwelbRUEt4JhfYLIfHvgg8g60/UF7kBv/nWv7Czi1gK//ObsuM9LvDeRBJDtNfYgpUz9A/BUROLTEFcDynJpoiZ51t7jXwzWD70ketC65r83RbIhqcfZkGmSsEAZGtDcxWBMKjMsU+gWOQe4W6k+0a/kYMOARm7XmpX6ml6TzS8L1dT/y9Vm6NQz8rpiZsZT7SjkymGDpBhsAtVGpW8HN2y1bBogpcCCn37EswO9oFqtPhsyDrtECxbsEF0mJdFxyMp 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: When CONFIG_TRANSPARENT_HUGEPAGE is not set, shmem_is_huge() is not needed outside of shmem.c. Signed-off-by: Yann Droneaud --- include/linux/shmem_fs.h | 9 +++++++++ mm/shmem.c | 4 ++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/include/linux/shmem_fs.h b/include/linux/shmem_fs.h index d500ea967dc7..18a4968ded73 100644 --- a/include/linux/shmem_fs.h +++ b/include/linux/shmem_fs.h @@ -92,6 +92,7 @@ extern struct page *shmem_read_mapping_page_gfp(struct address_space *mapping, extern void shmem_truncate_range(struct inode *inode, loff_t start, loff_t end); int shmem_unuse(unsigned int type); +#ifdef CONFIG_TRANSPARENT_HUGEPAGE extern bool shmem_is_huge(struct vm_area_struct *vma, struct inode *inode, pgoff_t index, bool shmem_huge_force); static inline bool shmem_huge_enabled(struct vm_area_struct *vma, @@ -100,6 +101,14 @@ static inline bool shmem_huge_enabled(struct vm_area_struct *vma, return shmem_is_huge(vma, file_inode(vma->vm_file), vma->vm_pgoff, shmem_huge_force); } +#else /* !CONFIG_TRANSPARENT_HUGEPAGE */ +static inline bool shmem_huge_enabled(struct vm_area_struct *vma, + bool shmem_huge_force) +{ + return false; +} +#endif /* CONFIG_TRANSPARENT_HUGEPAGE */ + extern unsigned long shmem_swap_usage(struct vm_area_struct *vma); extern unsigned long shmem_partial_swap_usage(struct address_space *mapping, pgoff_t start, pgoff_t end); diff --git a/mm/shmem.c b/mm/shmem.c index c301487be5fb..9437c200a311 100644 --- a/mm/shmem.c +++ b/mm/shmem.c @@ -678,8 +678,8 @@ static long shmem_unused_huge_count(struct super_block *sb, #define shmem_huge SHMEM_HUGE_DENY -bool shmem_is_huge(struct vm_area_struct *vma, struct inode *inode, - pgoff_t index, bool shmem_huge_force) +static inline bool shmem_is_huge(struct vm_area_struct *vma, struct inode *inode, + pgoff_t index, bool shmem_huge_force) { return false; }