mm: introduce folio_is_pfmemalloc
[linux-block.git] / include / linux / mm.h
index 8a856335994625275f35e2d73c45d8993bde6882..76c97cb8ee9aed6bd25d61f91ae03478c6b3d2c1 100644 (file)
@@ -1926,6 +1926,21 @@ static inline bool page_is_pfmemalloc(const struct page *page)
        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.