git: 40e726479d73 - main - LinuxKPI: Add mapping_gfp_mask() and four more folio/pagemap helpers
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Fri, 20 Nov 2026 18:19:36 UTC
The branch main has been updated by wulf:
URL: https://cgit.FreeBSD.org/src/commit/?id=40e726479d73468bacc1c1cd5bc58673aee20f4e
commit 40e726479d73468bacc1c1cd5bc58673aee20f4e
Author: Denis Borovikov <denis.borovikov@gmail.com>
AuthorDate: 2026-11-20 18:17:59 +0000
Commit: Vladimir Kondratyev <wulf@FreeBSD.org>
CommitDate: 2026-11-20 18:17:59 +0000
LinuxKPI: Add mapping_gfp_mask() and four more folio/pagemap helpers
Adds mapping_gfp_mask(), mapping_gfp_constraint(), mapping_set_unevictable(),
folio_page() and folio_file_page(), which Linux's drm_gem_get_pages() uses.
drm-kmod carries them in an overlay for virtio-gpu (freebsd/drm-kmod#517) today.
The mask is GFP_KERNEL, as shmem page allocation may sleep and ignores
the other flags. folio_page() and folio_file_page() are exact copies
from D58763, to not clash with it.
Signed-off-by: Denis Borovikov <denis.borovikov@gmail.com>
Reviewed by: wulf
Differential Revision: https://reviews.freebsd.org/D61217
---
.../linuxkpi/common/include/linux/page-flags.h | 8 ++++++++
sys/compat/linuxkpi/common/include/linux/pagemap.h | 24 ++++++++++++++++++++++
2 files changed, 32 insertions(+)
diff --git a/sys/compat/linuxkpi/common/include/linux/page-flags.h b/sys/compat/linuxkpi/common/include/linux/page-flags.h
index a22b3a24c330..bfee89a11a9c 100644
--- a/sys/compat/linuxkpi/common/include/linux/page-flags.h
+++ b/sys/compat/linuxkpi/common/include/linux/page-flags.h
@@ -38,4 +38,12 @@
const struct page *: (const struct folio *)(p), \
struct page *: (struct folio *)(p)))
+static inline struct page *
+folio_page(struct folio *folio, int n)
+{
+ KASSERT(n == 0, ("%s: n = %d but only n = 0 supported\n", __func__, n));
+
+ return (&folio->page);
+}
+
#endif /* _LINUXKPI_LINUX_PAGEFLAGS_H_ */
diff --git a/sys/compat/linuxkpi/common/include/linux/pagemap.h b/sys/compat/linuxkpi/common/include/linux/pagemap.h
index cb6a1820ea8b..c2d228dc9a98 100644
--- a/sys/compat/linuxkpi/common/include/linux/pagemap.h
+++ b/sys/compat/linuxkpi/common/include/linux/pagemap.h
@@ -35,12 +35,36 @@
struct folio_batch;
+static inline struct page *
+folio_file_page(struct folio *folio, pgoff_t index)
+{
+ return (folio_page(folio, index & (folio_nr_pages(folio) - 1)));
+}
+
#define invalidate_mapping_pages(...) \
linux_invalidate_mapping_pages(__VA_ARGS__)
unsigned long linux_invalidate_mapping_pages(vm_object_t obj, pgoff_t start,
pgoff_t end);
+/* Shmem page allocation may sleep and ignores the other flags. */
+static inline gfp_t
+mapping_gfp_mask(vm_object_t mapping)
+{
+ return (GFP_KERNEL);
+}
+
+static inline gfp_t
+mapping_gfp_constraint(vm_object_t mapping, gfp_t gfp_mask)
+{
+ return (mapping_gfp_mask(mapping) & gfp_mask);
+}
+
+static inline void
+mapping_set_unevictable(vm_object_t mapping)
+{
+}
+
static inline void
mapping_clear_unevictable(vm_object_t mapping)
{