提交 187dd317 编写于 作者: L Linus Torvalds

Merge branch 'timers-fixes-for-linus' of...

Merge branch 'timers-fixes-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip

* 'timers-fixes-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip:
  timer stats: Optimize by adding quick check to avoid function calls
  timers: Fix timer_migration interface which accepts any number as input
...@@ -21,6 +21,7 @@ ...@@ -21,6 +21,7 @@
#include <linux/list.h> #include <linux/list.h>
#include <linux/wait.h> #include <linux/wait.h>
#include <linux/percpu.h> #include <linux/percpu.h>
#include <linux/timer.h>
struct hrtimer_clock_base; struct hrtimer_clock_base;
...@@ -447,6 +448,8 @@ extern void timer_stats_update_stats(void *timer, pid_t pid, void *startf, ...@@ -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) 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_stats_update_stats(timer, timer->start_pid, timer->start_site,
timer->function, timer->start_comm, 0); timer->function, timer->start_comm, 0);
} }
...@@ -456,6 +459,8 @@ extern void __timer_stats_hrtimer_set_start_info(struct hrtimer *timer, ...@@ -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) 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)); __timer_stats_hrtimer_set_start_info(timer, __builtin_return_address(0));
} }
......
...@@ -190,6 +190,8 @@ extern unsigned long get_next_timer_interrupt(unsigned long now); ...@@ -190,6 +190,8 @@ extern unsigned long get_next_timer_interrupt(unsigned long now);
*/ */
#ifdef CONFIG_TIMER_STATS #ifdef CONFIG_TIMER_STATS
extern int timer_stats_active;
#define TIMER_STATS_FLAG_DEFERRABLE 0x1 #define TIMER_STATS_FLAG_DEFERRABLE 0x1
extern void init_timer_stats(void); extern void init_timer_stats(void);
...@@ -203,6 +205,8 @@ extern void __timer_stats_timer_set_start_info(struct timer_list *timer, ...@@ -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) 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)); __timer_stats_timer_set_start_info(timer, __builtin_return_address(0));
} }
......
...@@ -335,7 +335,10 @@ static struct ctl_table kern_table[] = { ...@@ -335,7 +335,10 @@ static struct ctl_table kern_table[] = {
.data = &sysctl_timer_migration, .data = &sysctl_timer_migration,
.maxlen = sizeof(unsigned int), .maxlen = sizeof(unsigned int),
.mode = 0644, .mode = 0644,
.proc_handler = &proc_dointvec, .proc_handler = &proc_dointvec_minmax,
.strategy = &sysctl_intvec,
.extra1 = &zero,
.extra2 = &one,
}, },
#endif #endif
{ {
......
...@@ -96,7 +96,7 @@ static DEFINE_MUTEX(show_mutex); ...@@ -96,7 +96,7 @@ static DEFINE_MUTEX(show_mutex);
/* /*
* Collection status, active/inactive: * Collection status, active/inactive:
*/ */
static int __read_mostly active; int __read_mostly timer_stats_active;
/* /*
* Beginning/end timestamps of measurement: * Beginning/end timestamps of measurement:
...@@ -242,7 +242,7 @@ void timer_stats_update_stats(void *timer, pid_t pid, void *startf, ...@@ -242,7 +242,7 @@ void timer_stats_update_stats(void *timer, pid_t pid, void *startf,
struct entry *entry, input; struct entry *entry, input;
unsigned long flags; unsigned long flags;
if (likely(!active)) if (likely(!timer_stats_active))
return; return;
lock = &per_cpu(lookup_lock, raw_smp_processor_id()); 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, ...@@ -254,7 +254,7 @@ void timer_stats_update_stats(void *timer, pid_t pid, void *startf,
input.timer_flag = timer_flag; input.timer_flag = timer_flag;
spin_lock_irqsave(lock, flags); spin_lock_irqsave(lock, flags);
if (!active) if (!timer_stats_active)
goto out_unlock; goto out_unlock;
entry = tstat_lookup(&input, comm); entry = tstat_lookup(&input, comm);
...@@ -290,7 +290,7 @@ static int tstats_show(struct seq_file *m, void *v) ...@@ -290,7 +290,7 @@ static int tstats_show(struct seq_file *m, void *v)
/* /*
* If still active then calculate up to now: * If still active then calculate up to now:
*/ */
if (active) if (timer_stats_active)
time_stop = ktime_get(); time_stop = ktime_get();
time = ktime_sub(time_stop, time_start); time = ktime_sub(time_stop, time_start);
...@@ -368,18 +368,18 @@ static ssize_t tstats_write(struct file *file, const char __user *buf, ...@@ -368,18 +368,18 @@ static ssize_t tstats_write(struct file *file, const char __user *buf,
mutex_lock(&show_mutex); mutex_lock(&show_mutex);
switch (ctl[0]) { switch (ctl[0]) {
case '0': case '0':
if (active) { if (timer_stats_active) {
active = 0; timer_stats_active = 0;
time_stop = ktime_get(); time_stop = ktime_get();
sync_access(); sync_access();
} }
break; break;
case '1': case '1':
if (!active) { if (!timer_stats_active) {
reset_entries(); reset_entries();
time_start = ktime_get(); time_start = ktime_get();
smp_mb(); smp_mb();
active = 1; timer_stats_active = 1;
} }
break; break;
default: default:
......
...@@ -380,6 +380,8 @@ static void timer_stats_account_timer(struct timer_list *timer) ...@@ -380,6 +380,8 @@ static void timer_stats_account_timer(struct timer_list *timer)
{ {
unsigned int flag = 0; unsigned int flag = 0;
if (likely(!timer->start_site))
return;
if (unlikely(tbase_get_deferrable(timer->base))) if (unlikely(tbase_get_deferrable(timer->base)))
flag |= TIMER_STATS_FLAG_DEFERRABLE; flag |= TIMER_STATS_FLAG_DEFERRABLE;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册