commit 3c6f33b7273a ("mm/ksm: support fork/exec for prctl") inherits MMF_VM_MERGE_ANY flag when a task calls execve(). Howerver, it doesn't create the mm_slot, so ksmd will not try to scan this task. The first patch fixes the issue. The second patch extend the selftests of ksm to verfity the deduplication really happens after fork/exec inherits ths KSM setting. Changelog since v1: - Add ksm cleanup in __bprm_mm_init() when error occurs. - Add some comment. - Extend the selftests of ksm fork/exec. Jinjiang Tu (2): mm/ksm: fix ksm exec support for prctl selftest/mm: ksm_functional_tests: extend test case for ksm fork/exec fs/exec.c | 10 +++ include/linux/ksm.h | 13 +++ .../selftests/mm/ksm_functional_tests.c | 79 +++++++++++++++++-- 3 files changed, 96 insertions(+), 6 deletions(-) -- 2.25.1