On Mon, Feb 19, 2024 at 04:31:14PM +0100, David Hildenbrand wrote: > I'm hoping we at least can get rid of page ranges at some point (and just > have folio + nr_refs), but for the time being there is no way around that > due to delayed rmap handling that needs the exact pages (ugh). Yup. I've looked at pulling some of that apart, but realistically it's not going to happen soon. > folios_put_refs() does sound reasonable in any case, although likely > "putting multiple references" is limited to zap/munmap/... code paths. Well ... maybe. We have a few places where we call folio_put_refs(), and maybe some of them could be batched. unpin_user_pages_dirty_lock() is a candidate, but I wouldn't be surprised if someone inventive could find a way to do something similar in the filemap_free_folio() paths. Although the real solution there is to make the pagecache reference count once, not N times. > > +EXPORT_SYMBOL(folios_put); heh, forgot to change that line. A full compile (as opposed to just mm/) picked it up. > > + if (fbatch.nr) > > + folios_put_refs(&fbatch, refs); > > I wonder if it makes sense to remember if any ref !=1, and simply call > folios_put() if that's the case. > > But I guess the whole point about PAGEVEC_SIZE is that it is very > cache-friendly and traversing it a second time (e.g., when all we are doing > is freeing order-0 folios) is not too expensive. I don't think we need to add that; it'd certainly be something we could look at though.