linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] mm: memory: Force-inline PTE/PMD zapping functions for performance
@ 2025-08-04 12:39 Li Qiang
  2025-08-04 12:51 ` David Hildenbrand
  2025-08-04 13:29 ` Lorenzo Stoakes
  0 siblings, 2 replies; 15+ messages in thread
From: Li Qiang @ 2025-08-04 12:39 UTC (permalink / raw)
  To: akpm, david
  Cc: linux-mm, linux-kernel, lorenzo.stoakes, Liam.Howlett, vbabka,
	rppt, surenb, mhocko, Li Qiang

This change converts several critical page table zapping functions from
`inline` to `__always_inline`, resulting in measurable performance
improvements in process spawning workloads.

Performance Impact (Intel Xeon Gold 6430 2.1GHz):
- UnixBench 'context1' test shows ~6% improvement (single-core)
- UnixBench  shows ~0.6% improvement (single-core)
- mm/memory.o size reduced by 2.49% (70190 -> 68445 bytes)
- Net code reduction of 1745 bytes (add/remove: 211/166)

The modified functions form a hot path during process teardown:
1. zap_present_ptes()
2. do_zap_pte_range()
3. zap_pte_range()
4. zap_pmd_range()

Signed-off-by: Li Qiang <liqiang01@kylinos.cn>
---
 mm/memory.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/mm/memory.c b/mm/memory.c
index b0cda5aab398..281a353fae7b 100644
--- a/mm/memory.c
+++ b/mm/memory.c
@@ -1543,7 +1543,7 @@ static __always_inline void zap_present_folio_ptes(struct mmu_gather *tlb,
  *
  * Returns the number of processed (skipped or zapped) PTEs (at least 1).
  */
-static inline int zap_present_ptes(struct mmu_gather *tlb,
+static __always_inline int zap_present_ptes(struct mmu_gather *tlb,
 		struct vm_area_struct *vma, pte_t *pte, pte_t ptent,
 		unsigned int max_nr, unsigned long addr,
 		struct zap_details *details, int *rss, bool *force_flush,
@@ -1662,7 +1662,7 @@ static inline int zap_nonpresent_ptes(struct mmu_gather *tlb,
 	return nr;
 }
 
-static inline int do_zap_pte_range(struct mmu_gather *tlb,
+static __always_inline int do_zap_pte_range(struct mmu_gather *tlb,
 				   struct vm_area_struct *vma, pte_t *pte,
 				   unsigned long addr, unsigned long end,
 				   struct zap_details *details, int *rss,
@@ -1698,7 +1698,7 @@ static inline int do_zap_pte_range(struct mmu_gather *tlb,
 	return nr;
 }
 
-static unsigned long zap_pte_range(struct mmu_gather *tlb,
+static __always_inline unsigned long zap_pte_range(struct mmu_gather *tlb,
 				struct vm_area_struct *vma, pmd_t *pmd,
 				unsigned long addr, unsigned long end,
 				struct zap_details *details)
@@ -1790,7 +1790,7 @@ static unsigned long zap_pte_range(struct mmu_gather *tlb,
 	return addr;
 }
 
-static inline unsigned long zap_pmd_range(struct mmu_gather *tlb,
+static __always_inline unsigned long zap_pmd_range(struct mmu_gather *tlb,
 				struct vm_area_struct *vma, pud_t *pud,
 				unsigned long addr, unsigned long end,
 				struct zap_details *details)
@@ -1832,7 +1832,7 @@ static inline unsigned long zap_pmd_range(struct mmu_gather *tlb,
 	return addr;
 }
 
-static inline unsigned long zap_pud_range(struct mmu_gather *tlb,
+static __always_inline unsigned long zap_pud_range(struct mmu_gather *tlb,
 				struct vm_area_struct *vma, p4d_t *p4d,
 				unsigned long addr, unsigned long end,
 				struct zap_details *details)
@@ -1861,7 +1861,7 @@ static inline unsigned long zap_pud_range(struct mmu_gather *tlb,
 	return addr;
 }
 
-static inline unsigned long zap_p4d_range(struct mmu_gather *tlb,
+static __always_inline unsigned long zap_p4d_range(struct mmu_gather *tlb,
 				struct vm_area_struct *vma, pgd_t *pgd,
 				unsigned long addr, unsigned long end,
 				struct zap_details *details)
-- 
2.25.1



^ permalink raw reply	[flat|nested] 15+ messages in thread

end of thread, other threads:[~2025-08-07 10:25 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-08-04 12:39 [PATCH] mm: memory: Force-inline PTE/PMD zapping functions for performance Li Qiang
2025-08-04 12:51 ` David Hildenbrand
2025-08-04 13:01   ` Nadav Amit
2025-08-04 13:30     ` David Hildenbrand
2025-08-05 12:04       ` Li Qiang
2025-08-05 13:15         ` Vlastimil Babka
2025-08-06  5:40           ` [PATCH] mm: memory: Force-inline PTE/PMD zapping functions Li Qiang
2025-08-05 13:35         ` [PATCH] mm: memory: Force-inline PTE/PMD zapping functions for performance Lorenzo Stoakes
2025-08-06  5:51           ` Li Qiang
2025-08-07 10:25             ` Vlastimil Babka
2025-08-04 13:15   ` Vlastimil Babka
2025-08-04 13:29 ` Lorenzo Stoakes
2025-08-04 13:59   ` Lorenzo Stoakes
2025-08-04 14:41     ` Vlastimil Babka
2025-08-04 14:50     ` Nadav Amit

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox