Blame SOURCES/libpfm-flags.patch

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