support PERF_TYPE_{HARDWARE|HW_CACHE} in perf_event_open

refs #829
This commit is contained in:
Ken Sato
2017-10-12 16:51:47 +09:00
parent 2ae6883a8b
commit 12840601e1
15 changed files with 685 additions and 51 deletions

View File

@@ -2,9 +2,9 @@
#ifndef MC_PERF_EVENT_H
#define MC_PERF_EVENT_H
#ifdef POSTK_DEBUG_TEMP_FIX_32
//#ifdef POSTK_DEBUG_TEMP_FIX_32
#include <list.h>
#endif /*POSTK_DEBUG_TEMP_FIX_32*/
//#endif /*POSTK_DEBUG_TEMP_FIX_32*/
#include <march.h>
struct perf_event_attr;
@@ -105,6 +105,40 @@ enum perf_hw_id {
PERF_COUNT_HW_MAX, /* non-ABI */
};
/*
* Generalized hardware cache events:
*
* { L1-D, L1-I, LLC, ITLB, DTLB, BPU, NODE } x
* { read, write, prefetch } x
* { accesses, misses }
*/
enum perf_hw_cache_id {
PERF_COUNT_HW_CACHE_L1D = 0,
PERF_COUNT_HW_CACHE_L1I = 1,
PERF_COUNT_HW_CACHE_LL = 2,
PERF_COUNT_HW_CACHE_DTLB = 3,
PERF_COUNT_HW_CACHE_ITLB = 4,
PERF_COUNT_HW_CACHE_BPU = 5,
PERF_COUNT_HW_CACHE_NODE = 6,
PERF_COUNT_HW_CACHE_MAX, /* non-ABI */
};
enum perf_hw_cache_op_id {
PERF_COUNT_HW_CACHE_OP_READ = 0,
PERF_COUNT_HW_CACHE_OP_WRITE = 1,
PERF_COUNT_HW_CACHE_OP_PREFETCH = 2,
PERF_COUNT_HW_CACHE_OP_MAX, /* non-ABI */
};
enum perf_hw_cache_op_result_id {
PERF_COUNT_HW_CACHE_RESULT_ACCESS = 0,
PERF_COUNT_HW_CACHE_RESULT_MISS = 1,
PERF_COUNT_HW_CACHE_RESULT_MAX, /* non-ABI */
};
/*
* Hardware event_id to monitor via a performance monitoring event:
*/
@@ -218,8 +252,18 @@ struct perf_event_attr {
#endif
};
struct hw_perf_event_extra {
unsigned long config;
unsigned int reg;
int idx;
};
struct mc_perf_event {
struct perf_event_attr attr;
struct hw_perf_event_extra extra_reg;
unsigned long hw_config;
unsigned long hw_config_ext;
int cpu_id;
int counter_id; // counter_id
unsigned long count; // counter_value