From: Kumar Kartikeya Dwivedi <memxor@gmail.com>
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>,
Martin KaFai Lau <martin.lau@kernel.org>
Subject: Re: [PATCH RFC bpf-next v1 1/2] bpf: Fix deadlock for bpf_timer's spinlock
Date: Tue, 8 Nov 2022 04:43:56 +0530 [thread overview]
Message-ID: <20221107231356.qaotvqi7dgojacly@apollo> (raw)
In-Reply-To: <CAADnVQKGd20kh_4xcEFMi365bOt0KtDwkYnzZsZP=vioVX3mGw@mail.gmail.com>
On Mon, Nov 07, 2022 at 09:15:26AM IST, Alexei Starovoitov wrote:
> On Sun, Nov 6, 2022 at 6:34 PM Alexei Starovoitov
> <alexei.starovoitov@gmail.com> wrote:
> >
> > >
> > > For bpf_timer, it would mean moving drop_prog_refcnt outside spin lock critical
> > > section. hrtimer_cancel is already done after the unlock. For bpf_list_head, it
>
> > > would mean swapping out the list_head and then draining it outside the lock.
> >
> > That also works.
> > drop_prog_refcnt() can be moved after unlock.
> > Don't see any race.
>
> I mean not the whole function obviously.
> Instead of
> static void drop_prog_refcnt(struct bpf_hrtimer *t)
> it can become
> static struct bpf_prog *drop_prog_refcnt(struct bpf_hrtimer *t)
> t->prog and callback_fn should only be manipulated
> under lock.
> bpf_prog_put itself can happen after unlock.
Right, both t->prog and t->callback_fn need to be set to NULL under the lock.
I will send out the bpf_timer change separately. For now, I moved list draining
out of the lock in my series and removed the check on BPF_PROG_TYPE_TRACING, and
posted it.
next prev parent reply other threads:[~2022-11-07 23:14 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-11-06 1:51 [PATCH RFC bpf-next v1 0/2] Fix deadlock with bpf_timer in fentry/fexit progs Kumar Kartikeya Dwivedi
2022-11-06 1:51 ` [PATCH RFC bpf-next v1 1/2] bpf: Fix deadlock for bpf_timer's spinlock Kumar Kartikeya Dwivedi
2022-11-06 21:20 ` Alexei Starovoitov
2022-11-06 21:44 ` Kumar Kartikeya Dwivedi
2022-11-07 0:31 ` Alexei Starovoitov
2022-11-07 1:48 ` Kumar Kartikeya Dwivedi
2022-11-07 2:34 ` Alexei Starovoitov
2022-11-07 3:45 ` Alexei Starovoitov
2022-11-07 23:13 ` Kumar Kartikeya Dwivedi [this message]
2022-11-06 1:51 ` [PATCH RFC bpf-next v1 2/2] [EXAMPLE] selftests/bpf: Add timer deadlock example Kumar Kartikeya Dwivedi
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=20221107231356.qaotvqi7dgojacly@apollo \
--to=memxor@gmail.com \
--cc=alexei.starovoitov@gmail.com \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--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