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
Subject: [PATCH v4 01/12] tracing: Add trace_array_find/_get() to find instance trace arrays
Date: Wed, 29 Jan 2020 12:59:21 -0600 [thread overview]
Message-ID: <cb68528c975eba95bee4561ac67dd1499423b2e5.1580323897.git.zanussi@kernel.org> (raw)
In-Reply-To: <cover.1580323897.git.zanussi@kernel.org>
In-Reply-To: <cover.1580323897.git.zanussi@kernel.org>
Add a new trace_array_find() function that can be used to find a trace
array given the instance name, and replace existing code that does the
same thing with it. Also add trace_array_find_get() which does the
same but returns the trace array after upping its refcount.
Also make both available for use outside of trace.c.
Signed-off-by: Tom Zanussi <zanussi@kernel.org>
Acked-by: Masami Hiramatsu <mhiramat@kernel.org>
---
kernel/trace/trace.c | 43 +++++++++++++++++++++++++++++++++----------
kernel/trace/trace.h | 2 ++
2 files changed, 35 insertions(+), 10 deletions(-)
diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
index 6a28b1b9bf42..6e415057d373 100644
--- a/kernel/trace/trace.c
+++ b/kernel/trace/trace.c
@@ -8501,6 +8501,34 @@ static void update_tracer_options(struct trace_array *tr)
mutex_unlock(&trace_types_lock);
}
+/* Must have trace_types_lock held */
+struct trace_array *trace_array_find(const char *instance)
+{
+ struct trace_array *tr, *found = NULL;
+
+ list_for_each_entry(tr, &ftrace_trace_arrays, list) {
+ if (tr->name && strcmp(tr->name, instance) == 0) {
+ found = tr;
+ break;
+ }
+ }
+
+ return found;
+}
+
+struct trace_array *trace_array_find_get(const char *instance)
+{
+ struct trace_array *tr;
+
+ mutex_lock(&trace_types_lock);
+ tr = trace_array_find(instance);
+ if (tr)
+ tr->ref++;
+ mutex_unlock(&trace_types_lock);
+
+ return tr;
+}
+
static struct trace_array *trace_array_create(const char *name)
{
struct trace_array *tr;
@@ -8577,10 +8605,8 @@ static int instance_mkdir(const char *name)
mutex_lock(&trace_types_lock);
ret = -EEXIST;
- list_for_each_entry(tr, &ftrace_trace_arrays, list) {
- if (tr->name && strcmp(tr->name, name) == 0)
- goto out_unlock;
- }
+ if (trace_array_find(name))
+ goto out_unlock;
tr = trace_array_create(name);
@@ -8708,12 +8734,9 @@ static int instance_rmdir(const char *name)
mutex_lock(&trace_types_lock);
ret = -ENODEV;
- list_for_each_entry(tr, &ftrace_trace_arrays, list) {
- if (tr->name && strcmp(tr->name, name) == 0) {
- ret = __remove_instance(tr);
- break;
- }
- }
+ tr = trace_array_find(name);
+ if (tr)
+ ret = __remove_instance(tr);
mutex_unlock(&trace_types_lock);
mutex_unlock(&event_mutex);
diff --git a/kernel/trace/trace.h b/kernel/trace/trace.h
index 6bb64d89c321..0db5341c113d 100644
--- a/kernel/trace/trace.h
+++ b/kernel/trace/trace.h
@@ -358,6 +358,8 @@ extern struct mutex trace_types_lock;
extern int trace_array_get(struct trace_array *tr);
extern int tracing_check_open_get_tr(struct trace_array *tr);
+extern struct trace_array *trace_array_find(const char *instance);
+extern struct trace_array *trace_array_find_get(const char *instance);
extern int tracing_set_time_stamp_abs(struct trace_array *tr, bool abs);
extern int tracing_set_clock(struct trace_array *tr, const char *clockstr);
--
2.14.1
next prev parent reply other threads:[~2020-01-29 19:01 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-01-29 18:59 [PATCH v4 00/12] tracing: Add support for in-kernel dynamic event API Tom Zanussi
2020-01-29 18:59 ` Tom Zanussi [this message]
2020-01-29 21:14 ` [PATCH v4 01/12] tracing: Add trace_array_find/_get() to find instance trace arrays Steven Rostedt
2020-01-29 18:59 ` [PATCH v4 02/12] tracing: Add trace_get/put_event_file() Tom Zanussi
2020-01-29 18:59 ` [PATCH v4 03/12] tracing: Add synth_event_delete() Tom Zanussi
2020-01-29 18:59 ` [PATCH v4 04/12] tracing: Add dynamic event command creation interface Tom Zanussi
2020-01-30 2:40 ` Masami Hiramatsu
2020-01-30 2:58 ` Steven Rostedt
2020-01-29 18:59 ` [PATCH v4 05/12] tracing: Add synthetic event command generation functions Tom Zanussi
2020-01-29 18:59 ` [PATCH v4 06/12] tracing: Change trace_boot to use synth_event interface Tom Zanussi
2020-01-31 17:49 ` Tom Zanussi
2020-01-31 17:55 ` Steven Rostedt
2020-01-31 18:00 ` Steven Rostedt
2020-01-31 18:01 ` Tom Zanussi
2020-01-29 18:59 ` [PATCH v4 07/12] tracing: Add synth_event_trace() and related functions Tom Zanussi
2020-01-29 21:09 ` Steven Rostedt
2020-01-29 22:58 ` Tom Zanussi
2020-01-30 3:01 ` Steven Rostedt
2020-01-29 18:59 ` [PATCH v4 08/12] tracing: Add synth event generation test module Tom Zanussi
2020-01-29 18:59 ` [PATCH v4 09/12] tracing: Add kprobe event command generation functions Tom Zanussi
2020-01-29 18:59 ` [PATCH v4 10/12] tracing: Change trace_boot to use kprobe_event interface Tom Zanussi
2020-01-29 18:59 ` [PATCH v4 11/12] tracing: Add kprobe event command generation test module Tom Zanussi
2020-01-29 18:59 ` [PATCH v4 12/12] tracing: Documentation for in-kernel synthetic event API 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=cb68528c975eba95bee4561ac67dd1499423b2e5.1580323897.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=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).