Generalise ARM perf-events backend for oprofile
Subsystems (5)
v3 cover Generalise ARM perf-events backend for oprofile
The perf-events backend for OProfile that Will Deacon wrote in 8c1fc96f6fd1f361428ba805103af0d0eee65179 ("ARM: 6072/1: oprofile: use perf-events framework as backend") is of use to more architectures than just ARM. Move the code into drivers/oprofile/ so that SH can use it instead of the nearly identical copy of its OProfile code.
The benefit of the backend is that it becomes necessary to only maintain one copy of the PMU accessor functions for each architecture, with bug fixes and new features benefiting both OProfile and perf.
Note that I haven't been able to test these patches on an ARM board to see if I've caused any regressions. If anyone else could do that I'd appreciate it. Though, I have been able to compile this version of the series.
This patch series is based on,
git://git.kernel.org/pub/scm/linux/kernel/git/rric/oprofile.git core
These patches can also be found at,
git://git.kernel.org/pub/scm/linux/kernel/git/mfleming/sh-2.6.git perf-oprofile
Changes from v2:
- Rebased against Robert's oprofile core branch
- Moved even more of the ARM code into the generic oprofile code
- Broke the patches up into more logical steps
Changes from v1:
- Prefix the new functons with "oprofile_" instead of "op_".
- Fix ARM compilation errors
- Move all the oprofile-perf logic into oprofile_perf.c
- Include cleanup patch from Will
Matt Fleming (6):
perf: Add helper function to return number of counters
ARM: oprofile: Rename op_arm to oprofile_perf
ARM: oprofile: Move non-ARM code into separate init/exit functions
oprofile: Abstract the perf-events backend
ARM: Make oprofile depend on CONFIG_HW_PERF_EVENTS
sh: oprofile: Use perf-events oprofile backend
arch/arm/Kconfig | 2 +- arch/arm/kernel/perf_event.c | 6 + arch/arm/oprofile/Makefile | 2 +- arch/arm/oprofile/common.c | 315 +------------------------------------ arch/sh/Kconfig | 2 +- arch/sh/kernel/perf_event.c | 17 ++ arch/sh/oprofile/Makefile | 2 +- arch/sh/oprofile/common.c | 104 ++----------- arch/sh/oprofile/op_impl.h | 33 ---- drivers/oprofile/oprofile_perf.c | 322 ++++++++++++++++++++++++++++++++++++++ include/linux/oprofile.h | 6 + include/linux/perf_event.h | 1 + 12 files changed, 368 insertions(+), 444 deletions(-) delete mode 100644 arch/sh/oprofile/op_impl.h create mode 100644 drivers/oprofile/oprofile_perf.c
PATCH v3 1/6 perf: Add helper function to return number of counters
The number of counters for the registered pmu is needed in a few places so provide a helper function that returns this number.
--- arch/arm/kernel/perf_event.c | 6 ++++++ arch/arm/oprofile/common.c | 25 +++++++++++-------------- arch/sh/kernel/perf_event.c | 9 +++++++++ include/linux/perf_event.h | 1 + 4 files changed, 27 insertions(+), 14 deletions(-)
arch/arm/kernel/perf_event.c +6 -0
@@ -123,6 +123,12 @@ armpmu_get_max_events(void) }EXPORT_SYMBOL_GPL (armpmu_get_max_events); +int perf_num_counters (void ) +{ +return armpmu_get_max_events (); +} +EXPORT_SYMBOL_GPL (perf_num_counters); +#define HW_OP_UNSUPPORTED 0xFFFF#define C (_x) \
arch/arm/oprofile/common.c +11 -14
@@ -43,7 +43,6 @@ static DEFINE_MUTEX(op_arm_mutex);static struct op_counter_config *counter_config;static struct perf_event **perf_events[nr_cpumask_bits]; -static int perf_num_counters;/* * Overflow callback for oprofile.
@@ -54,11 +53,11 @@ static void op_overflow_handler(struct perf_event *event, int unused,int id;u32 cpu =smp_processor_id (); -for (id =0 ; id < perf_num_counters; ++id) +for (id =0 ; id <perf_num_counters (); ++id)if (perf_events[cpu][id] == event)break ; -if (id != perf_num_counters) +if (id !=perf_num_counters ())oprofile_add_sample (regs, id);else pr_warning("oprofile: ignoring spurious overflow "
@@ -76,7 +75,7 @@ static void op_perf_setup(void)u32 size =sizeof (struct perf_event_attr );struct perf_event_attr *attr; -for (i =0 ; i < perf_num_counters; ++i) { +for (i =0 ; i <perf_num_counters (); ++i) { attr = &counter_config[i].attr;memset (attr,0 , size); attr->type =PERF_TYPE_RAW ;
@@ -131,7 +130,7 @@ static int op_perf_start(void)int cpu, event, ret =0 ;for_each_online_cpu (cpu) { -for (event =0 ; event < perf_num_counters; ++event) { +for (event =0 ; event <perf_num_counters (); ++event) { ret =op_create_counter (cpu, event);if (ret) goto out;
@@ -150,7 +149,7 @@ static void op_perf_stop(void)int cpu, event;for_each_online_cpu (cpu) -for (event =0 ; event < perf_num_counters; ++event) +for (event =0 ; event <perf_num_counters (); ++event)op_destroy_counter (cpu, event); }
@@ -179,7 +178,7 @@ static int op_arm_create_files(struct super_block *sb, struct dentry *root) {unsigned int i; -for (i =0 ; i < perf_num_counters; i++) { +for (i =0 ; i <perf_num_counters (); i++) {struct dentry *dir;char buf[4 ];
@@ -353,14 +352,12 @@ int __init oprofile_arch_init(struct oprofile_operations *ops)memset (&perf_events,0 ,sizeof (perf_events)); - perf_num_counters =armpmu_get_max_events (); - - counter_config =kcalloc (perf_num_counters, + counter_config =kcalloc (perf_num_counters (),sizeof (struct op_counter_config ),GFP_KERNEL );if (!counter_config) {pr_info ("oprofile: failed to allocate %d " -"counters\n" , perf_num_counters); +"counters\n" ,perf_num_counters ()); ret = -ENOMEM ; goto out; }
@@ -370,11 +367,11 @@ int __init oprofile_arch_init(struct oprofile_operations *ops) goto out;for_each_possible_cpu (cpu) { - perf_events[cpu] =kcalloc (perf_num_counters, + perf_events[cpu] =kcalloc (perf_num_counters (),sizeof (struct perf_event *),GFP_KERNEL );if (!perf_events[cpu]) {pr_info ("oprofile: failed to allocate %d perf events " -"for cpu %d\n" , perf_num_counters, cpu); +"for cpu %d\n" ,perf_num_counters (), cpu); ret = -ENOMEM ; goto out; }
@@ -409,7 +406,7 @@ void __exit oprofile_arch_exit(void)struct perf_event *event;for_each_possible_cpu (cpu) { -for (id =0 ; id < perf_num_counters; ++id) { +for (id =0 ; id <perf_num_counters (); ++id) { event = perf_events[cpu][id];if (event)perf_event_release_kernel (event);
arch/sh/kernel/perf_event.c +9 -0
@@ -59,6 +59,15 @@ static inline int sh_pmu_initialized(void)return !!sh_pmu; } +int perf_num_counters (void ) +{ +if (!sh_pmu) +return 0 ; + +return sh_pmu->num_events; +} +EXPORT_SYMBOL_GPL (perf_num_counters); +/* * Release the PMU if this is the last perf_event. */
include/linux/perf_event.h +1 -0
@@ -849,6 +849,7 @@ extern int perf_max_events;extern const struct pmu *hw_perf_event_init (struct perf_event *event); +extern int perf_num_counters (void );extern void perf_event_task_sched_in (struct task_struct *task);extern void perf_event_task_sched_out (struct task_struct *task,struct task_struct *next);extern void perf_event_task_tick (struct task_struct *task);
Signature · 1 line
1.7.1
Re: [PATCH 1/6] perf: Add helper function to return number of counters
Quoted 91 lines · Matt Fleming
The number of counters for the registered pmu is needed in a few places so provide a helper function that returns this number.
Signed-off-by Matt Fleming <[email protected]>--- arch/arm/kernel/perf_event.c | 6 ++++++ arch/arm/oprofile/common.c | 25 +++++++++++-------------- arch/sh/kernel/perf_event.c | 9 +++++++++ include/linux/perf_event.h | 1 + 4 files changed, 27 insertions(+), 14 deletions(-)arch/arm/kernel/perf_event.c +6
-0@@ -123,6 +123,12 @@ armpmu_get_max_events(void) }EXPORT_SYMBOL_GPL (armpmu_get_max_events); +int perf_num_counters (void ) +{ +return armpmu_get_max_events (); +} +EXPORT_SYMBOL_GPL (perf_num_counters); +#define HW_OP_UNSUPPORTED 0xFFFF#define C (_x) \arch/arm/oprofile/common.c +6
-7@@ -43,7 +43,6 @@ static DEFINE_MUTEX(op_arm_mutex);static struct op_counter_config *counter_config;static struct perf_event **perf_events[nr_cpumask_bits]; -static int perf_num_counters;/* * Overflow callback for oprofile. @@ -54,11 +53,11 @@ static void op_overflow_handler(struct perf_event *event, int unused,int id;u32 cpu =smp_processor_id (); -for (id =0 ; id < perf_num_counters; ++id) +for (id =0 ; id <perf_num_counters (); ++id)if (perf_events[cpu][id] == event)break ; -if (id != perf_num_counters) +if (id !=perf_num_counters ())oprofile_add_sample (regs, id);else pr_warning("oprofile: ignoring spurious overflow "@@ -76,7 +75,7 @@ static void op_perf_setup(void)u32 size =sizeof (struct perf_event_attr );struct perf_event_attr *attr; -for (i =0 ; i < perf_num_counters; ++i) { +for (i =0 ; i <perf_num_counters (); ++i) { attr = &counter_config[i].attr;memset (attr,0 , size); attr->type =PERF_TYPE_RAW ;@@ -131,7 +130,7 @@ static int op_perf_start(void)int cpu, event, ret =0 ;for_each_online_cpu (cpu) { -for (event =0 ; event < perf_num_counters; ++event) { +for (event =0 ; event <perf_num_counters (); ++event) { ret =op_create_counter (cpu, event);if (ret) goto out;@@ -150,7 +149,7 @@ static void op_perf_stop(void)int cpu, event;for_each_online_cpu (cpu) -for (event =0 ; event < perf_num_counters; ++event) +for (event =0 ; event <perf_num_counters (); ++event)op_destroy_counter (cpu, event); }@@ -179,7 +178,7 @@ static int op_arm_create_files(struct super_block *sb, struct dentry *root) {unsigned int i; -for (i =0 ; i < perf_num_counters; i++) { +for (i =0 ; i <perf_num_counters (); i++) {struct dentry *dir;char buf[4 ];
arch/arm/oprofile/common.c int __init oprofile_arch_init(struct oprofile_operations *ops) · line 357
Quoted 5 lines
arch/arm/oprofile/common.c +0
-2@@ -353,14 +352,12 @@ int __init oprofile_arch_init(struct oprofile_operations *ops)memset (&perf_events,0 ,sizeof (perf_events)); - perf_num_counters =armpmu_get_max_events (); -
Maybe we keep this variable and only call perf_num_counters() once during initialization as the function's return value should be constant. Otherwise this will cause unnecessary cache pollution and execution cycles esp. in the overflow handler.
Also it wouldn't be safe if the value changes anyway, for example you enable 4 counters and and after the value changed you disable only 3.
Module initialization should fail on errors or if no counters are available.
-Robert
Quoted 70 lines
arch/arm/oprofile/common.c +5
-5- counter_config =kcalloc (perf_num_counters, + counter_config =kcalloc (perf_num_counters (),sizeof (struct op_counter_config ),GFP_KERNEL );if (!counter_config) {pr_info ("oprofile: failed to allocate %d " -"counters\n" , perf_num_counters); +"counters\n" ,perf_num_counters ()); ret = -ENOMEM ; goto out; }@@ -370,11 +367,11 @@ int __init oprofile_arch_init(struct oprofile_operations *ops) goto out;for_each_possible_cpu (cpu) { - perf_events[cpu] =kcalloc (perf_num_counters, + perf_events[cpu] =kcalloc (perf_num_counters (),sizeof (struct perf_event *),GFP_KERNEL );if (!perf_events[cpu]) {pr_info ("oprofile: failed to allocate %d perf events " -"for cpu %d\n" , perf_num_counters, cpu); +"for cpu %d\n" ,perf_num_counters (), cpu); ret = -ENOMEM ; goto out; }@@ -409,7 +406,7 @@ void __exit oprofile_arch_exit(void)struct perf_event *event;for_each_possible_cpu (cpu) { -for (id =0 ; id < perf_num_counters; ++id) { +for (id =0 ; id <perf_num_counters (); ++id) { event = perf_events[cpu][id];if (event)perf_event_release_kernel (event);arch/sh/kernel/perf_event.c +9
-0@@ -59,6 +59,15 @@ static inline int sh_pmu_initialized(void)return !!sh_pmu; } +int perf_num_counters (void ) +{ +if (!sh_pmu) +return 0 ; + +return sh_pmu->num_events; +} +EXPORT_SYMBOL_GPL (perf_num_counters); +/* * Release the PMU if this is the last perf_event. */ include/linux/perf_event.h +1
-0@@ -849,6 +849,7 @@ extern int perf_max_events;extern const struct pmu *hw_perf_event_init (struct perf_event *event); +extern int perf_num_counters (void );extern void perf_event_task_sched_in (struct task_struct *task);extern void perf_event_task_sched_out (struct task_struct *task,struct task_struct *next);extern void perf_event_task_tick (struct task_struct *task);Signature · 1 line
1.7.1
Signature · 2 lines
Advanced Micro Devices, Inc. Operating System Research Center
PATCH v3 2/6 ARM: oprofile: Rename op_arm to oprofile_perf
In reply to Matt FlemingIn preparation for moving the generic functions out of this file, give the functions more general names (e.g. remove "arm" from the names).
--- arch/arm/oprofile/common.c | 68 ++++++++++++++++++++++---------------------- 1 files changed, 34 insertions(+), 34 deletions(-)
arch/arm/oprofile/common.c +34 -34
@@ -38,8 +38,8 @@ struct op_counter_config {struct perf_event_attr attr; }; -static int op_arm_enabled; -static DEFINE_MUTEX (op_arm_mutex); +static int oprofile_perf_enabled; +static DEFINE_MUTEX (oprofile_perf_mutex);static struct op_counter_config *counter_config;static struct perf_event **perf_events[nr_cpumask_bits];
@@ -65,7 +65,7 @@ static void op_overflow_handler(struct perf_event *event, int unused, }/* -* Called by op_arm_setup to create perf attributes to mirror the oprofile +* Called by oprofile_perf_setup to create perf attributes to mirror the oprofile * settings in counter_config. Attributes are created as `pinned' events and * so are permanently scheduled on the PMU. */
@@ -122,7 +122,7 @@ static void op_destroy_counter(int cpu, int event) }/* -* Called by op_arm_start to create active perf events based on the +* Called by oprofile_perf_start to create active perf events based on the * perviously configured attributes. */ static int op_perf_start (void )
@@ -142,7 +142,7 @@ out: }/* -* Called by op_arm_stop at the end of a profiling run. +* Called by oprofile_perf_stop at the end of a profiling run. */ static void op_perf_stop (void ) {
@@ -174,7 +174,7 @@ static char *op_name_from_perf_id(enum arm_perf_pmu_ids id) } } -static int op_arm_create_files (struct super_block *sb,struct dentry *root) +static int oprofile_perf_create_files (struct super_block *sb,struct dentry *root) {unsigned int i;
@@ -195,7 +195,7 @@ static int op_arm_create_files(struct super_block *sb, struct dentry *root)return 0 ; } -static int op_arm_setup (void ) +static int oprofile_perf_setup (void ) {spin_lock (&oprofilefs_lock);op_perf_setup ();
@@ -203,54 +203,54 @@ static int op_arm_setup(void)return 0 ; } -static int op_arm_start (void ) +static int oprofile_perf_start (void ) {int ret = -EBUSY ; -mutex_lock (&op_arm_mutex); -if (!op_arm_enabled) { +mutex_lock (&oprofile_perf_mutex); +if (!oprofile_perf_enabled) { ret =0 ;op_perf_start (); - op_arm_enabled =1 ; + oprofile_perf_enabled =1 ; } -mutex_unlock (&op_arm_mutex); +mutex_unlock (&oprofile_perf_mutex);return ret; } -static void op_arm_stop (void ) +static void oprofile_perf_stop (void ) { -mutex_lock (&op_arm_mutex); -if (op_arm_enabled) +mutex_lock (&oprofile_perf_mutex); +if (oprofile_perf_enabled)op_perf_stop (); - op_arm_enabled =0 ; -mutex_unlock (&op_arm_mutex); + oprofile_perf_enabled =0 ; +mutex_unlock (&oprofile_perf_mutex); }#ifdef CONFIG_PM -static int op_arm_suspend (struct platform_device *dev,pm_message_t state) +static int oprofile_perf_suspend (struct platform_device *dev,pm_message_t state) { -mutex_lock (&op_arm_mutex); -if (op_arm_enabled) +mutex_lock (&oprofile_perf_mutex); +if (oprofile_perf_enabled)op_perf_stop (); -mutex_unlock (&op_arm_mutex); +mutex_unlock (&oprofile_perf_mutex);return 0 ; } -static int op_arm_resume (struct platform_device *dev) +static int oprofile_perf_resume (struct platform_device *dev) { -mutex_lock (&op_arm_mutex); -if (op_arm_enabled &&op_perf_start ()) - op_arm_enabled =0 ; -mutex_unlock (&op_arm_mutex); +mutex_lock (&oprofile_perf_mutex); +if (oprofile_perf_enabled &&op_perf_start ()) + oprofile_perf_enabled =0 ; +mutex_unlock (&oprofile_perf_mutex);return 0 ; }static struct platform_driver oprofile_driver = { .driver = { - .name ="arm-oprofile" , + .name ="perf-oprofile" , }, - .resume = op_arm_resume, - .suspend = op_arm_suspend, + .resume = oprofile_perf_resume, + .suspend = oprofile_perf_suspend, };static struct platform_device *oprofile_pdev;
@@ -378,11 +378,11 @@ int __init oprofile_arch_init(struct oprofile_operations *ops) } ops->backtrace = arm_backtrace; - ops->create_files = op_arm_create_files; - ops->setup = op_arm_setup; - ops->start = op_arm_start; - ops->stop = op_arm_stop; - ops->shutdown = op_arm_stop; + ops->create_files = oprofile_perf_create_files; + ops->setup = oprofile_perf_setup; + ops->start = oprofile_perf_start; + ops->stop = oprofile_perf_stop; + ops->shutdown = oprofile_perf_stop; ops->cpu_type =op_name_from_perf_id (armpmu_get_pmu_id ());if (!ops->cpu_type)
Signature · 1 line
1.7.1
Re: [PATCH 2/6] ARM: oprofile: Rename op_arm to oprofile_perf
arch/arm/oprofile/common.c static int op_arm_setup(void) · line 250
Quoted 12 lines · Matt Fleming
In preparation for moving the generic functions out of this file, give the functions more general names (e.g. remove "arm" from the names).
Signed-off-by Matt Fleming <[email protected]>--- arch/arm/oprofile/common.c | 68 ++++++++++++++++++++++---------------------- 1 files changed, 34 insertions(+), 34 deletions(-)static struct
platform_driveroprofile_driver= {arch/arm/oprofile/common.c +1
-1.driver = { - .name = "arm-oprofile", + .name = "perf-oprofile",
This should be "oprofile-perf" instead, otherwise the driver belongs to perf.
-Robert
Quoted 6 lines
arch/arm/oprofile/common.c +2
-2}, - .resume = op_arm_resume, - .suspend = op_arm_suspend, + .resume = oprofile_perf_resume, + .suspend = oprofile_perf_suspend, };
Signature · 2 lines
Advanced Micro Devices, Inc. Operating System Research Center
PATCH v3 3/6 ARM: oprofile: Move non-ARM code into separate init/exit functions
In reply to Matt FlemingIn preparation for moving the majority of this oprofile code into an architecture-neutral place separate the architecture-independent code into oprofile_perf_init() and oprofile_perf_exit().
--- arch/arm/oprofile/common.c | 34 +++++++++++++++++++++++++--------- 1 files changed, 25 insertions(+), 9 deletions(-)
arch/arm/oprofile/common.c +25 -9
@@ -346,7 +346,7 @@ static void arm_backtrace(struct pt_regs * const regs, unsigned int depth) tail =user_backtrace (tail); } -int __init oprofile_arch_init (struct oprofile_operations *ops) +int __init oprofile_perf_init (struct oprofile_operations *ops) {int cpu, ret =0 ;
@@ -377,13 +377,16 @@ int __init oprofile_arch_init(struct oprofile_operations *ops) } } - ops->backtrace = arm_backtrace; - ops->create_files = oprofile_perf_create_files; - ops->setup = oprofile_perf_setup; - ops->start = oprofile_perf_start; - ops->stop = oprofile_perf_stop; - ops->shutdown = oprofile_perf_stop; - ops->cpu_type =op_name_from_perf_id (armpmu_get_pmu_id ()); +if (!ops->create_files) + ops->create_files = oprofile_perf_create_files; +if (!ops->setup) + ops->setup = oprofile_perf_setup; +if (!ops->start) + ops->start = oprofile_perf_start; +if (!ops->stop) + ops->stop = oprofile_perf_stop; +if (!ops->shutdown) + ops->shutdown = oprofile_perf_stop;if (!ops->cpu_type) ret = -ENODEV ;
@@ -400,7 +403,15 @@ out:return ret; } -void __exit oprofile_arch_exit(void) +int __init oprofile_arch_init (struct oprofile_operations *ops) +{ + ops->backtrace = arm_backtrace; + ops->cpu_type =op_name_from_perf_id (armpmu_get_pmu_id ()); + +return oprofile_perf_init (ops); +} + +void __exit oprofile_perf_exit(void) {int cpu, id;struct perf_event *event;
@@ -418,6 +429,11 @@ void __exit oprofile_arch_exit(void)kfree (counter_config);exit_driverfs (); } + +void __exit oprofile_arch_exit(void) +{ +oprofile_perf_exit (); +}#else int __init oprofile_arch_init (struct oprofile_operations *ops) {
Signature · 1 line
1.7.1
Re: [PATCH 3/6] ARM: oprofile: Move non-ARM code into separate init/exit functions
Quoted 33 lines · Matt Fleming
In preparation for moving the majority of this oprofile code into an architecture-neutral place separate the architecture-independent code into
oprofile_perf_init()andoprofile_perf_exit().Signed-off-by Matt Fleming <[email protected]>--- arch/arm/oprofile/common.c | 34 +++++++++++++++++++++++++--------- 1 files changed, 25 insertions(+), 9 deletions(-)arch/arm/oprofile/common.c +1
-8@@ -346,7 +346,7 @@ static void arm_backtrace(struct pt_regs * const regs, unsigned int depth) tail =user_backtrace (tail); } -int __init oprofile_arch_init (struct oprofile_operations *ops) +int __init oprofile_perf_init (struct oprofile_operations *ops) {int cpu, ret =0 ;@@ -377,13 +377,16 @@ int __init oprofile_arch_init(struct oprofile_operations *ops) } } - ops->backtrace = arm_backtrace; - ops->create_files = oprofile_perf_create_files; - ops->setup = oprofile_perf_setup; - ops->start = oprofile_perf_start; - ops->stop = oprofile_perf_stop; - ops->shutdown = oprofile_perf_stop; - ops->cpu_type =op_name_from_perf_id (armpmu_get_pmu_id ());
arch/arm/oprofile/common.c int __init oprofile_arch_init(struct oprofile_operations *ops) · line 389
Quoted 10 lines
arch/arm/oprofile/common.c +10
-0+if (!ops->create_files) + ops->create_files = oprofile_perf_create_files; +if (!ops->setup) + ops->setup = oprofile_perf_setup; +if (!ops->start) + ops->start = oprofile_perf_start; +if (!ops->stop) + ops->stop = oprofile_perf_stop; +if (!ops->shutdown) + ops->shutdown = oprofile_perf_stop;
I rather tend to not check this and instand hard overwrite it. Do you have something in mind why we have checks here? I mean, if something must be customizable, the arch init could overwrite it after doing perf init.
-Robert
Quoted 36 lines
arch/arm/oprofile/common.c +14
-1if (!ops->cpu_type) ret = -ENODEV ;@@ -400,7 +403,15 @@ out:return ret; } -void __exit oprofile_arch_exit(void) +int __init oprofile_arch_init (struct oprofile_operations *ops) +{ + ops->backtrace = arm_backtrace; + ops->cpu_type =op_name_from_perf_id (armpmu_get_pmu_id ()); + +return oprofile_perf_init (ops); +} + +void __exit oprofile_perf_exit(void) {int cpu, id;struct perf_event *event;@@ -418,6 +429,11 @@ void __exit oprofile_arch_exit(void)kfree (counter_config);exit_driverfs (); } + +void __exit oprofile_arch_exit(void) +{ +oprofile_perf_exit (); +}#else int __init oprofile_arch_init (struct oprofile_operations *ops) {Signature · 1 line
1.7.1
Signature · 2 lines
Advanced Micro Devices, Inc. Operating System Research Center
PATCH v3 4/6 oprofile: Abstract the perf-events backend
In reply to Matt FlemingMove the perf-events backend from arch/arm/oprofile into drivers/oprofile so that the code can be shared between architectures.
This allows each architecture to maintain only a single copy of the PMU accessor functions instead of one for both perf and OProfile. It also becomes possible for other architectures to delete much of their OProfile code in favour of the common code now available in drivers/oprofile/oprofile_perf.c.
--- arch/arm/oprofile/Makefile | 2 +- arch/arm/oprofile/common.c | 315 ------------------------------------- drivers/oprofile/oprofile_perf.c | 322 ++++++++++++++++++++++++++++++++++++++ include/linux/oprofile.h | 6 + 4 files changed, 329 insertions(+), 316 deletions(-) create mode 100644 drivers/oprofile/oprofile_perf.c
arch/arm/oprofile/Makefile +1 -1
@@ -4,6 +4,6 @@ DRIVER_OBJS = $(addprefix ../../../drivers/oprofile/, \ oprof.o cpu_buffer.o buffer_sync.o \ event_buffer.o oprofile_files.o \ oprofilefs.o oprofile_stats.o \ - timer_int.o ) + timer_int.o oprofile_perf.o ) oprofile-y := $(DRIVER_OBJS) common.o
arch/arm/oprofile/common.c +0 -315
339 lines not on this page · raw message
drivers/oprofile/oprofile_perf.c new file +322 -0
322 lines not on this page · raw message
include/linux/oprofile.h +6 -0
@@ -15,6 +15,7 @@#include <linux/types.h> #include <linux/spinlock.h> +#include <linux/init.h> #include <asm/atomic.h> /* Each escaped entry is prefixed by ESCAPE_CODE
@@ -185,4 +186,9 @@ int oprofile_add_data(struct op_entry *entry, unsigned long val);int oprofile_add_data64 (struct op_entry *entry,u64 val);int oprofile_write_commit (struct op_entry *entry); +#ifdef CONFIG_PERF_EVENTS +int __init oprofile_perf_init (struct oprofile_operations *ops); +void __exit oprofile_perf_exit(void); +#endif /* CONFIG_PERF_EVENTS */ +#endif /* OPROFILE_H */
Signature · 1 line
1.7.1
Re: [PATCH 4/6] oprofile: Abstract the perf-events backend
Quoted 9 lines · Matt Fleming
Move the perf-events backend from
arch/arm/oprofileintodrivers/oprofileso that the code can be shared between architectures.This allows each architecture to maintain only a single copy of the PMU accessor functions instead of one for both perf and OProfile. It also becomes possible for other architectures to delete much of their OProfile code in favour of the common code now available in
drivers/oprofile/oprofile_perf.c.
Quoted 8 lines
Signed-off-by Matt Fleming <[email protected]>--- arch/arm/oprofile/Makefile | 2 +- arch/arm/oprofile/common.c | 315 ------------------------------------- drivers/oprofile/oprofile_perf.c | 322 ++++++++++++++++++++++++++++++++++++++ include/linux/oprofile.h | 6 + 4 files changed, 329 insertions(+), 316 deletions(-) create mode 100644 drivers/oprofile/oprofile_perf.c
This patch looks good.
-Robert
Signature · 2 lines
Advanced Micro Devices, Inc. Operating System Research Center
PATCH v3 5/6 ARM: Make oprofile depend on CONFIG_HW_PERF_EVENTS
In reply to Matt FlemingCurrently, oprofile support is only functional if CONFIG_HW_PERF_EVENTS is set. If this symbol is not set, oprofile initialisation will fail at runtime. Instead of allowing the oprofile code to build but fail at runtime it seems less confusing to not allow the code to be built unless hardware performance counter support is available.
--- arch/arm/Kconfig | 2 +- arch/arm/oprofile/common.c | 9 --------- 2 files changed, 1 insertions(+), 10 deletions(-)
arch/arm/Kconfig +1 -1
@@ -14,7 +14,7 @@ config ARM select RTC_LIB select SYS_SUPPORTS_APM_EMULATION select GENERIC_ATOMIC64 if (!CPU_32v6K) - select HAVE_OPROFILE if (HAVE_PERF_EVENTS) + select HAVE_OPROFILE if (HW_PERF_EVENTS) select HAVE_ARCH_KGDB select HAVE_KPROBES if (!XIP_KERNEL) select HAVE_KRETPROBES if (HAVE_KPROBES)
arch/arm/oprofile/common.c +0 -9
@@ -24,7 +24,6 @@#include <asm/perf_event.h> #include <asm/ptrace.h> -#ifdef CONFIG_HW_PERF_EVENTS static char *op_name_from_perf_id (enum arm_perf_pmu_ids id) {switch (id) {
@@ -119,11 +118,3 @@ void __exit oprofile_arch_exit(void) {oprofile_perf_exit (); } -#else -int __init oprofile_arch_init (struct oprofile_operations *ops) -{ -pr_info ("oprofile: hardware counters not available\n" ); -return -ENODEV ; -} -void __exit oprofile_arch_exit(void) {} -#endif /* CONFIG_HW_PERF_EVENTS */
Signature · 1 line
1.7.1
Re: [PATCH 5/6] ARM: Make oprofile depend on CONFIG_HW_PERF_EVENTS
Hi Matt,
Quoted 50 lines · Matt Fleming
Currently, oprofile support is only functional if
CONFIG_HW_PERF_EVENTSis set. If this symbol is not set, oprofile initialisation will fail at runtime. Instead of allowing the oprofile code to build but fail at runtime it seems less confusing to not allow the code to be built unless hardware performance counter support is available.Signed-off-by Matt Fleming <[email protected]>--- arch/arm/Kconfig | 2 +- arch/arm/oprofile/common.c | 9 --------- 2 files changed, 1 insertions(+), 10 deletions(-)arch/arm/Kconfig +1
-1@@ -14,7 +14,7 @@ config ARM select RTC_LIB select SYS_SUPPORTS_APM_EMULATION select GENERIC_ATOMIC64 if (!CPU_32v6K) - select HAVE_OPROFILE if (HAVE_PERF_EVENTS) + select HAVE_OPROFILE if (HW_PERF_EVENTS) select HAVE_ARCH_KGDB select HAVE_KPROBES if (!XIP_KERNEL) select HAVE_KRETPROBES if (HAVE_KPROBES)arch/arm/oprofile/common.c +0
-10@@ -24,7 +24,6 @@#include <asm/perf_event.h> #include <asm/ptrace.h> -#ifdef CONFIG_HW_PERF_EVENTS static char *op_name_from_perf_id (enum arm_perf_pmu_ids id) {switch (id) {@@ -119,11 +118,3 @@ void __exit oprofile_arch_exit(void) {oprofile_perf_exit (); } -#else -int __init oprofile_arch_init (struct oprofile_operations *ops) -{ -pr_info ("oprofile: hardware counters not available\n" ); -return -ENODEV ; -} -void __exit oprofile_arch_exit(void) {} -#endif /* CONFIG_HW_PERF_EVENTS */ --
Quoted 1 line
1.7.1
When oprofile_arch_init fails (-ENODEV), oprofile will fall back to timer mode. With this patch, how can you make use of a timer fallback?
I'll try and get around to testing the rest of this series today.
Cheers,
Will
Re: [PATCH 5/6] ARM: Make oprofile depend on CONFIG_HW_PERF_EVENTS
Quoted 9 lines · Will Deacon
Hi Matt,
Quoted 6 lines · Matt Fleming
Currently, oprofile support is only functional if
CONFIG_HW_PERF_EVENTSis set. If this symbol is not set, oprofile initialisation will fail at runtime. Instead of allowing the oprofile code to build but fail at runtime it seems less confusing to not allow the code to be built unless hardware performance counter support is available.
Quoted 8 lines
Quoted 5 lines
Signed-off-by Matt Fleming <[email protected]>--- arch/arm/Kconfig | 2 +- arch/arm/oprofile/common.c | 9 --------- 2 files changed, 1 insertions(+), 10 deletions(-)When
oprofile_arch_initfails (-ENODEV), oprofile will fall back to timer mode. With this patch, how can you make use of a timer fallback?
True, if you want an error at compile time, maybe we use the #error pragma instead. But falling back to timer mode is fine to me too. Will leave that decision to the arm folks.
-Robert
Quoted 10 lines
I'll try and get around to testing the rest of this series today.
Cheers,
Will
Signature · 2 lines
Advanced Micro Devices, Inc. Operating System Research Center
Re: [PATCH 5/6] ARM: Make oprofile depend on CONFIG_HW_PERF_EVENTS
In reply to Matt FlemingHello.
Quoted 17 lines · Matt Fleming
Currently, oprofile support is only functional if
CONFIG_HW_PERF_EVENTSis set. If this symbol is not set, oprofile initialisation will fail at runtime. Instead of allowing the oprofile code to build but fail at runtime it seems less confusing to not allow the code to be built unless hardware performance counter support is available.Signed-off-by Matt Fleming<[email protected]>--- arch/arm/Kconfig | 2 +- arch/arm/oprofile/common.c | 9 --------- 2 files changed, 1 insertions(+), 10 deletions(-)arch/arm/Kconfig +0
-0
arch/arm/Kconfig config ARM · line 17
Quoted 5 lines
arch/arm/Kconfig +1
-1@@ -14,7 +14,7 @@ config ARM select RTC_LIB select SYS_SUPPORTS_APM_EMULATION select GENERIC_ATOMIC64 if (!CPU_32v6K) - select HAVE_OPROFILE if (HAVE_PERF_EVENTS) + select HAVE_OPROFILE if (HW_PERF_EVENTS)
Could remove useless parens while at it...
WBR, Sergei
PATCH v3 6/6 sh: oprofile: Use perf-events oprofile backend
In reply to Matt FlemingNow that we've got a generic perf-events based oprofile backend we might as well make use of it seeing as SH doesn't do anything special with its oprofile backend.
--- arch/sh/Kconfig | 2 +- arch/sh/kernel/perf_event.c | 8 +++ arch/sh/oprofile/Makefile | 2 +- arch/sh/oprofile/common.c | 104 ++++-------------------------------------- arch/sh/oprofile/op_impl.h | 33 -------------- 5 files changed, 20 insertions(+), 129 deletions(-) delete mode 100644 arch/sh/oprofile/op_impl.h
arch/sh/Kconfig +1 -1
@@ -11,7 +11,7 @@ config SUPERH select HAVE_CLK select HAVE_IDE if HAS_IOPORT select HAVE_MEMBLOCK - select HAVE_OPROFILE + select HAVE_OPROFILE if PERF_EVENTS select HAVE_GENERIC_DMA_COHERENT select HAVE_ARCH_TRACEHOOK select HAVE_DMA_API_DEBUG
arch/sh/kernel/perf_event.c +8 -0
@@ -59,6 +59,14 @@ static inline int sh_pmu_initialized(void)return !!sh_pmu; } +const char *sh_pmu_name (void ) +{ +if (!sh_pmu) +return NULL ; + +return sh_pmu->name; +} +int perf_num_counters (void ) {if (!sh_pmu)
arch/sh/oprofile/Makefile +1 -1
@@ -4,6 +4,6 @@ DRIVER_OBJS = $(addprefix ../../../drivers/oprofile/, \ oprof.o cpu_buffer.o buffer_sync.o \ event_buffer.o oprofile_files.o \ oprofilefs.o oprofile_stats.o \ - timer_int.o ) + timer_int.o oprofile_perf.o ) oprofile-y := $(DRIVER_OBJS) common.o backtrace.o
arch/sh/oprofile/common.c +10 -94
123 lines not on this page · raw message
arch/sh/oprofile/op_impl.h deleted +0 -33
@@ -1,33 +0,0 @@ -#ifndef __OP_IMPL_H -#define __OP_IMPL_H - -/* Per-counter configuration as set via oprofilefs. */ -struct op_counter_config { -unsigned long enabled; -unsigned long event; - -unsigned long count; - -/* Dummy values for userspace tool compliance */ -unsigned long kernel; -unsigned long user; -unsigned long unit_mask; -}; - -/* Per-architecture configury and hooks. */ -struct op_sh_model { -void (*reg_setup)(struct op_counter_config *); -int (*create_files)(struct super_block *sb,struct dentry *dir); -void (*cpu_setup)(void *dummy); -int (*init)(void ); -void (*exit)(void ); -void (*cpu_start)(void *args); -void (*cpu_stop)(void *args); -char *cpu_type; -unsigned char num_counters; -}; - -/* arch/sh/oprofile/common.c */ -extern void sh_backtrace (struct pt_regs *const regs,unsigned int depth); - -#endif /* __OP_IMPL_H */
Signature · 1 line
1.7.1
Re: [PATCH 6/6] sh: oprofile: Use perf-events oprofile backend
Quoted 19 lines · Matt Fleming
Now that we've got a generic perf-events based oprofile backend we might as well make use of it seeing as SH doesn't do anything special with its oprofile backend.
Signed-off-by Matt Fleming <[email protected]>--- arch/sh/Kconfig | 2 +- arch/sh/kernel/perf_event.c | 8 +++ arch/sh/oprofile/Makefile | 2 +- arch/sh/oprofile/common.c | 104 ++++-------------------------------------- arch/sh/oprofile/op_impl.h | 33 -------------- 5 files changed, 20 insertions(+), 129 deletions(-) delete mode 100644 arch/sh/oprofile/op_impl.harch/sh/Kconfig +0
-0
arch/sh/Kconfig config SUPERH · line 14
Quoted 5 lines
arch/sh/Kconfig +1
-1@@ -11,7 +11,7 @@ config SUPERH select HAVE_CLK select HAVE_IDE if HAS_IOPORT select HAVE_MEMBLOCK - select HAVE_OPROFILE + select HAVE_OPROFILE if PERF_EVENTS
Same here, we might want to fall back to timer mode.
Quoted 8 lines
arch/sh/Kconfig +0
-0select HAVE_GENERIC_DMA_COHERENT select HAVE_ARCH_TRACEHOOK select HAVE_DMA_API_DEBUGarch/sh/kernel/perf_event.c +0
-0
arch/sh/kernel/perf_event.c static inline int sh_pmu_initialized(void) · line 68
Quoted 10 lines
arch/sh/kernel/perf_event.c +7
-0@@ -59,6 +59,14 @@ static inline int sh_pmu_initialized(void)return !!sh_pmu; } +const char *sh_pmu_name (void ) +{ +if (!sh_pmu) +return NULL ; + +return sh_pmu->name; +}
Couldn't we make this a generic function like perf_num_counters()?
[...]
arch/sh/kernel/perf_event.c static inline int sh_pmu_initialized(void)
Quoted 6 lines
arch/sh/kernel/perf_event.c +1
-2void oprofile_arch_exit (void ) { -if (model && model->exit) - model->exit (); +oprofile_perf_exit (); }
This will probalby cause a section missmatch. Use __exit marker for oprofile_arch_exit().
-Robert
Signature · 2 lines
Advanced Micro Devices, Inc. Operating System Research Center
Re: [PATCH 6/6] sh: oprofile: Use perf-events oprofile backend
Quoted 8 lines · Robert Richter
Quoted 8 lines
arch/sh/kernel/perf_event.c +0
-0@@ -59,6 +59,14 @@ static inline int sh_pmu_initialized(void)return !!sh_pmu; }
Quoted 9 lines
arch/sh/kernel/perf_event.c static inline int sh_pmu_initialized(void) · line 68
Quoted 7 lines
arch/sh/kernel/perf_event.c +7
-0+const char *sh_pmu_name (void ) +{ +if (!sh_pmu) +return NULL ; + +return sh_pmu->name; +}Couldn't we make this a generic function like
perf_num_counters()?
Well, ARM doesn't have names as strings for its pmus currently. What's more, ARM wouldn't use it; SH would be the only user of this function. I don't think this one makes sense to be a generic function.
Re: [PATCH 6/6] sh: oprofile: Use perf-events oprofile backend
Quoted 19 lines · Matt Fleming
Quoted 8 lines · Robert Richter
Quoted 8 lines
arch/sh/kernel/perf_event.c +0
-0@@ -59,6 +59,14 @@ static inline int sh_pmu_initialized(void)return !!sh_pmu; }Quoted 9 lines
arch/sh/kernel/perf_event.c static inline int sh_pmu_initialized(void) · line 68
Quoted 7 lines
arch/sh/kernel/perf_event.c +7
-0+const char *sh_pmu_name (void ) +{ +if (!sh_pmu) +return NULL ; + +return sh_pmu->name; +}Couldn't we make this a generic function like
perf_num_counters()?
Quoted 3 lines
Well, ARM doesn't have names as strings for its pmus currently. What's more, ARM wouldn't use it; SH would be the only user of this function. I don't think this one makes sense to be a generic function.
I didn't catch this with my first review, the function will need an EXPORT_SYMBOL_GPL() to allow building modules. This will mean an interface extension what should be non-arch. So, for architectures we need the pmu name like SH we just implement the generic function. For ARM we don't need to provide this function.
Most of the interface is defined in linux/perf_event.h. We shouldn't move this to asm/perf_event.h, so this is one more argument for the non-arch implementation.
As the implementation of the function would be optional, why should we make it architectural?
-Robert
Signature · 2 lines
Advanced Micro Devices, Inc. Operating System Research Center
Re: [PATCH 6/6] sh: oprofile: Use perf-events oprofile backend
Quoted 24 lines · Robert Richter
Quoted 19 lines · Matt Fleming
Quoted 8 lines · Robert Richter
Quoted 8 lines
arch/sh/kernel/perf_event.c +0
-0@@ -59,6 +59,14 @@ static inline int sh_pmu_initialized(void)return !!sh_pmu; }Quoted 9 lines
arch/sh/kernel/perf_event.c static inline int sh_pmu_initialized(void) · line 68
Quoted 7 lines
arch/sh/kernel/perf_event.c +7
-0+const char *sh_pmu_name (void ) +{ +if (!sh_pmu) +return NULL ; + +return sh_pmu->name; +}Couldn't we make this a generic function like
perf_num_counters()?Quoted 3 lines
Well, ARM doesn't have names as strings for its pmus currently. What's more, ARM wouldn't use it; SH would be the only user of this function. I don't think this one makes sense to be a generic function.
Quoted 5 lines
I didn't catch this with my first review, the function will need an
EXPORT_SYMBOL_GPL()to allow building modules. This will mean an interface extension what should be non-arch. So, for architectures we need the pmu name like SH we just implement the generic function. For ARM we don't need to provide this function.
Yeah my bad, I just hit this EXPORT_SYMBOL_GPL issue when compiling oprofile as a module.
Quoted 3 lines
Most of the interface is defined in
linux/perf_event.h. We shouldn't move this toasm/perf_event.h, so this is one more argument for the non-arch implementation.
I'm not advocating moving this function to asm/perf_event.h.
Quoted 2 lines
As the implementation of the function would be optional, why should we make it architectural?
I don't see why we should pollute the perf namespace with a function that is only being used inside the SH oprofile code? There would be exactly one use of this function and I doubt the perf guys will want this function exposed. In it's current state, it really is no use to any architecture other than SH.
We can always add a generic perf_pmu_name() function later if needed, but it's definitely not needed at the moment.
Re: [PATCH 6/6] sh: oprofile: Use perf-events oprofile backend
Quoted 43 lines · Matt Fleming
Quoted 24 lines · Robert Richter
Quoted 19 lines · Matt Fleming
Quoted 8 lines · Robert Richter
Quoted 8 lines
arch/sh/kernel/perf_event.c +0
-0@@ -59,6 +59,14 @@ static inline int sh_pmu_initialized(void)return !!sh_pmu; }Quoted 9 lines
arch/sh/kernel/perf_event.c static inline int sh_pmu_initialized(void) · line 68
Quoted 7 lines
arch/sh/kernel/perf_event.c +7
-0+const char *sh_pmu_name (void ) +{ +if (!sh_pmu) +return NULL ; + +return sh_pmu->name; +}Couldn't we make this a generic function like
perf_num_counters()?Quoted 3 lines
Well, ARM doesn't have names as strings for its pmus currently. What's more, ARM wouldn't use it; SH would be the only user of this function. I don't think this one makes sense to be a generic function.
Quoted 5 lines
I didn't catch this with my first review, the function will need an
EXPORT_SYMBOL_GPL()to allow building modules. This will mean an interface extension what should be non-arch. So, for architectures we need the pmu name like SH we just implement the generic function. For ARM we don't need to provide this function.Yeah my bad, I just hit this
EXPORT_SYMBOL_GPLissue when compiling oprofile as a module.Quoted 3 lines
Most of the interface is defined in
linux/perf_event.h. We shouldn't move this toasm/perf_event.h, so this is one more argument for the non-arch implementation.I'm not advocating moving this function to
asm/perf_event.h.Quoted 2 lines
As the implementation of the function would be optional, why should we make it architectural?
Quoted 8 lines
I don't see why we should pollute the perf namespace with a function that is only being used inside the SH oprofile code? There would be exactly one use of this function and I doubt the perf guys will want this function exposed. In it's current state, it really is no use to any architecture other than SH.
We can always add a generic
perf_pmu_name()function later if needed, but it's definitely not needed at the moment.
Ok, so then let's implement sh_pmu_name() in arch/sh/oprofile/common.c, we import asm/perf_event.h to get access to struct sh_pmu. This could be implemented as a static function then and we also get rid of this interface thing.
-Robert
Signature · 2 lines
Advanced Micro Devices, Inc. Operating System Research Center
Re: [PATCH 6/6] sh: oprofile: Use perf-events oprofile backend
Quoted 8 lines · Robert Richter
Quoted 7 lines · Matt Fleming
I don't see why we should pollute the perf namespace with a function that is only being used inside the SH oprofile code? There would be exactly one use of this function and I doubt the perf guys will want this function exposed. In it's current state, it really is no use to any architecture other than SH.
Quoted 7 lines
Quoted 2 lines
We can always add a generic
perf_pmu_name()function later if needed, but it's definitely not needed at the moment.Ok, so then let's implement
sh_pmu_name()inarch/sh/oprofile/common.c, we importasm/perf_event.hto get access to structsh_pmu. This could be implemented as a static function then and we also get rid of this interface thing.
That seems OK to me s'long as Paul (the author of the perf events code for SH) doesn't have a problem with us exposing the struct sh_pmu * outside of arch/sh/kernel/perf_event.c
Re: [PATCH 6/6] sh: oprofile: Use perf-events oprofile backend
In reply to Matt FlemingQuoted 6 lines · Matt Fleming
Quoted 5 lines · Robert Richter
Quoted 3 lines · Matt Fleming
Well, ARM doesn't have names as strings for its pmus currently. What's more, ARM wouldn't use it; SH would be the only user of this function. I don't think this one makes sense to be a generic function.
Er, what? Yes it does. It has this silly id to string mapping thing that is at present duplicated between the perf and the oprofile code for no reason. Having a generic (albeit optional) perf_pmu_name() would allow this to be cleaned up.
Quoted 9 lines
Quoted 2 lines
As the implementation of the function would be optional, why should we make it architectural?
I don't see why we should pollute the perf namespace with a function that is only being used inside the SH oprofile code? There would be exactly one use of this function and I doubt the perf guys will want this function exposed. In it's current state, it really is no use to any architecture other than SH.
This has nothing at all to do with the SH oprofile code and everything to do with oprofile in general. This is the vary basis for the CPU model matching in the oprofile userspace tools, it's string based by design. Given that we're already seeing architetures double up their strings in both places, this really wants a consensus and to be dealt with before other architetures start getting the wrong idea.
Re: [PATCH 6/6] sh: oprofile: Use perf-events oprofile backend
Paul,
Quoted 8 lines · Paul Mundt
Quoted 6 lines · Matt Fleming
Quoted 5 lines · Robert Richter
Quoted 3 lines · Matt Fleming
Well, ARM doesn't have names as strings for its pmus currently. What's more, ARM wouldn't use it; SH would be the only user of this function. I don't think this one makes sense to be a generic function.
Quoted 5 lines
Er, what? Yes it does. It has this silly id to string mapping thing that is at present duplicated between the perf and the oprofile code for no reason. Having a generic (albeit optional)
perf_pmu_name()would allow this to be cleaned up.
It's not as silly as it appears. As you mention below, OProfile uses strings to identify the correct CPU model in userspace. With ARM, there is some horrible legacy here which means that the strings are extremely misleading (arm/mpcore => arm/11mpcore, arm/armv7 => Cortex A8). Rather than continue this mess into perf, I decided to separate the two and use a common numeric scheme for when they have to talk to each other.
Quoted 9 lines
Quoted 9 lines
Quoted 2 lines
As the implementation of the function would be optional, why should we make it architectural?
I don't see why we should pollute the perf namespace with a function that is only being used inside the SH oprofile code? There would be exactly one use of this function and I doubt the perf guys will want this function exposed. In it's current state, it really is no use to any architecture other than SH.
Quoted 6 lines
This has nothing at all to do with the SH oprofile code and everything to do with oprofile in general. This is the vary basis for the CPU model matching in the oprofile userspace tools, it's string based by design. Given that we're already seeing architetures double up their strings in both places, this really wants a consensus and to be dealt with before other architetures start getting the wrong idea.
I agree that if you have sane strings for OProfile then there's no reason to define new ones for perf.
Will
Hi,
I'm just being curious : do these patches change the way those chips should be supported, that do not have a PMU-like IP, but implement PC-sampling thanks to a general purpose timer (not the system timer) ?
Thanks and Regards,
Marc.
Quoted 65 lines
From: [email protected]
To: [email protected]
Subject: [PATCH V3 0/6] Generalise ARM perf-events backend for oprofile
Date: Mon, 13 Sep 2010 07:07:31 +0100
CC: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]The perf-events backend for OProfile that Will Deacon wrote in
8c1fc96f6fd1f361428ba805103af0d0eee65179("ARM: 6072/1: oprofile: use perf-events framework as backend") is of use to more architectures than just ARM. Move the code intodrivers/oprofile/so that SH can use it instead of the nearly identical copy of its OProfile code.The benefit of the backend is that it becomes necessary to only maintain one copy of the PMU accessor functions for each architecture, with bug fixes and new features benefiting both OProfile and perf.
Note that I haven't been able to test these patches on an ARM board to see if I've caused any regressions. If anyone else could do that I'd appreciate it. Though, I have been able to compile this version of the series.
This patch series is based on,
git://git.kernel.org/pub/scm/linux/kernel/git/rric/oprofile.gitcoreThese patches can also be found at,
git://git.kernel.org/pub/scm/linux/kernel/git/mfleming/sh-2.6.gitperf-oprofileChanges from v2:
- Rebased against Robert's oprofile core branch
- Moved even more of the ARM code into the generic oprofile code
- Broke the patches up into more logical stepsChanges from v1:
- Prefix the new functons with "oprofile_" instead of "op_".
- Fix ARM compilation errors
- Move all the oprofile-perf logic intooprofile_perf.c
- Include cleanup patch from WillMatt Fleming (6):
perf: Add helper function to return number of counters
ARM: oprofile: Renameop_armtooprofile_perf
ARM: oprofile: Move non-ARM code into separate init/exit functions
oprofile: Abstract the perf-events backend
ARM: Make oprofile depend onCONFIG_HW_PERF_EVENTS
sh: oprofile: Use perf-events oprofile backendarch/arm/Kconfig | 2 +- arch/arm/kernel/perf_event.c | 6 + arch/arm/oprofile/Makefile | 2 +- arch/arm/oprofile/common.c | 315 +------------------------------------ arch/sh/Kconfig | 2 +- arch/sh/kernel/perf_event.c | 17 ++ arch/sh/oprofile/Makefile | 2 +- arch/sh/oprofile/common.c | 104 ++----------- arch/sh/oprofile/op_impl.h | 33 ---- drivers/oprofile/oprofile_perf.c | 322 ++++++++++++++++++++++++++++++++++++++ include/linux/oprofile.h | 6 + include/linux/perf_event.h | 1 + 12 files changed, 368 insertions(+), 444 deletions(-) delete mode 100644 arch/sh/oprofile/op_impl.h create mode 100644 drivers/oprofile/oprofile_perf.c
Quoted 4 lines
_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Quoted 7 lines · Marc Titinger
Hi,
I'm just being curious : do these patches change the way those chips should be supported, that do not have a PMU-like IP, but implement PC-sampling thanks to a general purpose timer (not the system timer) ?
CPUs that do not have a PMU are not required to use the perf-events oprofile backend, it is entirely optional. The pc-sampling timer in oprofile is not affected by this series.
Quoted 4 lines · Matt Fleming
Quoted 3 lines · Marc Titinger
Hi,
Quoted 8 lines
Quoted 4 lines
I'm just being curious : do these patches change the way those chips should be supported, that do not have a PMU-like IP, but implement PC-sampling thanks to a general purpose timer (not the system timer) ?
CPUs that do not have a PMU are not required to use the perf-events oprofile backend, it is entirely optional. The pc-sampling timer in oprofile is not affected by this series.
It should still work fine though: a generalized oprofile backend should simply use hrtimer based events. That also has a chance to be higher quality than the system time fallback, on PMU-less (but high-res-timer capable) systems.
Thanks,
Ingo
Quoted 12 lines · Ingo Molnar
Quoted 9 lines · Matt Fleming
Quoted 7 lines · Marc Titinger
Hi,
I'm just being curious : do these patches change the way those chips should be supported, that do not have a PMU-like IP, but implement PC-sampling thanks to a general purpose timer (not the system timer) ?
Quoted 8 lines
Quoted 3 lines
CPUs that do not have a PMU are not required to use the perf-events oprofile backend, it is entirely optional. The pc-sampling timer in oprofile is not affected by this series.
It should still work fine though: a generalized oprofile backend should simply use hrtimer based events. That also has a chance to be higher quality than the system time fallback, on PMU-less (but high-res-timer capable) systems.
Yeah, that's a good point. It would make a nice addition to this patch series. I may get chance to take a look at it at some point.
Hi Matt,
Quoted 6 lines · Matt Fleming
The perf-events backend for OProfile that Will Deacon wrote in
8c1fc96f6fd1f361428ba805103af0d0eee65179("ARM: 6072/1: oprofile: use perf-events framework as backend") is of use to more architectures than just ARM. Move the code intodrivers/oprofile/so that SH can use it instead of the nearly identical copy of its OProfile code.
[...]
Quoted 6 lines
Note that I haven't been able to test these patches on an ARM board to see if I've caused any regressions. If anyone else could do that I'd appreciate it. Though, I have been able to compile this version of the series.
I've tested this patch series on a multicore Cortex-A9 board. If I revert patch 5/6 (ARM: Make oprofile depend on CONFIG_HW_PERF_EVENTS) then everything seems to work fine. Otherwise, testing without HW_PERF_EVENTS doesn't fall back to timer mode.
So, with the exception of the patch above:
Cheers!
Will
Quoted 16 lines · Will Deacon
Hi Matt,
Quoted 6 lines · Matt Fleming
The perf-events backend for OProfile that Will Deacon wrote in
8c1fc96f6fd1f361428ba805103af0d0eee65179("ARM: 6072/1: oprofile: use perf-events framework as backend") is of use to more architectures than just ARM. Move the code intodrivers/oprofile/so that SH can use it instead of the nearly identical copy of its OProfile code.[...]
Quoted 6 lines
Note that I haven't been able to test these patches on an ARM board to see if I've caused any regressions. If anyone else could do that I'd appreciate it. Though, I have been able to compile this version of the series.
Quoted 8 lines
I've tested this patch series on a multicore Cortex-A9 board. If I revert patch 5/6 (ARM: Make oprofile depend on
CONFIG_HW_PERF_EVENTS) then everything seems to work fine. Otherwise, testing withoutHW_PERF_EVENTSdoesn't fall back to timer mode.So, with the exception of the patch above:
Tested-by Will Deacon <[email protected]>
Hi Will, thanks for testing!
Ah yeah, making oprofile rely on CONFIG_HW_PERF_EVENTS is too strict. I hadn't noticed that armpmu_get_pmu_id() is wrapped in CONFIG_HW_PERF_EVENTS and had intended op->cpu_type to be NULL and so we'd fallback to the timer mode.
This patch needs to be dropped entirely (though another patch should conditionally include oprofile_perf.o based on CONFIG_HW_PERF_EVENT like I had in my original series).
Quoted 13 lines · Matt Fleming
Quoted 8 lines · Will Deacon
I've tested this patch series on a multicore Cortex-A9 board. If I revert patch 5/6 (ARM: Make oprofile depend on
CONFIG_HW_PERF_EVENTS) then everything seems to work fine. Otherwise, testing withoutHW_PERF_EVENTSdoesn't fall back to timer mode.So, with the exception of the patch above:
Tested-by Will Deacon <[email protected]>Hi Will, thanks for testing!
Quoted 8 lines
Ah yeah, making oprofile rely on
CONFIG_HW_PERF_EVENTSis too strict. I hadn't noticed thatarmpmu_get_pmu_id()is wrapped inCONFIG_HW_PERF_EVENTSand had intendedop->cpu_typeto be NULL and so we'd fallback to the timer mode.This patch needs to be dropped entirely (though another patch should conditionally include oprofile_perf.o based on
CONFIG_HW_PERF_EVENTlike I had in my original series).
Matt,
yes, the patch set looks good so far. With the exception of some minor comments I made and patch #5 dropped, we should be fine. Please update the patches.
Thanks,
-Robert
Signature · 2 lines
Advanced Micro Devices, Inc. Operating System Research Center