Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1367769 > unrolled thread

[PATCH 1/1] perf tools: fix format max value calculation

Started bykan.liang@intel.com
First post2016-03-31 04:50 +0200
Last post2016-03-31 17:00 +0200
Articles 2 — 2 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH 1/1] perf tools: fix format max value calculation kan.liang@intel.com - 2016-03-31 04:50 +0200
    Re: [PATCH 1/1] perf tools: fix format max value calculation Arnaldo Carvalho de Melo <acme@kernel.org> - 2016-03-31 17:00 +0200

#1367769 — [PATCH 1/1] perf tools: fix format max value calculation

Fromkan.liang@intel.com
Date2016-03-31 04:50 +0200
Subject[PATCH 1/1] perf tools: fix format max value calculation
Message-ID<riAQi-6yy-19@gated-at.bofh.it>
From: Kan Liang <kan.liang@intel.com>

Currently the max value of format is calculated by the bits number. It
relies on the continuity of the format.
However, uncore event format is not continuous. E.g. uncore qpi event
format can be 0-7,21.
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

This patch return the real max value by setting all possible bit to 1.

Signed-off-by: Kan Liang <kan.liang@intel.com>
---
 tools/perf/util/pmu.c | 13 ++++++-------
 1 file changed, 6 insertions(+), 7 deletions(-)

diff --git a/tools/perf/util/pmu.c b/tools/perf/util/pmu.c
index adef23b..bf34468 100644
--- a/tools/perf/util/pmu.c
+++ b/tools/perf/util/pmu.c
@@ -602,14 +602,13 @@ static void pmu_format_value(unsigned long *format, __u64 value, __u64 *v,
 
 static __u64 pmu_format_max_value(const unsigned long *format)
 {
-	int w;
+	__u64 w = 0;
+	int fbit;
 
-	w = bitmap_weight(format, PERF_PMU_FORMAT_BITS);
-	if (!w)
-		return 0;
-	if (w < 64)
-		return (1ULL << w) - 1;
-	return -1;
+	for_each_set_bit(fbit, format, PERF_PMU_FORMAT_BITS)
+		w |= (1ULL << fbit);
+
+	return w;
 }
 
 /*
-- 
2.5.0

[toc] | [next] | [standalone]


#1368378

FromArnaldo Carvalho de Melo <acme@kernel.org>
Date2016-03-31 17:00 +0200
Message-ID<riMeK-6A1-17@gated-at.bofh.it>
In reply to#1367769
Em Wed, Mar 30, 2016 at 12:16:15PM -0700, kan.liang@intel.com escreveu:
> From: Kan Liang <kan.liang@intel.com>
> 
> Currently the max value of format is calculated by the bits number. It
> relies on the continuity of the format.
> However, uncore event format is not continuous. E.g. uncore qpi event
> format can be 0-7,21.
> 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
> 
> This patch return the real max value by setting all possible bit to 1.

Looks good, applied.

- Arnaldo

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web