Re: [PATCH v3 1/6] set_memory: add number of pages parameter to set_direct_map APIs

From: Kevin Brodsky

Date: Mon Sep 21 2026 - 08:51:54 EST


On 18/09/2026 09:06, Mike Rapoport wrote:
> On Thu, Sep 17, 2026 at 08:11:22PM +0200, Kevin Brodsky wrote:
>> On 03/09/2026 11:28, Mike Rapoport (Microsoft) wrote:
>>> When set_direct_map APIs were introduced by the commit d253ca0c3865
>>> ("x86/mm/cpa: Add set_direct_map_*() functions") the single page
>>> parameter made sense because the initial callers (vmalloc and
>>> hibernation) had sets of unsorted struct pages that required changes of
>>> their mappings in the direct map.
>>>
>>> Since there is an increasing demand for direct map manipulation and it
>>> is also desirable to be able to update larger physically contiguous
>>> mappings, for example an entire large folio, extend set_direct_map APIs
>>> to receive number of pages parameter.
>>>
>>> As there is still only a handful of callers, change the existing
>>> functions directly and update all the call sites rather than adding
>>> wrappers for single page case.
>>>
>>> Signed-off-by: Mike Rapoport (Microsoft) <rppt@xxxxxxxxxx>
>>> ---
>>> arch/arm64/include/asm/set_memory.h | 4 ++--
>>> arch/arm64/mm/pageattr.c | 8 ++++----
>>> arch/loongarch/include/asm/set_memory.h | 4 ++--
>>> arch/loongarch/mm/pageattr.c | 8 ++++----
>>> arch/riscv/include/asm/set_memory.h | 4 ++--
>>> arch/riscv/mm/pageattr.c | 8 ++++----
>>> arch/s390/include/asm/set_memory.h | 4 ++--
>>> arch/s390/mm/pageattr.c | 8 ++++----
>>> arch/x86/include/asm/set_memory.h | 4 ++--
>>> arch/x86/mm/pat/set_memory.c | 8 ++++----
>>> include/linux/set_memory.h | 6 ++++--
>>> kernel/power/snapshot.c | 4 ++--
>>> mm/secretmem.c | 6 +++---
>>> mm/vmalloc.c | 5 +++--
>>> 14 files changed, 42 insertions(+), 39 deletions(-)
>>>
>>> diff --git a/arch/arm64/include/asm/set_memory.h b/arch/arm64/include/asm/set_memory.h
>>> index 90f61b17275e1..b07fd4e026eac 100644
>>> --- a/arch/arm64/include/asm/set_memory.h
>>> +++ b/arch/arm64/include/asm/set_memory.h
>>> @@ -11,8 +11,8 @@ bool can_set_direct_map(void);
>>>
>>> int set_memory_valid(unsigned long addr, int numpages, int enable);
>>>
>>> -int set_direct_map_invalid_noflush(struct page *page);
>>> -int set_direct_map_default_noflush(struct page *page);
>>> +int set_direct_map_invalid_noflush(struct page *page, unsigned int numpages);
>>> +int set_direct_map_default_noflush(struct page *page, unsigned int numpages);
>> I don't have a strong opinion on whether to call the argument nr or
>> numpages, but we might as well be consistent across archs :)
> Well, it's either consistent across archs or consistent within each arch :)
> Or add a churny patch that renames it everywhere to nr_pages :)

Eh fair enough... Clearly not the biggest inconsistency in the
set_direct_map API anyway!

- Kevin