yet more perf counter patches
Subsystems (4)
cover yet more perf counter patches
Signature · 1 line
--
PATCH 2/5 perf_counter: remove unused ABI bits.
extra_config_len isn't used for anything, remove it.
LKML-Reference: <new-submission>
--- include/linux/perf_counter.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
include/linux/perf_counter.h +2 -2
@@ -154,11 +154,11 @@ struct perf_counter_hw_event { __reserved_1 :51 ; -__u32 extra_config_len;__u32 wakeup_events;/* wakeup every n events */ +__u32 __reserved_2; -__u64 __reserved_2;__u64 __reserved_3; +__u64 __reserved_4; };/*
PATCH 1/5 perf_counter: fix perf-$cmd invokation
In reply to Peter ZijlstraFix:
$ perf-top fatal: cannot handle -top internally
LKML-Reference: <new-submission>
--- Documentation/perf_counter/perf.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Documentation/perf_counter/perf.c +1 -1
@@ -357,7 +357,7 @@ int main(int argc, const char **argv)* die if that one cannot handle it. */ if (!prefixcmp (cmd,"perf-" )) { - cmd +=4 ; + cmd +=5 ; argv[0 ] = cmd;handle_internal_command (argc, argv);die ("cannot handle %s internally" , cmd);
PATCH 4/5 perf_counter: propagate inheritance failures down the fork() path
In reply to Peter ZijlstraFail fork() when we fail inheritance for some reason (-ENOMEM most likely).
LKML-Reference: <new-submission>
--- kernel/fork.c | 5 ++++- kernel/perf_counter.c | 20 ++++++++++++-------- 2 files changed, 16 insertions(+), 9 deletions(-)
kernel/fork.c +4 -1
@@ -983,7 +983,9 @@ static struct task_struct *copy_process( goto fork_out;rt_mutex_init_task (p); -perf_counter_init_task (p); + retval =perf_counter_init_task (p); +if (retval) + goto bad_fork_free;#ifdef CONFIG_PROVE_LOCKING DEBUG_LOCKS_WARN_ON (!p->hardirqs_enabled);
@@ -1309,6 +1311,7 @@ bad_fork_cleanup_count:put_cred (p->real_cred);put_cred (p->cred); bad_fork_free: +perf_counter_exit_task (p);free_task (p); fork_out:return ERR_PTR (retval);
kernel/perf_counter.c +12 -8
@@ -3434,18 +3434,23 @@ again:/* * Initialize the perf_counter context in task_struct */ -void perf_counter_init_task (struct task_struct *child) +int perf_counter_init_task (struct task_struct *child) {struct perf_counter_context *child_ctx, *parent_ctx;struct perf_counter *counter;struct task_struct *parent = current;int inherited_all =1 ; +int ret =0 ; child->perf_counter_ctxp =NULL ;mutex_init (&child->perf_counter_mutex);INIT_LIST_HEAD (&child->perf_counter_list); + parent_ctx = parent->perf_counter_ctxp; +if (likely (!parent_ctx || !parent_ctx->nr_counters)) +return 0 ; +/* * This is executed from the parent task context, so inherit * counters that have been marked for cloning.
@@ -3454,11 +3459,7 @@ void perf_counter_init_task(struct task_ child_ctx =kmalloc (sizeof (struct perf_counter_context ),GFP_KERNEL );if (!child_ctx) -return ; - - parent_ctx = parent->perf_counter_ctxp; -if (likely (!parent_ctx || !parent_ctx->nr_counters)) -return ; +return -ENOMEM ;__perf_counter_init_context (child_ctx, child); child->perf_counter_ctxp = child_ctx;
@@ -3482,8 +3483,9 @@ void perf_counter_init_task(struct task_continue ; } -if (inherit_group (counter, parent, - parent_ctx, child, child_ctx)) { + ret =inherit_group (counter, parent, parent_ctx, + child, child_ctx); +if (ret) { inherited_all =0 ;break ; }
@@ -3505,6 +3507,8 @@ void perf_counter_init_task(struct task_ }mutex_unlock (&parent_ctx->mutex); + +return ret; }static void __cpuinit perf_counter_init_cpu (int cpu)
PATCH 5/5 perf_counter: fix PERF_COUNTER_CONTEXT_SWITCHES for cpu counters
In reply to Peter ZijlstraIngo noticed that cpu counters had 0 context switches, even though there was plenty scheduling on the cpu.
LKML-Reference: <new-submission>
--- kernel/perf_counter.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)
kernel/perf_counter.c +3 -4
@@ -932,14 +932,13 @@ void perf_counter_task_sched_out(structstruct perf_counter_context *next_ctx;struct pt_regs *regs; + regs =task_pt_regs (task); +perf_swcounter_event (PERF_COUNT_CONTEXT_SWITCHES ,1 ,1 , regs,0 ); +if (likely (!ctx || !cpuctx->task_ctx))return ;update_context_time (ctx); - - regs =task_pt_regs (task); -perf_swcounter_event (PERF_COUNT_CONTEXT_SWITCHES ,1 ,1 , regs,0 ); - next_ctx = next->perf_counter_ctxp;if (next_ctx &&context_equiv (ctx, next_ctx)) { task->perf_counter_ctxp = next_ctx;
PATCH 3/5 perf_counter: make pctrl() affect inherited counters too
In reply to Peter ZijlstraPaul noted that the new ptcrl() didn't work on child counters.
LKML-Reference: <new-submission>
--- kernel/perf_counter.c | 48 ++++++++++++++++++++++++------------------------ 1 file changed, 24 insertions(+), 24 deletions(-)
kernel/perf_counter.c +24 -24
@@ -1067,30 +1067,6 @@ static void perf_counter_cpu_sched_in(st__perf_counter_sched_in (ctx, cpuctx, cpu); } -int perf_counter_task_enable (void ) -{ -struct perf_counter *counter; - -mutex_lock (¤t->perf_counter_mutex); -list_for_each_entry (counter, ¤t->perf_counter_list, owner_entry) -perf_counter_enable (counter); -mutex_unlock (¤t->perf_counter_mutex); - -return 0 ; -} - -int perf_counter_task_disable (void ) -{ -struct perf_counter *counter; - -mutex_lock (¤t->perf_counter_mutex); -list_for_each_entry (counter, ¤t->perf_counter_list, owner_entry) -perf_counter_disable (counter); -mutex_unlock (¤t->perf_counter_mutex); - -return 0 ; -} -static void perf_log_period (struct perf_counter *counter,u64 period);static void perf_adjust_freq (struct perf_counter_context *ctx)
@@ -1505,6 +1481,30 @@ static long perf_ioctl(struct file *filereturn 0 ; } +int perf_counter_task_enable (void ) +{ +struct perf_counter *counter; + +mutex_lock (¤t->perf_counter_mutex); +list_for_each_entry (counter, ¤t->perf_counter_list, owner_entry) +perf_counter_for_each_child (counter, perf_counter_enable); +mutex_unlock (¤t->perf_counter_mutex); + +return 0 ; +} + +int perf_counter_task_disable (void ) +{ +struct perf_counter *counter; + +mutex_lock (¤t->perf_counter_mutex); +list_for_each_entry (counter, ¤t->perf_counter_list, owner_entry) +perf_counter_for_each_child (counter, perf_counter_disable); +mutex_unlock (¤t->perf_counter_mutex); + +return 0 ; +} +/* * Callers need to ensure there can be no nesting of this function, otherwise * the seqlock logic goes bad. We can not serialize this because the arch
[tip:perfcounters/core] perf_counter: Remove unused ABI bits
In reply to Peter ZijlstraCommit-ID: e527ea312f31e88a7fa5472b71db71c565b0d44f Gitweb: http://git.kernel.org/tip/e527ea312f31e88a7fa5472b71db71c565b0d44f Author: Peter Zijlstra <[email protected]> AuthorDate: Mon, 25 May 2009 14:45:25 +0200 Committer: Ingo Molnar <[email protected]> CommitDate: Mon, 25 May 2009 14:55:00 +0200
perf_counter: Remove unused ABI bits
extra_config_len isn't used for anything, remove it.
LKML-Reference: <[email protected]>
--- include/linux/perf_counter.h | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-)
include/linux/perf_counter.h +2 -2
@@ -154,11 +154,11 @@ struct perf_counter_hw_event { __reserved_1 :51 ; -__u32 extra_config_len;__u32 wakeup_events;/* wakeup every n events */ +__u32 __reserved_2; -__u64 __reserved_2;__u64 __reserved_3; +__u64 __reserved_4; };/*
[tip:perfcounters/core] perf_counter: Fix perf-$cmd invokation
In reply to Peter ZijlstraCommit-ID: 266dfb0b58bc4181b6158ee63a0069abaa9f3a98 Gitweb: http://git.kernel.org/tip/266dfb0b58bc4181b6158ee63a0069abaa9f3a98 Author: Peter Zijlstra <[email protected]> AuthorDate: Mon, 25 May 2009 14:45:24 +0200 Committer: Ingo Molnar <[email protected]> CommitDate: Mon, 25 May 2009 14:54:59 +0200
perf_counter: Fix perf-$cmd invokation
Fix:
$ perf-top fatal: cannot handle -top internally
LKML-Reference: <[email protected]>
--- Documentation/perf_counter/perf.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
Documentation/perf_counter/perf.c +1 -1
@@ -357,7 +357,7 @@ int main(int argc, const char **argv)* die if that one cannot handle it. */ if (!prefixcmp (cmd,"perf-" )) { - cmd +=4 ; + cmd +=5 ; argv[0 ] = cmd;handle_internal_command (argc, argv);die ("cannot handle %s internally" , cmd);
[tip:perfcounters/core] perf_counter: Make pctrl() affect inherited counters too
In reply to Peter ZijlstraCommit-ID: 771d7cde144d87f2d1fbee4da3c6234d61f7e42a Gitweb: http://git.kernel.org/tip/771d7cde144d87f2d1fbee4da3c6234d61f7e42a Author: Peter Zijlstra <[email protected]> AuthorDate: Mon, 25 May 2009 14:45:26 +0200 Committer: Ingo Molnar <[email protected]> CommitDate: Mon, 25 May 2009 14:55:00 +0200
perf_counter: Make pctrl() affect inherited counters too
Paul noted that the new ptcrl() didn't work on child counters.
LKML-Reference: <[email protected]>
--- kernel/perf_counter.c | 48 ++++++++++++++++++++++++------------------------ 1 files changed, 24 insertions(+), 24 deletions(-)
kernel/perf_counter.c +24 -24
@@ -1067,30 +1067,6 @@ static void perf_counter_cpu_sched_in(struct perf_cpu_context *cpuctx, int cpu)__perf_counter_sched_in (ctx, cpuctx, cpu); } -int perf_counter_task_enable (void ) -{ -struct perf_counter *counter; - -mutex_lock (¤t->perf_counter_mutex); -list_for_each_entry (counter, ¤t->perf_counter_list, owner_entry) -perf_counter_enable (counter); -mutex_unlock (¤t->perf_counter_mutex); - -return 0 ; -} - -int perf_counter_task_disable (void ) -{ -struct perf_counter *counter; - -mutex_lock (¤t->perf_counter_mutex); -list_for_each_entry (counter, ¤t->perf_counter_list, owner_entry) -perf_counter_disable (counter); -mutex_unlock (¤t->perf_counter_mutex); - -return 0 ; -} -static void perf_log_period (struct perf_counter *counter,u64 period);static void perf_adjust_freq (struct perf_counter_context *ctx)
@@ -1505,6 +1481,30 @@ static long perf_ioctl(struct file *file, unsigned int cmd, unsigned long arg)return 0 ; } +int perf_counter_task_enable (void ) +{ +struct perf_counter *counter; + +mutex_lock (¤t->perf_counter_mutex); +list_for_each_entry (counter, ¤t->perf_counter_list, owner_entry) +perf_counter_for_each_child (counter, perf_counter_enable); +mutex_unlock (¤t->perf_counter_mutex); + +return 0 ; +} + +int perf_counter_task_disable (void ) +{ +struct perf_counter *counter; + +mutex_lock (¤t->perf_counter_mutex); +list_for_each_entry (counter, ¤t->perf_counter_list, owner_entry) +perf_counter_for_each_child (counter, perf_counter_disable); +mutex_unlock (¤t->perf_counter_mutex); + +return 0 ; +} +/* * Callers need to ensure there can be no nesting of this function, otherwise * the seqlock logic goes bad. We can not serialize this because the arch
[tip:perfcounters/core] perf_counter: Propagate inheritance failures down the fork() path
In reply to Peter ZijlstraCommit-ID: 6ab423e0eaca827fbd201ca4ae7d4f8573a366b2 Gitweb: http://git.kernel.org/tip/6ab423e0eaca827fbd201ca4ae7d4f8573a366b2 Author: Peter Zijlstra <[email protected]> AuthorDate: Mon, 25 May 2009 14:45:27 +0200 Committer: Ingo Molnar <[email protected]> CommitDate: Mon, 25 May 2009 14:55:01 +0200
perf_counter: Propagate inheritance failures down the fork() path
Fail fork() when we fail inheritance for some reason (-ENOMEM most likely).
LKML-Reference: <[email protected]>
--- include/linux/perf_counter.h | 4 ++-- kernel/fork.c | 6 +++++- kernel/perf_counter.c | 20 ++++++++++++-------- 3 files changed, 19 insertions(+), 11 deletions(-)
include/linux/perf_counter.h +2 -2
@@ -566,7 +566,7 @@ extern void perf_counter_task_sched_in(struct task_struct *task, int cpu);extern void perf_counter_task_sched_out (struct task_struct *task,struct task_struct *next,int cpu);extern void perf_counter_task_tick (struct task_struct *task,int cpu); -extern void perf_counter_init_task (struct task_struct *child); +extern int perf_counter_init_task (struct task_struct *child);extern void perf_counter_exit_task (struct task_struct *child);extern void perf_counter_do_pending (void );extern void perf_counter_print_debug (void );
@@ -631,7 +631,7 @@ perf_counter_task_sched_out(struct task_struct *task, struct task_struct *next, int cpu) { }static inline void perf_counter_task_tick (struct task_struct *task,int cpu) { } -static inline void perf_counter_init_task (struct task_struct *child) { } +static inline int perf_counter_init_task (struct task_struct *child) { }static inline void perf_counter_exit_task (struct task_struct *child) { }static inline void perf_counter_do_pending (void ) { }static inline void perf_counter_print_debug (void ) { }
kernel/fork.c +5 -1
@@ -1095,7 +1095,10 @@ static struct task_struct *copy_process(unsigned long clone_flags,/* Perform scheduler related setup. Assign this task to a CPU. */ sched_fork (p, clone_flags); -perf_counter_init_task (p); + + retval =perf_counter_init_task (p); +if (retval) + goto bad_fork_cleanup_policy;if ((retval =audit_alloc (p))) goto bad_fork_cleanup_policy;
@@ -1295,6 +1298,7 @@ bad_fork_cleanup_semundo: bad_fork_cleanup_audit:audit_free (p); bad_fork_cleanup_policy: +perf_counter_exit_task (p);#ifdef CONFIG_NUMA mpol_put (p->mempolicy); bad_fork_cleanup_cgroup:
kernel/perf_counter.c +12 -8
@@ -3434,18 +3434,23 @@ again:/* * Initialize the perf_counter context in task_struct */ -void perf_counter_init_task (struct task_struct *child) +int perf_counter_init_task (struct task_struct *child) {struct perf_counter_context *child_ctx, *parent_ctx;struct perf_counter *counter;struct task_struct *parent = current;int inherited_all =1 ; +int ret =0 ; child->perf_counter_ctxp =NULL ;mutex_init (&child->perf_counter_mutex);INIT_LIST_HEAD (&child->perf_counter_list); + parent_ctx = parent->perf_counter_ctxp; +if (likely (!parent_ctx || !parent_ctx->nr_counters)) +return 0 ; +/* * This is executed from the parent task context, so inherit * counters that have been marked for cloning.
@@ -3454,11 +3459,7 @@ void perf_counter_init_task(struct task_struct *child) child_ctx =kmalloc (sizeof (struct perf_counter_context ),GFP_KERNEL );if (!child_ctx) -return ; - - parent_ctx = parent->perf_counter_ctxp; -if (likely (!parent_ctx || !parent_ctx->nr_counters)) -return ; +return -ENOMEM ;__perf_counter_init_context (child_ctx, child); child->perf_counter_ctxp = child_ctx;
@@ -3482,8 +3483,9 @@ void perf_counter_init_task(struct task_struct *child)continue ; } -if (inherit_group (counter, parent, - parent_ctx, child, child_ctx)) { + ret =inherit_group (counter, parent, parent_ctx, + child, child_ctx); +if (ret) { inherited_all =0 ;break ; }
@@ -3505,6 +3507,8 @@ void perf_counter_init_task(struct task_struct *child) }mutex_unlock (&parent_ctx->mutex); + +return ret; }static void __cpuinit perf_counter_init_cpu (int cpu)
[tip:perfcounters/core] perf_counter: Fix PERF_COUNTER_CONTEXT_SWITCHES for cpu counters
In reply to Peter ZijlstraCommit-ID: 10989fb2451763fae6f42d85fa6106c8fd010cf5 Gitweb: http://git.kernel.org/tip/10989fb2451763fae6f42d85fa6106c8fd010cf5 Author: Peter Zijlstra <[email protected]> AuthorDate: Mon, 25 May 2009 14:45:28 +0200 Committer: Ingo Molnar <[email protected]> CommitDate: Mon, 25 May 2009 14:55:01 +0200
perf_counter: Fix PERF_COUNTER_CONTEXT_SWITCHES for cpu counters
Ingo noticed that cpu counters had 0 context switches, even though there was plenty scheduling on the cpu.
LKML-Reference: <[email protected]>
--- kernel/perf_counter.c | 7 +++---- 1 files changed, 3 insertions(+), 4 deletions(-)
kernel/perf_counter.c +3 -4
@@ -924,14 +924,13 @@ void perf_counter_task_sched_out(struct task_struct *task,struct perf_counter_context *next_ctx;struct pt_regs *regs; + regs =task_pt_regs (task); +perf_swcounter_event (PERF_COUNT_CONTEXT_SWITCHES ,1 ,1 , regs,0 ); +if (likely (!ctx || !cpuctx->task_ctx))return ;update_context_time (ctx); - - regs =task_pt_regs (task); -perf_swcounter_event (PERF_COUNT_CONTEXT_SWITCHES ,1 ,1 , regs,0 ); - next_ctx = next->perf_counter_ctxp;if (next_ctx &&context_equiv (ctx, next_ctx)) { task->perf_counter_ctxp = next_ctx;