[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: Thomas Gleixner <tglx@xxxxxxxxxxxxx>
  • From: Krister Johansen <kjlx@xxxxxxxxxxxxxxxxxx>
  • Date: Mon, 20 Feb 2023 21:51:17 -0800
  • Arc-authentication-results: i=1; rspamd-5db48964c-9hc9p; 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=1676958680; 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=4Ryms4gHoy/MGnNprWGKzCdsTkn+W4ai7vFOzO+3AGw=; b=3P6hxWtKbaqG76Fh6IYONPJSCJYuOVJv2GC1nxO/in/eyXs9LZCqPLKd3d6SSK6cp99bUQ UFLoukSPM3nx4mDYL+Z3Usehjh1VBPC0v8ZD2Ob2QZZsjAnmtF/ra3hWek2fW55Wf0w3y4 6fyd/PPoOGnWipC18REV7qgKVdMnNtDgYKklX30BC615KXDv0HN5L5XsxFu4I4o9YkF6Uz Szn5NnDbHQDbhKYyQj5uT3dvqfMlp0xzB+GBfg8jS4nxF/Sa/gxomFi03+SNeJEk+aHFCq qRkRP/eYRlzV8M+eQoCo4IWqx2ZLpFK8BOFI5QNL3vdTAp1ztpaYlsW9UgI7Sw==
  • Arc-seal: i=1; s=arc-2022; d=mailchannels.net; t=1676958680; a=rsa-sha256; cv=none; b=P/LyeC5VJy2k15smy91wrTaCZPsx3iu4tVq3lIjboluvHkv0xcq39GNu0kfDijFfsHLf0p ULIXZxwyQYkAClvopN00WuZhlRclnlvezipw0h3qSBxH4CugmjEmg3nlgi/5huq/vZeqh7 SeBDZDW1b6UcbdYxooVA4nW1yaj6/1C0/10shj4EHPgzNzKAb43ZBPpPoZt/7PPlmWs8gd kc+BH/vg9IERTZJw9pcdkU7jCyxp7yLrcXSMvDCZdRnqWEIWbqH7QhET9xajN/r8gekLmY lzCGnaL7vEYExdnOSsF3nea5sN3A4YjB9o1Bh8VYS8oQRs6YedqRO1UsafUStQ==
  • Cc: xen-devel@xxxxxxxxxxxxxxxxxxxx, linux-kernel@xxxxxxxxxxxxxxx, Juergen Gross <jgross@xxxxxxxx>, 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 05:51:53 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

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?

-K



 


Rackspace

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