On Tue, May 14, 2019 at 8:16 PM Alexei Starovoitov <alexei.starovoitov@xxxxxxxxx> wrote: > > On Tue, May 14, 2019 at 07:56:36PM -0700, Stanislav Fomichev wrote: > > On 05/14, Eric Dumazet wrote: > > > > > > > > > On 5/14/19 7:27 PM, Alexei Starovoitov wrote: > > > > > > > what about activate_effective_progs() ? > > > > I wouldn't want to lose the annotation there. > > > > but then array_free will lose it? > > It would not have have it because the input is the result of > > bpf_prog_array_alloc() which returns kmalloc'd pointer (and > > is not bound to an rcu section). > > > > > > in some cases it's called without mutex in a destruction path. > > Hm, can you point me to this place? I think I checked every path, > > maybe I missed something subtle. I'll double check. > > I thought cgroup dying thingy is not doing it, but looks like it is. I was looking at the following chain: css_release_work_fn mutex_lock(&cgroup_mutex); cgroup_bpf_put bpf_prog_array_free mutex_unlock(&cgroup_mutex); I'll take another look tomorrow with a fresh mind :-) > > > > also how do you propose to solve different 'mtx' in > > > > lockdep_is_held(&mtx)); ? > > > > passing it through the call chain is imo not clean. > > Every caller would know which mutex protects it. As Eric said below, > > I'm adding a bunch of xxx_dereference macros that hardcode mutex, like > > the existing rtnl_dereference. > > I have a hard time imagining how it will look without being a mess. > There are three mutexes to pass down instead of single rtnl_derefernce: > cgroup_mutex, ir_raw_handler_lock, bpf_event_mutex. We don't need to pass them down, we need those xxx_dereference wrappers only in the callers of those apis. They are private to cgroup.c/lirc.c/bpf_trace.c. Take a look at the patches 2-4 in the current series where I convert the callers. (Though, I'd rename xxx_dereference to xxx_rcu_dereference for clarity we get to a v2). > > Anyway, let's see how the patches look and discuss further.