All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Hui Zhu" <hui.zhu@linux.dev>
Cc: bpf@vger.kernel.org
Subject: Re: [PATCH bpf-next v3 1/2] mm/bpf: Add bpf_proactive_reclaim kfuncs
Date: Wed, 19 Aug 2026 06:50:34 +0000	[thread overview]
Message-ID: <20260819065035.0786C1F000E9@smtp.kernel.org> (raw)
In-Reply-To: <0a2355a169c0900427b6e3c0d73ca6ae1be56f13.1787120833.git.zhuhui@kylinos.cn>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] Calling `try_to_free_mem_cgroup_pages` with `GFP_KERNEL` from arbitrary sleepable BPF programs can cause lock inversion deadlocks.
--

--- Patch [1]: [PATCH bpf-next v3 1/2] mm/bpf: Add bpf_proactive_reclaim kfuncs ---
commit 55d679bb7cd0ded2c29ec1fcf65b2396144cddad
Author: Hui Zhu <zhuhui@kylinos.cn>

mm/bpf: Add bpf_proactive_reclaim kfuncs

This commit introduces bpf_proactive_reclaim and
bpf_proactive_reclaim_swappiness kfuncs to expose memcg proactive reclaim
to sleepable BPF programs. They allow BPF programs to trigger one reclaim
pass on a given memcg with specific swappiness and size limits.

> diff --git a/mm/bpf_memcontrol.c b/mm/bpf_memcontrol.c
> index 716df49d76477..b0a0d4c55dc4e 100644
> --- a/mm/bpf_memcontrol.c
> +++ b/mm/bpf_memcontrol.c

[ ... ]

> +static unsigned long
> +bpf_proactive_reclaim_pages(struct mem_cgroup *memcg, unsigned long nr_pages,
> +			    int *swappiness)
> +{
> +	if (!nr_pages || unlikely(bpf_in_reclaim_context()))
> +		return 0;
> +
> +	return try_to_free_mem_cgroup_pages(memcg, nr_pages, GFP_KERNEL,
> +					    MEMCG_RECLAIM_MAY_SWAP |
> +					    MEMCG_RECLAIM_PROACTIVE,
> +					    swappiness);

[Severity: High]
Can calling try_to_free_mem_cgroup_pages() with GFP_KERNEL from arbitrary
sleepable BPF programs cause lock inversion deadlocks?

If a sleepable BPF program attaches to an LSM hook or fentry point where a
filesystem lock is already held (for example, bpf_lsm_inode_mkdir where
inode_lock is held), and the program calls bpf_proactive_reclaim(),
GFP_KERNEL will allow __GFP_FS reclaim.

The memory reclaim path could then enter filesystem shrinkers which attempt
to acquire the same lock, leading to a self-deadlock. 

Should this use a more restricted GFP mask, or perhaps dynamically inherit
the context's GFP constraints to avoid bypassing lock-context protections?

> +}

[ ... ]

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/cover.1787120833.git.zhuhui@kylinos.cn?part=1

  reply	other threads:[~2026-08-19  6:50 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-19  6:35 [PATCH bpf-next v3 0/2] bpf: BPF-driven proactive memcg reclaim Hui Zhu
2026-08-19  6:35 ` [PATCH bpf-next v3 1/2] mm/bpf: Add bpf_proactive_reclaim kfuncs Hui Zhu
2026-08-19  6:50   ` sashiko-bot [this message]
2026-08-19  7:16   ` bot+bpf-ci
2026-08-19  6:35 ` [PATCH bpf-next v3 2/2] selftests/bpf: add memcg async reclaim test Hui Zhu
2026-08-19  6:46   ` sashiko-bot
2026-08-19  7:16   ` 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=20260819065035.0786C1F000E9@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=hui.zhu@linux.dev \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.