From: Wei Huang <wei@redhat.com>
To: kvm@vger.kernel.org
Cc: pbonzini@redhat.com, rkrcmar@redhat.com, wei@redhat.com
Subject: [kvm-unit-tests RFC 1/3] x86/pmu: Move common x86 PMU definitions to pmu.h
Date: Thu, 3 Aug 2017 23:24:28 -0500 [thread overview]
Message-ID: <1501820670-23194-2-git-send-email-wei@redhat.com> (raw)
In-Reply-To: <1501820670-23194-1-git-send-email-wei@redhat.com>
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
+
+#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
next prev parent reply other threads:[~2017-08-04 4:24 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-08-04 4:24 [kvm-unit-tests RFC 0/3] x86/pmu: Add AMD vPMU testing code Wei Huang
2017-08-04 4:24 ` Wei Huang [this message]
2017-08-04 7:59 ` [kvm-unit-tests RFC 1/3] x86/pmu: Move common x86 PMU definitions to pmu.h Andrew Jones
2017-08-04 4:24 ` [kvm-unit-tests RFC 2/3] x86/pmu: Rename pmu.c code to intel_pmu.c Wei Huang
2017-08-04 8:00 ` Andrew Jones
2017-08-04 15:44 ` Wei Huang
2017-08-04 4:24 ` [kvm-unit-tests RFC 3/3] x86/pmu: Create AMD PMU test code Wei Huang
2017-08-04 8:14 ` Andrew Jones
2017-08-04 15:49 ` Wei Huang
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1501820670-23194-2-git-send-email-wei@redhat.com \
--to=wei@redhat.com \
--cc=kvm@vger.kernel.org \
--cc=pbonzini@redhat.com \
--cc=rkrcmar@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox