Re: [RFC PATCH v2 2/3] mm: distinguish large folio swap allocation failures
From: Xueyuan Chen
Date: Thu Jul 09 2026 - 11:56:46 EST
On Thu, Jul 09, 2026 at 11:04:23AM -0400, Johannes Weiner wrote:
Hi Johannes,
>On Thu, Jul 09, 2026 at 11:01:12AM -0400, Johannes Weiner wrote:
>> On Thu, Jul 09, 2026 at 10:51:23PM +0800, Xueyuan Chen wrote:
>> > @@ -5550,10 +5558,7 @@ long mem_cgroup_get_nr_swap_pages(struct mem_cgroup *memcg)
>> >
>> > if (mem_cgroup_disabled() || do_memsw_account())
>> > return nr_swap_pages;
>> > - for (; !mem_cgroup_is_root(memcg); memcg = parent_mem_cgroup(memcg))
>> > - nr_swap_pages = min_t(long, nr_swap_pages,
>> > - READ_ONCE(memcg->swap.max) -
>> > - page_counter_read(&memcg->swap));
>> > + nr_swap_pages = min(nr_swap_pages, page_counter_margin(&memcg->swap));
>>
>> This hunk is unrelated to this patch. Don't mix refactor work with new
>> functionality. Make the previous patch a pure refactor job (where you
>> add page_counter_margin() and use it here ^), like I had proposed.
You're right, that refactor doesn't belong in patch 2.
>I also liked my version of mem_cgroup_get_nr_swap_pages() a bit
>better. Please just use my patch, keep the From: and you can add
>
>Signed-off-by: Johannes Weiner <hannes@xxxxxxxxxxx>
>
I'll use your version in v3, keep your From: and Signed-off-by, and make
patch 1 a pure refactor patch that adds page_counter_margin() and
converts mem_cgroup_get_nr_swap_pages() to use it.
Patch 2 will only keep the functional folio_alloc_swap()/memcg charge
changes.
Thanks,
Xueyuan