On Tue, 2 Apr 2024 10:49:34 +0800 Jinjiang Tu <tujinjiang@xxxxxxxxxx> wrote: > 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(). > > ... > > --- a/include/linux/ksm.h > +++ b/include/linux/ksm.h > @@ -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; Thanks, I shall queue this up for testing and shall await review input from Stefan and hopefully others.