watchdog: Use local_clock for get_timestamp()
PATCH 1/2 watchdog: Use local_clock for get_timestamp()
From: Namhyung Kim <[email protected]>
The get_timestamp() function is always called with current cpu, thus using local_clock() would be more appropriate and it makes the code shorter and cleaner IMHO.
--- kernel/watchdog.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-)
kernel/watchdog.c +4 -6
@@ -112,9 +112,9 @@ static int get_softlockup_thresh(void)* resolution, and we don't need to waste time with a big divide when * 2^30ns == 1.074s. */ -static unsigned long get_timestamp (int this_cpu) +static unsigned long get_timestamp (void ) { -return cpu_clock (this_cpu) >>30LL ;/* 2^30 ~= 10^9 */ +return local_clock () >>30LL ;/* 2^30 ~= 10^9 */ }static void set_sample_period (void )
@@ -132,9 +132,7 @@ static void set_sample_period(void)/* Commands for resetting the watchdog */ static void __touch_watchdog (void ) { -int this_cpu =smp_processor_id (); - -__this_cpu_write (watchdog_touch_ts,get_timestamp (this_cpu)); +__this_cpu_write (watchdog_touch_ts,get_timestamp ()); }void touch_softlockup_watchdog (void )
@@ -195,7 +193,7 @@ static int is_hardlockup(void)static int is_softlockup (unsigned long touch_ts) { -unsigned long now =get_timestamp (smp_processor_id ()); +unsigned long now =get_timestamp ();/* Warn about unreasonable delays: */ if (time_after (now, touch_ts +get_softlockup_thresh ()))
Signature · 1 line
1.7.11.7
PATCH 2/2 tracing: Use sched_clock_cpu for trace_clock_global
From: Namhyung Kim <[email protected]>
For systems have unstable sched_clock, all cpu_clock() does is enable/ disable local irq during call to sched_clock(). And for stable systems they are same.
As in trace_clock_global(), we already does it for local irq, calling sched_clock_cpu() directly would be appropriate.
--- kernel/trace/trace_clock.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/trace/trace_clock.c +1 -1
@@ -86,7 +86,7 @@ u64 notrace trace_clock_global(void)local_irq_save (flags); this_cpu =raw_smp_processor_id (); - now =cpu_clock (this_cpu); + now =sched_clock_cpu (this_cpu);/* * If in an NMI context then dont risk lockups and return the * cpu_clock() time:
Signature · 1 line
1.7.11.7
Re: [PATCH 2/2] tracing: Use sched_clock_cpu for trace_clock_global
Quoted 4 lines · Namhyung Kim
From: Namhyung Kim <[email protected]>
For systems have unstable
sched_clock, allcpu_clock()does is enable/ disable local irq during call tosched_clock(). And for stable systems
Oops, I meant s/sched_clock/scheck_clock_cpu/.
Thanks,
Namhyung
Quoted 26 lines
they are same.
As in
trace_clock_global(), we already does it for local irq, callingsched_clock_cpu()directly would be appropriate.Cc Steven Rostedt <[email protected]>Cc Fredereic Weisbecker <[email protected]>Cc Ingo Molnar <[email protected]>Signed-off-by Namhyung Kim <[email protected]>--- kernel/trace/trace_clock.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)kernel/trace/trace_clock.c +1
-1@@ -86,7 +86,7 @@ u64 notrace trace_clock_global(void)local_irq_save (flags); this_cpu =raw_smp_processor_id (); - now =cpu_clock (this_cpu); + now =sched_clock_cpu (this_cpu);/* * If in an NMI context then dont risk lockups and return the * cpu_clock() time:
Steven Rostedt
maintainerRe: [PATCH 2/2] tracing: Use sched_clock_cpu for trace_clock_global
Quoted 8 lines · Namhyung Kim
Quoted 4 lines · Namhyung Kim
From: Namhyung Kim <[email protected]>
For systems have unstable
sched_clock, allcpu_clock()does is enable/ disable local irq during call tosched_clock(). And for stable systemsOops, I meant s/sched_clock/scheck_clock_cpu/.
I'll queue this up for 3.9.
Thanks,
-- Steve
[tip:perf/core] tracing: Use sched_clock_cpu for trace_clock_global
In reply to Namhyung KimCommit-ID: 5e67b51e3fb22ad43faf9589e9019ad9c6a00413 Gitweb: http://git.kernel.org/tip/5e67b51e3fb22ad43faf9589e9019ad9c6a00413 Author: Namhyung Kim <[email protected]> AuthorDate: Thu, 27 Dec 2012 11:49:45 +0900 Committer: Steven Rostedt <[email protected]> CommitDate: Wed, 30 Jan 2013 11:02:05 -0500
tracing: Use sched_clock_cpu for trace_clock_global
For systems with an unstable sched_clock, all cpu_clock() does is enable/ disable local irq during the call to sched_clock_cpu(). And for stable systems they are same.
trace_clock_global() already disables interrupts, so it can call sched_clock_cpu() directly.
--- kernel/trace/trace_clock.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/trace/trace_clock.c +1 -1
@@ -84,7 +84,7 @@ u64 notrace trace_clock_global(void)local_irq_save (flags); this_cpu =raw_smp_processor_id (); - now =cpu_clock (this_cpu); + now =sched_clock_cpu (this_cpu);/* * If in an NMI context then dont risk lockups and return the * cpu_clock() time:
Quoted 5 lines · Namhyung Kim
From: Namhyung Kim <[email protected]>
The
get_timestamp()function is always called with current cpu, thus usinglocal_clock()would be more appropriate and it makes the code shorter and cleaner IMHO.
Seems reasonable. Can't think of why it wasn't implemented this way to begin with.
Quoted 48 lines
Cc Don Zickus <[email protected]>Cc Ingo Molnar <[email protected]>Cc Thomas Gleixner <[email protected]>Signed-off-by Namhyung Kim <[email protected]>--- kernel/watchdog.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-)kernel/watchdog.c +4
-6@@ -112,9 +112,9 @@ static int get_softlockup_thresh(void)* resolution, and we don't need to waste time with a big divide when * 2^30ns == 1.074s. */ -static unsigned long get_timestamp (int this_cpu) +static unsigned long get_timestamp (void ) { -return cpu_clock (this_cpu) >>30LL ;/* 2^30 ~= 10^9 */ +return local_clock () >>30LL ;/* 2^30 ~= 10^9 */ }static void set_sample_period (void )@@ -132,9 +132,7 @@ static void set_sample_period(void)/* Commands for resetting the watchdog */ static void __touch_watchdog (void ) { -int this_cpu =smp_processor_id (); - -__this_cpu_write (watchdog_touch_ts,get_timestamp (this_cpu)); +__this_cpu_write (watchdog_touch_ts,get_timestamp ()); }void touch_softlockup_watchdog (void )@@ -195,7 +193,7 @@ static int is_hardlockup(void)static int is_softlockup (unsigned long touch_ts) { -unsigned long now =get_timestamp (smp_processor_id ()); +unsigned long now =get_timestamp ();/* Warn about unreasonable delays: */ if (time_after (now, touch_ts +get_softlockup_thresh ()))Signature · 1 line
1.7.11.7
Commit-ID: 03d8c5dc53d2e883bd3badb6436a33fc64e2f638 Gitweb: http://git.kernel.org/tip/03d8c5dc53d2e883bd3badb6436a33fc64e2f638 Author: Namhyung Kim <[email protected]> AuthorDate: Thu, 27 Dec 2012 11:49:44 +0900 Committer: Ingo Molnar <[email protected]> CommitDate: Thu, 24 Jan 2013 15:13:36 +0100
watchdog: Use local_clock for get_timestamp()
The get_timestamp() function is always called with current cpu, thus using local_clock() would be more appropriate and it makes the code shorter and cleaner IMHO.
--- kernel/watchdog.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-)
kernel/watchdog.c +4 -6
@@ -112,9 +112,9 @@ static int get_softlockup_thresh(void)* resolution, and we don't need to waste time with a big divide when * 2^30ns == 1.074s. */ -static unsigned long get_timestamp (int this_cpu) +static unsigned long get_timestamp (void ) { -return cpu_clock (this_cpu) >>30LL ;/* 2^30 ~= 10^9 */ +return local_clock () >>30LL ;/* 2^30 ~= 10^9 */ }static void set_sample_period (void )
@@ -132,9 +132,7 @@ static void set_sample_period(void)/* Commands for resetting the watchdog */ static void __touch_watchdog (void ) { -int this_cpu =smp_processor_id (); - -__this_cpu_write (watchdog_touch_ts,get_timestamp (this_cpu)); +__this_cpu_write (watchdog_touch_ts,get_timestamp ()); }void touch_softlockup_watchdog (void )
@@ -195,7 +193,7 @@ static int is_hardlockup(void)static int is_softlockup (unsigned long touch_ts) { -unsigned long now =get_timestamp (smp_processor_id ()); +unsigned long now =get_timestamp ();/* Warn about unreasonable delays: */ if (time_after (now, touch_ts +get_softlockup_thresh ()))
tip-bot for Namhyung Kim
merge botwatchdog: Use local_clock for get_timestamp()
Commit-ID: c06b4f1947213cd0902610fafcabac02d49ad728 Gitweb: http://git.kernel.org/tip/c06b4f1947213cd0902610fafcabac02d49ad728 Author: Namhyung Kim <[email protected]> AuthorDate: Thu, 27 Dec 2012 11:49:44 +0900 Committer: Ingo Molnar <[email protected]> CommitDate: Tue, 19 Feb 2013 08:42:40 +0100
watchdog: Use local_clock for get_timestamp()
The get_timestamp() function is always called with current cpu, thus using local_clock() would be more appropriate and it makes the code shorter and cleaner IMHO.
--- kernel/watchdog.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-)
kernel/watchdog.c +4 -6
@@ -112,9 +112,9 @@ static int get_softlockup_thresh(void)* resolution, and we don't need to waste time with a big divide when * 2^30ns == 1.074s. */ -static unsigned long get_timestamp (int this_cpu) +static unsigned long get_timestamp (void ) { -return cpu_clock (this_cpu) >>30LL ;/* 2^30 ~= 10^9 */ +return local_clock () >>30LL ;/* 2^30 ~= 10^9 */ }static void set_sample_period (void )
@@ -132,9 +132,7 @@ static void set_sample_period(void)/* Commands for resetting the watchdog */ static void __touch_watchdog (void ) { -int this_cpu =smp_processor_id (); - -__this_cpu_write (watchdog_touch_ts,get_timestamp (this_cpu)); +__this_cpu_write (watchdog_touch_ts,get_timestamp ()); }void touch_softlockup_watchdog (void )
@@ -195,7 +193,7 @@ static int is_hardlockup(void)static int is_softlockup (unsigned long touch_ts) { -unsigned long now =get_timestamp (smp_processor_id ()); +unsigned long now =get_timestamp ();/* Warn about unreasonable delays: */ if (time_after (now, touch_ts +get_softlockup_thresh ()))