git: e82a5dd0e6cf - stable/13 - linuxkpi: Add pagevec implementation
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Wed, 07 Sep 2022 15:10:07 UTC
The branch stable/13 has been updated by manu:
URL: https://cgit.FreeBSD.org/src/commit/?id=e82a5dd0e6cffd3c50213ced73ce6105e2fa8a8c
commit e82a5dd0e6cffd3c50213ced73ce6105e2fa8a8c
Author: Emmanuel Vadot <manu@FreeBSD.org>
AuthorDate: 2022-07-26 08:15:12 +0000
Commit: Emmanuel Vadot <manu@FreeBSD.org>
CommitDate: 2022-09-07 15:09:03 +0000
linuxkpi: Add pagevec implementation
Needed by drm-kmod.
Reviewed by: hselasky
Obtained from: OpenBSD
Sponsored by: Beckhoff Automation GmbH & Co. KG
Differential Revision: https://reviews.freebsd.org/D35941
(cherry picked from commit a0c171328f6689fb88e3881b8b5ee61d813b8c6d)
---
sys/compat/linuxkpi/common/include/linux/pagevec.h | 69 ++++++++++++++++++++++
1 file changed, 69 insertions(+)
diff --git a/sys/compat/linuxkpi/common/include/linux/pagevec.h b/sys/compat/linuxkpi/common/include/linux/pagevec.h
new file mode 100644
index 000000000000..4224124c4fe4
--- /dev/null
+++ b/sys/compat/linuxkpi/common/include/linux/pagevec.h
@@ -0,0 +1,69 @@
+/* Public domain. */
+
+#ifndef _LINUXKPI_LINUX_PAGEVEC_H_
+#define _LINUXKPI_LINUX_PAGEVEC_H_
+
+#include <sys/types.h>
+#include <sys/systm.h>
+#include <sys/errno.h>
+
+#include <linux/pagemap.h>
+
+#define PAGEVEC_SIZE 15
+
+struct pagevec {
+ uint8_t nr;
+ struct vm_page *pages[PAGEVEC_SIZE];
+};
+
+static inline unsigned int
+pagevec_space(struct pagevec *pvec)
+{
+ return PAGEVEC_SIZE - pvec->nr;
+}
+
+static inline void
+pagevec_init(struct pagevec *pvec)
+{
+ pvec->nr = 0;
+}
+
+static inline void
+pagevec_reinit(struct pagevec *pvec)
+{
+ pvec->nr = 0;
+}
+
+static inline unsigned int
+pagevec_count(struct pagevec *pvec)
+{
+ return pvec->nr;
+}
+
+static inline unsigned int
+pagevec_add(struct pagevec *pvec, struct vm_page *page)
+{
+ pvec->pages[pvec->nr++] = page;
+ return PAGEVEC_SIZE - pvec->nr;
+}
+
+static inline void
+__pagevec_release(struct pagevec *pvec)
+{
+ release_pages(pvec->pages, pagevec_count(pvec));
+ pagevec_reinit(pvec);
+}
+
+static inline void
+pagevec_release(struct pagevec *pvec)
+{
+ if (pagevec_count(pvec))
+ __pagevec_release(pvec);
+}
+
+static inline void
+check_move_unevictable_pages(struct pagevec *pvec)
+{
+}
+
+#endif /* _LINUXKPI_LINUX_PAGEVEC_H_ */