Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1275815

[PATCH v12 08/30] tracing: Add an unreg_all() callback to trigger commands

From Tom Zanussi <tom.zanussi@linux.intel.com>
Newsgroups linux.kernel
Subject [PATCH v12 08/30] tracing: Add an unreg_all() callback to trigger commands
Date 2015-11-23 21:10 +0100
Message-ID <qy5B0-6Cy-23@gated-at.bofh.it> (permalink)
References <qy5rk-6jA-5@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


Add a new unreg_all() callback that can be used to remove all
command-specific triggers from an event and arrange to have it called
whenever a trigger file is opened with O_TRUNC set.

Commands that don't want truncate semantics, or existing commands that
don't implement this function simply do nothing and their triggers
remain intact.

Signed-off-by: Tom Zanussi <tom.zanussi@linux.intel.com>
---
 kernel/trace/trace.h                |  9 +++++++--
 kernel/trace/trace_events_trigger.c | 13 +++++++++++++
 2 files changed, 20 insertions(+), 2 deletions(-)

diff --git a/kernel/trace/trace.h b/kernel/trace/trace.h
index 300add5..2028e98 100644
--- a/kernel/trace/trace.h
+++ b/kernel/trace/trace.h
@@ -1299,8 +1299,8 @@ struct event_trigger_ops {
  *	it (filters make a trigger require access to the trace record
  *	but are not always present).
  *
- * All the methods below, except for @set_filter(), must be
- * implemented.
+ * All the methods below, except for @set_filter() and @unreg_all(),
+ * must be implemented.
  *
  * @func: The callback function responsible for parsing and
  *	registering the trigger written to the 'trigger' file by the
@@ -1325,6 +1325,10 @@ struct event_trigger_ops {
  *	This is usually implemented by the generic utility function
  *	@unregister_trigger() (see trace_event_triggers.c).
  *
+ * @unreg_all: An optional function called to remove all the triggers
+ *	from the list of triggers associated with the event.  Called
+ *	when a trigger file is opened in truncate mode.
+ *
  * @set_filter: An optional function called to parse and set a filter
  *	for the trigger.  If no @set_filter() method is set for the
  *	event command, filters set by the user for the command will be
@@ -1351,6 +1355,7 @@ struct event_command {
 					 struct event_trigger_ops *ops,
 					 struct event_trigger_data *data,
 					 struct trace_event_file *file);
+	void			(*unreg_all)(struct trace_event_file *file);
 	int			(*set_filter)(char *filter_str,
 					      struct event_trigger_data *data,
 					      struct trace_event_file *file);
diff --git a/kernel/trace/trace_events_trigger.c b/kernel/trace/trace_events_trigger.c
index 2f881e9..362ae86 100644
--- a/kernel/trace/trace_events_trigger.c
+++ b/kernel/trace/trace_events_trigger.c
@@ -193,6 +193,19 @@ static int event_trigger_regex_open(struct inode *inode, struct file *file)
 		return -ENODEV;
 	}
 
+	if ((file->f_mode & FMODE_WRITE) &&
+	    (file->f_flags & O_TRUNC)) {
+		struct trace_event_file *event_file;
+		struct event_command *p;
+
+		event_file = event_file_data(file);
+
+		list_for_each_entry(p, &trigger_commands, list) {
+			if (p->unreg_all)
+				p->unreg_all(event_file);
+		}
+	}
+
 	if (file->f_mode & FMODE_READ) {
 		ret = seq_open(file, &event_triggers_seq_ops);
 		if (!ret) {
-- 
1.9.3

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH 00/30] tracing: 'hist' triggers Tom Zanussi <tom.zanussi@linux.intel.com> - 2015-11-23 21:00 +0100
  [PATCH v12 02/30] tracing: Make ftrace_event_field checking functions available Tom Zanussi <tom.zanussi@linux.intel.com> - 2015-11-23 21:00 +0100
  [PATCH v12 26/30] tracing: Add support for named triggers Tom Zanussi <tom.zanussi@linux.intel.com> - 2015-11-23 21:00 +0100
  [PATCH v12 04/30] tracing: Add event record param to trigger_ops.func() Tom Zanussi <tom.zanussi@linux.intel.com> - 2015-11-23 21:00 +0100
  [PATCH v12 23/30] tracing: Add enable_hist/disable_hist triggers Tom Zanussi <tom.zanussi@linux.intel.com> - 2015-11-23 21:00 +0100
  [PATCH v12 07/30] tracing: Add needs_rec flag to event triggers Tom Zanussi <tom.zanussi@linux.intel.com> - 2015-11-23 21:00 +0100
  [PATCH v12 11/30] tracing: Add hist trigger support for multiple values ('vals=' param) Tom Zanussi <tom.zanussi@linux.intel.com> - 2015-11-23 21:10 +0100
  [PATCH v12 08/30] tracing: Add an unreg_all() callback to trigger commands Tom Zanussi <tom.zanussi@linux.intel.com> - 2015-11-23 21:10 +0100
  [PATCH v12 06/30] tracing: Add a per-event-trigger 'paused' field Tom Zanussi <tom.zanussi@linux.intel.com> - 2015-11-23 21:10 +0100
  [PATCH v12 03/30] tracing: Make event trigger functions available Tom Zanussi <tom.zanussi@linux.intel.com> - 2015-11-23 21:10 +0100
  [PATCH v12 01/30] tracing: Update cond flag when enabling or disabling a trigger Tom Zanussi <tom.zanussi@linux.intel.com> - 2015-11-23 21:10 +0100
    Re: [PATCH v12 01/30] tracing: Update cond flag when enabling or  disabling a trigger Steven Rostedt <rostedt@goodmis.org> - 2015-11-23 22:30 +0100
      Re: [PATCH v12 01/30] tracing: Update cond flag when enabling or  disabling a trigger Namhyung Kim <namhyung@kernel.org> - 2015-11-25 02:30 +0100
  [PATCH v12 10/30] tracing: Add 'hist' event trigger command Tom Zanussi <tom.zanussi@linux.intel.com> - 2015-11-23 21:10 +0100
    Re: [PATCH v12 10/30] tracing: Add 'hist' event trigger command Namhyung Kim <namhyung@kernel.org> - 2015-11-29 16:00 +0100
  Re: [PATCH 00/30] tracing: 'hist' triggers Namhyung Kim <namhyung@kernel.org> - 2015-11-29 16:30 +0100

csiph-web