Hello,
I want read the performance counters for an external module. For this i found 2 function in ./include/linux/perf_event.h :
extern struct perf_event *perf_event_create_kernel_counter(struct perf_event_attr *attr, int cpu, struct task_struct *task, perf_overflow_handler_t callback);
extern u64 perf_event_read_value(struct perf_event *event, u64 *enabled, u64 *running);
The problem : the values recovered with perf_event_read_value are (a priori) erroneous.
I have recovered a program that reads the register in user space and the values are not same that for the module...
Code:
static void perf_counter(unsigned int cpu){
struct perf_event_attr attr = {
.type = PERF_TYPE_SOFTWARE
.config = PERF_COUNT_SW_CPU_CLOCK
};
u64 total=0, enabled=0, running=0;
struct perf_event *evt = perf_event_create_kernel_counter(&attr, cpu, NULL, f_overflow);
total = perf_event_read_value(evt, &enabled, &running);
printk(KERN_INFO "cpufreq(%u): governor Govtest perf : %llu %llu %llu", cpu, total,
enabled, running);
}
For example the displayed values by the module are between 300 and 700. total is always lower that enabled and running. More enabled=running at each test...
Normally I should have a value neighbor 1 000 000 000...
thanks for your help !