On Fri, Nov 10, 2023 at 9:23 AM Yonghong Song <yonghong.song@xxxxxxxxx> wrote: > > + if (meta.func_id == special_kfunc_list[KF_bpf_percpu_obj_new_impl]) { > + if (!bpf_global_percpu_ma_set) { > + mutex_lock(&bpf_verifier_lock); > + if (!bpf_global_percpu_ma_set) { > + err = bpf_mem_alloc_init(&bpf_global_percpu_ma, 0, true); > + if (!err) > + bpf_global_percpu_ma_set = true; > + } > + mutex_unlock(&bpf_verifier_lock); I feel we're taking unnecessary risk here by reusing the mutex. bpf_obj_new kfunc is a privileged operation and the verifier lock is not held in such scenario, so it won't deadlock, but let's just add another mutex to protect percpu_ma init. Much easier to reason about.