[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <20090209190406.GA11005@ghostprotocols.net>
Date: Mon, 9 Feb 2009 17:04:06 -0200
From: Arnaldo Carvalho de Melo <acme@...hat.com>
To: Steven Rostedt <rostedt@...dmis.org>
Cc: Ingo Molnar <mingo@...e.hu>,
Frédéric Weisbecker <fweisbec@...il.com>,
Linux Kernel Mailing List <linux-kernel@...r.kernel.org>
Subject: [PATCH tip 1/1] ring_buffer: pahole struct ring_buffer
Hi,
While fixing some bugs in pahole (built-in.o files were not being
processed due to relocation problems) I found out about these packable
structures:
$ pahole --packable kernel/trace/ring_buffer.o | grep ring
ring_buffer 72 64 8
ring_buffer_per_cpu 112 104 8
If we take a look at the current layout of struct ring_buffer we can see
that we have two 4 bytes holes.
$ pahole -C ring_buffer kernel/trace/ring_buffer.o
struct ring_buffer {
unsigned int pages; /* 0 4 */
unsigned int flags; /* 4 4 */
int cpus; /* 8 4 */
/* XXX 4 bytes hole, try to pack */
cpumask_var_t cpumask; /* 16 8 */
atomic_t record_disabled; /* 24 4 */
/* XXX 4 bytes hole, try to pack */
struct mutex mutex; /* 32 32 */
/* --- cacheline 1 boundary (64 bytes) --- */
struct ring_buffer_per_cpu * * buffers; /* 64 8 */
/* size: 72, cachelines: 2, members: 7 */
/* sum members: 64, holes: 2, sum holes: 8 */
/* last cacheline: 8 bytes */
};
So, if I ask pahole to reorganize it:
$ pahole -C ring_buffer --reorganize kernel/trace/ring_buffer.o
struct ring_buffer {
unsigned int pages; /* 0 4 */
unsigned int flags; /* 4 4 */
int cpus; /* 8 4 */
atomic_t record_disabled; /* 12 4 */
cpumask_var_t cpumask; /* 16 8 */
struct mutex mutex; /* 24 32 */
struct ring_buffer_per_cpu * * buffers; /* 56 8 */
/* --- cacheline 1 boundary (64 bytes) --- */
/* size: 64, cachelines: 1, members: 7 */
}; /* saved 8 bytes and 1 cacheline! */
We get it using just one 64 bytes cacheline.
To see what it did:
$ pahole -C ring_buffer --reorganize --show_reorg_steps \
kernel/trace/ring_buffer.o | grep \/
/* Moving 'record_disabled' from after 'cpumask' to after 'cpus' */
Cc: Ingo Molnar <mingo@...e.hu>
Cc: Frédéric Weisbecker <fweisbec@...il.com>
Signed-off-by: Arnaldo Carvalho de Melo <acme@...hat.com>
---
ring_buffer.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/kernel/trace/ring_buffer.c b/kernel/trace/ring_buffer.c
index 53ba3a6..27ef3bf 100644
--- a/kernel/trace/ring_buffer.c
+++ b/kernel/trace/ring_buffer.c
@@ -273,8 +273,8 @@ struct ring_buffer {
unsigned pages;
unsigned flags;
int cpus;
- cpumask_var_t cpumask;
atomic_t record_disabled;
+ cpumask_var_t cpumask;
struct mutex mutex;
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists