[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <643f5482-cd34-4534-8cd8-69f32482bc27@redhat.com>
Date: Tue, 2 Sep 2025 22:16:40 +0200
From: David Hildenbrand <david@...hat.com>
To: Ankur Arora <ankur.a.arora@...cle.com>, linux-kernel@...r.kernel.org,
linux-mm@...ck.org, x86@...nel.org
Cc: akpm@...ux-foundation.org, bp@...en8.de, dave.hansen@...ux.intel.com,
hpa@...or.com, mingo@...hat.com, mjguzik@...il.com, luto@...nel.org,
peterz@...radead.org, acme@...nel.org, namhyung@...nel.org,
tglx@...utronix.de, willy@...radead.org, raghavendra.kt@....com,
boris.ostrovsky@...cle.com, konrad.wilk@...cle.com
Subject: Re: [PATCH v6 11/15] mm: define clear_pages(), clear_user_pages()
On 02.09.25 10:08, Ankur Arora wrote:
> Define fallback versions of clear_pages(), clear_user_pages().
>
> In absence of architectural primitives, these just do straight clearing
> sequentially.
>
> Signed-off-by: Ankur Arora <ankur.a.arora@...cle.com>
> ---
> include/linux/mm.h | 32 ++++++++++++++++++++++++++++++++
> 1 file changed, 32 insertions(+)
>
> diff --git a/include/linux/mm.h b/include/linux/mm.h
> index 1ae97a0b8ec7..b8c3f265b497 100644
> --- a/include/linux/mm.h
> +++ b/include/linux/mm.h
> @@ -3768,6 +3768,38 @@ static inline void clear_page_guard(struct zone *zone, struct page *page,
> unsigned int order) {}
> #endif /* CONFIG_DEBUG_PAGEALLOC */
>
> +#ifndef ARCH_PAGE_CONTIG_NR
> +#define PAGE_CONTIG_NR 1
> +#else
> +#define PAGE_CONTIG_NR ARCH_PAGE_CONTIG_NR
> +#endif
> +
These likely don't belong into this aptch :)
> +#ifndef clear_pages
> +/*
/**
for proper kernel doc
> + * clear_pages() - clear kernel page range.
> + * @addr: start address of page range
> + * @npages: number of pages
> + *
> + * Assumes that (@addr, +@...ges) references a kernel region.
> + * Like clear_page(), this does absolutely no exception handling.
> + */
> +static inline void clear_pages(void *addr, unsigned int npages)
> +{
> + for (int i = 0; i < npages; i++)
> + clear_page(addr + i * PAGE_SIZE);
If we know that we will clear at least one page (which we can document)
do {
clear_page(addr);
addr += PAGE_SIZE;
} while (--npages);
Similarly for the case below.
> +}
> +#endif
> +
> +#ifndef clear_user_pages
Can we add kernel doc here as well?
> +static inline void clear_user_pages(void *addr, unsigned long vaddr,
> + struct page *pg, unsigned int npages)
> +{
> + for (int i = 0; i < npages; i++)
> + clear_user_page(addr + i * PAGE_SIZE,
> + vaddr + i * PAGE_SIZE, pg + i);
> +}
> +#endif
> +
> #ifdef __HAVE_ARCH_GATE_AREA
> extern struct vm_area_struct *get_gate_vma(struct mm_struct *mm);
> extern int in_gate_area_no_mm(unsigned long addr);
--
Cheers
David / dhildenb
Powered by blists - more mailing lists