Re: [PATCH bpf-next v2] bpf: Do not allocate percpu memory at init stage

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




On 11/10/23 12:32 PM, Alexei Starovoitov wrote:
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,

That is true. deadlock situation won't happen.

but let's just add another mutex to protect percpu_ma init.
Much easier to reason about.

Okay. will do.





[Index of Archives]     [Linux Samsung SoC]     [Linux Rockchip SoC]     [Linux Actions SoC]     [Linux for Synopsys ARC Processors]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]


  Powered by Linux