linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Dou Liyang <douly.fnst@cn.fujitsu.com>
To: Pavel Tatashin <pasha.tatashin@oracle.com>
Cc: Steven Sistare <steven.sistare@oracle.com>,
	Daniel Jordan <daniel.m.jordan@oracle.com>,
	<linux@armlinux.org.uk>, <schwidefsky@de.ibm.com>,
	Heiko Carstens <heiko.carstens@de.ibm.com>,
	John Stultz <john.stultz@linaro.org>, <sboyd@codeaurora.org>,
	<x86@kernel.org>, LKML <linux-kernel@vger.kernel.org>,
	<mingo@redhat.com>, <tglx@linutronix.de>, <hpa@zytor.com>,
	<peterz@infradead.org>, <prarit@redhat.com>,
	<feng.tang@intel.com>, Petr Mladek <pmladek@suse.com>,
	<gnomes@lxorguk.ukuu.org.uk>, <linux-s390@vger.kernel.org>,
	<boris.ostrovsky@oracle.com>, <jgross@suse.com>
Subject: Re: [PATCH v13 13/18] x86/tsc: calibrate tsc only once
Date: Mon, 16 Jul 2018 17:32:20 +0800	[thread overview]
Message-ID: <01812492-b88b-4436-570b-ef776eaafc6a@cn.fujitsu.com> (raw)
In-Reply-To: <CAGM2reb-MwiT8qoiSkXCjAAM46JOYL9BP+U3q7PMTcxp9EiK7w@mail.gmail.com>



At 07/13/2018 07:30 PM, Pavel Tatashin wrote:
> On Fri, Jul 13, 2018 at 3:24 AM Dou Liyang <douly.fnst@cn.fujitsu.com> wrote:
>>
>>
>> At 07/12/2018 08:04 AM, Pavel Tatashin wrote:
>>> During boot tsc is calibrated twice: once in tsc_early_delay_calibrate(),
>>> and the second time in tsc_init().
>>>
>>> Rename tsc_early_delay_calibrate() to tsc_early_init(), and rework it so
>>> the calibration is done only early, and make tsc_init() to use the values
>>> already determined in tsc_early_init().
>>>
>>> Sometimes it is not possible to determine tsc early, as the subsystem that
>>> is required is not yet initialized, in such case try again later in
>>> tsc_init().
>>>
>>> Suggested-by: Thomas Gleixner <tglx@linutronix.de>
>>> Signed-off-by: Pavel Tatashin <pasha.tatashin@oracle.com>
>>
>> Hi Pavel,
>>
>> Aha, a complex solution for a simple problem! ;-) And I did find any
>> benefits of doing that. did I miss something?
> 
> Hi Dou,
> 
> I had this in previous version:  init early, and unconditionally
> re-init later (which required to resync sched clocks for continuity,
> and check for some other corner cases). Thomas did not like the idea,
> as it is less deterministic: it leads for code to work by accident,
> where we might get one tsc frequency early and another later, and so
> on. The request was to initialize only once, and if that fails do it
> again later. This way, if early initialization is broken, we will know
> and fix it.
> 

Hi Pavel,

Yes, right, I have seen the purpose in v12.

>>
>> As the cpu_khz and tsc_khz are global variables and the tsc_khz may
>> be reset to cpu_khz. How about the following patch.
> 
> Could you please explain where you think this patch can be applied,
> and what it fixes?
> 

This patch is just an simple alternative to realize what you want in
your patch. your patch is also good but complex, and need some scrub.
eg:
   - Is it suitable to using the WARN_ON()
   - the name of determine_cpu_tsc_frequncies() function,
    s/frequncies/frequencies/. BTW, How about tsc_calibrate_frequencies()
   - ...

BTW, before this patch, seems we need make sure xen should work well, I
can investigate and try to test if we can also move the pagetable_init()
to the front of tsc_early_init() for you.

Thanks,
	dou

diff --git a/arch/x86/kernel/setup.c b/arch/x86/kernel/setup.c
index da1dbd99cb6e..74cb16d89e25 100644
--- a/arch/x86/kernel/setup.c
+++ b/arch/x86/kernel/setup.c
@@ -1197,12 +1197,12 @@ void __init setup_arch(char **cmdline_p)

         memblock_find_dma_reserve();

+       x86_init.paging.pagetable_init();
+
         tsc_early_delay_calibrate();
         if (!early_xdbc_setup_hardware())
                 early_xdbc_register_console();

-       x86_init.paging.pagetable_init();
-
         kasan_init();

         /*

> Thank you,
> Pavel
> 
>>
>> Thanks,
>>          dou
>> ------------------------8<-----------------------------------
>>
>> diff --git a/arch/x86/kernel/tsc.c b/arch/x86/kernel/tsc.c
>> index 74392d9d51e0..e54fa1037d45 100644
>> --- a/arch/x86/kernel/tsc.c
>> +++ b/arch/x86/kernel/tsc.c
>> @@ -1370,8 +1370,10 @@ void __init tsc_init(void)
>>                   return;
>>           }
>>
>> -       cpu_khz = x86_platform.calibrate_cpu();
>> -       tsc_khz = x86_platform.calibrate_tsc();
>> +       if (!tsc_khz) {
>> +               cpu_khz = x86_platform.calibrate_cpu();
>> +               tsc_khz = x86_platform.calibrate_tsc();
>> +       }
>>
>>           /*
>>            * Trust non-zero tsc_khz as authorative,
> 
> 
> 



  reply	other threads:[~2018-07-16  9:32 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-07-12  0:04 [PATCH v13 00/18] Early boot time stamps Pavel Tatashin
2018-07-12  0:04 ` [PATCH v13 01/18] x86: text_poke() may access uninitialized struct pages Pavel Tatashin
2018-07-12  0:04 ` [PATCH v13 02/18] x86: initialize static branching early Pavel Tatashin
2018-07-12  0:04 ` [PATCH v13 03/18] x86/CPU: Call detect_nopl() only on the BSP Pavel Tatashin
2018-07-12  0:04 ` [PATCH v13 04/18] x86/tsc: redefine notsc to behave as tsc=unstable Pavel Tatashin
2018-07-12  0:04 ` [PATCH v13 05/18] kvm/x86: remove kvm memblock dependency Pavel Tatashin
2018-07-12  0:04 ` [PATCH v13 06/18] x86/xen/time: initialize pv xen time in init_hypervisor_platform Pavel Tatashin
2018-07-13  1:57   ` Pavel Tatashin
2018-07-17 15:28   ` Boris Ostrovsky
2018-07-18  1:38     ` Pavel Tatashin
2018-07-12  0:04 ` [PATCH v13 07/18] x86/xen/time: output xen sched_clock time from 0 Pavel Tatashin
2018-07-17 15:43   ` Boris Ostrovsky
2018-07-18  1:59     ` Pavel Tatashin
2018-07-12  0:04 ` [PATCH v13 08/18] s390/time: add read_persistent_wall_and_boot_offset() Pavel Tatashin
2018-07-12  0:04 ` [PATCH v13 09/18] time: replace read_boot_clock64() with read_persistent_wall_and_boot_offset() Pavel Tatashin
2018-07-12  0:04 ` [PATCH v13 10/18] time: default boot time offset to local_clock() Pavel Tatashin
2018-07-12  0:04 ` [PATCH v13 11/18] s390/time: remove read_boot_clock64() Pavel Tatashin
2018-07-12  0:04 ` [PATCH v13 12/18] ARM/time: " Pavel Tatashin
2018-07-12  0:04 ` [PATCH v13 13/18] x86/tsc: calibrate tsc only once Pavel Tatashin
2018-07-13  7:22   ` Dou Liyang
2018-07-13 11:30     ` Pavel Tatashin
2018-07-16  9:32       ` Dou Liyang [this message]
2018-07-16 13:35         ` Pavel Tatashin
2018-07-17  8:59           ` Dou Liyang
2018-07-17 14:36             ` Pavel Tatashin
2018-07-12  0:04 ` [PATCH v13 14/18] x86/tsc: initialize cyc2ns when tsc freq. is determined Pavel Tatashin
2018-07-13  9:11   ` Dou Liyang
2018-07-13 11:39     ` Pavel Tatashin
2018-07-12  0:04 ` [PATCH v13 15/18] x86/tsc: use tsc early Pavel Tatashin
2018-07-12  0:04 ` [PATCH v13 16/18] sched: move sched clock initialization and merge with generic clock Pavel Tatashin
2018-07-12 23:50   ` kbuild test robot
2018-07-12  0:04 ` [PATCH v13 17/18] sched: early boot clock Pavel Tatashin
2018-07-12  0:04 ` [PATCH v13 18/18] sched: use static key for sched_clock_running Pavel Tatashin

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=01812492-b88b-4436-570b-ef776eaafc6a@cn.fujitsu.com \
    --to=douly.fnst@cn.fujitsu.com \
    --cc=boris.ostrovsky@oracle.com \
    --cc=daniel.m.jordan@oracle.com \
    --cc=feng.tang@intel.com \
    --cc=gnomes@lxorguk.ukuu.org.uk \
    --cc=heiko.carstens@de.ibm.com \
    --cc=hpa@zytor.com \
    --cc=jgross@suse.com \
    --cc=john.stultz@linaro.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-s390@vger.kernel.org \
    --cc=linux@armlinux.org.uk \
    --cc=mingo@redhat.com \
    --cc=pasha.tatashin@oracle.com \
    --cc=peterz@infradead.org \
    --cc=pmladek@suse.com \
    --cc=prarit@redhat.com \
    --cc=sboyd@codeaurora.org \
    --cc=schwidefsky@de.ibm.com \
    --cc=steven.sistare@oracle.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;
as well as URLs for NNTP newsgroup(s).