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>,
Thomas Gleixner <tglx@linutronix.de>,
Peter Zijlstra <peterz@infradead.org>,
"Joel Fernandes (Google)" <joel.opensrc@gmail.com>,
Abderrahmane Benbachir <abderrahmane.benbachir@polymtl.ca>
Subject: [PATCH 1/4 v2] init, tracing: Add initcall trace events
Date: Fri, 06 Apr 2018 15:08:55 -0400 [thread overview]
Message-ID: <20180406191334.072376811@goodmis.org> (raw)
In-Reply-To: 20180406190854.875810797@goodmis.org
[-- Attachment #1: 0001-init-tracing-Add-initcall-trace-events.patch --]
[-- Type: text/plain, Size: 3441 bytes --]
From: "Steven Rostedt (VMware)" <rostedt@goodmis.org>
Being able to trace the start and stop of initcalls is useful to see where
the timings are an issue. There is already an "initcall_debug" parameter,
but that can cause a large overhead itself, as the printing of the
information may take longer than the initcall functions.
Adding in a start and finish trace event around the initcall functions, as
well as a trace event that records the level of the initcalls, one can get a
much finer measurement of the times and interactions of the initcalls
themselves, as trace events are much lighter than printk()s.
Suggested-by: Abderrahmane Benbachir <abderrahmane.benbachir@polymtl.ca>
Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
---
include/trace/events/initcall.h | 66 +++++++++++++++++++++++++++++++++++++++++
init/main.c | 7 +++++
2 files changed, 73 insertions(+)
create mode 100644 include/trace/events/initcall.h
diff --git a/include/trace/events/initcall.h b/include/trace/events/initcall.h
new file mode 100644
index 000000000000..8d6cf10d27c9
--- /dev/null
+++ b/include/trace/events/initcall.h
@@ -0,0 +1,66 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+#undef TRACE_SYSTEM
+#define TRACE_SYSTEM initcall
+
+#if !defined(_TRACE_INITCALL_H) || defined(TRACE_HEADER_MULTI_READ)
+#define _TRACE_INITCALL_H
+
+#include <linux/tracepoint.h>
+
+TRACE_EVENT(initcall_level,
+
+ TP_PROTO(const char *level),
+
+ TP_ARGS(level),
+
+ TP_STRUCT__entry(
+ __string(level, level)
+ ),
+
+ TP_fast_assign(
+ __assign_str(level, level);
+ ),
+
+ TP_printk("level=%s", __get_str(level))
+);
+
+TRACE_EVENT(initcall_start,
+
+ TP_PROTO(initcall_t func),
+
+ TP_ARGS(func),
+
+ TP_STRUCT__entry(
+ __field(initcall_t, func)
+ ),
+
+ TP_fast_assign(
+ __entry->func = func;
+ ),
+
+ TP_printk("func=%pS", __entry->func)
+);
+
+TRACE_EVENT(initcall_finish,
+
+ TP_PROTO(initcall_t func, int ret),
+
+ TP_ARGS(func, ret),
+
+ TP_STRUCT__entry(
+ __field(initcall_t, func)
+ __field(int, ret)
+ ),
+
+ TP_fast_assign(
+ __entry->func = func;
+ __entry->ret = ret;
+ ),
+
+ TP_printk("func=%pS ret=%d", __entry->func, __entry->ret)
+);
+
+#endif /* if !defined(_TRACE_GPIO_H) || defined(TRACE_HEADER_MULTI_READ) */
+
+/* This part must be outside protection */
+#include <trace/define_trace.h>
diff --git a/init/main.c b/init/main.c
index 0ebdd5f15be8..2af8f2bb5ca8 100644
--- a/init/main.c
+++ b/init/main.c
@@ -97,6 +97,9 @@
#include <asm/sections.h>
#include <asm/cacheflush.h>
+#define CREATE_TRACE_POINTS
+#include <trace/events/initcall.h>
+
static int kernel_init(void *);
extern void init_IRQ(void);
@@ -827,10 +830,12 @@ int __init_or_module do_one_initcall(initcall_t fn)
if (initcall_blacklisted(fn))
return -EPERM;
+ trace_initcall_start(fn);
if (initcall_debug)
ret = do_one_initcall_debug(fn);
else
ret = fn();
+ trace_initcall_finish(fn, ret);
msgbuf[0] = 0;
@@ -895,6 +900,7 @@ static void __init do_initcall_level(int level)
level, level,
NULL, &repair_env_string);
+ trace_initcall_level(initcall_level_names[level]);
for (fn = initcall_levels[level]; fn < initcall_levels[level+1]; fn++)
do_one_initcall(*fn);
}
@@ -929,6 +935,7 @@ static void __init do_pre_smp_initcalls(void)
{
initcall_t *fn;
+ trace_initcall_level("early");
for (fn = __initcall_start; fn < __initcall0_start; fn++)
do_one_initcall(*fn);
}
--
2.15.1
next prev parent reply other threads:[~2018-04-06 19:13 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-04-06 19:08 [PATCH 0/4 v2] init, tracing: Steven Rostedt
2018-04-06 19:08 ` Steven Rostedt [this message]
2018-04-06 19:08 ` [PATCH 2/4 v2] init, tracing: instrument security and console initcall trace events Steven Rostedt
2018-04-06 19:08 ` [PATCH 3/4 v2] init, tracing: Have printk come through the trace events for initcall_debug Steven Rostedt
2018-04-09 5:32 ` [lkp-robot] [init, tracing] 2580d6b795: BUG:kernel_reboot-without-warning_in_boot_stage kernel test robot
2018-04-09 5:32 ` kernel test robot
2018-04-09 22:04 ` Steven Rostedt
2018-04-09 22:04 ` Steven Rostedt
2018-04-10 1:23 ` Ye Xiaolong
2018-04-10 1:23 ` Ye Xiaolong
2018-04-10 2:41 ` Steven Rostedt
2018-04-10 2:41 ` Steven Rostedt
2018-04-10 3:14 ` Ye Xiaolong
2018-04-10 3:14 ` Ye Xiaolong
2018-04-06 19:08 ` [PATCH 4/4 v2] init: Have initcall_debug still work without CONFIG_TRACEPOINTS Steven Rostedt
2018-04-07 8:18 ` kbuild test robot
2018-04-06 19:16 ` [PATCH 0/4 v2] init, tracing: Add initcall trace events Steven Rostedt
2018-04-06 19:19 ` Steven Rostedt
2018-04-06 19:34 ` Peter Zijlstra
2018-04-06 19:46 ` 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=20180406191334.072376811@goodmis.org \
--to=rostedt@goodmis.org \
--cc=abderrahmane.benbachir@polymtl.ca \
--cc=akpm@linux-foundation.org \
--cc=fweisbec@gmail.com \
--cc=joel.opensrc@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=peterz@infradead.org \
--cc=tglx@linutronix.de \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.