Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

mm: do not allocate page->ptl dynamically, if spinlock_t fits to long

In struct page we have enough space to fit long-size page->ptl there,
but we use dynamically-allocated page->ptl if size(spinlock_t) is larger
than sizeof(int).

It hurts 64-bit architectures with CONFIG_GENERIC_LOCKBREAK, where
sizeof(spinlock_t) == 8, but it easily fits into struct page.

Signed-off-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
Acked-by: Hugh Dickins <hughd@google.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

authored by

Kirill A. Shutemov and committed by
Linus Torvalds
597d795a fff4068c

+8 -7
+1 -1
include/linux/lockref.h
··· 19 19 20 20 #define USE_CMPXCHG_LOCKREF \ 21 21 (IS_ENABLED(CONFIG_ARCH_USE_CMPXCHG_LOCKREF) && \ 22 - IS_ENABLED(CONFIG_SMP) && !BLOATED_SPINLOCKS) 22 + IS_ENABLED(CONFIG_SMP) && SPINLOCK_SIZE <= 4) 23 23 24 24 struct lockref { 25 25 union {
+3 -3
include/linux/mm.h
··· 1317 1317 #endif /* CONFIG_MMU && !__ARCH_HAS_4LEVEL_HACK */ 1318 1318 1319 1319 #if USE_SPLIT_PTE_PTLOCKS 1320 - #if BLOATED_SPINLOCKS 1320 + #if ALLOC_SPLIT_PTLOCKS 1321 1321 extern bool ptlock_alloc(struct page *page); 1322 1322 extern void ptlock_free(struct page *page); 1323 1323 ··· 1325 1325 { 1326 1326 return page->ptl; 1327 1327 } 1328 - #else /* BLOATED_SPINLOCKS */ 1328 + #else /* ALLOC_SPLIT_PTLOCKS */ 1329 1329 static inline bool ptlock_alloc(struct page *page) 1330 1330 { 1331 1331 return true; ··· 1339 1339 { 1340 1340 return &page->ptl; 1341 1341 } 1342 - #endif /* BLOATED_SPINLOCKS */ 1342 + #endif /* ALLOC_SPLIT_PTLOCKS */ 1343 1343 1344 1344 static inline spinlock_t *pte_lockptr(struct mm_struct *mm, pmd_t *pmd) 1345 1345 {
+2 -1
include/linux/mm_types.h
··· 26 26 #define USE_SPLIT_PTE_PTLOCKS (NR_CPUS >= CONFIG_SPLIT_PTLOCK_CPUS) 27 27 #define USE_SPLIT_PMD_PTLOCKS (USE_SPLIT_PTE_PTLOCKS && \ 28 28 IS_ENABLED(CONFIG_ARCH_ENABLE_SPLIT_PMD_PTLOCK)) 29 + #define ALLOC_SPLIT_PTLOCKS (SPINLOCK_SIZE > BITS_PER_LONG/8) 29 30 30 31 /* 31 32 * Each physical page in the system has a struct page associated with ··· 156 155 * system if PG_buddy is set. 157 156 */ 158 157 #if USE_SPLIT_PTE_PTLOCKS 159 - #if BLOATED_SPINLOCKS 158 + #if ALLOC_SPLIT_PTLOCKS 160 159 spinlock_t *ptl; 161 160 #else 162 161 spinlock_t ptl;
+1 -1
kernel/bounds.c
··· 22 22 #ifdef CONFIG_SMP 23 23 DEFINE(NR_CPUS_BITS, ilog2(CONFIG_NR_CPUS)); 24 24 #endif 25 - DEFINE(BLOATED_SPINLOCKS, sizeof(spinlock_t) > sizeof(int)); 25 + DEFINE(SPINLOCK_SIZE, sizeof(spinlock_t)); 26 26 /* End of constants */ 27 27 }
+1 -1
mm/memory.c
··· 4271 4271 } 4272 4272 #endif /* CONFIG_TRANSPARENT_HUGEPAGE || CONFIG_HUGETLBFS */ 4273 4273 4274 - #if USE_SPLIT_PTE_PTLOCKS && BLOATED_SPINLOCKS 4274 + #if ALLOC_SPLIT_PTLOCKS 4275 4275 bool ptlock_alloc(struct page *page) 4276 4276 { 4277 4277 spinlock_t *ptl;