<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"></head><body style="overflow-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;"><br id="lineBreakAtBeginningOfMessage"><div><br><blockquote type="cite"><div>On 13 Feb 2025, at 9:04 AM, Namhyung Kim <namhyung@kernel.org> wrote:</div><br class="Apple-interchange-newline"><div><meta charset="UTF-8"><span style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; float: none; display: inline !important;">On Thu, Feb 13, 2025 at 12:24:38AM +0530, Athira Rajeev wrote:</span><br style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;"><blockquote type="cite" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;">"Tool PMU" tests fails on powerpc as below:<br><br>  12.1: Parsing without PMU name:<br>  --- start ---<br>  test child forked, pid 48492<br>  Using CPUID 0x00800200<br>  Attempt to add: tool/duration_time/<br>  ..after resolving event: tool/config=0x1/<br>  duration_time -> tool/duration_time/<br>  Attempt to add: tool/user_time/<br>  ..after resolving event: tool/config=0x2/<br>  user_time -> tool/user_time/<br>  Attempt to add: tool/system_time/<br>  ..after resolving event: tool/config=0x3/<br>  system_time -> tool/system_time/<br>  Attempt to add: tool/has_pmem/<br>  ..after resolving event: tool/config=0x4/<br>  has_pmem -> tool/has_pmem/<br>  Attempt to add: tool/num_cores/<br>  ..after resolving event: tool/config=0x5/<br>  num_cores -> tool/num_cores/<br>  Attempt to add: tool/num_cpus/<br>  ..after resolving event: tool/config=0x6/<br>  num_cpus -> tool/num_cpus/<br>  Attempt to add: tool/num_cpus_online/<br>  ..after resolving event: tool/config=0x7/<br>  num_cpus_online -> tool/num_cpus_online/<br>  Attempt to add: tool/num_dies/<br>  ..after resolving event: tool/config=0x8/<br>  num_dies -> tool/num_dies/<br>  Attempt to add: tool/num_packages/<br>  ..after resolving event: tool/config=0x9/<br>  num_packages -> tool/num_packages/<br><br>  ---- unexpected signal (11) ----<br>  12.1: Parsing without PMU name                                      : FAILED!<br><br>Same fail is observed for "Parsing with PMU name" as well.<br><br>The testcase loops through events in tool_pmu__for_each_event()<br>and access event name using "tool_pmu__event_to_str()".<br>Here tool_pmu__event_to_str returns null for "slots" event<br>and "system_tsc_freq" event. These two events are only applicable<br>for arm64 and x86 respectively. So the function tool_pmu__event_to_str()<br>skips for unsupported events and returns null. This null value is<br>causing testcase fail.<br><br>To address this in "Tool PMU" testcase, add a helper function<br>tool_pmu__all_event_to_str() which returns the name for all<br>events mapping to the tool_pmu_event index including the<br>skipped ones. So that even if its a skipped event, the<br>helper function helps to resolve the tool_pmu_event index to<br>its mapping event name. Update the testcase to check for null event<br>names before proceeding the test.<br><br>Signed-off-by: Athira Rajeev <atrajeev@linux.vnet.ibm.com><br></blockquote><br style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;"><span style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; float: none; display: inline !important;">Please take a look at:</span><br style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;"><a href="https://lore.kernel.org/r/20250212163859.1489916-1-james.clark@linaro.org" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;">https://lore.kernel.org/r/20250212163859.1489916-1-james.clark@linaro.org</a><br style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;"><br style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;"><span style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; float: none; display: inline !important;">Thanks,</span><br style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;"><span style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; float: none; display: inline !important;">Namhyung</span><br style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;"></div></blockquote>Hi,</div><div><br></div><div>Sure thanks for the fix James</div><div><br></div><div>Thomas,</div><div>Thanks for testing this patch.  But James already fixed this with a different patch and it is part of perf-tools-next</div><div><a href="https://git.kernel.org/pub/scm/linux/kernel/git/perf/perf-tools-next.git/commit/?h=perf-tools-next&id=615ec00b06f78912c370b372426190768402a5b9">https://git.kernel.org/pub/scm/linux/kernel/git/perf/perf-tools-next.git/commit/?h=perf-tools-next&id=615ec00b06f78912c370b372426190768402a5b9</a><br></div><div><br></div><div>Please test with latest perf-tools-next </div><div><br></div><div>Thanks</div><div>Athira</div><div><br><blockquote type="cite"><div><br style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;"><blockquote type="cite" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;">---<br>tools/perf/tests/tool_pmu.c | 12 ++++++++++++<br>tools/perf/util/tool_pmu.c  | 17 +++++++++++++++++<br>tools/perf/util/tool_pmu.h  |  1 +<br>3 files changed, 30 insertions(+)<br><br>diff --git a/tools/perf/tests/tool_pmu.c b/tools/perf/tests/tool_pmu.c<br>index 187942b749b7..e468e5fb3c73 100644<br>--- a/tools/perf/tests/tool_pmu.c<br>+++ b/tools/perf/tests/tool_pmu.c<br>@@ -19,6 +19,18 @@ static int do_test(enum tool_pmu_event ev, bool with_pmu)<br><span class="Apple-tab-span" style="white-space: pre;">     </span><span class="Apple-tab-span" style="white-space: pre;">  </span>return TEST_FAIL;<br><span class="Apple-tab-span" style="white-space: pre;">       </span>}<br><br>+<span class="Apple-tab-span" style="white-space: pre;">    </span>/*<br>+<span class="Apple-tab-span" style="white-space: pre;">     </span><span class="Apple-converted-space"> </span>* if tool_pmu__event_to_str returns NULL, Check if the event is<br>+<span class="Apple-tab-span" style="white-space: pre;"> </span><span class="Apple-converted-space"> </span>* valid for the platform.<br>+<span class="Apple-tab-span" style="white-space: pre;">       </span><span class="Apple-converted-space"> </span>* Example:<br>+<span class="Apple-tab-span" style="white-space: pre;">      </span><span class="Apple-converted-space"> </span>* slots event is only on arm64.<br>+<span class="Apple-tab-span" style="white-space: pre;"> </span><span class="Apple-converted-space"> </span>* system_tsc_freq event is only on x86.<br>+<span class="Apple-tab-span" style="white-space: pre;"> </span><span class="Apple-converted-space"> </span>*/<br>+<span class="Apple-tab-span" style="white-space: pre;">      </span>if (!tool_pmu__event_to_str(ev) && tool_pmu__skip_event(tool_pmu__all_event_to_str(ev))) {<br>+<span class="Apple-tab-span" style="white-space: pre;">     </span><span class="Apple-tab-span" style="white-space: pre;">  </span>ret = TEST_OK;<br>+<span class="Apple-tab-span" style="white-space: pre;"> </span><span class="Apple-tab-span" style="white-space: pre;">  </span>goto out;<br>+<span class="Apple-tab-span" style="white-space: pre;">      </span>}<br>+<br><span class="Apple-tab-span" style="white-space: pre;">    </span>if (with_pmu)<br><span class="Apple-tab-span" style="white-space: pre;">   </span><span class="Apple-tab-span" style="white-space: pre;">  </span>snprintf(str, sizeof(str), "tool/%s/", tool_pmu__event_to_str(ev));<br><span class="Apple-tab-span" style="white-space: pre;">   </span>else<br>diff --git a/tools/perf/util/tool_pmu.c b/tools/perf/util/tool_pmu.c<br>index 3a68debe7143..572422797f6e 100644<br>--- a/tools/perf/util/tool_pmu.c<br>+++ b/tools/perf/util/tool_pmu.c<br>@@ -60,6 +60,15 @@ int tool_pmu__num_skip_events(void)<br><span class="Apple-tab-span" style="white-space: pre;"> </span>return num;<br>}<br><br>+/*<br>+ * tool_pmu__event_to_str returns only supported event names.<br>+ * For events which are supposed to be skipped in the platform,<br>+ * return NULL<br>+ *<br>+ * tool_pmu__all_event_to_str returns the name for all<br>+ * events mapping to the tool_pmu_event index including the<br>+ * skipped ones.<br>+ */<br>const char *tool_pmu__event_to_str(enum tool_pmu_event ev)<br>{<br><span class="Apple-tab-span" style="white-space: pre;">    </span>if ((ev > TOOL_PMU__EVENT_NONE && ev < TOOL_PMU__EVENT_MAX) &&<br>@@ -69,6 +78,14 @@ const char *tool_pmu__event_to_str(enum tool_pmu_event ev)<br><span class="Apple-tab-span" style="white-space: pre;">     </span>return NULL;<br>}<br><br>+const char *tool_pmu__all_event_to_str(enum tool_pmu_event ev)<br>+{<br>+<span class="Apple-tab-span" style="white-space: pre;"> </span>if (ev > TOOL_PMU__EVENT_NONE && ev < TOOL_PMU__EVENT_MAX)<br>+<span class="Apple-tab-span" style="white-space: pre;">       </span><span class="Apple-tab-span" style="white-space: pre;">  </span>return tool_pmu__event_names[ev];<br>+<br>+<span class="Apple-tab-span" style="white-space: pre;">   </span>return NULL;<br>+}<br>+<br>enum tool_pmu_event tool_pmu__str_to_event(const char *str)<br>{<br><span class="Apple-tab-span" style="white-space: pre;">     </span>int i;<br>diff --git a/tools/perf/util/tool_pmu.h b/tools/perf/util/tool_pmu.h<br>index a60184859080..da76808ae71e 100644<br>--- a/tools/perf/util/tool_pmu.h<br>+++ b/tools/perf/util/tool_pmu.h<br>@@ -30,6 +30,7 @@ enum tool_pmu_event {<br><span class="Apple-tab-span" style="white-space: pre;">      </span>for ((ev) = TOOL_PMU__EVENT_DURATION_TIME; (ev) < TOOL_PMU__EVENT_MAX; ev++)<br><br>const char *tool_pmu__event_to_str(enum tool_pmu_event ev);<br>+const char *tool_pmu__all_event_to_str(enum tool_pmu_event ev);<br>enum tool_pmu_event tool_pmu__str_to_event(const char *str);<br>bool tool_pmu__skip_event(const char *name);<br>int tool_pmu__num_skip_events(void);<br>--<span class="Apple-converted-space"> </span><br>2.43.5</blockquote></div></blockquote></div><br></body></html>