From: sashiko-bot@kernel.org
To: "Aaron Tomlin" <atomlin@atomlin.com>
Cc: linux-perf-users@vger.kernel.org
Subject: Re: [PATCH] perf trace: Add --bitmask-list option and correct cpumask formatting
Date: Tue, 14 Jul 2026 16:39:36 +0000 [thread overview]
Message-ID: <20260714163937.7109C1F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260714162947.214270-1-atomlin@atomlin.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] The cpumask byte parsing and bitmask rendering ignores the endianness and word size of the trace payload, breaking cross-platform analysis.
--
--- Patch [1]: [PATCH] perf trace: Add --bitmask-list option and correct cpumask formatting ---
commit 3ae8add0cf042fd56dee83eecdf3dd3e5eeef32c
Author: Aaron Tomlin <atomlin@atomlin.com>
perf trace: Add --bitmask-list option and correct cpumask formatting
This commit corrects the parsing of dynamic non-array fields like cpumask_t
in perf trace to resolve raw pointers properly. It also updates the display
formatting for cpumasks to show zero-suppressed hex strings by default and
adds a --bitmask-list option for human-readable bitmask formatting.
Fixes: c5e006cdbd27 ("perf trace: Support tracepoint dynamic char arrays")
> diff --git a/tools/perf/builtin-trace.c b/tools/perf/builtin-trace.c
> index ba0f8749fc7d7..cd75ac4e51693 100644
> --- a/tools/perf/builtin-trace.c
> +++ b/tools/perf/builtin-trace.c
> @@ -3238,17 +3239,65 @@ static size_t trace__fprintf_tp_fields(struct trace *trace, struct perf_sample *
[ ... ]
> + if (trace->bitmask_list) {
> + if (syscall_arg.len > 0) {
> + unsigned long *mask = zalloc(BITS_TO_LONGS(syscall_arg.len * 8) * sizeof(unsigned long));
> + if (!mask) {
> + pr_err("Problem processing %s field, skipping...\n", field->name);
> + printed = saved_printed;
> + continue;
> + }
> + memcpy(mask, (void *)val, syscall_arg.len);
> + printed += bitmap_scnprintf(mask, syscall_arg.len * 8,
> + bf + printed, size - printed);
[Severity: Medium]
Will this memcpy() and bitmask formatting break cross-platform analysis if the
perf.data file was recorded on an architecture with a different endianness or
word size than the host?
It appears we are doing a direct copy of the target payload bytes into a
host-native unsigned long array without utilizing evsel->needs_swap.
Could this result in garbled or reversed cpumask values when viewing trace
data from a machine with different architectural characteristics?
> + free(mask);
> + }
> + } else {
> + unsigned char *b = (unsigned char *)val;
> + int i;
> + bool skip_zero = true;
> +
> + printed += scnprintf(bf + printed, size - printed, "0x");
> + /* Print in little-endian order */
> + for (i = syscall_arg.len - 1; i >= 0; i--) {
[Severity: Medium]
Does this backward loop assume the trace data is unconditionally little-endian?
If the trace data comes from a big-endian architecture, will this hardcoded
assumption fail to print the values correctly?
> + if (skip_zero && b[i] == 0 && i > 0)
> + continue;
> + if (skip_zero) {
> + printed += scnprintf(bf + printed, size - printed, "%x", b[i]);
> + skip_zero = false;
> + } else {
> + printed += scnprintf(bf + printed, size - printed, "%02x", b[i]);
> + }
> + }
> + }
> + continue;
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260714162947.214270-1-atomlin@atomlin.com?part=1
next prev parent reply other threads:[~2026-07-14 16:39 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-14 16:29 [PATCH] perf trace: Add --bitmask-list option and correct cpumask formatting Aaron Tomlin
2026-07-14 16:39 ` sashiko-bot [this message]
2026-07-15 1:22 ` Aaron Tomlin
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=20260714163937.7109C1F000E9@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=atomlin@atomlin.com \
--cc=linux-perf-users@vger.kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
/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.