Re: [PATCH v2 6/6] perf arm_spe: Print remaining IMPDEF event numbers

From: Leo Yan

Date: Mon Apr 13 2026 - 05:54:17 EST


Hi Jie,

On Sat, Apr 11, 2026 at 09:08:18AM +0800, Jie Gan wrote:

[...]

> > + /*
> > + * Print remaining IMPDEF bits that weren't printed above as raw
> > + * "IMPDEF:1,2,3,4" etc.
> > + */
> > + if (payload) {
> > + int i;
> > +
> > + arm_spe_pkt_out_string(&err, &buf, &buf_len, " IMPDEF:");
> > + for_each_set_bit(i, &payload, 64) {
>
> for_each_set_bit(i, &payload, 64) passes &payload where payload is u64. The
> macro expands to find_next_bit(const unsigned long *addr, ...). On a 32-bit
> host unsigned long is 32 bits wide, so only the low 32 bits of payload would
> be scanned; bits 32–63 would be silently ignored.

I think this is incorrect.

Even though unsigned long / long is 32 bits on 32-bit CPU, this should
be handled by the BITS_PER_LONG macro. The FIND_NEXT_BIT() macro can
fetch consecutive long values when the size > BITS_PER_LONG.

> While perf is almost
> always built on a 64-bit host today, the tools/ tree is explicitly portable
> and the compiler will emit a -Wpointer-arith / -Wincompatible-pointer-types
> warning on a 32-bit build.

I agree we should fix building issue on 32-bit target.

Thanks,
Leo