mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] mm: Inline vma_needs_copy
@ 2025-06-18  1:42 Yunshui Jiang
  2025-06-18  9:39 ` Vlastimil Babka
  2025-06-18 10:35 ` Lorenzo Stoakes
  0 siblings, 2 replies; 6+ messages in thread
From: Yunshui Jiang @ 2025-06-18  1:42 UTC (permalink / raw)
  To: linux-kernel, linux-mm
  Cc: akpm, david, lorenzo.stoakes, Liam.Howlett, vbabka, jiangyunshui

From: jiangyunshui <jiangyunshui@kylinos.cn>

Since commit bcd51a3c679d ("hugetlb: lazy page table copies
in fork()"), the logic about judging whether to copy
page table inside func copy_page_range has been extracted
into a separate func vma_needs_copy. While this change
improves code readability, it also incurs more function call
overhead, especially where fork() were frequently called.

Inline func vma_needs_copy to optimize the copy_page_range
performance. Given that func vma_needs_copy is only called
by copy_page_range, inlining it would not cause unacceptable
code bloat.

Testing was done with the byte-unixbench spawn benchmark
(which frequently calls fork). I measured 1.7% improvement
on x86 and 1.8% improvement on arm64.

Signed-off-by: jiangyunshui <jiangyunshui@kylinos.cn>
---
 mm/memory.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/mm/memory.c b/mm/memory.c
index 8eba595056fe..d15b07f96ab1 100644
--- a/mm/memory.c
+++ b/mm/memory.c
@@ -1337,7 +1337,7 @@ copy_p4d_range(struct vm_area_struct *dst_vma, struct vm_area_struct *src_vma,
  * false when we can speed up fork() by allowing lazy page faults later until
  * when the child accesses the memory range.
  */
-static bool
+static __always_inline bool
 vma_needs_copy(struct vm_area_struct *dst_vma, struct vm_area_struct *src_vma)
 {
 	/*
-- 
2.47.1


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

end of thread, other threads:[~2025-06-19  3:30 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-06-18  1:42 [PATCH] mm: Inline vma_needs_copy Yunshui Jiang
2025-06-18  9:39 ` Vlastimil Babka
2025-06-18 10:02   ` David Hildenbrand
2025-06-18 14:54     ` Liam R. Howlett
2025-06-19  3:30       ` Yunshui Jiang
2025-06-18 10:35 ` Lorenzo Stoakes

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

all inboxes | Powered by JetHome®