Commit 9527bd32 authored by Jiri Olsa's avatar Jiri Olsa Committed by Greg Kroah-Hartman

Revert "perf tools: Fix PMU term format max value calculation"

[ Upstream commit 1b9caa10b31dda0866f4028e4bfb923fb6e4072f ]

This reverts commit ac0e2cd5.

Michael reported an issue with oversized terms values assignment
and I noticed there was actually a misunderstanding of the max
value check in the past.

The above commit's changelog says:

  If bit 21 is set, there is parsing issues as below.

    $ perf stat -a -e uncore_qpi_0/event=0x200002,umask=0x8/
    event syntax error: '..pi_0/event=0x200002,umask=0x8/'
                                      \___ value too big for format, maximum is 511

But there's no issue there, because the event value is distributed
along the value defined by the format. Even if the format defines
separated bit, the value is treated as a continual number, which
should follow the format definition.

In above case it's 9-bit value with last bit separated:
  $ cat uncore_qpi_0/format/event

Hence the value 0x200002 is correctly reported as format violation,
because it exceeds 9 bits. It should have been 0x102 instead, which
sets the 9th bit - the bit 21 of the format.

  $ perf stat -vv -a -e uncore_qpi_0/event=0x102,umask=0x8/
  Using CPUID GenuineIntel-6-2D
    type                             10
    size                             112
    config                           0x200802
    sample_type                      IDENTIFIER
Reported-by: default avatarMichael Petlan <>
Signed-off-by: default avatarJiri Olsa <>
Cc: Alexander Shishkin <>
Cc: Andi Kleen <>
Cc: Kan Liang <>
Cc: Namhyung Kim <>
Cc: Peter Zijlstra <>
Fixes: ac0e2cd5 ("perf tools: Fix PMU term format max value calculation")
Link: default avatarArnaldo Carvalho de Melo <>
Signed-off-by: default avatarSasha Levin <>
Signed-off-by: default avatarGreg Kroah-Hartman <>
parent f6bded89
......@@ -685,13 +685,14 @@ static void pmu_format_value(unsigned long *format, __u64 value, __u64 *v,
static __u64 pmu_format_max_value(const unsigned long *format)
__u64 w = 0;
int fbit;
for_each_set_bit(fbit, format, PERF_PMU_FORMAT_BITS)
w |= (1ULL << fbit);
int w;
return w;
w = bitmap_weight(format, PERF_PMU_FORMAT_BITS);
if (!w)
return 0;
if (w < 64)
return (1ULL << w) - 1;
return -1;
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment