[v2,11/14] linux/mm.h: move pfmemalloc-related functions to pfmemalloc.h
Commit Message
This is needed to eliminate linux/skbuff.h's dependency on linux/mm.h.
Signed-off-by: Max Kellermann <max.kellermann@ionos.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
@@ -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>
@@ -1749,50 +1750,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.
*/
new file mode 100644
@@ -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 */