public inbox for linux-kernel@vger.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>,
	Arnaldo Carvalho de Melo <acme@kernel.org>,
	Rusty Russell <rusty@rustcorp.com.au>,
	Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
Subject: [for-next][PATCH 11/21] tracing: Allow for modules to convert their enums to values
Date: Wed, 08 Apr 2015 09:48:15 -0400	[thread overview]
Message-ID: <20150408134926.329553225@goodmis.org> (raw)
In-Reply-To: 20150408134804.225653449@goodmis.org

[-- Attachment #1: 0011-tracing-Allow-for-modules-to-convert-their-enums-to-.patch --]
[-- Type: text/plain, Size: 4274 bytes --]

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

Update the infrastructure such that modules that declare TRACE_DEFINE_ENUM()
will have those enums converted into their values in the tracepoint
print fmt strings.

Link: http://lkml.kernel.org/r/87vbhjp74q.fsf@rustcorp.com.au

Acked-by: Rusty Russell <rusty@rustcorp.com.au>
Reviewed-by: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
Tested-by: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
---
 include/linux/module.h      |  2 ++
 kernel/module.c             |  3 +++
 kernel/trace/trace.c        | 49 +++++++++++++++++++++++++++++++++++++++++----
 kernel/trace/trace_events.c |  2 +-
 4 files changed, 51 insertions(+), 5 deletions(-)

diff --git a/include/linux/module.h b/include/linux/module.h
index 42999fe2dbd0..53dc41dd5c62 100644
--- a/include/linux/module.h
+++ b/include/linux/module.h
@@ -338,6 +338,8 @@ struct module {
 #ifdef CONFIG_EVENT_TRACING
 	struct ftrace_event_call **trace_events;
 	unsigned int num_trace_events;
+	struct trace_enum_map **trace_enums;
+	unsigned int num_trace_enums;
 #endif
 #ifdef CONFIG_FTRACE_MCOUNT_RECORD
 	unsigned int num_ftrace_callsites;
diff --git a/kernel/module.c b/kernel/module.c
index b3d634ed06c9..d8f8ab271c2b 100644
--- a/kernel/module.c
+++ b/kernel/module.c
@@ -2753,6 +2753,9 @@ static int find_module_sections(struct module *mod, struct load_info *info)
 	mod->trace_events = section_objs(info, "_ftrace_events",
 					 sizeof(*mod->trace_events),
 					 &mod->num_trace_events);
+	mod->trace_enums = section_objs(info, "_ftrace_enum_map",
+					sizeof(*mod->trace_enums),
+					&mod->num_trace_enums);
 #endif
 #ifdef CONFIG_TRACING
 	mod->trace_bprintk_fmt_start = section_objs(info, "__trace_printk_fmt",
diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
index ebf49649534c..28e6654e640d 100644
--- a/kernel/trace/trace.c
+++ b/kernel/trace/trace.c
@@ -3908,11 +3908,9 @@ static const struct file_operations tracing_saved_cmdlines_size_fops = {
 	.write		= tracing_saved_cmdlines_size_write,
 };
 
-static void
-trace_insert_enum_map(struct trace_enum_map **start, struct trace_enum_map **stop)
+static void trace_insert_enum_map(struct trace_enum_map **start, int len)
 {
 	struct trace_enum_map **map;
-	int len = stop - start;
 
 	if (len <= 0)
 		return;
@@ -6561,9 +6559,48 @@ extern struct trace_enum_map *__stop_ftrace_enum_maps[];
 
 static void __init trace_enum_init(void)
 {
-	trace_insert_enum_map(__start_ftrace_enum_maps, __stop_ftrace_enum_maps);
+	int len;
+
+	len = __stop_ftrace_enum_maps - __start_ftrace_enum_maps;
+	trace_insert_enum_map(__start_ftrace_enum_maps, len);
+}
+
+#ifdef CONFIG_MODULES
+static void trace_module_add_enums(struct module *mod)
+{
+	if (!mod->num_trace_enums)
+		return;
+
+	/*
+	 * Modules with bad taint do not have events created, do
+	 * not bother with enums either.
+	 */
+	if (trace_module_has_bad_taint(mod))
+		return;
+
+	trace_insert_enum_map(mod->trace_enums, mod->num_trace_enums);
+}
+
+static int trace_module_notify(struct notifier_block *self,
+			       unsigned long val, void *data)
+{
+	struct module *mod = data;
+
+	switch (val) {
+	case MODULE_STATE_COMING:
+		trace_module_add_enums(mod);
+		break;
+	}
+
+	return 0;
 }
 
+static struct notifier_block trace_module_nb = {
+	.notifier_call = trace_module_notify,
+	.priority = 0,
+};
+#endif
+
 static __init int tracer_init_debugfs(void)
 {
 	struct dentry *d_tracer;
@@ -6590,6 +6627,10 @@ static __init int tracer_init_debugfs(void)
 
 	trace_enum_init();
 
+#ifdef CONFIG_MODULES
+	register_module_notifier(&trace_module_nb);
+#endif
+
 #ifdef CONFIG_DYNAMIC_FTRACE
 	trace_create_file("dyn_ftrace_total_info", 0444, d_tracer,
 			&ftrace_update_tot_cnt, &tracing_dyn_info_fops);
diff --git a/kernel/trace/trace_events.c b/kernel/trace/trace_events.c
index fc58c50fbf01..a576bbe75577 100644
--- a/kernel/trace/trace_events.c
+++ b/kernel/trace/trace_events.c
@@ -2034,7 +2034,7 @@ static int trace_module_notify(struct notifier_block *self,
 
 static struct notifier_block trace_module_nb = {
 	.notifier_call = trace_module_notify,
-	.priority = 0,
+	.priority = 1, /* higher than trace.c module notify */
 };
 #endif /* CONFIG_MODULES */
 
-- 
2.1.4



  parent reply	other threads:[~2015-04-08 13:51 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-04-08 13:48 [for-next][PATCH 00/21] tracing: Addition of TRACE_DEFINE_ENUM() to convert enums it TP_printk() Steven Rostedt
2015-04-08 13:48 ` [for-next][PATCH 01/21] tracing/drm: Remove unused TRACE_SYSTEM_STRING define Steven Rostedt
2015-04-08 13:48 ` [for-next][PATCH 02/21] tracing: Add TRACE_SYSTEM_VAR to intel-sst Steven Rostedt
2015-04-08 13:48 ` [for-next][PATCH 03/21] tracing: Add TRACE_SYSTEM_VAR to kvm-s390 Steven Rostedt
2015-04-08 13:48 ` [for-next][PATCH 04/21] tracing: Add TRACE_SYSTEM_VAR to xhci-hcd Steven Rostedt
2015-04-08 13:48 ` [for-next][PATCH 05/21] mac80211: Move message tracepoints to their own header Steven Rostedt
2015-04-08 13:48 ` [for-next][PATCH 06/21] iwlwifi: Move each system " Steven Rostedt
2015-04-08 13:48 ` [for-next][PATCH 07/21] brcmsmac: " Steven Rostedt
2015-04-08 13:48 ` [for-next][PATCH 08/21] tracing: Give system name a pointer Steven Rostedt
2015-04-08 13:48 ` [for-next][PATCH 09/21] tracing: Update trace-event-sample with TRACE_SYSTEM_VAR documentation Steven Rostedt
2015-04-08 13:48 ` [for-next][PATCH 10/21] tracing: Add TRACE_DEFINE_ENUM() macro to map enums to their values Steven Rostedt
2015-04-08 13:48 ` Steven Rostedt [this message]
2015-04-08 13:48 ` [for-next][PATCH 12/21] tracing/samples: Update the trace-event-sample.h with TRACE_DEFINE_ENUM() Steven Rostedt
2015-04-08 13:48 ` [for-next][PATCH 13/21] x86/tlb/trace: Export enums in used by tlb_flush tracepoint Steven Rostedt
2015-04-08 13:48 ` [for-next][PATCH 14/21] net/9p/tracing: Export enums in tracepoints to userspace Steven Rostedt
2015-04-08 13:48 ` [for-next][PATCH 15/21] f2fs: Export the enums in the " Steven Rostedt
2015-04-08 13:48 ` [for-next][PATCH 16/21] irq/tracing: Export enums in tracepoints to user space Steven Rostedt
2015-04-08 13:48 ` [for-next][PATCH 17/21] mm: tracing: " Steven Rostedt
2015-04-08 13:48 ` [for-next][PATCH 18/21] SUNRPC: " Steven Rostedt
2015-04-08 13:48 ` [for-next][PATCH 19/21] v4l: Export enums used by " Steven Rostedt
2015-04-08 14:43   ` Mauro Carvalho Chehab
2015-04-08 14:56     ` Steven Rostedt
2015-04-08 13:48 ` [for-next][PATCH 20/21] writeback: Export enums used by tracepoint " Steven Rostedt
2015-04-08 13:48 ` [for-next][PATCH 21/21] tracing: Add enum_map file to show enums that have been mapped 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=20150408134926.329553225@goodmis.org \
    --to=rostedt@goodmis.org \
    --cc=acme@kernel.org \
    --cc=akpm@linux-foundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=masami.hiramatsu.pt@hitachi.com \
    --cc=mingo@kernel.org \
    --cc=rusty@rustcorp.com.au \
    /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