All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] Revert "perf tools: Fix PMU term format max value calculation"
@ 2018-10-03  7:20 Jiri Olsa
  2018-10-03 14:34 ` [RFC] perf tools: Wrong filter_band* values in json calculation" Jiri Olsa
                   ` (2 more replies)
  0 siblings, 3 replies; 11+ messages in thread
From: Jiri Olsa @ 2018-10-03  7:20 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo
  Cc: Andi Kleen, Kan Liang, lkml, Ingo Molnar, Namhyung Kim,
	Alexander Shishkin, Peter Zijlstra, Andi Kleen, Michael Petlan

This reverts commit ac0e2cd555373ae6f8f3a3ad3fbbf5b6d1e7aaaa.

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
  config:0-7,21

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
  ...
  ------------------------------------------------------------
  perf_event_attr:
    type                             10
    size                             112
    config                           0x200802
    sample_type                      IDENTIFIER
  ...

Cc: Andi Kleen <ak@linux.intel.com>
Cc: Kan Liang <kan.liang@intel.com>
Reported-by: Michael Petlan <mpetlan@redhat.com>
Link: http://lkml.kernel.org/n/tip-icxq7a1r66lusm3ahaimekis@git.kernel.org
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
---
 tools/perf/util/pmu.c | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)

diff --git a/tools/perf/util/pmu.c b/tools/perf/util/pmu.c
index afd68524ffa9..7799788f662f 100644
--- a/tools/perf/util/pmu.c
+++ b/tools/perf/util/pmu.c
@@ -930,13 +930,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;
 }
 
 /*
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2018-10-18  6:17 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-10-03  7:20 [PATCH] Revert "perf tools: Fix PMU term format max value calculation" Jiri Olsa
2018-10-03 14:34 ` [RFC] perf tools: Wrong filter_band* values in json calculation" Jiri Olsa
2018-10-03 14:45   ` Andi Kleen
2018-10-09 10:01     ` Jiri Olsa
2018-10-09 21:18       ` Andi Kleen
2018-10-10  8:03         ` [PATCH] perf tools: Fix wrong filter_band* values for uncore events Jiri Olsa
2018-10-10 12:58           ` Arnaldo Carvalho de Melo
2018-10-18  6:17           ` [tip:perf/urgent] perf vendor events intel: " tip-bot for Jiri Olsa
2018-10-09  9:59 ` [PATCH] Revert "perf tools: Fix PMU term format max value calculation" Jiri Olsa
2018-10-09 13:52   ` Arnaldo Carvalho de Melo
2018-10-18  6:17 ` [tip:perf/urgent] " tip-bot for Jiri Olsa

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.