[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <CAMB2axOUU5J4Ec=tuBDYePzucw1QQLciFWC01=eVQdPOhT1BGQ@mail.gmail.com>
Date: Fri, 3 Oct 2025 15:03:37 -0700
From: Amery Hung <ameryhung@...il.com>
To: Alexei Starovoitov <alexei.starovoitov@...il.com>
Cc: bpf <bpf@...r.kernel.org>, Network Development <netdev@...r.kernel.org>,
Andrii Nakryiko <andrii@...nel.org>, Daniel Borkmann <daniel@...earbox.net>,
Kumar Kartikeya Dwivedi <memxor@...il.com>, Martin KaFai Lau <martin.lau@...nel.org>, KP Singh <kpsingh@...nel.org>,
Yonghong Song <yonghong.song@...ux.dev>, Song Liu <song@...nel.org>, Hao Luo <haoluo@...gle.com>,
Kernel Team <kernel-team@...a.com>
Subject: Re: [RFC PATCH bpf-next v2 06/12] bpf: Change local_storage->lock and
b->lock to rqspinlock
On Thu, Oct 2, 2025 at 4:37 PM Alexei Starovoitov
<alexei.starovoitov@...il.com> wrote:
>
> On Thu, Oct 2, 2025 at 3:54 PM Amery Hung <ameryhung@...il.com> wrote:
> >
> > bpf_selem_free_list(&old_selem_free_list, false);
> > if (alloc_selem) {
> > mem_uncharge(smap, owner, smap->elem_size);
> > @@ -791,7 +812,7 @@ void bpf_local_storage_destroy(struct bpf_local_storage *local_storage)
> > * when unlinking elem from the local_storage->list and
> > * the map's bucket->list.
> > */
> > - raw_spin_lock_irqsave(&local_storage->lock, flags);
> > + while (raw_res_spin_lock_irqsave(&local_storage->lock, flags));
>
> This pattern and other while(foo) doesn't make sense to me.
> res_spin_lock will fail only on deadlock or timeout.
> We should not spin, since retry will likely produce the same
> result. So the above pattern just enters into infinite spin.
I only spin in destroy() and map_free(), which cannot deadlock with
itself or each other. However, IIUC, a head waiter that detects
deadlock will cause other queued waiters to also return -DEADLOCK. I
think they should be able to make progress with a retry. Or better if
rqspinlock does not force queued waiters to exit the queue if it is
deadlock not timeout.
>
> If it should never fail in practice then pr_warn_once and goto out
> leaking memory. Better yet defer to irq_work and cleanup there.
Hmm, both functions are already called in some deferred callbacks.
Even if we defer the cleanup again, they still need to grab locks and
still might fail, no?
Powered by blists - more mailing lists