Re: [PATCH v3] mm/memory: drop PROCESS_PAGES_NON_PREEMPT_BATCH
From: Peter Zijlstra
Date: Wed Nov 11 2026 - 07:40:26 EST
On Mon, Nov 09, 2026 at 07:15:51PM +0000, Shivank Garg wrote:
> static void clear_contig_highpages(struct page *page, unsigned long addr,
> + unsigned int nr_pages)
> {
> + unsigned int i;
> +
> + might_sleep();
> +
> /*
> * When clearing we want to operate on the largest extent possible to
> * allow for architecture specific extent based optimizations.
> *
> + * clear_user_highpages() (and primitives clear_user_pages(),
> + * clear_pages()) do not call cond_resched(). That is fine on
> + * preemptible kernels, where the scheduler can preempt the clearing
> + * at any point, so clear the whole range at once. Otherwise, clear
> + * one page at a time and reschedule in between.
> */
> + if (IS_ENABLED(CONFIG_PREEMPTION)) {
> + clear_user_highpages(page, addr, nr_pages);
> + return;
> + }
>
> + for (i = 0; i < nr_pages; i++) {
FWIW one could do:
for (int i = 0; i < nr_pages; i++) {
and forgo the earlier variable declaration.
> cond_resched();
> + clear_user_highpage(page + i, addr + i * PAGE_SIZE);
> }
> }