The patch titled Subject: mm/ksm: remove redundant code in ksm_fork has been added to the -mm mm-unstable branch. Its filename is mm-ksm-remove-redundant-code-in-ksm_fork.patch This patch will shortly appear at https://git.kernel.org/pub/scm/linux/kernel/git/akpm/25-new.git/tree/patches/mm-ksm-remove-redundant-code-in-ksm_fork.patch This patch will later appear in the mm-unstable branch at git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm Before you just go and hit "reply", please: a) Consider who else should be cc'ed b) Prefer to cc a suitable mailing list as well c) Ideally: find the original patch on the mailing list and do a reply-to-all to that, adding suitable additional cc's *** Remember to use Documentation/process/submit-checklist.rst when testing your code *** The -mm tree is included into linux-next via the mm-everything branch at git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm and is updated there every 2-3 working days ------------------------------------------------------ From: Jinjiang Tu <tujinjiang@xxxxxxxxxx> Subject: mm/ksm: remove redundant code in ksm_fork Date: Tue, 2 Apr 2024 10:49:34 +0800 Since commit 3c6f33b7273a ("mm/ksm: support fork/exec for prctl"), when a child process is forked, the MMF_VM_MERGE_ANY flag will be inherited in mm_init(). So, it's unnecessary to set the flag in ksm_fork(). Link: https://lkml.kernel.org/r/20240402024934.1093361-1-tujinjiang@xxxxxxxxxx Signed-off-by: Jinjiang Tu <tujinjiang@xxxxxxxxxx> Reviewed-by: David Hildenbrand <david@xxxxxxxxxx> Cc: Johannes Weiner <hannes@xxxxxxxxxxx> Cc: Kefeng Wang <wangkefeng.wang@xxxxxxxxxx> Cc: Nanyong Sun <sunnanyong@xxxxxxxxxx> Cc: Rik van Riel <riel@xxxxxxxxxxx> Cc: Stefan Roesch <shr@xxxxxxxxxxxx> Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> --- include/linux/ksm.h | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) --- a/include/linux/ksm.h~mm-ksm-remove-redundant-code-in-ksm_fork +++ a/include/linux/ksm.h @@ -45,16 +45,8 @@ static inline void ksm_might_unmap_zero_ static inline int ksm_fork(struct mm_struct *mm, struct mm_struct *oldmm) { - int ret; - - if (test_bit(MMF_VM_MERGEABLE, &oldmm->flags)) { - ret = __ksm_enter(mm); - if (ret) - return ret; - } - - if (test_bit(MMF_VM_MERGE_ANY, &oldmm->flags)) - set_bit(MMF_VM_MERGE_ANY, &mm->flags); + if (test_bit(MMF_VM_MERGEABLE, &oldmm->flags)) + return __ksm_enter(mm); return 0; } _ Patches currently in -mm which might be from tujinjiang@xxxxxxxxxx are mm-ksm-fix-ksm-exec-support-for-prctl.patch selftest-mm-ksm_functional_tests-refactor-mmap_and_merge_range.patch selftest-mm-ksm_functional_tests-extend-test-case-for-ksm-fork-exec.patch mm-ksm-remove-redundant-code-in-ksm_fork.patch