Message ID | 20221113170507.208810-4-shivam.kumar1@nutanix.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | KVM: Dirty quota-based throttling | expand |
On Sun, Nov 13, 2022 at 05:05:10PM +0000, Shivam Kumar wrote: > Exit to userspace whenever the dirty quota is exhausted (i.e. dirty count > equals/exceeds dirty quota) to request more dirty quota. > > 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/arm64/kvm/arm.c | 9 +++++++++ > 1 file changed, 9 insertions(+) > > diff --git a/arch/arm64/kvm/arm.c b/arch/arm64/kvm/arm.c > index 94d33e296e10..850024982dd9 100644 > --- a/arch/arm64/kvm/arm.c > +++ b/arch/arm64/kvm/arm.c > @@ -746,6 +746,15 @@ static int check_vcpu_requests(struct kvm_vcpu *vcpu) > > if (kvm_check_request(KVM_REQ_SUSPEND, vcpu)) > return kvm_vcpu_suspend(vcpu); > + > + if (kvm_check_request(KVM_REQ_DIRTY_QUOTA_EXIT, vcpu)) { > + struct kvm_run *run = vcpu->run; > + > + run->exit_reason = KVM_EXIT_DIRTY_QUOTA_EXHAUSTED; > + run->dirty_quota_exit.count = vcpu->stat.generic.pages_dirtied; > + run->dirty_quota_exit.quota = vcpu->dirty_quota; > + return 0; > + } There is a recheck on x86 side, but not here. Any architecture specific reason? Sorry if I missed anything. BTW, not sure if the x86/arm code can be combined into a common function. I don't see any architecture specific code here.
On 15/11/22 5:57 am, Yunhong Jiang wrote: > On Sun, Nov 13, 2022 at 05:05:10PM +0000, Shivam Kumar wrote: >> Exit to userspace whenever the dirty quota is exhausted (i.e. dirty count >> equals/exceeds dirty quota) to request more dirty quota. >> >> 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/arm64/kvm/arm.c | 9 +++++++++ >> 1 file changed, 9 insertions(+) >> >> diff --git a/arch/arm64/kvm/arm.c b/arch/arm64/kvm/arm.c >> index 94d33e296e10..850024982dd9 100644 >> --- a/arch/arm64/kvm/arm.c >> +++ b/arch/arm64/kvm/arm.c >> @@ -746,6 +746,15 @@ static int check_vcpu_requests(struct kvm_vcpu *vcpu) >> >> if (kvm_check_request(KVM_REQ_SUSPEND, vcpu)) >> return kvm_vcpu_suspend(vcpu); >> + >> + if (kvm_check_request(KVM_REQ_DIRTY_QUOTA_EXIT, vcpu)) { >> + struct kvm_run *run = vcpu->run; >> + >> + run->exit_reason = KVM_EXIT_DIRTY_QUOTA_EXHAUSTED; >> + run->dirty_quota_exit.count = vcpu->stat.generic.pages_dirtied; >> + run->dirty_quota_exit.quota = vcpu->dirty_quota; >> + return 0; >> + } > There is a recheck on x86 side, but not here. Any architecture specific reason? > Sorry if I missed anything. > > BTW, not sure if the x86/arm code can be combined into a common function. I > don't see any architecture specific code here. Yes, I think we may use a common function for x86/arm. With that, this would look like: if (kvm_check_dirty_quota_request(vcpu)) { return 0; } Thanks, Shivam
On Sun, 13 Nov 2022 17:05:10 +0000, Shivam Kumar <shivam.kumar1@nutanix.com> wrote: > > Exit to userspace whenever the dirty quota is exhausted (i.e. dirty count > equals/exceeds dirty quota) to request more dirty quota. > > 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/arm64/kvm/arm.c | 9 +++++++++ > 1 file changed, 9 insertions(+) > > diff --git a/arch/arm64/kvm/arm.c b/arch/arm64/kvm/arm.c > index 94d33e296e10..850024982dd9 100644 > --- a/arch/arm64/kvm/arm.c > +++ b/arch/arm64/kvm/arm.c > @@ -746,6 +746,15 @@ static int check_vcpu_requests(struct kvm_vcpu *vcpu) > > if (kvm_check_request(KVM_REQ_SUSPEND, vcpu)) > return kvm_vcpu_suspend(vcpu); > + > + if (kvm_check_request(KVM_REQ_DIRTY_QUOTA_EXIT, vcpu)) { > + struct kvm_run *run = vcpu->run; > + > + run->exit_reason = KVM_EXIT_DIRTY_QUOTA_EXHAUSTED; > + run->dirty_quota_exit.count = vcpu->stat.generic.pages_dirtied; > + run->dirty_quota_exit.quota = vcpu->dirty_quota; > + return 0; > + } > } > > return 1; As pointed out by others, this should be common code. This would definitely avoid the difference in behaviour between architectures. M.
On 18/11/22 2:14 am, Marc Zyngier wrote: > On Sun, 13 Nov 2022 17:05:10 +0000, > Shivam Kumar <shivam.kumar1@nutanix.com> wrote: >> >> Exit to userspace whenever the dirty quota is exhausted (i.e. dirty count >> equals/exceeds dirty quota) to request more dirty quota. >> >> 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/arm64/kvm/arm.c | 9 +++++++++ >> 1 file changed, 9 insertions(+) >> >> diff --git a/arch/arm64/kvm/arm.c b/arch/arm64/kvm/arm.c >> index 94d33e296e10..850024982dd9 100644 >> --- a/arch/arm64/kvm/arm.c >> +++ b/arch/arm64/kvm/arm.c >> @@ -746,6 +746,15 @@ static int check_vcpu_requests(struct kvm_vcpu *vcpu) >> >> if (kvm_check_request(KVM_REQ_SUSPEND, vcpu)) >> return kvm_vcpu_suspend(vcpu); >> + >> + if (kvm_check_request(KVM_REQ_DIRTY_QUOTA_EXIT, vcpu)) { >> + struct kvm_run *run = vcpu->run; >> + >> + run->exit_reason = KVM_EXIT_DIRTY_QUOTA_EXHAUSTED; >> + run->dirty_quota_exit.count = vcpu->stat.generic.pages_dirtied; >> + run->dirty_quota_exit.quota = vcpu->dirty_quota; >> + return 0; >> + } >> } >> >> return 1; > > As pointed out by others, this should be common code. This would > definitely avoid the difference in behaviour between architectures. > > M. > Ack. Thanks, Shivam
diff --git a/arch/arm64/kvm/arm.c b/arch/arm64/kvm/arm.c index 94d33e296e10..850024982dd9 100644 --- a/arch/arm64/kvm/arm.c +++ b/arch/arm64/kvm/arm.c @@ -746,6 +746,15 @@ static int check_vcpu_requests(struct kvm_vcpu *vcpu) if (kvm_check_request(KVM_REQ_SUSPEND, vcpu)) return kvm_vcpu_suspend(vcpu); + + if (kvm_check_request(KVM_REQ_DIRTY_QUOTA_EXIT, vcpu)) { + struct kvm_run *run = vcpu->run; + + run->exit_reason = KVM_EXIT_DIRTY_QUOTA_EXHAUSTED; + run->dirty_quota_exit.count = vcpu->stat.generic.pages_dirtied; + run->dirty_quota_exit.quota = vcpu->dirty_quota; + return 0; + } } return 1;