Blame SOURCES/libpfm-flags.patch

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