lkml.org 
[lkml]   [2012]   [Aug]   [9]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
Subject[RFC][PATCH 3/4] tracing: Use helper functions in event assignment to shrink macro size
From: Steven Rostedt <srostedt@redhat.com>

The functions that assign the contents for the ftrace events are
defined by the TRACE_EVENT() macros. Each event has its own unique
way to assign data to its buffer. When you have over 700 events,
that means there's 700 functions assigning data uniquely for each
event (not really that many, as DECLARE_EVENT_CLASS() and multiple
DEFINE_EVENT()s will only need a single function).

By making helper functions in the core kernel to do some of the work
instead, we can shrink the size of the kernel down a bit.

With a kernel configured with 707 events, the change in size was:

text data bss dec hex filename
19991705 2594648 1945600 24531953 17653f1 vmlinux-before
19966937 2594648 1945600 24507185 175f331 vmlinux-after

That's a total of 24768 bytes, which comes down to 35 bytes per event.

Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
---
include/linux/ftrace_event.h | 14 ++++++++++++++
include/trace/ftrace.h | 21 ++++++---------------
kernel/trace/trace_output.c | 26 ++++++++++++++++++++++++++
3 files changed, 46 insertions(+), 15 deletions(-)

diff --git a/include/linux/ftrace_event.h b/include/linux/ftrace_event.h
index 22f5fec..b9f39d3 100644
--- a/include/linux/ftrace_event.h
+++ b/include/linux/ftrace_event.h
@@ -148,6 +148,20 @@ int ftrace_event_define_field(struct ftrace_event_call *call,
char *type, int len, char *item, int offset,
int field_size, int sign, int filter);

+struct ftrace_event_buffer {
+ struct ring_buffer *buffer;
+ struct ring_buffer_event *event;
+ unsigned long flags;
+ int pc;
+};
+
+void *ftrace_event_buffer_reserve(struct ftrace_event_buffer *fbuffer,
+ int type, unsigned long len);
+
+void ftrace_event_buffer_commit(struct ftrace_event_buffer *fbuffer,
+ struct ftrace_event_call *event_call,
+ void *entry);
+
struct event_filter;

enum trace_reg {
diff --git a/include/trace/ftrace.h b/include/trace/ftrace.h
index 95d6704..8118451 100644
--- a/include/trace/ftrace.h
+++ b/include/trace/ftrace.h
@@ -499,33 +499,24 @@ ftrace_raw_event_##call(void *__data, proto) \
{ \
struct ftrace_event_call *event_call = __data; \
struct ftrace_data_offsets_##call __maybe_unused __data_offsets;\
- struct ring_buffer_event *event; \
+ struct ftrace_event_buffer fbuffer; \
struct ftrace_raw_##call *entry; \
- struct ring_buffer *buffer; \
- unsigned long irq_flags; \
int __data_size; \
- int pc; \
- \
- local_save_flags(irq_flags); \
- pc = preempt_count(); \
\
__data_size = ftrace_get_offsets_##call(&__data_offsets, args); \
\
- event = trace_current_buffer_lock_reserve(&buffer, \
+ entry = ftrace_event_buffer_reserve(&fbuffer, \
event_call->event.type, \
- sizeof(*entry) + __data_size, \
- irq_flags, pc); \
- if (!event) \
+ sizeof(*entry) + __data_size); \
+ \
+ if (!entry) \
return; \
- entry = ring_buffer_event_data(event); \
\
tstruct \
\
{ assign; } \
\
- if (!filter_current_check_discard(buffer, event_call, entry, event)) \
- trace_nowake_buffer_unlock_commit(buffer, \
- event, irq_flags, pc); \
+ ftrace_event_buffer_commit(&fbuffer, event_call, entry); \
}
/*
* The ftrace_test_probe is compiled out, it is only here as a build time check
diff --git a/kernel/trace/trace_output.c b/kernel/trace/trace_output.c
index 06f27ab..2babeef 100644
--- a/kernel/trace/trace_output.c
+++ b/kernel/trace/trace_output.c
@@ -461,6 +461,32 @@ int ftrace_event_define_field(struct ftrace_event_call *call,
return ret;
}

+void *ftrace_event_buffer_reserve(struct ftrace_event_buffer *fbuffer,
+ int type, unsigned long len)
+{
+ local_save_flags(fbuffer->flags);
+ fbuffer->pc = preempt_count();
+
+ fbuffer->event =
+ trace_current_buffer_lock_reserve(&fbuffer->buffer, type, len,
+ fbuffer->flags, fbuffer->pc);
+ if (!fbuffer->event)
+ return NULL;
+
+ return ring_buffer_event_data(fbuffer->event);
+}
+
+void ftrace_event_buffer_commit(struct ftrace_event_buffer *fbuffer,
+ struct ftrace_event_call *event_call,
+ void *entry)
+{
+ if (!filter_current_check_discard(fbuffer->buffer, event_call,
+ entry, fbuffer->event))
+ trace_nowake_buffer_unlock_commit(fbuffer->buffer,
+ fbuffer->event,
+ fbuffer->flags, fbuffer->pc);
+}
+
#ifdef CONFIG_KRETPROBES
static inline const char *kretprobed(const char *name)
{
--
1.7.10.4



\
 
 \ /
  Last update: 2012-08-10 06:43    [W:0.090 / U:0.376 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site