Skip to contentSkip to conversation

watchdog: Use local_clock for get_timestamp()

PATCH In review Namhyung Kim 5 participants 8 messages Dec 27, 2012 – Feb 22, 2013 Tracing

lore
Share & tools
lore
#0 lore raw

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.

Cc Don Zickus <[email protected]>
Cc Ingo Molnar <[email protected]>
Cc Thomas Gleixner <[email protected]>
---
 kernel/watchdog.c | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)
kernel/watchdog.c +4 -6
index 75a2ab3d0b02..082ca6878a3f 100644
@@ -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
#1 lore raw

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.

Cc Steven Rostedt <[email protected]>
Cc Fredereic Weisbecker <[email protected]>
Cc Ingo Molnar <[email protected]>
---
 kernel/trace/trace_clock.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/trace/trace_clock.c +1 -1
index 394783531cbb..795f077978a8 100644
@@ -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
#2 lore raw

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, all cpu_clock() does is enable/ disable local irq during call to sched_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, calling sched_clock_cpu() directly would be appropriate.

Cc Steven Rostedt <[email protected]>
Cc Fredereic Weisbecker <[email protected]>
Cc Ingo Molnar <[email protected]>
---
 kernel/trace/trace_clock.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/trace/trace_clock.c +1 -1
index 394783531cbb..795f077978a8 100644
@@ -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:
maintainer
#3 lore raw

Re: [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, all cpu_clock() does is enable/ disable local irq during call to sched_clock(). And for stable systems

Oops, I meant s/sched_clock/scheck_clock_cpu/.

I'll queue this up for 3.9.

Thanks,

-- Steve

#4 lore raw

[tip:perf/core] tracing: Use sched_clock_cpu for trace_clock_global

In reply to Namhyung Kim
Commit-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
index 22b638b..24bf48e 100644
@@ -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:
Acked-by on v1 1/2
#5 lore raw
In reply to Namhyung Kim
Quoted 5 lines · Namhyung Kim

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.

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]>
---
 kernel/watchdog.c | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)
kernel/watchdog.c +4 -6
index 75a2ab3d0b02..082ca6878a3f 100644
@@ -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
#6 lore raw
In reply to Namhyung Kim
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
index 75a2ab3..082ca68 100644
@@ -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()))
#7 lore raw
In reply to Namhyung Kim
watchdog: 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
index 75a2ab3..082ca68 100644
@@ -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()))