On Fri, 4 Sep 2026 18:20:19 +0800 "Hui Zhu" <[email protected]> wrote:
> @@ -159,6 +160,74 @@ __bpf_kfunc void bpf_mem_cgroup_flush_stats(struct
> mem_cgroup *memcg)
> mem_cgroup_flush_stats(memcg);
> }
>
> +/*
> + * Reclaim must not recurse: try_to_free_mem_cgroup_pages() overwrites
> + * current->reclaim_state, so a nested call would corrupt the outer
> + * reclaim state. Reclaim windows are marked with PF_MEMALLOC;
> + * reclaim_state is also checked because it is installed slightly
> + * before PF_MEMALLOC.
> + */
> +static bool bpf_in_reclaim_context(void)
> +{
> + return (current->flags & PF_MEMALLOC) || current->reclaim_state;
> +}
> +
Would life improve if try_to_free_mem_cgroup_pages() didn't do that?
If try_to_free_mem_cgroup_pages() (or some variant of it) were to
permit nesting?
rs = new_thing(current, &sc.reclaim_state);
...
set_task_reclaim_state(current, rs);
?