public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Sean Christopherson <seanjc@google.com>
To: Nam Cao <namcao@linutronix.de>
Cc: Anna-Maria Behnsen <anna-maria@linutronix.de>,
	Frederic Weisbecker <frederic@kernel.org>,
	 Thomas Gleixner <tglx@linutronix.de>,
	Andreas Hindborg <a.hindborg@kernel.org>,
	 Alice Ryhl <aliceryhl@google.com>,
	Miguel Ojeda <ojeda@kernel.org>, Kees Cook <kees@kernel.org>,
	 linux-kernel@vger.kernel.org,
	Paolo Bonzini <pbonzini@redhat.com>,
	x86@kernel.org,  kvm@vger.kernel.org
Subject: Re: [PATCH 04/21] KVM: x86/xen: Initialize hrtimer in kvm_xen_init_vcpu()
Date: Mon, 28 Oct 2024 09:01:46 -0700	[thread overview]
Message-ID: <Zx-1ahdKLH3o2MHj@google.com> (raw)
In-Reply-To: <c8e184b7acf1e073c0d6cf489031bc7d2b6304b0.1729864615.git.namcao@linutronix.de>

On Mon, Oct 28, 2024, Nam Cao wrote:
> The hrtimer is initialized in the KVM_XEN_VCPU_SET_ATTR ioctl. That caused
> problem in the past, because the hrtimer can be initialized multiple times,
> which was fixed by commit af735db31285 ("KVM: x86/xen: Initialize Xen timer
> only once"). This commit avoids initializing the timer multiple times by
> checking the field 'function' of struct hrtimer to determine if it has
> already been initialized.
> 
> Instead of "abusing" the 'function' field, move the hrtimer initialization
> into kvm_xen_init_vcpu() so that it will only be initialized once.
> 
> Signed-off-by: Nam Cao <namcao@linutronix.de>
> ---
> Cc: Sean Christopherson <seanjc@google.com>
> Cc: Paolo Bonzini <pbonzini@redhat.com>
> Cc: x86@kernel.org
> Cc: kvm@vger.kernel.org
> ---
>  arch/x86/kvm/xen.c | 4 +---
>  1 file changed, 1 insertion(+), 3 deletions(-)
> 
> diff --git a/arch/x86/kvm/xen.c b/arch/x86/kvm/xen.c
> index 622fe24da910..c386fbe6b58d 100644
> --- a/arch/x86/kvm/xen.c
> +++ b/arch/x86/kvm/xen.c
> @@ -1070,9 +1070,6 @@ int kvm_xen_vcpu_set_attr(struct kvm_vcpu *vcpu, struct kvm_xen_vcpu_attr *data)
>  			break;
>  		}
>  
> -		if (!vcpu->arch.xen.timer.function)
> -			kvm_xen_init_timer(vcpu);
> -
>  		/* Stop the timer (if it's running) before changing the vector */
>  		kvm_xen_stop_timer(vcpu);
>  		vcpu->arch.xen.timer_virq = data->u.timer.port;
> @@ -2235,6 +2232,7 @@ void kvm_xen_init_vcpu(struct kvm_vcpu *vcpu)
>  	vcpu->arch.xen.poll_evtchn = 0;
>  
>  	timer_setup(&vcpu->arch.xen.poll_timer, cancel_evtchn_poll, 0);
> +	kvm_xen_init_timer(vcpu);

I vote for opportunistically dropping kvm_xen_init_timer() and open coding its
contents here.

If the intent is for subsystems to grab their relevant patches, I can fixup when
applying.

>  	kvm_gpc_init(&vcpu->arch.xen.runstate_cache, vcpu->kvm);
>  	kvm_gpc_init(&vcpu->arch.xen.runstate2_cache, vcpu->kvm);
> -- 
> 2.39.5
> 

  reply	other threads:[~2024-10-28 16:01 UTC|newest]

Thread overview: 37+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-10-28  7:29 [PATCH 00/21] hrtimers: Switch to new hrtimer interface functions (1/5) Nam Cao
2024-10-28  7:29 ` [PATCH 01/21] hrtimers: Add missing hrtimer_init event trace points Nam Cao
2024-10-28  7:29 ` [PATCH 02/21] hrtimers: Remove unused hrtimer_init_sleeper() Nam Cao
2024-10-28  7:29 ` [PATCH 03/21] drm/i915/request: Remove unnecessary abuse of hrtimer::function Nam Cao
2024-10-28  7:29 ` [PATCH 04/21] KVM: x86/xen: Initialize hrtimer in kvm_xen_init_vcpu() Nam Cao
2024-10-28 16:01   ` Sean Christopherson [this message]
2024-10-28 22:19     ` Thomas Gleixner
2024-10-30 18:05   ` Sean Christopherson
2024-10-28  7:29 ` [PATCH 05/21] can: bcm: Don't initialized an unused hrtimer Nam Cao
2024-10-30 10:49   ` Oliver Hartkopp
2024-10-30 12:15     ` Nam Cao
2024-10-30 14:51       ` Oliver Hartkopp
2024-10-30 15:01         ` Oliver Hartkopp
2024-10-30 15:18           ` Thomas Gleixner
2024-10-28  7:29 ` [PATCH 06/21] wifi: rt2x00: Remove redundant hrtimer_init() Nam Cao
2024-10-31 14:13   ` Kalle Valo
2024-10-28  7:29 ` [PATCH 07/21] io_uring: Remove redundant hrtimer's callback function setup Nam Cao
2024-10-28  7:29 ` [PATCH 08/21] hrtimers: Introduce hrtimer_setup() to replace hrtimer_init() Nam Cao
2024-10-28  7:29 ` [PATCH 09/21] hrtimers: Introduce hrtimer_setup_on_stack() Nam Cao
2024-10-28  7:29 ` [PATCH 10/21] hrtimers: Introduce hrtimer_setup_sleeper_on_stack() Nam Cao
2024-10-28  7:29 ` [PATCH 11/21] hrtimers: Introduce hrtimer_update_function() Nam Cao
2024-10-28  7:29 ` [PATCH 12/21] fs/aio: Switch to use hrtimer_setup_sleeper_on_stack() Nam Cao
2024-10-28  7:29 ` [PATCH 13/21] futex: " Nam Cao
2024-10-28  7:29 ` [PATCH 14/21] net: pktgen: " Nam Cao
2024-10-28  7:29 ` [PATCH 15/21] timers: " Nam Cao
2024-10-28  7:29 ` [PATCH 16/21] wait: " Nam Cao
2024-10-28  7:29 ` [PATCH 17/21] hrtimers: Delete hrtimer_init_sleeper_on_stack() Nam Cao
2024-10-28  7:29 ` [PATCH 18/21] sched/idle: Switch to use hrtimer_setup_on_stack() Nam Cao
2024-10-28  9:09   ` Peter Zijlstra
2024-10-28 10:50     ` Thomas Gleixner
2024-10-28 10:58       ` Peter Zijlstra
2024-10-28 22:33         ` Thomas Gleixner
2024-10-28  7:29 ` [PATCH 19/21] io_uring: " Nam Cao
2024-10-28  7:29 ` [PATCH 20/21] alarmtimer: Switch to use hrtimer_setup() and hrtimer_setup_on_stack() Nam Cao
2024-10-28  7:29 ` [PATCH 21/21] hrtimers: Delete hrtimer_init_on_stack() Nam Cao
2024-10-28 16:05 ` [PATCH 00/21] hrtimers: Switch to new hrtimer interface functions (1/5) Sean Christopherson
2024-10-29  8:15   ` Thomas Gleixner

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=Zx-1ahdKLH3o2MHj@google.com \
    --to=seanjc@google.com \
    --cc=a.hindborg@kernel.org \
    --cc=aliceryhl@google.com \
    --cc=anna-maria@linutronix.de \
    --cc=frederic@kernel.org \
    --cc=kees@kernel.org \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=namcao@linutronix.de \
    --cc=ojeda@kernel.org \
    --cc=pbonzini@redhat.com \
    --cc=tglx@linutronix.de \
    --cc=x86@kernel.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox