From 7fbfa694a891369ff408235cb7839505033cfc80 Mon Sep 17 00:00:00 2001 From: Lionel Landwerlin Date: Thu, 21 Jul 2022 07:51:03 +0000 Subject: [PATCH] intel/perf: simplify pass computation loop We don't need to go through all the metric sets as we're already built a bitset matching per counter to figure out in which metric set a particular counter is. Signed-off-by: Lionel Landwerlin Reviewed-by: Ivan Briano Part-of: --- src/intel/perf/intel_perf.c | 31 +++++++++++++------------------ 1 file changed, 13 insertions(+), 18 deletions(-) diff --git a/src/intel/perf/intel_perf.c b/src/intel/perf/intel_perf.c index 3fd83b8..a3ae255 100644 --- a/src/intel/perf/intel_perf.c +++ b/src/intel/perf/intel_perf.c @@ -898,28 +898,23 @@ get_passes_mask(struct intel_perf_config *perf, /* Now go through each metric set and find one that contains this * counter. */ - for (uint32_t q = 0; q < perf->n_queries; q++) { - bool found = false; - - for (uint32_t w = 0; w < BITSET_WORDS(INTEL_PERF_MAX_METRIC_SETS); w++) { - if (!counter_info->query_mask[w]) - continue; - - uint32_t query_idx = w * BITSET_WORDBITS + ffsll(counter_info->query_mask[w]) - 1; + bool found = false; + for (uint32_t w = 0; w < BITSET_WORDS(INTEL_PERF_MAX_METRIC_SETS); w++) { + if (!counter_info->query_mask[w]) + continue; - /* Since we already looked for this in the query_mask, it should - * not be set. - */ - assert(!BITSET_TEST(queries_mask, query_idx)); + uint32_t query_idx = w * BITSET_WORDBITS + ffsll(counter_info->query_mask[w]) - 1; - BITSET_SET(queries_mask, query_idx); - found = true; - break; - } + /* Since we already looked for this in the query_mask, it should not + * be set. + */ + assert(!BITSET_TEST(queries_mask, query_idx)); - if (found) - break; + BITSET_SET(queries_mask, query_idx); + found = true; + break; } + assert(found); } } -- 2.7.4