Re: [PATCH 04/12] mm: Allow compound zone device pages

Matthew Wilcox
2024-09-10T13:43:10Z

On Tue, Sep 10, 2024 at 04:57:41PM +1000, Alistair Popple wrote:
>
> Matthew Wilcox <willy@infradead.org> writes:
>
> > On Tue, Sep 10, 2024 at 02:14:29PM +1000, Alistair Popple wrote:
> >> @@ -337,6 +341,7 @@ struct folio {
> >> /* private: */
> >> };
> >> /* public: */
> >> + struct dev_pagemap *pgmap;
> >
> > Shouldn't that be indented by one more tab stop?
> >
> > And for ease of reading, perhaps it should be placed either immediately
> > before or after 'struct list_head lru;'?
> >
> >> +++ b/include/linux/mmzone.h
> >> @@ -1134,6 +1134,12 @@ static inline bool is_zone_device_page(const struct page *page)
> >> return page_zonenum(page) == ZONE_DEVICE;
> >> }
> >>
> >> +static inline struct dev_pagemap *page_dev_pagemap(const struct page *page)
> >> +{
> >> + WARN_ON(!is_zone_device_page(page));
> >> + return page_folio(page)->pgmap;
> >> +}
> >
> > I haven't read to the end yet, but presumably we'll eventually want:
> >
> > static inline struct dev_pagemap *folio_dev_pagemap(const struct folio *folio)
> > {
> > WARN_ON(!folio_is_zone_device(folio))
> > return folio->pgmap;
> > }
> >
> > and since we'll want it eventually, maybe now is the time to add it,
> > and make page_dev_pagemap() simply call it?
>
> Sounds reasonable. I had open-coded folio->pgmap where it's needed
> because at those points it's "obviously" a ZONE_DEVICE folio. Will add
> it.

Oh, if it's obvious then just do the dereference.