mm: Don't pin ZERO_PAGE in pin_user_pages()
[linux-block.git] / include / linux / mm.h
index 27ce77080c79c7a026e641e491246fcf6f7e26c0..3c2f6b452586f233dfdbe1f0ce1580733430f2ee 100644 (file)
@@ -1910,6 +1910,28 @@ static inline bool page_needs_cow_for_dma(struct vm_area_struct *vma,
        return page_maybe_dma_pinned(page);
 }
 
+/**
+ * is_zero_page - Query if a page is a zero page
+ * @page: The page to query
+ *
+ * This returns true if @page is one of the permanent zero pages.
+ */
+static inline bool is_zero_page(const struct page *page)
+{
+       return is_zero_pfn(page_to_pfn(page));
+}
+
+/**
+ * is_zero_folio - Query if a folio is a zero page
+ * @folio: The folio to query
+ *
+ * This returns true if @folio is one of the permanent zero pages.
+ */
+static inline bool is_zero_folio(const struct folio *folio)
+{
+       return is_zero_page(&folio->page);
+}
+
 /* MIGRATE_CMA and ZONE_MOVABLE do not allow pin pages */
 #ifdef CONFIG_MIGRATION
 static inline bool is_longterm_pinnable_page(struct page *page)
@@ -1920,8 +1942,8 @@ static inline bool is_longterm_pinnable_page(struct page *page)
        if (mt == MIGRATE_CMA || mt == MIGRATE_ISOLATE)
                return false;
 #endif
-       /* The zero page may always be pinned */
-       if (is_zero_pfn(page_to_pfn(page)))
+       /* The zero page can be "pinned" but gets special handling. */
+       if (is_zero_page(page))
                return true;
 
        /* Coherent device memory must always allow eviction. */