perf tools: Simplify evsel__add_modifier()
authorNamhyung Kim <namhyung@kernel.org>
Wed, 16 Oct 2024 06:23:53 +0000 (23:23 -0700)
committerNamhyung Kim <namhyung@kernel.org>
Tue, 22 Oct 2024 16:52:11 +0000 (09:52 -0700)
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>
tools/perf/dlfilters/dlfilter-test-api-v0.c
tools/perf/dlfilters/dlfilter-test-api-v2.c
tools/perf/util/evsel.c

index 4083b1abeaabe6057c929fd8b78ced041b57cd24..4ca2d7b2ea6c820074273c45f72600f88e0dc43d 100644 (file)
@@ -220,7 +220,7 @@ static int check_sample(struct filter_data *d, const struct perf_dlfilter_sample
        CHECK_SAMPLE(raw_callchain_nr);
        CHECK(!sample->raw_callchain);
 
-#define EVENT_NAME "branches:"
+#define EVENT_NAME "branches"
        CHECK(!strncmp(sample->event, EVENT_NAME, strlen(EVENT_NAME)));
 
        return 0;
index 32ff619e881caa501c05b713f9f5baaa45862de9..00d73a16c4fdaece70bf27b818a8dd3e5ad81bfc 100644 (file)
@@ -235,7 +235,7 @@ static int check_sample(struct filter_data *d, const struct perf_dlfilter_sample
        CHECK_SAMPLE(raw_callchain_nr);
        CHECK(!sample->raw_callchain);
 
-#define EVENT_NAME "branches:"
+#define EVENT_NAME "branches"
        CHECK(!strncmp(sample->event, EVENT_NAME, strlen(EVENT_NAME)));
 
        return 0;
index 8fb31f0b48b8d787900e096f80d43f9d3a477951..7f98f9d3394a72275a190e981d136f2cca515d20 100644 (file)
@@ -638,7 +638,6 @@ static int evsel__add_modifiers(struct evsel *evsel, char *bf, size_t size)
 {
        int colon = 0, r = 0;
        struct perf_event_attr *attr = &evsel->core.attr;
-       bool exclude_guest_default = false;
 
 #define MOD_PRINT(context, mod)        do {                                    \
                if (!attr->exclude_##context) {                         \
@@ -650,17 +649,15 @@ static int evsel__add_modifiers(struct evsel *evsel, char *bf, size_t size)
                MOD_PRINT(kernel, 'k');
                MOD_PRINT(user, 'u');
                MOD_PRINT(hv, 'h');
-               exclude_guest_default = true;
        }
 
        if (attr->precise_ip) {
                if (!colon)
                        colon = ++r;
                r += scnprintf(bf + r, size - r, "%.*s", attr->precise_ip, "ppp");
-               exclude_guest_default = true;
        }
 
-       if (attr->exclude_host || attr->exclude_guest == exclude_guest_default) {
+       if (attr->exclude_host || attr->exclude_guest) {
                MOD_PRINT(host, 'H');
                MOD_PRINT(guest, 'G');
        }