[ovs-dev] [PATCH] datapath: Wait for grace period before deleting a datapath.

Jesse Gross jesse at nicira.com
Wed Jan 5 20:10:05 UTC 2011


On Wed, Jan 5, 2011 at 12:34 PM, Ben Pfaff <blp at nicira.com> wrote:
> On Wed, Jan 05, 2011 at 08:33:58AM -0800, Jesse Gross wrote:
>> When deleting a datapath, we remove all of the vports and then immediately
>> free the datapath data structures.  Since the vports are allowed to use
>> call_rcu() to free their data, it's possible for them to return immediately
>> while packet processing is still taking place.  This adds an explicit
>> synchronize_rcu() call to wait for a grace period after all references
>> have been dropped.
>>
>> This race cannot actually occur in practice since the last port to be
>> deleted is an internal device, which uses synchronize_rcu() itself
>> (implicitly through unregister_netdevice()).  However, there is no
>> requirement that it must do this nor should there be.
>>
>> Reported-by: Ben Pfaff <blp at nicira.com>
>> Signed-off-by: Jesse Gross <jesse at nicira.com>
>
> If it's guaranteed that unregister_netdevice() synchronizes against RCU,
> then I'm not sure that I like waiting for a second grace period.  It's a
> waste of time then.  It might be better to add a comment explaining why
> it's safe.

I wouldn't say that it is guaranteed - that's just how it's
implemented.  It's conceivable, though probably unlikely, that it
could be replaced with a non-blocking implementation.  I don't think
that it is a good idea to rely on the side-effects to protect some
unrelated data structures.

It's not that hard to implement this as an RCU callback though, which
provides basically the same benefits without requiring additional
guarantees.  I'll implement that instead.




More information about the dev mailing list