BPF List
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Breno Leitao" <leitao@debian.org>
Cc: bpf@vger.kernel.org
Subject: Re: [PATCH] bpf: arena: reschedule while freeing the arena pages
Date: Mon, 24 Aug 2026 17:08:30 +0000	[thread overview]
Message-ID: <20260824170831.33E051F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260824-b4-bpf-arena-free-resched-v1-1-5c447477a64b@debian.org>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] Calling cond_resched() inside a pte_fn_t callback violates the lazy_mmu_mode contract, causing 'scheduling while atomic' bugs and failing to resolve softlockups on architectures where lazy MMU mode disables preemption.
--

--- Patch [1]: [PATCH] bpf: arena: reschedule while freeing the arena pages ---
commit aff4ff38f5c4bf3ce9d58e40df7c294fa156e787
Author: Breno Leitao <leitao@debian.org>

bpf: arena: reschedule while freeing the arena pages

This commit adds a cond_resched() call to the page freeing callback used
when tearing down a BPF arena to prevent softlockups.

> diff --git a/kernel/bpf/arena.c b/kernel/bpf/arena.c
> index 7b6847200b431..c5f6bebbb15c3 100644
> --- a/kernel/bpf/arena.c
> +++ b/kernel/bpf/arena.c
> @@ -364,6 +364,7 @@ static int existing_page_cb(pte_t *ptep, unsigned long addr, void *data)
>  	 * the freed page. So it all relies on 1.
>  	 */
>  	__free_page(page);
> +	cond_resched();

[Severity: High]
Does adding cond_resched() here violate the lazy MMU mode contract?

The callback existing_page_cb() is a pte_fn_t called by apply_to_pte_range(),
which establishes an atomic context by wrapping the callback loop in
lazy_mmu_mode_enable():

mm/memory.c:apply_to_pte_range() {
...
	lazy_mmu_mode_enable();
	if (fn) {
		do {
			if (create || !pte_none(ptep_get(pte))) {
				err = fn(pte, addr, data);
...
}

On architectures like PowerPC64 with hash MMUs, lazy_mmu_mode_enable()
explicitly disables preemption. Since preemption is disabled, cond_resched()
evaluates to a no-op, which means it won't actually yield the CPU and will
fail to resolve the original softlockup.

Additionally, if CONFIG_DEBUG_ATOMIC_SLEEP is enabled, this could trigger a
"sleeping function called from invalid context" bug during teardown.

>  	return 0;
>  }

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260824-b4-bpf-arena-free-resched-v1-1-5c447477a64b@debian.org?part=1

  reply	other threads:[~2026-08-24 17:08 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-24 16:54 [PATCH] bpf: arena: reschedule while freeing the arena pages Breno Leitao
2026-08-24 17:08 ` sashiko-bot [this message]
2026-08-25 14:06   ` Breno Leitao
2026-08-25 16:35     ` Alexei Starovoitov
2026-08-26 10:03       ` Breno Leitao
2026-08-24 17:48 ` bot+bpf-ci

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=20260824170831.33E051F000E9@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=leitao@debian.org \
    --cc=sashiko-reviews@lists.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