Skip to content

Commit 6d78089

Browse files
captain5050namhyung
authored andcommitted
perf tests: Fix hwmon parsing with PMU name test
Incorrectly the hwmon with PMU name test didn't pass "true". Fix and address issue with hwmon_pmu__config_terms needing to load events - a load bearing assert fired. Also fix missing list deletion when putting the hwmon test PMU and lower some debug warnings to make the hwmon PMU less spammy in verbose mode. Signed-off-by: Ian Rogers <irogers@google.com> Tested-by: Namhyung Kim <namhyung@kernel.org> Link: https://lore.kernel.org/r/20241121000955.536930-1-irogers@google.com Signed-off-by: Namhyung Kim <namhyung@kernel.org>
1 parent 62878b4 commit 6d78089

File tree

2 files changed

+13
-8
lines changed

2 files changed

+13
-8
lines changed

tools/perf/tests/hwmon_pmu.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ static int test_pmu_put(const char *dir, struct perf_pmu *hwm)
4141
if (ret)
4242
pr_err("Failure to \"%s\"\n", buf);
4343

44+
list_del(&hwm->list);
4445
perf_pmu__delete(hwm);
4546
return ret;
4647
}
@@ -147,7 +148,7 @@ static int do_test(size_t i, bool with_pmu, bool with_alias)
147148
}
148149

149150
if (with_pmu)
150-
snprintf(str, sizeof(str), "/%s/", test_event);
151+
snprintf(str, sizeof(str), "hwmon_a_test_hwmon_pmu/%s/", test_event);
151152
else
152153
strlcpy(str, test_event, sizeof(str));
153154

@@ -231,7 +232,7 @@ static int test__hwmon_pmu_without_pmu(struct test_suite *test __maybe_unused,
231232
static int test__hwmon_pmu_with_pmu(struct test_suite *test __maybe_unused,
232233
int subtest __maybe_unused)
233234
{
234-
return test__hwmon_pmu(/*with_pmu=*/false);
235+
return test__hwmon_pmu(/*with_pmu=*/true);
235236
}
236237

237238
static int test__parse_hwmon_filename(struct test_suite *test __maybe_unused,

tools/perf/util/hwmon_pmu.c

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -197,13 +197,13 @@ bool parse_hwmon_filename(const char *filename,
197197
}
198198
}
199199
if (fn_item == NULL || fn_type[0] == '\0' || (item != NULL && fn_item[0] == '\0')) {
200-
pr_debug("hwmon_pmu: not a hwmon file '%s'\n", filename);
200+
pr_debug3("hwmon_pmu: not a hwmon file '%s'\n", filename);
201201
return false;
202202
}
203203
elem = bsearch(&fn_type, hwmon_type_strs + 1, ARRAY_SIZE(hwmon_type_strs) - 1,
204204
sizeof(hwmon_type_strs[0]), hwmon_strcmp);
205205
if (!elem) {
206-
pr_debug("hwmon_pmu: not a hwmon type '%s' in file name '%s'\n",
206+
pr_debug3("hwmon_pmu: not a hwmon type '%s' in file name '%s'\n",
207207
fn_type, filename);
208208
return false;
209209
}
@@ -223,7 +223,7 @@ bool parse_hwmon_filename(const char *filename,
223223
elem = bsearch(fn_item, hwmon_item_strs + 1, ARRAY_SIZE(hwmon_item_strs) - 1,
224224
sizeof(hwmon_item_strs[0]), hwmon_strcmp);
225225
if (!elem) {
226-
pr_debug("hwmon_pmu: not a hwmon item '%s' in file name '%s'\n",
226+
pr_debug3("hwmon_pmu: not a hwmon item '%s' in file name '%s'\n",
227227
fn_item, filename);
228228
return false;
229229
}
@@ -281,7 +281,7 @@ static int hwmon_pmu__read_events(struct hwmon_pmu *pmu)
281281
continue;
282282

283283
if (!parse_hwmon_filename(ent->d_name, &type, &number, &item, &alarm)) {
284-
pr_debug("Not a hwmon file '%s'\n", ent->d_name);
284+
pr_debug3("Not a hwmon file '%s'\n", ent->d_name);
285285
continue;
286286
}
287287
key.num = number;
@@ -653,10 +653,14 @@ int hwmon_pmu__config_terms(const struct perf_pmu *pmu,
653653
struct parse_events_terms *terms,
654654
struct parse_events_error *err)
655655
{
656-
const struct hwmon_pmu *hwm = container_of(pmu, struct hwmon_pmu, pmu);
656+
struct hwmon_pmu *hwm = container_of(pmu, struct hwmon_pmu, pmu);
657657
struct parse_events_term *term;
658+
int ret;
659+
660+
ret = hwmon_pmu__read_events(hwm);
661+
if (ret)
662+
return ret;
658663

659-
assert(pmu->sysfs_aliases_loaded);
660664
list_for_each_entry(term, &terms->terms, list) {
661665
if (hwmon_pmu__config_term(hwm, attr, term, err))
662666
return -EINVAL;

0 commit comments

Comments
 (0)