[ovs-dev] [PATCH 07/18] lib/ovs-thread: Avoid atomic read in ovsthread_once_start().
blp at nicira.com
Fri Aug 29 21:12:05 UTC 2014
On Fri, Aug 29, 2014 at 02:11:26PM -0700, Jarno Rajahalme wrote:
> On Aug 28, 2014, at 9:42 AM, Ben Pfaff <blp at nicira.com> wrote:
> > On Fri, Aug 22, 2014 at 01:58:18PM -0700, Jarno Rajahalme wrote:
> >> Avoiding the atomic read may help if a function using
> >> ovsthread_once_start() is ever called in a loop, as the new
> >> 'maybe_not_done' can be kept in a register. The atomic read will
> >> still be done as long as 'maybe_not_done' is true. Since
> >> 'maybe_not_done' is not an atomic variable, whis may happen
> >> indefinitely, but if a loop starts with 'maybe_not_done' as false, no
> >> atomic read operations are needed.
> >> Signed-off-by: Jarno Rajahalme <jrajahalme at nicira.com>
> > It seems reasonable to have a cheaper test like this, but I don't think
> > that if we do that we need to also inline the more expensive test. In
> > other words, I think we could drop the call to
> > ovsthread_once_is_done__() from ovsthread_once_start(). (After that we
> > can move ovsthread_once_is_done__() into ovs-thread.c.)
> How about getting rid of the atomic variable and just is a bool. On
> false negatives we first need to take the mutex anyway to have the
> thread wait for the initialization to complete, and after ?once" is
> done, the first unnecessary (if any) mutex_lock will synchronize
> memory and after that the old ?done? value can not be cached any
It sounds clean.
> I?ll post this in v2 for you to review.
More information about the dev