git: b17957b9d165 - stable/15 - LinuxKPI: move clear_page() within the linux/page.h file

Bjoern A. Zeeb <[email protected]>
Newsgroups gmane.os.freebsd.devel.cvs.src
Message-ID <6a66a207.25f28.484c9a9f__22303.1071642012$1785111283$gmane$org@gitrepo.freebsd.org>
The branch stable/15 has been updated by bz:

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

commit b17957b9d165dbde267213cbb9469739197213d4
Author:     Bjoern A. Zeeb <[email protected]>
AuthorDate: 2026-07-17 12:53:16 +0000
Commit:     Bjoern A. Zeeb <[email protected]>
CommitDate: 2026-07-26 16:48:52 +0000

    LinuxKPI: move clear_page() within the linux/page.h file
    
    clear_page() would normally live in asm/page.h but adding the file
    and fixing the dependencies would be too much for a single line.
    
    Move the function to the end of the file with a clear separator
    and make it clear that it does not operate on a 'struct page'
    but on a page address by changing the argument name and leaving
    a comment.
    
    The function is currently used by at least mthca(4) as the only
    in-tree consumer, and drm-kmod ttm_pool.c.
    
    No functional changes.
    
    Sponsored by:   The FreeBSD Foundation
    Reviewed by:    emaste
    Differential Revision: https://reviews.freebsd.org/D58296
    
    (cherry picked from commit 0845efe88b355547b103dca90e69e46a3ebdd016)
---
 sys/compat/linuxkpi/common/include/linux/page.h | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/sys/compat/linuxkpi/common/include/linux/page.h b/sys/compat/linuxkpi/common/include/linux/page.h
index 6f5f37d2fd0f..a8e266af95fd 100644
--- a/sys/compat/linuxkpi/common/include/linux/page.h
+++ b/sys/compat/linuxkpi/common/include/linux/page.h
@@ -79,7 +79,6 @@ pgprot2cachemode(pgprot_t prot)
 #define	nth_page(page,n)	pfn_to_page(page_to_pfn(page) + (n))
 #define	page_to_phys(page)	VM_PAGE_TO_PHYS(page)
 
-#define	clear_page(page)		memset(page, 0, PAGE_SIZE)
 #define	pgprot_noncached(prot)		\
 	(((prot) & VM_PROT_ALL) | cachemode2protval(VM_MEMATTR_UNCACHEABLE))
 #ifdef VM_MEMATTR_WRITE_COMBINING
@@ -129,4 +128,11 @@ clflush_cache_range(void *addr, unsigned int size)
 
 int lkpi_set_pages_attr(struct page *page, int numpages, vm_memattr_t ma);
 
+/* -------------------------------------------------------------------------- */
+/*
+ * clear_page() is called on kmem allocated page addresses, thus zeros a page
+ * not a 'struct page'.  Really belongs into <asm/page.h>.
+ */
+#define	clear_page(_pa)		memset(_pa, 0, PAGE_SIZE)
+
 #endif	/* _LINUXKPI_LINUX_PAGE_H_ */
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.