From nobody Mon Apr 6 17:26:11 2026 Received: from mail-dl1-f73.google.com (mail-dl1-f73.google.com [74.125.82.73]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B2187393DF7 for ; Wed, 18 Mar 2026 23:46:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=74.125.82.73 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773877577; cv=none; b=Gu56O/tIwA4TU+xbmyttZBRUCy91fR9UG1E//zuDKUg6Y5Pt3wzy0W1g78dAiLxuhTGqlFEgEhlFWcZChNTP+D3uO/fpw0N//02ywWTQpqR6asjVhYMqz1CiHip5wS45gi+QOHK2wEMS4A22qc+sqrVgqOwfIRR5dGGiXxB/rgA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773877577; c=relaxed/simple; bh=hWlHUlY1KBEUso+82QhexCptJkL/cgS7z0Uij0nS5pg=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=u+/Po6X64RUidF2lof79vqIub7RWFWBizXewoPg3nswW0izGUU8cMAGhMhXq/zBiLet94B0UxxhzB2Mz0Nn1Rvth1sTNJcMjD/yKngSWTMOp9H/+ULPK77YbP0sh3/Mak73AcNfalgOo+XW5H93ILVOARKKiWR5iBNvPp+A/noI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--irogers.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=CrPe8RqG; arc=none smtp.client-ip=74.125.82.73 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--irogers.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="CrPe8RqG" Received: by mail-dl1-f73.google.com with SMTP id a92af1059eb24-128d285d6c3so410818c88.1 for ; Wed, 18 Mar 2026 16:46:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1773877574; x=1774482374; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=nMY8e2nXchz3cJrJ3A0a9fKJa//sBNfOk9+ZFibdgVs=; b=CrPe8RqGQjz0fHvMyzBYex/mYXEl5TtIbiTc8BrrR/OavjP850DLgDTeKc/Cneeq2L 3zfKOY36UVRC0cCJEznWLiiPcuG3N93+nUcMnCv8SofbVw1UGLckO+uvpUEiS12szoVn D6cywXOcG52W/2T2aOIsrU5iDYnGcoig1zRBiTxnrg54m8tLyHEQCIQ3y9RDt3/lk4vM 4OpwyuGSlgLTE23OZ2kc0hzPH/sfSb3ycy46F0GzZGGWn4Aix8loXPLPDAusdiLCEuW1 MEw7FWBsti7o+fMpY1rE3q8P6LcW0PbiTvz25Vv1StpizWMfb3XLNb7d4MkivQsvvii7 n8Tw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1773877574; x=1774482374; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=nMY8e2nXchz3cJrJ3A0a9fKJa//sBNfOk9+ZFibdgVs=; b=qTZOV2G3+ts5Zmqu2j821bUldRX4CmRF0ouCHVg299IPEwUgf4JpmKbAuoygKgCHNn PPMIyFRQWG9w0GVA2rhOJ98tQBAqiD7HcdKVzvwF8TBX8swuzONGfg5Jyhf1QPww9GJ7 heD6CTh/NmVUyleG6eob6h4EI/irvzy81zX4kpZ1LkcY+poo8R76k6YkU0gqznfhQvx0 OxHR59s3q2VOH2t994NSHSHo9fuSQPb2TsVoH7f/q/G1Tb/0v92XzHLkFxE6nKKbeXyX bd0hztxbeR8YJUcll5ZFu+ObjuB1J0/J1nrF+eist2MdjxDo5feyfEzSy3XYCBPgPYy3 999g== X-Forwarded-Encrypted: i=1; AJvYcCXdc+nm8mde9efElbV4CjGdhxTChxKgkauzD+7VfoomVsfE908/xe2qntQGFglEH/W5P7YObt65mDHzkMY=@vger.kernel.org X-Gm-Message-State: AOJu0YzVwNbrI1UFwfQnmOfqI86ZEbDIF7Vzrv4NqcNfeCm0eKG3fPdp 7RiqrE4IX+aZKOBMgid0SQxMGO2O2Wlf4Ud+6y0peRYKoskcrpBNKj3+peQQXM/trj9vjWJnVNx rCGHX4Kvnog== X-Received: from dlbur23.prod.google.com ([2002:a05:7022:ea57:b0:128:cd31:49b]) (user=irogers job=prod-delivery.src-stubby-dispatcher) by 2002:a05:701b:420a:20b0:12a:6a64:81f1 with SMTP id a92af1059eb24-12a6a648484mr155494c88.5.1773877573748; Wed, 18 Mar 2026 16:46:13 -0700 (PDT) Date: Wed, 18 Mar 2026 16:46:00 -0700 In-Reply-To: <20260318234600.730340-1-irogers@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20260318175808.582009-1-irogers@google.com> <20260318234600.730340-1-irogers@google.com> X-Mailer: git-send-email 2.53.0.851.ga537e3e6e9-goog Message-ID: <20260318234600.730340-6-irogers@google.com> Subject: [PATCH v8 5/5] perf evlist: Improve default event for s390 From: Ian Rogers To: acme@kernel.org, namhyung@kernel.org, tmricht@linux.ibm.com Cc: irogers@google.com, 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, sumanthk@linux.ibm.com Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Frame pointer callchains are not supported on s390 and dwarf callchains are only supported on software events. Switch the default event from the hardware 'cycles' event to the software 'cpu-clock' or 'task-clock' on s390 if callchains are enabled. Move some of the target initialization earlier in builtin-top and builtin-record, so it is ready for use by evlist__new_default. If frame pointer callchains are requested on s390 show a warning. Modify the '-g' option of `perf top` and `perf record` to default to dwarf callchains on s390. Signed-off-by: Ian Rogers Tested-by: Thomas Richter --- tools/perf/builtin-record.c | 18 +++++++++++------- tools/perf/builtin-top.c | 23 ++++++++++++----------- 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 | 32 +++++++++++++++++++++----------- tools/perf/util/evlist.h | 2 +- tools/perf/util/evsel.c | 5 +++++ 9 files changed, 64 insertions(+), 35 deletions(-) diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c index 59b8125d1b13..3276ffdc3141 100644 --- a/tools/perf/builtin-record.c +++ b/tools/perf/builtin-record.c @@ -55,6 +55,7 @@ #include "asm/bug.h" #include "perf.h" #include "cputopo.h" +#include "dwarf-regs.h" =20 #include #include @@ -2995,7 +2996,9 @@ static int record_callchain_opt(const struct option *= opt, return 0; } =20 - return record_opts__parse_callchain(opt->value, &callchain_param, "fp", u= nset); + return record_opts__parse_callchain(opt->value, &callchain_param, + EM_HOST !=3D EM_S390 ? "fp" : "dwarf", + unset); } =20 =20 @@ -4095,8 +4098,11 @@ int cmd_record(int argc, const char **argv) =20 perf_debuginfod_setup(&record.debuginfod); =20 - /* Make system wide (-a) the default target. */ - if (!argc && target__none(&rec->opts.target)) + /* + * Use system wide (-a) for the default target (ie. when no + * workload). User ID filtering also implies system-wide. + */ + if ((!argc && target__none(&rec->opts.target)) || rec->uid_str) rec->opts.target.system_wide =3D true; =20 if (nr_cgroups && !rec->opts.target.system_wide) { @@ -4274,7 +4280,8 @@ int cmd_record(int argc, const char **argv) record.opts.tail_synthesize =3D true; =20 if (rec->evlist->core.nr_entries =3D=3D 0) { - struct evlist *def_evlist =3D evlist__new_default(); + struct evlist *def_evlist =3D evlist__new_default(&rec->opts.target, + callchain_param.enabled); =20 if (!def_evlist) goto out; @@ -4303,9 +4310,6 @@ int cmd_record(int argc, const char **argv) err =3D parse_uid_filter(rec->evlist, uid); if (err) goto out; - - /* User ID filtering implies system wide. */ - rec->opts.target.system_wide =3D true; } =20 /* Enable ignoring missing threads when -p option is defined. */ diff --git a/tools/perf/builtin-top.c b/tools/perf/builtin-top.c index b6726f4dffb3..37950efb28ac 100644 --- a/tools/perf/builtin-top.c +++ b/tools/perf/builtin-top.c @@ -56,6 +56,7 @@ #include "util/debug.h" #include "util/ordered-events.h" #include "util/pfm.h" +#include "dwarf-regs.h" =20 #include #include @@ -1420,7 +1421,7 @@ callchain_opt(const struct option *opt, const char *a= rg __maybe_unused, int unse return 0; } =20 - return parse_callchain_opt(opt, "fp", unset); + return parse_callchain_opt(opt, EM_HOST !=3D EM_S390 ? "fp" : "dwarf", un= set); } =20 =20 @@ -1705,8 +1706,17 @@ int cmd_top(int argc, const char **argv) if (annotate_check_args() < 0) goto out_delete_evlist; =20 + status =3D target__validate(target); + if (status) { + target__strerror(target, status, errbuf, BUFSIZ); + ui__warning("%s\n", errbuf); + } + + if (target__none(target)) + target->system_wide =3D true; + if (!top.evlist->core.nr_entries) { - struct evlist *def_evlist =3D evlist__new_default(); + struct evlist *def_evlist =3D evlist__new_default(target, callchain_para= m.enabled); =20 if (!def_evlist) goto out_delete_evlist; @@ -1799,12 +1809,6 @@ int cmd_top(int argc, const char **argv) goto out_delete_evlist; } =20 - status =3D target__validate(target); - if (status) { - target__strerror(target, status, errbuf, BUFSIZ); - ui__warning("%s\n", errbuf); - } - if (top.uid_str) { uid_t uid =3D parse_uid(top.uid_str); =20 @@ -1818,9 +1822,6 @@ int cmd_top(int argc, const char **argv) goto out_delete_evlist; } =20 - if (target__none(target)) - target->system_wide =3D true; - if (evlist__create_maps(top.evlist, target) < 0) { ui__error("Couldn't create thread/CPU maps: %s\n", errno =3D=3D ENOENT ? "No such process" : str_error_r(errno, errbuf, = sizeof(errbuf))); diff --git a/tools/perf/tests/event_update.c b/tools/perf/tests/event_updat= e.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 __m= aybe_unused, int subtes { struct evsel *evsel; struct event_name tmp; - struct evlist *evlist =3D evlist__new_default(); + struct target target =3D {}; + struct evlist *evlist =3D evlist__new_default(&target, /*sample_callchain= s=3D*/false); =20 TEST_ASSERT_VAL("failed to get evlist", evlist); =20 diff --git a/tools/perf/tests/expand-cgroup.c b/tools/perf/tests/expand-cgr= oup.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 #include #include @@ -99,7 +100,8 @@ out: for (i =3D 0; i < nr_events; i++) static int expand_default_events(void) { int ret; - struct evlist *evlist =3D evlist__new_default(); + struct target target =3D {}; + struct evlist *evlist =3D evlist__new_default(&target, /*sample_callchain= s=3D*/false); =20 TEST_ASSERT_VAL("failed to get evlist", evlist); =20 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 __m= aybe_unused, int subtest CPU_ZERO_S(cpu_mask_size, cpu_mask); =20 perf_sample__init(&sample, /*all=3D*/false); - if (evlist =3D=3D NULL) /* Fallback for kernels lacking PERF_COUNT_SW_DUM= MY */ - evlist =3D evlist__new_default(); + if (evlist =3D=3D NULL) { /* Fallback for kernels lacking PERF_COUNT_SW_D= UMMY */ + struct target target =3D {}; + + evlist =3D evlist__new_default(&target, /*sample_callchains=3D*/false); + } =20 if (evlist =3D=3D 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 =20 #define TEMPL "/tmp/perf-test-XXXXXX" @@ -37,11 +38,12 @@ static int session_write_header(char *path) .path =3D path, .mode =3D PERF_DATA_MODE_WRITE, }; + struct target target =3D {}; =20 session =3D perf_session__new(&data, NULL); TEST_ASSERT_VAL("can't get session", !IS_ERR(session)); =20 - session->evlist =3D evlist__new_default(); + session->evlist =3D evlist__new_default(&target, /*sample_callchains=3D*/= false); TEST_ASSERT_VAL("can't get evlist", session->evlist); session->evlist->session =3D session; =20 diff --git a/tools/perf/util/evlist.c b/tools/perf/util/evlist.c index 591bdf0b3e2a..c702741a9173 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,47 @@ struct evlist *evlist__new(void) return evlist; } =20 -struct evlist *evlist__new_default(void) +struct evlist *evlist__new_default(const struct target *target, bool sampl= e_callchains) { struct evlist *evlist =3D evlist__new(); bool can_profile_kernel; struct perf_pmu *pmu =3D NULL; + struct evsel *evsel; + char buf[256]; + int err; =20 if (!evlist) return NULL; =20 can_profile_kernel =3D perf_event_paranoid_check(1); =20 - while ((pmu =3D perf_pmus__scan_core(pmu)) !=3D NULL) { - char buf[256]; - int err; - - snprintf(buf, sizeof(buf), "%s/cycles/%s", pmu->name, + if (EM_HOST =3D=3D 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 =3D parse_event(evlist, buf); - if (err) { - evlist__delete(evlist); - return NULL; + if (err) + goto out_err; + } else { + while ((pmu =3D perf_pmus__scan_core(pmu)) !=3D NULL) { + snprintf(buf, sizeof(buf), "%s/cycles/%s", pmu->name, + can_profile_kernel ? "P" : "Pu"); + err =3D parse_event(evlist, buf); + if (err) + goto out_err; } } =20 + /* If there is only 1 event a sample identifier isn't necessary. */ if (evlist->core.nr_entries > 1) { - struct evsel *evsel; - evlist__for_each_entry(evlist, evsel) evsel__set_sample_id(evsel, /*can_sample_identifier=3D*/false); } =20 return evlist; +out_err: + evlist__delete(evlist); + return NULL; } =20 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 { }; =20 struct evlist *evlist__new(void); -struct evlist *evlist__new_default(void); +struct evlist *evlist__new_default(const struct target *target, bool sampl= e_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 54c8922a8e47..5a294595a677 100644 --- a/tools/perf/util/evsel.c +++ b/tools/perf/util/evsel.c @@ -1021,6 +1021,11 @@ static void __evsel__config_callchain(struct evsel *= evsel, const struct record_o bool function =3D evsel__is_function_event(evsel); struct perf_event_attr *attr =3D &evsel->core.attr; =20 + if (EM_HOST =3D=3D EM_S390 && param->record_mode =3D=3D CALLCHAIN_FP) { + pr_warning_once( + "Framepointer unwinding lacks kernel support. Use '--call-graph dwarf'\= n"); + } + evsel__set_sample_bit(evsel, CALLCHAIN); =20 attr->sample_max_stack =3D param->max_stack; --=20 2.53.0.851.ga537e3e6e9-goog