Re: [PATCH v4 13/13] x86/folio_zero_user: Add multi-page clearing

From: Dave Hansen
Date: Mon Jun 16 2025 - 11:05:57 EST


On 6/16/25 07:50, Peter Zijlstra wrote:
> On Mon, Jun 16, 2025 at 07:44:13AM -0700, Dave Hansen wrote:
>> To me, that's deserving of an ARCH_HAS_FOO bit that we can set on the
>> x86 side that then cajoles the core mm/ code to use the fancy new
>> clear_pages_resched() implementation.
> Note that we should only set this bit with either full or lazy
> preemption selected. Haven't checked the patch-set to see if that
> constraint is already taken care of.

There is a check in the C code for preempt_model_preemptible(). So as
long as there was something like:

config SOMETHING_PAGE_CLEARING
def_bool y
depends on ARCH_HAS_WHATEVER_PAGE_CLEARING
depends on !HIGHMEM

Then the check for HIGHMEM and the specific architecture support could
be along the lines of:

static void clear_pages_resched(void *addr, int npages)
{
int i, remaining;

if (!IS_ENABLED(SOMETHING_PAGE_CLEARING) ||
preempt_model_preemptible()) {
clear_pages(addr, npages);
goto out;
}

... which would also remove the #ifdef CONFIG_HIGHMEM in there now.