All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] KVM: arm64: Add big.LITTLE architecture support for vcpu
@ 2021-03-05 10:34 ` Yejune Deng
  0 siblings, 0 replies; 6+ messages in thread
From: Yejune Deng @ 2021-03-05 10:34 UTC (permalink / raw)
  To: maz, james.morse, julien.thierry.kdev, suzuki.poulose,
	catalin.marinas, will
  Cc: linux-arm-kernel, kvmarm, linux-kernel, yejune.deng

In big.LITTLE architecture,the application layer calls KVM_ARM_VCPU_INIT
several times.Sometimes the thread will run on the big core, sometimes
will run on the little core.The big core and the little core has always
different cpuid, but the init target is fixed. and that leads to
init->target != phys_target. So modify phys target from the current core
to all cpu online.

Signed-off-by: Yejune Deng <yejune.deng@gmail.com>
---
 arch/arm64/kvm/arm.c | 30 +++++++++++++++++++++---------
 1 file changed, 21 insertions(+), 9 deletions(-)

diff --git a/arch/arm64/kvm/arm.c b/arch/arm64/kvm/arm.c
index fc4c95dd2d26..f7fe09a5b23e 100644
--- a/arch/arm64/kvm/arm.c
+++ b/arch/arm64/kvm/arm.c
@@ -983,20 +983,37 @@ int kvm_vm_ioctl_irq_line(struct kvm *kvm, struct kvm_irq_level *irq_level,
 	return -EINVAL;
 }
 
+static void check_kvm_target_cpu(void *ret)
+{
+	*(int *)ret = kvm_target_cpu();
+}
+
+static int kvm_cpu_online_target(int init_target)
+{
+	int cpu, ret = -1;
+
+	for_each_online_cpu(cpu) {
+		smp_call_function_single(cpu, check_kvm_target_cpu, &ret, 1);
+		if (ret == init_target)
+			return 0;
+	}
+
+	return -EINVAL;
+}
+
 static int kvm_vcpu_set_target(struct kvm_vcpu *vcpu,
 			       const struct kvm_vcpu_init *init)
 {
 	unsigned int i, ret;
-	int phys_target = kvm_target_cpu();
 
-	if (init->target != phys_target)
+	if (kvm_cpu_online_target(init->target))
 		return -EINVAL;
 
 	/*
 	 * Secondary and subsequent calls to KVM_ARM_VCPU_INIT must
 	 * use the same target.
 	 */
-	if (vcpu->arch.target != -1 && vcpu->arch.target != init->target)
+	if (vcpu->arch.target != -1 && kvm_cpu_online_target(init->target))
 		return -EINVAL;
 
 	/* -ENOENT for unknown features, -EINVAL for invalid combinations. */
@@ -1018,7 +1035,7 @@ static int kvm_vcpu_set_target(struct kvm_vcpu *vcpu,
 			set_bit(i, vcpu->arch.features);
 	}
 
-	vcpu->arch.target = phys_target;
+	vcpu->arch.target = init->target;
 
 	/* Now we know what it is, we can reset it. */
 	ret = kvm_reset_vcpu(vcpu);
@@ -1815,11 +1832,6 @@ static int init_hyp_mode(void)
 	return err;
 }
 
-static void check_kvm_target_cpu(void *ret)
-{
-	*(int *)ret = kvm_target_cpu();
-}
-
 struct kvm_vcpu *kvm_mpidr_to_vcpu(struct kvm *kvm, unsigned long mpidr)
 {
 	struct kvm_vcpu *vcpu;
-- 
2.29.0


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

* [PATCH] KVM: arm64: Add big.LITTLE architecture support for vcpu
@ 2021-03-05 10:34 ` Yejune Deng
  0 siblings, 0 replies; 6+ messages in thread
From: Yejune Deng @ 2021-03-05 10:34 UTC (permalink / raw)
  To: maz, james.morse, julien.thierry.kdev, suzuki.poulose,
	catalin.marinas, will
  Cc: yejune.deng, kvmarm, linux-arm-kernel, linux-kernel

In big.LITTLE architecture,the application layer calls KVM_ARM_VCPU_INIT
several times.Sometimes the thread will run on the big core, sometimes
will run on the little core.The big core and the little core has always
different cpuid, but the init target is fixed. and that leads to
init->target != phys_target. So modify phys target from the current core
to all cpu online.

Signed-off-by: Yejune Deng <yejune.deng@gmail.com>
---
 arch/arm64/kvm/arm.c | 30 +++++++++++++++++++++---------
 1 file changed, 21 insertions(+), 9 deletions(-)

diff --git a/arch/arm64/kvm/arm.c b/arch/arm64/kvm/arm.c
index fc4c95dd2d26..f7fe09a5b23e 100644
--- a/arch/arm64/kvm/arm.c
+++ b/arch/arm64/kvm/arm.c
@@ -983,20 +983,37 @@ int kvm_vm_ioctl_irq_line(struct kvm *kvm, struct kvm_irq_level *irq_level,
 	return -EINVAL;
 }
 
+static void check_kvm_target_cpu(void *ret)
+{
+	*(int *)ret = kvm_target_cpu();
+}
+
+static int kvm_cpu_online_target(int init_target)
+{
+	int cpu, ret = -1;
+
+	for_each_online_cpu(cpu) {
+		smp_call_function_single(cpu, check_kvm_target_cpu, &ret, 1);
+		if (ret == init_target)
+			return 0;
+	}
+
+	return -EINVAL;
+}
+
 static int kvm_vcpu_set_target(struct kvm_vcpu *vcpu,
 			       const struct kvm_vcpu_init *init)
 {
 	unsigned int i, ret;
-	int phys_target = kvm_target_cpu();
 
-	if (init->target != phys_target)
+	if (kvm_cpu_online_target(init->target))
 		return -EINVAL;
 
 	/*
 	 * Secondary and subsequent calls to KVM_ARM_VCPU_INIT must
 	 * use the same target.
 	 */
-	if (vcpu->arch.target != -1 && vcpu->arch.target != init->target)
+	if (vcpu->arch.target != -1 && kvm_cpu_online_target(init->target))
 		return -EINVAL;
 
 	/* -ENOENT for unknown features, -EINVAL for invalid combinations. */
@@ -1018,7 +1035,7 @@ static int kvm_vcpu_set_target(struct kvm_vcpu *vcpu,
 			set_bit(i, vcpu->arch.features);
 	}
 
-	vcpu->arch.target = phys_target;
+	vcpu->arch.target = init->target;
 
 	/* Now we know what it is, we can reset it. */
 	ret = kvm_reset_vcpu(vcpu);
@@ -1815,11 +1832,6 @@ static int init_hyp_mode(void)
 	return err;
 }
 
-static void check_kvm_target_cpu(void *ret)
-{
-	*(int *)ret = kvm_target_cpu();
-}
-
 struct kvm_vcpu *kvm_mpidr_to_vcpu(struct kvm *kvm, unsigned long mpidr)
 {
 	struct kvm_vcpu *vcpu;
-- 
2.29.0

_______________________________________________
kvmarm mailing list
kvmarm@lists.cs.columbia.edu
https://lists.cs.columbia.edu/mailman/listinfo/kvmarm

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

* [PATCH] KVM: arm64: Add big.LITTLE architecture support for vcpu
@ 2021-03-05 10:34 ` Yejune Deng
  0 siblings, 0 replies; 6+ messages in thread
From: Yejune Deng @ 2021-03-05 10:34 UTC (permalink / raw)
  To: maz, james.morse, julien.thierry.kdev, suzuki.poulose,
	catalin.marinas, will
  Cc: linux-arm-kernel, kvmarm, linux-kernel, yejune.deng

In big.LITTLE architecture,the application layer calls KVM_ARM_VCPU_INIT
several times.Sometimes the thread will run on the big core, sometimes
will run on the little core.The big core and the little core has always
different cpuid, but the init target is fixed. and that leads to
init->target != phys_target. So modify phys target from the current core
to all cpu online.

Signed-off-by: Yejune Deng <yejune.deng@gmail.com>
---
 arch/arm64/kvm/arm.c | 30 +++++++++++++++++++++---------
 1 file changed, 21 insertions(+), 9 deletions(-)

diff --git a/arch/arm64/kvm/arm.c b/arch/arm64/kvm/arm.c
index fc4c95dd2d26..f7fe09a5b23e 100644
--- a/arch/arm64/kvm/arm.c
+++ b/arch/arm64/kvm/arm.c
@@ -983,20 +983,37 @@ int kvm_vm_ioctl_irq_line(struct kvm *kvm, struct kvm_irq_level *irq_level,
 	return -EINVAL;
 }
 
+static void check_kvm_target_cpu(void *ret)
+{
+	*(int *)ret = kvm_target_cpu();
+}
+
+static int kvm_cpu_online_target(int init_target)
+{
+	int cpu, ret = -1;
+
+	for_each_online_cpu(cpu) {
+		smp_call_function_single(cpu, check_kvm_target_cpu, &ret, 1);
+		if (ret == init_target)
+			return 0;
+	}
+
+	return -EINVAL;
+}
+
 static int kvm_vcpu_set_target(struct kvm_vcpu *vcpu,
 			       const struct kvm_vcpu_init *init)
 {
 	unsigned int i, ret;
-	int phys_target = kvm_target_cpu();
 
-	if (init->target != phys_target)
+	if (kvm_cpu_online_target(init->target))
 		return -EINVAL;
 
 	/*
 	 * Secondary and subsequent calls to KVM_ARM_VCPU_INIT must
 	 * use the same target.
 	 */
-	if (vcpu->arch.target != -1 && vcpu->arch.target != init->target)
+	if (vcpu->arch.target != -1 && kvm_cpu_online_target(init->target))
 		return -EINVAL;
 
 	/* -ENOENT for unknown features, -EINVAL for invalid combinations. */
@@ -1018,7 +1035,7 @@ static int kvm_vcpu_set_target(struct kvm_vcpu *vcpu,
 			set_bit(i, vcpu->arch.features);
 	}
 
-	vcpu->arch.target = phys_target;
+	vcpu->arch.target = init->target;
 
 	/* Now we know what it is, we can reset it. */
 	ret = kvm_reset_vcpu(vcpu);
@@ -1815,11 +1832,6 @@ static int init_hyp_mode(void)
 	return err;
 }
 
-static void check_kvm_target_cpu(void *ret)
-{
-	*(int *)ret = kvm_target_cpu();
-}
-
 struct kvm_vcpu *kvm_mpidr_to_vcpu(struct kvm *kvm, unsigned long mpidr)
 {
 	struct kvm_vcpu *vcpu;
-- 
2.29.0


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [PATCH] KVM: arm64: Add big.LITTLE architecture support for vcpu
  2021-03-05 10:34 ` Yejune Deng
  (?)
@ 2021-03-05 12:02   ` Marc Zyngier
  -1 siblings, 0 replies; 6+ messages in thread
From: Marc Zyngier @ 2021-03-05 12:02 UTC (permalink / raw)
  To: Yejune Deng
  Cc: james.morse, julien.thierry.kdev, suzuki.poulose,
	catalin.marinas, will, linux-arm-kernel, kvmarm, linux-kernel

On Fri, 05 Mar 2021 10:34:25 +0000,
Yejune Deng <yejune.deng@gmail.com> wrote:
> 
> In big.LITTLE architecture,the application layer calls KVM_ARM_VCPU_INIT
> several times.Sometimes the thread will run on the big core, sometimes
> will run on the little core.The big core and the little core has always
> different cpuid, but the init target is fixed. and that leads to
> init->target != phys_target. So modify phys target from the current core
> to all cpu online.

This is done on purpose, and it is userspace's responsibility to pin
its vcpu threads to a certain type of CPUs if it cares at all.

Thanks,

	M.

-- 
Without deviation from the norm, progress is not possible.

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

* Re: [PATCH] KVM: arm64: Add big.LITTLE architecture support for vcpu
@ 2021-03-05 12:02   ` Marc Zyngier
  0 siblings, 0 replies; 6+ messages in thread
From: Marc Zyngier @ 2021-03-05 12:02 UTC (permalink / raw)
  To: Yejune Deng; +Cc: catalin.marinas, linux-kernel, will, kvmarm, linux-arm-kernel

On Fri, 05 Mar 2021 10:34:25 +0000,
Yejune Deng <yejune.deng@gmail.com> wrote:
> 
> In big.LITTLE architecture,the application layer calls KVM_ARM_VCPU_INIT
> several times.Sometimes the thread will run on the big core, sometimes
> will run on the little core.The big core and the little core has always
> different cpuid, but the init target is fixed. and that leads to
> init->target != phys_target. So modify phys target from the current core
> to all cpu online.

This is done on purpose, and it is userspace's responsibility to pin
its vcpu threads to a certain type of CPUs if it cares at all.

Thanks,

	M.

-- 
Without deviation from the norm, progress is not possible.
_______________________________________________
kvmarm mailing list
kvmarm@lists.cs.columbia.edu
https://lists.cs.columbia.edu/mailman/listinfo/kvmarm

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

* Re: [PATCH] KVM: arm64: Add big.LITTLE architecture support for vcpu
@ 2021-03-05 12:02   ` Marc Zyngier
  0 siblings, 0 replies; 6+ messages in thread
From: Marc Zyngier @ 2021-03-05 12:02 UTC (permalink / raw)
  To: Yejune Deng
  Cc: james.morse, julien.thierry.kdev, suzuki.poulose,
	catalin.marinas, will, linux-arm-kernel, kvmarm, linux-kernel

On Fri, 05 Mar 2021 10:34:25 +0000,
Yejune Deng <yejune.deng@gmail.com> wrote:
> 
> In big.LITTLE architecture,the application layer calls KVM_ARM_VCPU_INIT
> several times.Sometimes the thread will run on the big core, sometimes
> will run on the little core.The big core and the little core has always
> different cpuid, but the init target is fixed. and that leads to
> init->target != phys_target. So modify phys target from the current core
> to all cpu online.

This is done on purpose, and it is userspace's responsibility to pin
its vcpu threads to a certain type of CPUs if it cares at all.

Thanks,

	M.

-- 
Without deviation from the norm, progress is not possible.

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

end of thread, other threads:[~2021-03-05 18:58 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-05 10:34 [PATCH] KVM: arm64: Add big.LITTLE architecture support for vcpu Yejune Deng
2021-03-05 10:34 ` Yejune Deng
2021-03-05 10:34 ` Yejune Deng
2021-03-05 12:02 ` Marc Zyngier
2021-03-05 12:02   ` Marc Zyngier
2021-03-05 12:02   ` Marc Zyngier

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.