Skip to contentSkip to conversation

trace: reorder struct ring_buffer_per_cpu to remove padding on 64bit

PATCH In review Richard Kennedy 2 participants 4 messages Mar 25, 2010 – Jul 23, 2010

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 trace: reorder struct ring_buffer_per_cpu to remove padding on 64bit

Reorder structure to remove 8 bytes of padding on 64 bit builds. This shrinks the size to 128 bytes so allowing allocation from a smaller slab & needed one fewer cache lines.

----
patch against 2.6.34-rc2
compiled & booted on x86_64

regards
Richard

kernel/trace/ring_buffer.c +0 -0
index 05a9f83..421db5e 100644
@@ -422,6 +422,7 @@ int ring_buffer_print_page_header(struct trace_seq

*s)
*/
struct ring_buffer_per_cpu {
int cpu;
+ atomic_t record_disabled;
struct ring_buffer *buffer;
spinlock_t reader_lock; /* serialize readers */
arch_spinlock_t lock;
@@ -439,7 +440,6 @@ struct ring_buffer_per_cpu {
unsigned long read;
u64 write_stamp;
u64 read_stamp;
- atomic_t record_disabled;
};

struct ring_buffer {

maintainer
#1 lore raw
Quoted 4 lines · Richard Kennedy

Reorder structure to remove 8 bytes of padding on 64 bit builds. This shrinks the size to 128 bytes so allowing allocation from a smaller slab & needed one fewer cache lines.

Thanks!

Just curious, did you use Arnaldo's pahole utility to find this?

-- Steve

Quoted 31 lines

----
patch against 2.6.34-rc2
compiled & booted on x86_64

regards
Richard

kernel/trace/ring_buffer.c +1 -0
index 05a9f83..421db5e 100644
@@ -422,6 +422,7 @@ int ring_buffer_print_page_header(struct trace_seq
 *s)
  */
 struct ring_buffer_per_cpu {
 	int				cpu;
+	atomic_t			record_disabled;
 	struct ring_buffer		*buffer;
 	spinlock_t			reader_lock;	/* serialize readers */
kernel/trace/ring_buffer.c +0 -1
 	arch_spinlock_t			lock;
@@ -439,7 +440,6 @@ struct ring_buffer_per_cpu {
 	unsigned long			read;
 	u64				write_stamp;
 	u64				read_stamp;
-	atomic_t			record_disabled;
 };
 
 struct ring_buffer {
#2 lore raw
Quoted 11 lines · Steven Rostedt
Quoted 4 lines · Richard Kennedy

Reorder structure to remove 8 bytes of padding on 64 bit builds. This shrinks the size to 128 bytes so allowing allocation from a smaller slab & needed one fewer cache lines.

Thanks!

Just curious, did you use Arnaldo's pahole utility to find this?

-- Steve

No, but something similar I guess. I wrote my own tool that parses the debug data & filters out the interesting results ;)

Richard

#3 lore raw

[tip:perf/core] trace: Reorder struct ring_buffer_per_cpu to remove padding on 64bit

In reply to Richard Kennedy
Commit-ID:  985023dee6e212493831431ba2e3ce8918f001b2
Gitweb:     http://git.kernel.org/tip/985023dee6e212493831431ba2e3ce8918f001b2
Author:     Richard Kennedy <[email protected]>
AuthorDate: Thu, 25 Mar 2010 11:27:36 +0000
Committer:  Steven Rostedt <[email protected]>
CommitDate: Tue, 20 Jul 2010 21:58:44 -0400

trace: Reorder struct ring_buffer_per_cpu to remove padding on 64bit

Reorder structure to remove 8 bytes of padding on 64 bit builds. This shrinks the size to 128 bytes so allowing allocation from a smaller slab & needed one fewer cache lines.

LKML-Reference: <1269516456.2054.8.camel@localhost>

---
 kernel/trace/ring_buffer.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
kernel/trace/ring_buffer.c +1 -1
index 28d0615..3632ce8 100644
@@ -443,6 +443,7 @@ int ring_buffer_print_page_header(struct trace_seq *s)
  */
 struct ring_buffer_per_cpu {
 	int				cpu;
+	atomic_t			record_disabled;
 	struct ring_buffer		*buffer;
 	spinlock_t			reader_lock;	/* serialize readers */
 	arch_spinlock_t			lock;
@@ -462,7 +463,6 @@ struct ring_buffer_per_cpu {
 	unsigned long			read;
 	u64				write_stamp;
 	u64				read_stamp;
-	atomic_t			record_disabled;
 };
 
 struct ring_buffer {