linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Tom Zanussi <tom.zanussi@linux.intel.com>
To: rostedt@goodmis.org
Cc: masami.hiramatsu.pt@hitachi.com, namhyung@kernel.org,
	josh@joshtriplett.org, andi@firstfloor.org,
	mathieu.desnoyers@efficios.com, peterz@infradead.org,
	linux-kernel@vger.kernel.org,
	Tom Zanussi <tom.zanussi@linux.intel.com>
Subject: [PATCH v13 07/29] tracing: Add an unreg_all() callback to trigger commands
Date: Thu, 10 Dec 2015 12:50:49 -0600	[thread overview]
Message-ID: <2b7d62854d01f28c19185e1bbb8f826f385edfba.1449767187.git.tom.zanussi@linux.intel.com> (raw)
In-Reply-To: <cover.1449767187.git.tom.zanussi@linux.intel.com>
In-Reply-To: <cover.1449767187.git.tom.zanussi@linux.intel.com>

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>
Reviewed-by: Namhyung Kim <namhyung@kernel.org>
---
 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


  parent reply	other threads:[~2015-12-10 18:51 UTC|newest]

Thread overview: 44+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-12-10 18:50 [PATCH 00/29] tracing: 'hist' triggers Tom Zanussi
2015-12-10 18:50 ` [PATCH v13 01/29] tracing: Make ftrace_event_field checking functions available Tom Zanussi
2015-12-10 18:50 ` [PATCH v13 02/29] tracing: Make event trigger " Tom Zanussi
2015-12-10 18:50 ` [PATCH v13 03/29] tracing: Add event record param to trigger_ops.func() Tom Zanussi
2015-12-10 18:50 ` [PATCH v13 04/29] tracing: Add get_syscall_name() Tom Zanussi
2015-12-10 18:50 ` [PATCH v13 05/29] tracing: Add a per-event-trigger 'paused' field Tom Zanussi
2015-12-10 18:50 ` [PATCH v13 06/29] tracing: Add needs_rec flag to event triggers Tom Zanussi
2016-02-19 19:30   ` Steven Rostedt
2016-02-19 22:35     ` Steven Rostedt
2016-02-19 23:31       ` Tom Zanussi
2016-02-20  1:27         ` Steven Rostedt
2015-12-10 18:50 ` Tom Zanussi [this message]
2015-12-10 18:50 ` [PATCH v13 08/29] tracing: Add lock-free tracing_map Tom Zanussi
2016-02-19 19:38   ` Steven Rostedt
2015-12-10 18:50 ` [PATCH v13 09/29] tracing: Add 'hist' event trigger command Tom Zanussi
2016-02-19 21:23   ` Steven Rostedt
2016-02-19 23:27     ` Tom Zanussi
2016-02-20  1:55       ` Steven Rostedt
2015-12-10 18:50 ` [PATCH v13 10/29] tracing: Add hist trigger support for multiple values ('vals=' param) Tom Zanussi
2015-12-10 18:50 ` [PATCH v13 11/29] tracing: Add hist trigger support for compound keys Tom Zanussi
2015-12-10 18:50 ` [PATCH v13 12/29] tracing: Add hist trigger support for user-defined sorting ('sort=' param) Tom Zanussi
2015-12-10 18:50 ` [PATCH v13 13/29] tracing: Add hist trigger support for pausing and continuing a trace Tom Zanussi
2015-12-10 18:50 ` [PATCH v13 14/29] tracing: Add hist trigger support for clearing " Tom Zanussi
2015-12-10 18:50 ` [PATCH v13 15/29] tracing: Add hist trigger 'hex' modifier for displaying numeric fields Tom Zanussi
2015-12-10 18:50 ` [PATCH v13 16/29] tracing: Add hist trigger 'sym' and 'sym-offset' modifiers Tom Zanussi
2015-12-10 18:50 ` [PATCH v13 17/29] tracing: Add hist trigger 'execname' modifier Tom Zanussi
2015-12-10 18:51 ` [PATCH v13 18/29] tracing: Add hist trigger 'syscall' modifier Tom Zanussi
2015-12-10 18:51 ` [PATCH v13 19/29] tracing: Add hist trigger support for stacktraces as keys Tom Zanussi
2015-12-10 18:51 ` [PATCH v13 20/29] tracing: Support string type key properly Tom Zanussi
2015-12-10 18:51 ` [PATCH v13 21/29] tracing: Remove restriction on string position in hist trigger keys Tom Zanussi
2015-12-10 18:51 ` [PATCH v13 22/29] tracing: Add enable_hist/disable_hist triggers Tom Zanussi
2015-12-10 18:51 ` [PATCH v13 23/29] tracing: Add 'hist' trigger Documentation Tom Zanussi
2015-12-10 18:51 ` [PATCH v13 24/29] tracing: Add support for multiple hist triggers per event Tom Zanussi
2015-12-10 18:51 ` [PATCH v13 25/29] tracing: Add support for named triggers Tom Zanussi
2015-12-10 18:51 ` [PATCH v13 26/29] tracing: Add support for named hist triggers Tom Zanussi
2015-12-10 18:51 ` [PATCH v13 27/29] kselftests/ftrace : Add event trigger testcases Tom Zanussi
2015-12-10 18:51 ` [PATCH v13 28/29] kselftests/ftrace: Add hist " Tom Zanussi
2015-12-10 18:51 ` [PATCH v13 29/29] tracing: Add hist trigger 'log2' modifier Tom Zanussi
2016-02-12 16:17 ` [PATCH 00/29] tracing: 'hist' triggers Tom Zanussi
2016-02-12 16:59   ` Steven Rostedt
2016-02-16 22:43     ` Tom Zanussi
2016-02-16 23:42       ` Steven Rostedt
2016-02-17  2:57       ` 平松雅巳 / HIRAMATU,MASAMI
2016-02-19 15:24         ` Tom Zanussi

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=2b7d62854d01f28c19185e1bbb8f826f385edfba.1449767187.git.tom.zanussi@linux.intel.com \
    --to=tom.zanussi@linux.intel.com \
    --cc=andi@firstfloor.org \
    --cc=josh@joshtriplett.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=masami.hiramatsu.pt@hitachi.com \
    --cc=mathieu.desnoyers@efficios.com \
    --cc=namhyung@kernel.org \
    --cc=peterz@infradead.org \
    --cc=rostedt@goodmis.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;
as well as URLs for NNTP newsgroup(s).