From patchwork Tue Jun 4 09:08:41 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Max Kellermann X-Patchwork-Id: 13684923 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 11DB9C25B78 for ; Tue, 4 Jun 2024 09:09:44 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 4C5F56B00A4; Tue, 4 Jun 2024 05:09:24 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 475B06B00A5; Tue, 4 Jun 2024 05:09:24 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 27B296B00A6; Tue, 4 Jun 2024 05:09:24 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 057296B00A4 for ; Tue, 4 Jun 2024 05:09:23 -0400 (EDT) Received: from smtpin09.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id B48041604CF for ; Tue, 4 Jun 2024 09:09:23 +0000 (UTC) X-FDA: 82192632606.09.C332B66 Received: from mail-lj1-f180.google.com (mail-lj1-f180.google.com [209.85.208.180]) by imf27.hostedemail.com (Postfix) with ESMTP id BECAA4001A for ; Tue, 4 Jun 2024 09:09:21 +0000 (UTC) Authentication-Results: imf27.hostedemail.com; dkim=pass header.d=ionos.com header.s=google header.b=MpJX7NU2; spf=pass (imf27.hostedemail.com: domain of max.kellermann@ionos.com designates 209.85.208.180 as permitted sender) smtp.mailfrom=max.kellermann@ionos.com; dmarc=pass (policy=quarantine) header.from=ionos.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1717492161; 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=7a14+jXYXTjmg6E3qRGIvRJfYcGA2t0M1Ozzz17Ypyc=; b=7xkUk1YeMBqyuJSmYuWfY04ye0CvHQGOfWIn+TJH4ijuPjoBnntfuO0iT1+LOt/L1jpi3H s8CLRxuI/8hHhLMseUI7MBKaAv0nOqQNAgTXQzpM8iED6wVA+0CuzZgqHvO1lmeL2DvNZN 0jIiKe/rIeucGaqvTfBOUGjFvNm0wv0= ARC-Authentication-Results: i=1; imf27.hostedemail.com; dkim=pass header.d=ionos.com header.s=google header.b=MpJX7NU2; spf=pass (imf27.hostedemail.com: domain of max.kellermann@ionos.com designates 209.85.208.180 as permitted sender) smtp.mailfrom=max.kellermann@ionos.com; dmarc=pass (policy=quarantine) header.from=ionos.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1717492161; a=rsa-sha256; cv=none; b=TXBOpt4Dy2GtqyI0KR2ExoSSe/ScGTw4W/E9qO6D+QBSjW+LerSlndDKCY4MvHS661qgIA N1P1PUfC5KX2lLTo55nKA/VeZSWLHtkwrzF8vzDoRd2xTzdNCf+DKqpgjnt2Yy0Gg61JXG lpP5MgUSheyfNmNdWi9qbhM3YA/HWSg= Received: by mail-lj1-f180.google.com with SMTP id 38308e7fff4ca-2eaae2a6dc1so35251841fa.0 for ; Tue, 04 Jun 2024 02:09:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ionos.com; s=google; t=1717492160; x=1718096960; 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=7a14+jXYXTjmg6E3qRGIvRJfYcGA2t0M1Ozzz17Ypyc=; b=MpJX7NU2wldDrF1MzX33Y/bkwQiJZcUbpGCKZuHW2S+cDvQB19gzE+E8SBroSn9l0O PK8eYIvcqGCbQvPclmHv3uuo8fgr8AuqyXsslg67dLo4EJDM+48qLWwRva+0X4kxmNqC p5cJObmN2mUhmMalFLlfwy8Q3HwiD7cqXw37xoQQGtxFJtDRsa7X0+6PUOjAUD0/99Qe t4sK8/RcfuqbrwW8nMBnCcSPahs2A8LXBurm3WPFvyklKvxCn4jWVuQ2zovSXMVWh8Y7 UZ1PdJuJWOsJO1MLcDHDsnb3T0cw1OH3MXLOBMMKl1Yblp9omf8X3riMRIPzYj3Nj7J+ JJGQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717492160; x=1718096960; 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=7a14+jXYXTjmg6E3qRGIvRJfYcGA2t0M1Ozzz17Ypyc=; b=FdEAE8PTghqJ2beBHEtaxyWrBHUCrNfeQFd/X3HqQly60opynX3VokQ+EJ8IoXaToG zNGyokt6PKVw9Z4QxQnpT87xRSHEoTmcEWMJyZjb2InMrB8GTMAdHElCwV/dLfiDHUq2 YLqvkFk/Y/viGqVHPJ9YxdiuKqM0wIyNYam9FHcD18nP8G+8cijfOZeiTEgCUTh2ERNb vhght2dTwpOHkeB4sjBngEsF9f6av2eBnO1voMxJaOJ2RbE8s5SHR7WCrxgboXhGcbFK O9UNqtG3vG3ArHkLgum00Mn35YojybQcmk274BUvsWlSyU/COClSoFSXauiVAt9ceNLu jFqA== X-Forwarded-Encrypted: i=1; AJvYcCW8t1aeERS5rp4tlCfqw8a7SKNW902bPRjOpOW3YP39P6SyhQKXcStvAsiFrHFKPbLeTnn9+QGIHsM5EZD+1uKpmw8= X-Gm-Message-State: AOJu0Ywl/ONW0IsJsXDFBXMt1FUiVPcOX5Y+ek/xNUkJwFn6fTkZfhD5 oRYArsPkh8n6Lgtm0UEIRUc3mSnw+R6h6izwoGyDUf7FPyBAGzaKPxUcR7JXzys= X-Google-Smtp-Source: AGHT+IHsJf4f3OBFK5S9RQgJe4xLIo0Z7mZgH0CJQAgenYk9ZH6OP2KgkT94QdNs7YGr5ClMSzJPQA== X-Received: by 2002:a2e:9d88:0:b0:2e1:9c57:195a with SMTP id 38308e7fff4ca-2ea951de27fmr93794341fa.32.1717492160177; Tue, 04 Jun 2024 02:09:20 -0700 (PDT) Received: from raven.blarg.de (p200300dc6f4f9200023064fffe740809.dip0.t-ipconnect.de. [2003:dc:6f4f:9200:230:64ff:fe74:809]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a68fa49e66fsm328376766b.129.2024.06.04.02.09.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 04 Jun 2024 02:09:19 -0700 (PDT) From: Max Kellermann To: akpm@linux-foundation.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org Cc: willy@infradead.org, sfr@canb.auug.org.au, david@redhat.com, Max Kellermann Subject: [PATCH v6 11/15] linux/mm.h: move page_zone_id() and more to mm/folio_zone.h Date: Tue, 4 Jun 2024 11:08:41 +0200 Message-Id: <20240604090845.2182265-12-max.kellermann@ionos.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240604090845.2182265-1-max.kellermann@ionos.com> References: <20240604090845.2182265-1-max.kellermann@ionos.com> MIME-Version: 1.0 X-Rspam-User: X-Rspamd-Server: rspam09 X-Rspamd-Queue-Id: BECAA4001A X-Stat-Signature: rnqd6icsbcygyngcmdrncbdkpukkpqqa X-HE-Tag: 1717492161-786626 X-HE-Meta: U2FsdGVkX191yibPURFgRzrs9tVpzG1HY7QP8EqWNEX22A61Zs7sD0l01fSgLaOijFWmVSdbcGFBsZpWdZka/+wF9fHGcq54ymphOkLvRDN1CrwYoApgJ5WR0HWFOM7ruSY0Z2DxoNrwBXkIW3WvpBzwMDWoJRu3AmNAXFTOpmH316ARYYbyazgSHC2ojJ/ZyJ4PPVoA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FIEYxZZlBYajcUhtfcOmiE3nkpQyzD7yu2fQjNNJ9m9u6wFB7r4faZ/dGJtmfgYBp2V9Y8A95AWbuYFBLa6pd+zpnudADo0713wl+Y/9ZTAF5p2sCdXPnojw= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000002, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: This is needed to eliminate linux/skbuff.h's dependency on linux/mm.h. Signed-off-by: Max Kellermann --- include/linux/mm.h | 48 +----------------------------- include/linux/mm/folio_zone.h | 56 +++++++++++++++++++++++++++++++++++ 2 files changed, 57 insertions(+), 47 deletions(-) create mode 100644 include/linux/mm/folio_zone.h diff --git a/include/linux/mm.h b/include/linux/mm.h index a32d284813f4..c026e58e3725 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -5,6 +5,7 @@ #include #include #include +#include #include #include #include @@ -1369,33 +1370,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 -int page_to_nid(const struct page *page); -#else -static inline int page_to_nid(const struct page *page) -{ - return (PF_POISONED_CHECK(page)->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 @@ -1546,26 +1520,6 @@ static inline void vma_set_access_pid_bit(struct vm_area_struct *vma) } #endif /* CONFIG_NUMA_BALANCING */ -static inline struct zone *page_zone(const struct page *page) -{ - return &NODE_DATA(page_to_nid(page))->node_zones[page_zonenum(page)]; -} - -static inline pg_data_t *page_pgdat(const struct page *page) -{ - return NODE_DATA(page_to_nid(page)); -} - -static inline struct zone *folio_zone(const struct folio *folio) -{ - return page_zone(&folio->page); -} - -static inline pg_data_t *folio_pgdat(const struct folio *folio) -{ - return page_pgdat(&folio->page); -} - /** * folio_pfn - Return the Page Frame Number of a folio. * @folio: The folio. diff --git a/include/linux/mm/folio_zone.h b/include/linux/mm/folio_zone.h new file mode 100644 index 000000000000..3f3e4284b911 --- /dev/null +++ b/include/linux/mm/folio_zone.h @@ -0,0 +1,56 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#ifndef _LINUX_MM_FOLIO_ZONE_H +#define _LINUX_MM_FOLIO_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 +int page_to_nid(const struct page *page); +#else +static inline int page_to_nid(const struct page *page) +{ + return (PF_POISONED_CHECK(page)->flags >> NODES_PGSHIFT) & NODES_MASK; +} +#endif + +static inline int folio_nid(const struct folio *folio) +{ + return page_to_nid(&folio->page); +} + +static inline struct zone *page_zone(const struct page *page) +{ + return &NODE_DATA(page_to_nid(page))->node_zones[page_zonenum(page)]; +} + +static inline pg_data_t *page_pgdat(const struct page *page) +{ + return NODE_DATA(page_to_nid(page)); +} + +static inline struct zone *folio_zone(const struct folio *folio) +{ + return page_zone(&folio->page); +} + +static inline pg_data_t *folio_pgdat(const struct folio *folio) +{ + return page_pgdat(&folio->page); +} + +#endif /* _LINUX_MM_FOLIO_ZONE_H */