On Tue, Aug 04, 2020 at 05:17:52PM +0100, Matthew Wilcox (Oracle) wrote: > diff --git a/include/linux/pagemap.h b/include/linux/pagemap.h > index 484a36185bb5..a474a92a2a72 100644 > --- a/include/linux/pagemap.h > +++ b/include/linux/pagemap.h > @@ -18,6 +18,11 @@ > > struct pagevec; > > +static inline bool page_cache_empty(struct address_space *mapping) > +{ > + return xa_empty(&mapping->i_pages); What about something like bool empty = xa_empty(&mapping->i_pages); VM_BUG_ON(empty && mapping->nrpages); return empty; ? > +} > + > /* > * Bits in mapping->flags. > */ -- Kirill A. Shutemov