From patchwork Thu Feb 15 14:55:58 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Max Kellermann X-Patchwork-Id: 13558590 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 09E35C48BC4 for ; Thu, 15 Feb 2024 14:56:43 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B794C8D002A; Thu, 15 Feb 2024 09:56:23 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id B00F48D0029; Thu, 15 Feb 2024 09:56:23 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 901828D002A; Thu, 15 Feb 2024 09:56:23 -0500 (EST) 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 77D398D0029 for ; Thu, 15 Feb 2024 09:56:23 -0500 (EST) Received: from smtpin11.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 579DEA2900 for ; Thu, 15 Feb 2024 14:56:23 +0000 (UTC) X-FDA: 81794339046.11.DF283D1 Received: from mail-ej1-f47.google.com (mail-ej1-f47.google.com [209.85.218.47]) by imf27.hostedemail.com (Postfix) with ESMTP id 7361B40024 for ; Thu, 15 Feb 2024 14:56:21 +0000 (UTC) Authentication-Results: imf27.hostedemail.com; dkim=pass header.d=ionos.com header.s=google header.b=WwFbhUK6; dmarc=pass (policy=quarantine) header.from=ionos.com; spf=pass (imf27.hostedemail.com: domain of max.kellermann@ionos.com designates 209.85.218.47 as permitted sender) smtp.mailfrom=max.kellermann@ionos.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1708008981; 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=eKsp875PnvJuIa0s07e10KRuMSwJl/UB/2fWYWucGxo=; b=VhlZVdkmr1a0pmysjIR5tm7IdEgXPqMURwb7wLIsb29WG4ScEAWUjS6q4eSijSYaIMmGp+ R/Q/pl9bJ1KgU5GEUEn6oSUUKabySQhFgoeawo9ccdSrnlk7B/UcP8pOmPWw/1LJ0TjXWV Ozy//Gf40E+Abocg6TVXuU4xz3uLsO0= ARC-Authentication-Results: i=1; imf27.hostedemail.com; dkim=pass header.d=ionos.com header.s=google header.b=WwFbhUK6; dmarc=pass (policy=quarantine) header.from=ionos.com; spf=pass (imf27.hostedemail.com: domain of max.kellermann@ionos.com designates 209.85.218.47 as permitted sender) smtp.mailfrom=max.kellermann@ionos.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1708008981; a=rsa-sha256; cv=none; b=DrkLoHjRVFeTmSebAVRWM6KR7Nrey+cX34ZCy3Qt9rCpgMZgDxU1JTpPwQlkpzvolniQUG A6wPT59ARSRjRns0dYt9Hnu/gMR0HlRXcS7bxtBBKsze1gz2/CEjgq3O8fgvl02NJUe80k wtAtggroBrV6bjaaChp36cjrFXaWl1A= Received: by mail-ej1-f47.google.com with SMTP id a640c23a62f3a-a3db0b8b313so39409166b.0 for ; Thu, 15 Feb 2024 06:56:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ionos.com; s=google; t=1708008980; x=1708613780; darn=kvack.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=eKsp875PnvJuIa0s07e10KRuMSwJl/UB/2fWYWucGxo=; b=WwFbhUK69kiUr01ZVM9VN4ZINJ+sl3GL6wFZ1qSt9FLlJLGSSSQ2VXWcqMcX/lyCDv tcSTbLuwmOsmYqtCvIgm2v2ZHkbfhL/kEIahoAxRdZ+Cig++N7ovraMvPmnZ3kWbazai yp+IZ/CyI1Ft7sEUcB2sOzrQktCYoeZnX+D7kxxQNTYgBA3LEMzwpJWnUux4QrxvDnHb th7yX5YUT1iOjbcfiY/k4De9wK75J633ZBVWnwHo4J4EFxfz8UtRtE2CypV+ZTdUI7Ke 6UWqmDBaDauJMZUODsZ6WyHK3RtvKwB6PTlEcFKNFYlgmmzIKr+fv4mHa0184z6bmEvo eFEA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708008980; x=1708613780; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=eKsp875PnvJuIa0s07e10KRuMSwJl/UB/2fWYWucGxo=; b=i+COJXpJn/IW05HGfT+9UMj2zzD82cPSE7sKIyTEvZ2kTTqgelmzd7VfHUBYWqUU72 IYi39sbQe/vjsv51pAIDu+DtvYwup4phO3UVf5LL9C3yN6YGuJTGGsQmlufeSwMdqHVN A99zC521PyHfKo1FV7pv5xuQvPgGreCsNhoSOeqKYUYrPpS6FZaM9e8qs4lmXPboRQXL uYz8drmXAqVaJ+8PYa4k7rYTb1p2gVHFSAzpGTBUrLNqRz33u+fQLgVuQjTtpfSwt+11 amR9gZffqK9lxC2r146tDd5DPMsrQQcPJDDSOVN+SH/xGyiNe5LzasV1uy7IeZfUUaJf dJjQ== X-Forwarded-Encrypted: i=1; AJvYcCU6jEtpJ9PsSijzxjkouyiVtnGP5O5R9Kohvj9Q+7e9SUbkJkBenrLyvT4T3eMwAnXs2e4G/06LzGcJ8m44oa7xe38= X-Gm-Message-State: AOJu0YxMaWv/VV/iSBieneKC3yjjOiav+EqzlTNYHyeuSC49eWYZpvhy mfzAJgqDUV9Ry5xBqcJ7DsCAcdAG0ZRhJu19EfGbgHxjVMGvapRE0dHptGnR+ug= X-Google-Smtp-Source: AGHT+IH5yGTXkkYLGBHGfcaxHapm+uOnyxEcWP/yZTJOKq1Do5sZaLON8Um9ALDtXnu5fhpKYHSzQg== X-Received: by 2002:a17:906:34cd:b0:a3d:b317:8ac9 with SMTP id h13-20020a17090634cd00b00a3db3178ac9mr499801ejb.33.1708008980212; Thu, 15 Feb 2024 06:56:20 -0800 (PST) Received: from raven.intern.cm-ag (p200300dc6f267100023064fffe740809.dip0.t-ipconnect.de. [2003:dc:6f26:7100:230:64ff:fe74:809]) by smtp.gmail.com with ESMTPSA id s18-20020a170906169200b00a3d1897ab68sm631175ejd.113.2024.02.15.06.56.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 15 Feb 2024 06:56:19 -0800 (PST) From: Max Kellermann To: akpm@linux-foundation.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org Cc: Max Kellermann Subject: [PATCH v1 10/14] linux/mm.h: move page_zone_id() and more to mm/page_zone.h Date: Thu, 15 Feb 2024 15:55:58 +0100 Message-Id: <20240215145602.1371274-11-max.kellermann@ionos.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240215145602.1371274-1-max.kellermann@ionos.com> References: <20240215145602.1371274-1-max.kellermann@ionos.com> MIME-Version: 1.0 X-Rspamd-Queue-Id: 7361B40024 X-Rspam-User: X-Rspamd-Server: rspam05 X-Stat-Signature: mmzh9isu3dptjido831oftkrcf8hmuxs X-HE-Tag: 1708008981-2476 X-HE-Meta: U2FsdGVkX1/FRaonN7H29V3p5b5auGayAZWwmCGOgSdskHRYZMgn1NwUYFqT9sFwkVBhuWNxkSRhe+0T9gHl2Dwu/Uy705+ZA6Zy1C+FiltZuzTyl84xhVETZPer1jDHBu5mkxP2I1UY5kjAh/Beaml/tpLGAm0/ULI++ffrp3mDdGrwq2gzhs4/2dwrUbFnayr0oAjtnXdKL7v4YXh/rajFpzlzOx8SC+4tyY05cxs/nycOg5Xmhwe5Smiotr5wrlPguV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37FlEn41TrZwNxm5ZK6doRrggjgOvVukYeNqWVntp5IscPeQpAHyEAhzNOAeo8qFK8NaUsMDeM9zsjlF1dhbYrk3Mq1IVXsRXTkVGS4LWnXtECGNgqCTKCbWs72H7z2yEpzSNiUVA== X-Bogosity: Ham, tests=bogofilter, spamicity=0.001372, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: Prepare to reduce dependencies in linux/mm.h. Signed-off-by: Max Kellermann --- include/linux/mm.h | 30 +--------------------------- include/linux/mm/page_zone.h | 38 ++++++++++++++++++++++++++++++++++++ 2 files changed, 39 insertions(+), 29 deletions(-) create mode 100644 include/linux/mm/page_zone.h diff --git a/include/linux/mm.h b/include/linux/mm.h index 26d506ed855f..aa24e6fed9b6 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -7,6 +7,7 @@ #include #include #include +#include #include #include #include @@ -1358,35 +1359,6 @@ static inline bool is_nommu_shared_mapping(vm_flags_t flags) } #endif -/* - * The identification function is mainly used by the buddy allocator for - * determining if two pages could be buddies. We are not really identifying - * the zone since we could be using the section number id if we do not have - * node id available in page flags. - * We only guarantee that it will return the same value for two combinable - * pages in a zone. - */ -static inline int page_zone_id(struct page *page) -{ - return (page->flags >> ZONEID_PGSHIFT) & ZONEID_MASK; -} - -#ifdef NODE_NOT_IN_PAGE_FLAGS -extern int page_to_nid(const struct page *page); -#else -static inline int page_to_nid(const struct page *page) -{ - struct page *p = (struct page *)page; - - return (PF_POISONED_CHECK(p)->flags >> NODES_PGSHIFT) & NODES_MASK; -} -#endif - -static inline int folio_nid(const struct folio *folio) -{ - return page_to_nid(&folio->page); -} - #ifdef CONFIG_NUMA_BALANCING /* page access time bits needs to hold at least 4 seconds */ #define PAGE_ACCESS_TIME_MIN_BITS 12 diff --git a/include/linux/mm/page_zone.h b/include/linux/mm/page_zone.h new file mode 100644 index 000000000000..6bbd46743aeb --- /dev/null +++ b/include/linux/mm/page_zone.h @@ -0,0 +1,38 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#ifndef _LINUX_MM_PAGE_ZONE_H +#define _LINUX_MM_PAGE_ZONE_H + +#include // for struct page, struct folio +#include // for ZONEID_*, NODES_* +#include // for PF_POISONED_CHECK() + +/* + * The identification function is mainly used by the buddy allocator for + * determining if two pages could be buddies. We are not really identifying + * the zone since we could be using the section number id if we do not have + * node id available in page flags. + * We only guarantee that it will return the same value for two combinable + * pages in a zone. + */ +static inline int page_zone_id(struct page *page) +{ + return (page->flags >> ZONEID_PGSHIFT) & ZONEID_MASK; +} + +#ifdef NODE_NOT_IN_PAGE_FLAGS +extern int page_to_nid(const struct page *page); +#else +static inline int page_to_nid(const struct page *page) +{ + struct page *p = (struct page *)page; + + return (PF_POISONED_CHECK(p)->flags >> NODES_PGSHIFT) & NODES_MASK; +} +#endif + +static inline int folio_nid(const struct folio *folio) +{ + return page_to_nid(&folio->page); +} + +#endif /* _LINUX_MM_PAGE_ZONE_H */