Re: [PATCH] mm: remove redundant compound_head() calling

From: Matthew Wilcox
Date: Fri Aug 13 2021 - 10:26:14 EST


On Fri, Aug 13, 2021 at 04:02:33PM +0200, Vlastimil Babka wrote:
> On 8/11/21 12:14 PM, Muchun Song wrote:
> > There is a READ_ONCE() in the macro of compound_head(), which will
> > prevent compiler from optimizing the code when there are more than
> > once calling of it in a function. Remove the redundant calling of
> > compound_head() from page_to_index() and page_add_file_rmap() for
> > better code generation.
> >
> > Signed-off-by: Muchun Song <songmuchun@xxxxxxxxxxxxx>
>
> Seems to be compatible with folio/for-next and not made redundant by that (yet?
> didn't check the branches planned for future versions), so OK. But long-term I'd
> expect these optimizations to be obsoleted by the folio work.

Yes, I haven't touched page_add_file_rmap() in my tree yet. Trying to
keep my focus on page cache instead of working on more generic mm stuff.
Hopefully other people will work on those pieces once the folio work
lands.

Looking at page_add_file_rmap(), it needs someone to think in detail
about what 'compound' means in the context of sub-PMD-sized compound
pages. I suspect it really means "map_as_pmd".