kvm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 0/2] diag 9c improvements
@ 2019-10-10 11:05 Christian Borntraeger
  2019-10-10 11:05 ` [PATCH v2 1/2] KVM: s390: count invalid yields Christian Borntraeger
  2019-10-10 11:05 ` [PATCH v2 2/2] KVM: s390: Do not yield when target is already running Christian Borntraeger
  0 siblings, 2 replies; 5+ messages in thread
From: Christian Borntraeger @ 2019-10-10 11:05 UTC (permalink / raw)
  To: Janosch Frank
  Cc: KVM, Cornelia Huck, Christian Borntraeger, David Hildenbrand,
	linux-s390, Thomas Huth

Christian Borntraeger (2):
  KVM: s390: count invalid yields
  KVM: s390: Do not yield when target is already running

 arch/s390/include/asm/kvm_host.h |  1 +
 arch/s390/kvm/diag.c             | 22 ++++++++++++++++++----
 arch/s390/kvm/kvm-s390.c         |  1 +
 3 files changed, 20 insertions(+), 4 deletions(-)

-- 
2.21.0


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH v2 1/2] KVM: s390: count invalid yields
  2019-10-10 11:05 [PATCH v2 0/2] diag 9c improvements Christian Borntraeger
@ 2019-10-10 11:05 ` Christian Borntraeger
  2019-10-10 11:15   ` Cornelia Huck
  2019-10-10 11:05 ` [PATCH v2 2/2] KVM: s390: Do not yield when target is already running Christian Borntraeger
  1 sibling, 1 reply; 5+ messages in thread
From: Christian Borntraeger @ 2019-10-10 11:05 UTC (permalink / raw)
  To: Janosch Frank
  Cc: KVM, Cornelia Huck, Christian Borntraeger, David Hildenbrand,
	linux-s390, Thomas Huth

To analyze some performance issues with lock contention and scheduling
it is nice to know when diag9c did not result in any action or when
no action was tried.

Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
Reviewed-by: David Hildenbrand <david@redhat.com>
---
 arch/s390/include/asm/kvm_host.h |  1 +
 arch/s390/kvm/diag.c             | 18 ++++++++++++++----
 arch/s390/kvm/kvm-s390.c         |  1 +
 3 files changed, 16 insertions(+), 4 deletions(-)

diff --git a/arch/s390/include/asm/kvm_host.h b/arch/s390/include/asm/kvm_host.h
index abe60268335d..02f4c21c57f6 100644
--- a/arch/s390/include/asm/kvm_host.h
+++ b/arch/s390/include/asm/kvm_host.h
@@ -392,6 +392,7 @@ struct kvm_vcpu_stat {
 	u64 diagnose_10;
 	u64 diagnose_44;
 	u64 diagnose_9c;
+	u64 diagnose_9c_ignored;
 	u64 diagnose_258;
 	u64 diagnose_308;
 	u64 diagnose_500;
diff --git a/arch/s390/kvm/diag.c b/arch/s390/kvm/diag.c
index 45634b3d2e0a..609c55df3ce8 100644
--- a/arch/s390/kvm/diag.c
+++ b/arch/s390/kvm/diag.c
@@ -158,14 +158,24 @@ static int __diag_time_slice_end_directed(struct kvm_vcpu *vcpu)
 
 	tid = vcpu->run->s.regs.gprs[(vcpu->arch.sie_block->ipa & 0xf0) >> 4];
 	vcpu->stat.diagnose_9c++;
-	VCPU_EVENT(vcpu, 5, "diag time slice end directed to %d", tid);
 
+	/* yield to self */
 	if (tid == vcpu->vcpu_id)
-		return 0;
+		goto no_yield;
 
+	/* yield to invalid */
 	tcpu = kvm_get_vcpu_by_id(vcpu->kvm, tid);
-	if (tcpu)
-		kvm_vcpu_yield_to(tcpu);
+	if (!tcpu)
+		goto no_yield;
+
+	if (kvm_vcpu_yield_to(tcpu) <= 0)
+		goto no_yield;
+
+	VCPU_EVENT(vcpu, 5, "diag time slice end directed to %d: done", tid);
+	return 0;
+no_yield:
+	VCPU_EVENT(vcpu, 5, "diag time slice end directed to %d: ignored", tid);
+	vcpu->stat.diagnose_9c_ignored++;
 	return 0;
 }
 
diff --git a/arch/s390/kvm/kvm-s390.c b/arch/s390/kvm/kvm-s390.c
index 4a3bc40ca1a4..d9e6bf3d54f0 100644
--- a/arch/s390/kvm/kvm-s390.c
+++ b/arch/s390/kvm/kvm-s390.c
@@ -155,6 +155,7 @@ struct kvm_stats_debugfs_item debugfs_entries[] = {
 	{ "instruction_diag_10", VCPU_STAT(diagnose_10) },
 	{ "instruction_diag_44", VCPU_STAT(diagnose_44) },
 	{ "instruction_diag_9c", VCPU_STAT(diagnose_9c) },
+	{ "diag_9c_ignored", VCPU_STAT(diagnose_9c_ignored) },
 	{ "instruction_diag_258", VCPU_STAT(diagnose_258) },
 	{ "instruction_diag_308", VCPU_STAT(diagnose_308) },
 	{ "instruction_diag_500", VCPU_STAT(diagnose_500) },
-- 
2.21.0


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH v2 2/2] KVM: s390: Do not yield when target is already running
  2019-10-10 11:05 [PATCH v2 0/2] diag 9c improvements Christian Borntraeger
  2019-10-10 11:05 ` [PATCH v2 1/2] KVM: s390: count invalid yields Christian Borntraeger
@ 2019-10-10 11:05 ` Christian Borntraeger
  2019-10-10 11:16   ` Cornelia Huck
  1 sibling, 1 reply; 5+ messages in thread
From: Christian Borntraeger @ 2019-10-10 11:05 UTC (permalink / raw)
  To: Janosch Frank
  Cc: KVM, Cornelia Huck, Christian Borntraeger, David Hildenbrand,
	linux-s390, Thomas Huth

If the target is already running we do not need to yield.

Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
Reviewed-by: David Hildenbrand <david@redhat.com>
---
 arch/s390/kvm/diag.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/arch/s390/kvm/diag.c b/arch/s390/kvm/diag.c
index 609c55df3ce8..3fb54ec2cf3e 100644
--- a/arch/s390/kvm/diag.c
+++ b/arch/s390/kvm/diag.c
@@ -168,6 +168,10 @@ static int __diag_time_slice_end_directed(struct kvm_vcpu *vcpu)
 	if (!tcpu)
 		goto no_yield;
 
+	/* target already running */
+	if (READ_ONCE(tcpu->cpu) >= 0)
+		goto no_yield;
+
 	if (kvm_vcpu_yield_to(tcpu) <= 0)
 		goto no_yield;
 
-- 
2.21.0


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH v2 1/2] KVM: s390: count invalid yields
  2019-10-10 11:05 ` [PATCH v2 1/2] KVM: s390: count invalid yields Christian Borntraeger
@ 2019-10-10 11:15   ` Cornelia Huck
  0 siblings, 0 replies; 5+ messages in thread
From: Cornelia Huck @ 2019-10-10 11:15 UTC (permalink / raw)
  To: Christian Borntraeger
  Cc: Janosch Frank, KVM, David Hildenbrand, linux-s390, Thomas Huth

On Thu, 10 Oct 2019 13:05:17 +0200
Christian Borntraeger <borntraeger@de.ibm.com> wrote:

> To analyze some performance issues with lock contention and scheduling
> it is nice to know when diag9c did not result in any action or when
> no action was tried.
> 
> Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
> Reviewed-by: David Hildenbrand <david@redhat.com>
> ---
>  arch/s390/include/asm/kvm_host.h |  1 +
>  arch/s390/kvm/diag.c             | 18 ++++++++++++++----
>  arch/s390/kvm/kvm-s390.c         |  1 +
>  3 files changed, 16 insertions(+), 4 deletions(-)

Reviewed-by: Cornelia Huck <cohuck@redhat.com>

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH v2 2/2] KVM: s390: Do not yield when target is already running
  2019-10-10 11:05 ` [PATCH v2 2/2] KVM: s390: Do not yield when target is already running Christian Borntraeger
@ 2019-10-10 11:16   ` Cornelia Huck
  0 siblings, 0 replies; 5+ messages in thread
From: Cornelia Huck @ 2019-10-10 11:16 UTC (permalink / raw)
  To: Christian Borntraeger
  Cc: Janosch Frank, KVM, David Hildenbrand, linux-s390, Thomas Huth

On Thu, 10 Oct 2019 13:05:18 +0200
Christian Borntraeger <borntraeger@de.ibm.com> wrote:

> If the target is already running we do not need to yield.
> 
> Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
> Reviewed-by: David Hildenbrand <david@redhat.com>
> ---
>  arch/s390/kvm/diag.c | 4 ++++
>  1 file changed, 4 insertions(+)

Reviewed-by: Cornelia Huck <cohuck@redhat.com>

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2019-10-10 11:16 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-10-10 11:05 [PATCH v2 0/2] diag 9c improvements Christian Borntraeger
2019-10-10 11:05 ` [PATCH v2 1/2] KVM: s390: count invalid yields Christian Borntraeger
2019-10-10 11:15   ` Cornelia Huck
2019-10-10 11:05 ` [PATCH v2 2/2] KVM: s390: Do not yield when target is already running Christian Borntraeger
2019-10-10 11:16   ` Cornelia Huck

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 NNTP newsgroup(s).