BPF List
 help / color / mirror / Atom feed
From: Yonghong Song <yonghong.song@linux.dev>
To: Alexei Starovoitov <alexei.starovoitov@gmail.com>
Cc: bpf <bpf@vger.kernel.org>, Alexei Starovoitov <ast@kernel.org>,
	Andrii Nakryiko <andrii@kernel.org>,
	Daniel Borkmann <daniel@iogearbox.net>,
	Kernel Team <kernel-team@fb.com>,
	Martin KaFai Lau <martin.lau@kernel.org>,
	"Kirill A . Shutemov" <kirill.shutemov@linux.intel.com>
Subject: Re: [PATCH bpf-next v2] bpf: Do not allocate percpu memory at init stage
Date: Fri, 10 Nov 2023 13:05:07 -0800	[thread overview]
Message-ID: <82346298-c730-43ff-a53f-801dc209617f@linux.dev> (raw)
In-Reply-To: <CAADnVQJ2b8UNmzOLAQQbZXxanyPDSd7uv+j=xdh=g9pQCzKi5Q@mail.gmail.com>


On 11/10/23 12:32 PM, Alexei Starovoitov wrote:
> On Fri, Nov 10, 2023 at 9:23 AM Yonghong Song <yonghong.song@linux.dev> 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.


      reply	other threads:[~2023-11-10 21:05 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-11-10 17:20 [PATCH bpf-next v2] bpf: Do not allocate percpu memory at init stage Yonghong Song
2023-11-10 20:32 ` Alexei Starovoitov
2023-11-10 21:05   ` Yonghong Song [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=82346298-c730-43ff-a53f-801dc209617f@linux.dev \
    --to=yonghong.song@linux.dev \
    --cc=alexei.starovoitov@gmail.com \
    --cc=andrii@kernel.org \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=kernel-team@fb.com \
    --cc=kirill.shutemov@linux.intel.com \
    --cc=martin.lau@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox