From: Dapeng Mi <dapeng1.mi@linux.intel.com>
To: Peter Zijlstra <peterz@infradead.org>,
Ingo Molnar <mingo@redhat.com>,
Arnaldo Carvalho de Melo <acme@kernel.org>,
Namhyung Kim <namhyung@kernel.org>,
Ian Rogers <irogers@google.com>,
Adrian Hunter <adrian.hunter@intel.com>,
Alexander Shishkin <alexander.shishkin@linux.intel.com>,
John Garry <john.g.garry@oracle.com>,
Will Deacon <will@kernel.org>,
James Clark <james.clark@linaro.org>,
Mike Leach <mike.leach@linaro.org>, Guo Ren <guoren@kernel.org>,
Paul Walmsley <pjw@kernel.org>,
Palmer Dabbelt <palmer@dabbelt.com>,
Albert Ou <aou@eecs.berkeley.edu>,
Alexandre Ghiti <alex@ghiti.fr>
Cc: linux-perf-users@vger.kernel.org,
linux-arm-kernel@lists.infradead.org, linux-csky@vger.kernel.org,
linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org,
Zide Chen <zide.chen@intel.com>,
Falcon Thomas <thomas.falcon@intel.com>,
Dapeng Mi <dapeng1.mi@intel.com>,
Xudong Hao <xudong.hao@intel.com>,
Dapeng Mi <dapeng1.mi@linux.intel.com>
Subject: [Patch v3 1/4] perf regs: Fix abort for "-I" or "--user-regs" options
Date: Tue, 3 Feb 2026 10:43:53 +0800 [thread overview]
Message-ID: <20260203024356.444942-2-dapeng1.mi@linux.intel.com> (raw)
In-Reply-To: <20260203024356.444942-1-dapeng1.mi@linux.intel.com>
Fix an issue where the `perf` tool aborts unexpectedly when running the
following command:
```
perf record -e cycles -I -- true
Usage: perf record [<options>] [<command>]
or: perf record [<options>] -- <command> [<options>]
-I, --intr-regs[=<any register>]
sample selected machine registers on interrupt, use '-I?' to list register names
```
The usage of the `-I` or `--user-regs` options without specifying any
registers should default to sampling all general-purpose registers.
However, this currently causes an abnormal termination.
The issue was introduced by commit 3d06db9bad1a ("perf regs: Refactor
use of arch__sample_reg_masks() to perf_reg_name()"). This patch
resolves the problem, ensuring that the `-I` or `--user-regs` options
work as intended without causing an abort.
Fixes: 3d06db9bad1a ("perf regs: Refactor use of arch__sample_reg_masks() to perf_reg_name()")
Signed-off-by: Dapeng Mi <dapeng1.mi@linux.intel.com>
---
tools/perf/util/parse-regs-options.c | 13 ++++++-------
1 file changed, 6 insertions(+), 7 deletions(-)
diff --git a/tools/perf/util/parse-regs-options.c b/tools/perf/util/parse-regs-options.c
index 8dd35f50f644..b44b47d9059f 100644
--- a/tools/perf/util/parse-regs-options.c
+++ b/tools/perf/util/parse-regs-options.c
@@ -66,12 +66,14 @@ __parse_regs(const struct option *opt, const char *str, int unset, bool intr)
if (*mode)
return -1;
- /* str may be NULL in case no arg is passed to -I */
- if (!str)
- return -1;
-
mask = intr ? arch__intr_reg_mask() : arch__user_reg_mask();
+ /* str may be NULL in case no arg is passed to -I */
+ if (!str) {
+ *mode = mask;
+ return 0;
+ }
+
/* because str is read-only */
s = os = strdup(str);
if (!s)
@@ -104,9 +106,6 @@ __parse_regs(const struct option *opt, const char *str, int unset, bool intr)
}
ret = 0;
- /* default to all possible regs */
- if (*mode == 0)
- *mode = mask;
error:
free(os);
return ret;
--
2.34.1
next prev parent reply other threads:[~2026-02-03 2:47 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-02-03 2:43 [Patch v3 0/4] Perf tools: perf-regs bug fix and optimization Dapeng Mi
2026-02-03 2:43 ` Dapeng Mi [this message]
2026-02-03 23:06 ` [Patch v3 1/4] perf regs: Fix abort for "-I" or "--user-regs" options Ian Rogers
2026-02-03 2:43 ` [Patch v3 2/4] perf arch: Update arch headers to use relative UAPI paths Dapeng Mi
2026-02-03 2:43 ` [Patch v3 3/4] perf regs: Remove __weak attributive arch__xxx_reg_mask() functions Dapeng Mi
2026-02-03 23:08 ` Ian Rogers
2026-02-03 2:43 ` [Patch v3 4/4] perf regs: Remove __weak attributive arch_sdt_arg_parse_op() function Dapeng Mi
2026-02-03 23:11 ` Ian Rogers
2026-02-06 15:17 ` [Patch v3 0/4] Perf tools: perf-regs bug fix and optimization Arnaldo Carvalho de Melo
2026-02-09 0:46 ` Mi, Dapeng
2026-03-24 6:07 ` patchwork-bot+linux-riscv
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=20260203024356.444942-2-dapeng1.mi@linux.intel.com \
--to=dapeng1.mi@linux.intel.com \
--cc=acme@kernel.org \
--cc=adrian.hunter@intel.com \
--cc=alex@ghiti.fr \
--cc=alexander.shishkin@linux.intel.com \
--cc=aou@eecs.berkeley.edu \
--cc=dapeng1.mi@intel.com \
--cc=guoren@kernel.org \
--cc=irogers@google.com \
--cc=james.clark@linaro.org \
--cc=john.g.garry@oracle.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-csky@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-perf-users@vger.kernel.org \
--cc=linux-riscv@lists.infradead.org \
--cc=mike.leach@linaro.org \
--cc=mingo@redhat.com \
--cc=namhyung@kernel.org \
--cc=palmer@dabbelt.com \
--cc=peterz@infradead.org \
--cc=pjw@kernel.org \
--cc=thomas.falcon@intel.com \
--cc=will@kernel.org \
--cc=xudong.hao@intel.com \
--cc=zide.chen@intel.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox