From: Steven Rostedt <rostedt@goodmis.org>
To: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
Cc: Alexei Starovoitov <alexei.starovoitov@gmail.com>,
John Ogness <john.ogness@linutronix.de>,
Alexei Starovoitov <ast@kernel.org>,
Daniel Borkmann <daniel@iogearbox.net>,
Andrii Nakryiko <andrii@kernel.org>,
Martin KaFai Lau <martin.lau@linux.dev>,
Eduard Zingerman <eddyz87@gmail.com>, Song Liu <song@kernel.org>,
Yonghong Song <yonghong.song@linux.dev>,
John Fastabend <john.fastabend@gmail.com>,
KP Singh <kpsingh@kernel.org>,
Stanislav Fomichev <sdf@fomichev.me>, Hao Luo <haoluo@google.com>,
Jiri Olsa <jolsa@kernel.org>, Petr Mladek <pmladek@suse.com>,
Sergey Senozhatsky <senozhatsky@chromium.org>,
bpf <bpf@vger.kernel.org>, LKML <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] bpf: defer printk() inside __bpf_prog_run()
Date: Wed, 26 Jun 2024 18:33:11 -0400 [thread overview]
Message-ID: <20240626183311.05eaf091@rorschach.local.home> (raw)
In-Reply-To: <f6c23073-dc0d-4b3f-b37d-1edb82737b5b@I-love.SAKURA.ne.jp>
On Thu, 27 Jun 2024 07:15:25 +0900
Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp> wrote:
> On 2024/06/27 1:27, Steven Rostedt wrote:
> > On Wed, 26 Jun 2024 09:02:22 +0900
> > Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp> wrote:
> >
> >> On 2024/06/26 8:56, Alexei Starovoitov wrote:
> >>> You are missing the point. The bug has nothing to do with bpf.
> >>
> >> The bug is caused by calling tracing hooks with rq lock held.
> >> If tracing hooks do not exist, this bug does not exist.
> >
> > Could you expand on this. What tracing hooks are called with rq lock
> > held? You mean the scheduling events?
>
> Yes, trace_sched_switch().
> __schedule() calls trace_sched_switch() hook with rq lock held.
>
> #2: ffff8880b943e798 (&rq->__lock){-.-.}-{2:2}, at: raw_spin_rq_lock_nested+0x2a/0x140 kernel/sched/core.c:559
>
> __bpf_prog_run include/linux/filter.h:691 [inline]
> bpf_prog_run include/linux/filter.h:698 [inline]
> __bpf_trace_run kernel/trace/bpf_trace.c:2403 [inline]
> bpf_trace_run4+0x334/0x590 kernel/trace/bpf_trace.c:2446
> __traceiter_sched_switch+0x98/0xd0 include/trace/events/sched.h:222
> trace_sched_switch include/trace/events/sched.h:222 [inline]
> __schedule+0x2587/0x4a20 kernel/sched/core.c:6742
> preempt_schedule_notrace+0x100/0x140 kernel/sched/core.c:7017
So you are saying that because a BPF hook can attach to a tracepoint
that is called with rq locks held, it should always disable preemption
and call printk_deferred_enter(), because it *might* hit an error path
that will call printk?? In other words, how the BPF hook is used
determines if the rq lock is held or not when it is called.
I can use that same argument for should_fail_ex(). Because how it is
used determines if the rq lock is held or not when it is called. And it
is the function that actually calls printk().
Sorry, but it makes no sense to put the burden of the
printk_deferred_enter() on the BPF hook logic. It should sit solely
with the code that actually calls printk().
-- Steve
next prev parent reply other threads:[~2024-06-26 22:33 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-06-25 13:56 [PATCH] bpf: defer printk() inside __bpf_prog_run() Tetsuo Handa
2024-06-25 14:17 ` John Ogness
2024-06-25 15:07 ` Tetsuo Handa
2024-06-25 15:47 ` John Ogness
2024-06-25 16:05 ` Tetsuo Handa
2024-06-25 19:32 ` Alexei Starovoitov
2024-06-25 23:52 ` Tetsuo Handa
2024-06-25 23:56 ` Alexei Starovoitov
2024-06-26 0:02 ` Tetsuo Handa
2024-06-26 16:27 ` Steven Rostedt
2024-06-26 22:15 ` Tetsuo Handa
2024-06-26 22:33 ` Steven Rostedt [this message]
2024-06-26 23:08 ` Tetsuo Handa
2024-06-26 23:52 ` Alexei Starovoitov
2024-06-27 0:00 ` Tetsuo Handa
2024-06-27 0:09 ` Steven Rostedt
2024-06-27 0:21 ` Tetsuo Handa
2024-06-27 0:29 ` Steven Rostedt
2024-06-27 11:10 ` [PATCH] sched/core: defer printk() while rq lock is held Tetsuo Handa
2024-06-26 8:45 ` [PATCH] bpf: defer printk() inside __bpf_prog_run() Petr Mladek
2024-06-26 8:18 ` Petr Mladek
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=20240626183311.05eaf091@rorschach.local.home \
--to=rostedt@goodmis.org \
--cc=alexei.starovoitov@gmail.com \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=eddyz87@gmail.com \
--cc=haoluo@google.com \
--cc=john.fastabend@gmail.com \
--cc=john.ogness@linutronix.de \
--cc=jolsa@kernel.org \
--cc=kpsingh@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=martin.lau@linux.dev \
--cc=penguin-kernel@I-love.SAKURA.ne.jp \
--cc=pmladek@suse.com \
--cc=sdf@fomichev.me \
--cc=senozhatsky@chromium.org \
--cc=song@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