From: David Laight <david.laight.linux@gmail.com>
To: Thomas Richter <tmricht@linux.ibm.com>
Cc: linux-kernel@vger.kernel.org, linux-s390@vger.kernel.org,
linux-perf-users@vger.kernel.org, acme@kernel.org,
namhyung@kernel.org, irogers@google.com, agordeev@linux.ibm.com,
gor@linux.ibm.com, sumanthk@linux.ibm.com, hca@linux.ibm.com
Subject: Re: [PATCH] perf test: Fix perf test 11 hwmon endianess issue
Date: Sat, 1 Feb 2025 11:34:06 +0000 [thread overview]
Message-ID: <20250201113406.4312a601@pumpkin> (raw)
In-Reply-To: <20250131112400.568975-1-tmricht@linux.ibm.com>
On Fri, 31 Jan 2025 12:24:00 +0100
Thomas Richter <tmricht@linux.ibm.com> wrote:
> perf test 11 hwmon fails on s390 with this error
>
> # ./perf test -Fv 11
> --- start ---
> ---- end ----
> 11.1: Basic parsing test : Ok
> --- start ---
> Testing 'temp_test_hwmon_event1'
> Using CPUID IBM,3931,704,A01,3.7,002f
> temp_test_hwmon_event1 -> hwmon_a_test_hwmon_pmu/temp_test_hwmon_event1/
> FAILED tests/hwmon_pmu.c:189 Unexpected config for
> 'temp_test_hwmon_event1', 292470092988416 != 655361
> ---- end ----
> 11.2: Parsing without PMU name : FAILED!
> --- start ---
> Testing 'hwmon_a_test_hwmon_pmu/temp_test_hwmon_event1/'
> FAILED tests/hwmon_pmu.c:189 Unexpected config for
> 'hwmon_a_test_hwmon_pmu/temp_test_hwmon_event1/',
> 292470092988416 != 655361
> ---- end ----
> 11.3: Parsing with PMU name : FAILED!
> #
>
> The root cause is in member test_event::config which is initialized
> to 0xA0001 or 655361. During event parsing a long list event parsing
> functions are called and end up with this gdb call stack:
...
> However member key::type_and_num is defined as union and bit field:
>
> union hwmon_pmu_event_key {
> long type_and_num;
> struct {
> int num :16;
> enum hwmon_type type :8;
> };
> };
That is entirely horrid.
I'm surprised this even compiles:
static size_t hwmon_pmu__event_hashmap_hash(long key, void *ctx __maybe_unused)
{
return ((union hwmon_pmu_event_key)key).type_and_num;
}
It has to be just 'return key', but I'm not sure what the hashmap code is doing.
AFAICT the code is just trying to generate a value for the hashmap to hash on?
Why not just use (type << 16 | num) instead of 'trying to be clever' with a union?
David
next prev parent reply other threads:[~2025-02-01 11:34 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-01-31 11:24 [PATCH] perf test: Fix perf test 11 hwmon endianess issue Thomas Richter
2025-02-01 7:00 ` Ian Rogers
2025-02-01 11:34 ` David Laight [this message]
2025-02-01 16:12 ` Ian Rogers
2025-02-01 17:14 ` David Laight
2025-02-02 6:48 ` Ian Rogers
2025-02-04 3:35 ` Namhyung Kim
2025-02-05 18:39 ` Namhyung Kim
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=20250201113406.4312a601@pumpkin \
--to=david.laight.linux@gmail.com \
--cc=acme@kernel.org \
--cc=agordeev@linux.ibm.com \
--cc=gor@linux.ibm.com \
--cc=hca@linux.ibm.com \
--cc=irogers@google.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-perf-users@vger.kernel.org \
--cc=linux-s390@vger.kernel.org \
--cc=namhyung@kernel.org \
--cc=sumanthk@linux.ibm.com \
--cc=tmricht@linux.ibm.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;
as well as URLs for NNTP newsgroup(s).