From: Peter Xu <peterx@redhat.com>
To: Marcelo Tosatti <mtosatti@redhat.com>
Cc: kvm@vger.kernel.org, Paolo Bonzini <pbonzini@redhat.com>,
Alex Williamson <alex.williamson@redhat.com>,
Sean Christopherson <seanjc@google.com>
Subject: Re: [patch 2/3] KVM: rename KVM_REQ_PENDING_TIMER to KVM_REQ_UNBLOCK
Date: Tue, 25 May 2021 15:14:33 -0400 [thread overview]
Message-ID: <YK1MmcHqJGCR631n@t490s> (raw)
In-Reply-To: <20210525134321.303768132@redhat.com>
On Tue, May 25, 2021 at 10:41:17AM -0300, Marcelo Tosatti wrote:
> KVM_REQ_UNBLOCK will be used to exit a vcpu from
> its inner vcpu halt emulation loop.
>
> Rename KVM_REQ_PENDING_TIMER to KVM_REQ_UNBLOCK, switch
> PowerPC to arch specific request bit.
>
> Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
>
> Index: kvm/include/linux/kvm_host.h
> ===================================================================
> --- kvm.orig/include/linux/kvm_host.h
> +++ kvm/include/linux/kvm_host.h
> @@ -146,7 +146,7 @@ static inline bool is_error_page(struct
> */
> #define KVM_REQ_TLB_FLUSH (0 | KVM_REQUEST_WAIT | KVM_REQUEST_NO_WAKEUP)
> #define KVM_REQ_MMU_RELOAD (1 | KVM_REQUEST_WAIT | KVM_REQUEST_NO_WAKEUP)
> -#define KVM_REQ_PENDING_TIMER 2
> +#define KVM_REQ_UNBLOCK 2
> #define KVM_REQ_UNHALT 3
> #define KVM_REQUEST_ARCH_BASE 8
>
> Index: kvm/virt/kvm/kvm_main.c
> ===================================================================
> --- kvm.orig/virt/kvm/kvm_main.c
> +++ kvm/virt/kvm/kvm_main.c
> @@ -2794,6 +2794,8 @@ static int kvm_vcpu_check_block(struct k
> goto out;
> if (signal_pending(current))
> goto out;
> + if (kvm_check_request(KVM_REQ_UNBLOCK, vcpu))
> + goto out;
>
> ret = 0;
> out:
> Index: kvm/Documentation/virt/kvm/vcpu-requests.rst
> ===================================================================
> --- kvm.orig/Documentation/virt/kvm/vcpu-requests.rst
> +++ kvm/Documentation/virt/kvm/vcpu-requests.rst
> @@ -118,10 +118,11 @@ KVM_REQ_MMU_RELOAD
> necessary to inform each VCPU to completely refresh the tables. This
> request is used for that.
>
> -KVM_REQ_PENDING_TIMER
> +KVM_REQ_UNBLOCK
>
> This request may be made from a timer handler run on the host on behalf
> - of a VCPU. It informs the VCPU thread to inject a timer interrupt.
> + of a VCPU, or when device assignment is performed. It informs the VCPU to
> + exit the vcpu halt inner loop.
>
> KVM_REQ_UNHALT
>
> Index: kvm/arch/powerpc/include/asm/kvm_host.h
> ===================================================================
> --- kvm.orig/arch/powerpc/include/asm/kvm_host.h
> +++ kvm/arch/powerpc/include/asm/kvm_host.h
> @@ -51,6 +51,7 @@
> /* PPC-specific vcpu->requests bit members */
> #define KVM_REQ_WATCHDOG KVM_ARCH_REQ(0)
> #define KVM_REQ_EPR_EXIT KVM_ARCH_REQ(1)
> +#define KVM_REQ_PENDING_TIMER KVM_ARCH_REQ(2)
>
> #include <linux/mmu_notifier.h>
>
> Index: kvm/arch/x86/kvm/lapic.c
> ===================================================================
> --- kvm.orig/arch/x86/kvm/lapic.c
> +++ kvm/arch/x86/kvm/lapic.c
> @@ -1657,7 +1657,7 @@ static void apic_timer_expired(struct kv
> }
>
> atomic_inc(&apic->lapic_timer.pending);
> - kvm_make_request(KVM_REQ_PENDING_TIMER, vcpu);
> + kvm_make_request(KVM_REQ_UNBLOCK, vcpu);
> if (from_timer_fn)
> kvm_vcpu_kick(vcpu);
> }
Pure question on the existing code: why do we need kvm_make_request() for
timer? As I see kvm_vcpu_check_block() already checks explicitly for timers:
static int kvm_vcpu_check_block(struct kvm_vcpu *vcpu)
{
...
if (kvm_cpu_has_pending_timer(vcpu))
goto out;
...
}
for x86:
int kvm_cpu_has_pending_timer(struct kvm_vcpu *vcpu)
{
if (lapic_in_kernel(vcpu))
return apic_has_pending_timer(vcpu);
return 0;
}
So wondering why we can drop the two references to KVM_REQ_PENDING_TIMER in x86
directly..
> Index: kvm/arch/x86/kvm/x86.c
> ===================================================================
> --- kvm.orig/arch/x86/kvm/x86.c
> +++ kvm/arch/x86/kvm/x86.c
> @@ -9300,7 +9300,7 @@ static int vcpu_run(struct kvm_vcpu *vcp
> if (r <= 0)
> break;
>
> - kvm_clear_request(KVM_REQ_PENDING_TIMER, vcpu);
> + kvm_clear_request(KVM_REQ_UNBLOCK, vcpu);
> if (kvm_cpu_has_pending_timer(vcpu))
> kvm_inject_pending_timer_irqs(vcpu);
>
>
>
--
Peter Xu
next prev parent reply other threads:[~2021-05-25 19:14 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-05-25 13:41 [patch 0/3] VMX: configure posted interrupt descriptor when assigning device (v5) Marcelo Tosatti
2021-05-25 13:41 ` [patch 1/3] KVM: x86: add start_assignment hook to kvm_x86_ops Marcelo Tosatti
2021-05-25 19:52 ` Peter Xu
2021-05-25 13:41 ` [patch 2/3] KVM: rename KVM_REQ_PENDING_TIMER to KVM_REQ_UNBLOCK Marcelo Tosatti
2021-05-25 19:14 ` Peter Xu [this message]
2021-05-25 19:26 ` Marcelo Tosatti
2021-05-25 19:52 ` Peter Xu
2021-05-27 11:57 ` Paolo Bonzini
2021-05-27 11:57 ` Paolo Bonzini
2021-05-25 13:41 ` [patch 3/3] KVM: VMX: update vcpu posted-interrupt descriptor when assigning device Marcelo Tosatti
2021-05-25 19:55 ` Peter Xu
2021-05-26 17:20 ` [patch 3/3 V2] " Marcelo Tosatti
2021-05-25 21:09 ` [patch 3/3] " kernel test robot
2021-05-27 11:59 ` [patch 0/3] VMX: configure posted interrupt descriptor when assigning device (v5) Paolo Bonzini
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=YK1MmcHqJGCR631n@t490s \
--to=peterx@redhat.com \
--cc=alex.williamson@redhat.com \
--cc=kvm@vger.kernel.org \
--cc=mtosatti@redhat.com \
--cc=pbonzini@redhat.com \
--cc=seanjc@google.com \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox