Re: [PATCH V3] x86/mm: Tracking linear mapping split events

From: Dave Hansen
Date: Wed Jan 27 2021 - 18:44:59 EST


On 1/27/21 2:50 PM, Saravanan D wrote:
> +#if defined(__x86_64__)

We don't use __x86_64__ in the kernel. This should be CONFIG_X86.

> +#if defined(CONFIG_X86_64) || defined(CONFIG_X86_PAE)
> + "direct_map_2M_splits",
> +#else
> + "direct_map_4M_splits",
> +#endif
> + "direct_map_1G_splits",
> +#endif

These #ifdefs are hideous, and repeated.

I'd rather have no 32-bit support than expose us to this ugliness.
Worst case, the 32-bit non-PAE folks (i.e. almost nobody in the world)
can just live with seeing "2M" when the mappings are really 4M. Or, you
*could* name these after the page table levels:

direct_map_pmd_splits
direct_map_pud_splits

or the level from the bottom where the split occurred:

direct_map_level2_splits
direct_map_level3_splits

That has the bonus of being usable on other architectures.

Oh, and 1G splits aren't possible on non-PAE 32-bit. There are only 2
levels: 4M and 4k, which would make what you have above:

> +#if defined(CONFIG_X86_64) || defined(CONFIG_X86_PAE)
> + "direct_map_2M_splits",
> + "direct_map_1G_splits",
> +#else
> + "direct_map_4M_splits",
> +#endif

I don't think there's ever a 1G/4M case.