add mTHP support for wp
Quoted 34 lines
Hi all,
This patchset is introduced to make pagefault write-protect copy support mthp, with this series, pagefault write-protect copy will have a 9-14% performance improvement.
Currently pagefaults on anonymous pages support mthp [1], and hardware features (such as arm64 contpte) can be used to store multiple ptes in one TLB entry, reducing the probability of TLB misses. However, when the process is forked and the cow is triggered again, the above optimization effect is lost, and only 4KB is requested once at a time.
Therefore, make pagefault write-protect copy support mthp to maintain the optimization effect of TLB and improve the efficiency of cow pagefault.
vm-scalability usemem shows a great improvement, test using: usemem -n 32 --prealloc --prefault 249062617 (result unit is KB/s, bigger is better)
| size | w/o patch | w/ patch | delta | |-------------|-----------|-----------|---------| | baseline 4K | 723041.63 | 717643.21 | -0.75% | | mthp 16K | 732871.14 | 799513.18 | +9.09% | | mthp 32K | 746060.91 | 836261.83 | +12.09% | | mthp 64K | 747333.18 | 855570.43 | +14.48% |This series is based on Linux v6.16 (
038d61fd6422).Thanks,
Vernon[1] https://lore.kernel.org/all/20231207161211.2374093-1-
[email protected]/
Quoted 7 lines
Vernon Yang (7):
mm: memory: replace single-operation with multi-operation in wp
mm: memory: addptep_clear_flush_rangefunction
mm: memory: addkmsan_copy_pages_metafunction
mm: memory: add offset to start copy forcopy_user_gigantic_page
mm: memory: improvewp_page_copyreadability
mm: memory: add mTHP support for wp
Oh, we are also doing similar optimizations, but only for the code segment. :)
Quoted 16 lines
selftests: mm: support wp mTHP collapse testing
include/linux/huge_mm.h | 3 + include/linux/kmsan.h | 13 +- include/linux/mm.h | 8 + include/linux/pgtable.h | 3 + mm/hugetlb.c | 6 +- mm/kmsan/shadow.c | 26 +- mm/memory.c | 309 ++++++++++++++++++------ mm/pgtable-generic.c | 20 ++ tools/testing/selftests/mm/khugepaged.c | 5 +- 9 files changed, 302 insertions(+), 91 deletions(-)--
2.50.1
Quoted 46 lines · zhangqilong
Quoted 35 lines
Hi all,
This patchset is introduced to make pagefault write-protect copy support mthp, with this series, pagefault write-protect copy will have a 9-14% performance improvement.
Currently pagefaults on anonymous pages support mthp [1], and hardware features (such as arm64 contpte) can be used to store multiple ptes in one TLB entry, reducing the probability of TLB misses. However, when the process is forked and the cow is triggered again, the above optimization effect is lost, and only 4KB is requested once at a time.
Therefore, make pagefault write-protect copy support mthp to maintain the optimization effect of TLB and improve the efficiency of cow pagefault.
vm-scalability usemem shows a great improvement, test using: usemem -n 32 --prealloc --prefault 249062617 (result unit is KB/s, bigger is better)
| size | w/o patch | w/ patch | delta | |-------------|-----------|-----------|---------| | baseline 4K | 723041.63 | 717643.21 | -0.75% | | mthp 16K | 732871.14 | 799513.18 | +9.09% | | mthp 32K | 746060.91 | 836261.83 | +12.09% | | mthp 64K | 747333.18 | 855570.43 | +14.48% |This series is based on Linux v6.16 (
038d61fd6422).Thanks,
Vernon[1] https://lore.kernel.org/all/20231207161211.2374093-1-
[email protected]/Quoted 7 lines
Vernon Yang (7):
mm: memory: replace single-operation with multi-operation in wp
mm: memory: addptep_clear_flush_rangefunction
mm: memory: addkmsan_copy_pages_metafunction
mm: memory: add offset to start copy forcopy_user_gigantic_page
mm: memory: improvewp_page_copyreadability
mm: memory: add mTHP support for wp
Quoted 1 line
Oh, we are also doing similar optimizations, but only for the code segment. :)
Good! You use a similar optimizations in your code segment, which mthp size do you use?
Quoted 16 lines
Quoted 16 lines
selftests: mm: support wp mTHP collapse testing
include/linux/huge_mm.h | 3 + include/linux/kmsan.h | 13 +- include/linux/mm.h | 8 + include/linux/pgtable.h | 3 + mm/hugetlb.c | 6 +- mm/kmsan/shadow.c | 26 +- mm/memory.c | 309 ++++++++++++++++++------ mm/pgtable-generic.c | 20 ++ tools/testing/selftests/mm/khugepaged.c | 5 +- 9 files changed, 302 insertions(+), 91 deletions(-)--
2.50.1