linux-rt-users.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Tom Zanussi <zanussi@kernel.org>
To: rostedt@goodmis.org
Cc: artem.bityutskiy@linux.intel.com, mhiramat@kernel.org,
	linux-kernel@vger.kernel.org, linux-rt-users@vger.kernel.org,
	ndesaulniers@google.com
Subject: [PATCH v3 03/12] tracing: Add synth_event_delete()
Date: Fri, 24 Jan 2020 16:56:14 -0600	[thread overview]
Message-ID: <fb1828de7e276c5589071fe34f509a6cfba83cf7.1579904761.git.zanussi@kernel.org> (raw)
In-Reply-To: <cover.1579904761.git.zanussi@kernel.org>
In-Reply-To: <cover.1579904761.git.zanussi@kernel.org>

create_or_delete_synth_event() contains code to delete a synthetic
event, which would be useful on its own - specifically, it would be
useful to allow event-creating modules to call it separately.

Separate out the delete code from that function and create an exported
function named synth_event_delete().

Signed-off-by: Tom Zanussi <zanussi@kernel.org>
---
 include/linux/trace_events.h     |  2 ++
 kernel/trace/trace_events_hist.c | 57 +++++++++++++++++++++++++++++-----------
 2 files changed, 43 insertions(+), 16 deletions(-)

diff --git a/include/linux/trace_events.h b/include/linux/trace_events.h
index 8d621a73c97e..25fe743bcbaf 100644
--- a/include/linux/trace_events.h
+++ b/include/linux/trace_events.h
@@ -354,6 +354,8 @@ extern struct trace_event_file *trace_get_event_file(const char *instance,
 						     const char *event);
 extern void trace_put_event_file(struct trace_event_file *file);
 
+extern int synth_event_delete(const char *name);
+
 /*
  * Event file flags:
  *  ENABLED	  - The event is enabled
diff --git a/kernel/trace/trace_events_hist.c b/kernel/trace/trace_events_hist.c
index 117a1202a6b9..94ee1e576a1e 100644
--- a/kernel/trace/trace_events_hist.c
+++ b/kernel/trace/trace_events_hist.c
@@ -1354,29 +1354,54 @@ static int __create_synth_event(int argc, const char *name, const char **argv)
 	goto out;
 }
 
+static int destroy_synth_event(struct synth_event *se)
+{
+	int ret;
+
+	if (se->ref)
+		ret = -EBUSY;
+	else {
+		ret = unregister_synth_event(se);
+		if (!ret) {
+			dyn_event_remove(&se->devent);
+			free_synth_event(se);
+		}
+	}
+
+	return ret;
+}
+
+/**
+ * synth_event_delete - Delete a synthetic event
+ * @event_name: The name of the new sythetic event
+ *
+ * Delete a synthetic event that was created with synth_event_create().
+ *
+ * Return: 0 if successful, error otherwise.
+ */
+int synth_event_delete(const char *event_name)
+{
+	struct synth_event *se = NULL;
+	int ret = -ENOENT;
+
+	mutex_lock(&event_mutex);
+	se = find_synth_event(event_name);
+	if (se)
+		ret = destroy_synth_event(se);
+	mutex_unlock(&event_mutex);
+
+	return ret;
+}
+EXPORT_SYMBOL_GPL(synth_event_delete);
+
 static int create_or_delete_synth_event(int argc, char **argv)
 {
 	const char *name = argv[0];
-	struct synth_event *event = NULL;
 	int ret;
 
 	/* trace_run_command() ensures argc != 0 */
 	if (name[0] == '!') {
-		mutex_lock(&event_mutex);
-		event = find_synth_event(name + 1);
-		if (event) {
-			if (event->ref)
-				ret = -EBUSY;
-			else {
-				ret = unregister_synth_event(event);
-				if (!ret) {
-					dyn_event_remove(&event->devent);
-					free_synth_event(event);
-				}
-			}
-		} else
-			ret = -ENOENT;
-		mutex_unlock(&event_mutex);
+		ret = synth_event_delete(name + 1);
 		return ret;
 	}
 
-- 
2.14.1


  parent reply	other threads:[~2020-01-24 22:57 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-01-24 22:56 [PATCH v3 00/12] tracing: Add support for in-kernel dynamic event API Tom Zanussi
2020-01-24 22:56 ` [PATCH v3 01/12] tracing: Add trace_array_find/_get() to find instance trace arrays Tom Zanussi
2020-01-24 22:56 ` [PATCH v3 02/12] tracing: Add trace_get/put_event_file() Tom Zanussi
2020-01-29 17:52   ` Steven Rostedt
2020-01-29 19:05     ` Tom Zanussi
2020-01-24 22:56 ` Tom Zanussi [this message]
2020-01-24 22:56 ` [PATCH v3 04/12] tracing: Add dynamic event command creation interface Tom Zanussi
2020-01-27 13:44   ` Masami Hiramatsu
2020-01-27 15:24     ` Tom Zanussi
2020-01-29 18:00   ` Steven Rostedt
2020-01-29 19:02     ` Tom Zanussi
2020-01-29 19:55       ` Steven Rostedt
2020-01-24 22:56 ` [PATCH v3 05/12] tracing: Add synthetic event command generation functions Tom Zanussi
2020-01-24 22:56 ` [PATCH v3 06/12] tracing: Change trace_boot to use synth_event interface Tom Zanussi
2020-01-24 22:56 ` [PATCH v3 07/12] tracing: Add synth_event_trace() and related functions Tom Zanussi
2020-01-24 22:56 ` [PATCH v3 08/12] tracing: Add synth event generation test module Tom Zanussi
2020-01-24 22:56 ` [PATCH v3 09/12] tracing: Add kprobe event command generation functions Tom Zanussi
2020-01-24 22:56 ` [PATCH v3 10/12] tracing: Change trace_boot to use kprobe_event interface Tom Zanussi
2020-01-24 22:56 ` [PATCH v3 11/12] tracing: Add kprobe event command generation test module Tom Zanussi
2020-01-24 22:56 ` [PATCH v3 12/12] tracing: Documentation for in-kernel synthetic event API Tom Zanussi
2020-01-27 13:48 ` [PATCH v3 00/12] tracing: Add support for in-kernel dynamic " Masami Hiramatsu
2020-01-27 15:28   ` 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=fb1828de7e276c5589071fe34f509a6cfba83cf7.1579904761.git.zanussi@kernel.org \
    --to=zanussi@kernel.org \
    --cc=artem.bityutskiy@linux.intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-rt-users@vger.kernel.org \
    --cc=mhiramat@kernel.org \
    --cc=ndesaulniers@google.com \
    --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).