Message ID | 1501820670-23194-2-git-send-email-wei@redhat.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
On Thu, Aug 03, 2017 at 11:24:28PM -0500, Wei Huang wrote: > This patch moves common x86 PMU counter and event defintions to pmu.h > file. This header file will be used by both Intel and AMD PMU test > code. > > Signed-off-by: Wei Huang <wei@redhat.com> > --- > x86/pmu.c | 38 ++------------------------------------ > x86/pmu.h | 42 ++++++++++++++++++++++++++++++++++++++++++ > 2 files changed, 44 insertions(+), 36 deletions(-) > create mode 100644 x86/pmu.h > > diff --git a/x86/pmu.c b/x86/pmu.c > index a0238dc..1b818c2 100644 > --- a/x86/pmu.c > +++ b/x86/pmu.c > @@ -8,38 +8,9 @@ > #include "x86/vm.h" > > #include "libcflat.h" > +#include "pmu.h" > #include <stdint.h> > > -#define FIXED_CNT_INDEX 32 > -#define PC_VECTOR 32 > - > -#define EVNSEL_EVENT_SHIFT 0 > -#define EVNTSEL_UMASK_SHIFT 8 > -#define EVNTSEL_USR_SHIFT 16 > -#define EVNTSEL_OS_SHIFT 17 > -#define EVNTSEL_EDGE_SHIFT 18 > -#define EVNTSEL_PC_SHIFT 19 > -#define EVNTSEL_INT_SHIFT 20 > -#define EVNTSEL_EN_SHIF 22 > -#define EVNTSEL_INV_SHIF 23 > -#define EVNTSEL_CMASK_SHIFT 24 > - > -#define EVNTSEL_EN (1 << EVNTSEL_EN_SHIF) > -#define EVNTSEL_USR (1 << EVNTSEL_USR_SHIFT) > -#define EVNTSEL_OS (1 << EVNTSEL_OS_SHIFT) > -#define EVNTSEL_PC (1 << EVNTSEL_PC_SHIFT) > -#define EVNTSEL_INT (1 << EVNTSEL_INT_SHIFT) > -#define EVNTSEL_INV (1 << EVNTSEL_INV_SHIF) > - > -#define N 1000000 > - > -typedef struct { > - uint32_t ctr; > - uint32_t config; > - uint64_t count; > - int idx; > -} pmu_counter_t; > - > union cpuid10_eax { > struct { > unsigned int version_id:8; > @@ -72,12 +43,7 @@ union cpuid10_edx { > unsigned int full; > } edx; > > -struct pmu_event { > - const char *name; > - uint32_t unit_sel; > - int min; > - int max; > -} gp_events[] = { > +struct pmu_event gp_events[] = { > {"core cycles", 0x003c, 1*N, 50*N}, > {"instructions", 0x00c0, 10*N, 10.2*N}, > {"ref cycles", 0x013c, 0.1*N, 30*N}, > diff --git a/x86/pmu.h b/x86/pmu.h > new file mode 100644 > index 0000000..b1e8e51 > --- /dev/null > +++ b/x86/pmu.h > @@ -0,0 +1,42 @@ > +/* vPMU unit testing for x86 */ > +#ifndef __PMU_H > +#define __PMU_H New files should get GPL headers. > + > +#define N 1000000 > + > +#define FIXED_CNT_INDEX 32 > +#define PC_VECTOR 32 > + > +#define EVNTSEL_EVENT_SHIFT 0 > +#define EVNTSEL_UMASK_SHIFT 8 > +#define EVNTSEL_USR_SHIFT 16 > +#define EVNTSEL_OS_SHIFT 17 > +#define EVNTSEL_EDGE_SHIFT 18 > +#define EVNTSEL_PC_SHIFT 19 > +#define EVNTSEL_INT_SHIFT 20 > +#define EVNTSEL_EN_SHIF 22 > +#define EVNTSEL_INV_SHIF 23 > +#define EVNTSEL_CMASK_SHIFT 24 > + > +#define EVNTSEL_EN (1 << EVNTSEL_EN_SHIF) > +#define EVNTSEL_USR (1 << EVNTSEL_USR_SHIFT) > +#define EVNTSEL_OS (1 << EVNTSEL_OS_SHIFT) > +#define EVNTSEL_PC (1 << EVNTSEL_PC_SHIFT) > +#define EVNTSEL_INT (1 << EVNTSEL_INT_SHIFT) > +#define EVNTSEL_INV (1 << EVNTSEL_INV_SHIF) > + > +typedef struct { > + uint32_t ctr; > + uint32_t config; > + uint64_t count; > + int idx; > +} pmu_counter_t; > + > +struct pmu_event { > + const char *name; > + uint32_t unit_sel; > + int min; > + int max; > +}; > + > +#endif /* __PMU_H */ > -- > 2.7.5 > Otherwise Reviewed-by: Andrew Jones <drjones@redhat.com>
diff --git a/x86/pmu.c b/x86/pmu.c index a0238dc..1b818c2 100644 --- a/x86/pmu.c +++ b/x86/pmu.c @@ -8,38 +8,9 @@ #include "x86/vm.h" #include "libcflat.h" +#include "pmu.h" #include <stdint.h> -#define FIXED_CNT_INDEX 32 -#define PC_VECTOR 32 - -#define EVNSEL_EVENT_SHIFT 0 -#define EVNTSEL_UMASK_SHIFT 8 -#define EVNTSEL_USR_SHIFT 16 -#define EVNTSEL_OS_SHIFT 17 -#define EVNTSEL_EDGE_SHIFT 18 -#define EVNTSEL_PC_SHIFT 19 -#define EVNTSEL_INT_SHIFT 20 -#define EVNTSEL_EN_SHIF 22 -#define EVNTSEL_INV_SHIF 23 -#define EVNTSEL_CMASK_SHIFT 24 - -#define EVNTSEL_EN (1 << EVNTSEL_EN_SHIF) -#define EVNTSEL_USR (1 << EVNTSEL_USR_SHIFT) -#define EVNTSEL_OS (1 << EVNTSEL_OS_SHIFT) -#define EVNTSEL_PC (1 << EVNTSEL_PC_SHIFT) -#define EVNTSEL_INT (1 << EVNTSEL_INT_SHIFT) -#define EVNTSEL_INV (1 << EVNTSEL_INV_SHIF) - -#define N 1000000 - -typedef struct { - uint32_t ctr; - uint32_t config; - uint64_t count; - int idx; -} pmu_counter_t; - union cpuid10_eax { struct { unsigned int version_id:8; @@ -72,12 +43,7 @@ union cpuid10_edx { unsigned int full; } edx; -struct pmu_event { - const char *name; - uint32_t unit_sel; - int min; - int max; -} gp_events[] = { +struct pmu_event gp_events[] = { {"core cycles", 0x003c, 1*N, 50*N}, {"instructions", 0x00c0, 10*N, 10.2*N}, {"ref cycles", 0x013c, 0.1*N, 30*N}, diff --git a/x86/pmu.h b/x86/pmu.h new file mode 100644 index 0000000..b1e8e51 --- /dev/null +++ b/x86/pmu.h @@ -0,0 +1,42 @@ +/* vPMU unit testing for x86 */ +#ifndef __PMU_H +#define __PMU_H + +#define N 1000000 + +#define FIXED_CNT_INDEX 32 +#define PC_VECTOR 32 + +#define EVNTSEL_EVENT_SHIFT 0 +#define EVNTSEL_UMASK_SHIFT 8 +#define EVNTSEL_USR_SHIFT 16 +#define EVNTSEL_OS_SHIFT 17 +#define EVNTSEL_EDGE_SHIFT 18 +#define EVNTSEL_PC_SHIFT 19 +#define EVNTSEL_INT_SHIFT 20 +#define EVNTSEL_EN_SHIF 22 +#define EVNTSEL_INV_SHIF 23 +#define EVNTSEL_CMASK_SHIFT 24 + +#define EVNTSEL_EN (1 << EVNTSEL_EN_SHIF) +#define EVNTSEL_USR (1 << EVNTSEL_USR_SHIFT) +#define EVNTSEL_OS (1 << EVNTSEL_OS_SHIFT) +#define EVNTSEL_PC (1 << EVNTSEL_PC_SHIFT) +#define EVNTSEL_INT (1 << EVNTSEL_INT_SHIFT) +#define EVNTSEL_INV (1 << EVNTSEL_INV_SHIF) + +typedef struct { + uint32_t ctr; + uint32_t config; + uint64_t count; + int idx; +} pmu_counter_t; + +struct pmu_event { + const char *name; + uint32_t unit_sel; + int min; + int max; +}; + +#endif /* __PMU_H */
This patch moves common x86 PMU counter and event defintions to pmu.h file. This header file will be used by both Intel and AMD PMU test code. Signed-off-by: Wei Huang <wei@redhat.com> --- x86/pmu.c | 38 ++------------------------------------ x86/pmu.h | 42 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 44 insertions(+), 36 deletions(-) create mode 100644 x86/pmu.h