mm/thp: Make ALLOC_SPLIT_PTLOCKS dependent on USE_SPLIT_PTE_PTLOCKS
Subsystems (2)
PATCH v2 1/1 mm/thp: Make ALLOC_SPLIT_PTLOCKS dependent on USE_SPLIT_PTE_PTLOCKS
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.
---
This applies on v5.13-rc2.
Changes in V2:
- Dropped spinlock_t element from struct page
Changes in V1:
https://lore.kernel.org/linux-mm/[email protected]/
include/linux/mm_types.h | 2 ++ include/linux/mm_types_task.h | 5 +++++ mm/memory.c | 2 +- 3 files changed, 8 insertions(+), 1 deletion(-)
include/linux/mm_types.h +2 -0
@@ -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 */
include/linux/mm_types_task.h +5 -0
@@ -22,7 +22,12 @@#define USE_SPLIT_PTE_PTLOCKS (NR_CPUS >= CONFIG_SPLIT_PTLOCK_CPUS)#define USE_SPLIT_PMD_PTLOCKS (USE_SPLIT_PTE_PTLOCKS && \ IS_ENABLED(CONFIG_ARCH_ENABLE_SPLIT_PMD_PTLOCK)) + +#if USE_SPLIT_PTE_PTLOCKS #define ALLOC_SPLIT_PTLOCKS (SPINLOCK_SIZE > BITS_PER_LONG/8) +#else +#define ALLOC_SPLIT_PTLOCKS 0 +#endif /* * The per task VMA cache array:
mm/memory.c +1 -1
@@ -5250,7 +5250,7 @@ long copy_huge_page_from_user(struct page *dst_page, }#endif /* CONFIG_TRANSPARENT_HUGEPAGE || CONFIG_HUGETLBFS */ -#if USE_SPLIT_PTE_PTLOCKS &&ALLOC_SPLIT_PTLOCKS +#if ALLOC_SPLIT_PTLOCKS static struct kmem_cache *page_ptl_cachep;
Signature · 1 line
2.20.1
Quoted 4 lines · Anshuman Khandual
Split ptlocks need not be defined and allocated unless they are being used.
ALLOC_SPLIT_PTLOCKSis inherently dependent onUSE_SPLIT_PTE_PTLOCKS. This just makes it explicit and clear. While here drop thespinlock_telement from the struct page whenUSE_SPLIT_PTE_PTLOCKSis 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.
Quoted 14 lines
+++
b/include/linux/mm_types.hinclude/linux/mm_types.h +2
-0@@ -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 */
Quoted 9 lines · Matthew Wilcox
Quoted 4 lines · Anshuman Khandual
Split ptlocks need not be defined and allocated unless they are being used.
ALLOC_SPLIT_PTLOCKSis inherently dependent onUSE_SPLIT_PTE_PTLOCKS. This just makes it explicit and clear. While here drop thespinlock_telement from the struct page whenUSE_SPLIT_PTE_PTLOCKSis 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.
This discussion thread just got dropped off the radar, sorry about it. None of the spinlock_t elements are required unless split ptlocks are in use. I understand your concern regarding yet another #ifdef in the struct page definition. But this change is simple and minimal. Do you have any other particular alternative in mind which I could explore ?
Quoted 15 lines
Quoted 15 lines
+++
b/include/linux/mm_types.hinclude/linux/mm_types.h +2
-0@@ -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 */
Quoted 13 lines · Anshuman Khandual
Quoted 9 lines · Matthew Wilcox
Quoted 4 lines · Anshuman Khandual
Split ptlocks need not be defined and allocated unless they are being used.
ALLOC_SPLIT_PTLOCKSis inherently dependent onUSE_SPLIT_PTE_PTLOCKS. This just makes it explicit and clear. While here drop thespinlock_telement from the struct page whenUSE_SPLIT_PTE_PTLOCKSis 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.
Quoted 5 lines
This discussion thread just got dropped off the radar, sorry about it. None of the
spinlock_telements are required unless split ptlocks are in use. I understand your concern regarding yet another #ifdef in the struct page definition. But this change is simple and minimal. Do you have any other particular alternative in mind which I could explore ?
Do nothing? I don't understand what problem you're trying to solve.
Quoted 14 lines · Matthew Wilcox
Quoted 13 lines · Anshuman Khandual
Quoted 9 lines · Matthew Wilcox
Quoted 4 lines · Anshuman Khandual
Split ptlocks need not be defined and allocated unless they are being used.
ALLOC_SPLIT_PTLOCKSis inherently dependent onUSE_SPLIT_PTE_PTLOCKS. This just makes it explicit and clear. While here drop thespinlock_telement from the struct page whenUSE_SPLIT_PTE_PTLOCKSis 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.
Quoted 7 lines
Quoted 5 lines
This discussion thread just got dropped off the radar, sorry about it. None of the
spinlock_telements are required unless split ptlocks are in use. I understand your concern regarding yet another #ifdef in the struct page definition. But this change is simple and minimal. Do you have any other particular alternative in mind which I could explore ?Do nothing? I don't understand what problem you're trying to solve.
Currently there is an element (spinlock_t ptl) in the struct page for page table lock. Although a struct page based spinlock is not even required in case USE_SPLIT_PTE_PTLOCKS evaluates to be false. Is not that something to be fixed here i.e drop the splinlock_t element if not required ?
The problem is USE_SPLIT_PTE_PTLOCKS and ALLOC_SPLIT_PTLOCKS get evaluated independently, although they are inherently dependent. ALLOC_SPLIT_PTLOCKS could just be set to 0, when USE_SPLIT_PTE_PTLOCKS evaluates to be 0. This patch makes that dependency explicit and also fixes the above situation.
Quoted 22 lines · Anshuman Khandual
Quoted 20 lines · Matthew Wilcox
Quoted 18 lines · Anshuman Khandual
Quoted 9 lines · Matthew Wilcox
Quoted 4 lines · Anshuman Khandual
Split ptlocks need not be defined and allocated unless they are being used.
ALLOC_SPLIT_PTLOCKSis inherently dependent onUSE_SPLIT_PTE_PTLOCKS. This just makes it explicit and clear. While here drop thespinlock_telement from the struct page whenUSE_SPLIT_PTE_PTLOCKSis 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.
This discussion thread just got dropped off the radar, sorry about it. None of the
spinlock_telements are required unless split ptlocks are in use. I understand your concern regarding yet another #ifdef in the struct page definition. But this change is simple and minimal. Do you have any other particular alternative in mind which I could explore ?
Quoted 6 lines
Quoted 1 line
Do nothing? I don't understand what problem you're trying to solve.
Currently there is an element (
spinlock_tptl) in the struct page for page table lock. Although a struct page based spinlock is not even required in caseUSE_SPLIT_PTE_PTLOCKSevaluates to be false. Is not that something to be fixed here i.e drop thesplinlock_telement if not required ?
No? It doesn't actually cause any problems, does it?
Quoted 23 lines · Matthew Wilcox
Quoted 22 lines · Anshuman Khandual
Quoted 20 lines · Matthew Wilcox
Quoted 18 lines · Anshuman Khandual
Quoted 9 lines · Matthew Wilcox
Quoted 4 lines · Anshuman Khandual
Split ptlocks need not be defined and allocated unless they are being used.
ALLOC_SPLIT_PTLOCKSis inherently dependent onUSE_SPLIT_PTE_PTLOCKS. This just makes it explicit and clear. While here drop thespinlock_telement from the struct page whenUSE_SPLIT_PTE_PTLOCKSis 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.
This discussion thread just got dropped off the radar, sorry about it. None of the
spinlock_telements are required unless split ptlocks are in use. I understand your concern regarding yet another #ifdef in the struct page definition. But this change is simple and minimal. Do you have any other particular alternative in mind which I could explore ?
Quoted 9 lines
Quoted 6 lines
Quoted 1 line
Do nothing? I don't understand what problem you're trying to solve.
Currently there is an element (
spinlock_tptl) in the struct page for page table lock. Although a struct page based spinlock is not even required in caseUSE_SPLIT_PTE_PTLOCKSevaluates to be false. Is not that something to be fixed here i.e drop thesplinlock_telement if not required ?No? It doesn't actually cause any problems, does it?
No but should an unnecessary element in a struct is dropped only if there is a reported problem ?
Quoted 33 lines · Anshuman Khandual
Quoted 30 lines · Matthew Wilcox
Quoted 28 lines · Anshuman Khandual
Quoted 14 lines · Matthew Wilcox
Quoted 13 lines · Anshuman Khandual
Quoted 9 lines · Matthew Wilcox
Quoted 4 lines · Anshuman Khandual
Split ptlocks need not be defined and allocated unless they are being used.
ALLOC_SPLIT_PTLOCKSis inherently dependent onUSE_SPLIT_PTE_PTLOCKS. This just makes it explicit and clear. While here drop thespinlock_telement from the struct page whenUSE_SPLIT_PTE_PTLOCKSis 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.
Quoted 7 lines
Quoted 5 lines
This discussion thread just got dropped off the radar, sorry about it. None of the
spinlock_telements are required unless split ptlocks are in use. I understand your concern regarding yet another #ifdef in the struct page definition. But this change is simple and minimal. Do you have any other particular alternative in mind which I could explore ?Do nothing? I don't understand what problem you're trying to solve.
Currently there is an element (
spinlock_tptl) in the struct page for page table lock. Although a struct page based spinlock is not even required in caseUSE_SPLIT_PTE_PTLOCKSevaluates to be false. Is not that something to be fixed here i.e drop thesplinlock_telement if not required ?
Quoted 4 lines
Quoted 1 line
No? It doesn't actually cause any problems, does it?
No but should an unnecessary element in a struct is dropped only if there is a reported problem ?
In this case, yes. It's not just a struct member; it's a member of a union in the struct. You don't save any memory by getting rid of it. There's no benefit to getting rid of it.