summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLionel Landwerlin <lionel.g.landwerlin@intel.com>2020-08-24 13:52:59 +0300
committerEric Engestrom <eric@engestrom.ch>2020-09-02 21:50:48 +0200
commit65e52c4a01214f12d9965eab594fad8bdc1c5bb7 (patch)
treed590d6653f76d0cc22476e74607854a03f2da61d
parent62917dade98c82ec7750f1c492f9a4096e6ee6e8 (diff)
intel/perf: fix raw query kernel metric selection
The raw query is meant to be used with MDAPI [1]. When using this metric without this library, we usually selected the TestOa metric to provide some default sensible values (instead of undefined). Historically this TestOa metric lived in the kernel at ID=1. We removed all metrics from the kernel in kernel commit 9aba9c188da136 ("drm/i915/perf: remove generated code"). This fixes the Mesa code to use a valid metric set ID (1 could work some of the time, but not guaranteed). [1] : https://github.com/intel/metrics-discovery v2: Store fallback metric at init time v3: Drop TestOa lookout v4: Skip the existing queries (Marcin) Signed-off-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com> CC: <mesa-stable@lists.freedesktop.org> Tested-by: Marcin Ĺšlusarz <marcin.slusarz@intel.com> (v1) Reviewed-by: Kenneth Graunke <kenneth@whitecape.org> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6438> (cherry-picked from commit ec1fa1d51ff614c19d08c949482b40c060de48c9)
-rw-r--r--.pick_status.json2
-rw-r--r--src/intel/perf/gen_perf.c13
-rw-r--r--src/intel/perf/gen_perf.h5
-rw-r--r--src/intel/perf/gen_perf_query.c2
4 files changed, 20 insertions, 2 deletions
diff --git a/.pick_status.json b/.pick_status.json
index bba637c6d6e..281098e0920 100644
--- a/.pick_status.json
+++ b/.pick_status.json
@@ -3406,7 +3406,7 @@
"description": "intel/perf: fix raw query kernel metric selection",
"nominated": true,
"nomination_type": 0,
- "resolution": 0,
+ "resolution": 1,
"master_sha": null,
"because_sha": null
},
diff --git a/src/intel/perf/gen_perf.c b/src/intel/perf/gen_perf.c
index 189f71f6575..77b7f4d8188 100644
--- a/src/intel/perf/gen_perf.c
+++ b/src/intel/perf/gen_perf.c
@@ -621,6 +621,19 @@ load_oa_metrics(struct gen_perf_config *perf, int fd,
else
enumerate_sysfs_metrics(perf);
+ /* Select a fallback OA metric. Look for the TestOa metric or use the last
+ * one if no present (on HSW).
+ */
+ for (int i = 0; i < perf->n_queries; i++) {
+ if (perf->queries[i].symbol_name &&
+ strcmp(perf->queries[i].symbol_name, "TestOa") == 0) {
+ perf->fallback_raw_oa_metric = perf->queries[i].oa_metrics_set_id;
+ break;
+ }
+ }
+ if (perf->fallback_raw_oa_metric == 0)
+ perf->fallback_raw_oa_metric = perf->queries[perf->n_queries - 1].oa_metrics_set_id;
+
return true;
}
diff --git a/src/intel/perf/gen_perf.h b/src/intel/perf/gen_perf.h
index 1421d2b3a08..05029bc912e 100644
--- a/src/intel/perf/gen_perf.h
+++ b/src/intel/perf/gen_perf.h
@@ -228,6 +228,11 @@ struct gen_perf_config {
*/
struct hash_table *oa_metrics_table;
+ /* When MDAPI hasn't configured the metric we need to use by the time the
+ * query begins, this OA metric is used as a fallback.
+ */
+ uint64_t fallback_raw_oa_metric;
+
/* Location of the device's sysfs entry. */
char sysfs_dev_dir[256];
diff --git a/src/intel/perf/gen_perf_query.c b/src/intel/perf/gen_perf_query.c
index b9744913b16..fb6e5d33efb 100644
--- a/src/intel/perf/gen_perf_query.c
+++ b/src/intel/perf/gen_perf_query.c
@@ -423,7 +423,7 @@ get_metric_id(struct gen_perf_config *perf,
if (!gen_perf_load_metric_id(perf, query->guid,
&raw_query->oa_metrics_set_id)) {
DBG("Unable to read query guid=%s ID, falling back to test config\n", query->guid);
- raw_query->oa_metrics_set_id = 1ULL;
+ raw_query->oa_metrics_set_id = perf->fallback_raw_oa_metric;
} else {
DBG("Raw query '%s'guid=%s loaded ID: %"PRIu64"\n",
query->name, query->guid, query->oa_metrics_set_id);