lkml.org 
[lkml]   [2022]   [Jan]   [24]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
SubjectRe: [PATCH] mm: make 'highmem' symbol ro_after_init
On Mon, Jan 24, 2022 at 06:05:55PM +0100, Ard Biesheuvel wrote:
> The 'highmem' variable is only set at boot, so we can make it
> ro_after_init and prevent it from being corrupted inadvertently, or from
> ending up in a contended cacheline.

I'm not against this patch, but it'd be nice to go further and remove
it entirely for !CONFIG_HIGHMEM builds? Adding something like

static inline bool is_high_pfn(unsigned long pfn)
{
#ifdef CONFIG_HIGHMEM
return pfn <= max_low_pfn;
#else
return false;
#endif
}

static inline bool is_high_phys(phys_addr_t pa)
{
return is_high_pfn(pa / PAGE_SIZE);
}

static inline bool is_high_addr(void *addr)
{
return is_high_phys(virt_to_phys(addr));
}

should be all the primitives you need, from a quick grep.

> Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
> ---
> mm/memory.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/mm/memory.c b/mm/memory.c
> index c125c4969913..50e82cb94ccc 100644
> --- a/mm/memory.c
> +++ b/mm/memory.c
> @@ -106,7 +106,7 @@ EXPORT_SYMBOL(mem_map);
> * highstart_pfn must be the same; there must be no gap between ZONE_NORMAL
> * and ZONE_HIGHMEM.
> */
> -void *high_memory;
> +void *high_memory __ro_after_init;
> EXPORT_SYMBOL(high_memory);
>
> /*
> --
> 2.30.2
>
>

\
 
 \ /
  Last update: 2022-01-24 19:33    [W:0.152 / U:0.024 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site