even more perf counter patches
Subsystems (2)
cover even more perf counter patches
PATCH 3/3 perf_counter: generic per counter interrupt throttle
Introduce a generic per counter interrupt throttle.
This uses the perf_counter_overflow() quick disable to throttle a specific counter when its going too fast when a pmu->unthrottle() method is provided which can undo the quick disable.
Power needs to implement both the quick disable and the unthrottle method.
--- arch/x86/kernel/cpu/perf_counter.c | 13 ++++++++ include/linux/perf_counter.h | 11 ++++++ kernel/perf_counter.c | 59 ++++++++++++++++++++++++++++++++++--- kernel/sysctl.c | 8 +++++ 4 files changed, 87 insertions(+), 4 deletions(-)
include/linux/perf_counter.h +11 -0
@@ -267,6 +267,15 @@ enum perf_event_type {PERF_EVENT_PERIOD =4 ,/* +* struct { +* struct perf_event_header header; +* u64 time; +* }; +*/ +PERF_EVENT_THROTTLE =5 , +PERF_EVENT_UNTHROTTLE =6 , + +/* * When header.misc & PERF_EVENT_MISC_OVERFLOW the event_type field * will be PERF_RECORD_* *
@@ -367,6 +376,7 @@ struct pmu {int (*enable) (struct perf_counter *counter);void (*disable) (struct perf_counter *counter);void (*read) (struct perf_counter *counter); +void (*unthrottle) (struct perf_counter *counter); };/**
@@ -613,6 +623,7 @@ extern struct perf_callchain_entry *perfextern int sysctl_perf_counter_priv;extern int sysctl_perf_counter_mlock; +extern int sysctl_perf_counter_limit;extern void perf_counter_init (void );
kernel/perf_counter.c +55 -4
105 lines not on this page · raw message
kernel/sysctl.c +8 -0
@@ -939,6 +939,14 @@ static struct ctl_table kern_table[] = { .mode = 0644, .proc_handler = &proc_dointvec, }, + { + .ctl_name = CTL_UNNUMBERED, + .procname = "perf_counter_int_limit", + .data = &sysctl_perf_counter_limit, + .maxlen = sizeof(sysctl_perf_counter_limit), + .mode = 0644, + .proc_handler = &proc_dointvec, + },#endif /* * NOTE: do not add new entries to this table unless you have read
arch/x86/kernel/cpu/perf_counter.c +13 -0
@@ -623,6 +623,18 @@ try_generic:return 0 ; } +static void x86_pmu_unthrottle (struct perf_counter *counter) +{ +struct cpu_hw_counters *cpuc = &__get_cpu_var (cpu_hw_counters); +struct hw_perf_counter *hwc = &counter->hw; + +if (WARN_ON_ONCE (hwc->idx >=X86_PMC_IDX_MAX || + cpuc->counters[hwc->idx] != counter)) +return ; + + x86_pmu.enable (hwc, hwc->idx); +} +void perf_counter_print_debug (void ) {u64 ctrl, status, overflow, pmc_ctrl, pmc_count, prev_left, fixed;
@@ -1038,6 +1050,7 @@ static const struct pmu pmu = { .enable = x86_pmu_enable, .disable = x86_pmu_disable, .read = x86_pmu_read, + .unthrottle = x86_pmu_unthrottle, };const struct pmu *hw_perf_counter_init (struct perf_counter *counter)
PATCH 2/3 perf_counter: x86: remove interrupt throttle
In reply to Peter Zijlstraremove the x86 specific interrupt throttle
LKML-Reference: <new-submission>
--- arch/x86/kernel/apic/apic.c | 2 - arch/x86/kernel/cpu/perf_counter.c | 47 +++---------------------------------- include/linux/perf_counter.h | 2 - 3 files changed, 5 insertions(+), 46 deletions(-)
arch/x86/kernel/apic/apic.c +0 -2
@@ -817,8 +817,6 @@ static void local_apic_timer_interrupt(vinc_irq_stat (apic_timer_irqs); evt->event_handler (evt); - -perf_counter_unthrottle (); }/*
arch/x86/kernel/cpu/perf_counter.c +5 -42
92 lines not on this page · raw message
include/linux/perf_counter.h +0 -2
@@ -570,7 +570,6 @@ extern void perf_counter_init_task(strucextern void perf_counter_exit_task (struct task_struct *child);extern void perf_counter_do_pending (void );extern void perf_counter_print_debug (void ); -extern void perf_counter_unthrottle (void );extern void __perf_disable (void );extern bool __perf_enable (void );extern void perf_disable (void );
@@ -635,7 +634,6 @@ static inline void perf_counter_init_tasstatic 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 ) { } -static inline void perf_counter_unthrottle (void ) { }static inline void perf_disable (void ) { }static inline void perf_enable (void ) { }static inline int perf_counter_task_disable (void ) {return -EINVAL ; }
PATCH 1/3 perf_counter: x86: expose INV and EDGE bits
In reply to Peter ZijlstraExpose the INV and EDGE bits of the PMU to raw configs.
LKML-Reference: <new-submission>
--- arch/x86/kernel/cpu/perf_counter.c | 8 ++++++++ 1 file changed, 8 insertions(+)
arch/x86/kernel/cpu/perf_counter.c +8 -0
@@ -87,11 +87,15 @@ static u64 intel_pmu_raw_event(u64 event {#define CORE_EVNTSEL_EVENT_MASK 0x000000FFULL#define CORE_EVNTSEL_UNIT_MASK 0x0000FF00ULL +#define CORE_EVNTSEL_EDGE_MASK 0x00040000ULL +#define CORE_EVNTSEL_INV_MASK 0x00800000ULL#define CORE_EVNTSEL_COUNTER_MASK 0xFF000000ULL#define CORE_EVNTSEL_MASK \ (CORE_EVNTSEL_EVENT_MASK | \ CORE_EVNTSEL_UNIT_MASK | \ + CORE_EVNTSEL_EDGE_MASK | \ + CORE_EVNTSEL_INV_MASK | \ CORE_EVNTSEL_COUNTER_MASK)return event &CORE_EVNTSEL_MASK ;
@@ -119,11 +123,15 @@ static u64 amd_pmu_raw_event(u64 event) {#define K7_EVNTSEL_EVENT_MASK 0x7000000FFULL#define K7_EVNTSEL_UNIT_MASK 0x00000FF00ULL +#define K7_EVNTSEL_EDGE_MASK 0x000040000ULL +#define K7_EVNTSEL_INV_MASK 0x000800000ULL#define K7_EVNTSEL_COUNTER_MASK 0x0FF000000ULL#define K7_EVNTSEL_MASK \ (K7_EVNTSEL_EVENT_MASK | \ K7_EVNTSEL_UNIT_MASK | \ + K7_EVNTSEL_EDGE_MASK | \ + K7_EVNTSEL_INV_MASK | \ K7_EVNTSEL_COUNTER_MASK)return event &K7_EVNTSEL_MASK ;
[tip:perfcounters/core] perf_counter: x86: Expose INV and EDGE bits
Commit-ID: ff99be573e02e9f7edc23b472c7f9a5ddba12795 Gitweb: http://git.kernel.org/tip/ff99be573e02e9f7edc23b472c7f9a5ddba12795 Author: Peter Zijlstra <[email protected]> AuthorDate: Mon, 25 May 2009 17:39:03 +0200 Committer: Ingo Molnar <[email protected]> CommitDate: Mon, 25 May 2009 21:41:11 +0200
perf_counter: x86: Expose INV and EDGE bits
Expose the INV and EDGE bits of the PMU to raw configs.
LKML-Reference: <[email protected]>
--- arch/x86/kernel/cpu/perf_counter.c | 8 ++++++++ 1 files changed, 8 insertions(+), 0 deletions(-)
arch/x86/kernel/cpu/perf_counter.c +8 -0
@@ -87,11 +87,15 @@ static u64 intel_pmu_raw_event(u64 event) {#define CORE_EVNTSEL_EVENT_MASK 0x000000FFULL#define CORE_EVNTSEL_UNIT_MASK 0x0000FF00ULL +#define CORE_EVNTSEL_EDGE_MASK 0x00040000ULL +#define CORE_EVNTSEL_INV_MASK 0x00800000ULL#define CORE_EVNTSEL_COUNTER_MASK 0xFF000000ULL#define CORE_EVNTSEL_MASK \ (CORE_EVNTSEL_EVENT_MASK | \ CORE_EVNTSEL_UNIT_MASK | \ + CORE_EVNTSEL_EDGE_MASK | \ + CORE_EVNTSEL_INV_MASK | \ CORE_EVNTSEL_COUNTER_MASK)return event &CORE_EVNTSEL_MASK ;
@@ -119,11 +123,15 @@ static u64 amd_pmu_raw_event(u64 event) {#define K7_EVNTSEL_EVENT_MASK 0x7000000FFULL#define K7_EVNTSEL_UNIT_MASK 0x00000FF00ULL +#define K7_EVNTSEL_EDGE_MASK 0x000040000ULL +#define K7_EVNTSEL_INV_MASK 0x000800000ULL#define K7_EVNTSEL_COUNTER_MASK 0x0FF000000ULL#define K7_EVNTSEL_MASK \ (K7_EVNTSEL_EVENT_MASK | \ K7_EVNTSEL_UNIT_MASK | \ + K7_EVNTSEL_EDGE_MASK | \ + K7_EVNTSEL_INV_MASK | \ K7_EVNTSEL_COUNTER_MASK)return event &K7_EVNTSEL_MASK ;
[tip:perfcounters/core] perf_counter: Generic per counter interrupt throttle
In reply to Peter ZijlstraCommit-ID: a78ac3258782f3e64cb40beb5990808e1febcc0c Gitweb: http://git.kernel.org/tip/a78ac3258782f3e64cb40beb5990808e1febcc0c Author: Peter Zijlstra <[email protected]> AuthorDate: Mon, 25 May 2009 17:39:05 +0200 Committer: Ingo Molnar <[email protected]> CommitDate: Mon, 25 May 2009 21:41:12 +0200
perf_counter: Generic per counter interrupt throttle
Introduce a generic per counter interrupt throttle.
This uses the perf_counter_overflow() quick disable to throttle a specific counter when its going too fast when a pmu->unthrottle() method is provided which can undo the quick disable.
Power needs to implement both the quick disable and the unthrottle method.
LKML-Reference: <[email protected]>
--- arch/x86/kernel/cpu/perf_counter.c | 13 ++++++++ include/linux/perf_counter.h | 11 +++++++ kernel/perf_counter.c | 59 +++++++++++++++++++++++++++++++++-- kernel/sysctl.c | 8 +++++ 4 files changed, 87 insertions(+), 4 deletions(-)
arch/x86/kernel/cpu/perf_counter.c +13 -0
@@ -623,6 +623,18 @@ try_generic:return 0 ; } +static void x86_pmu_unthrottle (struct perf_counter *counter) +{ +struct cpu_hw_counters *cpuc = &__get_cpu_var (cpu_hw_counters); +struct hw_perf_counter *hwc = &counter->hw; + +if (WARN_ON_ONCE (hwc->idx >=X86_PMC_IDX_MAX || + cpuc->counters[hwc->idx] != counter)) +return ; + + x86_pmu.enable (hwc, hwc->idx); +} +void perf_counter_print_debug (void ) {u64 ctrl, status, overflow, pmc_ctrl, pmc_count, prev_left, fixed;
@@ -1038,6 +1050,7 @@ static const struct pmu pmu = { .enable = x86_pmu_enable, .disable = x86_pmu_disable, .read = x86_pmu_read, + .unthrottle = x86_pmu_unthrottle, };const struct pmu *hw_perf_counter_init (struct perf_counter *counter)
include/linux/perf_counter.h +11 -0
@@ -267,6 +267,15 @@ enum perf_event_type {PERF_EVENT_PERIOD =4 ,/* +* struct { +* struct perf_event_header header; +* u64 time; +* }; +*/ +PERF_EVENT_THROTTLE =5 , +PERF_EVENT_UNTHROTTLE =6 , + +/* * When header.misc & PERF_EVENT_MISC_OVERFLOW the event_type field * will be PERF_RECORD_* *
@@ -367,6 +376,7 @@ struct pmu {int (*enable) (struct perf_counter *counter);void (*disable) (struct perf_counter *counter);void (*read) (struct perf_counter *counter); +void (*unthrottle) (struct perf_counter *counter); };/**
@@ -613,6 +623,7 @@ extern struct perf_callchain_entry *perf_callchain(struct pt_regs *regs);extern int sysctl_perf_counter_priv;extern int sysctl_perf_counter_mlock; +extern int sysctl_perf_counter_limit;extern void perf_counter_init (void );
kernel/perf_counter.c +55 -4
105 lines not on this page · raw message
kernel/sysctl.c +8 -0
@@ -930,6 +930,14 @@ static struct ctl_table kern_table[] = { .mode = 0644, .proc_handler = &proc_dointvec, }, + { + .ctl_name = CTL_UNNUMBERED, + .procname = "perf_counter_int_limit", + .data = &sysctl_perf_counter_limit, + .maxlen = sizeof(sysctl_perf_counter_limit), + .mode = 0644, + .proc_handler = &proc_dointvec, + },#endif /* * NOTE: do not add new entries to this table unless you have read
[tip:perfcounters/core] perf_counter: x86: Remove interrupt throttle
In reply to Peter ZijlstraCommit-ID: 48e22d56ecdeddd1ffb42a02fccba5c6ef42b133 Gitweb: http://git.kernel.org/tip/48e22d56ecdeddd1ffb42a02fccba5c6ef42b133 Author: Peter Zijlstra <[email protected]> AuthorDate: Mon, 25 May 2009 17:39:04 +0200 Committer: Ingo Molnar <[email protected]> CommitDate: Mon, 25 May 2009 21:41:12 +0200
perf_counter: x86: Remove interrupt throttle
remove the x86 specific interrupt throttle
LKML-Reference: <[email protected]>
--- arch/x86/kernel/apic/apic.c | 2 - arch/x86/kernel/cpu/perf_counter.c | 47 ++++-------------------------------- include/linux/perf_counter.h | 2 - 3 files changed, 5 insertions(+), 46 deletions(-)
arch/x86/kernel/apic/apic.c +0 -2
@@ -763,8 +763,6 @@ static void local_apic_timer_interrupt(void)inc_irq_stat (apic_timer_irqs); evt->event_handler (evt); - -perf_counter_unthrottle (); }/*
arch/x86/kernel/cpu/perf_counter.c +5 -42
92 lines not on this page · raw message
include/linux/perf_counter.h +0 -2
@@ -570,7 +570,6 @@ 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 ); -extern void perf_counter_unthrottle (void );extern void __perf_disable (void );extern bool __perf_enable (void );extern void perf_disable (void );
@@ -635,7 +634,6 @@ 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 ) { } -static inline void perf_counter_unthrottle (void ) { }static inline void perf_disable (void ) { }static inline void perf_enable (void ) { }static inline int perf_counter_task_disable (void ) {return -EINVAL ; }
[tip:perfcounters/core] Revert "perf_counter, x86: speed up the scheduling fast-path"
In reply to Peter ZijlstraCommit-ID: 53b441a565bf4036ab49c8ea04c5ad06ace7dd6b Gitweb: http://git.kernel.org/tip/53b441a565bf4036ab49c8ea04c5ad06ace7dd6b Author: Ingo Molnar <[email protected]> AuthorDate: Mon, 25 May 2009 21:41:28 +0200 Committer: Ingo Molnar <[email protected]> CommitDate: Mon, 25 May 2009 21:41:28 +0200
Revert "perf_counter, x86: speed up the scheduling fast-path"
This reverts commit b68f1d2e7aa21029d73c7d453a8046e95d351740.
It is causing problems (stuck/stuttering profiling) - when mixed NMI and non-NMI counters are used.
Cc: Peter Zijlstra <[email protected]>
Cc: Paul Mackerras <[email protected]>
Cc: Corey Ashford <[email protected]>
Cc: Arnaldo Carvalho de Melo <[email protected]>
Cc: John Kacur <[email protected]>
LKML-Reference: <[email protected]>
--- arch/x86/kernel/cpu/perf_counter.c | 5 +++-- 1 files changed, 3 insertions(+), 2 deletions(-)
arch/x86/kernel/cpu/perf_counter.c +3 -2
@@ -293,7 +293,6 @@ static int __hw_perf_counter_init(struct perf_counter *counter)return -EACCES ; hwc->nmi =1 ; } -perf_counters_lapic_init (hwc->nmi);if (!hwc->irq_period) hwc->irq_period = x86_pmu.max_period;
@@ -612,6 +611,8 @@ try_generic: hwc->counter_base = x86_pmu.perfctr; } +perf_counters_lapic_init (hwc->nmi); + x86_pmu.disable (hwc, idx); cpuc->counters[idx] = counter;
@@ -1037,7 +1038,7 @@ void __init init_hw_perf_counters(void)pr_info ("... counter mask: %016Lx\n" , perf_counter_mask); -perf_counters_lapic_init (1 ); +perf_counters_lapic_init (0 );register_die_notifier (&perf_counter_nmi_notifier); }
[tip:perfcounters/core] perf_counter: fix warning & lockup
In reply to Peter ZijlstraCommit-ID: 0127c3ea082ee9f1034789b978dfc7fd83254617 Gitweb: http://git.kernel.org/tip/0127c3ea082ee9f1034789b978dfc7fd83254617 Author: Ingo Molnar <[email protected]> AuthorDate: Mon, 25 May 2009 22:03:26 +0200 Committer: Ingo Molnar <[email protected]> CommitDate: Mon, 25 May 2009 22:02:23 +0200
perf_counter: fix warning & lockup
- remove bogus warning
- fix wakeup from NMI path lockup
- also fix up whitespace noise in perf_counter.h
Cc: Peter Zijlstra <[email protected]>
Cc: Paul Mackerras <[email protected]>
Cc: Corey Ashford <[email protected]>
Cc: Arnaldo Carvalho de Melo <[email protected]>
Cc: John Kacur <[email protected]>
LKML-Reference: <[email protected]>
--- include/linux/perf_counter.h | 78 +++++++++++++++++++++--------------------- kernel/perf_counter.c | 4 +-- 2 files changed, 40 insertions(+), 42 deletions(-)
include/linux/perf_counter.h +39 -39
@@ -73,7 +73,7 @@ enum sw_event_ids { PERF_SW_EVENTS_MAX = 7, }; -#define __PERF_COUNTER_MASK (name) \ +#define __PERF_COUNTER_MASK (name) \ (((1ULL << PERF_COUNTER_##name##_BITS) - 1) << \ PERF_COUNTER_##name##_SHIFT)
@@ -98,14 +98,14 @@ enum sw_event_ids {* in the overflow packets. */ enum perf_counter_record_format { -PERF_RECORD_IP =1U <<0 , -PERF_RECORD_TID =1U <<1 , -PERF_RECORD_TIME =1U <<2 , -PERF_RECORD_ADDR =1U <<3 , -PERF_RECORD_GROUP =1U <<4 , -PERF_RECORD_CALLCHAIN =1U <<5 , -PERF_RECORD_CONFIG =1U <<6 , -PERF_RECORD_CPU =1U <<7 , +PERF_RECORD_IP =1U <<0 , +PERF_RECORD_TID =1U <<1 , +PERF_RECORD_TIME =1U <<2 , +PERF_RECORD_ADDR =1U <<3 , +PERF_RECORD_GROUP =1U <<4 , +PERF_RECORD_CALLCHAIN =1U <<5 , +PERF_RECORD_CONFIG =1U <<6 , +PERF_RECORD_CPU =1U <<7 , };/*
@@ -235,13 +235,13 @@ enum perf_event_type {* correlate userspace IPs to code. They have the following structure: * * struct { -* struct perf_event_header header; +* struct perf_event_header header; * -* u32 pid, tid; -* u64 addr; -* u64 len; -* u64 pgoff; -* char filename[]; +* u32 pid, tid; +* u64 addr; +* u64 len; +* u64 pgoff; +* char filename[]; * }; */ PERF_EVENT_MMAP = 1,
@@ -249,27 +249,27 @@ enum perf_event_type {/* * struct { -* struct perf_event_header header; +* struct perf_event_header header; * -* u32 pid, tid; -* char comm[]; +* u32 pid, tid; +* char comm[]; * }; */ PERF_EVENT_COMM =3 ,/* * struct { -* struct perf_event_header header; -* u64 time; -* u64 irq_period; +* struct perf_event_header header; +* u64 time; +* u64 irq_period; * }; */ PERF_EVENT_PERIOD =4 ,/* * struct { -* struct perf_event_header header; -* u64 time; +* struct perf_event_header header; +* u64 time; * }; */ PERF_EVENT_THROTTLE = 5,
@@ -280,23 +280,23 @@ enum perf_event_type {* will be PERF_RECORD_* * * struct { -* struct perf_event_header header; +* struct perf_event_header header; * -* { u64 ip; } && PERF_RECORD_IP -* { u32 pid, tid; } && PERF_RECORD_TID -* { u64 time; } && PERF_RECORD_TIME -* { u64 addr; } && PERF_RECORD_ADDR -* { u64 config; } && PERF_RECORD_CONFIG -* { u32 cpu, res; } && PERF_RECORD_CPU +* { u64 ip; } && PERF_RECORD_IP +* { u32 pid, tid; } && PERF_RECORD_TID +* { u64 time; } && PERF_RECORD_TIME +* { u64 addr; } && PERF_RECORD_ADDR +* { u64 config; } && PERF_RECORD_CONFIG +* { u32 cpu, res; } && PERF_RECORD_CPU * -* { u64 nr; -* { u64 event, val; } cnt[nr]; } && PERF_RECORD_GROUP +* { u64 nr; +* { u64 event, val; } cnt[nr]; } && PERF_RECORD_GROUP * -* { u16 nr, -* hv, -* kernel, -* user; -* u64 ips[nr]; } && PERF_RECORD_CALLCHAIN +* { u16 nr, +* hv, +* kernel, +* user; +* u64 ips[nr]; } && PERF_RECORD_CALLCHAIN * }; */ };
@@ -406,7 +406,7 @@ struct perf_mmap_data {atomic_t wakeup;/* needs a wakeup */ struct perf_counter_mmap_page *user_page; -void *data_pages[0 ]; +void *data_pages[0 ]; };struct perf_pending_entry {
@@ -422,7 +422,7 @@ struct perf_counter {struct list_head list_entry;struct list_head event_entry;struct list_head sibling_list; -int nr_siblings; +int nr_siblings;struct perf_counter *group_leader;const struct pmu *pmu;
kernel/perf_counter.c +1 -3
@@ -2576,7 +2576,7 @@ static void perf_log_throttle(struct perf_counter *counter, int enable) .time = sched_clock(), }; - ret =perf_output_begin (&handle, counter,sizeof (throttle_event),0 ,0 ); + ret =perf_output_begin (&handle, counter,sizeof (throttle_event),1 ,0 );if (ret)return ;
@@ -3449,8 +3449,6 @@ void perf_counter_exit_task(struct task_struct *child)struct perf_counter_context *child_ctx;unsigned long flags; -WARN_ON_ONCE (child != current); - child_ctx = child->perf_counter_ctxp;if (likely (!child_ctx))