Messages in this thread | | | Date | Mon, 24 Jan 2011 12:51:56 +0100 | From | Oleg Nesterov <> | Subject | Re: [PATCH] perf: perf_event_exit_task_context: s/rcu_dereference/rcu_dereference_raw/ |
| |
On 01/21, Paul E. McKenney wrote: > > On Fri, Jan 21, 2011 at 06:53:45PM +0100, Oleg Nesterov wrote: > > > > But rcu_dereference_raw() looks a bit confusing, and it is not > > very convenient to use read_barrier_depends() directly. > > > > Paul, may be it makes sense to add the new trivial helper which > > can be used instead? > > > > Yes, this is only cosmetic issue, I know ;) > > Cosmetic issues can be pretty important to the poor guy trying to read > the code. ;-)
Agreed!
> What keeps the structure that rcu_dereference_raw() returns a pointer > to from going away?
It can't go away, current owns its ->perf_event_ctxp[] pointers. But the pointer can be installed at any time by sys_perf_event_open().
Currently the code does
ctx = current->perf_event_ctxp[ctxn]; if (ctx) do_something(ctx);
and in theory we need smp_read_barrier_depends() in between.
> Best would be if a lockdep condition could be > constructed from the answer to this question and added to the appropriate > rcu_dereference() primitive.
In this case the condition is "true", so we can use rcu_dereference_raw(). The only problem, it looks confusing. Especially because you actually need rcu_read_lock() if you look at not_current_task->perf_event_ctxp[].
Oleg.
| |