From: James Houghton <jthoughton@google.com>
To: Andrew Morton <akpm@linux-foundation.org>,
Paolo Bonzini <pbonzini@redhat.com>
Cc: Yu Zhao <yuzhao@google.com>, David Matlack <dmatlack@google.com>,
Marc Zyngier <maz@kernel.org>,
Oliver Upton <oliver.upton@linux.dev>,
Sean Christopherson <seanjc@google.com>,
Jonathan Corbet <corbet@lwn.net>,
James Morse <james.morse@arm.com>,
Suzuki K Poulose <suzuki.poulose@arm.com>,
Zenghui Yu <yuzenghui@huawei.com>,
Catalin Marinas <catalin.marinas@arm.com>,
Will Deacon <will@kernel.org>,
Thomas Gleixner <tglx@linutronix.de>,
Ingo Molnar <mingo@redhat.com>, Borislav Petkov <bp@alien8.de>,
Dave Hansen <dave.hansen@linux.intel.com>,
"H. Peter Anvin" <hpa@zytor.com>,
Steven Rostedt <rostedt@goodmis.org>,
Masami Hiramatsu <mhiramat@kernel.org>,
Mathieu Desnoyers <mathieu.desnoyers@efficios.com>,
Shaoqin Huang <shahuang@redhat.com>,
Gavin Shan <gshan@redhat.com>,
Ricardo Koller <ricarkol@google.com>,
Raghavendra Rao Ananta <rananta@google.com>,
Ryan Roberts <ryan.roberts@arm.com>,
David Rientjes <rientjes@google.com>,
Axel Rasmussen <axelrasmussen@google.com>,
linux-kernel@vger.kernel.org,
linux-arm-kernel@lists.infradead.org, kvmarm@lists.linux.dev,
kvm@vger.kernel.org, linux-mm@kvack.org,
linux-trace-kernel@vger.kernel.org,
James Houghton <jthoughton@google.com>
Subject: [PATCH v3 0/7] mm/kvm: Improve parallelism for access bit harvesting
Date: Mon, 1 Apr 2024 23:29:39 +0000 [thread overview]
Message-ID: <20240401232946.1837665-1-jthoughton@google.com> (raw)
This patchset adds a fast path in KVM to test and clear access bits on
sptes without taking the mmu_lock. It also adds support for using a
bitmap to (1) test the access bits for many sptes in a single call to
mmu_notifier_test_young, and to (2) clear the access bits for many ptes
in a single call to mmu_notifier_clear_young.
With Yu's permission, I'm now working on getting this series into a
mergeable state.
I'm posting this as an RFC because I'm not sure if the arm64 bits are
correct, and I haven't done complete performance testing. I want to do
broader experimentation to see how much this improves VM performance in
a cloud environment, but I want to be sure that the code is mergeable
first.
Yu has posted other performance results[1], [2]. This v3 shouldn't
significantly change the x86 results, but the arm64 results may have
changed.
The most important changes since v2[3]:
- Split the test_clear_young MMU notifier back into test_young and
clear_young. I did this because the bitmap passed in has a distinct
meaning for each of them, and I felt that this was cleaner.
- The return value of test_young / clear_young now indicates if the
bitmap was used.
- Removed the custom spte walker to implement the lockless path. This
was important for arm64 to be functionally correct (thanks Oliver),
and it avoids a lot of problems brought up in review of v2 (for
example[4]).
- Add kvm_arch_prepare_bitmap_age and kvm_arch_finish_bitmap_age to
allow for arm64 to implement its bitmap-based aging to grab the MMU
lock for reading while allowing x86 to be lockless.
- The powerpc changes have been dropped.
- The logic to inform architectures how to use the bitmap has been
cleaned up (kvm_should_clear_young has been split into
kvm_gfn_should_age and kvm_gfn_record_young) (thanks Nicolas).
There were some smaller changes too:
- Added test_clear_young_metadata (thanks Sean).
- MMU_NOTIFIER_RANGE_LOCKLESS has been renamed to
MMU_NOTIFIER_YOUNG_FAST, to indicate to the caller that passing a
bitmap for MGLRU look-around is likely to be beneficial.
- Cleaned up comments that describe the changes to
mmu_notifier_test_young / mmu_notifier_clear_young (thanks Nicolas).
[1]: https://lore.kernel.org/all/20230609005943.43041-1-yuzhao@google.com/
[2]: https://lore.kernel.org/all/20230609005935.42390-1-yuzhao@google.com/
[3]: https://lore.kernel.org/kvmarm/20230526234435.662652-1-yuzhao@google.com/
[4]: https://lore.kernel.org/all/ZItX64Bbx5vdjo9M@google.com/
James Houghton (5):
mm: Add a bitmap into mmu_notifier_{clear,test}_young
KVM: Move MMU notifier function declarations
KVM: Add basic bitmap support into kvm_mmu_notifier_test/clear_young
KVM: x86: Participate in bitmap-based PTE aging
KVM: arm64: Participate in bitmap-based PTE aging
Yu Zhao (2):
KVM: x86: Move tdp_mmu_enabled and shadow_accessed_mask
mm: multi-gen LRU: use mmu_notifier_test_clear_young()
Documentation/admin-guide/mm/multigen_lru.rst | 6 +-
arch/arm64/include/asm/kvm_host.h | 5 +
arch/arm64/include/asm/kvm_pgtable.h | 4 +-
arch/arm64/kvm/hyp/pgtable.c | 21 +-
arch/arm64/kvm/mmu.c | 23 ++-
arch/x86/include/asm/kvm_host.h | 20 ++
arch/x86/kvm/mmu.h | 6 -
arch/x86/kvm/mmu/mmu.c | 16 +-
arch/x86/kvm/mmu/spte.h | 1 -
arch/x86/kvm/mmu/tdp_mmu.c | 10 +-
include/linux/kvm_host.h | 101 ++++++++--
include/linux/mmu_notifier.h | 93 ++++++++-
include/linux/mmzone.h | 6 +-
include/trace/events/kvm.h | 13 +-
mm/mmu_notifier.c | 20 +-
mm/rmap.c | 9 +-
mm/vmscan.c | 183 ++++++++++++++----
virt/kvm/kvm_main.c | 100 +++++++---
18 files changed, 509 insertions(+), 128 deletions(-)
base-commit: 0cef2c0a2a356137b170c3cb46cb9c1dd2ca3e6b
--
2.44.0.478.gd926399ef9-goog
next reply other threads:[~2024-04-01 23:29 UTC|newest]
Thread overview: 32+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-04-01 23:29 James Houghton [this message]
2024-04-01 23:29 ` [PATCH v3 1/7] mm: Add a bitmap into mmu_notifier_{clear,test}_young James Houghton
2024-04-04 18:52 ` David Hildenbrand
2024-04-09 18:31 ` James Houghton
2024-04-09 19:35 ` David Hildenbrand
2024-04-11 0:35 ` James Houghton
2024-04-12 18:45 ` David Matlack
2024-04-19 20:34 ` James Houghton
2024-04-01 23:29 ` [PATCH v3 2/7] KVM: Move MMU notifier function declarations James Houghton
2024-04-01 23:29 ` [PATCH v3 3/7] KVM: Add basic bitmap support into kvm_mmu_notifier_test/clear_young James Houghton
2024-04-12 20:28 ` David Matlack
2024-04-19 20:41 ` James Houghton
2024-04-01 23:29 ` [PATCH v3 4/7] KVM: x86: Move tdp_mmu_enabled and shadow_accessed_mask James Houghton
2024-04-01 23:29 ` [PATCH v3 5/7] KVM: x86: Participate in bitmap-based PTE aging James Houghton
2024-04-11 17:08 ` David Matlack
2024-04-11 17:28 ` David Matlack
2024-04-11 18:00 ` David Matlack
2024-04-11 18:07 ` David Matlack
2024-04-19 20:47 ` James Houghton
2024-04-19 21:06 ` David Matlack
2024-04-19 21:48 ` James Houghton
2024-04-21 0:19 ` Yu Zhao
2024-04-12 20:44 ` David Matlack
2024-04-19 20:54 ` James Houghton
2024-04-01 23:29 ` [PATCH v3 6/7] KVM: arm64: " James Houghton
2024-04-02 4:06 ` Yu Zhao
2024-04-02 7:00 ` Oliver Upton
2024-04-02 7:33 ` Marc Zyngier
2024-04-01 23:29 ` [PATCH v3 7/7] mm: multi-gen LRU: use mmu_notifier_test_clear_young() James Houghton
2024-04-12 18:41 ` [PATCH v3 0/7] mm/kvm: Improve parallelism for access bit harvesting David Matlack
2024-04-19 20:57 ` James Houghton
2024-04-19 22:23 ` Oliver Upton
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240401232946.1837665-1-jthoughton@google.com \
--to=jthoughton@google.com \
--cc=akpm@linux-foundation.org \
--cc=axelrasmussen@google.com \
--cc=bp@alien8.de \
--cc=catalin.marinas@arm.com \
--cc=corbet@lwn.net \
--cc=dave.hansen@linux.intel.com \
--cc=dmatlack@google.com \
--cc=gshan@redhat.com \
--cc=hpa@zytor.com \
--cc=james.morse@arm.com \
--cc=kvm@vger.kernel.org \
--cc=kvmarm@lists.linux.dev \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=linux-trace-kernel@vger.kernel.org \
--cc=mathieu.desnoyers@efficios.com \
--cc=maz@kernel.org \
--cc=mhiramat@kernel.org \
--cc=mingo@redhat.com \
--cc=oliver.upton@linux.dev \
--cc=pbonzini@redhat.com \
--cc=rananta@google.com \
--cc=ricarkol@google.com \
--cc=rientjes@google.com \
--cc=rostedt@goodmis.org \
--cc=ryan.roberts@arm.com \
--cc=seanjc@google.com \
--cc=shahuang@redhat.com \
--cc=suzuki.poulose@arm.com \
--cc=tglx@linutronix.de \
--cc=will@kernel.org \
--cc=yuzenghui@huawei.com \
--cc=yuzhao@google.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).