All of lore.kernel.org
 help / color / mirror / Atom feed
From: Steven Rostedt <rostedt@goodmis.org>
To: linux-kernel@vger.kernel.org
Cc: Ingo Molnar <mingo@kernel.org>,
	Andrew Morton <akpm@linux-foundation.org>,
	Arnd Bergmann <arnd@arndb.de>,
	Lukas Bulwahn <lukas.bulwahn@gmail.com>,
	Masami Hiramatsu <mhiramat@kernel.org>,
	Qiujun Huang <hqjagain@gmail.com>,
	Lucas Stach <l.stach@pengutronix.de>
Subject: [for-linus][PATCH 9/9] tracing: Offload eval map updates to a work queue
Date: Wed, 16 Dec 2020 20:04:17 -0500	[thread overview]
Message-ID: <20201217010503.521310301@goodmis.org> (raw)
In-Reply-To: 20201217010408.742794078@goodmis.org

From: "Steven Rostedt (VMware)" <rostedt@goodmis.org>

In order for tracepoints to export their enums to user space, the use of the
TRACE_DEFINE_ENUM() macro is used. On boot up, the strings shown in the
tracefs "print fmt" lines are processed, and all the enums registered by
TRACE_DEFINE_ENUM are replaced with the interger value. This way, userspace
tools that read the raw binary data, knows how to evaluate the raw events.

This is currently done in an initcall, but it has been noticed that slow
embedded boards that have tracing may take a few seconds to process them
all, and a few seconds slow down on an embedded device is detrimental to the
system.

Instead, offload the work to a work queue and make sure that its finished by
destroying the work queue (which flushes all work) in a late initcall. This
will allow the system to continue to boot and run the updates in the
background, and this speeds up the boot time. Note, the strings being
updated are only used by user space, so finishing the process before the
system is fully booted will prevent any race issues.

Link: https://lore.kernel.org/r/68d7b3327052757d0cd6359a6c9015a85b437232.camel@pengutronix.de

Reported-by: Lucas Stach <l.stach@pengutronix.de>
Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
---
 kernel/trace/trace.c | 32 +++++++++++++++++++++++++++++++-
 1 file changed, 31 insertions(+), 1 deletion(-)

diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
index eee484afcc51..eb5205e48733 100644
--- a/kernel/trace/trace.c
+++ b/kernel/trace/trace.c
@@ -9066,7 +9066,10 @@ int tracing_init_dentry(void)
 extern struct trace_eval_map *__start_ftrace_eval_maps[];
 extern struct trace_eval_map *__stop_ftrace_eval_maps[];
 
-static void __init trace_eval_init(void)
+static struct workqueue_struct *eval_map_wq __initdata;
+static struct work_struct eval_map_work __initdata;
+
+static void __init eval_map_work_func(struct work_struct *work)
 {
 	int len;
 
@@ -9074,6 +9077,33 @@ static void __init trace_eval_init(void)
 	trace_insert_eval_map(NULL, __start_ftrace_eval_maps, len);
 }
 
+static int __init trace_eval_init(void)
+{
+	INIT_WORK(&eval_map_work, eval_map_work_func);
+
+	eval_map_wq = alloc_workqueue("eval_map_wq", WQ_UNBOUND, 0);
+	if (!eval_map_wq) {
+		pr_err("Unable to allocate eval_map_wq\n");
+		/* Do work here */
+		eval_map_work_func(&eval_map_work);
+		return -ENOMEM;
+	}
+
+	queue_work(eval_map_wq, &eval_map_work);
+	return 0;
+}
+
+static int __init trace_eval_sync(void)
+{
+	/* Make sure the eval map updates are finished */
+	if (eval_map_wq)
+		destroy_workqueue(eval_map_wq);
+	return 0;
+}
+
+late_initcall_sync(trace_eval_sync);
+
+
 #ifdef CONFIG_MODULES
 static void trace_module_add_evals(struct module *mod)
 {
-- 
2.29.2



      parent reply	other threads:[~2020-12-17  1:13 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-12-17  1:04 [for-linus][PATCH 0/9] tracing: Last minute fixes before pushing to Linus Steven Rostedt
2020-12-17  1:04 ` [for-linus][PATCH 1/9] ring-buffer: Remove obsolete rb_event_is_commit() Steven Rostedt
2020-12-17  1:04 ` [for-linus][PATCH 2/9] ring-buffer: Fix a typo in function description Steven Rostedt
2020-12-17  1:04 ` [for-linus][PATCH 3/9] seq_buf: Avoid type mismatch for seq_buf_init Steven Rostedt
2020-12-17  1:04 ` [for-linus][PATCH 4/9] tracing: Disable ftrace selftests when any tracer is running Steven Rostedt
2020-12-17  1:04 ` [for-linus][PATCH 5/9] tracing: Drop unneeded assignment in ring_buffer_resize() Steven Rostedt
2020-12-17  1:04 ` [for-linus][PATCH 6/9] ring-buffer: Fix two typos in comments Steven Rostedt
2020-12-17  1:04 ` [for-linus][PATCH 7/9] ring-buffer: Add rb_check_bpage in __rb_allocate_pages Steven Rostedt
2020-12-17  1:04 ` [for-linus][PATCH 8/9] Revert: "ring-buffer: Remove HAVE_64BIT_ALIGNED_ACCESS" Steven Rostedt
2020-12-17  1:04 ` Steven Rostedt [this message]

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=20201217010503.521310301@goodmis.org \
    --to=rostedt@goodmis.org \
    --cc=akpm@linux-foundation.org \
    --cc=arnd@arndb.de \
    --cc=hqjagain@gmail.com \
    --cc=l.stach@pengutronix.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lukas.bulwahn@gmail.com \
    --cc=mhiramat@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 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.