libpfm/SOURCES/libpfm-flags.patch

185 lines
6.5 KiB
Diff

commit 20bd642e0ebc2c1d29e39417ee4665271df43d93
Author: Stephane Eranian <eranian@gmail.com>
Date: Thu Nov 7 10:47:02 2019 -0800
add support for speculation event information
This patch extends the information returned by get_event_info()
with speculation information. Some events can include occurrences
happening during speculative execution. This is important information
because it impacts the cost associated with such event. The
pfm_event_info_t struct is extended with a 2-bit field describing
whether or not the event counts during speculation.
Given that the speculation information is not always available from
hardware vendors, the field can have 3 values:
- PFM_EVENT_SPEC_INFO_NA: no information available (default)
- PFM_EVENT_INFO_SPEC_TRUE: event includes speculative execution
- PFM_EVENT_INFO_SPEC_FALSE: evnet does not include speculative execution
Signed-off-by: Stephane Eranian <eranian@gmail.com>
diff --git a/docs/man3/pfm_get_event_info.3 b/docs/man3/pfm_get_event_info.3
index 7eaa6cf..a8c7546 100644
--- a/docs/man3/pfm_get_event_info.3
+++ b/docs/man3/pfm_get_event_info.3
@@ -85,6 +85,16 @@ field means that at least one umask supports precise sampling. On Intel X86
processors, this indicates whether the event supports Precise Event-Based
Sampling (PEBS).
.PP
+.TP
+.B is_speculative
+This bitfield indicates whether or not the event includes occurrences happening
+during speculative execution for both wrong and correct path. Given that this
+kind of event information is not always available from vendors, this field uses
+multiple bits. A value of \fBPFM_EVENT_INFO_SPEC_NA\fR indicates that speculation
+information is not available. A value of \fBPFM_EVENT_INFO_SPEC_TRUE\fR indicates
+that the event count during speculative execution. A value of \fBPFM_EVENT_INFO_SPEC_FALS\fR
+indicates that the event does not count during speculative execution.
+.PP
The \fBpfm_os_t\fR enumeration provides the following choices:
.TP
diff --git a/examples/showevtinfo.c b/examples/showevtinfo.c
index 40966ac..44e958e 100644
--- a/examples/showevtinfo.c
+++ b/examples/showevtinfo.c
@@ -376,11 +376,16 @@ static void
print_event_flags(pfm_event_info_t *info)
{
int n = 0;
+ int spec = info->is_speculative;
if (info->is_precise) {
printf("[precise] ");
n++;
}
+ if (spec > PFM_EVENT_INFO_SPEC_NA) {
+ printf("[%s] ", spec == PFM_EVENT_INFO_SPEC_TRUE ? "speculative" : "non-speculative");
+ n++;
+ }
if (!n)
printf("None");
}
diff --git a/include/perfmon/pfmlib.h b/include/perfmon/pfmlib.h
index bd6f935..09c673d 100644
--- a/include/perfmon/pfmlib.h
+++ b/include/perfmon/pfmlib.h
@@ -645,6 +645,12 @@ typedef struct {
} SWIG_NAME(flags);
} pfm_pmu_info_t;
+typedef enum {
+ PFM_EVENT_INFO_SPEC_NA = 0,
+ PFM_EVENT_INFO_SPEC_TRUE = 1,
+ PFM_EVENT_INFO_SPEC_FALSE = 2,
+} pfm_event_info_spec_t;
+
typedef struct {
const char *name; /* event name */
const char *desc; /* event description */
@@ -657,8 +663,9 @@ typedef struct {
int nattrs; /* number of attributes */
int reserved; /* for future use */
struct {
- unsigned int is_precise:1; /* precise sampling (Intel X86=PEBS) */
- unsigned int reserved_bits:31;
+ unsigned int is_precise:1; /* precise sampling (Intel X86=PEBS) */
+ unsigned int is_speculative:2;/* count correct and wrong path occurrences */
+ unsigned int reserved_bits:29;
} SWIG_NAME(flags);
} pfm_event_info_t;
diff --git a/lib/pfmlib_common.c b/lib/pfmlib_common.c
index 688edb6..2b6cbb4 100644
--- a/lib/pfmlib_common.c
+++ b/lib/pfmlib_common.c
@@ -1951,7 +1951,8 @@ pfm_get_event_info(int idx, pfm_os_t os, pfm_event_info_t *uinfo)
info.dtype = PFM_DTYPE_UINT64;
/* reset flags */
- info.is_precise = 0;
+ info.is_precise = 0;
+ info.is_speculative = PFM_EVENT_INFO_SPEC_NA;
ret = pmu->get_event_info(pmu, pidx, &info);
if (ret != PFM_SUCCESS)
diff --git a/lib/pfmlib_priv.h b/lib/pfmlib_priv.h
index fe13351..b0070a6 100644
--- a/lib/pfmlib_priv.h
+++ b/lib/pfmlib_priv.h
@@ -186,6 +186,7 @@ typedef struct {
#define PFMLIB_PMU_FL_RAW_UMASK 0x4 /* PMU supports PFM_ATTR_RAW_UMASKS */
#define PFMLIB_PMU_FL_ARCH_DFL 0x8 /* PMU is arch default */
#define PFMLIB_PMU_FL_NO_SMPL 0x10 /* PMU does not support sampling */
+#define PFMLIB_PMU_FL_SPEC 0x20 /* PMU provides event speculation info */
typedef struct {
int initdone;
commit fb31170eab2d62d6cb182f14df3a6d8e065303d2
Author: Stephane Eranian <eranian@google.com>
Date: Thu Dec 19 16:13:16 2019 -0800
add PFMLIB_PMU_FL_DEPR flag
To mark a PMU model as deprecated. This is useful when a PMU model
is superseded by another one, yet the obsolete model must remain
for backward compatibility reason.
The ensures that a fully qualified event string with the old pmu
name will still be accepted. But when running on the matching
CPU model, the new PMU model will be selected by default when
the pmu model name is not specified.
Example: when running on pmu_old PMU model:
- pmu_old::cycles is still accepted
- pmu_new::cycles is accepted
- cycles is mapped to pmu_new::cycles
Signed-off-by: Stephane Eranian <eranian@gmail.com>
diff --git a/lib/pfmlib_common.c b/lib/pfmlib_common.c
index 8cb8998..31d16e9 100644
--- a/lib/pfmlib_common.c
+++ b/lib/pfmlib_common.c
@@ -712,6 +712,12 @@ pfmlib_pmu_active(pfmlib_pmu_t *pmu)
return !!(pmu->flags & PFMLIB_PMU_FL_ACTIVE);
}
+static inline int
+pfmlib_pmu_deprecated(pfmlib_pmu_t *pmu)
+{
+ return !!(pmu->flags & PFMLIB_PMU_FL_DEPR);
+}
+
static inline int
pfmlib_pmu_initialized(pfmlib_pmu_t *pmu)
{
@@ -1495,6 +1501,14 @@ pfmlib_parse_event(const char *event, pfmlib_event_desc_t *d)
*/
if (!pname && !pfmlib_pmu_active(pmu))
continue;
+
+ /*
+ * if the PMU name is not passed, then if
+ * the pmu is deprecated, then skip it. It means
+ * there is a better candidate in the active list
+ */
+ if (!pname && pfmlib_pmu_deprecated(pmu))
+ continue;
/*
* check for requested PMU name,
*/
diff --git a/lib/pfmlib_priv.h b/lib/pfmlib_priv.h
index 1340a6b..5cddc9c 100644
--- a/lib/pfmlib_priv.h
+++ b/lib/pfmlib_priv.h
@@ -187,6 +187,7 @@ typedef struct {
#define PFMLIB_PMU_FL_ARCH_DFL 0x8 /* PMU is arch default */
#define PFMLIB_PMU_FL_NO_SMPL 0x10 /* PMU does not support sampling */
#define PFMLIB_PMU_FL_SPEC 0x20 /* PMU provides event speculation info */
+#define PFMLIB_PMU_FL_DEPR 0x40 /* PMU model is deprecated */
typedef struct {
int initdone;