randprotect: mm: THP: preserved young bit in the THP split

page migration, in response to an AutoNUMA migrate-on-fault, should
keep the pgtable young to avoid slowing down the next memory access.

split_huge_page() or page migration for compaction or CMA are more
neutral cases: the migration entry swpentry format has to be extended
to retain also the young/old boolean information as it retains other
pgtable bits already. In the meantime, it's preferable to set the
young bit rather than to clear it, to avoid hurting performance post
migration or post physical THP split.

The below is a measurement of the time to read 10M of virtual memory
after physical THP splits as those triggered by KSM and the respective
number of dTLB misses as measured by perf.

before: Duration = 740µs - 44,219      dTLB-load-misses:u
after:  Duration =  23µs -  5,198      dTLB-load-misses:u

Cc: stable@kernel.org
Fixes: e9b61f19858a ("thp: reintroduce split_huge_page()")
Reported-by: Jonas Juffinger <jonas.juffinger@lamarr.at>
Signed-off-by: Andrea Arcangeli <aarcange@redhat.com>
2 files changed