Re: [PATCH v5 04/13] mm: Add readahead address space operation

Matthew Wilcox
2020-02-15T01:15:10Z

On Thu, Feb 13, 2020 at 09:36:25PM -0800, John Hubbard wrote:
> > +static inline struct page *readahead_page(struct readahead_control *rac)
> > +{
> > + struct page *page;
> > +
> > + if (!rac->nr_pages)
> > + return NULL;
> > +
> > + page = xa_load(&rac->mapping->i_pages, rac->start);
>
>
> Is it worth asserting that the page was found:
>
> VM_BUG_ON_PAGE(!page || xa_is_value(page), page);
>
> ? Or is that overkill here?

It shouldn't be possible since they were just added in a locked state.
If it did happen, it'll be caught by the assert below -- dereferencing
a NULL pointer or a shadow entry is not going to go well.

> > + VM_BUG_ON_PAGE(!PageLocked(page), page);
> > + rac->batch_count = hpage_nr_pages(page);
> > + rac->start += rac->batch_count;
>
> The above was surprising, until I saw the other thread with Dave and you.
> I was reviewing this patchset in order to have a chance at understanding the
> follow-on patchset ("Large pages in the page cache"), and it seems like that
> feature has a solid head start here. :)

Right, I'll document that.