[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20250201113406.4312a601@pumpkin>
Date: Sat, 1 Feb 2025 11:34:06 +0000
From: David Laight <david.laight.linux@...il.com>
To: Thomas Richter <tmricht@...ux.ibm.com>
Cc: linux-kernel@...r.kernel.org, linux-s390@...r.kernel.org,
linux-perf-users@...r.kernel.org, acme@...nel.org, namhyung@...nel.org,
irogers@...gle.com, agordeev@...ux.ibm.com, gor@...ux.ibm.com,
sumanthk@...ux.ibm.com, hca@...ux.ibm.com
Subject: Re: [PATCH] perf test: Fix perf test 11 hwmon endianess issue
On Fri, 31 Jan 2025 12:24:00 +0100
Thomas Richter <tmricht@...ux.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
Powered by blists - more mailing lists