Result of tools/testing/selftests/mm/cow.c tests: # [RUN] Basic COW after fork() when collapsing before fork() ok 145 No leak from parent into child # [RUN] Basic COW after fork() when collapsing after fork() (fully shared) ok 146 No leak from parent into child # [RUN] Basic COW after fork() when collapsing after fork() (lower shared) ok 147 No leak from parent into child # [RUN] Basic COW after fork() when collapsing after fork() (upper shared) ok 148 No leak from parent into child A long run (w/ CONFIG_DEBUG_VM enabled) shows no panic or memory leaks. Changes since v2: - Use folios in the new code, as suggested by David. - Handle folio refcount and rmap properly, as suggested by David. - minor modification includes 1) advance vma write lock, 2) remove redundant rollback logic, 3) clear old ptes in pgtable before deposit. Changes since v1: - Deal with PageAnonExclusive properly, as suggested by David. Xu Yu (2): mm/khugepaged: map RO non-exclusive pte-mapped anon THPs by pmds mm/khugepaged: map exclusive anonymous pte-mapped THPs by pmds mm/khugepaged.c | 229 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 229 insertions(+) -- 2.37.1