[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <51F5CFFF.3090502@huawei.com>
Date: Mon, 29 Jul 2013 10:14:23 +0800
From: Li Zefan <lizefan@...wei.com>
To: Steven Rostedt <rostedt@...dmis.org>
CC: Borislav Petkov <bp@...en8.de>,
Frederic Weisbecker <fweisbec@...il.com>,
LKML <linux-kernel@...r.kernel.org>
Subject: [PATCH v3 2/2] tracing: Shrink the size of struct ftrace_event_field
Use bit fields, and the size of struct ftrace_event_field can be
shrunk from 48 bytes to 40 bytes on 64bit kernel.
slab_name active_obj nr_obj size obj_per_slab
---------------------------------------------
ftrace_event_field 1105 1105 48 85 (before)
ftrace_event_field 1224 1224 40 102 (after)
This saves a few Kbytes: (1224 * 40) - (1105 * 48) = 4080
v2:
- use !!is_signed, and nuke the check on this field.
- use a different way to detect overflow.
(both suggested by Steven)
v3:
- use plain WARN_ON() instead of a macro. (suggeusted by Borislav)
Signed-off-by: Li Zefan <lizefan@...wei.com>
---
kernel/trace/trace.h | 8 ++++----
kernel/trace/trace_events.c | 12 ++++++++----
2 files changed, 12 insertions(+), 8 deletions(-)
diff --git a/kernel/trace/trace.h b/kernel/trace/trace.h
index 4a4f6e1..3e8c97f 100644
--- a/kernel/trace/trace.h
+++ b/kernel/trace/trace.h
@@ -904,10 +904,10 @@ struct ftrace_event_field {
struct list_head link;
const char *name;
const char *type;
- int filter_type;
- int offset;
- int size;
- int is_signed;
+ unsigned int filter_type:4;
+ unsigned int offset:12;
+ unsigned int size:12;
+ unsigned int is_signed:1;
};
struct event_filter {
diff --git a/kernel/trace/trace_events.c b/kernel/trace/trace_events.c
index 7d85429..6509afe 100644
--- a/kernel/trace/trace_events.c
+++ b/kernel/trace/trace_events.c
@@ -120,13 +120,17 @@ static int __trace_define_field(struct list_head *head, const char *type,
field->type = type;
if (filter_type == FILTER_OTHER)
- field->filter_type = filter_assign_type(type);
- else
- field->filter_type = filter_type;
+ filter_type = filter_assign_type(type);
+ field->filter_type = filter_type;
field->offset = offset;
field->size = size;
- field->is_signed = is_signed;
+ field->is_signed = !!is_signed;
+
+ /* detect bit-field overflow */
+ WARN_ON(filter_type > field->filter_type);
+ WARN_ON(offset > field->offset);
+ WARN_ON(size > field->size);
list_add(&field->link, head);
--
1.8.0.2
--
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