]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
perf arm-spe: Don't warn about the discard bit if it doesn't exist
authorJames Clark <james.clark@linaro.org>
Fri, 10 Apr 2026 11:05:12 +0000 (12:05 +0100)
committerArnaldo Carvalho de Melo <acme@redhat.com>
Sat, 30 May 2026 00:20:50 +0000 (21:20 -0300)
Opening an SPE event shows a warning that doesn't concern the user:

  $ perf record -e arm_spe
  Unknown/empty format name: discard

Perf only wants to know if the discard bit is set for configuring the
event, not in response to anything the user has done. Fix it by adding
another helper that returns if a config bit exists without warning.

We should probably keep the warning in evsel__get_config_val() to avoid
having every caller having to do it, and most format bits should never
be missing.

Add a test for the new helper. Rename the parent test function to be
more generic rather than adding a new one as it requires a lot of
boilerplate.

Reviewed-by: Ian Rogers <irogers@google.com>
Reviewed-by: Leo Yan <leo.yan@arm.com>
Signed-off-by: James Clark <james.clark@linaro.org>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: John Garry <john.g.garry@oracle.com>
Cc: Leo Yan <leo.yan@linux.dev>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Mike Leach <mike.leach@linaro.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Will Deacon <will@kernel.org>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
tools/perf/arch/arm64/util/arm-spe.c
tools/perf/tests/pmu.c
tools/perf/util/evsel.c
tools/perf/util/evsel.h

index f00d72d087fccd8ceac43b02d1ac67f150b8ac84..91bb28cad79a5573fea819a630440c4818a5be74 100644 (file)
@@ -428,7 +428,8 @@ static int arm_spe_recording_options(struct auxtrace_record *itr,
        evlist__for_each_entry_safe(evlist, tmp, evsel) {
                if (evsel__is_aux_event(evsel)) {
                        arm_spe_setup_evsel(evsel, cpus);
-                       if (!evsel__get_config_val(evsel, "discard", &discard_bit))
+                       if (evsel__config_exists(evsel, "discard") &&
+                           !evsel__get_config_val(evsel, "discard", &discard_bit))
                                discard = !!discard_bit;
                }
        }
index 0ebf2d7b2cb410ebc6cbb0473f66c3abd4a2ff05..d7be9d1c6f52b8614ab736b6212b71f908997012 100644 (file)
@@ -201,7 +201,8 @@ err_out:
        return ret;
 }
 
-static int test__pmu_usr_chgs(struct test_suite *test __maybe_unused, int subtest __maybe_unused)
+static int test__pmu_config_helpers(struct test_suite *test __maybe_unused,
+                                   int subtest __maybe_unused)
 {
        const char *event = "perf-pmu-test/config=15,config1=4,krava02=170,"
                            "krava03=1,krava11=27,krava12=1/";
@@ -236,6 +237,12 @@ static int test__pmu_usr_chgs(struct test_suite *test __maybe_unused, int subtes
        }
        evsel = evlist__first(evlist);
 
+       /* Test evsel__config_exists() */
+       TEST_ASSERT_EQUAL("krava01 should exist",
+                         evsel__config_exists(evsel, "krava01"), true);
+       TEST_ASSERT_EQUAL("krava99 should not exist",
+                         evsel__config_exists(evsel, "krava99"), false);
+
        /*
         * Set via config=15, krava01 bits 0-1
         * Set via config1=4, krava11 bit 1
@@ -629,7 +636,7 @@ static struct test_case tests__pmu[] = {
        TEST_CASE("PMU name combining", name_len),
        TEST_CASE("PMU name comparison", name_cmp),
        TEST_CASE("PMU cmdline match", pmu_match),
-       TEST_CASE("PMU user config changes", pmu_usr_chgs),
+       TEST_CASE("PMU config helpers", pmu_config_helpers),
        {       .name = NULL, }
 };
 
index ac92f9e0e5b4caaac40829852fd50b181febe88d..34c03f47a91339e01aec8385283ee25351aa6285 100644 (file)
@@ -1399,6 +1399,12 @@ void evsel__set_config_if_unset(struct evsel *evsel, const char *config_name,
        perf_pmu__format_pack(format->bits, val, vp, /*zero=*/true);
 }
 
+bool evsel__config_exists(const struct evsel *evsel, const char *config_name)
+{
+       struct perf_pmu_format *format = pmu_find_format(&evsel->pmu->format, config_name);
+
+       return format && !bitmap_empty(format->bits, PERF_PMU_FORMAT_BITS);
+}
 
 int evsel__get_config_val(const struct evsel *evsel, const char *config_name,
                          u64 *val)
index 3b12d99f0aa9fd718e24ed76fb7bc00cfb0f4639..8178858d168a6b84b8c796033f7c91e42dc939fb 100644 (file)
@@ -589,6 +589,7 @@ void evsel__uniquify_counter(struct evsel *counter);
        ((((src) >> (pos)) & ((1ull << (size)) - 1)) << (63 - ((pos) + (size) - 1)))
 
 u64 evsel__bitfield_swap_branch_flags(u64 value);
+bool evsel__config_exists(const struct evsel *evsel, const char *config_name);
 int evsel__get_config_val(const struct evsel *evsel, const char *config_name,
                          u64 *val);
 void evsel__set_config_if_unset(struct evsel *evsel, const char *config_name,