All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ian Rogers <irogers@google.com>
To: tmricht@linux.ibm.com
Cc: irogers@google.com, acme@kernel.org, agordeev@linux.ibm.com,
	 gor@linux.ibm.com, hca@linux.ibm.com, japo@linux.ibm.com,
	 linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org,
	 linux-s390@vger.kernel.org, namhyung@kernel.org,
	sumanthk@linux.ibm.com
Subject: [PATCH v3 3/3] perf evlist: Improve default event for s390
Date: Fri, 13 Mar 2026 13:28:11 -0700	[thread overview]
Message-ID: <20260313202811.2599195-4-irogers@google.com> (raw)
In-Reply-To: <20260313202811.2599195-1-irogers@google.com>

Frame pointer callchains are not supported on s390 and dwarf
callchains are only supported on software events.

Switch the default event from cycles to cpu-clock or task-clock on
s390 if callchains are enabled.

If frame pointer callchains are requested on s390, warn and switch to
dwarf callchains.

Signed-off-by: Ian Rogers <irogers@google.com>
---
 tools/perf/builtin-record.c      |  3 ++-
 tools/perf/builtin-top.c         |  2 +-
 tools/perf/tests/event_update.c  |  4 +++-
 tools/perf/tests/expand-cgroup.c |  4 +++-
 tools/perf/tests/perf-record.c   |  7 ++++--
 tools/perf/tests/topology.c      |  4 +++-
 tools/perf/util/evlist.c         | 37 +++++++++++++++++++-------------
 tools/perf/util/evlist.h         |  2 +-
 tools/perf/util/evsel.c          | 11 ++++++++--
 9 files changed, 49 insertions(+), 25 deletions(-)

diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c
index 60d764068302..07ecc8a5fec7 100644
--- a/tools/perf/builtin-record.c
+++ b/tools/perf/builtin-record.c
@@ -4310,7 +4310,8 @@ int cmd_record(int argc, const char **argv)
 		record.opts.tail_synthesize = true;
 
 	if (rec->evlist->core.nr_entries == 0) {
-		struct evlist *def_evlist = evlist__new_default();
+		struct evlist *def_evlist = evlist__new_default(&rec->opts.target,
+								callchain_param.enabled);
 
 		if (!def_evlist)
 			goto out;
diff --git a/tools/perf/builtin-top.c b/tools/perf/builtin-top.c
index 710604c4f6f6..58bab595b024 100644
--- a/tools/perf/builtin-top.c
+++ b/tools/perf/builtin-top.c
@@ -1695,7 +1695,7 @@ int cmd_top(int argc, const char **argv)
 		goto out_delete_evlist;
 
 	if (!top.evlist->core.nr_entries) {
-		struct evlist *def_evlist = evlist__new_default();
+		struct evlist *def_evlist = evlist__new_default(target, callchain_param.enabled);
 
 		if (!def_evlist)
 			goto out_delete_evlist;
diff --git a/tools/perf/tests/event_update.c b/tools/perf/tests/event_update.c
index cb9e6de2e033..facc65e29f20 100644
--- a/tools/perf/tests/event_update.c
+++ b/tools/perf/tests/event_update.c
@@ -8,6 +8,7 @@
 #include "header.h"
 #include "machine.h"
 #include "util/synthetic-events.h"
+#include "target.h"
 #include "tool.h"
 #include "tests.h"
 #include "debug.h"
@@ -81,7 +82,8 @@ static int test__event_update(struct test_suite *test __maybe_unused, int subtes
 {
 	struct evsel *evsel;
 	struct event_name tmp;
-	struct evlist *evlist = evlist__new_default();
+	struct target target = {};
+	struct evlist *evlist = evlist__new_default(&target, /*sample_callchains=*/false);
 
 	TEST_ASSERT_VAL("failed to get evlist", evlist);
 
diff --git a/tools/perf/tests/expand-cgroup.c b/tools/perf/tests/expand-cgroup.c
index c7b32a220ca1..dd547f2f77cc 100644
--- a/tools/perf/tests/expand-cgroup.c
+++ b/tools/perf/tests/expand-cgroup.c
@@ -8,6 +8,7 @@
 #include "parse-events.h"
 #include "pmu-events/pmu-events.h"
 #include "pfm.h"
+#include "target.h"
 #include <subcmd/parse-options.h>
 #include <stdio.h>
 #include <stdlib.h>
@@ -99,7 +100,8 @@ out:	for (i = 0; i < nr_events; i++)
 static int expand_default_events(void)
 {
 	int ret;
-	struct evlist *evlist = evlist__new_default();
+	struct target target = {};
+	struct evlist *evlist = evlist__new_default(&target, /*sample_callchains=*/false);
 
 	TEST_ASSERT_VAL("failed to get evlist", evlist);
 
diff --git a/tools/perf/tests/perf-record.c b/tools/perf/tests/perf-record.c
index efbd9cd60c63..c6e31ab8a6b8 100644
--- a/tools/perf/tests/perf-record.c
+++ b/tools/perf/tests/perf-record.c
@@ -84,8 +84,11 @@ static int test__PERF_RECORD(struct test_suite *test __maybe_unused, int subtest
 	CPU_ZERO_S(cpu_mask_size, cpu_mask);
 
 	perf_sample__init(&sample, /*all=*/false);
-	if (evlist == NULL) /* Fallback for kernels lacking PERF_COUNT_SW_DUMMY */
-		evlist = evlist__new_default();
+	if (evlist == NULL) { /* Fallback for kernels lacking PERF_COUNT_SW_DUMMY */
+		struct target target = {};
+
+		evlist = evlist__new_default(&target, /*sample_callchains=*/false);
+	}
 
 	if (evlist == NULL) {
 		pr_debug("Not enough memory to create evlist\n");
diff --git a/tools/perf/tests/topology.c b/tools/perf/tests/topology.c
index ec01150d208d..a34a7ab19a80 100644
--- a/tools/perf/tests/topology.c
+++ b/tools/perf/tests/topology.c
@@ -9,6 +9,7 @@
 #include "evlist.h"
 #include "debug.h"
 #include "pmus.h"
+#include "target.h"
 #include <linux/err.h>
 
 #define TEMPL "/tmp/perf-test-XXXXXX"
@@ -37,11 +38,12 @@ static int session_write_header(char *path)
 		.path = path,
 		.mode = PERF_DATA_MODE_WRITE,
 	};
+	struct target target = {};
 
 	session = perf_session__new(&data, NULL);
 	TEST_ASSERT_VAL("can't get session", !IS_ERR(session));
 
-	session->evlist = evlist__new_default();
+	session->evlist = evlist__new_default(&target, /*sample_callchains=*/false);
 	TEST_ASSERT_VAL("can't get evlist", session->evlist);
 	session->evlist->session = session;
 
diff --git a/tools/perf/util/evlist.c b/tools/perf/util/evlist.c
index 591bdf0b3e2a..e6c518cc4a69 100644
--- a/tools/perf/util/evlist.c
+++ b/tools/perf/util/evlist.c
@@ -13,6 +13,7 @@
 #include "util/mmap.h"
 #include "thread_map.h"
 #include "target.h"
+#include "dwarf-regs.h"
 #include "evlist.h"
 #include "evsel.h"
 #include "record.h"
@@ -98,38 +99,44 @@ struct evlist *evlist__new(void)
 	return evlist;
 }
 
-struct evlist *evlist__new_default(void)
+struct evlist *evlist__new_default(const struct target *target, bool sample_callchains)
 {
 	struct evlist *evlist = evlist__new();
 	bool can_profile_kernel;
 	struct perf_pmu *pmu = NULL;
+	struct evsel *evsel;
+	char buf[256];
+	int err;
 
 	if (!evlist)
 		return NULL;
 
 	can_profile_kernel = perf_event_paranoid_check(1);
 
-	while ((pmu = perf_pmus__scan_core(pmu)) != NULL) {
-		char buf[256];
-		int err;
-
-		snprintf(buf, sizeof(buf), "%s/cycles/%s", pmu->name,
+	if (EM_HOST == EM_S390 && sample_callchains) {
+		snprintf(buf, sizeof(buf), "software/%s/%s",
+			 target__has_cpu(target) ? "cpu-clock" : "task-clock",
 			 can_profile_kernel ? "P" : "Pu");
 		err = parse_event(evlist, buf);
-		if (err) {
-			evlist__delete(evlist);
-			return NULL;
+		if (err)
+			goto out_err;
+	} else {
+		while ((pmu = perf_pmus__scan_core(pmu)) != NULL) {
+			snprintf(buf, sizeof(buf), "%s/cycles/%s", pmu->name,
+				can_profile_kernel ? "P" : "Pu");
+			err = parse_event(evlist, buf);
+			if (err)
+				goto out_err;
 		}
 	}
 
-	if (evlist->core.nr_entries > 1) {
-		struct evsel *evsel;
-
-		evlist__for_each_entry(evlist, evsel)
-			evsel__set_sample_id(evsel, /*can_sample_identifier=*/false);
-	}
+	evlist__for_each_entry(evlist, evsel)
+		evsel__set_sample_id(evsel, /*can_sample_identifier=*/false);
 
 	return evlist;
+out_err:
+	evlist__delete(evlist);
+	return NULL;
 }
 
 struct evlist *evlist__new_dummy(void)
diff --git a/tools/perf/util/evlist.h b/tools/perf/util/evlist.h
index d17c3b57a409..e507f5f20ef6 100644
--- a/tools/perf/util/evlist.h
+++ b/tools/perf/util/evlist.h
@@ -104,7 +104,7 @@ struct evsel_str_handler {
 };
 
 struct evlist *evlist__new(void);
-struct evlist *evlist__new_default(void);
+struct evlist *evlist__new_default(const struct target *target, bool sample_callchains);
 struct evlist *evlist__new_dummy(void);
 void evlist__init(struct evlist *evlist, struct perf_cpu_map *cpus,
 		  struct perf_thread_map *threads);
diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c
index bd14d9bbc91f..caa95dc06ac5 100644
--- a/tools/perf/util/evsel.c
+++ b/tools/perf/util/evsel.c
@@ -1020,6 +1020,13 @@ static void __evsel__config_callchain(struct evsel *evsel, struct record_opts *o
 {
 	bool function = evsel__is_function_event(evsel);
 	struct perf_event_attr *attr = &evsel->core.attr;
+	enum perf_call_graph_mode record_mode = param->record_mode;
+
+	if (EM_HOST == EM_S390 && param->record_mode == CALLCHAIN_FP) {
+		pr_warning("Framepointer unwinding switched to dwarf due to a lack of kernel support.\n"
+			   "Use '--call-graph dwarf' to silence this warning.\n");
+		record_mode = CALLCHAIN_DWARF;
+	}
 
 	evsel__set_sample_bit(evsel, CALLCHAIN);
 
@@ -1029,7 +1036,7 @@ static void __evsel__config_callchain(struct evsel *evsel, struct record_opts *o
 		attr->exclude_callchain_user = 1;
 	if (opts->user_callchains)
 		attr->exclude_callchain_kernel = 1;
-	if (param->record_mode == CALLCHAIN_LBR) {
+	if (record_mode == CALLCHAIN_LBR) {
 		if (!opts->branch_stack) {
 			if (attr->exclude_user) {
 				pr_warning("LBR callstack option is only available "
@@ -1048,7 +1055,7 @@ static void __evsel__config_callchain(struct evsel *evsel, struct record_opts *o
 				    "Falling back to framepointers.\n");
 	}
 
-	if (param->record_mode == CALLCHAIN_DWARF) {
+	if (record_mode == CALLCHAIN_DWARF) {
 		if (!function) {
 			uint16_t e_machine = evsel__e_machine(evsel, /*e_flags=*/NULL);
 
-- 
2.53.0.851.ga537e3e6e9-goog


  parent reply	other threads:[~2026-03-13 20:28 UTC|newest]

Thread overview: 63+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-03-06  7:10 [PATCH] perf test: Fix test case 120 and 121 for s390 Thomas Richter
2026-03-06 15:51 ` Jan Polensky
2026-03-06 16:53   ` Ian Rogers
2026-03-09 12:59     ` Thomas Richter
2026-03-09 18:18       ` Ian Rogers
2026-03-11  6:09         ` Namhyung Kim
2026-03-11  7:21           ` Thomas Richter
2026-03-12  3:19             ` [PATCH v1 0/2] perf evsel fallback changes Ian Rogers
2026-03-12  3:19               ` [PATCH v1 1/2] perf evsel: Improve falling back from cycles Ian Rogers
2026-03-12  3:19               ` [PATCH v1 2/2] perf evsel: Don't configure framepointer callchains on s390 Ian Rogers
2026-03-12  6:16               ` [PATCH v2 0/2] perf evsel fallback changes Ian Rogers
2026-03-12  6:16                 ` [PATCH v2 1/2] perf evsel: Improve falling back from cycles Ian Rogers
2026-03-12  6:16                 ` [PATCH v2 2/2] perf evsel: Don't configure framepointer callchains on s390 Ian Rogers
2026-03-12 12:45                   ` Thomas Richter
2026-03-12 15:54                     ` Ian Rogers
2026-03-12 16:46                       ` Ian Rogers
2026-03-12 18:00                         ` Namhyung Kim
2026-03-13  9:46                         ` Thomas Richter
2026-03-13 21:01                           ` Namhyung Kim
2026-03-13 20:28                 ` [PATCH v3 0/3] perf evsel fallback changes Ian Rogers
2026-03-13 20:28                   ` [PATCH v3 1/3] perf evsel: Improve falling back from cycles Ian Rogers
2026-03-13 20:28                   ` [PATCH v3 2/3] perf target: Constify simple check functions Ian Rogers
2026-03-13 20:28                   ` Ian Rogers [this message]
2026-03-16 12:13                     ` [PATCH v3 3/3] perf evlist: Improve default event for s390 Thomas Richter
2026-03-16 18:41                       ` Ian Rogers
2026-03-17  3:05                         ` [PATCH v4 0/5] perf evsel fallback changes Ian Rogers
2026-03-17  3:05                           ` [PATCH v4 1/5] perf evsel: Improve falling back from cycles Ian Rogers
2026-03-17  3:05                           ` [PATCH v4 2/5] perf target: Constify simple check functions Ian Rogers
2026-03-17  3:05                           ` [PATCH v4 3/5] perf evsel: Constify option arguments to config functions Ian Rogers
2026-03-17  3:06                           ` [PATCH v4 4/5] perf callchain: Move callchain option parsing out of builtin Ian Rogers
2026-03-17  3:06                           ` [PATCH v4 5/5] perf evlist: Improve default event for s390 Ian Rogers
2026-03-17  5:53                           ` [PATCH v5 0/5] perf evsel fallback changes Ian Rogers
2026-03-17  5:53                             ` [PATCH v5 1/5] perf evsel: Improve falling back from cycles Ian Rogers
2026-03-17  5:53                             ` [PATCH v5 2/5] perf target: Constify simple check functions Ian Rogers
2026-03-17  5:53                             ` [PATCH v5 3/5] perf evsel: Constify option arguments to config functions Ian Rogers
2026-03-17  5:53                             ` [PATCH v5 4/5] perf callchain: Refactor callchain option parsing Ian Rogers
2026-03-17  5:53                             ` [PATCH v5 5/5] perf evlist: Improve default event for s390 Ian Rogers
2026-03-17  7:52                               ` Thomas Richter
2026-03-17 15:54                                 ` Ian Rogers
2026-03-17 17:56                                   ` [PATCH v6 0/5] perf evsel fallback changes, better s390 defaults Ian Rogers
2026-03-17 17:56                                     ` [PATCH v6 1/5] perf evsel: Improve falling back from cycles Ian Rogers
2026-03-17 17:56                                     ` [PATCH v6 2/5] perf target: Constify simple check functions Ian Rogers
2026-03-17 17:56                                     ` [PATCH v6 3/5] perf evsel: Constify option arguments to config functions Ian Rogers
2026-03-17 17:56                                     ` [PATCH v6 4/5] perf callchain: Refactor callchain option parsing Ian Rogers
2026-03-17 17:56                                     ` [PATCH v6 5/5] perf evlist: Improve default event for s390 Ian Rogers
2026-03-18  8:20                                     ` [PATCH v6 0/5] perf evsel fallback changes, better s390 defaults Thomas Richter
2026-03-18 16:29                                       ` Ian Rogers
2026-03-18 17:58                                         ` [PATCH v7 " Ian Rogers
2026-03-18 17:58                                           ` [PATCH v7 1/5] perf evsel: Improve falling back from cycles Ian Rogers
2026-03-18 17:58                                           ` [PATCH v7 2/5] perf target: Constify simple check functions Ian Rogers
2026-03-18 17:58                                           ` [PATCH v7 3/5] perf evsel: Constify option arguments to config functions Ian Rogers
2026-03-18 17:58                                           ` [PATCH v7 4/5] perf callchain: Refactor callchain option parsing Ian Rogers
2026-03-18 17:58                                           ` [PATCH v7 5/5] perf evlist: Improve default event for s390 Ian Rogers
2026-03-18 23:45                                           ` [PATCH v8 0/5] perf evsel fallback changes, better s390 defaults Ian Rogers
2026-03-18 23:45                                             ` [PATCH v8 1/5] perf evsel: Improve falling back from cycles Ian Rogers
2026-03-18 23:45                                             ` [PATCH v8 2/5] perf target: Constify simple check functions Ian Rogers
2026-03-18 23:45                                             ` [PATCH v8 3/5] perf evsel: Constify option arguments to config functions Ian Rogers
2026-03-18 23:45                                             ` [PATCH v8 4/5] perf callchain: Refactor callchain option parsing Ian Rogers
2026-03-18 23:46                                             ` [PATCH v8 5/5] perf evlist: Improve default event for s390 Ian Rogers
2026-03-19  7:53                                               ` Thomas Richter
2026-03-19  5:39                                             ` [PATCH v8 0/5] perf evsel fallback changes, better s390 defaults Ian Rogers
2026-03-19  8:02                                               ` Thomas Richter
2026-03-20 18:12                                             ` Namhyung Kim

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260313202811.2599195-4-irogers@google.com \
    --to=irogers@google.com \
    --cc=acme@kernel.org \
    --cc=agordeev@linux.ibm.com \
    --cc=gor@linux.ibm.com \
    --cc=hca@linux.ibm.com \
    --cc=japo@linux.ibm.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-perf-users@vger.kernel.org \
    --cc=linux-s390@vger.kernel.org \
    --cc=namhyung@kernel.org \
    --cc=sumanthk@linux.ibm.com \
    --cc=tmricht@linux.ibm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.