Jakub Kicinski <jakub.kicin...@netronome.com> writes: > On Mon, 04 Mar 2019 20:05:30 +0100, Toke Høiland-Jørgensen wrote: >> > Hm. I think you'll still need a lock (mutex?) on the alloc path, but >> > the free path should be fine as long as you load the map pointer before >> > looking at the refcnt (atomic op ensuring the barrier there). >> >> Yeah, for the per-namespace refcnt it's pretty straight forward, the >> trouble is the global count that needs to iterate over all namespaces; >> probably need to put that all behind a (non-spin)lock, right? > > Because net iteration is under RCU? You can switch to taking net_rwsem > for that one, no? I'm probably confused again ;)
Because there's a single refcount that needs to trigger creation/deletion of *all* the default maps. I.e. if (atomic_dec_return(&global_refcnt)) for_each_namespace(net) destroy_default_map(net); which needs to not step on the toes of a subsequent if (atomic_inc_return(&global_refcnt) == 1) for_each_namespace(net) create_default_map(net); (or vice versa, of course). Not sure there's a way to do that without wrapping both of those constructs (including the refcnt inc/dec) in a mutex? -Toke