From: "Kumar Kartikeya Dwivedi" <memxor@gmail.com>
To: "Michal Hocko" <mhocko@suse.com>,
"Jiayuan Chen" <jiayuan.chen@linux.dev>
Cc: <bpf@vger.kernel.org>, "Emil Tsalapatis" <emil@etsalapatis.com>,
"Alexei Starovoitov" <ast@kernel.org>,
"Daniel Borkmann" <daniel@iogearbox.net>,
"John Fastabend" <john.fastabend@gmail.com>,
"Andrii Nakryiko" <andrii@kernel.org>,
"Eduard Zingerman" <eddyz87@gmail.com>,
"Martin KaFai Lau" <martin.lau@linux.dev>,
"Song Liu" <song@kernel.org>,
"Yonghong Song" <yonghong.song@linux.dev>,
"Jiri Olsa" <jolsa@kernel.org>,
"Ihor Solodrai" <ihor.solodrai@linux.dev>,
"Sebastian Andrzej Siewior" <bigeasy@linutronix.de>,
"Clark Williams" <clrkwllms@kernel.org>,
"Steven Rostedt" <rostedt@goodmis.org>,
<linux-kernel@vger.kernel.org>, <linux-rt-devel@lists.linux.dev>
Subject: Re: [PATCH bpf-next v4 1/4] bpf: Add a sleepable page allocator for map memory
Date: Mon, 24 Aug 2026 15:11:57 +0200 [thread overview]
Message-ID: <DKX77B18XF28.LG3DX8NUFQGI@gmail.com> (raw)
In-Reply-To: <aoxAo6gDK00PeCzG@tiehlicka>
On Mon Aug 24, 2026 at 3:01 PM CEST, Michal Hocko wrote:
> On Mon 24-08-26 20:44:18, Jiayuan Chen wrote:
>>
>> On 8/24/26 8:26 PM, Michal Hocko wrote:
>> > On Fri 21-08-26 13:06:12, Jiayuan Chen wrote:
>> > > bpf_map_alloc_pages() picks the allocator via can_alloc_pages(), a
>> > > conservative guess for BPF program context that is always false under
>> > > PREEMPT_RT. So even a caller that really is sleepable gets the
>> > > non-blocking allocator, which never reclaims and never engages the OOM
>> > > machinery.
>> > I thought one of the main motivations was reentrancy. As you cannot
>> > really assume the context bpf_map_alloc_pages is called from there is an
>> > extra care needed so that this doesn't re-enter the allocator from bpf
>> > program called from allocator path and deadlock.
>>
>>
>> Agreed, bpf_map_alloc_pages() is designed to be safe to run in any context.
>>
>> The commit message should be precise.
>
> How do you achive any level of safety for the _sleepable version? Vast
> majority of the kernel is sleepable but that doesn't mean this is safe
> from the mm reentrancy POV.
I think it will only be invoked directly in the arena map fault handler, which
runs in task context. If an interrupt occurs and tries to allocate pages,
can_alloc_pages() will return false and it should pick the _nolock() variant
which is safe against reentrancy.
next prev parent reply other threads:[~2026-08-24 13:12 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-21 5:01 [PATCH bpf-next v4 0/4] bpf: arena: handle memory.max on fault-in with reclaim/OOM Jiayuan Chen
2026-08-21 5:06 ` [PATCH bpf-next v4 1/4] bpf: Add a sleepable page allocator for map memory Jiayuan Chen
2026-08-21 5:06 ` [PATCH bpf-next v4 2/4] bpf: arena: allocate the fault-in page outside the lock Jiayuan Chen
2026-08-21 5:59 ` bot+bpf-ci
2026-08-21 10:31 ` Jiayuan Chen
2026-08-21 5:06 ` [PATCH bpf-next v4 3/4] selftests/bpf: Add read_cgroup_file() to cgroup_helpers Jiayuan Chen
2026-08-21 5:06 ` [PATCH bpf-next v4 4/4] selftests/bpf: Add a test for arena fault-in under memory.max Jiayuan Chen
2026-08-21 5:59 ` bot+bpf-ci
2026-08-24 12:26 ` [PATCH bpf-next v4 1/4] bpf: Add a sleepable page allocator for map memory Michal Hocko
2026-08-24 12:44 ` Jiayuan Chen
2026-08-24 13:01 ` Michal Hocko
2026-08-24 13:11 ` Kumar Kartikeya Dwivedi [this message]
2026-08-24 13:55 ` Michal Hocko
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=DKX77B18XF28.LG3DX8NUFQGI@gmail.com \
--to=memxor@gmail.com \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=bigeasy@linutronix.de \
--cc=bpf@vger.kernel.org \
--cc=clrkwllms@kernel.org \
--cc=daniel@iogearbox.net \
--cc=eddyz87@gmail.com \
--cc=emil@etsalapatis.com \
--cc=ihor.solodrai@linux.dev \
--cc=jiayuan.chen@linux.dev \
--cc=john.fastabend@gmail.com \
--cc=jolsa@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-rt-devel@lists.linux.dev \
--cc=martin.lau@linux.dev \
--cc=mhocko@suse.com \
--cc=rostedt@goodmis.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
all inboxes | Powered by JetHome®