lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAGM2rebgzrPAOSHXq8XY=e6YoHLeg-qhJZy4JJLntV7xLnrPDw@mail.gmail.com>
Date:   Mon, 30 Jul 2018 10:09:07 -0400
From:   Pavel Tatashin <pasha.tatashin@...cle.com>
To:     douly.fnst@...fujitsu.com
Cc:     LKML <linux-kernel@...r.kernel.org>, x86@...nel.org,
        tglx@...utronix.de, mingo@...hat.com, hpa@...or.com,
        peterz@...radead.org
Subject: Re: [PATCH 1/2] x86/tsc: Avoid a double call if TSC initializes earlier.

On Mon, Jul 30, 2018 at 3:55 AM Dou Liyang <douly.fnst@...fujitsu.com> wrote:
>
> static_branch_enable(&__use_tsc) may be called twice in common case, that
> is redundant. And there are also some common functions both in
> tsc_early_init() and tsc_init().
>
> Move them into a separate helper function, only call it once.
> Also fix comments:
>  -s/authorative/authoritative
>  -s/cyc2ns_init/tsc_init
>
> Cc: Thomas Gleixner <tglx@...utronix.de>
> Cc: Ingo Molnar <mingo@...hat.com>
> Cc: "H. Peter Anvin" <hpa@...or.com>
> Cc: Peter Zijlstra <peterz@...radead.org>
> Cc: Pavel Tatashin <pasha.tatashin@...cle.com>
> Signed-off-by: Dou Liyang <douly.fnst@...fujitsu.com>

Hi Dou,

Nice cleanup.
Reviewed-by: Pavel Tatashin <pasha.tatashin@...cle.com>

Thank you,
Pavel

> ---
>  arch/x86/kernel/tsc.c | 22 ++++++++++++----------
>  1 file changed, 12 insertions(+), 10 deletions(-)
>
> diff --git a/arch/x86/kernel/tsc.c b/arch/x86/kernel/tsc.c
> index 02e416b87ac1..ba0a6b6e0726 100644
> --- a/arch/x86/kernel/tsc.c
> +++ b/arch/x86/kernel/tsc.c
> @@ -182,7 +182,7 @@ static void __init cyc2ns_init_boot_cpu(void)
>  }
>
>  /*
> - * Secondary CPUs do not run through cyc2ns_init(), so set up
> + * Secondary CPUs do not run through tsc_init(), so set up
>   * all the scale factors for all CPUs, assuming the same
>   * speed as the bootup CPU. (cpufreq notifiers will fix this
>   * up if their speed diverges)
> @@ -1389,7 +1389,7 @@ static bool __init determine_cpu_tsc_frequencies(bool early)
>         }
>
>         /*
> -        * Trust non-zero tsc_khz as authorative,
> +        * Trust non-zero tsc_khz as authoritative,
>          * and use it to sanity check cpu_khz,
>          * which will be off if system timer is off.
>          */
> @@ -1421,6 +1421,14 @@ static unsigned long __init get_loops_per_jiffy(void)
>         return lpj;
>  }
>
> +static void __init enable_use_tsc(void)
> +{
> +       /* Sanitize TSC ADJUST before cyc2ns gets initialized */
> +       tsc_store_and_check_tsc_adjust(true);
> +       cyc2ns_init_boot_cpu();
> +       static_branch_enable(&__use_tsc);
> +}
> +
>  void __init tsc_early_init(void)
>  {
>         if (!boot_cpu_has(X86_FEATURE_TSC))
> @@ -1429,10 +1437,7 @@ void __init tsc_early_init(void)
>                 return;
>         loops_per_jiffy = get_loops_per_jiffy();
>
> -       /* Sanitize TSC ADJUST before cyc2ns gets initialized */
> -       tsc_store_and_check_tsc_adjust(true);
> -       cyc2ns_init_boot_cpu();
> -       static_branch_enable(&__use_tsc);
> +       enable_use_tsc();
>  }
>
>  void __init tsc_init(void)
> @@ -1456,13 +1461,10 @@ void __init tsc_init(void)
>                         setup_clear_cpu_cap(X86_FEATURE_TSC_DEADLINE_TIMER);
>                         return;
>                 }
> -               /* Sanitize TSC ADJUST before cyc2ns gets initialized */
> -               tsc_store_and_check_tsc_adjust(true);
> -               cyc2ns_init_boot_cpu();
> +               enable_use_tsc();
>         }
>
>         cyc2ns_init_secondary_cpus();
> -       static_branch_enable(&__use_tsc);
>
>         if (!no_sched_irq_time)
>                 enable_sched_clock_irqtime();
> --
> 2.14.3
>
>
>

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ