* [PATCH 0/2] Two cleanup patches
@ 2018-07-30 7:54 Dou Liyang
2018-07-30 7:54 ` [PATCH 1/2] x86/tsc: Avoid a double call if TSC initializes earlier Dou Liyang
2018-07-30 7:54 ` [PATCH 2/2] x86/kvmclock: Mark kvm_get_preset_lpj() as __init Dou Liyang
0 siblings, 2 replies; 9+ messages in thread
From: Dou Liyang @ 2018-07-30 7:54 UTC (permalink / raw)
To: linux-kernel, x86; +Cc: tglx, mingo, hpa, Dou Liyang
Here are two cleanup patches, When I test the early boot time stamps
with tip tree today.
Dou Liyang (2):
x86/tsc: Avoid a double call if tsc can initialize earlier.
x86/kvmclock: Mark kvm_get_preset_lpj() as __init
arch/x86/kernel/kvmclock.c | 2 +-
arch/x86/kernel/tsc.c | 22 ++++++++++++----------
2 files changed, 13 insertions(+), 11 deletions(-)
--
2.14.3
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH 1/2] x86/tsc: Avoid a double call if TSC initializes earlier.
2018-07-30 7:54 [PATCH 0/2] Two cleanup patches Dou Liyang
@ 2018-07-30 7:54 ` Dou Liyang
2018-07-30 9:34 ` Peter Zijlstra
` (2 more replies)
2018-07-30 7:54 ` [PATCH 2/2] x86/kvmclock: Mark kvm_get_preset_lpj() as __init Dou Liyang
1 sibling, 3 replies; 9+ messages in thread
From: Dou Liyang @ 2018-07-30 7:54 UTC (permalink / raw)
To: linux-kernel, x86
Cc: tglx, mingo, hpa, Dou Liyang, Peter Zijlstra, Pavel Tatashin
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@linutronix.de>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: "H. Peter Anvin" <hpa@zytor.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Pavel Tatashin <pasha.tatashin@oracle.com>
Signed-off-by: Dou Liyang <douly.fnst@cn.fujitsu.com>
---
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
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH 2/2] x86/kvmclock: Mark kvm_get_preset_lpj() as __init
2018-07-30 7:54 [PATCH 0/2] Two cleanup patches Dou Liyang
2018-07-30 7:54 ` [PATCH 1/2] x86/tsc: Avoid a double call if TSC initializes earlier Dou Liyang
@ 2018-07-30 7:54 ` Dou Liyang
2018-07-30 14:17 ` Pavel Tatashin
2018-07-30 17:38 ` [tip:x86/timers] " tip-bot for Dou Liyang
1 sibling, 2 replies; 9+ messages in thread
From: Dou Liyang @ 2018-07-30 7:54 UTC (permalink / raw)
To: linux-kernel, x86
Cc: tglx, mingo, hpa, Dou Liyang, Paolo Bonzini,
Radim Krčmář,
kvm
kvm_get_preset_lpj() just be called at kvmclock_init(), So mark it
__init as well.
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: "H. Peter Anvin" <hpa@zytor.com>
Cc: Paolo Bonzini <pbonzini@redhat.com>
Cc: "Radim Krčmář" <rkrcmar@redhat.com>
Cc: kvm@vger.kernel.org
Signed-off-by: Dou Liyang <douly.fnst@cn.fujitsu.com>
---
arch/x86/kernel/kvmclock.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/arch/x86/kernel/kvmclock.c b/arch/x86/kernel/kvmclock.c
index 91b94c0ae4e3..d2edd7e6c294 100644
--- a/arch/x86/kernel/kvmclock.c
+++ b/arch/x86/kernel/kvmclock.c
@@ -145,7 +145,7 @@ static unsigned long kvm_get_tsc_khz(void)
return pvclock_tsc_khz(this_cpu_pvti());
}
-static void kvm_get_preset_lpj(void)
+static void __init kvm_get_preset_lpj(void)
{
unsigned long khz;
u64 lpj;
--
2.14.3
^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: [PATCH 1/2] x86/tsc: Avoid a double call if TSC initializes earlier.
2018-07-30 7:54 ` [PATCH 1/2] x86/tsc: Avoid a double call if TSC initializes earlier Dou Liyang
@ 2018-07-30 9:34 ` Peter Zijlstra
2018-07-30 9:53 ` Dou Liyang
2018-07-30 14:09 ` Pavel Tatashin
2018-07-30 17:37 ` [tip:x86/timers] x86/tsc: Consolidate init code tip-bot for Dou Liyang
2 siblings, 1 reply; 9+ messages in thread
From: Peter Zijlstra @ 2018-07-30 9:34 UTC (permalink / raw)
To: Dou Liyang; +Cc: linux-kernel, x86, tglx, mingo, hpa, Pavel Tatashin
On Mon, Jul 30, 2018 at 03:54:20PM +0800, Dou Liyang wrote:
> static_branch_enable(&__use_tsc) may be called twice in common case, that
> is redundant.
It is also really not a problem...
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH 1/2] x86/tsc: Avoid a double call if TSC initializes earlier.
2018-07-30 9:34 ` Peter Zijlstra
@ 2018-07-30 9:53 ` Dou Liyang
0 siblings, 0 replies; 9+ messages in thread
From: Dou Liyang @ 2018-07-30 9:53 UTC (permalink / raw)
To: Peter Zijlstra; +Cc: linux-kernel, x86, tglx, mingo, hpa, Pavel Tatashin
Hi Peter,
At 07/30/2018 05:34 PM, Peter Zijlstra wrote:
> On Mon, Jul 30, 2018 at 03:54:20PM +0800, Dou Liyang wrote:
>> static_branch_enable(&__use_tsc) may be called twice in common case, that
>> is redundant.
>
> It is also really not a problem...
>
Yes, right. Just avoid the second useless setting.
Thanks,
dou
>
>
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH 1/2] x86/tsc: Avoid a double call if TSC initializes earlier.
2018-07-30 7:54 ` [PATCH 1/2] x86/tsc: Avoid a double call if TSC initializes earlier Dou Liyang
2018-07-30 9:34 ` Peter Zijlstra
@ 2018-07-30 14:09 ` Pavel Tatashin
2018-07-30 17:37 ` [tip:x86/timers] x86/tsc: Consolidate init code tip-bot for Dou Liyang
2 siblings, 0 replies; 9+ messages in thread
From: Pavel Tatashin @ 2018-07-30 14:09 UTC (permalink / raw)
To: douly.fnst; +Cc: LKML, x86, tglx, mingo, hpa, peterz
On Mon, Jul 30, 2018 at 3:55 AM Dou Liyang <douly.fnst@cn.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@linutronix.de>
> Cc: Ingo Molnar <mingo@redhat.com>
> Cc: "H. Peter Anvin" <hpa@zytor.com>
> Cc: Peter Zijlstra <peterz@infradead.org>
> Cc: Pavel Tatashin <pasha.tatashin@oracle.com>
> Signed-off-by: Dou Liyang <douly.fnst@cn.fujitsu.com>
Hi Dou,
Nice cleanup.
Reviewed-by: Pavel Tatashin <pasha.tatashin@oracle.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
>
>
>
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH 2/2] x86/kvmclock: Mark kvm_get_preset_lpj() as __init
2018-07-30 7:54 ` [PATCH 2/2] x86/kvmclock: Mark kvm_get_preset_lpj() as __init Dou Liyang
@ 2018-07-30 14:17 ` Pavel Tatashin
2018-07-30 17:38 ` [tip:x86/timers] " tip-bot for Dou Liyang
1 sibling, 0 replies; 9+ messages in thread
From: Pavel Tatashin @ 2018-07-30 14:17 UTC (permalink / raw)
To: douly.fnst; +Cc: LKML, x86, tglx, mingo, hpa, pbonzini, rkrcmar, kvm
On Mon, Jul 30, 2018 at 3:55 AM Dou Liyang <douly.fnst@cn.fujitsu.com> wrote:
>
> kvm_get_preset_lpj() just be called at kvmclock_init(), So mark it
> __init as well.
Reviewed-by: Pavel Tatashin <pasha.tatashin@oracle.com>
Thank you,
Pavel
^ permalink raw reply [flat|nested] 9+ messages in thread
* [tip:x86/timers] x86/tsc: Consolidate init code
2018-07-30 7:54 ` [PATCH 1/2] x86/tsc: Avoid a double call if TSC initializes earlier Dou Liyang
2018-07-30 9:34 ` Peter Zijlstra
2018-07-30 14:09 ` Pavel Tatashin
@ 2018-07-30 17:37 ` tip-bot for Dou Liyang
2 siblings, 0 replies; 9+ messages in thread
From: tip-bot for Dou Liyang @ 2018-07-30 17:37 UTC (permalink / raw)
To: linux-tip-commits
Cc: tglx, peterz, hpa, mingo, pasha.tatashin, linux-kernel, douly.fnst
Commit-ID: 608008a45798fe9e2aee04f99b5270ea57c1376f
Gitweb: https://git.kernel.org/tip/608008a45798fe9e2aee04f99b5270ea57c1376f
Author: Dou Liyang <douly.fnst@cn.fujitsu.com>
AuthorDate: Mon, 30 Jul 2018 15:54:20 +0800
Committer: Thomas Gleixner <tglx@linutronix.de>
CommitDate: Mon, 30 Jul 2018 19:33:35 +0200
x86/tsc: Consolidate init code
Split out suplicated code from tsc_early_init() and tsc_init() into a
common helper and fixup some comment typos.
[ tglx: Massaged changelog and renamed function ]
Signed-off-by: Dou Liyang <douly.fnst@cn.fujitsu.com>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Reviewed-by: Pavel Tatashin <pasha.tatashin@oracle.com>
Cc: <hpa@zytor.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: "H. Peter Anvin" <hpa@zytor.com>
Link: https://lkml.kernel.org/r/20180730075421.22830-2-douly.fnst@cn.fujitsu.com
---
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..1463468ba9a0 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 tsc_enable_sched_clock(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);
+ tsc_enable_sched_clock();
}
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();
+ tsc_enable_sched_clock();
}
cyc2ns_init_secondary_cpus();
- static_branch_enable(&__use_tsc);
if (!no_sched_irq_time)
enable_sched_clock_irqtime();
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [tip:x86/timers] x86/kvmclock: Mark kvm_get_preset_lpj() as __init
2018-07-30 7:54 ` [PATCH 2/2] x86/kvmclock: Mark kvm_get_preset_lpj() as __init Dou Liyang
2018-07-30 14:17 ` Pavel Tatashin
@ 2018-07-30 17:38 ` tip-bot for Dou Liyang
1 sibling, 0 replies; 9+ messages in thread
From: tip-bot for Dou Liyang @ 2018-07-30 17:38 UTC (permalink / raw)
To: linux-tip-commits
Cc: pasha.tatashin, pbonzini, mingo, tglx, linux-kernel, rkrcmar,
douly.fnst, kvm, hpa
Commit-ID: 1088c6eef261939bda8346ec35b513790a2111d5
Gitweb: https://git.kernel.org/tip/1088c6eef261939bda8346ec35b513790a2111d5
Author: Dou Liyang <douly.fnst@cn.fujitsu.com>
AuthorDate: Mon, 30 Jul 2018 15:54:21 +0800
Committer: Thomas Gleixner <tglx@linutronix.de>
CommitDate: Mon, 30 Jul 2018 19:33:35 +0200
x86/kvmclock: Mark kvm_get_preset_lpj() as __init
kvm_get_preset_lpj() is only called from kvmclock_init(), so mark it __init
as well.
Signed-off-by: Dou Liyang <douly.fnst@cn.fujitsu.com>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Reviewed-by: Pavel Tatashin <pasha.tatashin@oracle.com>
Cc: <hpa@zytor.com>
Cc: Paolo Bonzini <pbonzini@redhat.com>
Cc: Radim Krčmář<rkrcmar@redhat.com>
Cc: <kvm@vger.kernel.org>
Cc: "H. Peter Anvin" <hpa@zytor.com>
Cc: "Radim Krčmář" <rkrcmar@redhat.com>
Cc: kvm@vger.kernel.org
Link: https://lkml.kernel.org/r/20180730075421.22830-3-douly.fnst@cn.fujitsu.com
---
arch/x86/kernel/kvmclock.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/arch/x86/kernel/kvmclock.c b/arch/x86/kernel/kvmclock.c
index 91b94c0ae4e3..d2edd7e6c294 100644
--- a/arch/x86/kernel/kvmclock.c
+++ b/arch/x86/kernel/kvmclock.c
@@ -145,7 +145,7 @@ static unsigned long kvm_get_tsc_khz(void)
return pvclock_tsc_khz(this_cpu_pvti());
}
-static void kvm_get_preset_lpj(void)
+static void __init kvm_get_preset_lpj(void)
{
unsigned long khz;
u64 lpj;
^ permalink raw reply related [flat|nested] 9+ messages in thread
end of thread, other threads:[~2018-07-30 17:38 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-07-30 7:54 [PATCH 0/2] Two cleanup patches Dou Liyang
2018-07-30 7:54 ` [PATCH 1/2] x86/tsc: Avoid a double call if TSC initializes earlier Dou Liyang
2018-07-30 9:34 ` Peter Zijlstra
2018-07-30 9:53 ` Dou Liyang
2018-07-30 14:09 ` Pavel Tatashin
2018-07-30 17:37 ` [tip:x86/timers] x86/tsc: Consolidate init code tip-bot for Dou Liyang
2018-07-30 7:54 ` [PATCH 2/2] x86/kvmclock: Mark kvm_get_preset_lpj() as __init Dou Liyang
2018-07-30 14:17 ` Pavel Tatashin
2018-07-30 17:38 ` [tip:x86/timers] " tip-bot for Dou Liyang
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).