git: 9e9c682ff3a1 - main - LinuxKPI: reduce usage of struct vm_page and vm_page_t

From: Bjoern A. Zeeb <bz_at_FreeBSD.org>
Date: Mon, 07 Aug 2023 01:00:20 UTC
The branch main has been updated by bz:

URL: https://cgit.FreeBSD.org/src/commit/?id=9e9c682ff3a1aec20a7e5f5b1dd88ceaec7c3950

commit 9e9c682ff3a1aec20a7e5f5b1dd88ceaec7c3950
Author:     Bjoern A. Zeeb <bz@FreeBSD.org>
AuthorDate: 2023-07-31 02:03:39 +0000
Commit:     Bjoern A. Zeeb <bz@FreeBSD.org>
CommitDate: 2023-08-07 00:55:30 +0000

    LinuxKPI: reduce usage of struct vm_page and vm_page_t
    
    We currently define (Linux) page to (FreeBSD) vm_page.
    Cleanup some of the direct struct vm_page and vm_page_t declarations
    and usages in the Linux KPI and make them 'struct page' or
    'struct page *' to prepare for more upcoming work.
    
    This should be a NOP.
    
    Sponsored by:   The FreeBSD Foundation
    MFC after:      2 weeks
    Reviewed by:    markj
    Differential Revision: https://reviews.freebsd.org/D41255
---
 sys/compat/linuxkpi/common/include/asm/set_memory.h | 12 ++++++------
 sys/compat/linuxkpi/common/include/linux/gfp.h      |  4 ++--
 sys/compat/linuxkpi/common/include/linux/highmem.h  | 12 ++++++------
 sys/compat/linuxkpi/common/include/linux/mm.h       | 10 +++++-----
 sys/compat/linuxkpi/common/include/linux/pagevec.h  |  4 ++--
 sys/compat/linuxkpi/common/src/linux_page.c         |  6 +++---
 sys/compat/linuxkpi/common/src/linux_shmemfs.c      |  2 +-
 7 files changed, 25 insertions(+), 25 deletions(-)

diff --git a/sys/compat/linuxkpi/common/include/asm/set_memory.h b/sys/compat/linuxkpi/common/include/asm/set_memory.h
index cdb7ad912acc..ae50148f0314 100644
--- a/sys/compat/linuxkpi/common/include/asm/set_memory.h
+++ b/sys/compat/linuxkpi/common/include/asm/set_memory.h
@@ -54,7 +54,7 @@ set_memory_wb(unsigned long addr, int numpages)
 }
 
 static inline int
-set_pages_uc(vm_page_t page, int numpages)
+set_pages_uc(struct page *page, int numpages)
 {
 	KASSERT(numpages == 1, ("%s: numpages %d", __func__, numpages));
 
@@ -63,7 +63,7 @@ set_pages_uc(vm_page_t page, int numpages)
 }
 
 static inline int
-set_pages_wc(vm_page_t page, int numpages)
+set_pages_wc(struct page *page, int numpages)
 {
 	KASSERT(numpages == 1, ("%s: numpages %d", __func__, numpages));
 
@@ -76,7 +76,7 @@ set_pages_wc(vm_page_t page, int numpages)
 }
 
 static inline int
-set_pages_wb(vm_page_t page, int numpages)
+set_pages_wb(struct page *page, int numpages)
 {
 	KASSERT(numpages == 1, ("%s: numpages %d", __func__, numpages));
 
@@ -85,7 +85,7 @@ set_pages_wb(vm_page_t page, int numpages)
 }
 
 static inline int
-set_pages_array_wb(vm_page_t *pages, int addrinarray)
+set_pages_array_wb(struct page **pages, int addrinarray)
 {
 	int i;
 
@@ -95,7 +95,7 @@ set_pages_array_wb(vm_page_t *pages, int addrinarray)
 }
 
 static inline int
-set_pages_array_wc(vm_page_t *pages, int addrinarray)
+set_pages_array_wc(struct page **pages, int addrinarray)
 {
 	int i;
 
@@ -105,7 +105,7 @@ set_pages_array_wc(vm_page_t *pages, int addrinarray)
 }
 
 static inline int
-set_pages_array_uc(vm_page_t *pages, int addrinarray)
+set_pages_array_uc(struct page **pages, int addrinarray)
 {
 	int i;
 
diff --git a/sys/compat/linuxkpi/common/include/linux/gfp.h b/sys/compat/linuxkpi/common/include/linux/gfp.h
index 55558500dd30..9e6d3a665869 100644
--- a/sys/compat/linuxkpi/common/include/linux/gfp.h
+++ b/sys/compat/linuxkpi/common/include/linux/gfp.h
@@ -99,8 +99,8 @@ extern void *linux_page_address(struct page *);
 /*
  * Page management for unmapped pages:
  */
-extern vm_page_t linux_alloc_pages(gfp_t flags, unsigned int order);
-extern void linux_free_pages(vm_page_t page, unsigned int order);
+extern struct page *linux_alloc_pages(gfp_t flags, unsigned int order);
+extern void linux_free_pages(struct page *page, unsigned int order);
 void *linuxkpi_page_frag_alloc(struct page_frag_cache *, size_t, gfp_t);
 void linuxkpi_page_frag_free(void *);
 void linuxkpi__page_frag_cache_drain(struct page *, size_t);
diff --git a/sys/compat/linuxkpi/common/include/linux/highmem.h b/sys/compat/linuxkpi/common/include/linux/highmem.h
index 1c2c97e03578..a3f9af82400e 100644
--- a/sys/compat/linuxkpi/common/include/linux/highmem.h
+++ b/sys/compat/linuxkpi/common/include/linux/highmem.h
@@ -47,7 +47,7 @@
 
 #define	PageHighMem(p)		(0)
 
-static inline vm_page_t
+static inline struct page *
 kmap_to_page(void *addr)
 {
 
@@ -55,7 +55,7 @@ kmap_to_page(void *addr)
 }
 
 static inline void *
-kmap(vm_page_t page)
+kmap(struct page *page)
 {
 	struct sf_buf *sf;
 
@@ -73,7 +73,7 @@ kmap(vm_page_t page)
 }
 
 static inline void *
-kmap_atomic_prot(vm_page_t page, pgprot_t prot)
+kmap_atomic_prot(struct page *page, pgprot_t prot)
 {
 	vm_memattr_t attr = pgprot2cachemode(prot);
 
@@ -87,21 +87,21 @@ kmap_atomic_prot(vm_page_t page, pgprot_t prot)
 }
 
 static inline void *
-kmap_atomic(vm_page_t page)
+kmap_atomic(struct page *page)
 {
 
 	return (kmap_atomic_prot(page, VM_PROT_ALL));
 }
 
 static inline void *
-kmap_local_page_prot(vm_page_t page, pgprot_t prot)
+kmap_local_page_prot(struct page *page, pgprot_t prot)
 {
 
 	return (kmap_atomic_prot(page, prot));
 }
 
 static inline void
-kunmap(vm_page_t page)
+kunmap(struct page *page)
 {
 	struct sf_buf *sf;
 
diff --git a/sys/compat/linuxkpi/common/include/linux/mm.h b/sys/compat/linuxkpi/common/include/linux/mm.h
index 8dab5b9daa76..00d102b6af4b 100644
--- a/sys/compat/linuxkpi/common/include/linux/mm.h
+++ b/sys/compat/linuxkpi/common/include/linux/mm.h
@@ -248,19 +248,19 @@ vma_pages(struct vm_area_struct *vma)
 #define	offset_in_page(off)	((unsigned long)(off) & (PAGE_SIZE - 1))
 
 static inline void
-set_page_dirty(struct vm_page *page)
+set_page_dirty(struct page *page)
 {
 	vm_page_dirty(page);
 }
 
 static inline void
-mark_page_accessed(struct vm_page *page)
+mark_page_accessed(struct page *page)
 {
 	vm_page_reference(page);
 }
 
 static inline void
-get_page(struct vm_page *page)
+get_page(struct page *page)
 {
 	vm_page_wire(page);
 }
@@ -307,7 +307,7 @@ pin_user_pages_remote(struct task_struct *task, struct mm_struct *mm,
 }
 
 static inline void
-put_page(struct vm_page *page)
+put_page(struct page *page)
 {
 	vm_page_unwire(page, PQ_ACTIVE);
 }
@@ -323,7 +323,7 @@ vm_get_page_prot(unsigned long vm_flags)
 	return (vm_flags & VM_PROT_ALL);
 }
 
-static inline vm_page_t
+static inline struct page *
 vmalloc_to_page(const void *addr)
 {
 	vm_paddr_t paddr;
diff --git a/sys/compat/linuxkpi/common/include/linux/pagevec.h b/sys/compat/linuxkpi/common/include/linux/pagevec.h
index 4224124c4fe4..9ba8ff8effa0 100644
--- a/sys/compat/linuxkpi/common/include/linux/pagevec.h
+++ b/sys/compat/linuxkpi/common/include/linux/pagevec.h
@@ -13,7 +13,7 @@
 
 struct pagevec {
 	uint8_t	nr;
-	struct vm_page *pages[PAGEVEC_SIZE];
+	struct page *pages[PAGEVEC_SIZE];
 };
 
 static inline unsigned int
@@ -41,7 +41,7 @@ pagevec_count(struct pagevec *pvec)
 }
 
 static inline unsigned int
-pagevec_add(struct pagevec *pvec, struct vm_page *page)
+pagevec_add(struct pagevec *pvec, struct page *page)
 {
 	pvec->pages[pvec->nr++] = page;
 	return PAGEVEC_SIZE - pvec->nr;
diff --git a/sys/compat/linuxkpi/common/src/linux_page.c b/sys/compat/linuxkpi/common/src/linux_page.c
index 6fcf9373a2f5..0cb724ebf6c4 100644
--- a/sys/compat/linuxkpi/common/src/linux_page.c
+++ b/sys/compat/linuxkpi/common/src/linux_page.c
@@ -98,10 +98,10 @@ linux_page_address(struct page *page)
 	    IDX_TO_OFF(page->pindex)));
 }
 
-vm_page_t
+struct page *
 linux_alloc_pages(gfp_t flags, unsigned int order)
 {
-	vm_page_t page;
+	struct page *page;
 
 	if (PMAP_HAS_DMAP) {
 		unsigned long npages = 1UL << order;
@@ -148,7 +148,7 @@ linux_alloc_pages(gfp_t flags, unsigned int order)
 }
 
 void
-linux_free_pages(vm_page_t page, unsigned int order)
+linux_free_pages(struct page *page, unsigned int order)
 {
 	if (PMAP_HAS_DMAP) {
 		unsigned long npages = 1UL << order;
diff --git a/sys/compat/linuxkpi/common/src/linux_shmemfs.c b/sys/compat/linuxkpi/common/src/linux_shmemfs.c
index 741bb20c1aab..6ae11e8ef57e 100644
--- a/sys/compat/linuxkpi/common/src/linux_shmemfs.c
+++ b/sys/compat/linuxkpi/common/src/linux_shmemfs.c
@@ -47,7 +47,7 @@ __FBSDID("$FreeBSD$");
 struct page *
 linux_shmem_read_mapping_page_gfp(vm_object_t obj, int pindex, gfp_t gfp)
 {
-	vm_page_t page;
+	struct page *page;
 	int rv;
 
 	if ((gfp & GFP_NOWAIT) != 0)