Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

perf tools: Simplify evsel__add_modifier()

Since it doesn't set the exclude_guest, no need to special handle the
bit and simply show only if one of host or guest bit is set. Now the
default event name might not have :H prefix anymore so change the
dlfilter test not to compare the ":" at the end.

Reviewed-by: Ian Rogers <irogers@google.com>
Reviewed-by: James Clark <james.clark@linaro.org>
Reviewed-by: Ravi Bangoria <ravi.bangoria@amd.com>
Acked-by: Kan Liang <kan.liang@linux.intel.com>
Cc: James Clark <james.clark@arm.com>
Cc: Atish Patra <atishp@atishpatra.org>
Cc: Mingwei Zhang <mizhang@google.com>
Cc: Kajol Jain <kjain@linux.ibm.com>
Cc: Thomas Richter <tmricht@linux.ibm.com>
Cc: Palmer Dabbelt <palmer@rivosinc.com>
Link: https://lore.kernel.org/r/20241016062359.264929-4-namhyung@kernel.org
Signed-off-by: Namhyung Kim <namhyung@kernel.org>

+3 -6
+1 -1
tools/perf/dlfilters/dlfilter-test-api-v0.c
··· 220 220 CHECK_SAMPLE(raw_callchain_nr); 221 221 CHECK(!sample->raw_callchain); 222 222 223 - #define EVENT_NAME "branches:" 223 + #define EVENT_NAME "branches" 224 224 CHECK(!strncmp(sample->event, EVENT_NAME, strlen(EVENT_NAME))); 225 225 226 226 return 0;
+1 -1
tools/perf/dlfilters/dlfilter-test-api-v2.c
··· 235 235 CHECK_SAMPLE(raw_callchain_nr); 236 236 CHECK(!sample->raw_callchain); 237 237 238 - #define EVENT_NAME "branches:" 238 + #define EVENT_NAME "branches" 239 239 CHECK(!strncmp(sample->event, EVENT_NAME, strlen(EVENT_NAME))); 240 240 241 241 return 0;
+1 -4
tools/perf/util/evsel.c
··· 638 638 { 639 639 int colon = 0, r = 0; 640 640 struct perf_event_attr *attr = &evsel->core.attr; 641 - bool exclude_guest_default = false; 642 641 643 642 #define MOD_PRINT(context, mod) do { \ 644 643 if (!attr->exclude_##context) { \ ··· 649 650 MOD_PRINT(kernel, 'k'); 650 651 MOD_PRINT(user, 'u'); 651 652 MOD_PRINT(hv, 'h'); 652 - exclude_guest_default = true; 653 653 } 654 654 655 655 if (attr->precise_ip) { 656 656 if (!colon) 657 657 colon = ++r; 658 658 r += scnprintf(bf + r, size - r, "%.*s", attr->precise_ip, "ppp"); 659 - exclude_guest_default = true; 660 659 } 661 660 662 - if (attr->exclude_host || attr->exclude_guest == exclude_guest_default) { 661 + if (attr->exclude_host || attr->exclude_guest) { 663 662 MOD_PRINT(host, 'H'); 664 663 MOD_PRINT(guest, 'G'); 665 664 }