From: Steven Rostedt <rostedt@goodmis.org>
To: linux-kernel@vger.kernel.org
Cc: Ingo Molnar <mingo@kernel.org>,
Frederic Weisbecker <fweisbec@gmail.com>,
Andrew Morton <akpm@linux-foundation.org>
Subject: [for-next][PATCH 5/5] tracing: Show available event triggers when no trigger is set
Date: Fri, 10 Jan 2014 10:20:09 -0500 [thread overview]
Message-ID: <20140110152100.763984865@goodmis.org> (raw)
In-Reply-To: 20140110152004.200225053@goodmis.org
[-- Attachment #1: 0005-tracing-Show-available-event-triggers-when-no-trigge.patch --]
[-- Type: text/plain, Size: 2461 bytes --]
From: "Steven Rostedt (Red Hat)" <rostedt@goodmis.org>
Currently there's no way to know what triggers exist on a kernel without
looking at the source of the kernel or randomly trying out triggers.
Instead of creating another file in the debugfs system, simply show
what available triggers are there when cat'ing the trigger file when
it has no events:
[root /sys/kernel/debug/tracing]# cat events/sched/sched_switch/trigger
# Available triggers:
# traceon traceoff snapshot stacktrace enable_event disable_event
This stays consistent with other debugfs files where meta data like
this is always proceeded with a '#' at the start of the line so that
tools can strip these out.
Link: http://lkml.kernel.org/r/20140107103548.0a84536d@gandalf.local.home
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
---
kernel/trace/trace_events_trigger.c | 20 ++++++++++++++++++++
1 file changed, 20 insertions(+)
diff --git a/kernel/trace/trace_events_trigger.c b/kernel/trace/trace_events_trigger.c
index a53e0da..8efbb69 100644
--- a/kernel/trace/trace_events_trigger.c
+++ b/kernel/trace/trace_events_trigger.c
@@ -115,10 +115,15 @@ event_triggers_post_call(struct ftrace_event_file *file,
}
EXPORT_SYMBOL_GPL(event_triggers_post_call);
+#define SHOW_AVAILABLE_TRIGGERS (void *)(1UL)
+
static void *trigger_next(struct seq_file *m, void *t, loff_t *pos)
{
struct ftrace_event_file *event_file = event_file_data(m->private);
+ if (t == SHOW_AVAILABLE_TRIGGERS)
+ return NULL;
+
return seq_list_next(t, &event_file->triggers, pos);
}
@@ -132,6 +137,9 @@ static void *trigger_start(struct seq_file *m, loff_t *pos)
if (unlikely(!event_file))
return ERR_PTR(-ENODEV);
+ if (list_empty(&event_file->triggers))
+ return *pos == 0 ? SHOW_AVAILABLE_TRIGGERS : NULL;
+
return seq_list_start(&event_file->triggers, *pos);
}
@@ -143,6 +151,18 @@ static void trigger_stop(struct seq_file *m, void *t)
static int trigger_show(struct seq_file *m, void *v)
{
struct event_trigger_data *data;
+ struct event_command *p;
+
+ if (v == SHOW_AVAILABLE_TRIGGERS) {
+ seq_puts(m, "# Available triggers:\n");
+ seq_putc(m, '#');
+ mutex_lock(&trigger_cmd_mutex);
+ list_for_each_entry_reverse(p, &trigger_commands, list)
+ seq_printf(m, " %s", p->name);
+ seq_putc(m, '\n');
+ mutex_unlock(&trigger_cmd_mutex);
+ return 0;
+ }
data = list_entry(v, struct event_trigger_data, list);
data->ops->print(m, data->ops, data);
--
1.8.4.3
prev parent reply other threads:[~2014-01-10 15:21 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-01-10 15:20 [for-next][PATCH 0/5] tracing: event trigger updates Steven Rostedt
2014-01-10 15:20 ` [for-next][PATCH 1/5] tracing/kprobes: Add trace event trigger invocations Steven Rostedt
2014-01-10 15:20 ` [for-next][PATCH 2/5] tracing: Remove double-underscore naming in syscall " Steven Rostedt
2014-01-10 15:20 ` [for-next][PATCH 3/5] tracing: Fix counter for traceon/off event triggers Steven Rostedt
2014-01-10 15:20 ` [for-next][PATCH 4/5] tracing: Consolidate event trigger code Steven Rostedt
2014-01-10 15:20 ` 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=20140110152100.763984865@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