From: sashiko-bot@kernel.org
To: "Sizhe Liu" <liusizhe5@huawei.com>
Cc: linux-perf-users@vger.kernel.org, linux-pci@vger.kernel.org
Subject: Re: [PATCH 09/10] perf hisi-ptt: Add field-level parsing for header DW2/DW3
Date: Thu, 04 Jun 2026 07:58:56 +0000 [thread overview]
Message-ID: <20260604075857.734541F00893@smtp.kernel.org> (raw)
In-Reply-To: <20260604075005.2219785-10-liusizhe5@huawei.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] Host-endian-dependent C bitfields break cross-platform trace analysis on big-endian hosts.
--
commit b5a1a94b81406195d7c90b32fd8a96a3d26602c2
Author: Sizhe Liu <liusizhe5@huawei.com>
perf hisi-ptt: Add field-level parsing for header DW2/DW3
This commit adds detailed field parsing for TLP header DW2 and DW3 based on
the message type parsed from DW0. It aims to provide more structured
information for users analyzing PTT trace data.
> diff --git a/tools/perf/util/hisi-ptt-decoder/hisi-ptt-pkt-decoder.c b/tools/perf/util/hisi-ptt-decoder/hisi-ptt-pkt-decoder.c
> index 59ab8ec3a03da..46f11d5719aca 100644
> --- a/tools/perf/util/hisi-ptt-decoder/hisi-ptt-pkt-decoder.c
> +++ b/tools/perf/util/hisi-ptt-decoder/hisi-ptt-pkt-decoder.c
> @@ -127,6 +142,45 @@ union hisi_ptt_field_data {
> uint32_t type : 5;
> uint32_t format : 3;
> } dw0_8dw;
> + /*
> + * Header DW2 for MWr/Msg/MsgD/FetchAdd/Swap/CAS/IORd/IOWr TLPs.
> + * Affects both 4DW and 8DW format.
> + */
> + struct {
> + uint32_t header_dw2 : 16;
> + uint32_t tag : 4;
> + uint32_t t : 1;
> + uint32_t tv : 1;
> + uint32_t rsv : 1;
> + uint32_t request_segment : 8;
> + uint32_t reserved : 1;
> + } dw2_mixed;
[Severity: Medium]
Does using C bitfields here create an issue for big-endian hosts?
While le32_to_cpu() correctly handles the byte order of the raw integer,
the layout of C bitfields is implementation-defined. On big-endian systems,
won't the compiler pack these fields starting from the most significant
bit instead of the least significant bit?
> + /*
> + * Header DW3 for CfgRd0/CfgWr0/CfgRd1/CfgWr1 TLPs.
> + * Affects both 4DW and 8DW format.
> + */
[ ... ]
> @@ -211,6 +265,85 @@ static void hisi_ptt_print_head0(struct hisi_ptt_pkt_buf *pkt_buf)
[ ... ]
> +static void hisi_ptt_print_head2(struct hisi_ptt_pkt_buf *pkt_buf)
> +{
> + const char *color = PERF_COLOR_BLUE;
> + union hisi_ptt_field_data dw;
> +
> + dw.value = le32_to_cpu(*(__le32 *)(pkt_buf->buf + pkt_buf->pos));
> + hisi_ptt_print_raw_record(pkt_buf->pos, dw.value);
> +
> + if (pkt_buf->pkt_msg_type == HISI_PTT_PKT_TYPE_MWR ||
> + pkt_buf->pkt_msg_type == HISI_PTT_PKT_TYPE_MSG ||
> + pkt_buf->pkt_msg_type == HISI_PTT_PKT_TYPE_ATOM ||
> + pkt_buf->pkt_msg_type == HISI_PTT_PKT_TYPE_IO)
> + color_fprintf(stdout, color,
> + " %s %x %s %x %s %x %s %x %s %x %s %x %s %x\n",
> + "Reserved", dw.dw2_mixed.reserved,
> + "Request Segment", dw.dw2_mixed.request_segment,
[Severity: Medium]
Will this result in extracting entirely incorrect bits when a big-endian
host processes an ARM perf.data trace file?
Since perf tools are expected to support cross-platform trace analysis,
could we use bitwise operations instead of C bitfields to ensure the fields
are reliably extracted regardless of the host architecture's endianness?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260604075005.2219785-1-liusizhe5@huawei.com?part=9
next prev parent reply other threads:[~2026-06-04 7:58 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-04 7:49 [PATCH 00/10] perf hisi-ptt: Enhance TLP packet decoder with field-level parsing and versioning Sizhe Liu
2026-06-04 7:49 ` [PATCH 01/10] perf hisi-ptt: Fix spelling and abbreviation errors Sizhe Liu
2026-06-04 7:49 ` [PATCH 02/10] perf hisi-ptt: Fix PTT trace TLP Header parsing Sizhe Liu
2026-06-04 7:59 ` sashiko-bot
2026-06-04 7:49 ` [PATCH 03/10] perf hisi-ptt: Rename hisi_ptt_4dw union for reuse Sizhe Liu
2026-06-04 7:49 ` [PATCH 04/10] perf hisi-ptt: Abstract trace data buf and offset Sizhe Liu
2026-06-04 7:50 ` [PATCH 05/10] perf hisi-ptt: Complete the field names for 4DW and 8DW packets Sizhe Liu
2026-06-04 7:50 ` [PATCH 06/10] perf hisi-ptt: Extract the raw data printing part Sizhe Liu
2026-06-04 7:50 ` [PATCH 07/10] perf hisi-ptt: Merge 4DW and 8DW HEAD0 printing Sizhe Liu
2026-06-04 7:50 ` [PATCH 08/10] perf hisi-ptt: Add parsing of supported message types Sizhe Liu
2026-06-04 8:01 ` sashiko-bot
2026-06-04 7:50 ` [PATCH 09/10] perf hisi-ptt: Add field-level parsing for header DW2/DW3 Sizhe Liu
2026-06-04 7:58 ` sashiko-bot [this message]
2026-06-04 7:50 ` [PATCH 10/10] perf hisi-ptt: Add decoder version compatibility Sizhe Liu
2026-06-04 8:03 ` sashiko-bot
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=20260604075857.734541F00893@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=linux-pci@vger.kernel.org \
--cc=linux-perf-users@vger.kernel.org \
--cc=liusizhe5@huawei.com \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox