perf/core: some small patches
Subsystems (2)
cover perf/core: some small patches
This patch series includes some changes I found useful when reviewing and working with the code. Nothing exciting.
-Robert
PATCH 1/4 perf/core, x86: reduce number of CONFIG_X86_LOCAL_APIC macros
The function reserve_pmc_hardware() and release_pmc_hardware() were hard to read. This patch improves readablity of the code by removing most of the CONFIG_X86_LOCAL_APIC macros.
--- arch/x86/kernel/cpu/perf_event.c | 15 +++++++++------ 1 files changed, 9 insertions(+), 6 deletions(-)
arch/x86/kernel/cpu/perf_event.c +9 -6
@@ -313,9 +313,10 @@ again:static atomic_t active_events;static DEFINE_MUTEX (pmc_reserve_mutex); +#ifdef CONFIG_X86_LOCAL_APIC +static bool reserve_pmc_hardware (void ) { -#ifdef CONFIG_X86_LOCAL_APIC int i;if (nmi_watchdog ==NMI_LOCAL_APIC )
@@ -330,11 +331,9 @@ static bool reserve_pmc_hardware(void)if (!reserve_evntsel_nmi (x86_pmu.eventsel + i)) goto eventsel_fail; } -#endif return true; -#ifdef CONFIG_X86_LOCAL_APIC eventsel_fail:for (i--; i >=0 ; i--)release_evntsel_nmi (x86_pmu.eventsel + i);
@@ -349,12 +348,10 @@ perfctr_fail:enable_lapic_nmi_watchdog ();return false; -#endif }static void release_pmc_hardware (void ) { -#ifdef CONFIG_X86_LOCAL_APIC int i;for (i =0 ; i < x86_pmu.num_events; i++) {
@@ -364,9 +361,15 @@ static void release_pmc_hardware(void)if (nmi_watchdog ==NMI_LOCAL_APIC ) enable_lapic_nmi_watchdog(); -#endif } +#else + +static bool reserve_pmc_hardware (void ) {return true; } +static void release_pmc_hardware (void ) {} + +#endif +static int reserve_ds_buffers (void );static void release_ds_buffers (void );
Signature · 1 line
1.7.0
[tip:perf/core] perf/core, x86: Reduce number of CONFIG_X86_LOCAL_APIC macros
Commit-ID: b27ea29c6267889be255f2217fa7a6106e6a8b04 Gitweb: http://git.kernel.org/tip/b27ea29c6267889be255f2217fa7a6106e6a8b04 Author: Robert Richter <[email protected]> AuthorDate: Wed, 17 Mar 2010 12:49:10 +0100 Committer: Ingo Molnar <[email protected]> CommitDate: Wed, 17 Mar 2010 13:06:58 +0100
perf/core, x86: Reduce number of CONFIG_X86_LOCAL_APIC macros
The function reserve_pmc_hardware() and release_pmc_hardware() were hard to read. This patch improves readability of the code by removing most of the CONFIG_X86_LOCAL_APIC macros.
LKML-Reference: <[email protected]>
--- arch/x86/kernel/cpu/perf_event.c | 15 +++++++++------ 1 files changed, 9 insertions(+), 6 deletions(-)
arch/x86/kernel/cpu/perf_event.c +9 -6
@@ -313,9 +313,10 @@ again:static atomic_t active_events;static DEFINE_MUTEX (pmc_reserve_mutex); +#ifdef CONFIG_X86_LOCAL_APIC +static bool reserve_pmc_hardware (void ) { -#ifdef CONFIG_X86_LOCAL_APIC int i;if (nmi_watchdog ==NMI_LOCAL_APIC )
@@ -330,11 +331,9 @@ static bool reserve_pmc_hardware(void)if (!reserve_evntsel_nmi (x86_pmu.eventsel + i)) goto eventsel_fail; } -#endif return true; -#ifdef CONFIG_X86_LOCAL_APIC eventsel_fail:for (i--; i >=0 ; i--)release_evntsel_nmi (x86_pmu.eventsel + i);
@@ -349,12 +348,10 @@ perfctr_fail:enable_lapic_nmi_watchdog ();return false; -#endif }static void release_pmc_hardware (void ) { -#ifdef CONFIG_X86_LOCAL_APIC int i;for (i =0 ; i < x86_pmu.num_events; i++) {
@@ -364,9 +361,15 @@ static void release_pmc_hardware(void)if (nmi_watchdog ==NMI_LOCAL_APIC ) enable_lapic_nmi_watchdog(); -#endif } +#else + +static bool reserve_pmc_hardware (void ) {return true; } +static void release_pmc_hardware (void ) {} + +#endif +static int reserve_ds_buffers (void );static void release_ds_buffers (void );
PATCH 2/4 perf/core: correct files in MAINTAINERS entry
In reply to Robert RichterThis corrects the file entries for perf_events. The following files are catched now:
$ xargs | eval ls $(cat) | sort -u kernel/perf_event*.c include/linux/perf_event.h arch/*/kernel/perf_event*.c arch/*/kernel/*/perf_event*.c arch/*/kernel/*/*/perf_event*.c arch/*/include/asm/perf_event.h arch/*/lib/perf_event*.c arch/*/kernel/perf_callchain.c
arch/alpha/include/asm/perf_event.h
arch/arm/include/asm/perf_event.h
arch/arm/kernel/perf_event.c
arch/frv/include/asm/perf_event.h
arch/frv/lib/perf_event.c
arch/parisc/include/asm/perf_event.h
arch/powerpc/include/asm/perf_event.h
arch/powerpc/kernel/perf_callchain.c
arch/powerpc/kernel/perf_event.c
arch/s390/include/asm/perf_event.h
arch/sh/include/asm/perf_event.h
arch/sh/kernel/cpu/sh4a/perf_event.c
arch/sh/kernel/cpu/sh4/perf_event.c
arch/sh/kernel/perf_callchain.c
arch/sh/kernel/perf_event.c
arch/sparc/include/asm/perf_event.h
arch/sparc/kernel/perf_event.c
arch/x86/include/asm/perf_event.h
arch/x86/kernel/cpu/perf_event_amd.c
arch/x86/kernel/cpu/perf_event.c
arch/x86/kernel/cpu/perf_event_intel.c
arch/x86/kernel/cpu/perf_event_p6.c
include/linux/perf_event.h
kernel/perf_event.c
--- MAINTAINERS | 10 +++++----- 1 files changed, 5 insertions(+), 5 deletions(-)
MAINTAINERS +5 -5
@@ -4295,13 +4295,13 @@ M: Paul Mackerras <[email protected]> M: Ingo Molnar <[email protected]> M: Arnaldo Carvalho de Melo <[email protected]> S: Supported -F: kernel/perf_event.c +F: kernel/perf_event*.c F: include/linux/perf_event.h -F: arch/*/kernel/perf_event.c -F: arch/*/kernel/*/perf_event.c -F: arch/*/kernel/*/*/perf_event.c +F: arch/*/kernel/perf_event*.c +F: arch/*/kernel/*/perf_event*.c +F: arch/*/kernel/*/*/perf_event*.c F: arch/*/include/asm/perf_event.h -F: arch/*/lib/perf_event.c +F: arch/*/lib/perf_event*.c F: arch/*/kernel/perf_callchain.c F: tools/perf/
Signature · 1 line
1.7.0
[tip:perf/core] perf/core: Correct files in MAINTAINERS entry
Commit-ID: 141c4296cb630a7ed4c3730913bc3c0617ef9753 Gitweb: http://git.kernel.org/tip/141c4296cb630a7ed4c3730913bc3c0617ef9753 Author: Robert Richter <[email protected]> AuthorDate: Wed, 17 Mar 2010 12:49:11 +0100 Committer: Ingo Molnar <[email protected]> CommitDate: Wed, 17 Mar 2010 13:06:58 +0100
perf/core: Correct files in MAINTAINERS entry
This corrects the file entries for perf_events. The following files are caught now:
$ xargs | eval ls $(cat) | sort -u kernel/perf_event*.c include/linux/perf_event.h arch/*/kernel/perf_event*.c arch/*/kernel/*/perf_event*.c arch/*/kernel/*/*/perf_event*.c arch/*/include/asm/perf_event.h arch/*/lib/perf_event*.c arch/*/kernel/perf_callchain.c
arch/alpha/include/asm/perf_event.h
arch/arm/include/asm/perf_event.h
arch/arm/kernel/perf_event.c
arch/frv/include/asm/perf_event.h
arch/frv/lib/perf_event.c
arch/parisc/include/asm/perf_event.h
arch/powerpc/include/asm/perf_event.h
arch/powerpc/kernel/perf_callchain.c
arch/powerpc/kernel/perf_event.c
arch/s390/include/asm/perf_event.h
arch/sh/include/asm/perf_event.h
arch/sh/kernel/cpu/sh4a/perf_event.c
arch/sh/kernel/cpu/sh4/perf_event.c
arch/sh/kernel/perf_callchain.c
arch/sh/kernel/perf_event.c
arch/sparc/include/asm/perf_event.h
arch/sparc/kernel/perf_event.c
arch/x86/include/asm/perf_event.h
arch/x86/kernel/cpu/perf_event_amd.c
arch/x86/kernel/cpu/perf_event.c
arch/x86/kernel/cpu/perf_event_intel.c
arch/x86/kernel/cpu/perf_event_p6.c
include/linux/perf_event.h
kernel/perf_event.c
LKML-Reference: <[email protected]>
--- MAINTAINERS | 10 +++++----- 1 files changed, 5 insertions(+), 5 deletions(-)
MAINTAINERS +5 -5
@@ -4295,13 +4295,13 @@ M: Paul Mackerras <[email protected]> M: Ingo Molnar <[email protected]> M: Arnaldo Carvalho de Melo <[email protected]> S: Supported -F: kernel/perf_event.c +F: kernel/perf_event*.c F: include/linux/perf_event.h -F: arch/*/kernel/perf_event.c -F: arch/*/kernel/*/perf_event.c -F: arch/*/kernel/*/*/perf_event.c +F: arch/*/kernel/perf_event*.c +F: arch/*/kernel/*/perf_event*.c +F: arch/*/kernel/*/*/perf_event*.c F: arch/*/include/asm/perf_event.h -F: arch/*/lib/perf_event.c +F: arch/*/lib/perf_event*.c F: arch/*/kernel/perf_callchain.c F: tools/perf/
PATCH 3/4 perf/core, x86: remove cpu_hw_events.interrupts
In reply to Robert RichterThis member in the struct is not used anymore and can be removed.
--- arch/x86/kernel/cpu/perf_event.c | 1 - 1 files changed, 0 insertions(+), 1 deletions(-)
arch/x86/kernel/cpu/perf_event.c +0 -1
@@ -102,7 +102,6 @@ struct cpu_hw_events {*/ struct perf_event *events[X86_PMC_IDX_MAX ];/* in counter order */ unsigned long active_mask[BITS_TO_LONGS (X86_PMC_IDX_MAX )]; -unsigned long interrupts;int enabled;int n_events;
Signature · 1 line
1.7.0
[tip:perf/core] perf/core, x86: Remove cpu_hw_events.interrupts
Commit-ID: 10f1014d86fd4fe5087080d609b51183396c5e4c Gitweb: http://git.kernel.org/tip/10f1014d86fd4fe5087080d609b51183396c5e4c Author: Robert Richter <[email protected]> AuthorDate: Wed, 17 Mar 2010 12:49:12 +0100 Committer: Ingo Molnar <[email protected]> CommitDate: Wed, 17 Mar 2010 13:06:59 +0100
perf/core, x86: Remove cpu_hw_events.interrupts
This member in the struct is not used anymore and can be removed.
LKML-Reference: <[email protected]>
--- arch/x86/kernel/cpu/perf_event.c | 1 - 1 files changed, 0 insertions(+), 1 deletions(-)
arch/x86/kernel/cpu/perf_event.c +0 -1
@@ -102,7 +102,6 @@ struct cpu_hw_events {*/ struct perf_event *events[X86_PMC_IDX_MAX ];/* in counter order */ unsigned long active_mask[BITS_TO_LONGS (X86_PMC_IDX_MAX )]; -unsigned long interrupts;int enabled;int n_events;
PATCH 4/4 perf/core, x86: remove duplicate perf_event_mask variable
In reply to Robert RichterThe same information is stored also in x86_pmu.intel_ctrl. This patch removes perf_event_mask and instead uses x86_pmu.intel_ctrl directly.
--- arch/x86/kernel/cpu/perf_event.c | 9 +++------ 1 files changed, 3 insertions(+), 6 deletions(-)
arch/x86/kernel/cpu/perf_event.c +3 -6
@@ -75,8 +75,6 @@ copy_from_user_nmi(void *to, const void __user *from, unsigned long n)return len; } -static u64 perf_event_mask__read_mostly ; -struct event_constraint {union {unsigned long idxmsk[BITS_TO_LONGS (X86_PMC_IDX_MAX )];
@@ -1406,7 +1404,7 @@ void __init init_hw_perf_events(void) x86_pmu.num_events, X86_PMC_MAX_GENERIC); x86_pmu.num_events =X86_PMC_MAX_GENERIC ; } - perf_event_mask = (1 << x86_pmu.num_events) -1 ; + x86_pmu.intel_ctrl = (1 << x86_pmu.num_events) -1 ; perf_max_events = x86_pmu.num_events;if (x86_pmu.num_events_fixed >X86_PMC_MAX_FIXED ) {
@@ -1415,9 +1413,8 @@ void __init init_hw_perf_events(void) x86_pmu.num_events_fixed =X86_PMC_MAX_FIXED ; } - perf_event_mask |= + x86_pmu.intel_ctrl |= ((1LL << x86_pmu.num_events_fixed)-1 ) <<X86_PMC_IDX_FIXED ; - x86_pmu.intel_ctrl = perf_event_mask;perf_events_lapic_init ();register_die_notifier (&perf_event_nmi_notifier);
@@ -1442,7 +1439,7 @@ void __init init_hw_perf_events(void)pr_info ("... value mask: %016Lx\n" , x86_pmu.event_mask);pr_info ("... max period: %016Lx\n" , x86_pmu.max_period);pr_info ("... fixed-purpose events: %d\n" , x86_pmu.num_events_fixed); -pr_info ("... event mask: %016Lx\n" , perf_event_mask); +pr_info ("... event mask: %016Lx\n" , x86_pmu.intel_ctrl);perf_cpu_notifier (x86_pmu_notifier); }
Signature · 1 line
1.7.0
[tip:perf/core] perf/core, x86: Remove duplicate perf_event_mask variable
Commit-ID: d6dc0b4ead6e8720096ecfa3d9e899b47ddbc8ed Gitweb: http://git.kernel.org/tip/d6dc0b4ead6e8720096ecfa3d9e899b47ddbc8ed Author: Robert Richter <[email protected]> AuthorDate: Wed, 17 Mar 2010 12:49:13 +0100 Committer: Ingo Molnar <[email protected]> CommitDate: Wed, 17 Mar 2010 13:06:59 +0100
perf/core, x86: Remove duplicate perf_event_mask variable
The same information is stored also in x86_pmu.intel_ctrl. This patch removes perf_event_mask and instead uses x86_pmu.intel_ctrl directly.
LKML-Reference: <[email protected]>
--- arch/x86/kernel/cpu/perf_event.c | 9 +++------ 1 files changed, 3 insertions(+), 6 deletions(-)
arch/x86/kernel/cpu/perf_event.c +3 -6
@@ -75,8 +75,6 @@ copy_from_user_nmi(void *to, const void __user *from, unsigned long n)return len; } -static u64 perf_event_mask__read_mostly ; -struct event_constraint {union {unsigned long idxmsk[BITS_TO_LONGS (X86_PMC_IDX_MAX )];
@@ -1406,7 +1404,7 @@ void __init init_hw_perf_events(void) x86_pmu.num_events, X86_PMC_MAX_GENERIC); x86_pmu.num_events =X86_PMC_MAX_GENERIC ; } - perf_event_mask = (1 << x86_pmu.num_events) -1 ; + x86_pmu.intel_ctrl = (1 << x86_pmu.num_events) -1 ; perf_max_events = x86_pmu.num_events;if (x86_pmu.num_events_fixed >X86_PMC_MAX_FIXED ) {
@@ -1415,9 +1413,8 @@ void __init init_hw_perf_events(void) x86_pmu.num_events_fixed =X86_PMC_MAX_FIXED ; } - perf_event_mask |= + x86_pmu.intel_ctrl |= ((1LL << x86_pmu.num_events_fixed)-1 ) <<X86_PMC_IDX_FIXED ; - x86_pmu.intel_ctrl = perf_event_mask;perf_events_lapic_init ();register_die_notifier (&perf_event_nmi_notifier);
@@ -1442,7 +1439,7 @@ void __init init_hw_perf_events(void)pr_info ("... value mask: %016Lx\n" , x86_pmu.event_mask);pr_info ("... max period: %016Lx\n" , x86_pmu.max_period);pr_info ("... fixed-purpose events: %d\n" , x86_pmu.num_events_fixed); -pr_info ("... event mask: %016Lx\n" , perf_event_mask); +pr_info ("... event mask: %016Lx\n" , x86_pmu.intel_ctrl);perf_cpu_notifier (x86_pmu_notifier); }
Ingo Molnar
AppliedQuoted 2 lines · Robert Richter
This patch series includes some changes I found useful when reviewing and working with the code. Nothing exciting.
Applied, thanks Robert!
Ingo