Re: [RFC PATCH bpf-next v5 08/12] mm: memcontrol: Add BPF struct_ops for memory controller
From: bot+bpf-ci@kernel.org
Date: 2026-01-27 10:08:37
Also in:
bpf, cgroups, linux-kselftest, linux-mm, lkml
quoted hunk ↗ jump to hunk
diff --git a/mm/memcontrol.c b/mm/memcontrol.c index 1f74fce27677..8d90575aa77d 100644 --- a/mm/memcontrol.c +++ b/mm/memcontrol.c
[ ... ]
quoted hunk ↗ jump to hunk
@@ -2530,10 +2537,14 @@ static int try_charge_memcg(struct mem_cgroup *memcg, gfp_t gfp_mask, * kernel. If this is successful, the return path will see it * when it rechecks the overage and simply bail out. */ - if (current->memcg_nr_pages_over_high > MEMCG_CHARGE_BATCH && - !(current->flags & PF_MEMALLOC) && - gfpflags_allow_blocking(gfp_mask)) - __mem_cgroup_handle_over_high(gfp_mask); + if (gfpflags_allow_blocking(gfp_mask)) { + unsigned long bpf_high_delay; + + bpf_high_delay = bpf_memcg_get_high_delay(orig_memcg); + if (bpf_high_delay || + current->memcg_nr_pages_over_high > MEMCG_CHARGE_BATCH) + __mem_cgroup_handle_over_high(gfp_mask, bpf_high_delay); + }
The old code checked !(current->flags & PF_MEMALLOC) before calling __mem_cgroup_handle_over_high(). This check appears to be missing in the new code. When PF_MEMALLOC is set, the task is already in the memory reclaim context. Calling __mem_cgroup_handle_over_high() from such a context would invoke reclaim_high() -> try_to_free_mem_cgroup_pages(), potentially causing reclaim recursion. Was the removal of the PF_MEMALLOC check intentional? If a BPF program returns a non-zero delay from get_high_delay_ms while the task is in a reclaim context, could this lead to recursive reclaim or deadlock? --- AI reviewed your patch. Please fix the bug or email reply why it's not a bug. See: https://github.com/kernel-patches/vmtest/blob/master/ci/claude/README.md CI run summary: https://github.com/kernel-patches/bpf/actions/runs/21392729810 AI-authorship-score: low AI-authorship-explanation: The code shows typical human characteristics including a refactoring oversight that AI would likely not make; the commit follows standard kernel conventions and has multiple human authors. issues-found: 1 issue-severity-score: medium issue-severity-explanation: Missing PF_MEMALLOC check could cause memory reclaim recursion when BPF programs are attached, potentially leading to system instability.