Messages in this thread | | | Date | Wed, 25 Sep 2013 17:16:42 +0200 | From | Oleg Nesterov <> | Subject | Re: [PATCH] hotplug: Optimize {get,put}_online_cpus() |
| |
On 09/24, Peter Zijlstra wrote: > > On Tue, Sep 24, 2013 at 08:00:05PM +0200, Oleg Nesterov wrote: > > > > Yes, we need to ensure gcc doesn't reorder this code so that > > do_something() comes before get_online_cpus(). But it can't? At least > > it should check current->cpuhp_ref != 0 first? And if it is non-zero > > we do not really care, we are already in the critical section and > > this ->cpuhp_ref has only meaning in put_online_cpus(). > > > > Confused... > > > So the reason I put it in was because of the inline; it could possibly > make it do:
[...snip...]
> In which case the recursive fast path doesn't have a barrier() between > taking the ref and starting do_something().
Yes, but my point was, this can only happen in recursive fast path. And in this case (I think) we do not care, we are already in the critical section.
current->cpuhp_ref doesn't matter at all until we call put_online_cpus().
Suppose that gcc knows for sure that current->cpuhp_ref != 0. Then I think, for example,
get_online_cpus(); do_something(); put_online_cpus();
converted to
do_something(); current->cpuhp_ref++; current->cpuhp_ref--;
is fine. do_something() should not depend on ->cpuhp_ref.
OK, please forget. I guess I will never understand this ;)
Oleg.
| |