linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH/Resend] timer stats: add quick check to avoid function calls
@ 2009-06-23 14:12 Heiko Carstens
  2009-06-23 15:08 ` Ingo Molnar
  0 siblings, 1 reply; 4+ messages in thread
From: Heiko Carstens @ 2009-06-23 14:12 UTC (permalink / raw)
  To: Thomas Gleixner, Andrew Morton
  Cc: Martin Schwidefsky, Mustafa Mesanovic, Arjan van de Ven,
	Ingo Molnar, linux-kernel

From: Heiko Carstens <heiko.carstens@de.ibm.com>

When the kernel is configured with CONFIG_TIMER_STATS but timer stats
are runtime disabled we still get calls to __timer_stats_timer_set_start_info
which initializes some fields in the corresponding struct timer_list.

So add some quick checks in the the timer stats setup functions to avoid
function calls to __timer_stats_timer_set_start_info when timer stats are
disabled.

In an artificial workload that does nothing but playing ping pong with a
single tcp packet via loopback this decreases cpu consumption by 1 - 1.5%.

This is part of a modified function trace output on SLES11:

perl-2497  [00] 28630647177732388 [+  125]: sk_reset_timer <-tcp_v4_rcv
perl-2497  [00] 28630647177732513 [+  125]: mod_timer <-sk_reset_timer
perl-2497  [00] 28630647177732638 [+  125]: __timer_stats_timer_set_start_info <-mod_timer
perl-2497  [00] 28630647177732763 [+  125]: __mod_timer <-mod_timer
perl-2497  [00] 28630647177732888 [+  125]: __timer_stats_timer_set_start_info <-__mod_timer
perl-2497  [00] 28630647177733013 [+   93]: lock_timer_base <-__mod_timer

Signed-off-by: Heiko Carstens <heiko.carstens@de.ibm.com>
---

 include/linux/hrtimer.h   |    6 ++++++
 include/linux/timer.h     |    4 ++++
 kernel/time/timer_stats.c |   16 ++++++++--------
 kernel/timer.c            |    2 ++
 4 files changed, 20 insertions(+), 8 deletions(-)

Index: linux-2.6/include/linux/hrtimer.h
===================================================================
--- linux-2.6.orig/include/linux/hrtimer.h
+++ linux-2.6/include/linux/hrtimer.h
@@ -438,12 +438,16 @@ extern void sysrq_timer_list_show(void);
  */
 #ifdef CONFIG_TIMER_STATS
 
+extern int timer_stats_active;
+
 extern void timer_stats_update_stats(void *timer, pid_t pid, void *startf,
 				     void *timerf, char *comm,
 				     unsigned int timer_flag);
 
 static inline void timer_stats_account_hrtimer(struct hrtimer *timer)
 {
+	if (likely(!timer->start_pid))
+		return;
 	timer_stats_update_stats(timer, timer->start_pid, timer->start_site,
 				 timer->function, timer->start_comm, 0);
 }
@@ -453,6 +457,8 @@ extern void __timer_stats_hrtimer_set_st
 
 static inline void timer_stats_hrtimer_set_start_info(struct hrtimer *timer)
 {
+	if (likely(!timer_stats_active))
+		return;
 	__timer_stats_hrtimer_set_start_info(timer, __builtin_return_address(0));
 }
 
Index: linux-2.6/include/linux/timer.h
===================================================================
--- linux-2.6.orig/include/linux/timer.h
+++ linux-2.6/include/linux/timer.h
@@ -187,6 +187,8 @@ extern unsigned long get_next_timer_inte
  */
 #ifdef CONFIG_TIMER_STATS
 
+extern int timer_stats_active;
+
 #define TIMER_STATS_FLAG_DEFERRABLE	0x1
 
 extern void init_timer_stats(void);
@@ -200,6 +202,8 @@ extern void __timer_stats_timer_set_star
 
 static inline void timer_stats_timer_set_start_info(struct timer_list *timer)
 {
+	if (likely(!timer_stats_active))
+		return;
 	__timer_stats_timer_set_start_info(timer, __builtin_return_address(0));
 }
 
Index: linux-2.6/kernel/timer.c
===================================================================
--- linux-2.6.orig/kernel/timer.c
+++ linux-2.6/kernel/timer.c
@@ -378,6 +378,8 @@ static void timer_stats_account_timer(st
 {
 	unsigned int flag = 0;
 
+	if (likely(!timer->start_site))
+		return;
 	if (unlikely(tbase_get_deferrable(timer->base)))
 		flag |= TIMER_STATS_FLAG_DEFERRABLE;
 
Index: linux-2.6/kernel/time/timer_stats.c
===================================================================
--- linux-2.6.orig/kernel/time/timer_stats.c
+++ linux-2.6/kernel/time/timer_stats.c
@@ -96,7 +96,7 @@ static DEFINE_MUTEX(show_mutex);
 /*
  * Collection status, active/inactive:
  */
-static int __read_mostly active;
+int __read_mostly timer_stats_active;
 
 /*
  * Beginning/end timestamps of measurement:
@@ -242,7 +242,7 @@ void timer_stats_update_stats(void *time
 	struct entry *entry, input;
 	unsigned long flags;
 
-	if (likely(!active))
+	if (likely(!timer_stats_active))
 		return;
 
 	lock = &per_cpu(lookup_lock, raw_smp_processor_id());
@@ -254,7 +254,7 @@ void timer_stats_update_stats(void *time
 	input.timer_flag = timer_flag;
 
 	spin_lock_irqsave(lock, flags);
-	if (!active)
+	if (!timer_stats_active)
 		goto out_unlock;
 
 	entry = tstat_lookup(&input, comm);
@@ -290,7 +290,7 @@ static int tstats_show(struct seq_file *
 	/*
 	 * If still active then calculate up to now:
 	 */
-	if (active)
+	if (timer_stats_active)
 		time_stop = ktime_get();
 
 	time = ktime_sub(time_stop, time_start);
@@ -368,18 +368,18 @@ static ssize_t tstats_write(struct file 
 	mutex_lock(&show_mutex);
 	switch (ctl[0]) {
 	case '0':
-		if (active) {
-			active = 0;
+		if (timer_stats_active) {
+			timer_stats_active = 0;
 			time_stop = ktime_get();
 			sync_access();
 		}
 		break;
 	case '1':
-		if (!active) {
+		if (!timer_stats_active) {
 			reset_entries();
 			time_start = ktime_get();
 			smp_mb();
-			active = 1;
+			timer_stats_active = 1;
 		}
 		break;
 	default:

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH/Resend] timer stats: add quick check to avoid function calls
  2009-06-23 14:12 [PATCH/Resend] timer stats: add quick check to avoid function calls Heiko Carstens
@ 2009-06-23 15:08 ` Ingo Molnar
  2009-06-23 15:38   ` Heiko Carstens
  0 siblings, 1 reply; 4+ messages in thread
From: Ingo Molnar @ 2009-06-23 15:08 UTC (permalink / raw)
  To: Heiko Carstens
  Cc: Thomas Gleixner, Andrew Morton, Martin Schwidefsky,
	Mustafa Mesanovic, Arjan van de Ven, linux-kernel


* Heiko Carstens <heiko.carstens@de.ibm.com> wrote:

> From: Heiko Carstens <heiko.carstens@de.ibm.com>
> 
> When the kernel is configured with CONFIG_TIMER_STATS but timer stats
> are runtime disabled we still get calls to __timer_stats_timer_set_start_info
> which initializes some fields in the corresponding struct timer_list.
> 
> So add some quick checks in the the timer stats setup functions to avoid
> function calls to __timer_stats_timer_set_start_info when timer stats are
> disabled.
> 
> In an artificial workload that does nothing but playing ping pong with a
> single tcp packet via loopback this decreases cpu consumption by 1 - 1.5%.
> 
> This is part of a modified function trace output on SLES11:
> 
> perl-2497  [00] 28630647177732388 [+  125]: sk_reset_timer <-tcp_v4_rcv
> perl-2497  [00] 28630647177732513 [+  125]: mod_timer <-sk_reset_timer
> perl-2497  [00] 28630647177732638 [+  125]: __timer_stats_timer_set_start_info <-mod_timer
> perl-2497  [00] 28630647177732763 [+  125]: __mod_timer <-mod_timer
> perl-2497  [00] 28630647177732888 [+  125]: __timer_stats_timer_set_start_info <-__mod_timer
> perl-2497  [00] 28630647177733013 [+   93]: lock_timer_base <-__mod_timer

makes sense.

Only one very small detail:

> 
> Signed-off-by: Heiko Carstens <heiko.carstens@de.ibm.com>
> ---
> 
>  include/linux/hrtimer.h   |    6 ++++++
>  include/linux/timer.h     |    4 ++++
>  kernel/time/timer_stats.c |   16 ++++++++--------
>  kernel/timer.c            |    2 ++
>  4 files changed, 20 insertions(+), 8 deletions(-)
> 
> Index: linux-2.6/include/linux/hrtimer.h
> ===================================================================
> --- linux-2.6.orig/include/linux/hrtimer.h
> +++ linux-2.6/include/linux/hrtimer.h
> @@ -438,12 +438,16 @@ extern void sysrq_timer_list_show(void);
>   */
>  #ifdef CONFIG_TIMER_STATS
>  
> +extern int timer_stats_active;
> +
>  extern void timer_stats_update_stats(void *timer, pid_t pid, void *startf,
>  				     void *timerf, char *comm,
>  				     unsigned int timer_flag);
>  
>  static inline void timer_stats_account_hrtimer(struct hrtimer *timer)
>  {
> +	if (likely(!timer->start_pid))
> +		return;
>  	timer_stats_update_stats(timer, timer->start_pid, timer->start_site,
>  				 timer->function, timer->start_comm, 0);
>  }
> @@ -453,6 +457,8 @@ extern void __timer_stats_hrtimer_set_st
>  
>  static inline void timer_stats_hrtimer_set_start_info(struct hrtimer *timer)
>  {
> +	if (likely(!timer_stats_active))
> +		return;
>  	__timer_stats_hrtimer_set_start_info(timer, __builtin_return_address(0));
>  }
>  
> Index: linux-2.6/include/linux/timer.h
> ===================================================================
> --- linux-2.6.orig/include/linux/timer.h
> +++ linux-2.6/include/linux/timer.h
> @@ -187,6 +187,8 @@ extern unsigned long get_next_timer_inte
>   */
>  #ifdef CONFIG_TIMER_STATS
>  
> +extern int timer_stats_active;

Why is this declared twice, once in hrtimer.h and once in timer.h? 
One should suffice, right?

	Ingo

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH/Resend] timer stats: add quick check to avoid function calls
  2009-06-23 15:08 ` Ingo Molnar
@ 2009-06-23 15:38   ` Heiko Carstens
  2009-06-24  9:47     ` [tip:timers/urgent] timer stats: Optimize by adding " tip-bot for Heiko Carstens
  0 siblings, 1 reply; 4+ messages in thread
From: Heiko Carstens @ 2009-06-23 15:38 UTC (permalink / raw)
  To: Ingo Molnar
  Cc: Thomas Gleixner, Andrew Morton, Martin Schwidefsky,
	Mustafa Mesanovic, Arjan van de Ven, linux-kernel

On Tue, Jun 23, 2009 at 05:08:03PM +0200, Ingo Molnar wrote:
> 
> * Heiko Carstens <heiko.carstens@de.ibm.com> wrote:
> 
> > From: Heiko Carstens <heiko.carstens@de.ibm.com>
> > 
> > When the kernel is configured with CONFIG_TIMER_STATS but timer stats
> > are runtime disabled we still get calls to __timer_stats_timer_set_start_info
> > which initializes some fields in the corresponding struct timer_list.
> > 
> > So add some quick checks in the the timer stats setup functions to avoid
> > function calls to __timer_stats_timer_set_start_info when timer stats are
> > disabled.
> > 
> > In an artificial workload that does nothing but playing ping pong with a
> > single tcp packet via loopback this decreases cpu consumption by 1 - 1.5%.
> > 
> > This is part of a modified function trace output on SLES11:
> > 
> > perl-2497  [00] 28630647177732388 [+  125]: sk_reset_timer <-tcp_v4_rcv
> > perl-2497  [00] 28630647177732513 [+  125]: mod_timer <-sk_reset_timer
> > perl-2497  [00] 28630647177732638 [+  125]: __timer_stats_timer_set_start_info <-mod_timer
> > perl-2497  [00] 28630647177732763 [+  125]: __mod_timer <-mod_timer
> > perl-2497  [00] 28630647177732888 [+  125]: __timer_stats_timer_set_start_info <-__mod_timer
> > perl-2497  [00] 28630647177733013 [+   93]: lock_timer_base <-__mod_timer
> 
> makes sense.
> 
> Only one very small detail:

[..]

> > Index: linux-2.6/include/linux/timer.h
> > ===================================================================
> > --- linux-2.6.orig/include/linux/timer.h
> > +++ linux-2.6/include/linux/timer.h
> > @@ -187,6 +187,8 @@ extern unsigned long get_next_timer_inte
> >   */
> >  #ifdef CONFIG_TIMER_STATS
> >  
> > +extern int timer_stats_active;
> 
> Why is this declared twice, once in hrtimer.h and once in timer.h? 
> One should suffice, right?

Actually I only followed the example of timer_stats_update_stats()
which is declared also in both files.
But including timer.h from hrtimer.h doesn't bring up any compile
breakages on the few configs I tested.
Updated patch which avoids the double declaration but adds an
include of timer.h to hrtimer.h

Subject: [PATCH] timer stats: add quick check to avoid function calls

From: Heiko Carstens <heiko.carstens@de.ibm.com>

When the kernel is configured with CONFIG_TIMER_STATS but timer stats
are runtime disabled we still get calls to __timer_stats_timer_set_start_info
which initializes some fields in the corresponding struct timer_list.

So add some quick checks in the the timer stats setup functions to avoid
function calls to __timer_stats_timer_set_start_info when timer stats are
disabled.

In an artificial workload that does nothing but playing ping pong with a
single tcp packet via loopback this decreases cpu consumption by 1 - 1.5%.

This is part of a modified function trace output on SLES11:

perl-2497  [00] 28630647177732388 [+  125]: sk_reset_timer <-tcp_v4_rcv
perl-2497  [00] 28630647177732513 [+  125]: mod_timer <-sk_reset_timer
perl-2497  [00] 28630647177732638 [+  125]: __timer_stats_timer_set_start_info <-mod_timer
perl-2497  [00] 28630647177732763 [+  125]: __mod_timer <-mod_timer
perl-2497  [00] 28630647177732888 [+  125]: __timer_stats_timer_set_start_info <-__mod_timer
perl-2497  [00] 28630647177733013 [+   93]: lock_timer_base <-__mod_timer

Signed-off-by: Heiko Carstens <heiko.carstens@de.ibm.com>
---

 include/linux/hrtimer.h   |    5 +++++
 include/linux/timer.h     |    4 ++++
 kernel/time/timer_stats.c |   16 ++++++++--------
 kernel/timer.c            |    2 ++
 4 files changed, 19 insertions(+), 8 deletions(-)

Index: linux-2.6/include/linux/hrtimer.h
===================================================================
--- linux-2.6.orig/include/linux/hrtimer.h
+++ linux-2.6/include/linux/hrtimer.h
@@ -21,6 +21,7 @@
 #include <linux/list.h>
 #include <linux/wait.h>
 #include <linux/percpu.h>
+#include <linux/timer.h>
 
 
 struct hrtimer_clock_base;
@@ -447,6 +448,8 @@ extern void timer_stats_update_stats(voi
 
 static inline void timer_stats_account_hrtimer(struct hrtimer *timer)
 {
+	if (likely(!timer->start_pid))
+		return;
 	timer_stats_update_stats(timer, timer->start_pid, timer->start_site,
 				 timer->function, timer->start_comm, 0);
 }
@@ -456,6 +459,8 @@ extern void __timer_stats_hrtimer_set_st
 
 static inline void timer_stats_hrtimer_set_start_info(struct hrtimer *timer)
 {
+	if (likely(!timer_stats_active))
+		return;
 	__timer_stats_hrtimer_set_start_info(timer, __builtin_return_address(0));
 }
 
Index: linux-2.6/include/linux/timer.h
===================================================================
--- linux-2.6.orig/include/linux/timer.h
+++ linux-2.6/include/linux/timer.h
@@ -190,6 +190,8 @@ extern unsigned long get_next_timer_inte
  */
 #ifdef CONFIG_TIMER_STATS
 
+extern int timer_stats_active;
+
 #define TIMER_STATS_FLAG_DEFERRABLE	0x1
 
 extern void init_timer_stats(void);
@@ -203,6 +205,8 @@ extern void __timer_stats_timer_set_star
 
 static inline void timer_stats_timer_set_start_info(struct timer_list *timer)
 {
+	if (likely(!timer_stats_active))
+		return;
 	__timer_stats_timer_set_start_info(timer, __builtin_return_address(0));
 }
 
Index: linux-2.6/kernel/timer.c
===================================================================
--- linux-2.6.orig/kernel/timer.c
+++ linux-2.6/kernel/timer.c
@@ -380,6 +380,8 @@ static void timer_stats_account_timer(st
 {
 	unsigned int flag = 0;
 
+	if (likely(!timer->start_site))
+		return;
 	if (unlikely(tbase_get_deferrable(timer->base)))
 		flag |= TIMER_STATS_FLAG_DEFERRABLE;
 
Index: linux-2.6/kernel/time/timer_stats.c
===================================================================
--- linux-2.6.orig/kernel/time/timer_stats.c
+++ linux-2.6/kernel/time/timer_stats.c
@@ -96,7 +96,7 @@ static DEFINE_MUTEX(show_mutex);
 /*
  * Collection status, active/inactive:
  */
-static int __read_mostly active;
+int __read_mostly timer_stats_active;
 
 /*
  * Beginning/end timestamps of measurement:
@@ -242,7 +242,7 @@ void timer_stats_update_stats(void *time
 	struct entry *entry, input;
 	unsigned long flags;
 
-	if (likely(!active))
+	if (likely(!timer_stats_active))
 		return;
 
 	lock = &per_cpu(lookup_lock, raw_smp_processor_id());
@@ -254,7 +254,7 @@ void timer_stats_update_stats(void *time
 	input.timer_flag = timer_flag;
 
 	spin_lock_irqsave(lock, flags);
-	if (!active)
+	if (!timer_stats_active)
 		goto out_unlock;
 
 	entry = tstat_lookup(&input, comm);
@@ -290,7 +290,7 @@ static int tstats_show(struct seq_file *
 	/*
 	 * If still active then calculate up to now:
 	 */
-	if (active)
+	if (timer_stats_active)
 		time_stop = ktime_get();
 
 	time = ktime_sub(time_stop, time_start);
@@ -368,18 +368,18 @@ static ssize_t tstats_write(struct file 
 	mutex_lock(&show_mutex);
 	switch (ctl[0]) {
 	case '0':
-		if (active) {
-			active = 0;
+		if (timer_stats_active) {
+			timer_stats_active = 0;
 			time_stop = ktime_get();
 			sync_access();
 		}
 		break;
 	case '1':
-		if (!active) {
+		if (!timer_stats_active) {
 			reset_entries();
 			time_start = ktime_get();
 			smp_mb();
-			active = 1;
+			timer_stats_active = 1;
 		}
 		break;
 	default:

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [tip:timers/urgent] timer stats: Optimize by adding quick check to avoid function calls
  2009-06-23 15:38   ` Heiko Carstens
@ 2009-06-24  9:47     ` tip-bot for Heiko Carstens
  0 siblings, 0 replies; 4+ messages in thread
From: tip-bot for Heiko Carstens @ 2009-06-24  9:47 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: linux-kernel, hpa, mingo, schwidefsky, arjan, akpm,
	mustafa.mesanovic, heiko.carstens, tglx, mingo

Commit-ID:  507e123151149e578c9aae33eb876c49824da5f8
Gitweb:     http://git.kernel.org/tip/507e123151149e578c9aae33eb876c49824da5f8
Author:     Heiko Carstens <heiko.carstens@de.ibm.com>
AuthorDate: Tue, 23 Jun 2009 17:38:15 +0200
Committer:  Ingo Molnar <mingo@elte.hu>
CommitDate: Wed, 24 Jun 2009 11:15:09 +0200

timer stats: Optimize by adding quick check to avoid function calls

When the kernel is configured with CONFIG_TIMER_STATS but timer
stats are runtime disabled we still get calls to
__timer_stats_timer_set_start_info which initializes some
fields in the corresponding struct timer_list.

So add some quick checks in the the timer stats setup functions
to avoid function calls to __timer_stats_timer_set_start_info
when timer stats are disabled.

In an artificial workload that does nothing but playing ping
pong with a single tcp packet via loopback this decreases cpu
consumption by 1 - 1.5%.

This is part of a modified function trace output on SLES11:

 perl-2497  [00] 28630647177732388 [+  125]: sk_reset_timer <-tcp_v4_rcv
 perl-2497  [00] 28630647177732513 [+  125]: mod_timer <-sk_reset_timer
 perl-2497  [00] 28630647177732638 [+  125]: __timer_stats_timer_set_start_info <-mod_timer
 perl-2497  [00] 28630647177732763 [+  125]: __mod_timer <-mod_timer
 perl-2497  [00] 28630647177732888 [+  125]: __timer_stats_timer_set_start_info <-__mod_timer
 perl-2497  [00] 28630647177733013 [+   93]: lock_timer_base <-__mod_timer

Signed-off-by: Heiko Carstens <heiko.carstens@de.ibm.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Martin Schwidefsky <schwidefsky@de.ibm.com>
Cc: Mustafa Mesanovic <mustafa.mesanovic@de.ibm.com>
Cc: Arjan van de Ven <arjan@infradead.org>
LKML-Reference: <20090623153811.GA4641@osiris.boeblingen.de.ibm.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>


---
 include/linux/hrtimer.h   |    5 +++++
 include/linux/timer.h     |    4 ++++
 kernel/time/timer_stats.c |   16 ++++++++--------
 kernel/timer.c            |    2 ++
 4 files changed, 19 insertions(+), 8 deletions(-)

diff --git a/include/linux/hrtimer.h b/include/linux/hrtimer.h
index 7400900..54648e6 100644
--- a/include/linux/hrtimer.h
+++ b/include/linux/hrtimer.h
@@ -21,6 +21,7 @@
 #include <linux/list.h>
 #include <linux/wait.h>
 #include <linux/percpu.h>
+#include <linux/timer.h>
 
 
 struct hrtimer_clock_base;
@@ -447,6 +448,8 @@ extern void timer_stats_update_stats(void *timer, pid_t pid, void *startf,
 
 static inline void timer_stats_account_hrtimer(struct hrtimer *timer)
 {
+	if (likely(!timer->start_pid))
+		return;
 	timer_stats_update_stats(timer, timer->start_pid, timer->start_site,
 				 timer->function, timer->start_comm, 0);
 }
@@ -456,6 +459,8 @@ extern void __timer_stats_hrtimer_set_start_info(struct hrtimer *timer,
 
 static inline void timer_stats_hrtimer_set_start_info(struct hrtimer *timer)
 {
+	if (likely(!timer_stats_active))
+		return;
 	__timer_stats_hrtimer_set_start_info(timer, __builtin_return_address(0));
 }
 
diff --git a/include/linux/timer.h b/include/linux/timer.h
index ccf882e..be62ec2 100644
--- a/include/linux/timer.h
+++ b/include/linux/timer.h
@@ -190,6 +190,8 @@ extern unsigned long get_next_timer_interrupt(unsigned long now);
  */
 #ifdef CONFIG_TIMER_STATS
 
+extern int timer_stats_active;
+
 #define TIMER_STATS_FLAG_DEFERRABLE	0x1
 
 extern void init_timer_stats(void);
@@ -203,6 +205,8 @@ extern void __timer_stats_timer_set_start_info(struct timer_list *timer,
 
 static inline void timer_stats_timer_set_start_info(struct timer_list *timer)
 {
+	if (likely(!timer_stats_active))
+		return;
 	__timer_stats_timer_set_start_info(timer, __builtin_return_address(0));
 }
 
diff --git a/kernel/time/timer_stats.c b/kernel/time/timer_stats.c
index c994530..4cde8b9 100644
--- a/kernel/time/timer_stats.c
+++ b/kernel/time/timer_stats.c
@@ -96,7 +96,7 @@ static DEFINE_MUTEX(show_mutex);
 /*
  * Collection status, active/inactive:
  */
-static int __read_mostly active;
+int __read_mostly timer_stats_active;
 
 /*
  * Beginning/end timestamps of measurement:
@@ -242,7 +242,7 @@ void timer_stats_update_stats(void *timer, pid_t pid, void *startf,
 	struct entry *entry, input;
 	unsigned long flags;
 
-	if (likely(!active))
+	if (likely(!timer_stats_active))
 		return;
 
 	lock = &per_cpu(lookup_lock, raw_smp_processor_id());
@@ -254,7 +254,7 @@ void timer_stats_update_stats(void *timer, pid_t pid, void *startf,
 	input.timer_flag = timer_flag;
 
 	spin_lock_irqsave(lock, flags);
-	if (!active)
+	if (!timer_stats_active)
 		goto out_unlock;
 
 	entry = tstat_lookup(&input, comm);
@@ -290,7 +290,7 @@ static int tstats_show(struct seq_file *m, void *v)
 	/*
 	 * If still active then calculate up to now:
 	 */
-	if (active)
+	if (timer_stats_active)
 		time_stop = ktime_get();
 
 	time = ktime_sub(time_stop, time_start);
@@ -368,18 +368,18 @@ static ssize_t tstats_write(struct file *file, const char __user *buf,
 	mutex_lock(&show_mutex);
 	switch (ctl[0]) {
 	case '0':
-		if (active) {
-			active = 0;
+		if (timer_stats_active) {
+			timer_stats_active = 0;
 			time_stop = ktime_get();
 			sync_access();
 		}
 		break;
 	case '1':
-		if (!active) {
+		if (!timer_stats_active) {
 			reset_entries();
 			time_start = ktime_get();
 			smp_mb();
-			active = 1;
+			timer_stats_active = 1;
 		}
 		break;
 	default:
diff --git a/kernel/timer.c b/kernel/timer.c
index 54d3912..0b36b9e 100644
--- a/kernel/timer.c
+++ b/kernel/timer.c
@@ -380,6 +380,8 @@ static void timer_stats_account_timer(struct timer_list *timer)
 {
 	unsigned int flag = 0;
 
+	if (likely(!timer->start_site))
+		return;
 	if (unlikely(tbase_get_deferrable(timer->base)))
 		flag |= TIMER_STATS_FLAG_DEFERRABLE;
 

^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2009-06-24  9:48 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-06-23 14:12 [PATCH/Resend] timer stats: add quick check to avoid function calls Heiko Carstens
2009-06-23 15:08 ` Ingo Molnar
2009-06-23 15:38   ` Heiko Carstens
2009-06-24  9:47     ` [tip:timers/urgent] timer stats: Optimize by adding " tip-bot for Heiko Carstens

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).