Skip to contentSkip to conversation

perf: Fix PMU format parsing test failure

PATCH In review Sukadev Bhattiprolu 2 participants 3 messages Jan 17, 2013 – Jan 25, 2013 perf events

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 perf: Fix PMU format parsing test failure

Quoted 2 lines

From 776e6d7942754f139c27753213c9cf4617536618 Mon Sep 17 00:00:00 2001

From: Sukadev Bhattiprolu <[email protected]>
Date: Thu, 17 Jan 2013 09:11:30 -0800
Subject: [PATCH] perf; Fix PMU format parsing test failure

On POWER, the 'perf format parsing' test always fails.

Looks like it is because memset() is being passed number of longs rather than number of bytes. It is interesting that the test always passes on my x86 box.

With this patch, the test passes on POWER and continues to pass on x86.

---
 tools/perf/util/include/linux/bitops.h |    1 +
 tools/perf/util/pmu.c                  |    2 +-
 2 files changed, 2 insertions(+), 1 deletions(-)
tools/perf/util/include/linux/bitops.h +1 -0
index a55d8cf..45cf10a 100644
@@ -14,6 +14,7 @@
 #define BITS_TO_LONGS(nr)       DIV_ROUND_UP(nr, BITS_PER_BYTE * sizeof(long))
 #define BITS_TO_U64(nr)         DIV_ROUND_UP(nr, BITS_PER_BYTE * sizeof(u64))
 #define BITS_TO_U32(nr)         DIV_ROUND_UP(nr, BITS_PER_BYTE * sizeof(u32))
+#define BITS_TO_BYTES(nr)       DIV_ROUND_UP(nr, BITS_PER_BYTE)
 
 #define for_each_set_bit(bit, addr, size) \
 	for ((bit) = find_first_bit((addr), (size));		\
tools/perf/util/pmu.c +1 -1
index 9bdc60c..b93ff14 100644
@@ -548,7 +548,7 @@ void perf_pmu__set_format(unsigned long *bits, long from, long to)
 	if (!to)
 		to = from;
 
-	memset(bits, 0, BITS_TO_LONGS(PERF_PMU_FORMAT_BITS));
+	memset(bits, 0, BITS_TO_BYTES(PERF_PMU_FORMAT_BITS));
 	for (b = from; b <= to; b++)
 		set_bit(b, bits);
 }
Signature · 1 line
1.7.1
Acked-by on v1 1/1
#1 lore raw
Quoted 11 lines · Sukadev Bhattiprolu

From 776e6d7942754f139c27753213c9cf4617536618 Mon Sep 17 00:00:00 2001
From: Sukadev Bhattiprolu <[email protected]>
Date: Thu, 17 Jan 2013 09:11:30 -0800
Subject: [PATCH] perf; Fix PMU format parsing test failure

On POWER, the 'perf format parsing' test always fails.

Looks like it is because memset() is being passed number of longs rather than number of bytes. It is interesting that the test always passes on my x86 box.

indeed.. not sure how the bison 'union' stuff is (z)allocated, x86 is probably lucky one ;-)

Quoted 26 lines

With this patch, the test passes on POWER and continues to pass on x86.

---
 tools/perf/util/include/linux/bitops.h |    1 +
 tools/perf/util/pmu.c                  |    2 +-
 2 files changed, 2 insertions(+), 1 deletions(-)
tools/perf/util/include/linux/bitops.h +1 -0
index a55d8cf..45cf10a 100644
@@ -14,6 +14,7 @@
 #define BITS_TO_LONGS(nr)       DIV_ROUND_UP(nr, BITS_PER_BYTE * sizeof(long))
 #define BITS_TO_U64(nr)         DIV_ROUND_UP(nr, BITS_PER_BYTE * sizeof(u64))
 #define BITS_TO_U32(nr)         DIV_ROUND_UP(nr, BITS_PER_BYTE * sizeof(u32))
+#define BITS_TO_BYTES(nr)       DIV_ROUND_UP(nr, BITS_PER_BYTE)
 
 #define for_each_set_bit(bit, addr, size) \
 	for ((bit) = find_first_bit((addr), (size));		\
tools/perf/util/pmu.c +0 -0
index 9bdc60c..b93ff14 100644

tools/perf/util/pmu.c void perf_pmu__set_format(unsigned long *bits, long from, long to) · line 553

Quoted 7 lines
tools/perf/util/pmu.c +1 -1
@@ -548,7 +548,7 @@ void perf_pmu__set_format(unsigned long *bits, long from, long to)
 	if (!to)
 		to = from;
 
-	memset(bits, 0, BITS_TO_LONGS(PERF_PMU_FORMAT_BITS));
+	memset(bits, 0, BITS_TO_BYTES(PERF_PMU_FORMAT_BITS));
 	for (b = from; b <= to; b++)
 		set_bit(b, bits);

oops, nice catch!

thanks,
jirka

#2 lore raw

[tip:perf/core] perf tools: Fix PMU format parsing test failure

In reply to Sukadev Bhattiprolu
Commit-ID:  15268138e334bd0362f8395edac4822351714a22
Gitweb:     http://git.kernel.org/tip/15268138e334bd0362f8395edac4822351714a22
Author:     Sukadev Bhattiprolu <[email protected]>
AuthorDate: Thu, 17 Jan 2013 09:11:30 -0800
Committer:  Arnaldo Carvalho de Melo <[email protected]>
CommitDate: Thu, 24 Jan 2013 16:40:47 -0300

perf tools: Fix PMU format parsing test failure

On POWER, the 'perf format parsing' test always fails.

Looks like it is because memset() is being passed number of longs rather than number of bytes. It is interesting that the test always passes on my x86 box.

With this patch, the test passes on POWER and continues to pass on x86.

---
 tools/perf/util/include/linux/bitops.h | 1 +
 tools/perf/util/pmu.c                  | 2 +-
 2 files changed, 2 insertions(+), 1 deletion(-)
tools/perf/util/include/linux/bitops.h +1 -0
index a55d8cf..45cf10a 100644
@@ -14,6 +14,7 @@
 #define BITS_TO_LONGS(nr)       DIV_ROUND_UP(nr, BITS_PER_BYTE * sizeof(long))
 #define BITS_TO_U64(nr)         DIV_ROUND_UP(nr, BITS_PER_BYTE * sizeof(u64))
 #define BITS_TO_U32(nr)         DIV_ROUND_UP(nr, BITS_PER_BYTE * sizeof(u32))
+#define BITS_TO_BYTES(nr)       DIV_ROUND_UP(nr, BITS_PER_BYTE)
 
 #define for_each_set_bit(bit, addr, size) \
 	for ((bit) = find_first_bit((addr), (size));		\
tools/perf/util/pmu.c +1 -1
index 9bdc60c..b93ff14 100644
@@ -548,7 +548,7 @@ void perf_pmu__set_format(unsigned long *bits, long from, long to)
 	if (!to)
 		to = from;
 
-	memset(bits, 0, BITS_TO_LONGS(PERF_PMU_FORMAT_BITS));
+	memset(bits, 0, BITS_TO_BYTES(PERF_PMU_FORMAT_BITS));
 	for (b = from; b <= to; b++)
 		set_bit(b, bits);
 }