[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH linux-next 2/2] x86/xen/time: cleanup xen_tsc_safe_clocksource


  • To: Juergen Gross <jgross@xxxxxxxx>
  • From: Krister Johansen <kjlx@xxxxxxxxxxxxxxxxxx>
  • Date: Tue, 21 Feb 2023 09:22:00 -0800
  • Arc-authentication-results: i=1; rspamd-5db48964c-ktlv5; auth=pass smtp.auth=dreamhost smtp.mailfrom=kjlx@xxxxxxxxxxxxxxxxxx
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=mailchannels.net; s=arc-2022; t=1677000126; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references:dkim-signature; bh=V/XcrwQCic125n2lnngmDNOBHq5WbsWAtWXZs/Ki6+I=; b=O58r4wR44Bi7btXXk0tmTJkuiA9es2N5rQNlo1qCWiHZWf/NVOQxVkIyg7xjkfyP9Lp2ER npFT/doMfOAKL3j6TQwMirKvsFjMlfQ8G5zqn4plqfYvPZxlxcKH+ox8o0CkLFLPXSzIRY uG62+cK64UcndoqXUuLqvn1pj0nk3qrzcpuVlXp7d0b6xn136Mppqgg3YvFIVSo8G6jz2t uwD1e1PQt7TcjD7i8p/Q4r8VNMdv7UJOnZmYWpG07ya7ZOVJGnvqfyfMSwWzM0Q1OzdzJp VAw4obKkV31Iwbayua2s92szIFCAUFpkIGdSkM3SA3Dp+R1lL+6m9BP7QhqT7g==
  • Arc-seal: i=1; s=arc-2022; d=mailchannels.net; t=1677000126; a=rsa-sha256; cv=none; b=o9FVfGd+S5cbGE25X6uMiTupqVMxKNZq+be6g+k5TuI59ZyjSBvzerbgp5dhGpz5SBv+CJ 4PteRvLicgDQqAdRvZX+xbsFJfycnpeh+YFS6Y79L8KllgMxpVFcEnaXbtvH2U4js9EMwa KtxGoYDXPbzZCHQ1qddQii6Nw70wZMZLEo5kRz1hBiTeFh/4jcbWzqqScjyeniEYpV5wW0 sRoZw7PhGXhGCGBp11lXh4Q78Zh54+ykOAE/ohhHTnx6dVhvPnvNxFGftWHa4t2ojtbYU8 xytaUgQzulG32eIchUArzigxGSqiM9ogRYjpqHcXtFSAfWf26WnpZXgs9GjgCg==
  • Cc: Krister Johansen <kjlx@xxxxxxxxxxxxxxxxxx>, Thomas Gleixner <tglx@xxxxxxxxxxxxx>, xen-devel@xxxxxxxxxxxxxxxxxxxx, linux-kernel@xxxxxxxxxxxxxxx, Jan Beulich <jbeulich@xxxxxxxx>, Boris Ostrovsky <boris.ostrovsky@xxxxxxxxxx>, Ingo Molnar <mingo@xxxxxxxxxx>, Borislav Petkov <bp@xxxxxxxxx>, Dave Hansen <dave.hansen@xxxxxxxxxxxxxxx>, x86@xxxxxxxxxx, "H. Peter Anvin" <hpa@xxxxxxxxx>, Marcelo Tosatti <mtosatti@xxxxxxxxxx>, Anthony Liguori <aliguori@xxxxxxxxxx>, David Reaver <me@xxxxxxxxxxxxxxx>, Brendan Gregg <brendan@xxxxxxxxx>
  • Delivery-date: Tue, 21 Feb 2023 17:22:21 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On Tue, Feb 21, 2023 at 09:47:24AM +0100, Juergen Gross wrote:
> On 21.02.23 06:51, Krister Johansen wrote:
> > On Mon, Feb 20, 2023 at 08:14:40PM -0800, Krister Johansen wrote:
> > > On Mon, Feb 20, 2023 at 11:01:18PM +0100, Thomas Gleixner wrote:
> > > > On Mon, Feb 20 2023 at 09:17, Krister Johansen wrote:
> > > > > @@ -495,8 +496,7 @@ static int __init xen_tsc_safe_clocksource(void)
> > > > >       /* Leaf 4, sub-leaf 0 (0x40000x03) */
> > > > >       cpuid_count(xen_cpuid_base() + 3, 0, &eax, &ebx, &ecx, &edx);
> > > > > -     /* tsc_mode = no_emulate (2) */
> > > > > -     if (ebx != 2)
> > > > > +     if (ebx != XEN_CPUID_TSC_MODE_NEVER_EMULATE)
> > > > >               return 0;
> > > > >       return 1;
> > > > 
> > > > What about removing more stupidity from that function?
> > > > 
> > > > static bool __init xen_tsc_safe_clocksource(void)
> > > > {
> > > >         u32 eax, ebx. ecx, edx;
> > > >         /* Leaf 4, sub-leaf 0 (0x40000x03) */
> > > >         cpuid_count(xen_cpuid_base() + 3, 0, &eax, &ebx, &ecx, &edx);
> > > > 
> > > >         return ebx == XEN_CPUID_TSC_MODE_NEVER_EMULATE;
> > > > }
> > > 
> > > I'm all for simplifying.  I'm happy to clean up that return to be more
> > > idiomatic.  I was under the impression, perhaps mistaken, though, that
> > > the X86_FEATURE_CONSTANT_TSC, X86_FEATURE_NONSTOP_TSC, and
> > > check_tsc_unstable() checks were actually serving a purpose: to ensure
> > > that we don't rely on the tsc in environments where it's being emulated
> > > and the OS would be better served by using a PV clock.  Specifically,
> > > kvmclock_init() makes a very similar set of checks that I also thought
> > > were load-bearing.
> > 
> > Bah, what I meant to say was emulated, unstable, or otherwise unsuitable
> > for use as a clocksource.  IOW, even if TSC_MODE_NEVER_EMULATE is
> > set, it's possible that a user is attempting a migration from a cpu
> > that's not invariant, and we'd still want to check for that case and
> > fall back to a PV clocksource, correct?
> 
> But Thomas' suggestion wasn't changing any behavior compared to your
> patch. It just makes it easier to read.
> 
> If you are unsure your patch is correct, please verify the correctness
> before sending it.

Thanks, and apologies. I misunderstood and thought a more complex change
was requested.

-K



 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.