mm/ksm: remove redundant code in ksm_fork
authorJinjiang Tu <tujinjiang@huawei.com>
Tue, 2 Apr 2024 02:49:34 +0000 (10:49 +0800)
committerAndrew Morton <akpm@linux-foundation.org>
Fri, 26 Apr 2024 03:56:41 +0000 (20:56 -0700)
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@huawei.com
Signed-off-by: Jinjiang Tu <tujinjiang@huawei.com>
Reviewed-by: David Hildenbrand <david@redhat.com>
Cc: Johannes Weiner <hannes@cmpxchg.org>
Cc: Kefeng Wang <wangkefeng.wang@huawei.com>
Cc: Nanyong Sun <sunnanyong@huawei.com>
Cc: Rik van Riel <riel@surriel.com>
Cc: Stefan Roesch <shr@devkernel.io>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
include/linux/ksm.h

index 7e2b1de3996ac24fd82948e12ccf6a3d96e5923a..358803cfd4d5eb9fca866e57d1ce95e99c212e7b 100644 (file)
@@ -45,16 +45,8 @@ static inline void ksm_might_unmap_zero_page(struct mm_struct *mm, pte_t pte)
 
 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;
 }