multiplexing event measurement
Dear users/developers
Forgive me for asking a basic question. Is there a way to efficiently multiplex hardware events in oprofile? I have AMD opterons and I want to profile certain MPI applications for various hardware events. Now my system only supports 4 events, and to get more counters in one run, I have to do tedious work of stop, kill, set events, start the oprofiled with opcontrol. This is time consuming job and we end up loosing useful information. As we need to do some anlysis on Xen guests, therefore we cannot make use of PAPI etc, which support multiplexed event measurement.
Best Regards,
Muhammad Atif
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel
Muhammad,
I do have a patch allowing the Oprofile kernel module to multiplex between different events. The patch is still under development and testing, and it might not be 100% stable at this time.
I was not planning to send it out until fully tested, but if you find it useful and have any fix, question, or comment please let me know.
You also need to make a few oprofile changes:
1. Modify the nr_counters for the CPU you are running in op_cpu_type.c
2. Modify the allowed counter in the events file in events/x86-64/<cpu type>/events.
Jason
Quoted 7 lines · Muhammad Atif
Dear users/developers
Forgive me for asking a basic question. Is there a way to efficiently multiplex hardware events in oprofile? I have AMD opterons and I want to profile certain MPI applications for various hardware events. Now my system only supports 4 events, and to get more counters in one run, I have to do tedious work of stop, kill, set events, start the oprofiled with opcontrol. This is time consuming job and we end up loosing useful information. As we need to do some anlysis on Xen guests, therefore we cannot make use of PAPI etc, which support multiplexed event measurement.Best Regards,
Muhammad Atif
arch/x86/oprofile/nmi_int.c +22 -0
@@ -80,6 +80,26 @@ static void exit_sysfs(void)#define exit_sysfs () do { } while (0)#endif /* CONFIG_PM */ +static void nmi_cpu_switch (void *dummy) +{ +struct op_msrs *msrs = &__get_cpu_var (cpu_msrs); + model->switch_ctrs (msrs); +} + +static int nmi_switch_event (void ) +{ +/* Check CPU 0 should be sufficient */ +struct op_msrs const *msrs = &per_cpu (cpu_msrs,0 ); + +if (model->check_multiplexing (msrs) <0 ) +return -EINVAL ; + +spin_lock (&oprofilefs_lock); +on_each_cpu (nmi_cpu_switch,NULL ,0 ,1 ); +spin_unlock (&oprofilefs_lock); +return 0 ; +} +static int profile_exceptions_notify (struct notifier_block *self,unsigned long val,void *data) {
@@ -326,6 +346,7 @@ static int nmi_create_files(struct super_block *sb, struct dentry *root)oprofilefs_create_ulong (sb, dir,"unit_mask" , &counter_config[i].unit_mask);oprofilefs_create_ulong (sb, dir,"kernel" , &counter_config[i].kernel);oprofilefs_create_ulong (sb, dir,"user" , &counter_config[i].user); + counter_config[i].save_count_low =0 ; }return 0 ;
@@ -455,6 +476,7 @@ int __init op_nmi_init(struct oprofile_operations *ops) ops->start = nmi_start; ops->stop = nmi_stop; ops->cpu_type = cpu_type; + ops->switch_events = nmi_switch_event;printk (KERN_INFO "oprofile: using NMI interrupt.\n" );return 0 ; }
arch/x86/oprofile/op_counter.h +2 -1
@@ -10,13 +10,14 @@ #ifndef OP_COUNTER_H #define OP_COUNTER_H -#define OP_MAX_COUNTER 8 +#define OP_MAX_COUNTER 32 /* Per-perfctr configuration as set via * oprofilefs. */ struct op_counter_config { unsigned long count; + unsigned long save_count_low; unsigned long enabled; unsigned long event; unsigned long kernel;
arch/x86/oprofile/op_model_athlon.c +123 -21
253 lines not on this page · raw message
arch/x86/oprofile/op_x86_model.h +2 -0
@@ -41,6 +41,8 @@ struct op_x86_model_spec {void (*start)(struct op_msrs const *const msrs);void (*stop)(struct op_msrs const *const msrs);void (*shutdown)(struct op_msrs const *const msrs); +void (*switch_ctrs)(struct op_msrs const *const msrs); +int (*check_multiplexing)(struct op_msrs const *const msrs); };extern struct op_x86_model_spec const op_ppro_spec;
drivers/oprofile/oprof.c +53 -2
114 lines not on this page · raw message
drivers/oprofile/oprof.h +3 -1
@@ -27,7 +27,8 @@ extern unsigned long fs_buffer_watershed;extern struct oprofile_operations oprofile_ops;extern unsigned long oprofile_started;extern unsigned long backtrace_depth; - +extern unsigned long time_slice; +struct super_block ;struct dentry ;
@@ -35,5 +36,6 @@ void oprofile_create_files(struct super_block * sb, struct dentry * root);void oprofile_timer_init (struct oprofile_operations * ops);int oprofile_set_backtrace (unsigned long depth); +int oprofile_set_time_slice (unsigned long time);#endif /* OPROF_H */
drivers/oprofile/oprofile_files.c +33 -2
@@ -18,6 +18,37 @@ unsigned long fs_buffer_size = 131072;unsigned long fs_cpu_buffer_size =8192 ;unsigned long fs_buffer_watershed =32768 ;/* FIXME: tune */ +static ssize_t time_slice_read (struct file * file,char __user * buf,size_t count,loff_t * offset) +{ +return oprofilefs_ulong_to_user (time_slice, buf, count, offset); +} + + +static ssize_t time_slice_write (struct file * file,char const __user * buf,size_t count,loff_t * offset) +{ +unsigned long val; +int retval; + +if (*offset) +return -EINVAL ; + + retval =oprofilefs_ulong_from_user (&val, buf, count); +if (retval) +return retval; + + retval =oprofile_set_time_slice (val); + +if (retval) +return retval; +return count; +} + +static const struct file_operations time_slice_fops = { + .read = time_slice_read, + .write = time_slice_write +}; + +static ssize_t depth_read (struct file * file,char __user * buf,size_t count,loff_t * offset) {return oprofilefs_ulong_to_user (backtrace_depth, buf, count, offset);
@@ -85,11 +116,10 @@ static ssize_t enable_write(struct file * file, char const __user * buf, size_tif (*offset)return -EINVAL ; - retval =oprofilefs_ulong_from_user (&val, buf, count);if (retval)return retval; - +if (val) retval =oprofile_start ();else
@@ -129,6 +159,7 @@ void oprofile_create_files(struct super_block * sb, struct dentry * root)oprofilefs_create_file (sb, root,"cpu_type" , &cpu_type_fops);oprofilefs_create_file (sb, root,"backtrace_depth" , &depth_fops);oprofilefs_create_file (sb, root,"pointer_size" , &pointer_size_fops); +oprofilefs_create_file (sb, root,"time_slice" , &time_slice_fops);oprofile_create_stats_files (sb, root);if (oprofile_ops.create_files) oprofile_ops.create_files (sb, root);
include/linux/oprofile.h +3 -0
@@ -65,6 +65,9 @@ struct oprofile_operations {/* Initiate a stack backtrace. Optional. */ void (*backtrace)(struct pt_regs *const regs,unsigned int depth); + +/* Multiplex between different events. Optioinal. */ +int (*switch_events)(void );/* CPU identification string. */ char * cpu_type; };
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
oprofile-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/oprofile-list