From: Oleg Nesterov <oleg@redhat.com>
To: Ingo Molnar <mingo@redhat.com>, Steven Rostedt <rostedt@goodmis.org>
Cc: Frederic Weisbecker <fweisbec@gmail.com>,
Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>,
linux-kernel@vger.kernel.org
Subject: [PATCH 1/1] tracing: Simplify trace_array_get()
Date: Fri, 19 Jul 2013 17:51:01 +0200 [thread overview]
Message-ID: <20130719155101.GA19509@redhat.com> (raw)
In-Reply-To: <20130719155041.GA19501@redhat.com>
trace_array_get() scans the global ftrace_trace_arrays list
to ensure that "this_tr" was not removed by instance_delete().
This looks a bit confusing, we can simply use list_empty() with
the same result. list_empty() == F can not be false positive,
new_instance_create() does everything under the same lock and
tracer_alloc_buffers() which plays with global_trace is __init.
Signed-off-by: Oleg Nesterov <oleg@redhat.com>
---
kernel/trace/trace.c | 12 ++++--------
1 files changed, 4 insertions(+), 8 deletions(-)
diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
index 0cd500b..ee471fb 100644
--- a/kernel/trace/trace.c
+++ b/kernel/trace/trace.c
@@ -206,16 +206,12 @@ LIST_HEAD(ftrace_trace_arrays);
int trace_array_get(struct trace_array *this_tr)
{
- struct trace_array *tr;
int ret = -ENODEV;
mutex_lock(&trace_types_lock);
- list_for_each_entry(tr, &ftrace_trace_arrays, list) {
- if (tr == this_tr) {
- tr->ref++;
- ret = 0;
- break;
- }
+ if (!list_empty(&this_tr->list)) {
+ this_tr->ref++;
+ ret = 0;
}
mutex_unlock(&trace_types_lock);
@@ -6019,7 +6015,7 @@ static int instance_delete(const char *name)
if (tr->ref)
goto out_unlock;
- list_del(&tr->list);
+ list_del_init(&tr->list); /* trace_array_get() checks list_empty() */
event_trace_del_tracer(tr);
debugfs_remove_recursive(tr->dir);
--
1.5.5.1
next prev parent reply other threads:[~2013-07-19 15:56 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-07-19 15:50 [PATCH 0/1] tracing: Simplify trace_array_get() Oleg Nesterov
2013-07-19 15:51 ` Oleg Nesterov [this message]
2013-07-19 16:26 ` [PATCH 1/1] " Steven Rostedt
2013-07-19 16:33 ` Oleg Nesterov
2013-07-19 17:20 ` Oleg Nesterov
2013-07-19 17:35 ` Steven Rostedt
2013-07-19 17:39 ` Steven Rostedt
2013-07-19 18:24 ` Oleg Nesterov
2013-07-21 19:14 ` Oleg Nesterov
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=20130719155101.GA19509@redhat.com \
--to=oleg@redhat.com \
--cc=fweisbec@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=masami.hiramatsu.pt@hitachi.com \
--cc=mingo@redhat.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).