From: Peter Zijlstra <peterz@infradead.org>
To: Ruan Bonan <bonan.ruan@u.nus.edu>
Cc: Steven Rostedt <rostedt@goodmis.org>,
Alexei Starovoitov <alexei.starovoitov@gmail.com>,
"mingo@redhat.com" <mingo@redhat.com>,
"will@kernel.org" <will@kernel.org>,
"longman@redhat.com" <longman@redhat.com>,
"boqun.feng@gmail.com" <boqun.feng@gmail.com>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"kpsingh@kernel.org" <kpsingh@kernel.org>,
"mattbobrowski@google.com" <mattbobrowski@google.com>,
"ast@kernel.org" <ast@kernel.org>,
"daniel@iogearbox.net" <daniel@iogearbox.net>,
"andrii@kernel.org" <andrii@kernel.org>,
"martin.lau@linux.dev" <martin.lau@linux.dev>,
"eddyz87@gmail.com" <eddyz87@gmail.com>,
"song@kernel.org" <song@kernel.org>,
"yonghong.song@linux.dev" <yonghong.song@linux.dev>,
"john.fastabend@gmail.com" <john.fastabend@gmail.com>,
"sdf@fomichev.me" <sdf@fomichev.me>,
"haoluo@google.com" <haoluo@google.com>,
"jolsa@kernel.org" <jolsa@kernel.org>,
"mhiramat@kernel.org" <mhiramat@kernel.org>,
"mathieu.desnoyers@efficios.com" <mathieu.desnoyers@efficios.com>,
"bpf@vger.kernel.org" <bpf@vger.kernel.org>,
"linux-trace-kernel@vger.kernel.org"
<linux-trace-kernel@vger.kernel.org>,
"netdev@vger.kernel.org" <netdev@vger.kernel.org>,
Fu Yeqi <e1374359@u.nus.edu>
Subject: Re: [BUG] possible deadlock in __schedule (with reproducer available)
Date: Mon, 25 Nov 2024 10:44:26 +0100 [thread overview]
Message-ID: <20241125094426.GO39245@noisy.programming.kicks-ass.net> (raw)
In-Reply-To: <5489FB30-8B09-4F74-9C2B-FF25F4654A3F@u.nus.edu>
On Mon, Nov 25, 2024 at 05:24:05AM +0000, Ruan Bonan wrote:
> From the discussion, it appears that the root cause might involve
> specific printk or BPF operations in the given context. To clarify and
> possibly avoid similar issues in the future, are there guidelines or
> best practices for writing BPF programs/hooks that interact with
> tracepoints, especially those related to scheduler events, to prevent
> such deadlocks?
The general guideline and recommendation for all tracepoints is to be
wait-free. Typically all tracer code should be.
Now, BPF (users) (ab)uses tracepoints to do all sorts and takes certain
liberties with them, but it is very much at the discretion of the BPF
user.
Slightly relaxed guideline would perhaps be to consider the context of
the tracepoint, notably one of: NMI, IRQ, SoftIRQ or Task context -- and
to not exceed the bounds of the given context.
More specifically, when the tracepoint is inside critical sections of
any sort (as is the case here) then it very much is on the BPF user to
not cause inversions.
At this point there really is no substitute for knowing what you're
doing. Knowledge is key.
In short; tracepoints should be wait-free, if you know what you're doing
you can perhaps get away with a little more.
next prev parent reply other threads:[~2024-11-25 9:44 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-11-23 3:39 [BUG] possible deadlock in __schedule (with reproducer available) Ruan Bonan
2024-11-23 20:27 ` Peter Zijlstra
2024-11-23 23:00 ` Steven Rostedt
2024-11-25 2:02 ` Alexei Starovoitov
2024-11-25 3:30 ` Steven Rostedt
2024-11-25 3:44 ` Steven Rostedt
2024-11-25 5:24 ` Ruan Bonan
2024-11-25 9:44 ` Peter Zijlstra [this message]
2024-11-26 21:15 ` Andrii Nakryiko
2024-11-29 8:35 ` Masami Hiramatsu
2024-11-29 12:09 ` Peter Zijlstra
2024-12-01 12:53 ` Akinobu Mita
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=20241125094426.GO39245@noisy.programming.kicks-ass.net \
--to=peterz@infradead.org \
--cc=alexei.starovoitov@gmail.com \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=bonan.ruan@u.nus.edu \
--cc=boqun.feng@gmail.com \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=e1374359@u.nus.edu \
--cc=eddyz87@gmail.com \
--cc=haoluo@google.com \
--cc=john.fastabend@gmail.com \
--cc=jolsa@kernel.org \
--cc=kpsingh@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-trace-kernel@vger.kernel.org \
--cc=longman@redhat.com \
--cc=martin.lau@linux.dev \
--cc=mathieu.desnoyers@efficios.com \
--cc=mattbobrowski@google.com \
--cc=mhiramat@kernel.org \
--cc=mingo@redhat.com \
--cc=netdev@vger.kernel.org \
--cc=rostedt@goodmis.org \
--cc=sdf@fomichev.me \
--cc=song@kernel.org \
--cc=will@kernel.org \
--cc=yonghong.song@linux.dev \
/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;
as well as URLs for NNTP newsgroup(s).