On Mon 18 Feb 2019 at 19:08, Cong Wang <xiyou.wangc...@gmail.com> wrote: > On Wed, Feb 13, 2019 at 11:47 PM Vlad Buslov <vla...@mellanox.com> wrote: >> >> Flower classifier only changes root pointer during init and destroy. Cls >> API implements reference counting for tcf_proto, so there is no danger of >> concurrent access to tp when it is being destroyed, even without protection >> provided by rtnl lock. > > How about atomicity? Refcnt doesn't guarantee atomicity, how do > you make sure two concurrent modifications are atomic?
In order to guarantee atomicity I lock shared flower classifier data structures with tp->lock in following patches. > > >> >> Implement new function fl_head_dereference() to dereference tp->root >> without checking for rtnl lock. Use it in all flower function that obtain >> head pointer instead of rtnl_dereference(). >> > > So what lock protects RCU writers after this patch? I explained it in comment for fl_head_dereference(), but should have copied this information to changelog as well: Flower classifier only changes root pointer during init and destroy. Cls API implements reference counting for tcf_proto, so there is no danger of concurrent access to tp when it is being destroyed, even without protection provided by rtnl lock. In initial version of this change I used tp->lock to protect tp->root access and verified it with lockdep, but during internal review Jiri noted that this is not needed in current flower implementation.