From: Harry Yoo <harry@kernel.org>
To: "Vlastimil Babka (SUSE)" <vbabka@kernel.org>
Cc: Alexei Starovoitov <alexei.starovoitov@gmail.com>,
Karl Mehltretter <kmehltretter@gmail.com>,
Sebastian Andrzej Siewior <bigeasy@linutronix.de>,
Andrew Morton <akpm@linux-foundation.org>,
Hao Li <hao.li@linux.dev>,
Suren Baghdasaryan <surenb@google.com>,
Michal Hocko <mhocko@suse.com>, Amery Hung <ameryhung@gmail.com>,
Swaraj Gaikwad <swarajgaikwad1925@gmail.com>,
Clark Williams <clrkwllms@kernel.org>,
Steven Rostedt <rostedt@goodmis.org>,
linux-mm@kvack.org, bpf@vger.kernel.org,
linux-rt-devel@lists.linux.dev, linux-kernel@vger.kernel.org
Subject: Re: [RFC PATCH] mm: restrict can_spin_trylock() to preemptible context on PREEMPT_RT
Date: Fri, 25 Sep 2026 12:05:50 +0100 [thread overview]
Message-ID: <arZVV6Vq-ZJuCyun@thinkstation> (raw)
In-Reply-To: <c2f8eb01-7a10-4ccb-92f1-eece29c06cd4@kernel.org>
On Fri, Sep 25, 2026 at 09:29:16AM +0200, Vlastimil Babka (SUSE) wrote:
> On 9/25/26 06:12, Alexei Starovoitov wrote:
> > On Tue, Sep 22, 2026 at 08:04 AM Karl Mehltretter <kmehltretter@gmail.com> wrote:
> >> a) Change MM so _nolock() allocation remains safe and can still succeed
> >> while pi_lock or an rq lock is held. Existing BPF behavior would
> >> remain unchanged. Is this feasible, or would it require substantial
> >> allocator changes?
> >
> > I don't think it's feasible. On RT the sheaves lock, n->list_lock and
> > zone->lock are all rtmutex based. When trylock succeeded and a waiter
> > showed up rt_spin_unlock() has to wake it.
> >
> >> b) Restore BPF local storage's dedicated allocator, and document, with
> >> debug checks if possible, that _nolock() must not be used in those
> >> scheduler-lock contexts.
> >
> > No. Local storage is not the only one. bpf_arena_alloc_pages(),
> > bpf_stream_vprintk(), bpf_task_work_schedule_*() call kmalloc_nolock()
> > as well and the same sched_waking prog can call them.
> > bpf_mem_alloc was removed from local storage, because it wastes memory
> > on preallocation. Same answer for d).
> >
> >> c) Have MM detect those contexts and return NULL. This prevents the
> >> deadlock while preserving ordinary raw-lock callers such as arena,
> >> but task-storage creation from scheduler tracepoints then fails
> >> deterministically.
> >
> > This one.
>
> Yeah, but how exactly to do that detection :)
>
> > bpf_task_storage_get() with F_CREATE can return NULL and the progs
> > have to check for it anyway.
>
> e) Introduce raw_local_trylock_t...
+1 on this :)
> >> Are these the right alternatives? In particular, what behavior is
> >> intended from the _nolock() API in these scheduler-lock contexts?
> >
> > It can be called from any context and it can return NULL.
> > That's what it does from NMI and hardirq on RT already.
--
Cheers,
Harry / Hyeonggon
prev parent reply other threads:[~2026-09-25 11:05 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-19 17:14 Karl Mehltretter
2026-09-19 17:24 ` sashiko-bot
2026-09-19 18:17 ` Alexei Starovoitov
2026-09-22 6:04 ` Karl Mehltretter
2026-09-25 4:12 ` Alexei Starovoitov
2026-09-25 7:29 ` Vlastimil Babka (SUSE)
2026-09-25 11:05 ` Harry Yoo [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=arZVV6Vq-ZJuCyun@thinkstation \
--to=harry@kernel.org \
--cc=akpm@linux-foundation.org \
--cc=alexei.starovoitov@gmail.com \
--cc=ameryhung@gmail.com \
--cc=bigeasy@linutronix.de \
--cc=bpf@vger.kernel.org \
--cc=clrkwllms@kernel.org \
--cc=hao.li@linux.dev \
--cc=kmehltretter@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=linux-rt-devel@lists.linux.dev \
--cc=mhocko@suse.com \
--cc=rostedt@goodmis.org \
--cc=surenb@google.com \
--cc=swarajgaikwad1925@gmail.com \
--cc=vbabka@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
all inboxes | Powered by JetHome®