From: Steven Rostedt <rostedt@goodmis.org>
To: linux-kernel@vger.kernel.org
Cc: Ingo Molnar <mingo@kernel.org>,
Andrew Morton <akpm@linux-foundation.org>,
Frederic Weisbecker <fweisbec@gmail.com>
Subject: [RFC][PATCH 3/4] tracing: Use helper functions in event assignment to shrink macro size
Date: Thu, 09 Aug 2012 23:43:05 -0400 [thread overview]
Message-ID: <20120810034708.370808175@goodmis.org> (raw)
In-Reply-To: 20120810034302.758092203@goodmis.org
[-- Attachment #1: 0003-tracing-Use-helper-functions-in-event-assignment-to-.patch --]
[-- Type: text/plain, Size: 4594 bytes --]
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
next prev parent reply other threads:[~2012-08-10 3:47 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-08-10 3:43 [RFC][PATCH 0/4] tracing/perf: Use helper functions to help shrink kernel size Steven Rostedt
2012-08-10 3:43 ` [RFC][PATCH 1/4] tracing: Move print code from macro to standalone function Steven Rostedt
2012-08-10 3:43 ` [RFC][PATCH 2/4] tracing: Move event storage for array " Steven Rostedt
2012-08-10 3:43 ` Steven Rostedt [this message]
2012-08-10 3:43 ` [RFC][PATCH 4/4] perf/events: Use helper functions in event assignment to shrink macro size Steven Rostedt
2012-08-13 8:03 ` Peter Zijlstra
2012-08-13 13:03 ` Steven Rostedt
2012-08-13 13:52 ` Peter Zijlstra
2012-08-13 14:40 ` Steven Rostedt
2012-08-13 14:47 ` Peter Zijlstra
-- strict thread matches above, loose matches on Subject: below --
2014-02-06 17:39 [RFC][PATCH 0/4] tracing/perf: Use helper functions to help shrink kernel size Steven Rostedt
2014-02-06 17:39 ` [RFC][PATCH 3/4] tracing: Use helper functions in event assignment to shrink macro size Steven Rostedt
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20120810034708.370808175@goodmis.org \
--to=rostedt@goodmis.org \
--cc=akpm@linux-foundation.org \
--cc=fweisbec@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).