kvm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [GIT PULL 0/5] KVM: s390: fixes and enhancements for 5.5
@ 2019-11-18  8:35 Christian Borntraeger
  2019-11-18  8:35 ` [GIT PULL 1/5] KVM: s390: Remove unused parameter from __inject_sigp_restart() Christian Borntraeger
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: Christian Borntraeger @ 2019-11-18  8:35 UTC (permalink / raw)
  To: Paolo Bonzini, Radim Krčmář
  Cc: KVM, Cornelia Huck, Christian Borntraeger, linux-s390,
	Janosch Frank, David Hildenbrand

Paolo, Radim,

everybody is busy on the ultravisor related things, so only a small
number of changes for s390 for 5.5.

The following changes since commit 54ecb8f7028c5eb3d740bb82b0f1d90f2df63c5c:

  Linux 5.4-rc1 (2019-09-30 10:35:40 -0700)

are available in the Git repository at:

  git://git.kernel.org/pub/scm/linux/kernel/git/kvms390/linux.git  tags/kvm-s390-next-5.5-1

for you to fetch changes up to c7b7de63124645089ccf9900b9e5ea08059ccae0:

  KVM: s390: Do not yield when target is already running (2019-10-10 13:18:40 +0200)

----------------------------------------------------------------
KVM: s390: small fixes and enhancements

- selftest improvements
- yield improvements
- cleanups

----------------------------------------------------------------
Christian Borntraeger (3):
      selftests: kvm: make syncregs more reliable on s390
      KVM: s390: count invalid yields
      KVM: s390: Do not yield when target is already running

Janosch Frank (1):
      KVM: s390: Cleanup kvm_arch_init error path

Thomas Huth (1):
      KVM: s390: Remove unused parameter from __inject_sigp_restart()

 arch/s390/include/asm/kvm_host.h                   |  1 +
 arch/s390/kvm/diag.c                               | 22 ++++++++++++++++++----
 arch/s390/kvm/interrupt.c                          |  5 ++---
 arch/s390/kvm/kvm-s390.c                           | 19 ++++++++-----------
 tools/testing/selftests/kvm/s390x/sync_regs_test.c | 15 +++++++++------
 5 files changed, 38 insertions(+), 24 deletions(-)


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

* [GIT PULL 1/5] KVM: s390: Remove unused parameter from __inject_sigp_restart()
  2019-11-18  8:35 [GIT PULL 0/5] KVM: s390: fixes and enhancements for 5.5 Christian Borntraeger
@ 2019-11-18  8:35 ` Christian Borntraeger
  2019-11-18  8:35 ` [GIT PULL 2/5] KVM: s390: Cleanup kvm_arch_init error path Christian Borntraeger
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: Christian Borntraeger @ 2019-11-18  8:35 UTC (permalink / raw)
  To: Paolo Bonzini, Radim Krčmář
  Cc: KVM, Cornelia Huck, Christian Borntraeger, linux-s390,
	Janosch Frank, David Hildenbrand

From: Thomas Huth <thuth@redhat.com>

It's not required, so drop it to make it clear that this interrupt
does not have any extra parameters.

Signed-off-by: Thomas Huth <thuth@redhat.com>
Link: https://lore.kernel.org/kvm/20190912070250.15131-1-thuth@redhat.com
Reviewed-by: Janosch Frank <frankja@linux.ibm.com>
Reviewed-by: David Hildenbrand <david@redhat.com>
Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
---
 arch/s390/kvm/interrupt.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/arch/s390/kvm/interrupt.c b/arch/s390/kvm/interrupt.c
index d1ccc168c071..165dea4c7f19 100644
--- a/arch/s390/kvm/interrupt.c
+++ b/arch/s390/kvm/interrupt.c
@@ -1477,8 +1477,7 @@ static int __inject_sigp_stop(struct kvm_vcpu *vcpu, struct kvm_s390_irq *irq)
 	return 0;
 }
 
-static int __inject_sigp_restart(struct kvm_vcpu *vcpu,
-				 struct kvm_s390_irq *irq)
+static int __inject_sigp_restart(struct kvm_vcpu *vcpu)
 {
 	struct kvm_s390_local_interrupt *li = &vcpu->arch.local_int;
 
@@ -2007,7 +2006,7 @@ static int do_inject_vcpu(struct kvm_vcpu *vcpu, struct kvm_s390_irq *irq)
 		rc = __inject_sigp_stop(vcpu, irq);
 		break;
 	case KVM_S390_RESTART:
-		rc = __inject_sigp_restart(vcpu, irq);
+		rc = __inject_sigp_restart(vcpu);
 		break;
 	case KVM_S390_INT_CLOCK_COMP:
 		rc = __inject_ckc(vcpu);
-- 
2.21.0


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

* [GIT PULL 2/5] KVM: s390: Cleanup kvm_arch_init error path
  2019-11-18  8:35 [GIT PULL 0/5] KVM: s390: fixes and enhancements for 5.5 Christian Borntraeger
  2019-11-18  8:35 ` [GIT PULL 1/5] KVM: s390: Remove unused parameter from __inject_sigp_restart() Christian Borntraeger
@ 2019-11-18  8:35 ` Christian Borntraeger
  2019-11-18  8:36 ` [GIT PULL 3/5] selftests: kvm: make syncregs more reliable on s390 Christian Borntraeger
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: Christian Borntraeger @ 2019-11-18  8:35 UTC (permalink / raw)
  To: Paolo Bonzini, Radim Krčmář
  Cc: KVM, Cornelia Huck, Christian Borntraeger, linux-s390,
	Janosch Frank, David Hildenbrand

From: Janosch Frank <frankja@linux.ibm.com>

Both kvm_s390_gib_destroy and debug_unregister test if the needed
pointers are not NULL and hence can be called unconditionally.

Signed-off-by: Janosch Frank <frankja@linux.ibm.com>
Link: https://lore.kernel.org/kvm/20191002075627.3582-1-frankja@linux.ibm.com
Reviewed-by: David Hildenbrand <david@redhat.com>
Reviewed-by: Thomas Huth <thuth@redhat.com>
Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
---
 arch/s390/kvm/kvm-s390.c | 18 +++++++-----------
 1 file changed, 7 insertions(+), 11 deletions(-)

diff --git a/arch/s390/kvm/kvm-s390.c b/arch/s390/kvm/kvm-s390.c
index f6db0f1bc867..40af442b2e15 100644
--- a/arch/s390/kvm/kvm-s390.c
+++ b/arch/s390/kvm/kvm-s390.c
@@ -453,16 +453,14 @@ static void kvm_s390_cpu_feat_init(void)
 
 int kvm_arch_init(void *opaque)
 {
-	int rc;
+	int rc = -ENOMEM;
 
 	kvm_s390_dbf = debug_register("kvm-trace", 32, 1, 7 * sizeof(long));
 	if (!kvm_s390_dbf)
 		return -ENOMEM;
 
-	if (debug_register_view(kvm_s390_dbf, &debug_sprintf_view)) {
-		rc = -ENOMEM;
-		goto out_debug_unreg;
-	}
+	if (debug_register_view(kvm_s390_dbf, &debug_sprintf_view))
+		goto out;
 
 	kvm_s390_cpu_feat_init();
 
@@ -470,19 +468,17 @@ int kvm_arch_init(void *opaque)
 	rc = kvm_register_device_ops(&kvm_flic_ops, KVM_DEV_TYPE_FLIC);
 	if (rc) {
 		pr_err("A FLIC registration call failed with rc=%d\n", rc);
-		goto out_debug_unreg;
+		goto out;
 	}
 
 	rc = kvm_s390_gib_init(GAL_ISC);
 	if (rc)
-		goto out_gib_destroy;
+		goto out;
 
 	return 0;
 
-out_gib_destroy:
-	kvm_s390_gib_destroy();
-out_debug_unreg:
-	debug_unregister(kvm_s390_dbf);
+out:
+	kvm_arch_exit();
 	return rc;
 }
 
-- 
2.21.0


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

* [GIT PULL 3/5] selftests: kvm: make syncregs more reliable on s390
  2019-11-18  8:35 [GIT PULL 0/5] KVM: s390: fixes and enhancements for 5.5 Christian Borntraeger
  2019-11-18  8:35 ` [GIT PULL 1/5] KVM: s390: Remove unused parameter from __inject_sigp_restart() Christian Borntraeger
  2019-11-18  8:35 ` [GIT PULL 2/5] KVM: s390: Cleanup kvm_arch_init error path Christian Borntraeger
@ 2019-11-18  8:36 ` Christian Borntraeger
  2019-11-18  8:36 ` [GIT PULL 4/5] KVM: s390: count invalid yields Christian Borntraeger
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: Christian Borntraeger @ 2019-11-18  8:36 UTC (permalink / raw)
  To: Paolo Bonzini, Radim Krčmář
  Cc: KVM, Cornelia Huck, Christian Borntraeger, linux-s390,
	Janosch Frank, David Hildenbrand

similar to commit 2c57da356800 ("selftests: kvm: fix sync_regs_test with
newer gccs") and commit 204c91eff798a ("KVM: selftests: do not blindly
clobber registers in guest asm") we better do not rely on gcc leaving
r11 untouched.  We can write the simple ucall inline and have the guest
code completely as small assembler function.

Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
Suggested-by: Paolo Bonzini <pbonzini@redhat.com>
Reviewed-by: Thomas Huth <thuth@redhat.com>
---
 .../testing/selftests/kvm/s390x/sync_regs_test.c  | 15 +++++++++------
 1 file changed, 9 insertions(+), 6 deletions(-)

diff --git a/tools/testing/selftests/kvm/s390x/sync_regs_test.c b/tools/testing/selftests/kvm/s390x/sync_regs_test.c
index d5290b4ad636..b705637ca14b 100644
--- a/tools/testing/selftests/kvm/s390x/sync_regs_test.c
+++ b/tools/testing/selftests/kvm/s390x/sync_regs_test.c
@@ -25,12 +25,15 @@
 
 static void guest_code(void)
 {
-	register u64 stage asm("11") = 0;
-
-	for (;;) {
-		GUEST_SYNC(0);
-		asm volatile ("ahi %0,1" : : "r"(stage));
-	}
+	/*
+	 * We embed diag 501 here instead of doing a ucall to avoid that
+	 * the compiler has messed with r11 at the time of the ucall.
+	 */
+	asm volatile (
+		"0:	diag 0,0,0x501\n"
+		"	ahi 11,1\n"
+		"	j 0b\n"
+	);
 }
 
 #define REG_COMPARE(reg) \
-- 
2.21.0


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

* [GIT PULL 4/5] KVM: s390: count invalid yields
  2019-11-18  8:35 [GIT PULL 0/5] KVM: s390: fixes and enhancements for 5.5 Christian Borntraeger
                   ` (2 preceding siblings ...)
  2019-11-18  8:36 ` [GIT PULL 3/5] selftests: kvm: make syncregs more reliable on s390 Christian Borntraeger
@ 2019-11-18  8:36 ` Christian Borntraeger
  2019-11-18  8:36 ` [GIT PULL 5/5] KVM: s390: Do not yield when target is already running Christian Borntraeger
  2019-11-18 12:15 ` [GIT PULL 0/5] KVM: s390: fixes and enhancements for 5.5 Paolo Bonzini
  5 siblings, 0 replies; 7+ messages in thread
From: Christian Borntraeger @ 2019-11-18  8:36 UTC (permalink / raw)
  To: Paolo Bonzini, Radim Krčmář
  Cc: KVM, Cornelia Huck, Christian Borntraeger, linux-s390,
	Janosch Frank, David Hildenbrand

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>
Reviewed-by: Cornelia Huck <cohuck@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 40af442b2e15..3b5ebf48f802 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] 7+ messages in thread

* [GIT PULL 5/5] KVM: s390: Do not yield when target is already running
  2019-11-18  8:35 [GIT PULL 0/5] KVM: s390: fixes and enhancements for 5.5 Christian Borntraeger
                   ` (3 preceding siblings ...)
  2019-11-18  8:36 ` [GIT PULL 4/5] KVM: s390: count invalid yields Christian Borntraeger
@ 2019-11-18  8:36 ` Christian Borntraeger
  2019-11-18 12:15 ` [GIT PULL 0/5] KVM: s390: fixes and enhancements for 5.5 Paolo Bonzini
  5 siblings, 0 replies; 7+ messages in thread
From: Christian Borntraeger @ 2019-11-18  8:36 UTC (permalink / raw)
  To: Paolo Bonzini, Radim Krčmář
  Cc: KVM, Cornelia Huck, Christian Borntraeger, linux-s390,
	Janosch Frank, David Hildenbrand

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>
Reviewed-by: Cornelia Huck <cohuck@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] 7+ messages in thread

* Re: [GIT PULL 0/5] KVM: s390: fixes and enhancements for 5.5
  2019-11-18  8:35 [GIT PULL 0/5] KVM: s390: fixes and enhancements for 5.5 Christian Borntraeger
                   ` (4 preceding siblings ...)
  2019-11-18  8:36 ` [GIT PULL 5/5] KVM: s390: Do not yield when target is already running Christian Borntraeger
@ 2019-11-18 12:15 ` Paolo Bonzini
  5 siblings, 0 replies; 7+ messages in thread
From: Paolo Bonzini @ 2019-11-18 12:15 UTC (permalink / raw)
  To: Christian Borntraeger, Radim Krčmář
  Cc: KVM, Cornelia Huck, linux-s390, Janosch Frank, David Hildenbrand

On 18/11/19 09:35, Christian Borntraeger wrote:
> Paolo, Radim,
> 
> everybody is busy on the ultravisor related things, so only a small
> number of changes for s390 for 5.5.
> 
> The following changes since commit 54ecb8f7028c5eb3d740bb82b0f1d90f2df63c5c:
> 
>   Linux 5.4-rc1 (2019-09-30 10:35:40 -0700)
> 
> are available in the Git repository at:
> 
>   git://git.kernel.org/pub/scm/linux/kernel/git/kvms390/linux.git  tags/kvm-s390-next-5.5-1
> 
> for you to fetch changes up to c7b7de63124645089ccf9900b9e5ea08059ccae0:
> 
>   KVM: s390: Do not yield when target is already running (2019-10-10 13:18:40 +0200)
> 

Pulled, thanks.

Paolo

> ----------------------------------------------------------------
> KVM: s390: small fixes and enhancements
> 
> - selftest improvements
> - yield improvements
> - cleanups
> 
> ----------------------------------------------------------------
> Christian Borntraeger (3):
>       selftests: kvm: make syncregs more reliable on s390
>       KVM: s390: count invalid yields
>       KVM: s390: Do not yield when target is already running
> 
> Janosch Frank (1):
>       KVM: s390: Cleanup kvm_arch_init error path
> 
> Thomas Huth (1):
>       KVM: s390: Remove unused parameter from __inject_sigp_restart()
> 
>  arch/s390/include/asm/kvm_host.h                   |  1 +
>  arch/s390/kvm/diag.c                               | 22 ++++++++++++++++++----
>  arch/s390/kvm/interrupt.c                          |  5 ++---
>  arch/s390/kvm/kvm-s390.c                           | 19 ++++++++-----------
>  tools/testing/selftests/kvm/s390x/sync_regs_test.c | 15 +++++++++------
>  5 files changed, 38 insertions(+), 24 deletions(-)
> 


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

end of thread, other threads:[~2019-11-18 12:15 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-11-18  8:35 [GIT PULL 0/5] KVM: s390: fixes and enhancements for 5.5 Christian Borntraeger
2019-11-18  8:35 ` [GIT PULL 1/5] KVM: s390: Remove unused parameter from __inject_sigp_restart() Christian Borntraeger
2019-11-18  8:35 ` [GIT PULL 2/5] KVM: s390: Cleanup kvm_arch_init error path Christian Borntraeger
2019-11-18  8:36 ` [GIT PULL 3/5] selftests: kvm: make syncregs more reliable on s390 Christian Borntraeger
2019-11-18  8:36 ` [GIT PULL 4/5] KVM: s390: count invalid yields Christian Borntraeger
2019-11-18  8:36 ` [GIT PULL 5/5] KVM: s390: Do not yield when target is already running Christian Borntraeger
2019-11-18 12:15 ` [GIT PULL 0/5] KVM: s390: fixes and enhancements for 5.5 Paolo Bonzini

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).