[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20240312094133.2084996-13-max.kellermann@ionos.com>
Date: Tue, 12 Mar 2024 10:41:30 +0100
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,
Max Kellermann <max.kellermann@...os.com>
Subject: [PATCH v4 12/15] linux/mm.h: move pfmemalloc-related functions to pfmemalloc.h
This is needed to eliminate linux/skbuff.h's dependency on linux/mm.h.
Signed-off-by: Max Kellermann <max.kellermann@...os.com>
---
include/linux/mm.h | 45 +-----------------------------
include/linux/mm/pfmemalloc.h | 52 +++++++++++++++++++++++++++++++++++
2 files changed, 53 insertions(+), 44 deletions(-)
create mode 100644 include/linux/mm/pfmemalloc.h
diff --git a/include/linux/mm.h b/include/linux/mm.h
index b3f83fb26aca..07262ae43c5d 100644
--- a/include/linux/mm.h
+++ b/include/linux/mm.h
@@ -8,6 +8,7 @@
#include <linux/mm/folio_zone.h>
#include <linux/mm/page_address.h>
#include <linux/mm/page_section.h>
+#include <linux/mm/pfmemalloc.h>
#include <linux/errno.h>
#include <linux/mmdebug.h>
#include <linux/gfp.h>
@@ -1763,50 +1764,6 @@ static inline pgoff_t page_index(struct page *page)
return page->index;
}
-/*
- * Return true only if the page has been allocated with
- * ALLOC_NO_WATERMARKS and the low watermark was not
- * met implying that the system is under some pressure.
- */
-static inline bool page_is_pfmemalloc(const struct page *page)
-{
- /*
- * lru.next has bit 1 set if the page is allocated from the
- * pfmemalloc reserves. Callers may simply overwrite it if
- * they do not need to preserve that information.
- */
- return (uintptr_t)page->lru.next & BIT(1);
-}
-
-/*
- * Return true only if the folio has been allocated with
- * ALLOC_NO_WATERMARKS and the low watermark was not
- * met implying that the system is under some pressure.
- */
-static inline bool folio_is_pfmemalloc(const struct folio *folio)
-{
- /*
- * lru.next has bit 1 set if the page is allocated from the
- * pfmemalloc reserves. Callers may simply overwrite it if
- * they do not need to preserve that information.
- */
- return (uintptr_t)folio->lru.next & BIT(1);
-}
-
-/*
- * Only to be called by the page allocator on a freshly allocated
- * page.
- */
-static inline void set_page_pfmemalloc(struct page *page)
-{
- page->lru.next = (void *)BIT(1);
-}
-
-static inline void clear_page_pfmemalloc(struct page *page)
-{
- page->lru.next = NULL;
-}
-
/*
* Can be called by the pagefault handler when it gets a VM_FAULT_OOM.
*/
diff --git a/include/linux/mm/pfmemalloc.h b/include/linux/mm/pfmemalloc.h
new file mode 100644
index 000000000000..345b215a3566
--- /dev/null
+++ b/include/linux/mm/pfmemalloc.h
@@ -0,0 +1,52 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+#ifndef _LINUX_MM_PFMEMALLOC_H
+#define _LINUX_MM_PFMEMALLOC_H
+
+#include <linux/bits.h> // for BIT()
+#include <linux/mm_types.h> // for struct page
+
+/*
+ * Return true only if the page has been allocated with
+ * ALLOC_NO_WATERMARKS and the low watermark was not
+ * met implying that the system is under some pressure.
+ */
+static inline bool page_is_pfmemalloc(const struct page *page)
+{
+ /*
+ * lru.next has bit 1 set if the page is allocated from the
+ * pfmemalloc reserves. Callers may simply overwrite it if
+ * they do not need to preserve that information.
+ */
+ return (uintptr_t)page->lru.next & BIT(1);
+}
+
+/*
+ * Return true only if the folio has been allocated with
+ * ALLOC_NO_WATERMARKS and the low watermark was not
+ * met implying that the system is under some pressure.
+ */
+static inline bool folio_is_pfmemalloc(const struct folio *folio)
+{
+ /*
+ * lru.next has bit 1 set if the page is allocated from the
+ * pfmemalloc reserves. Callers may simply overwrite it if
+ * they do not need to preserve that information.
+ */
+ return (uintptr_t)folio->lru.next & BIT(1);
+}
+
+/*
+ * Only to be called by the page allocator on a freshly allocated
+ * page.
+ */
+static inline void set_page_pfmemalloc(struct page *page)
+{
+ page->lru.next = (void *)BIT(1);
+}
+
+static inline void clear_page_pfmemalloc(struct page *page)
+{
+ page->lru.next = NULL;
+}
+
+#endif /* _LINUX_MM_PFMEMALLOC_H */
--
2.39.2
Powered by blists - more mailing lists