[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20240604090845.2182265-6-max.kellermann@ionos.com>
Date: Tue, 4 Jun 2024 11:08:35 +0200
From: Max Kellermann <max.kellermann@...os.com>
To: akpm@...ux-foundation.org,
linux-mm@...ck.org,
linux-kernel@...r.kernel.org
Cc: willy@...radead.org,
sfr@...b.auug.org.au,
david@...hat.com,
Max Kellermann <max.kellermann@...os.com>
Subject: [PATCH v6 05/15] linux/mm.h: move section functions to mm/page_section.h
Prepare to reduce dependencies on linux/mm.h.
page_to_section() is used by __page_to_pfn() (but
asm-generic/memory_model.h does not include linux/mm.h). Thus, in
order to be able to use anything that calls page_to_pfn(), linux/mm.h
needs to be included.
This would prevent us from moving page_address() to a separate header,
because it calls lowmem_page_address() which in turn calls
page_to_virt() and then page_to_pfn(). To prepare for this move, we
move page_to_section() out of linux/mm.h into a separate lean header.
Signed-off-by: Max Kellermann <max.kellermann@...os.com>
---
include/linux/mm.h | 18 +-----------------
include/linux/mm/page_section.h | 23 +++++++++++++++++++++++
2 files changed, 24 insertions(+), 17 deletions(-)
create mode 100644 include/linux/mm/page_section.h
diff --git a/include/linux/mm.h b/include/linux/mm.h
index 3ff239992d4c..c9a3f1c0ae07 100644
--- a/include/linux/mm.h
+++ b/include/linux/mm.h
@@ -3,6 +3,7 @@
#define _LINUX_MM_H
#include <linux/mm/page_kasan_tag.h>
+#include <linux/mm/page_section.h>
#include <linux/errno.h>
#include <linux/mmdebug.h>
#include <linux/gfp.h>
@@ -1631,10 +1632,6 @@ static inline bool is_nommu_shared_mapping(vm_flags_t flags)
}
#endif
-#if defined(CONFIG_SPARSEMEM) && !defined(CONFIG_SPARSEMEM_VMEMMAP)
-#define SECTION_IN_PAGE_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
@@ -1832,19 +1829,6 @@ static inline pg_data_t *folio_pgdat(const struct folio *folio)
return page_pgdat(&folio->page);
}
-#ifdef SECTION_IN_PAGE_FLAGS
-static inline void set_page_section(struct page *page, unsigned long section)
-{
- page->flags &= ~(SECTIONS_MASK << SECTIONS_PGSHIFT);
- page->flags |= (section & SECTIONS_MASK) << SECTIONS_PGSHIFT;
-}
-
-static inline unsigned long page_to_section(const struct page *page)
-{
- return (page->flags >> SECTIONS_PGSHIFT) & SECTIONS_MASK;
-}
-#endif
-
/**
* folio_pfn - Return the Page Frame Number of a folio.
* @folio: The folio.
diff --git a/include/linux/mm/page_section.h b/include/linux/mm/page_section.h
new file mode 100644
index 000000000000..e4558c2691b8
--- /dev/null
+++ b/include/linux/mm/page_section.h
@@ -0,0 +1,23 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+#ifndef _LINUX_MM_PAGE_SECTION_H
+#define _LINUX_MM_PAGE_SECTION_H
+
+#include <linux/mm_types.h> // for struct page
+#include <linux/mmzone.h> // for SECTIONS_*
+
+#if defined(CONFIG_SPARSEMEM) && !defined(CONFIG_SPARSEMEM_VMEMMAP)
+#define SECTION_IN_PAGE_FLAGS
+
+static inline void set_page_section(struct page *page, unsigned long section)
+{
+ page->flags &= ~(SECTIONS_MASK << SECTIONS_PGSHIFT);
+ page->flags |= (section & SECTIONS_MASK) << SECTIONS_PGSHIFT;
+}
+
+static inline unsigned long page_to_section(const struct page *page)
+{
+ return (page->flags >> SECTIONS_PGSHIFT) & SECTIONS_MASK;
+}
+#endif
+
+#endif /* _LINUX_MM_PAGE_SECTION_H */
--
2.39.2
Powered by blists - more mailing lists