On Fri, 25 Oct 2024, Yang Shi wrote: > On Thu, Oct 24, 2024 at 11:57 PM Hugh Dickins <hughd@xxxxxxxxxx> wrote: > > On Thu, 24 Oct 2024, Yang Shi wrote: > > > On Wed, Oct 23, 2024 at 9:13 PM Hugh Dickins <hughd@xxxxxxxxxx> wrote: > > > > --- a/mm/page_alloc.c > > > > +++ b/mm/page_alloc.c > > > > @@ -2681,7 +2681,9 @@ void free_unref_folios(struct folio_batch *folios) > > > > unsigned long pfn = folio_pfn(folio); > > > > unsigned int order = folio_order(folio); > > > > > > > > - folio_undo_large_rmappable(folio); > > > > + if (mem_cgroup_disabled()) > > > > + folio_unqueue_deferred_split(folio); > > > > > > This looks confusing. It looks all callsites of free_unref_folios() > > > have folio_unqueue_deferred_split() and memcg uncharge called before > > > it. If there is any problem, memcg uncharge should catch it. Did I > > > miss something? > > > > I don't understand what you're suggesting there. But David remarked > > on it too, so it seems that I do need at least to add some comment. > > > > I'd better re-examine the memcg/non-memcg forking paths again: but by > > strange coincidence (or suggestion?), I'm suddenly now too tired here, > > precisely where David stopped too. I'll have to come back to this > > tomorrow, sorry. > > I perhaps misunderstood this code. Just feel free to correct me if it > doesn't make sense to you. But, yes, some comments are definitely > welcome and helpful for understanding the code and review. Thanks a lot for challenging that: it was me who misunderstood, not you. I might just be inventing this excuse, but I think what happened was, I'd been staring at an earlier release tree, and in that earlier tree the prior unqueueing was tucked away inside a memcg function, but not done in the #ifndef CONFIG_MEMCG stub: so I thought that this folio_unqueue_deferred_split() in free_unref_folios() was needed just to do it when mem_cgroup_disabled() (either by CONFIG or bootoption). And I thought the "if (mem_cgroup_disabled())" was comment enough: except it made no sense to you and David who saw what I was blind to (and what you describe perfectly clearly above - it depresses me sometimes, how I cannot even read what someone wrote, until I've arrived at the same conclusion myself!). If my story about !memcg stubs is true, then I think Matthew has been cleaning all that up recently. Except for put_pages_list() (where I now see he wanted to insert a VM_BUG_ON(folio_memcg) in April, but was forced to retreat): that one does not have a folio_unqueue_deferred_split() in, but the good news is that it no longer has any callers - I'll send a patch to delete it. And instead of my misunderstood code above in free_unref_folios(), just deleting the folio_undo_large_unmappable() line, with a comment in the commit message. Thanks! Hugh