Re: [RFC PATCH v3 2/4] mm: distinguish large folio swap allocation failures
Johannes Weiner <[email protected]>
| Newsgroups | org.kernel.vger.cgroups,org.kernel.vger.linux-kernel,org.kvack.linux-mm |
|---|---|
| Message-ID | <[email protected]> |
On Tue, Jul 21, 2026 at 04:15:13PM +0800, Barry Song wrote: > On Fri, Jul 17, 2026 at 8:25 PM Xueyuan Chen <[email protected]> wrote: > > @@ -5495,6 +5497,9 @@ int __mem_cgroup_try_charge_swap(struct folio *folio, swp_entry_t entry) > > rcu_read_lock(); > > memcg = obj_cgroup_memcg(objcg); > > if (!entry.val) { > > + if (nr_swap_pages && !mem_cgroup_is_root(memcg)) > > + *nr_swap_pages = min(*nr_swap_pages, > > + page_counter_margin(&memcg->swap)); > > This looks a bit odd. Could we decouple *nr_swap_pages from margin and > have the function always return margin instead? > > I don't think this function needs to care about the initial value returned by > get_nr_swap_pages(). While folio_alloc_swap() may depend on it, they're > different software layers, and we shouldn't couple them together. Agreed!