public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] mm/mmap: move vma operations to mm_struct out of the critical section of file mapping lock
@ 2023-06-06 12:49 Yu Ma
  2023-06-06 19:20 ` Liam R. Howlett
  0 siblings, 1 reply; 15+ messages in thread
From: Yu Ma @ 2023-06-06 12:49 UTC (permalink / raw)
  To: akpm, tim.c.chen
  Cc: linux-mm, linux-kernel, dave.hansen, dan.j.williams, shakeelb,
	Liam.Howlett, pan.deng, tianyou.li, lipeng.zhu, tim.c.chen, yu.ma

UnixBench/Execl represents a class of workload where bash scripts are
spawned frequently to do some short jobs. When running multiple parallel
tasks, hot osq_lock is observed from do_mmap and exit_mmap. Both of them
come from load_elf_binary through the call chain
"execl->do_execveat_common->bprm_execve->load_elf_binary". In do_mmap,it will
call mmap_region to create vma node, initialize it and insert it to vma
maintain structure in mm_struct and i_mmap tree of the mapping file, then
increase map_count to record the number of vma nodes used. The hot osq_lock
is to protect operations on file’s i_mmap tree. For the mm_struct member
change like vma insertion and map_count update, they do not affect i_mmap
tree. Move those operations out of the lock's critical section, to reduce
hold time on the lock.

With this change, on Intel Sapphire Rapids 112C/224T platform, based on
v6.0-rc6, the 160 parallel score improves by 12%. The patch has no
obvious performance gain on v6.4-rc4 due to regression of this benchmark
from this commit f1a7941243c102a44e8847e3b94ff4ff3ec56f25 (mm: convert 
mm's rss stats into percpu_counter). Related discussion and conclusion
can be referred at the mail thread initiated by 0day as below:
Link: https://lore.kernel.org/linux-mm/a4aa2e13-7187-600b-c628-7e8fb108def0@intel.com/

Reviewed-by: Tim Chen <tim.c.chen@linux.intel.com>
Signed-off-by: Yu Ma <yu.ma@intel.com>
---
 mm/mmap.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/mm/mmap.c b/mm/mmap.c
index 13678edaa22c..0e694a0433bc 100644
--- a/mm/mmap.c
+++ b/mm/mmap.c
@@ -2711,12 +2711,10 @@ unsigned long mmap_region(struct file *file, unsigned long addr,
 	if (vma_iter_prealloc(&vmi))
 		goto close_and_free_vma;
 
-	if (vma->vm_file)
-		i_mmap_lock_write(vma->vm_file->f_mapping);
-
 	vma_iter_store(&vmi, vma);
 	mm->map_count++;
 	if (vma->vm_file) {
+		i_mmap_lock_write(vma->vm_file->f_mapping);
 		if (vma->vm_flags & VM_SHARED)
 			mapping_allow_writable(vma->vm_file->f_mapping);
 
-- 
2.39.3


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

end of thread, other threads:[~2023-07-12 14:30 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-06-06 12:49 [PATCH] mm/mmap: move vma operations to mm_struct out of the critical section of file mapping lock Yu Ma
2023-06-06 19:20 ` Liam R. Howlett
2023-06-06 19:54   ` Liam R. Howlett
2023-06-07 13:09     ` Ma, Yu
2023-06-21 14:20     ` Ma, Yu
2023-07-05 16:54   ` Kirill A. Shutemov
2023-07-05 17:33     ` Liam R. Howlett
2023-07-05 19:06       ` Kirill A. Shutemov
2023-07-06 15:15         ` [PATCH] mm/mmap: move vmKirill A. Shutemov <kirill@shutemov.name>a " Ma, Yu
2023-07-11 17:20           ` [PATCH v2] mm/mmap: move vma " Yu Ma
2023-07-11 18:28             ` Andrew Morton
2023-07-12  0:15               ` Ma, Yu
2023-07-12 14:57               ` [PATCH v3] " Yu Ma
2023-07-06 22:04         ` [PATCH] " Suren Baghdasaryan
2023-07-07  4:40           ` Suren Baghdasaryan

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