Optimize S2 hugepage splitting, introduce skip-level flags
Get series with b4
b4 am [email protected]Versions newest first · linked by author and title
- v4 Latest posting 2/23 patches 8 repliesIn review
- v4 posting 1/23 patches 0 repliesSuperseded
- v33 patches 13 repliesSuperseded
Earlier versions · 2
| Version | Posted | Patches | Replies | Status |
|---|---|---|---|---|
| v2 | 3 patches | 1 reply | Superseded | |
| v1 | 2 patches | 2 replies | Superseded |
Changes in v4 from the cover letter
- Check if root level should be skipped,
- Improve commit messages (Marc)
- Improve skip_level documentation (Marc & Wei Lin)
- Improved skip_level code (Marc)
- Dropped skip_children explanation in the cover letter (Dev)
- Rebased on top of v7.3-rc5
v3 Link: https://lore.kernel.org/all/[email protected]/
Patches in v4 posting 2/2 No applies recorded yet
| # | Subject and files | Size | Replies | Applied |
|---|---|---|---|---|
| 1/3 | KVM: arm64: Avoid re-testing walk_continuearch/ | +2 | 2 replies | |
| 2/3 | KVM: arm64: Introduce KVM_PGTABLE_WALK_SKIP_LEVEL* walk flagsarch/ arch/ | +27 | 4 replies | |
| 3/3 | KVM: arm64: Make stage2_split_walker() skip unnecessary walksarch/ | +2 | 0 replies |
Reviews trailers per patch
1 of 3 patches has a Reviewed-by or Acked-by.
| Patch | Suzuki K Poulose |
|---|---|
| 1/3 | R-b |
| 2/3 | |
| 3/3 |
Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.
Cover letter [PATCH RESEND v4 0/3] Optimize S2 hugepage splitting, introduce skip-level flags
While playing with dirty-bit tracking, I decided to take a look on how page splitting works. Found out all entries are walked, even though we don't need to walk the level-3 entries, as they don't need to be split.
This patches' idea is to introduce new walking flags to skip pagetable levels 0-3.
Optimization measured on two scenarios involving eager-splitting on a VM with 32 memslot of 2GB (total 64GB), and vcpu per slot:
- Scenario 1: No manual protect, whole memslot split at dirty-track enable (KVM_SET_USER_MEMORY_REGION2 ioctl with KVM_MEM_LOG_DIRTY_PAGES)
- Split happens only once, whole region
- Evalutes improved batch performance of splitting
- Scenario 2: Manual protect, split happens during every dirty-bit clean (KVM_CLEAR_DIRTY_LOG ioctl), average for 2 iterations.
- Split called multiple times, for smaller 64-page sections.
- Evaluate improved performance for multiple calls
Scenario 1, improvement on dirty-track enable ioctl for the memslot:
- Memory was already split (4k pages): -47.82% runtime - THP backed memory: -27.50% runtime - 64x1GB hugetlb memory: -28.47% runtime
Scenario 2, improvement on dirty-log clean ioctl for the memslot:
- Memory was already split (4k pages): -44.72% runtime - THP backed memory: -29.80% runtime - 64x1GB hugetlb memory: -30.01% runtime
For collecting above numbers, the following script was ran in both vanilla and patched kernels, with kernel parameter 'default_hugepagesz=1G', on an TX2 with 128GB RAM.
--- dirty_test.sh
#!/bin/bash
filename=$(uname -r |cut -d'-' -f 4-)
run_test(){
base_test="./dirty_log_perf_test -b 2G -v 32 -m 6 -m 8"
# Manual cleaning disable
${base_test} -g
${base_test} -g -s anonymous_thp
echo 64 > /proc/sys/vm/nr_hugepages
${base_test} -g -s shared_hugetlb
echo 0 > /proc/sys/vm/nr_hugepages # Manual cleaning enable
${base_test}
${base_test} -s anonymous_thp
echo 64 > /proc/sys/vm/nr_hugepages
${base_test} -s shared_hugetlb
echo 0 > /proc/sys/vm/nr_hugepages
}
run_test 2>&1 | tee ${filename}
---
Above dirty_log_perf_test command is the standard kvm selftest found in the kernel tree. It tested the following guest modes:
Testing guest mode: PA-bits:40, VA-bits:48, 4K pages
Testing guest mode: PA-bits:40, VA-bits:48, 64K pages
(Modes with PA-bits:36 were discarted in this version, given the amount of RAM being used for testing, and the similarity of previous results)
Performance numbers from above modes were used to calculate average showed in the optimization improvements.
Changes since v3:
- Check if root level should be skipped,
- Improve commit messages (Marc)
- Improve skip_level documentation (Marc & Wei Lin)
- Improved skip_level code (Marc)
- Dropped skip_children explanation in the cover letter (Dev)
- Rebased on top of v7.3-rc5
v3 Link: https://lore.kernel.org/all/[email protected]/
Changes since v2:
- Rebased on top of v7.2-rc1
- Improved testing, added more memory, re-tested
- Now: 32 vcpus @ total of 64G
- Before: 1cpu @ 16G
v2 Link: https://lore.kernel.org/all/[email protected]/
Changes since v1:
- Fixed inverted flag verification priority (Sashiko)
- Fixed incorrectly skipping POST call if level was skipped (Sashiko), and to that
- New pre-patch that changes goto-out -> return to avoid re-testing walk_continue v1 Link: https://lore.kernel.org/lkml/[email protected]/
Changes since RFC:
- Changed approach from return value to walk flags (Will Deacon)
- Discarted skip_child approach (Oliver Upton)
- Measured in real hardware, and from userspace perspective (Marc Zyngier)
- Better explanation of what and how numbers were collected
RFC Link: https://lore.kernel.org/all/[email protected]/
Thanks!
Leo
Leonardo Bras (3):
KVM: arm64: Avoid re-testing walk_continue
KVM: arm64: Introduce KVM_PGTABLE_WALK_SKIP_LEVEL* walk flags
KVM: arm64: Make stage2_split_walker() skip unnecessary walks
arch/arm64/include/asm/kvm_pgtable.h | 14 ++++++++++++++ arch/arm64/kvm/hyp/pgtable.c | 25 ++++++++++++++++++------- 2 files changed, 32 insertions(+), 7 deletions(-)
base-commit: 72d3fcf802c45d00b300f25b848a93c3a2bd7c7e
Signature · 1 line
2.55.0