Skip to contentSkip to conversation

HWBKPT: Make bp_len type to u64 generic across the arch

PATCH Frederic Weisbecker 3 participants 6 messages Jan 30, 2010 – Feb 4, 2010 2 messages not in the archive perf events

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

A message that is not in the archive (sent off-list or not yet received): [email protected]

Frederic Weisbecker

author Acked-by
#2 lore raw
Quoted 24 lines · Mahesh Salgaonkar

Change 'bp_len' type to __u64 to make it work across the arch. The s390 architecture watch point length can be upto 2^64.

reference:

	http://lkml.org/lkml/2010/1/25/212

Based on commit 6aa41f8b01301199af6c9febb24f3c1f5a0bc9d5

---

 include/linux/hw_breakpoint.h |    2 +-
 include/linux/perf_event.h    |    6 ++----
 kernel/hw_breakpoint.c        |    2 +-
 kernel/perf_event.c           |    2 +-
 4 files changed, 5 insertions(+), 7 deletions(-)
include/linux/hw_breakpoint.h +0 -0
index 41235c9..76e7427 100644

include/linux/hw_breakpoint.h static inline int hw_breakpoint_type(struct perf_event *bp) · line 50

Quoted 8 lines
include/linux/hw_breakpoint.h +1 -1
@@ -44,7 +44,7 @@ static inline int hw_breakpoint_type(struct perf_event *bp)
 	return bp->attr.bp_type;
 }
 
-static inline int hw_breakpoint_len(struct perf_event *bp)
+static inline unsigned long hw_breakpoint_len(struct perf_event *bp)
 {
 	return bp->attr.bp_len;
 }

This should return a u64, or gcc will warn us about loosing informations in 32 bits arch?

Quoted 6 lines
include/linux/perf_event.h +0 -0
index 1438463..30c78bd 100644
@@ -211,11 +211,9 @@ struct perf_event_attr {
 		__u32		wakeup_watermark; /* bytes before wakeup   */

include/linux/perf_event.h struct perf_event_attr { · line 217

Quoted 10 lines
include/linux/perf_event.h +2 -4
 	};
 
-	__u32			__reserved_2;
-
-	__u64			bp_addr;
 	__u32			bp_type;
-	__u32			bp_len;
+	__u64			bp_addr;
+	__u64			bp_len;
 };

Peter, what do you think about this new layout? Putting the bp_type right after the wakeup_* fields is going to remove the padding difference between 64 and 32 archs. That looks better than the __reserved_2 we had.

If this patch can make it for .33, it would be nice.

Quoted 22 lines
include/linux/perf_event.h +0 -0
 /*
kernel/hw_breakpoint.c +1 -1
index 50dbd59..a1f511f 100644
@@ -324,8 +324,8 @@ EXPORT_SYMBOL_GPL(register_user_hw_breakpoint);
 int modify_user_hw_breakpoint(struct perf_event *bp, struct perf_event_attr *attr)
 {
 	u64 old_addr = bp->attr.bp_addr;
+	u64 old_len = bp->attr.bp_len;
 	int old_type = bp->attr.bp_type;
-	int old_len = bp->attr.bp_len;
 	int err = 0;
 
 	perf_event_disable(bp);
kernel/perf_event.c +0 -0
index 8f8f7aa..1473cc9 100644

kernel/perf_event.c static int perf_copy_attr(struct perf_event_attr __user *uattr, · line 4726

Quoted 8 lines
kernel/perf_event.c +1 -1
@@ -4720,7 +4720,7 @@ static int perf_copy_attr(struct perf_event_attr __user *uattr,
 	if (attr->type >= PERF_TYPE_MAX)
 		return -EINVAL;
 
-	if (attr->__reserved_1 || attr->__reserved_2)
+	if (attr->__reserved_1)
 		return -EINVAL;
 
 	if (attr->sample_type & ~(PERF_SAMPLE_MAX-1))
#3 lore raw
Quoted 28 lines · Frederic Weisbecker
Quoted 27 lines · Mahesh Salgaonkar

Change 'bp_len' type to __u64 to make it work across the arch. The s390 architecture watch point length can be upto 2^64.

reference:

	http://lkml.org/lkml/2010/1/25/212

Based on commit 6aa41f8b01301199af6c9febb24f3c1f5a0bc9d5

---

  include/linux/hw_breakpoint.h |    2 +-
  include/linux/perf_event.h    |    6 ++----
  kernel/hw_breakpoint.c        |    2 +-
  kernel/perf_event.c           |    2 +-
  4 files changed, 5 insertions(+), 7 deletions(-)
include/linux/hw_breakpoint.h +0 -0
index 41235c9..76e7427 100644
@@ -44,7 +44,7 @@ static inline int hw_breakpoint_type(struct perf_event *bp)
  	return bp->attr.bp_type;
  }
 
Quoted 11 lines

include/linux/hw_breakpoint.h static inline int hw_breakpoint_type(struct perf_event *bp) · line 50

Quoted 5 lines
include/linux/hw_breakpoint.h +1 -1
-static inline int hw_breakpoint_len(struct perf_event *bp)
+static inline unsigned long hw_breakpoint_len(struct perf_event *bp)
  {
  	return bp->attr.bp_len;
  }

This should return a u64, or gcc will warn us about loosing informations in 32 bits arch?

Yup, I even thought so, but then I figured out the function 'hw_breakpoint_addr()' also has same return type for returning 'attr.bp_addr' and kept the same type to be consistent. We may have to fix that also. What do you think?

Quoted 7 lines
Quoted 3 lines

Thanks for reviewing.

#4 lore raw
Quoted 40 lines · Mahesh Jagannath Salgaonkar
Quoted 28 lines · Frederic Weisbecker
Quoted 27 lines · Mahesh Salgaonkar

Change 'bp_len' type to __u64 to make it work across the arch. The s390 architecture watch point length can be upto 2^64.

reference:

	http://lkml.org/lkml/2010/1/25/212

Based on commit 6aa41f8b01301199af6c9febb24f3c1f5a0bc9d5

---

  include/linux/hw_breakpoint.h |    2 +-
  include/linux/perf_event.h    |    6 ++----
  kernel/hw_breakpoint.c        |    2 +-
  kernel/perf_event.c           |    2 +-
  4 files changed, 5 insertions(+), 7 deletions(-)
include/linux/hw_breakpoint.h +0 -0
index 41235c9..76e7427 100644
@@ -44,7 +44,7 @@ static inline int hw_breakpoint_type(struct perf_event *bp)
  	return bp->attr.bp_type;
  }
 
Quoted 11 lines

include/linux/hw_breakpoint.h static inline int hw_breakpoint_type(struct perf_event *bp) · line 50

Quoted 5 lines
include/linux/hw_breakpoint.h +1 -1
-static inline int hw_breakpoint_len(struct perf_event *bp)
+static inline unsigned long hw_breakpoint_len(struct perf_event *bp)
  {
  	return bp->attr.bp_len;
  }

This should return a u64, or gcc will warn us about loosing informations in 32 bits arch?

Quoted 4 lines

Yup, I even thought so, but then I figured out the function 'hw_breakpoint_addr()' also has same return type for returning 'attr.bp_addr' and kept the same type to be consistent. We may have to fix that also. What do you think?

True. I'll fix both then, thanks!

maintainer
#5 lore raw
In reply to Frederic Weisbecker
Quoted 8 lines · Frederic Weisbecker
Quoted 8 lines
include/linux/perf_event.h +0 -0
index 1438463..30c78bd 100644
@@ -211,11 +211,9 @@ struct perf_event_attr {
              __u32           wakeup_watermark; /* bytes before wakeup   */
      };
 
Quoted 16 lines

include/linux/perf_event.h struct perf_event_attr { · line 217

Quoted 8 lines
include/linux/perf_event.h +2 -4
-     __u32                   __reserved_2;
-
-     __u64                   bp_addr;
      __u32                   bp_type;
-     __u32                   bp_len;
+     __u64                   bp_addr;
+     __u64                   bp_len;
 };

Peter, what do you think about this new layout? Putting the bp_type right after the wakeup_* fields is going to remove the padding difference between 64 and 32 archs. That looks better than the __reserved_2 we had.

Right, I think this works nicely in that all elements will be naturally aligned and not result in different layouts between 32/64 bit builds.

Quoted 1 line

If this patch can make it for .33, it would be nice.

It has to make .33, if it doesn't you're hosed because then the old layout is fixed in stone.

#6 lore raw
Quoted 26 lines · Peter Zijlstra
Quoted 8 lines · Frederic Weisbecker
Quoted 8 lines
include/linux/perf_event.h +0 -0
index 1438463..30c78bd 100644
@@ -211,11 +211,9 @@ struct perf_event_attr {
              __u32           wakeup_watermark; /* bytes before wakeup   */
      };
 
Quoted 16 lines

include/linux/perf_event.h struct perf_event_attr { · line 217

Quoted 8 lines
include/linux/perf_event.h +2 -4
-     __u32                   __reserved_2;
-
-     __u64                   bp_addr;
      __u32                   bp_type;
-     __u32                   bp_len;
+     __u64                   bp_addr;
+     __u64                   bp_len;
 };

Peter, what do you think about this new layout? Putting the bp_type right after the wakeup_* fields is going to remove the padding difference between 64 and 32 archs. That looks better than the __reserved_2 we had.

Quoted 8 lines

Right, I think this works nicely in that all elements will be naturally aligned and not result in different layouts between 32/64 bit builds.

Quoted 1 line

If this patch can make it for .33, it would be nice.

It has to make .33, if it doesn't you're hosed because then the old layout is fixed in stone.

Truly.
I'll send a pull request to Ingo quickly then.

Thanks.

#7 lore raw

[tip:perf/urgent] perf: Make bp_len type to u64 generic across the arch

In reply to a message not in the archive
Commit-ID:  cd757645fbdc34a8343c04bb0e74e06fccc2cb10
Gitweb:     http://git.kernel.org/tip/cd757645fbdc34a8343c04bb0e74e06fccc2cb10
Author:     Mahesh Salgaonkar <[email protected]>
AuthorDate: Sat, 30 Jan 2010 10:25:18 +0530
Committer:  Frederic Weisbecker <[email protected]>
CommitDate: Thu, 4 Feb 2010 01:07:12 +0100

perf: Make bp_len type to u64 generic across the arch

Change 'bp_len' type to __u64 to make it work across archs as the s390 architecture watch point length can be upto 2^64.

reference:

	http://lkml.org/lkml/2010/1/25/212

This is an ABI change that is not backward compatible with the previous hardware breakpoint info layout integrated in this development cycle, a rebuilt of perf tools is necessary for versions based on 2.6.33-rc1 - 2.6.33-rc6 to work with a kernel based on this patch.

Cc Ananth N Mavinakayanahalli <[email protected]>
Cc "K. Prasad" <[email protected]>
Cc Maneesh Soni <[email protected]>
Cc Heiko Carstens <[email protected]>
Cc Martin <[email protected]>

LKML-Reference: <[email protected]>

---
 include/linux/hw_breakpoint.h |    2 +-
 include/linux/perf_event.h    |    6 ++----
 kernel/hw_breakpoint.c        |    2 +-
 kernel/perf_event.c           |    2 +-
 4 files changed, 5 insertions(+), 7 deletions(-)
include/linux/hw_breakpoint.h +1 -1
index 070ba06..5977b72 100644
@@ -44,7 +44,7 @@ static inline int hw_breakpoint_type(struct perf_event *bp)
 	return bp->attr.bp_type;
 }
 
-static inline int hw_breakpoint_len(struct perf_event *bp)
+static inline unsigned long hw_breakpoint_len(struct perf_event *bp)
 {
 	return bp->attr.bp_len;
 }
include/linux/perf_event.h +2 -4
index 8fa7187..a177698 100644
@@ -211,11 +211,9 @@ struct perf_event_attr {
 		__u32		wakeup_watermark; /* bytes before wakeup   */
 	};
 
-	__u32			__reserved_2;
-
-	__u64			bp_addr;
 	__u32			bp_type;
-	__u32			bp_len;
+	__u64			bp_addr;
+	__u64			bp_len;
 };
 
 /*
kernel/hw_breakpoint.c +1 -1
index 8a5c7d5..967e661 100644
@@ -360,8 +360,8 @@ EXPORT_SYMBOL_GPL(register_user_hw_breakpoint);
 int modify_user_hw_breakpoint(struct perf_event *bp, struct perf_event_attr *attr)
 {
 	u64 old_addr = bp->attr.bp_addr;
+	u64 old_len = bp->attr.bp_len;
 	int old_type = bp->attr.bp_type;
-	int old_len = bp->attr.bp_len;
 	int err = 0;
 
 	perf_event_disable(bp);
kernel/perf_event.c +1 -1
index d27746b..2b19297 100644
@@ -4580,7 +4580,7 @@ static int perf_copy_attr(struct perf_event_attr __user *uattr,
 	if (attr->type >= PERF_TYPE_MAX)
 		return -EINVAL;
 
-	if (attr->__reserved_1 || attr->__reserved_2)
+	if (attr->__reserved_1)
 		return -EINVAL;
 
 	if (attr->sample_type & ~(PERF_SAMPLE_MAX-1))