All of lore.kernel.org
 help / color / mirror / Atom feed
From: Shivam Kumar <shivam.kumar1@nutanix.com>
To: Yuan Yao <yuan.yao@linux.intel.com>
Cc: pbonzini@redhat.com, seanjc@google.com, maz@kernel.org,
	james.morse@arm.com, borntraeger@linux.ibm.com, david@redhat.com,
	aravind.retnakaran@nutanix.com, kvm@vger.kernel.org,
	Shaju Abraham <shaju.abraham@nutanix.com>,
	Manish Mishra <manish.mishra@nutanix.com>,
	Anurag Madnawat <anurag.madnawat@nutanix.com>
Subject: Re: [PATCH v8 2/3] KVM: x86: Dirty quota-based throttling of vcpus
Date: Sat, 4 Mar 2023 17:15:02 +0530	[thread overview]
Message-ID: <1e02dfcd-48e9-48b3-7a59-57ca541d0dcf@nutanix.com> (raw)
In-Reply-To: <20230228013131.o4xw3ikacrgyjc52@yy-desk-7060>



On 28/02/23 7:01 am, Yuan Yao wrote:
> On Sat, Feb 25, 2023 at 08:47:59PM +0000, Shivam Kumar wrote:
>> Call update_dirty_quota whenever a page is marked dirty with
>> appropriate arch-specific page size. Process the KVM request
>> KVM_REQ_DIRTY_QUOTA_EXIT (raised by update_dirty_quota) to exit to
>> userspace with exit reason KVM_EXIT_DIRTY_QUOTA_EXHAUSTED.
>>
>> Suggested-by: Shaju Abraham <shaju.abraham@nutanix.com>
>> Suggested-by: Manish Mishra <manish.mishra@nutanix.com>
>> Co-developed-by: Anurag Madnawat <anurag.madnawat@nutanix.com>
>> Signed-off-by: Anurag Madnawat <anurag.madnawat@nutanix.com>
>> Signed-off-by: Shivam Kumar <shivam.kumar1@nutanix.com>
>> ---
>>   arch/x86/kvm/Kconfig       |  1 +
>>   arch/x86/kvm/mmu/mmu.c     |  8 +++++++-
>>   arch/x86/kvm/mmu/spte.c    |  3 +++
>>   arch/x86/kvm/mmu/tdp_mmu.c |  3 +++
>>   arch/x86/kvm/vmx/vmx.c     |  5 +++++
>>   arch/x86/kvm/x86.c         | 16 ++++++++++++++++
>>   arch/x86/kvm/xen.c         | 12 +++++++++++-
>>   7 files changed, 46 insertions(+), 2 deletions(-)
>>
>> diff --git a/arch/x86/kvm/Kconfig b/arch/x86/kvm/Kconfig
>> index 8e578311ca9d..8621a9512572 100644
>> --- a/arch/x86/kvm/Kconfig
>> +++ b/arch/x86/kvm/Kconfig
>> @@ -48,6 +48,7 @@ config KVM
>>   	select KVM_VFIO
>>   	select SRCU
>>   	select INTERVAL_TREE
>> +	select HAVE_KVM_DIRTY_QUOTA
>>   	select HAVE_KVM_PM_NOTIFIER if PM
>>   	select KVM_GENERIC_HARDWARE_ENABLING
>>   	help
>> diff --git a/arch/x86/kvm/mmu/mmu.c b/arch/x86/kvm/mmu/mmu.c
>> index c8ebe542c565..e0c8348ecdf1 100644
>> --- a/arch/x86/kvm/mmu/mmu.c
>> +++ b/arch/x86/kvm/mmu/mmu.c
>> @@ -3323,8 +3323,14 @@ fast_pf_fix_direct_spte(struct kvm_vcpu *vcpu, struct kvm_page_fault *fault,
>>   	if (!try_cmpxchg64(sptep, &old_spte, new_spte))
>>   		return false;
>>
>> -	if (is_writable_pte(new_spte) && !is_writable_pte(old_spte))
>> +	if (is_writable_pte(new_spte) && !is_writable_pte(old_spte)) {
>> +#ifdef CONFIG_HAVE_KVM_DIRTY_QUOTA
>> +		struct kvm_mmu_page *sp = sptep_to_sp(sptep);
>> +
>> +		update_dirty_quota(vcpu->kvm, (1L << SPTE_LEVEL_SHIFT(sp->role.level)));
>> +#endif
>>   		mark_page_dirty_in_slot(vcpu->kvm, fault->slot, fault->gfn);
> 
> Possible to call update_dirty_quota() from mark_page_dirty_in_slot() ?
> Then other Architectures can be covered yet.

As Marc commented on the first patch of this patchset, 
mark_page_dirty_in_slot can be called multiple times for the same page, 
e.g. in the case of PML for nested guests. If bitmap-based dirty 
tracking is not enabled, we might not be able to handle those cases 
without adding an extra param (which can tell us whether a dirty quota 
update is required or not) in mark_page_dirty_in_slot. Thanks.

Thanks,
Shivam

  reply	other threads:[~2023-03-04 11:47 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-02-25 20:47 [PATCH v8 0/3] KVM: Dirty quota-based throttling Shivam Kumar
2023-02-25 20:47 ` [PATCH v8 1/3] KVM: Implement dirty quota-based throttling of vcpus Shivam Kumar
2023-02-25 22:08   ` kernel test robot
2023-02-25 22:28   ` kernel test robot
2023-02-26  0:11   ` kernel test robot
2023-02-27  1:49   ` Marc Zyngier
2023-03-04  9:58     ` Shivam Kumar
2023-02-25 20:47 ` [PATCH v8 2/3] KVM: x86: Dirty " Shivam Kumar
2023-02-28  1:31   ` Yuan Yao
2023-03-04 11:45     ` Shivam Kumar [this message]
2023-02-25 20:48 ` [PATCH v8 3/3] KVM: arm64: " Shivam Kumar
2023-02-27  1:49   ` Marc Zyngier
2023-03-04 11:37     ` Shivam Kumar

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=1e02dfcd-48e9-48b3-7a59-57ca541d0dcf@nutanix.com \
    --to=shivam.kumar1@nutanix.com \
    --cc=anurag.madnawat@nutanix.com \
    --cc=aravind.retnakaran@nutanix.com \
    --cc=borntraeger@linux.ibm.com \
    --cc=david@redhat.com \
    --cc=james.morse@arm.com \
    --cc=kvm@vger.kernel.org \
    --cc=manish.mishra@nutanix.com \
    --cc=maz@kernel.org \
    --cc=pbonzini@redhat.com \
    --cc=seanjc@google.com \
    --cc=shaju.abraham@nutanix.com \
    --cc=yuan.yao@linux.intel.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.