From: Petr Mladek <pmladek@suse.com>
To: John Ogness <john.ogness@linutronix.de>
Cc: Tetsuo Handa <penguin-kernel@i-love.sakura.ne.jp>,
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>,
Steven Rostedt <rostedt@goodmis.org>,
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 10:18:08 +0200 [thread overview]
Message-ID: <ZnvOwGk0cqpx4kkk@pathway.suse.cz> (raw)
In-Reply-To: <87ikxxxbwd.fsf@jogness.linutronix.de>
On Tue 2024-06-25 17:53:14, John Ogness wrote:
> On 2024-06-26, Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp> wrote:
> > On 2024/06/25 23:17, John Ogness wrote:
> >> On 2024-06-25, Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp> wrote:
> >>> syzbot is reporting circular locking dependency inside __bpf_prog_run(),
> >>> for fault injection calls printk() despite rq lock is already held.
> >>>
> >>> Guard __bpf_prog_run() using printk_deferred_{enter,exit}() (and
> >>> preempt_{disable,enable}() if CONFIG_PREEMPT_RT=n) in order to defer any
> >>> printk() messages.
> >>
> >> Why is the reason for disabling preemption?
> >
> > Because since kernel/printk/printk_safe.c uses a percpu counter for deferring
> > printk(), printk_safe_enter() and printk_safe_exit() have to be called from
> > the same CPU. preempt_disable() before printk_safe_enter() and preempt_enable()
> > after printk_safe_exit() guarantees that printk_safe_enter() and
> > printk_safe_exit() are called from the same CPU.
>
> Yes, but we already have cant_migrate(). Are you suggesting there are
> configurations where cant_migrate() is true but the context can be
> migrated anyway?
IMHO, we want to enter printk_safe only with preemption disabled.
Otherwise, printk() would stay deferred on the given CPU for any
task scheduled in this section.
Best Regards,
Petr
prev parent reply other threads:[~2024-06-26 8:18 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
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 [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=ZnvOwGk0cqpx4kkk@pathway.suse.cz \
--to=pmladek@suse.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=rostedt@goodmis.org \
--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