On Tue, Apr 20, 2021 at 12:49 AM Keqian Zhu wrote:
>
> Hi Ben,
>
> On 2021/4/20 3:20, Ben Gardon wrote:
> > On Fri, Apr 16, 2021 at 1:25 AM Keqian Zhu wrote:
> >>
> >> Currently during start dirty logging, if we're with init-all-set,
> >>
On Thu, Feb 11, 2021 at 7:58 AM Sean Christopherson wrote:
>
> On Thu, Feb 11, 2021, Paolo Bonzini wrote:
> > On 11/02/21 02:56, Sean Christopherson wrote:
> > > > > + pta->gpa = (vm_get_max_gfn(vm) - guest_num_pages) *
> > > > > pta->guest_page_size;
> > > > > + pta->gpa &= ~(pta->ho
ment to verify that.
>
> Cheers,
> Longman
>
Thanks Longman and Guenter for developing and testing this fix! I
don't have the environment to test this either, but the patch looks
good to me.
Reviewed-by: Ben Gardon
; to ensure gpa alignment for hugepages.
>
> No functional change intended.
>
> Signed-off-by: Sean Christopherson
Reviewed-by: Ben Gardon
> ---
> tools/testing/selftests/kvm/include/kvm_util.h | 15 +++
> tools/testing/selftests/kvm/lib/kvm_util.c | 1
On Wed, Feb 10, 2021 at 3:06 PM Sean Christopherson wrote:
>
> Explicitly state the indices when populating vm_guest_mode_params to
> make it marginally easier to visualize what's going on.
>
> No functional change intended.
>
> Signed-off-by: Sean Christopherson
On Wed, Feb 10, 2021 at 3:06 PM Sean Christopherson wrote:
>
> Align the HVA for HugeTLB memslots, not just THP memslots. Add an
> assert so any future backing types are forced to assess whether or not
> they need to be aligned.
>
> Cc: Ben Gardon
> Cc: Yanan Wang
>
> hugepages when dirty logging is activated is otherwise not exercised.
>
> Add a comment explaining that guest_page_size is for non-huge pages to
> try and avoid confusion about what it actually tracks.
>
> Cc: Ben Gardon
> Cc: Yanan Wang
> Cc: Andrew Jones
> Cc:
On Wed, Feb 10, 2021 at 3:06 PM Sean Christopherson wrote:
>
> Use 'pta' as a local pointer to the global perf_tests_args in order to
> shorten line lengths and make the code borderline readable.
>
> No functional change intended.
>
> Signed-off-by: Sean Christoph
>
> No functional change intended.
>
> Signed-off-by: Sean Christopherson
Reviewed-by: Ben Gardon
> ---
> .../selftests/kvm/include/perf_test_util.h| 8 +-
> .../selftests/kvm/lib/perf_test_util.c| 28 ---
> .../kvm/memslot_modificatio
On Wed, Feb 10, 2021 at 3:06 PM Sean Christopherson wrote:
>
> Capture the per-vCPU GPA in perf_test_vcpu_args so that tests can get
> the GPA without having to calculate the GPA on their own.
>
> No functional change intended.
>
> Signed-off-by: Sean Christopherson
Re
t clear
> that the test's calculations are guaranteed to yield the same value as
> perf_util, e.g. if guest_percpu_mem_size != vcpu_args->pages.
>
> Signed-off-by: Sean Christopherson
Reviewed-by: Ben Gardon
> ---
> .../selftests/kvm/demand_paging_test.c| 20 +--
,
> e.g. that the logic is unchanged if hugepages are in play.
>
> No functional change intended.
>
> Signed-off-by: Sean Christopherson
Reviewed-by: Ben Gardon
> ---
> tools/testing/selftests/kvm/demand_paging_test.c | 8
> tools/testing/selfte
rson
Reviewed-by: Ben Gardon
> ---
> tools/testing/selftests/kvm/lib/perf_test_util.c | 9 ++---
> 1 file changed, 6 insertions(+), 3 deletions(-)
>
> diff --git a/tools/testing/selftests/kvm/lib/perf_test_util.c
> b/tools/testing/selftests/kvm/lib/perf_test_util.c
>
the TDP MMU is disabled
- Merged RCU commits
- Extended additional MMU operations to operate in parallel
- Ammended dirty log perf test to cover newly parallelized code paths
- Misc refactorings (see changelogs for individual commits)
- Big thanks to Sean and Paolo for their thorough review of
-by: Paolo Bonzini
Signed-off-by: Ben Gardon
---
arch/x86/kvm/mmu/tdp_mmu.c | 16
1 file changed, 16 insertions(+)
diff --git a/arch/x86/kvm/mmu/tdp_mmu.c b/arch/x86/kvm/mmu/tdp_mmu.c
index e9f9ff81a38e..3d8cca238eba 100644
--- a/arch/x86/kvm/mmu/tdp_mmu.c
+++ b/arch/x86/kvm/mmu
Add lockdep to __tdp_mmu_set_spte to ensure that SPTEs are only modified
under the MMU lock.
No functional change intended.
Reviewed-by: Peter Feiner
Reviewed-by: Sean Christopherson
Acked-by: Paolo Bonzini
Signed-off-by: Ben Gardon
---
arch/x86/kvm/mmu/tdp_mmu.c | 2 ++
1 file changed, 2
semantics as cond_resched: true if the thread yielded,
false if it did not. If the function yielded in the _flush_ version,
then the TLBs will have been flushed.
Reviewed-by: Peter Feiner
Acked-by: Paolo Bonzini
Signed-off-by: Ben Gardon
---
arch/x86/kvm/mmu/tdp_mmu.c | 39
The KVM MMU caches already guarantee that shadow page table memory will
be zeroed, so there is no reason to re-zero the page in the TDP MMU page
fault handler.
No functional change intended.
Reviewed-by: Peter Feiner
Reviewed-by: Sean Christopherson
Acked-by: Paolo Bonzini
Signed-off-by: Ben
Acked-by: Paolo Bonzini
Signed-off-by: Ben Gardon
---
include/asm-generic/qrwlock.h | 24 ++--
include/linux/rwlock.h| 7 +++
2 files changed, 25 insertions(+), 6 deletions(-)
diff --git a/include/asm-generic/qrwlock.h b/include/asm-generic/qrwlock.h
index
Acked-by: Waiman Long
Acked-by: Paolo Bonzini
Signed-off-by: Ben Gardon
---
include/linux/sched.h | 17 +
1 file changed, 17 insertions(+)
diff --git a/include/linux/sched.h b/include/linux/sched.h
index 6e3a5eeec509..5d1378e5a040 100644
--- a/include/linux/sched.h
+++ b/include
yielding only happens after an SPTE is modified.
Fix this issue by moving the yield to the beginning of the loop.
Fixes: a6a0b05da9f3 ("kvm: x86/mmu: Support dirty logging for the TDP MMU")
Reviewed-by: Peter Feiner
Signed-off-by: Ben Gardon
---
v1 -> v2
- Split patch into three
arc
The goal_gfn field in tdp_iter can be misleading as it implies that it
is the iterator's final goal. It is really a taget for the lowest gfn
mapped by the leaf level SPTE the iterator will traverse towards. Change
the field's name to be more precise.
Signed-off-by: Ben Gardon
---
ar
Signed-off-by: Ben Gardon
---
v1 -> v2
- Replaced "disconnected" with "removed" updated derivative
comments and code
arch/x86/kvm/mmu/tdp_mmu.c | 71 ++
1 file changed, 42 insertions(+), 29 deletions(-)
diff --git a/arch/x86/kvm/mmu/t
Skip setting SPTEs if no change is expected.
Reviewed-by: Peter Feiner
Signed-off-by: Ben Gardon
---
v1 -> v2
- Merged no-op checks into exiting old_spte check
arch/x86/kvm/mmu/tdp_mmu.c | 6 --
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/arch/x86/kvm/mmu/tdp_mmu.
Move the work of adding and removing TDP MMU pages to/from "secondary"
data structures to helper functions. These functions will be built on in
future commits to enable MMU operations to proceed (mostly) in parallel.
No functional change expected.
Signed-off-by: Ben Gardon
---
ar
d-by: Sean Christopherson
Signed-off-by: Ben Gardon
---
arch/x86/kvm/mmu/tdp_mmu.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/arch/x86/kvm/mmu/tdp_mmu.c b/arch/x86/kvm/mmu/tdp_mmu.c
index aeb05f626b55..a75e92164a8b 100644
--- a/arch/x86/kvm/mmu/tdp_mmu.c
+++ b/arch/x
already acquired a pointer to that memory and installs a mapping in
an already cleared entry. This can lead to memory leaks and accounting
errors.
Reviewed-by: Peter Feiner
Signed-off-by: Ben Gardon
---
arch/x86/kvm/mmu/tdp_mmu.c | 36 ++--
1 file changed, 30
To reduce lock contention and interference with page fault handlers,
allow the TDP MMU function to zap a GFN range to operate under the MMU
read lock.
Signed-off-by: Ben Gardon
---
arch/x86/kvm/mmu/mmu.c | 13 ++-
arch/x86/kvm/mmu/mmu_internal.h | 6 +-
arch/x86/kvm/mmu/tdp_mmu.c
To reduce lock contention and interference with page fault handlers,
allow the TDP MMU functions which enable and disable dirty logging
to operate under the MMU read lock.
Extend dirty logging enable disable functions read lock-ness
Signed-off-by: Ben Gardon
---
arch/x86/kvm/mmu/mmu.c
Make the last few changes necessary to enable the TDP MMU to handle page
faults in parallel while holding the mmu_lock in read mode.
Reviewed-by: Peter Feiner
Signed-off-by: Ben Gardon
---
arch/x86/kvm/mmu/mmu.c | 12 ++--
1 file changed, 10 insertions(+), 2 deletions(-)
diff --git a
To speed the process of disabling dirty logging, change the TDP MMU
function which zaps collapsible SPTEs to run under the MMU read lock.
Signed-off-by: Ben Gardon
---
arch/x86/kvm/mmu/mmu.c | 5 ++---
arch/x86/kvm/mmu/tdp_mmu.c | 22 +++---
2 files changed, 17 insertions
Add a parameter to control the backing memory type for
dirty_log_perf_test so that the test can be run with hugepages.
To: linux-kselft...@vger.kernel.org
CC: Peter Xu
CC: Andrew Jones
CC: Thomas Huth
Signed-off-by: Ben Gardon
---
.../selftests/kvm/demand_paging_test.c| 3
: Andrew Jones
CC: Thomas Huth
Signed-off-by: Ben Gardon
---
tools/testing/selftests/kvm/dirty_log_perf_test.c | 10 +-
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/tools/testing/selftests/kvm/dirty_log_perf_test.c
b/tools/testing/selftests/kvm/dirty_log_perf_test.c
are flushed properly before other threads are allowed to
install any present value for the SPTE.
Reviewed-by: Peter Feiner
Signed-off-by: Ben Gardon
---
v1 -> v2
- Renamed "FROZEN_SPTE" to "REMOVED_SPTE" and updated derivative
comments and code
arch/x86
To prepare for handling page faults in parallel, change the TDP MMU
page fault handler to use atomic operations to set SPTEs so that changes
are not lost if multiple threads attempt to modify the same SPTE.
Reviewed-by: Peter Feiner
Signed-off-by: Ben Gardon
---
v1 -> v2
- Rename "ato
Add a read / write lock to be used in place of the MMU spinlock on x86.
The rwlock will enable the TDP MMU to handle page faults, and other
operations in parallel in future commits.
Reviewed-by: Peter Feiner
Signed-off-by: Ben Gardon
---
v1 -> v2
- Removed MMU lock wrappers
- Complet
MIO in the TDP MMU")
Reviewed-by: Peter Feiner
Suggested-by: Sean Christopherson
Signed-off-by: Ben Gardon
---
v1 -> v2
- Moved RCU read unlock before the TLB flush
- Merged the RCU commits from v1 into a single commit
- Changed the way accesses to page table memory are annotated wit
quot;)
Reviewed-by: Peter Feiner
Signed-off-by: Ben Gardon
---
v1 -> v2
- Moved forward progress check into tdp_mmu_iter_cond_resched
- Folded tdp_iter_refresh_walk into tdp_mmu_iter_cond_resched
- Split patch into three and renamed all
arch/x86/kvm/mmu/tdp_iter.c | 18 +-
The flushing and non-flushing variants of tdp_mmu_iter_cond_resched have
almost identical implementations. Merge the two functions and add a
flush parameter.
Signed-off-by: Ben Gardon
---
arch/x86/kvm/mmu/tdp_mmu.c | 42 --
1 file changed, 13 insertions
Signed-off-by: Ben Gardon
---
arch/x86/kvm/mmu/tdp_mmu.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/arch/x86/kvm/mmu/tdp_mmu.c b/arch/x86/kvm/mmu/tdp_mmu.c
index c3075fb568eb..e3066d08c1dc 100644
--- a/arch/x86/kvm/mmu/tdp_mmu.c
+++ b/arch/x86/kvm/mmu/tdp_mmu.c
No functional change intended.
Fixes: 29cf0f5007a2 ("kvm: x86/mmu: NX largepage recovery for TDP MMU")
Signed-off-by: Ben Gardon
---
arch/x86/kvm/mmu/mmu.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/arch/x86/kvm/mmu/mmu.c b/arch/x86/kvm/mmu/mmu.c
index 6d
Signed-off-by: Ben Gardon
---
include/linux/sched.h | 12
kernel/sched/core.c | 40
2 files changed, 52 insertions(+)
diff --git a/include/linux/sched.h b/include/linux/sched.h
index 5d1378e5a040..3052d16da3cf 100644
--- a/include/linux
On Wed, Feb 3, 2021 at 4:40 AM Paolo Bonzini wrote:
>
> On 02/02/21 19:57, Ben Gardon wrote:
> >
> > - write_lock(&vcpu->kvm->mmu_lock);
> > +
> > + if (is_tdp_mmu_root(vcpu->kvm, vcpu->arch.mmu->root_hpa))
> > +
On Wed, Feb 3, 2021 at 3:26 AM Paolo Bonzini wrote:
>
> On 02/02/21 19:57, Ben Gardon wrote:
> > +#ifdef CONFIG_LOCKDEP
> > + if (shared)
> > + lockdep_assert_held_read(&kvm->mmu_lock);
> > + else
> > + lockdep_ass
On Wed, Feb 3, 2021 at 3:34 AM Paolo Bonzini wrote:
>
> On 02/02/21 19:57, Ben Gardon wrote:
> > @@ -1485,7 +1489,9 @@ void kvm_tdp_mmu_zap_collapsible_sptes(struct kvm
> > *kvm,
> > struct kvm_mmu_page *root;
> > int root_as_id;
> >
> >
vmx_flush_pml_buffer repeatedly calls kvm_vcpu_mark_page_dirty, which
SRCU-derefrences kvm->memslots. In order to give the compiler more
freedom to optimize the function, SRCU-dereference the pointer
kvm->memslots only once.
Reviewed-by: Makarand Sonare
Signed-off-by: Ben Gardon
---
Tes
On Thu, Feb 4, 2021 at 2:51 PM Peter Xu wrote:
>
> Hi, Ben,
>
> On Thu, Feb 04, 2021 at 02:19:59PM -0800, Ben Gardon wrote:
> > The average time for each run demonstrated a strange bimodal distribution,
> > with clusters around 2 seconds and 2.5 seconds. This may have b
On Mon, Feb 8, 2021 at 1:08 AM Yanan Wang wrote:
>
> Add a macro to get string of the backing source memory type, so that
> application can add choices for source types in the help() function,
> and users can specify which type to use for testing.
Coincidentally, I sent out a change last week to
On Mon, Feb 8, 2021 at 1:08 AM Yanan Wang wrote:
>
> This test serves as a performance tester and a bug reproducer for
> kvm page table code (GPA->HPA mappings), so it gives guidance for
> people trying to make some improvement for kvm.
>
> The function guest_code() is designed to cover conditions
On Tue, Feb 9, 2021 at 3:21 AM wangyanan (Y) wrote:
>
>
> On 2021/2/9 2:13, Ben Gardon wrote:
> > On Mon, Feb 8, 2021 at 1:08 AM Yanan Wang wrote:
> >> Add a macro to get string of the backing source memory type, so that
> >> application can add choices for so
On Mon, Feb 8, 2021 at 11:22 PM wangyanan (Y) wrote:
>
> Hi Ben,
>
> On 2021/2/9 4:29, Ben Gardon wrote:
> > On Mon, Feb 8, 2021 at 1:08 AM Yanan Wang wrote:
> >> This test serves as a performance tester and a bug reproducer for
> >> kvm page table code (GPA-
On Tue, Feb 9, 2021 at 1:43 AM wangyanan (Y) wrote:
>
>
> On 2021/2/9 4:29, Ben Gardon wrote:
> > On Mon, Feb 8, 2021 at 1:08 AM Yanan Wang wrote:
> >> This test serves as a performance tester and a bug reproducer for
> >> kvm page table code (GPA->HPA
e can also
> read file /sys/kernel/mm/transparent_hugepage/hpage_pmd_size to get THP
> hugepage size.
>
> Signed-off-by: Yanan Wang
Reviewed-by: Ben Gardon
> ---
> .../testing/selftests/kvm/include/test_util.h | 2 ++
> tools/testing/selftests/kvm/lib/test_util.c | 36 +
On Wed, Feb 24, 2021 at 10:03 PM Yanan Wang wrote:
>
> With VM_MEM_SRC_ANONYMOUS_HUGETLB, we currently can only use system
> default hugetlb pages to back the testing guest memory. In order to
> add flexibility, now list all the known hugetlb backing src types with
> different page sizes, so that
On Wed, Feb 24, 2021 at 10:03 PM Yanan Wang wrote:
>
> With VM_MEM_SRC_ANONYMOUS_THP specified in vm_userspace_mem_region_add(),
> we have to get the transparent hugepage size for HVA alignment. With the
> new helpers, we can use get_backing_src_pagesz() to check whether THP is
> configured and th
On Wed, Feb 24, 2021 at 9:59 PM Yanan Wang wrote:
>
> Hi,
> This v2 series can mainly include two parts.
> Based on kvm queue branch:
> https://git.kernel.org/pub/scm/virt/kvm/kvm.git/log/?h=queue
> Links of v1:
> https://lore.kernel.org/lkml/20210208090841.333724-1-wangyana...@huawei.com/
>
> I
his doesn't provide the advertised performance benefits.
>
> Ben Gardon (1):
> KVM: x86/MMU: Recursively zap nested TDP SPs when zapping last/only
> parent
>
> Sean Christopherson (1):
> KVM: x86/mmu: Move flush logic from mmu_page_zap_pte() to
> FN
On Tue, Aug 4, 2020 at 2:14 PM Sean Christopherson
wrote:
>
> On Mon, Jul 27, 2020 at 01:33:24PM -0700, Ben Gardon wrote:
> > When the KVM MMU zaps a page, it will recursively zap the unsynced child
> > pages, but not the synced ones. This can create problems over time whe
On Wed, Aug 5, 2020 at 9:53 AM Yulei Zhang wrote:
>
> From: Yulei Zhang
>
> Currently in KVM memory virtulization we relay on mmu_lock to synchronize
> the memory mapping update, which make vCPUs work in serialize mode and
> slow down the execution, especially after migration to do substantial
>
+ no TDP MMU works
DBX + TDP MMU works
Cross-compilation was also checked for PowerPC and ARM64.
This series can be viewed in Gerrit at:
https://linux-review.googlesource.com/c/linux/kernel/git/torvalds/linux/+/7172
Ben Gardon (24):
locking/rwlocks: Add contention detection for rwlocks
sched:
Acked-by: Waiman Long
Acked-by: Paolo Bonzini
Signed-off-by: Ben Gardon
---
include/linux/sched.h | 17 +
1 file changed, 17 insertions(+)
diff --git a/include/linux/sched.h b/include/linux/sched.h
index 6e3a5eeec509..5d1378e5a040 100644
--- a/include/linux/sched.h
+++ b/include
only yielding if the loop has made forward
progress since the last yield.
Fixes: a6a0b05da9f3 ("kvm: x86/mmu: Support dirty logging for the TDP MMU")
Reviewed-by: Peter Feiner
Signed-off-by: Ben Gardon
---
arch/x86/kvm/mmu/tdp_mmu.c | 83 +++---
1 f
Signed-off-by: Ben Gardon
---
arch/x86/kvm/mmu/tdp_mmu.c | 16
1 file changed, 16 insertions(+)
diff --git a/arch/x86/kvm/mmu/tdp_mmu.c b/arch/x86/kvm/mmu/tdp_mmu.c
index 2650fa9fe066..b033da8243fc 100644
--- a/arch/x86/kvm/mmu/tdp_mmu.c
+++ b/arch/x86/kvm/mmu/tdp_mmu.c
@@ -357,6
The KVM MMU caches already guarantee that shadow page table memory will
be zeroed, so there is no reason to re-zero the page in the TDP MMU page
fault handler.
No functional change intended.
Reviewed-by: Peter Feiner
Signed-off-by: Ben Gardon
---
arch/x86/kvm/mmu/tdp_mmu.c | 1 -
1 file
semantics as cond_resched: true if the thread yielded,
false if it did not. If the function yielded in the _flush_ version,
then the TLBs will have been flushed.
Reviewed-by: Peter Feiner
Signed-off-by: Ben Gardon
---
arch/x86/kvm/mmu/tdp_mmu.c | 38 +-
1 file
Add lockdep to __tdp_mmu_set_spte to ensure that SPTEs are only modified
under the MMU lock. This lockdep will be updated in future commits to
reflect and validate changes to the TDP MMU's synchronization strategy.
No functional change intended.
Reviewed-by: Peter Feiner
Signed-off-by
other archs.
No functional change intended.
Signed-off-by: Peter Feiner
Signed-off-by: Ben Gardon
---
arch/arm64/kvm/mmu.c | 36 ++---
arch/mips/kvm/mips.c | 8 +--
arch/mips/kvm/mmu.c| 14 ++---
arch/powerpc/kvm
Move the mmu_lock to struct kvm_arch so that it can be replaced with a
rwlock on x86 without affecting the performance of other archs.
No functional change intended.
Reviewed-by: Peter Feiner
Signed-off-by: Ben Gardon
---
Documentation/virt/kvm/locking.rst | 2 +-
arch/arm64/include/asm
lock is still used as locking and unlocking a spin lock is
slightly faster.
Reviewed-by: Peter Feiner
Signed-off-by: Ben Gardon
---
arch/x86/include/asm/kvm_host.h | 8 ++-
arch/x86/kvm/mmu/mmu.c | 89 +
arch/x86/kvm/mmu/mmu_internal.h | 9
arch
Factor out the code to handle a disconnected subtree of the TDP paging
structure from the code to handle the change to an individual SPTE.
Future commits will build on this to allow asynchronous page freeing.
No functional change intended.
Reviewed-by: Peter Feiner
Signed-off-by: Ben Gardon
are flushed properly before other threads are allowed to
install any present value for the SPTE.
Reviewed-by: Peter Feiner
Signed-off-by: Ben Gardon
---
arch/x86/kvm/mmu/spte.h| 16 +-
arch/x86/kvm/mmu/tdp_mmu.c | 62 --
2 files changed, 68
Acked-by: Paolo Bonzini
Signed-off-by: Ben Gardon
---
include/asm-generic/qrwlock.h | 24 ++--
include/linux/rwlock.h| 7 +++
2 files changed, 25 insertions(+), 6 deletions(-)
diff --git a/include/asm-generic/qrwlock.h b/include/asm-generic/qrwlock.h
index
pages will cause some serialization, but only on
non-leaf page table entries, so the lock is not expected to be very
contended.
Reviewed-by: Peter Feiner
Signed-off-by: Ben Gardon
---
arch/x86/include/asm/kvm_host.h | 15
arch/x86/kvm/mmu/tdp_mmu.c | 67
By waiting until an RCU grace period has elapsed to free TDP MMU PT memory,
the system can ensure that no kernel threads access the memory after it
has been freed.
Reviewed-by: Peter Feiner
Signed-off-by: Ben Gardon
---
arch/x86/kvm/mmu/mmu_internal.h | 3 +++
arch/x86/kvm/mmu/tdp_mmu.c
Feiner
Signed-off-by: Ben Gardon
---
arch/arm64/kvm/mmu.c | 2 +-
arch/x86/kvm/mmu/mmu.c | 16
arch/x86/kvm/mmu/tdp_mmu.c | 8
include/linux/kvm_host.h | 2 ++
virt/kvm/kvm_main.c| 10 ++
5 files changed, 25 insertions(+), 13 deletions
Make the last few changes necessary to enable the TDP MMU to handle page
faults in parallel while holding the mmu_lock in read mode.
Reviewed-by: Peter Feiner
Signed-off-by: Ben Gardon
---
arch/x86/kvm/mmu/mmu.c | 12 ++--
1 file changed, 10 insertions(+), 2 deletions(-)
diff --git a
To prepare for handling page faults in parallel, change the TDP MMU
page fault handler to use atomic operations to set SPTEs so that changes
are not lost if multiple threads attempt to modify the same SPTE.
Reviewed-by: Peter Feiner
Signed-off-by: Ben Gardon
---
arch/x86/kvm/mmu/tdp_mmu.c
kvm_arch so that it can be replaced with an rwlock for
x86.
Reviewed-by: Peter Feiner
Signed-off-by: Ben Gardon
---
arch/arm64/kvm/mmu.c | 2 +-
arch/powerpc/include/asm/kvm_book3s_64.h | 7 +++
arch/powerpc/kvm/book3s_hv_nested.c | 3 +--
arch/x86/kvm/mmu
In order to protect TDP MMU PT memory with RCU, ensure that page table
links are properly rcu_derefenced.
Reviewed-by: Peter Feiner
Signed-off-by: Ben Gardon
---
arch/x86/kvm/mmu/tdp_iter.c | 6 +-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/arch/x86/kvm/mmu/tdp_iter.c b
already acquired a pointer to that memory and installs a mapping in
an already cleared entry. This can lead to memory leaks and accounting
errors.
Reviewed-by: Peter Feiner
Signed-off-by: Ben Gardon
---
arch/x86/kvm/mmu/tdp_mmu.c | 35 +--
1 file changed, 29
In order to allow multiple TDP MMU operations to proceed in parallel,
there must be an option to modify SPTEs atomically so that changes are
not lost. Add that option to __tdp_mmu_set_spte and
__handle_changed_spte.
Reviewed-by: Peter Feiner
Signed-off-by: Ben Gardon
---
arch/x86/kvm/mmu
.
Reviewed-by: Peter Feiner
Signed-off-by: Ben Gardon
---
arch/x86/kvm/mmu/tdp_mmu.c | 53 --
1 file changed, 51 insertions(+), 2 deletions(-)
diff --git a/arch/x86/kvm/mmu/tdp_mmu.c b/arch/x86/kvm/mmu/tdp_mmu.c
index e8f35cd46b4c..662907d374b3 100644
--- a/arch/x86
Signed-off-by: Ben Gardon
---
include/linux/sched.h | 12
kernel/sched/core.c | 40
2 files changed, 52 insertions(+)
diff --git a/include/linux/sched.h b/include/linux/sched.h
index 5d1378e5a040..3052d16da3cf 100644
--- a/include/linux
Skip setting SPTEs if no change is expected.
Reviewed-by: Peter Feiner
Signed-off-by: Ben Gardon
---
arch/x86/kvm/mmu/tdp_mmu.c | 6 ++
1 file changed, 6 insertions(+)
diff --git a/arch/x86/kvm/mmu/tdp_mmu.c b/arch/x86/kvm/mmu/tdp_mmu.c
index 1987da0da66e..2650fa9fe066 100644
--- a/arch
-by: Ben Gardon
---
tools/testing/selftests/kvm/dirty_log_perf_test.c | 9 -
1 file changed, 4 insertions(+), 5 deletions(-)
diff --git a/tools/testing/selftests/kvm/dirty_log_perf_test.c
b/tools/testing/selftests/kvm/dirty_log_perf_test.c
index 16efe6589b43..15a9c45bdb5f 100644
--- a
kernel.
Reviewed-by: Jacob Xu
Reviewed-by: Makarand Sonare
Signed-off-by: Ben Gardon
---
.../selftests/kvm/demand_paging_test.c| 32 +++
.../selftests/kvm/dirty_log_perf_test.c | 14 ++--
.../selftests/kvm/include/perf_test_util.h| 4 ++-
.../selftests/kvm
In response to some earlier comments from Peter Xu, rename
timespec_diff_now to the much more sensible timespec_elapsed.
No functional change intended.
Reviewed-by: Jacob Xu
Reviewed-by: Makarand Sonare
Signed-off-by: Ben Gardon
---
tools/testing/selftests/kvm/demand_paging_test.c | 8
. Adding and removing a memslot also has the effect of
tearing down the entire paging structure, which leads to more page
faults and pressure on the page fault handling path than a one-and-done
memory population test.
Reviewed-by: Jacob Xu
Signed-off-by: Ben Gardon
---
tools/testing/selftests/kvm
Currently the population stage in the dirty_log_perf_test does nothing
as the per-vCPU iteration counters are not initialized and the loop does
not wait for each vCPU. Remedy those errors.
Reviewed-by: Jacob Xu
Reviewed-by: Makarand Sonare
Signed-off-by: Ben Gardon
---
tools/testing
In order to add an iteration -1 to indicate that the memory population
phase has not yet completed, convert the interations counters to ints.
No functional change intended.
Reviewed-by: Jacob Xu
Signed-off-by: Ben Gardon
---
.../selftests/kvm/dirty_log_perf_test.c | 26
ource.com/c/linux/kernel/git/torvalds/linux/+/7216
Ben Gardon (6):
KVM: selftests: Rename timespec_diff_now to timespec_elapsed
KVM: selftests: Avoid flooding debug log while populating memory
KVM: selftests: Convert iterations to int in dirty_log_perf_test
KVM: selftests: Fix populati
break its loop
> before getting a chance to yield.
>
> But that is all very, very subtle, and will break at the slightest sneeze,
> e.g. zapping while holding mmu_lock for read would break as the TDP MMU
> wouldn't be guaranteed to see the present shadow page, and thus could step
to do the
> flush. If pages are zapped from the TDP MMU but not the legacy MMU, then
> no flush will occur.
>
> Fixes: 29cf0f5007a2 ("kvm: x86/mmu: NX largepage recovery for TDP MMU")
> Cc: sta...@vger.kernel.org
> Cc: Ben Gardon
> Signed-off-by: Sean Christopherson
25b3 ("KVM: x86/mmu: Yield in TDU MMU iter even if no SPTES
> changed")
> Cc: sta...@vger.kernel.org
> Cc: Ben Gardon
> Signed-off-by: Sean Christopherson
Reviewed-By: Ben Gardon
> ---
> arch/x86/kvm/mmu/tdp_mmu.c | 23 ---
> 1 file changed,
ond, tell the TDP MMU a flush is pending if the list of zapped pages
> from legacy MMUs is not empty, i.e. the legacy MMU needs a flush. This
> fixes the case where the TDP MMU yields, but it iteslf does not require a
> flush.
>
> Fixes: 29cf0f5007a2 ("kvm: x86/mmu: NX lar
On Mon, Mar 22, 2021 at 5:15 PM Sean Christopherson wrote:
>
> On Mon, Mar 22, 2021, Ben Gardon wrote:
> > On Fri, Mar 19, 2021 at 4:20 PM Sean Christopherson
> > wrote:
> > > @@ -5960,19 +5963,21 @@ static void kvm_recove
On Tue, Mar 23, 2021 at 11:58 AM Sean Christopherson wrote:
>
> On Tue, Mar 23, 2021, Ben Gardon wrote:
> > On Mon, Mar 22, 2021 at 5:15 PM Sean Christopherson
> > wrote:
> > >
> > > On Mon, Mar 22, 2021, Ben Gardon wrote:
> > > > It could be fi
On Thu, Mar 25, 2021 at 7:20 PM Sean Christopherson wrote:
>
> The end goal of this series is to optimize the MMU notifiers to take
> mmu_lock if and only if the notification is relevant to KVM, i.e. the hva
> range overlaps a memslot. Large VMs (hundreds of vCPUs) are very
> sensitive to mmu_lo
a
> bug where KVM would fail to free valid PAE roots if a one of the later
> roots failed to allocate.
>
> Note, KVM still leaks the PAE roots if the lm_root allocation fails.
> This will be addressed in a future commit.
>
> Cc: Ben Gardon
> Signed-off-by: Sean Christopher
tdp
> enabled")
> Fixes: b6b80c78af83 ("KVM: x86/mmu: Allocate PAE root array when using SVM's
> 32-bit NPT")
> Cc: sta...@vger.kernel.org
> Signed-off-by: Sean Christopherson
Reviewed-by: Ben Gardon
> ---
> arch/x86/kvm/mmu/mmu.c | 44 +
1 - 100 of 313 matches
Mail list logo