mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Lai Jiangshan <laijs@cn.fujitsu.com>
To: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Ingo Molnar <mingo@elte.hu>, Steven Rostedt <rostedt@goodmis.org>,
	LKML <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] tracing: add trace_event_read_lock()
Date: Tue, 19 May 2009 10:05:21 +0800	[thread overview]
Message-ID: <4A1213E1.8050608@cn.fujitsu.com> (raw)
In-Reply-To: <20090518135930.GC4704@nowhere>

Frederic Weisbecker wrote:
> On Mon, May 18, 2009 at 07:35:34PM +0800, Lai Jiangshan wrote:
>> I found that there is nothing to protect event_hash in
>> ftrace_find_event().
> 
> 
> 
> Actually, rcu protects it, but not enough. We have neither
> synchronize_rcu() nor rcu_read_lock.

We have no rcu_read_lock(), RCU can not protects it.

> 
> So we protect against concurrent hlist accesses.
> But the event can be removed when a module is unloaded,
> and that can happen between the time we get the event output
> callback and the time we actually use it.
> 

[...]

> It could be more fine grained.

I think it's fine-grained enough, write-side(modules loading/unloading)
is happened rarely. trace_event_read_lock() will not sleep very likely.

Thoughts?

> We could have a per event rwsem, and also place the
> protected read section only in trace_print_entry() which is the only racy window.
> 

print_trace_line() is the only racy window.
So I just protect print_trace_line()(except __ftrace_dump())

I protect loops which call print_trace_line(), it
reduces invoke-times:

trace_event_read_lock();
while (...) {
	...
	print_trace_line();
	...
}
trace_event_read_unlock();

Thanks!
Lai

> But I'm not sure it's that worthy since event removal is a rare thing.
> 
> So I guess this patch is fine.
> 
> 
> 
> 



  parent reply	other threads:[~2009-05-19  2:08 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-05-18 11:35 Lai Jiangshan
2009-05-18 13:59 ` Frederic Weisbecker
2009-05-19  0:35   ` Paul E. McKenney
2009-05-19  5:15     ` Lai Jiangshan
2009-05-19 12:38       ` Paul E. McKenney
2009-05-20  0:59         ` Frederic Weisbecker
2009-05-20  4:38           ` Paul E. McKenney
2009-05-19  2:05   ` Lai Jiangshan [this message]
2009-05-20  0:24     ` Frederic Weisbecker
2009-05-20  2:25       ` Lai Jiangshan
2009-05-20 15:41         ` Paul E. McKenney
2009-05-20 16:04         ` Steven Rostedt
2009-05-27 22:34 ` [tip:tracing/core] " tip-bot for Lai Jiangshan

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=4A1213E1.8050608@cn.fujitsu.com \
    --to=laijs@cn.fujitsu.com \
    --cc=fweisbec@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    --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

Powered by JetHome