perf counter patches
Subsystems (2)
cover perf counter patches
Not quite tested, since my upgrade to F11 the userspace bits seem to segfault within the dynamic linker :/
PATCH 1/7 perf_counter: fix dynamic irq_period logging
We call perf_adjust_freq() from perf_counter_task_tick() which is is called under the rq->lock causing lock recursion. However, it's no longer required to be called under the rq->lock, so remove it from under it.
Also, fix up some related comments.
LKML-Reference: <new-submission>
--- include/linux/perf_counter.h | 1 + kernel/perf_counter.c | 3 ++- kernel/sched.c | 3 ++- 3 files changed, 5 insertions(+), 2 deletions(-)
include/linux/perf_counter.h +1 -0
@@ -260,6 +260,7 @@ enum perf_event_type {/* * struct { * struct perf_event_header header; +* u64 time; * u64 irq_period; * }; */
kernel/perf_counter.c +2 -1
@@ -2559,7 +2559,8 @@ void perf_counter_munmap(unsigned long a }/* -* +* Log irq_period changes so that analyzing tools can re-normalize the +* event flow. */ static void perf_log_period (struct perf_counter *counter,u64 period)
kernel/sched.c +2 -1
@@ -5113,9 +5113,10 @@ void scheduler_tick(void)update_rq_clock (rq);update_cpu_load (rq); curr->sched_class->task_tick (rq, curr,0 ); -perf_counter_task_tick (curr, cpu);spin_unlock (&rq->lock); +perf_counter_task_tick (curr, cpu); +#ifdef CONFIG_SMP rq->idle_at_tick =idle_cpu (cpu);trigger_load_balance (rq, cpu);
[tip:perfcounters/core] perf_counter: Fix dynamic irq_period logging
Commit-ID: e220d2dcb944c5c488b6855d15ec66d76900514f Gitweb: http://git.kernel.org/tip/e220d2dcb944c5c488b6855d15ec66d76900514f Author: Peter Zijlstra <[email protected]> AuthorDate: Sat, 23 May 2009 18:28:55 +0200 Committer: Ingo Molnar <[email protected]> CommitDate: Sat, 23 May 2009 19:37:44 +0200
perf_counter: Fix dynamic irq_period logging
We call perf_adjust_freq() from perf_counter_task_tick() which is is called under the rq->lock causing lock recursion. However, it's no longer required to be called under the rq->lock, so remove it from under it.
Also, fix up some related comments.
LKML-Reference: <[email protected]>
--- include/linux/perf_counter.h | 1 + kernel/perf_counter.c | 3 ++- kernel/sched.c | 3 ++- 3 files changed, 5 insertions(+), 2 deletions(-)
include/linux/perf_counter.h +1 -0
@@ -260,6 +260,7 @@ enum perf_event_type {/* * struct { * struct perf_event_header header; +* u64 time; * u64 irq_period; * }; */
kernel/perf_counter.c +2 -1
@@ -2559,7 +2559,8 @@ void perf_counter_munmap(unsigned long addr, unsigned long len, }/* -* +* Log irq_period changes so that analyzing tools can re-normalize the +* event flow. */ static void perf_log_period (struct perf_counter *counter,u64 period)
kernel/sched.c +2 -1
@@ -4875,9 +4875,10 @@ void scheduler_tick(void)update_rq_clock (rq);update_cpu_load (rq); curr->sched_class->task_tick (rq, curr,0 ); -perf_counter_task_tick (curr, cpu);spin_unlock (&rq->lock); +perf_counter_task_tick (curr, cpu); +#ifdef CONFIG_SMP rq->idle_at_tick =idle_cpu (cpu);trigger_load_balance (rq, cpu);
Re: [PATCH 1/7] perf_counter: fix dynamic irq_period logging
In reply to Peter ZijlstraQuoted 2 lines · Peter Zijlstra
We call
perf_adjust_freq()fromperf_counter_task_tick()which is is called under therq->lockcausing lock recursion.
What was the lock recursion? I see perf_adjust_freq taking ctx->lock, but we were careful not to take any rq->lock within a ctx->lock, at least in the past.
Paul.
Re: [PATCH 1/7] perf_counter: fix dynamic irq_period logging
Quoted 8 lines · Paul Mackerras
Quoted 2 lines · Peter Zijlstra
We call
perf_adjust_freq()fromperf_counter_task_tick()which is is called under therq->lockcausing lock recursion.What was the lock recursion? I see
perf_adjust_freqtakingctx->lock, but we were careful not to take anyrq->lockwithin actx->lock, at least in the past.
perf_output_end() can end up calling a wake_up().
perf_output_end()
perf_output_unlock()
perf_output_wakeup()
perf_counter_wakeup()
wake_up_all();PATCH 2/7 perf_counter: sanitize counter->mutex
In reply to Peter Zijlstras/counter->mutex/counter->child_mutex/ and make sure its only used to protect child_list.
The usage in __perf_counter_exit_task() doesn't appear to be problematic since ctx->mutex also covers anything related to fd tear-down.
LKML-Reference: <new-submission>
--- include/linux/perf_counter.h | 7 ++---- kernel/perf_counter.c | 47 +++++++++++++++++-------------------------- 2 files changed, 22 insertions(+), 32 deletions(-)
include/linux/perf_counter.h +3 -4
@@ -452,9 +452,6 @@ struct perf_counter {struct perf_counter_context *ctx;struct file *filp; -struct perf_counter *parent; -struct list_head child_list; -/* * These accumulate total time (in nanoseconds) that children * counters have been enabled and running, respectively.
@@ -465,7 +462,9 @@ struct perf_counter {/* * Protect attach/detach and child_list: */ -struct mutex mutex; +struct mutex child_mutex; +struct list_head child_list; +struct perf_counter *parent;int oncpu;int cpu;
kernel/perf_counter.c +19 -28
137 lines not on this page · raw message
[tip:perfcounters/core] perf_counter: Sanitize counter->mutex
Commit-ID: fccc714b3148ab9741fafc1e90c3876d50df6093 Gitweb: http://git.kernel.org/tip/fccc714b3148ab9741fafc1e90c3876d50df6093 Author: Peter Zijlstra <[email protected]> AuthorDate: Sat, 23 May 2009 18:28:56 +0200 Committer: Ingo Molnar <[email protected]> CommitDate: Sat, 23 May 2009 19:37:45 +0200
perf_counter: Sanitize counter->mutex
s/counter->mutex/counter->child_mutex/ and make sure its only used to protect child_list.
The usage in __perf_counter_exit_task() doesn't appear to be problematic since ctx->mutex also covers anything related to fd tear-down.
LKML-Reference: <[email protected]>
--- include/linux/perf_counter.h | 7 ++--- kernel/perf_counter.c | 47 +++++++++++++++++------------------------- 2 files changed, 22 insertions(+), 32 deletions(-)
include/linux/perf_counter.h +3 -4
@@ -452,9 +452,6 @@ struct perf_counter {struct perf_counter_context *ctx;struct file *filp; -struct perf_counter *parent; -struct list_head child_list; -/* * These accumulate total time (in nanoseconds) that children * counters have been enabled and running, respectively.
@@ -465,7 +462,9 @@ struct perf_counter {/* * Protect attach/detach and child_list: */ -struct mutex mutex; +struct mutex child_mutex; +struct list_head child_list; +struct perf_counter *parent;int oncpu;int cpu;
kernel/perf_counter.c +19 -28
137 lines not on this page · raw message
PATCH 3/7 perf_counter: sanitize context locking
In reply to Peter ZijlstraEnsure we're consistent with the context locks.
context->mutex
context->lock
list_{add,del}_counter();so that either lock is sufficient to stabilize the context.
LKML-Reference: <new-submission>
--- kernel/perf_counter.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)
kernel/perf_counter.c +7 -2
@@ -597,6 +597,8 @@ static void add_counter_to_ctx(struct pe/* * Cross CPU call to install and enable a performance counter +* +* Must be called with ctx->mutex held */ static void __perf_install_in_context (void *info) {
@@ -1496,13 +1498,13 @@ static void perf_counter_for_each_siblinstruct perf_counter_context *ctx = counter->ctx;struct perf_counter *sibling; -spin_lock_irq (&ctx->lock); +mutex_lock (&ctx->mutex); counter = counter->group_leader;func (counter);list_for_each_entry (sibling, &counter->sibling_list, list_entry)func (sibling); -spin_unlock_irq (&ctx->lock); +mutex_unlock (&ctx->mutex); } static void perf_counter_for_each_child(struct perf_counter *counter,
@@ -3414,7 +3416,10 @@ __perf_counter_exit_task(struct task_strstruct perf_counter *parent_counter;update_counter_times (child_counter); + +spin_lock_irq (&child_ctx->lock);list_del_counter (child_counter, child_ctx); +spin_unlock_irq (&child_ctx->lock); parent_counter = child_counter->parent;/*
[tip:perfcounters/core] perf_counter: Sanitize context locking
Commit-ID: 682076ae1de0aba9c2da509f7b19dc03e30a6e1f Gitweb: http://git.kernel.org/tip/682076ae1de0aba9c2da509f7b19dc03e30a6e1f Author: Peter Zijlstra <[email protected]> AuthorDate: Sat, 23 May 2009 18:28:57 +0200 Committer: Ingo Molnar <[email protected]> CommitDate: Sat, 23 May 2009 19:37:46 +0200
perf_counter: Sanitize context locking
Ensure we're consistent with the context locks.
context->mutex
context->lock
list_{add,del}_counter();so that either lock is sufficient to stabilize the context.
LKML-Reference: <[email protected]>
--- kernel/perf_counter.c | 9 +++++++-- 1 files changed, 7 insertions(+), 2 deletions(-)
kernel/perf_counter.c +7 -2
@@ -597,6 +597,8 @@ static void add_counter_to_ctx(struct perf_counter *counter,/* * Cross CPU call to install and enable a performance counter +* +* Must be called with ctx->mutex held */ static void __perf_install_in_context (void *info) {
@@ -1496,13 +1498,13 @@ static void perf_counter_for_each_sibling(struct perf_counter *counter,struct perf_counter_context *ctx = counter->ctx;struct perf_counter *sibling; -spin_lock_irq (&ctx->lock); +mutex_lock (&ctx->mutex); counter = counter->group_leader;func (counter);list_for_each_entry (sibling, &counter->sibling_list, list_entry)func (sibling); -spin_unlock_irq (&ctx->lock); +mutex_unlock (&ctx->mutex); } static void perf_counter_for_each_child(struct perf_counter *counter,
@@ -3414,7 +3416,10 @@ __perf_counter_exit_task(struct task_struct *child,struct perf_counter *parent_counter;update_counter_times (child_counter); + +spin_lock_irq (&child_ctx->lock);list_del_counter (child_counter, child_ctx); +spin_unlock_irq (&child_ctx->lock); parent_counter = child_counter->parent;/*
PATCH 4/7 perf_counter: fix userspace build
In reply to Peter Zijlstrarecent userspace (F11) seems to already include the linux/unistd.h bits which means we cannot include the version in the kernel sources due to the header guards being the same.
Ensure we include the kernel version first.
LKML-Reference: <new-submission>
--- Documentation/perf_counter/builtin-record.c | 3 -- Documentation/perf_counter/builtin-stat.c | 5 ---- Documentation/perf_counter/builtin-top.c | 5 ---- Documentation/perf_counter/perf.h | 31 +++++++++++++++++----------- 4 files changed, 22 insertions(+), 22 deletions(-)
Documentation/perf_counter/builtin-record.c +1 -2
@@ -1,5 +1,6 @@ +#include "perf.h" #include "util/util.h" #include <sys/types.h>
@@ -30,9 +31,7 @@#include <linux/unistd.h> #include <linux/types.h> -#include "../../include/linux/perf_counter.h" -#include "perf.h" #define ALIGN (x,a) __ALIGN_MASK(x,(typeof(x))(a)-1)#define __ALIGN_MASK (x,mask) (((x)+(mask))&~(mask))
Documentation/perf_counter/builtin-stat.c +1 -4
@@ -61,6 +61,7 @@* Released under the GPL v2. (and only v2, not any later version) */ +#include "perf.h" #include "util/util.h" #include <getopt.h>
@@ -83,10 +84,6 @@#include <linux/unistd.h> #include <linux/types.h> -#include "../../include/linux/perf_counter.h" - -#include "perf.h" -#define EVENT_MASK_KERNEL 1#define EVENT_MASK_USER 2
Documentation/perf_counter/builtin-top.c +1 -4
@@ -42,6 +42,7 @@* Released under the GPL v2. (and only v2, not any later version) */ +#include "perf.h" #include "util/util.h" #include <getopt.h>
@@ -64,10 +65,6 @@#include <linux/unistd.h> #include <linux/types.h> -#include "../../include/linux/perf_counter.h" - -#include "perf.h" -static int system_wide =0 ;static int nr_counters =0 ;
Documentation/perf_counter/perf.h +19 -12
@@ -1,6 +1,25 @@#ifndef _PERF_PERF_H#define _PERF_PERF_H +#if defined(__x86_64__) || defined(__i386__) +#include "../../arch/x86/include/asm/unistd.h" +#define rmb () asm volatile("lfence" ::: "memory") +#define cpu_relax () asm volatile("rep; nop" ::: "memory"); +#endif + +#ifdef __powerpc__ +#include "../../arch/powerpc/include/asm/unistd.h" +#define rmb () asm volatile ("sync" ::: "memory") +#define cpu_relax () asm volatile ("" ::: "memory"); +#endif + +#include <time.h> +#include <unistd.h> +#include <sys/types.h> +#include <sys/syscall.h> + +#include "../../include/linux/perf_counter.h" +/* * prctl(PR_TASK_PERF_COUNTERS_DISABLE) will (cheaply) disable all * counters in the current task.
@@ -26,18 +45,6 @@ static inline unsigned long long rdclock#define __user#define asmlinkage -#if defined(__x86_64__) || defined(__i386__) -#include "../../arch/x86/include/asm/unistd.h" -#define rmb () asm volatile("lfence" ::: "memory") -#define cpu_relax () asm volatile("rep; nop" ::: "memory"); -#endif - -#ifdef __powerpc__ -#include "../../arch/powerpc/include/asm/unistd.h" -#define rmb () asm volatile ("sync" ::: "memory") -#define cpu_relax () asm volatile ("" ::: "memory"); -#endif -#define unlikely (x) __builtin_expect(!!(x), 0)#define min (x, y) ({ \ typeof(x) _min1 = (x); \
[tip:perfcounters/core] perf_counter: Fix userspace build
Commit-ID: 1a482f38c5aafeb3576079a38a5b21b46619f3d2 Gitweb: http://git.kernel.org/tip/1a482f38c5aafeb3576079a38a5b21b46619f3d2 Author: Peter Zijlstra <[email protected]> AuthorDate: Sat, 23 May 2009 18:28:58 +0200 Committer: Ingo Molnar <[email protected]> CommitDate: Sat, 23 May 2009 19:37:46 +0200
perf_counter: Fix userspace build
recent userspace (F11) seems to already include the linux/unistd.h bits which means we cannot include the version in the kernel sources due to the header guards being the same.
Ensure we include the kernel version first.
LKML-Reference: <[email protected]>
--- Documentation/perf_counter/builtin-record.c | 3 +- Documentation/perf_counter/builtin-stat.c | 5 +--- Documentation/perf_counter/builtin-top.c | 5 +--- Documentation/perf_counter/perf.h | 31 ++++++++++++++++---------- 4 files changed, 22 insertions(+), 22 deletions(-)
Documentation/perf_counter/builtin-record.c +1 -2
@@ -1,5 +1,6 @@ +#include "perf.h" #include "util/util.h" #include <sys/types.h>
@@ -30,9 +31,7 @@#include <linux/unistd.h> #include <linux/types.h> -#include "../../include/linux/perf_counter.h" -#include "perf.h" #define ALIGN (x,a) __ALIGN_MASK(x,(typeof(x))(a)-1)#define __ALIGN_MASK (x,mask) (((x)+(mask))&~(mask))
Documentation/perf_counter/builtin-stat.c +1 -4
@@ -61,6 +61,7 @@* Released under the GPL v2. (and only v2, not any later version) */ +#include "perf.h" #include "util/util.h" #include <getopt.h>
@@ -83,10 +84,6 @@#include <linux/unistd.h> #include <linux/types.h> -#include "../../include/linux/perf_counter.h" - -#include "perf.h" -#define EVENT_MASK_KERNEL 1#define EVENT_MASK_USER 2
Documentation/perf_counter/builtin-top.c +1 -4
@@ -42,6 +42,7 @@* Released under the GPL v2. (and only v2, not any later version) */ +#include "perf.h" #include "util/util.h" #include <getopt.h>
@@ -64,10 +65,6 @@#include <linux/unistd.h> #include <linux/types.h> -#include "../../include/linux/perf_counter.h" - -#include "perf.h" -static int system_wide =0 ;static int nr_counters =0 ;
Documentation/perf_counter/perf.h +19 -12
@@ -1,6 +1,25 @@#ifndef _PERF_PERF_H#define _PERF_PERF_H +#if defined(__x86_64__) || defined(__i386__) +#include "../../arch/x86/include/asm/unistd.h" +#define rmb () asm volatile("lfence" ::: "memory") +#define cpu_relax () asm volatile("rep; nop" ::: "memory"); +#endif + +#ifdef __powerpc__ +#include "../../arch/powerpc/include/asm/unistd.h" +#define rmb () asm volatile ("sync" ::: "memory") +#define cpu_relax () asm volatile ("" ::: "memory"); +#endif + +#include <time.h> +#include <unistd.h> +#include <sys/types.h> +#include <sys/syscall.h> + +#include "../../include/linux/perf_counter.h" +/* * prctl(PR_TASK_PERF_COUNTERS_DISABLE) will (cheaply) disable all * counters in the current task.
@@ -26,18 +45,6 @@ static inline unsigned long long rdclock(void)#define __user#define asmlinkage -#if defined(__x86_64__) || defined(__i386__) -#include "../../arch/x86/include/asm/unistd.h" -#define rmb () asm volatile("lfence" ::: "memory") -#define cpu_relax () asm volatile("rep; nop" ::: "memory"); -#endif - -#ifdef __powerpc__ -#include "../../arch/powerpc/include/asm/unistd.h" -#define rmb () asm volatile ("sync" ::: "memory") -#define cpu_relax () asm volatile ("" ::: "memory"); -#endif -#define unlikely (x) __builtin_expect(!!(x), 0)#define min (x, y) ({ \ typeof(x) _min1 = (x); \
PATCH 5/7 perf_counter: simplify context cleanup
In reply to Peter ZijlstraUse perf_counter_remove_from_context() to remove counters from the context.
--- kernel/perf_counter.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-)
kernel/perf_counter.c +1 -4
@@ -3416,10 +3416,7 @@ __perf_counter_exit_task(struct task_strstruct perf_counter *parent_counter;update_counter_times (child_counter); - -spin_lock_irq (&child_ctx->lock); -list_del_counter (child_counter, child_ctx); -spin_unlock_irq (&child_ctx->lock); +perf_counter_remove_from_context (child_counter); parent_counter = child_counter->parent;/*
[tip:perfcounters/core] perf_counter: Simplify context cleanup
Commit-ID: aa9c67f53d1969cf1db4c9c2db3a78c4ceb96469 Gitweb: http://git.kernel.org/tip/aa9c67f53d1969cf1db4c9c2db3a78c4ceb96469 Author: Peter Zijlstra <[email protected]> AuthorDate: Sat, 23 May 2009 18:28:59 +0200 Committer: Ingo Molnar <[email protected]> CommitDate: Sat, 23 May 2009 19:37:47 +0200
perf_counter: Simplify context cleanup
Use perf_counter_remove_from_context() to remove counters from the context.
LKML-Reference: <[email protected]>
--- kernel/perf_counter.c | 5 +---- 1 files changed, 1 insertions(+), 4 deletions(-)
kernel/perf_counter.c +1 -4
@@ -3416,10 +3416,7 @@ __perf_counter_exit_task(struct task_struct *child,struct perf_counter *parent_counter;update_counter_times (child_counter); - -spin_lock_irq (&child_ctx->lock); -list_del_counter (child_counter, child_ctx); -spin_unlock_irq (&child_ctx->lock); +perf_counter_remove_from_context (child_counter); parent_counter = child_counter->parent;/*
PATCH 6/7 perf_counter: change pctrl() behaviour
In reply to Peter ZijlstraInstead of en/dis-abling all counters acting on a particular task, en/dis- able all counters we created.
LKML-Reference: <new-submission>
--- include/linux/init_task.h | 10 +++++ include/linux/perf_counter.h | 3 + include/linux/sched.h | 2 + kernel/perf_counter.c | 84 ++++++++++--------------------------------- 4 files changed, 36 insertions(+), 63 deletions(-)
include/linux/init_task.h +10 -0
@@ -108,6 +108,15 @@ extern struct group_info init_groups;extern struct cred init_cred; +#ifdef CONFIG_PERF_COUNTERS +# define INIT_PERF_COUNTERS (tsk) \ + .perf_counter_mutex = \ + __MUTEX_INITIALIZER(tsk.perf_counter_mutex), \ + .perf_counter_list = LIST_HEAD_INIT(tsk.perf_counter_list), +#else +# define INIT_PERF_COUNTERS (tsk) +#endif +/* * INIT_TASK is used to set up the first task table, touch at * your own risk!. Base=0, limit=0x1fffff (=2MB)
@@ -171,6 +180,7 @@ extern struct cred init_cred; }, \ .dirties = INIT_PROP_LOCAL_SINGLE(dirties), \ INIT_IDS \ +INIT_PERF_COUNTERS (tsk) \ INIT_TRACE_IRQFLAGS \INIT_LOCKDEP \INIT_FTRACE_GRAPH \
include/linux/perf_counter.h +3 -0
@@ -469,6 +469,9 @@ struct perf_counter {int oncpu;int cpu; +struct list_head owner_entry; +struct task_struct *owner; +/* mmap bits */ struct mutex mmap_mutex;atomic_t mmap_count;
include/linux/sched.h +2 -0
@@ -1403,6 +1403,8 @@ struct task_struct {#endif #ifdef CONFIG_PERF_COUNTERS struct perf_counter_context *perf_counter_ctxp; +struct mutex perf_counter_mutex; +struct list_head perf_counter_list;#endif #ifdef CONFIG_NUMA struct mempolicy *mempolicy;
kernel/perf_counter.c +21 -63
112 lines not on this page · raw message
Re: [PATCH 6/7] perf_counter: change pctrl() behaviour
Quoted 7 lines · Peter Zijlstra
plain text document attachment (perf_counter-ctrl-all.patch) Instead of en/dis-abling all counters acting on a particular task, en/dis- able all counters we created.
LKML-Reference: <new-submission>
Signed-off-by Peter Zijlstra <[email protected]>---
Please fold in the below so as to avoid an explosion on first sys_perf_counter_open().
kernel/perf_counter.c +3 -0
@@ -3446,6 +3446,9 @@ void perf_counter_init_task(struct task_ child->perf_counter_ctxp =NULL ; +mutex_init (&child->perf_counter_mutex); +INIT_LIST_HEAD (&child->perf_counter_list); +/* * This is executed from the parent task context, so inherit * counters that have been marked for cloning.
[tip:perfcounters/core] perf_counter: Change pctrl() behaviour
In reply to Peter ZijlstraCommit-ID: 082ff5a2767a0679ee543f14883adbafb631ffbe Gitweb: http://git.kernel.org/tip/082ff5a2767a0679ee543f14883adbafb631ffbe Author: Peter Zijlstra <[email protected]> AuthorDate: Sat, 23 May 2009 18:29:00 +0200 Committer: Ingo Molnar <[email protected]> CommitDate: Sun, 24 May 2009 08:24:08 +0200
perf_counter: Change pctrl() behaviour
Instead of en/dis-abling all counters acting on a particular task, en/dis- able all counters we created.
[ v2: fix crash on first counter enable ]
LKML-Reference: <[email protected]>
--- include/linux/init_task.h | 10 +++++ include/linux/perf_counter.h | 3 + include/linux/sched.h | 2 + kernel/perf_counter.c | 87 +++++++++++------------------------------ 4 files changed, 39 insertions(+), 63 deletions(-)
include/linux/init_task.h +10 -0
@@ -108,6 +108,15 @@ extern struct group_info init_groups;extern struct cred init_cred; +#ifdef CONFIG_PERF_COUNTERS +# define INIT_PERF_COUNTERS (tsk) \ + .perf_counter_mutex = \ + __MUTEX_INITIALIZER(tsk.perf_counter_mutex), \ + .perf_counter_list = LIST_HEAD_INIT(tsk.perf_counter_list), +#else +# define INIT_PERF_COUNTERS (tsk) +#endif +/* * INIT_TASK is used to set up the first task table, touch at * your own risk!. Base=0, limit=0x1fffff (=2MB)
@@ -171,6 +180,7 @@ extern struct cred init_cred; }, \ .dirties = INIT_PROP_LOCAL_SINGLE(dirties), \ INIT_IDS \ +INIT_PERF_COUNTERS (tsk) \ INIT_TRACE_IRQFLAGS \INIT_LOCKDEP \INIT_FTRACE_GRAPH \
include/linux/perf_counter.h +3 -0
@@ -469,6 +469,9 @@ struct perf_counter {int oncpu;int cpu; +struct list_head owner_entry; +struct task_struct *owner; +/* mmap bits */ struct mutex mmap_mutex;atomic_t mmap_count;
include/linux/sched.h +2 -0
@@ -1389,6 +1389,8 @@ struct task_struct {#endif #ifdef CONFIG_PERF_COUNTERS struct perf_counter_context *perf_counter_ctxp; +struct mutex perf_counter_mutex; +struct list_head perf_counter_list;#endif #ifdef CONFIG_NUMA struct mempolicy *mempolicy;
kernel/perf_counter.c +24 -63
121 lines not on this page · raw message
PATCH 7/7 perf_counter: remove perf_counter_context::nr_enabled
In reply to Peter Zijlstranow that pctrl() no longer disables other people's counters, remove the PMU cache code that deals with that.
LKML-Reference: <new-submission>
--- include/linux/perf_counter.h | 1 - kernel/perf_counter.c | 11 +---------- 2 files changed, 1 insertion(+), 11 deletions(-)
include/linux/perf_counter.h +0 -1
@@ -516,7 +516,6 @@ struct perf_counter_context {struct list_head event_list;int nr_counters;int nr_active; -int nr_enabled;int is_active;atomic_t refcount;struct task_struct *task;
kernel/perf_counter.c +1 -10
@@ -134,8 +134,6 @@ list_add_counter(struct perf_counter *colist_add_rcu (&counter->event_entry, &ctx->event_list); ctx->nr_counters++; -if (counter->state >=PERF_COUNTER_STATE_INACTIVE ) - ctx->nr_enabled++; }/*
@@ -150,8 +148,6 @@ list_del_counter(struct perf_counter *coif (list_empty (&counter->list_entry))return ; ctx->nr_counters--; -if (counter->state >=PERF_COUNTER_STATE_INACTIVE ) - ctx->nr_enabled--;list_del_init (&counter->list_entry);list_del_rcu (&counter->event_entry);
@@ -406,7 +402,6 @@ static void __perf_counter_disable(voidelse counter_sched_out (counter, cpuctx, ctx); counter->state =PERF_COUNTER_STATE_OFF ; - ctx->nr_enabled--; }spin_unlock_irqrestore (&ctx->lock, flags);
@@ -448,7 +443,6 @@ static void perf_counter_disable(structif (counter->state ==PERF_COUNTER_STATE_INACTIVE ) {update_counter_times (counter); counter->state =PERF_COUNTER_STATE_OFF ; - ctx->nr_enabled--; }spin_unlock_irq (&ctx->lock);
@@ -759,7 +753,6 @@ static void __perf_counter_enable(void * goto unlock; counter->state =PERF_COUNTER_STATE_INACTIVE ; counter->tstamp_enabled = ctx->time - counter->total_time_enabled; - ctx->nr_enabled++;/* * If the counter is in a group and isn't the group leader,
@@ -850,7 +843,6 @@ static void perf_counter_enable(struct p counter->state =PERF_COUNTER_STATE_INACTIVE ; counter->tstamp_enabled = ctx->time - counter->total_time_enabled; - ctx->nr_enabled++; } out:spin_unlock_irq (&ctx->lock);
@@ -910,8 +902,7 @@ static int context_equiv(struct perf_cou struct perf_counter_context *ctx2) {return ctx1->parent_ctx && ctx1->parent_ctx == ctx2->parent_ctx - && ctx1->parent_gen == ctx2->parent_gen - && ctx1->nr_enabled == ctx2->nr_enabled; + && ctx1->parent_gen == ctx2->parent_gen; }/*
[tip:perfcounters/core] perf_counter: Remove perf_counter_context::nr_enabled
Commit-ID: 475c55797323b67435083f6e2eb8ee670f6410ec Gitweb: http://git.kernel.org/tip/475c55797323b67435083f6e2eb8ee670f6410ec Author: Peter Zijlstra <[email protected]> AuthorDate: Sat, 23 May 2009 18:29:01 +0200 Committer: Ingo Molnar <[email protected]> CommitDate: Sun, 24 May 2009 08:24:30 +0200
perf_counter: Remove perf_counter_context::nr_enabled
now that pctrl() no longer disables other people's counters, remove the PMU cache code that deals with that.
LKML-Reference: <[email protected]>
--- include/linux/perf_counter.h | 1 - kernel/perf_counter.c | 11 +---------- 2 files changed, 1 insertions(+), 11 deletions(-)
include/linux/perf_counter.h +0 -1
@@ -516,7 +516,6 @@ struct perf_counter_context {struct list_head event_list;int nr_counters;int nr_active; -int nr_enabled;int is_active;atomic_t refcount;struct task_struct *task;
kernel/perf_counter.c +1 -10
@@ -134,8 +134,6 @@ list_add_counter(struct perf_counter *counter, struct perf_counter_context *ctx)list_add_rcu (&counter->event_entry, &ctx->event_list); ctx->nr_counters++; -if (counter->state >=PERF_COUNTER_STATE_INACTIVE ) - ctx->nr_enabled++; }/*
@@ -150,8 +148,6 @@ list_del_counter(struct perf_counter *counter, struct perf_counter_context *ctx)if (list_empty (&counter->list_entry))return ; ctx->nr_counters--; -if (counter->state >=PERF_COUNTER_STATE_INACTIVE ) - ctx->nr_enabled--;list_del_init (&counter->list_entry);list_del_rcu (&counter->event_entry);
@@ -406,7 +402,6 @@ static void __perf_counter_disable(void *info)else counter_sched_out (counter, cpuctx, ctx); counter->state =PERF_COUNTER_STATE_OFF ; - ctx->nr_enabled--; }spin_unlock_irqrestore (&ctx->lock, flags);
@@ -448,7 +443,6 @@ static void perf_counter_disable(struct perf_counter *counter)if (counter->state ==PERF_COUNTER_STATE_INACTIVE ) {update_counter_times (counter); counter->state =PERF_COUNTER_STATE_OFF ; - ctx->nr_enabled--; }spin_unlock_irq (&ctx->lock);
@@ -759,7 +753,6 @@ static void __perf_counter_enable(void *info) goto unlock; counter->state =PERF_COUNTER_STATE_INACTIVE ; counter->tstamp_enabled = ctx->time - counter->total_time_enabled; - ctx->nr_enabled++;/* * If the counter is in a group and isn't the group leader,
@@ -850,7 +843,6 @@ static void perf_counter_enable(struct perf_counter *counter) counter->state =PERF_COUNTER_STATE_INACTIVE ; counter->tstamp_enabled = ctx->time - counter->total_time_enabled; - ctx->nr_enabled++; } out:spin_unlock_irq (&ctx->lock);
@@ -910,8 +902,7 @@ static int context_equiv(struct perf_counter_context *ctx1, struct perf_counter_context *ctx2) {return ctx1->parent_ctx && ctx1->parent_ctx == ctx2->parent_ctx - && ctx1->parent_gen == ctx2->parent_gen - && ctx1->nr_enabled == ctx2->nr_enabled; + && ctx1->parent_gen == ctx2->parent_gen; }/*