Re: [PATCH RESEND] mm/vmscan: Fix legacy memcg reclaim deadlock against filesystem freeze

From: Chris Down

Date: Fri Nov 27 2026 - 19:57:23 EST


Hi Andrew,

Andrew Morton writes:
>Can people please take a look and suggest whether it should be a
>standalone patch, or just fold it into this patch, "mm/vmscan: Fix
>legacy memcg reclaim deadlock against filesystem freeze"?

Yes, I think we should fold it in so that stable doesn't get the fix
without the scoping. With the other patch on top, the reproducer I used
for Tejun's patch doesn't deadlock either.

>(That's mem_cgroup's fifth bool - maybe scrunch them all into an
>atomic_t and do atomic bitops on it?)

Hmm, oom_group and zswap_writeback are in the read-mostly group on
purpose. I also think packing them into one word with runtime-written
flags like this one is likely to result in cache line thrashing, though
I haven't tested that. It wouldn't save space either, at least in the
x86_64 config I built (given each bool sits in what would otherwise be
padding).

>(I am told that moving wb_wait_skip to just after oom_group would avoid
>increasing sizeof(mem_cgroup), but that puts wb_wait_skip into the
>read-mostly section. wdyt?)

On x86_64 it doesn't increase the size from the previous situation I don't
think, since peaks_lock is followed by a 4 byte hole, and then wb_wait_skip
just dutifully slots into it. In that config, pahole gives 2240 bytes for
struct mem_cgroup both with and without the other patch. So I'd keep it in
memcg_cold, since the read-mostly group is for fields that are set when the
memcg is created and only read after that.

It does need an entry in memcg_struct_check(), though. Every other field
in the groups is asserted there, and without one nothing checks that
wb_wait_skip stays in memcg_cold:

CACHELINE_ASSERT_GROUP_MEMBER(struct mem_cgroup, memcg_cold,
wb_wait_skip);

With that added:

Reviewed-by: Chris Down <chris@xxxxxxxxxxxxxx>

Chris