From: gleb@redhat.com (Gleb Natapov)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 3/4] arm64: KVM: let other tasks run when hitting WFE
Date: Mon, 22 Jul 2013 10:36:06 +0300 [thread overview]
Message-ID: <20130722073605.GJ20379@redhat.com> (raw)
In-Reply-To: <1374242035-13199-4-git-send-email-marc.zyngier@arm.com>
On Fri, Jul 19, 2013 at 02:53:54PM +0100, Marc Zyngier wrote:
> So far, when a guest executes WFE (like when waiting for a spinlock
> to become unlocked), we don't do a thing and let it run uninterrupted.
>
> Another option is to trap a blocking WFE and offer the opportunity
> to the scheduler to switch to another task, potentially giving the
> vcpu holding the spinlock a chance to run sooner.
>
Why is this targeted at 3.11 as opposite to 3.12? Looks like an
optimization.
> Signed-off-by: Marc Zyngier <marc.zyngier@arm.com>
> ---
> arch/arm64/include/asm/kvm_arm.h | 6 ++++--
> arch/arm64/kvm/handle_exit.c | 18 +++++++++++++-----
> 2 files changed, 17 insertions(+), 7 deletions(-)
>
> diff --git a/arch/arm64/include/asm/kvm_arm.h b/arch/arm64/include/asm/kvm_arm.h
> index a5f28e2..ac1ea05 100644
> --- a/arch/arm64/include/asm/kvm_arm.h
> +++ b/arch/arm64/include/asm/kvm_arm.h
> @@ -63,6 +63,7 @@
> * TAC: Trap ACTLR
> * TSC: Trap SMC
> * TSW: Trap cache operations by set/way
> + * TWE: Trap WFE
> * TWI: Trap WFI
> * TIDCP: Trap L2CTLR/L2ECTLR
> * BSU_IS: Upgrade barriers to the inner shareable domain
> @@ -72,8 +73,9 @@
> * FMO: Override CPSR.F and enable signaling with VF
> * SWIO: Turn set/way invalidates into set/way clean+invalidate
> */
> -#define HCR_GUEST_FLAGS (HCR_TSC | HCR_TSW | HCR_TWI | HCR_VM | HCR_BSU_IS | \
> - HCR_FB | HCR_TAC | HCR_AMO | HCR_IMO | HCR_FMO | \
> +#define HCR_GUEST_FLAGS (HCR_TSC | HCR_TSW | HCR_TWE | HCR_TWI | HCR_VM | \
> + HCR_BSU_IS | HCR_FB | HCR_TAC | \
> + HCR_AMO | HCR_IMO | HCR_FMO | \
> HCR_SWIO | HCR_TIDCP | HCR_RW)
> #define HCR_VIRT_EXCP_MASK (HCR_VA | HCR_VI | HCR_VF)
>
> diff --git a/arch/arm64/kvm/handle_exit.c b/arch/arm64/kvm/handle_exit.c
> index 9beaca03..b0098c2 100644
> --- a/arch/arm64/kvm/handle_exit.c
> +++ b/arch/arm64/kvm/handle_exit.c
> @@ -47,21 +47,29 @@ static int handle_smc(struct kvm_vcpu *vcpu, struct kvm_run *run)
> }
>
> /**
> - * kvm_handle_wfi - handle a wait-for-interrupts instruction executed by a guest
> + * kvm_handle_wfx - handle a wait-for-interrupts or wait-for-event
> + * instruction executed by a guest
> + *
> * @vcpu: the vcpu pointer
> *
> - * Simply call kvm_vcpu_block(), which will halt execution of
> + * WFE: Yield the CPU and come back to this vcpu when the scheduler
> + * decides to.
> + * WFI: Simply call kvm_vcpu_block(), which will halt execution of
> * world-switches and schedule other host processes until there is an
> * incoming IRQ or FIQ to the VM.
> */
> -static int kvm_handle_wfi(struct kvm_vcpu *vcpu, struct kvm_run *run)
> +static int kvm_handle_wfx(struct kvm_vcpu *vcpu, struct kvm_run *run)
> {
> - kvm_vcpu_block(vcpu);
> + if (kvm_vcpu_get_hsr(vcpu) & 1)
> + cond_resched();
> + else
> + kvm_vcpu_block(vcpu);
> +
> return 1;
> }
>
> static exit_handle_fn arm_exit_handlers[] = {
> - [ESR_EL2_EC_WFI] = kvm_handle_wfi,
> + [ESR_EL2_EC_WFI] = kvm_handle_wfx,
> [ESR_EL2_EC_CP15_32] = kvm_handle_cp15_32,
> [ESR_EL2_EC_CP15_64] = kvm_handle_cp15_64,
> [ESR_EL2_EC_CP14_MR] = kvm_handle_cp14_access,
> --
> 1.8.2.3
>
>
> --
> To unsubscribe from this list: send the line "unsubscribe kvm" in
> the body of a message to majordomo at vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
--
Gleb.
WARNING: multiple messages have this Message-ID (diff)
From: Gleb Natapov <gleb@redhat.com>
To: Marc Zyngier <marc.zyngier@arm.com>
Cc: linux-arm-kernel@lists.infradead.org, kvm@vger.kernel.org,
kvmarm@lists.cs.columbia.edu, christoffer.dall@linaro.org,
catalin.marinas@arm.com, will.deacon@arm.com
Subject: Re: [PATCH 3/4] arm64: KVM: let other tasks run when hitting WFE
Date: Mon, 22 Jul 2013 10:36:06 +0300 [thread overview]
Message-ID: <20130722073605.GJ20379@redhat.com> (raw)
In-Reply-To: <1374242035-13199-4-git-send-email-marc.zyngier@arm.com>
On Fri, Jul 19, 2013 at 02:53:54PM +0100, Marc Zyngier wrote:
> So far, when a guest executes WFE (like when waiting for a spinlock
> to become unlocked), we don't do a thing and let it run uninterrupted.
>
> Another option is to trap a blocking WFE and offer the opportunity
> to the scheduler to switch to another task, potentially giving the
> vcpu holding the spinlock a chance to run sooner.
>
Why is this targeted at 3.11 as opposite to 3.12? Looks like an
optimization.
> Signed-off-by: Marc Zyngier <marc.zyngier@arm.com>
> ---
> arch/arm64/include/asm/kvm_arm.h | 6 ++++--
> arch/arm64/kvm/handle_exit.c | 18 +++++++++++++-----
> 2 files changed, 17 insertions(+), 7 deletions(-)
>
> diff --git a/arch/arm64/include/asm/kvm_arm.h b/arch/arm64/include/asm/kvm_arm.h
> index a5f28e2..ac1ea05 100644
> --- a/arch/arm64/include/asm/kvm_arm.h
> +++ b/arch/arm64/include/asm/kvm_arm.h
> @@ -63,6 +63,7 @@
> * TAC: Trap ACTLR
> * TSC: Trap SMC
> * TSW: Trap cache operations by set/way
> + * TWE: Trap WFE
> * TWI: Trap WFI
> * TIDCP: Trap L2CTLR/L2ECTLR
> * BSU_IS: Upgrade barriers to the inner shareable domain
> @@ -72,8 +73,9 @@
> * FMO: Override CPSR.F and enable signaling with VF
> * SWIO: Turn set/way invalidates into set/way clean+invalidate
> */
> -#define HCR_GUEST_FLAGS (HCR_TSC | HCR_TSW | HCR_TWI | HCR_VM | HCR_BSU_IS | \
> - HCR_FB | HCR_TAC | HCR_AMO | HCR_IMO | HCR_FMO | \
> +#define HCR_GUEST_FLAGS (HCR_TSC | HCR_TSW | HCR_TWE | HCR_TWI | HCR_VM | \
> + HCR_BSU_IS | HCR_FB | HCR_TAC | \
> + HCR_AMO | HCR_IMO | HCR_FMO | \
> HCR_SWIO | HCR_TIDCP | HCR_RW)
> #define HCR_VIRT_EXCP_MASK (HCR_VA | HCR_VI | HCR_VF)
>
> diff --git a/arch/arm64/kvm/handle_exit.c b/arch/arm64/kvm/handle_exit.c
> index 9beaca03..b0098c2 100644
> --- a/arch/arm64/kvm/handle_exit.c
> +++ b/arch/arm64/kvm/handle_exit.c
> @@ -47,21 +47,29 @@ static int handle_smc(struct kvm_vcpu *vcpu, struct kvm_run *run)
> }
>
> /**
> - * kvm_handle_wfi - handle a wait-for-interrupts instruction executed by a guest
> + * kvm_handle_wfx - handle a wait-for-interrupts or wait-for-event
> + * instruction executed by a guest
> + *
> * @vcpu: the vcpu pointer
> *
> - * Simply call kvm_vcpu_block(), which will halt execution of
> + * WFE: Yield the CPU and come back to this vcpu when the scheduler
> + * decides to.
> + * WFI: Simply call kvm_vcpu_block(), which will halt execution of
> * world-switches and schedule other host processes until there is an
> * incoming IRQ or FIQ to the VM.
> */
> -static int kvm_handle_wfi(struct kvm_vcpu *vcpu, struct kvm_run *run)
> +static int kvm_handle_wfx(struct kvm_vcpu *vcpu, struct kvm_run *run)
> {
> - kvm_vcpu_block(vcpu);
> + if (kvm_vcpu_get_hsr(vcpu) & 1)
> + cond_resched();
> + else
> + kvm_vcpu_block(vcpu);
> +
> return 1;
> }
>
> static exit_handle_fn arm_exit_handlers[] = {
> - [ESR_EL2_EC_WFI] = kvm_handle_wfi,
> + [ESR_EL2_EC_WFI] = kvm_handle_wfx,
> [ESR_EL2_EC_CP15_32] = kvm_handle_cp15_32,
> [ESR_EL2_EC_CP15_64] = kvm_handle_cp15_64,
> [ESR_EL2_EC_CP14_MR] = kvm_handle_cp14_access,
> --
> 1.8.2.3
>
>
> --
> To unsubscribe from this list: send the line "unsubscribe kvm" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
--
Gleb.
next prev parent reply other threads:[~2013-07-22 7:36 UTC|newest]
Thread overview: 42+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-07-19 13:53 [PATCH 0/4] KVM/arm64 fixes for 3.11 Marc Zyngier
2013-07-19 13:53 ` Marc Zyngier
2013-07-19 13:53 ` [PATCH 1/4] arm64: KVM: perform save/restore of PAR_EL1 Marc Zyngier
2013-07-19 13:53 ` Marc Zyngier
2013-07-20 21:51 ` Christoffer Dall
2013-07-20 21:51 ` Christoffer Dall
2013-07-19 13:53 ` [PATCH 2/4] arm64: KVM: add missing dsb before invalidating Stage-2 TLBs Marc Zyngier
2013-07-19 13:53 ` Marc Zyngier
2013-07-19 14:32 ` Will Deacon
2013-07-19 14:32 ` Will Deacon
2013-07-19 14:53 ` Marc Zyngier
2013-07-19 14:53 ` Marc Zyngier
2013-07-19 13:53 ` [PATCH 3/4] arm64: KVM: let other tasks run when hitting WFE Marc Zyngier
2013-07-19 13:53 ` Marc Zyngier
2013-07-19 14:25 ` Will Deacon
2013-07-19 14:25 ` Will Deacon
2013-07-19 14:29 ` Marc Zyngier
2013-07-19 14:29 ` Marc Zyngier
2013-07-20 22:04 ` Christoffer Dall
2013-07-20 22:04 ` Christoffer Dall
2013-07-22 7:36 ` Gleb Natapov [this message]
2013-07-22 7:36 ` Gleb Natapov
2013-07-22 8:53 ` Raghavendra KT
2013-07-22 8:53 ` Raghavendra KT
2013-07-22 12:51 ` Christoffer Dall
2013-07-22 12:51 ` Christoffer Dall
2013-07-22 13:01 ` Will Deacon
2013-07-22 13:01 ` Will Deacon
2013-07-22 13:57 ` Raghavendra K T
2013-07-22 13:57 ` Raghavendra K T
2013-07-28 20:55 ` Christoffer Dall
2013-07-28 20:55 ` Christoffer Dall
2013-07-29 7:35 ` Raghavendra K T
2013-07-29 7:35 ` Raghavendra K T
2013-07-23 10:41 ` Catalin Marinas
2013-07-23 10:41 ` Catalin Marinas
2013-07-23 16:04 ` Will Deacon
2013-07-23 16:04 ` Will Deacon
2013-07-19 13:53 ` [PATCH 4/4] arm64: KVM: remove __kvm_hyp_code_{start,end} from hyp.S Marc Zyngier
2013-07-19 13:53 ` Marc Zyngier
2013-07-22 7:36 ` Gleb Natapov
2013-07-22 7:36 ` Gleb Natapov
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=20130722073605.GJ20379@redhat.com \
--to=gleb@redhat.com \
--cc=linux-arm-kernel@lists.infradead.org \
/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.