linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/1] perf tools: fix format max value calculation
@ 2016-03-30 19:16 kan.liang
  2016-03-31 14:49 ` Arnaldo Carvalho de Melo
  2016-04-06  7:09 ` [tip:perf/core] perf tools: Fix PMU term " tip-bot for Kan Liang
  0 siblings, 2 replies; 3+ messages in thread
From: kan.liang @ 2016-03-30 19:16 UTC (permalink / raw)
  To: acme; +Cc: jolsa, ak, alexander.shishkin, linux-kernel, Kan Liang

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

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

* Re: [PATCH 1/1] perf tools: fix format max value calculation
  2016-03-30 19:16 [PATCH 1/1] perf tools: fix format max value calculation kan.liang
@ 2016-03-31 14:49 ` Arnaldo Carvalho de Melo
  2016-04-06  7:09 ` [tip:perf/core] perf tools: Fix PMU term " tip-bot for Kan Liang
  1 sibling, 0 replies; 3+ messages in thread
From: Arnaldo Carvalho de Melo @ 2016-03-31 14:49 UTC (permalink / raw)
  To: kan.liang; +Cc: jolsa, ak, alexander.shishkin, linux-kernel

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

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

* [tip:perf/core] perf tools: Fix PMU term format max value calculation
  2016-03-30 19:16 [PATCH 1/1] perf tools: fix format max value calculation kan.liang
  2016-03-31 14:49 ` Arnaldo Carvalho de Melo
@ 2016-04-06  7:09 ` tip-bot for Kan Liang
  1 sibling, 0 replies; 3+ messages in thread
From: tip-bot for Kan Liang @ 2016-04-06  7:09 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: jolsa, tglx, hpa, mingo, acme, ak, alexander.shishkin, kan.liang,
	linux-kernel

Commit-ID:  ac0e2cd555373ae6f8f3a3ad3fbbf5b6d1e7aaaa
Gitweb:     http://git.kernel.org/tip/ac0e2cd555373ae6f8f3a3ad3fbbf5b6d1e7aaaa
Author:     Kan Liang <kan.liang@intel.com>
AuthorDate: Wed, 30 Mar 2016 12:16:15 -0700
Committer:  Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Fri, 1 Apr 2016 18:46:24 -0300

perf tools: Fix PMU term format max value calculation

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 bits to 1.

Signed-off-by: Kan Liang <kan.liang@intel.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Link: http://lkml.kernel.org/r/1459365375-14285-1-git-send-email-kan.liang@intel.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.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;
 }
 
 /*

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

end of thread, other threads:[~2016-04-06  7:09 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-03-30 19:16 [PATCH 1/1] perf tools: fix format max value calculation kan.liang
2016-03-31 14:49 ` Arnaldo Carvalho de Melo
2016-04-06  7:09 ` [tip:perf/core] perf tools: Fix PMU term " tip-bot for Kan Liang

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).