Re: [PATCH v9 01/13] set_memory: add folio_{zap, restore}_direct_map helpers
From: Nikita Kalyazin
Date: Thu Jan 15 2026 - 12:46:15 EST
On 15/01/2026 15:55, Matthew Wilcox wrote:
On Wed, Jan 14, 2026 at 01:45:23PM +0000, Kalyazin, Nikita wrote:
+int folio_zap_direct_map(struct folio *folio)
+{
+ return set_direct_map_valid_noflush(folio_page(folio, 0),
+ folio_nr_pages(folio), false);
+}
The implementation isn't the greatest. None of the implementations
of set_direct_map_valid_noflush() actually do anything with the struct
page; they all call page_address() or page_to_virt() (fundamentally the
same thing). So converting folio->page->address is a bit inefficient.
It feels like we should change set_direct_map_valid_noflush() to take a
const void * and pass either page_address() or folio_address(), depending
whether the caller has a page or a folio. What do you think?
I have nothing against that. execmem_set_direct_map_valid() appears to be the only other user of set_direct_map_valid_noflush() so it isn't going to be a broad change.