Re: [PATCH V2] mm/thp: Make ALLOC_SPLIT_PTLOCKS dependent on USE_SPLIT_PTE_PTLOCKS

From: Matthew Wilcox
Date: Thu May 20 2021 - 08:24:30 EST


On Wed, May 19, 2021 at 01:03:06PM +0530, Anshuman Khandual wrote:
> Split ptlocks need not be defined and allocated unless they are being used.
> ALLOC_SPLIT_PTLOCKS is inherently dependent on USE_SPLIT_PTE_PTLOCKS. This
> just makes it explicit and clear. While here drop the spinlock_t element
> from the struct page when USE_SPLIT_PTE_PTLOCKS is not enabled.

I didn't spot this email yesterday. I'm not a fan. Isn't struct page
already complicated enough without adding another ifdef to it? Surely
there's a better way than this.

> +++ b/include/linux/mm_types.h
> @@ -152,10 +152,12 @@ struct page {
> struct mm_struct *pt_mm; /* x86 pgds only */
> atomic_t pt_frag_refcount; /* powerpc */
> };
> +#if USE_SPLIT_PTE_PTLOCKS
> #if ALLOC_SPLIT_PTLOCKS
> spinlock_t *ptl;
> #else
> spinlock_t ptl;
> +#endif
> #endif
> };
> struct { /* ZONE_DEVICE pages */