lkml.org 
[lkml]   [2013]   [Jul]   [24]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
Subject[PATCH 2/2][RESEND] 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

Signed-off-by: Li Zefan <lizefan@huawei.com>
---
kernel/trace/trace.h | 8 ++++----
kernel/trace/trace_events.c | 5 +++++
2 files changed, 9 insertions(+), 4 deletions(-)

diff --git a/kernel/trace/trace.h b/kernel/trace/trace.h
index 9e01458..a3365a4 100644
--- a/kernel/trace/trace.h
+++ b/kernel/trace/trace.h
@@ -916,10 +916,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 53582e9..67aee85 100644
--- a/kernel/trace/trace_events.c
+++ b/kernel/trace/trace_events.c
@@ -111,6 +111,11 @@ static int __trace_define_field(struct list_head *head, const char *type,
field->size = size;
field->is_signed = is_signed;

+ WARN_ON(offset >= (1 << 12));
+ WARN_ON(size >= (1 << 12));
+ WARN_ON(is_signed >= (1 << 1));
+ WARN_ON(field->filter_type >= (1 << 4));
+
list_add(&field->link, head);

return 0;
-- 1.8.0.2


\
 
 \ /
  Last update: 2013-07-25 04:41    [W:0.070 / U:4.796 seconds]
©2003-2017 Jasper Spaans. hosted at Digital OceanAdvertise on this site