Commit 09d2056e authored by Yang Jihong's avatar Yang Jihong Committed by Arnaldo Carvalho de Melo
Browse files

perf evsel: Use evsel__name_is() helper



Code cleanup, replace strcmp(evsel__name(evsel, {NAME})) with
evsel__name_is() helper.

No functional change.

Committer notes:

Fix this build error:

          trace.syscalls.events.bpf_output = evlist__last(trace.evlist);
  -       assert(evsel__name_is(trace.syscalls.events.bpf_output), "__augmented_syscalls__");
  +       assert(evsel__name_is(trace.syscalls.events.bpf_output, "__augmented_syscalls__"));

Reviewed-by: default avatarIan Rogers <irogers@google.com>
Signed-off-by: default avatarYang Jihong <yangjihong@bytedance.com>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: James Clark <james.clark@arm.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Kan Liang <kan.liang@linux.intel.com>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: https://lore.kernel.org/r/20240401062724.1006010-3-yangjihong@bytedance.com


Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parent 6e4b3987
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -1408,7 +1408,7 @@ static int __cmd_kmem(struct perf_session *session)
	}

	evlist__for_each_entry(session->evlist, evsel) {
		if (!strcmp(evsel__name(evsel), "kmem:mm_page_alloc") &&
		if (evsel__name_is(evsel, "kmem:mm_page_alloc") &&
		    evsel__field(evsel, "pfn")) {
			use_pfn = true;
			break;
+2 −2
Original line number Diff line number Diff line
@@ -2148,7 +2148,7 @@ static bool is_idle_sample(struct perf_sample *sample,
			   struct evsel *evsel)
{
	/* pid 0 == swapper == idle task */
	if (strcmp(evsel__name(evsel), "sched:sched_switch") == 0)
	if (evsel__name_is(evsel, "sched:sched_switch"))
		return evsel__intval(evsel, sample, "prev_pid") == 0;

	return sample->pid == 0;
@@ -2375,7 +2375,7 @@ static bool timehist_skip_sample(struct perf_sched *sched,
	}

	if (sched->idle_hist) {
		if (strcmp(evsel__name(evsel), "sched:sched_switch"))
		if (!evsel__name_is(evsel, "sched:sched_switch"))
			rc = true;
		else if (evsel__intval(evsel, sample, "prev_pid") != 0 &&
			 evsel__intval(evsel, sample, "next_pid") != 0)
+1 −1
Original line number Diff line number Diff line
@@ -3471,7 +3471,7 @@ static int check_ev_match(char *dir_name, char *scriptname,

			match = 0;
			evlist__for_each_entry(session->evlist, pos) {
				if (!strcmp(evsel__name(pos), evname)) {
				if (evsel__name_is(pos, evname)) {
					match = 1;
					break;
				}
+2 −2
Original line number Diff line number Diff line
@@ -4916,7 +4916,7 @@ int cmd_trace(int argc, const char **argv)
		goto out;
	}
	trace.syscalls.events.bpf_output = evlist__last(trace.evlist);
	assert(!strcmp(evsel__name(trace.syscalls.events.bpf_output), "__augmented_syscalls__"));
	assert(evsel__name_is(trace.syscalls.events.bpf_output, "__augmented_syscalls__"));
skip_augmentation:
#endif
	err = -1;
@@ -4973,7 +4973,7 @@ int cmd_trace(int argc, const char **argv)
	 */
	if (trace.syscalls.events.bpf_output) {
		evlist__for_each_entry(trace.evlist, evsel) {
			bool raw_syscalls_sys_exit = strcmp(evsel__name(evsel), "raw_syscalls:sys_exit") == 0;
			bool raw_syscalls_sys_exit = evsel__name_is(evsel, "raw_syscalls:sys_exit");

			if (raw_syscalls_sys_exit) {
				trace.raw_augmented_syscalls = true;
+2 −2
Original line number Diff line number Diff line
@@ -37,7 +37,7 @@ static int perf_evsel__roundtrip_cache_name_test(void)
					continue;
				}
				evlist__for_each_entry(evlist, evsel) {
					if (strcmp(evsel__name(evsel), name)) {
					if (!evsel__name_is(evsel, name)) {
						pr_debug("%s != %s\n", evsel__name(evsel), name);
						ret = TEST_FAIL;
					}
@@ -71,7 +71,7 @@ static int perf_evsel__name_array_test(const char *const names[], int nr_names)
			continue;
		}
		evlist__for_each_entry(evlist, evsel) {
			if (strcmp(evsel__name(evsel), names[i])) {
			if (!evsel__name_is(evsel, names[i])) {
				pr_debug("%s != %s\n", evsel__name(evsel), names[i]);
				ret = TEST_FAIL;
			}
Loading