From patchwork Mon May 6 08:46:25 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Baolin Wang X-Patchwork-Id: 13655142 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 CA609C4345F for ; Mon, 6 May 2024 08:46:52 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 321676B0083; Mon, 6 May 2024 04:46:52 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 2CB616B0087; Mon, 6 May 2024 04:46:52 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 192F96B0085; Mon, 6 May 2024 04:46:52 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id F0A1D6B007B for ; Mon, 6 May 2024 04:46:51 -0400 (EDT) Received: from smtpin03.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 9396E1208AE for ; Mon, 6 May 2024 08:46:51 +0000 (UTC) X-FDA: 82087340622.03.85BD006 Received: from out30-119.freemail.mail.aliyun.com (out30-119.freemail.mail.aliyun.com [115.124.30.119]) by imf06.hostedemail.com (Postfix) with ESMTP id A810E18001E for ; Mon, 6 May 2024 08:46:48 +0000 (UTC) Authentication-Results: imf06.hostedemail.com; dkim=pass header.d=linux.alibaba.com header.s=default header.b="M4G/dyZ5"; spf=pass (imf06.hostedemail.com: domain of baolin.wang@linux.alibaba.com designates 115.124.30.119 as permitted sender) smtp.mailfrom=baolin.wang@linux.alibaba.com; dmarc=pass (policy=none) header.from=linux.alibaba.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1714985209; 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:in-reply-to:references:references:dkim-signature; bh=p4+ojbN485lnDhEdHj7u8+ldhF5xWmY9Y6UtO0qnCFI=; b=uEJvk4MtiUqsse/yYDgYc//VZxmOlxCOUMu+gZRPvdjqsMN4cr5MRRRRnlbxTtp2TDmOJk gqONU8GoK5YfrjMsT8AOREue178AgUS9rz/8X6rqSdZuBjSzzV9V6FuSgwnh4wMZ5SMWiB giZnR/slxeEvvpTuLmWp0ZFtPWMruDs= ARC-Authentication-Results: i=1; imf06.hostedemail.com; dkim=pass header.d=linux.alibaba.com header.s=default header.b="M4G/dyZ5"; spf=pass (imf06.hostedemail.com: domain of baolin.wang@linux.alibaba.com designates 115.124.30.119 as permitted sender) smtp.mailfrom=baolin.wang@linux.alibaba.com; dmarc=pass (policy=none) header.from=linux.alibaba.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1714985209; a=rsa-sha256; cv=none; b=0v9pcrCg8telyMGKinxK6pVC9KlHSW0xOmJ60/TdXarl29vvE+fS2uibYAQ3sf2c9ddPDN hQwBSVH9DmfsFugiuruARbyYM8umV2Gk6KKWN1GW8/NZ8f2cLjA/NT1Ud9EHszllWwLRXk 4jCTqK1WrX/QnnFvjQ7DRhDTlblrkdQ= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.alibaba.com; s=default; t=1714985205; h=From:To:Subject:Date:Message-Id:MIME-Version; bh=p4+ojbN485lnDhEdHj7u8+ldhF5xWmY9Y6UtO0qnCFI=; b=M4G/dyZ5V2GLWpno88uZhxml1FzQhmZmjzn7sY0ruOavuCP5oPev+hAzC2+Fg6K26gu1yaaEb0Mx+ArbuNpkW4Tuyk6ui+sTn9VRLxfu4nGJiyNGAhZvWDwqGpzD+gP7mClCkTmO4SPKoihph6k2k8/+5Rael0lQWAhWK/a1a1Y= X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R571e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=maildocker-contentspam033032014031;MF=baolin.wang@linux.alibaba.com;NM=1;PH=DS;RN=14;SR=0;TI=SMTPD_---0W5weiJg_1714985203; Received: from localhost(mailfrom:baolin.wang@linux.alibaba.com fp:SMTPD_---0W5weiJg_1714985203) by smtp.aliyun-inc.com; Mon, 06 May 2024 16:46:44 +0800 From: Baolin Wang To: akpm@linux-foundation.org, hughd@google.com Cc: willy@infradead.org, david@redhat.com, ioworker0@gmail.com, wangkefeng.wang@huawei.com, ying.huang@intel.com, 21cnbao@gmail.com, ryan.roberts@arm.com, shy828301@gmail.com, ziy@nvidia.com, baolin.wang@linux.alibaba.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH 1/8] mm: move highest_order() and next_order() out of the THP config Date: Mon, 6 May 2024 16:46:25 +0800 Message-Id: X-Mailer: git-send-email 2.39.3 In-Reply-To: References: MIME-Version: 1.0 X-Stat-Signature: qqw8h97fcthfuftbc8jy9kq8ed3wohte X-Rspam-User: X-Rspamd-Queue-Id: A810E18001E X-Rspamd-Server: rspam05 X-HE-Tag: 1714985208-495486 X-HE-Meta: U2FsdGVkX1/nCOdOOAAyHj97kT15gkTW/Lvm7KZ2kGqACWj36f30z5FzGRnMzrTk8pfgJCrQF1lA7GJ5Oq7wTLrP1ehWTapZpQWuDp61knLkbUl5XlYmrAuUeAxnpRLfeviRwasfJ03nEpZtEtopTpuCW1V4qoSrYKvMnWOf0NKr4zOC29QyU4WXEP6sbdvDh0LS9N2tA1kSEMnBbELBjNygc/9kG1cAXylvZeWt1LSkRRkc1g2B5ix4OIj86sjPVtX39ef6yItCuN295yV9QfCfwjMDe0cDlsVMSKY301knDWrndDDuOdNVJ+k/eDV2K6d0t64M0gyAwf7loowR2ugan/pNBGI5JZWXGWSuOr5wJLnNHW/7ihBs5ikihwJtuk6OROkZZdSmSPqOlAi1ypXZH4hpTNX0EeuV+7CSq6kR35y9ZHg8Z9MAhHxLYRfrIjyM0RHUZD09lir8dK/ZGsM7M/6+3WqlLwCFj/IvWDluF/CChum9RreZPRZfvduIxML36ZEJ43zz1wZLwosp9blRppyWjOY6+qEO+F4Y4GNSAf6noPQUoy115iY5yK+xycGdiTw9/41my8bqpZ/ULNnNQtcdVluzWQZI1ZdntiVrr5lpCoquq5Q4WcJVt1+R7JYS0xwyZKCYD7WjQq17lNAde0Z4E8XCWtq5iMn7ZnQWDnNc5+bW/qrykrCjyWnN1Fh70meXSsO+keKoFoiwr1/zy2wf4g56TiuFXXPYv4LDz31qbHvvIGM3d8SuDCNYi28C7CqQajQW8WrBtqYrApvO4fJ6sMAfIEz+TpE2lU7NqXDVZAkGhxEXC4CFQDrq89aNAYqoYQtxM7lFRoR9EMEeHAB2y7vHRw8Jr7Gtr+V+omVEdtNejsYAshNzpZmVHW57503XkVE3YMViPAR3bZppv+xCRXglUd8qE1vR0DNkBbRv7H3sesQsI9VpY7a1+YSjWmSCaUPGS+A+Wac qk7naAh3 zOWwycjU5d6pDdwMhatLsUSW56GOV+bSQInWMTLeGCo1xtNMaVOBldr6oU3S/Q0ojpX3+ORt+4B5BNo02YMD9OQqNnR1lVUpbF3lQ9dSSDo3V5G/7Z/m2YvpmUocsJ+ka3OP56I3EA47yBVRtSiiF85kK4WZBV81S5MZuQ6WOUM0krN1xAK7K6JBym9CMObyxkfDfvcm2A4h/q2QtZIk0BYdS6Ul9ryyGFcoNvx+mRwkjqPw= 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: Move highest_order() and next_order() out of the CONFIG_TRANSPARENT_HUGEPAGE macro, which can be common functions to be used. Signed-off-by: Baolin Wang --- include/linux/huge_mm.h | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/include/linux/huge_mm.h b/include/linux/huge_mm.h index 017cee864080..e49b56c40a11 100644 --- a/include/linux/huge_mm.h +++ b/include/linux/huge_mm.h @@ -106,6 +106,17 @@ extern struct kobj_attribute shmem_enabled_attr; #define HPAGE_PUD_MASK (~(HPAGE_PUD_SIZE - 1)) #define HPAGE_PUD_SIZE ((1UL) << HPAGE_PUD_SHIFT) +static inline int highest_order(unsigned long orders) +{ + return fls_long(orders) - 1; +} + +static inline int next_order(unsigned long *orders, int prev) +{ + *orders &= ~BIT(prev); + return highest_order(*orders); +} + #ifdef CONFIG_TRANSPARENT_HUGEPAGE extern unsigned long transparent_hugepage_flags; @@ -138,17 +149,6 @@ static inline bool hugepage_flags_enabled(void) huge_anon_orders_madvise; } -static inline int highest_order(unsigned long orders) -{ - return fls_long(orders) - 1; -} - -static inline int next_order(unsigned long *orders, int prev) -{ - *orders &= ~BIT(prev); - return highest_order(*orders); -} - /* * Do the below checks: * - For file vma, check if the linear page offset of vma is