Matthew Wilcox <willy@xxxxxxxxxxxxx> writes: > On Tue, Jan 01, 2019 at 08:57:53AM +0530, Aneesh Kumar K.V wrote: >> Matthew Wilcox <willy@xxxxxxxxxxxxx> writes: >> > +/* Returns the number of bytes in this potentially compound page. */ >> > +static inline unsigned long page_size(struct page *page) >> > +{ >> > + return (unsigned long)PAGE_SIZE << compound_order(page); >> > +} >> > + >> >> How about compound_page_size() to make it clear this is for >> compound_pages? Should we make it work with Tail pages by doing >> compound_head(page)? > > I think that's a terrible idea. Actually, I think the whole way we handle > compound pages is terrible; we should only ever see head pages. Doing > page cache lookups should only give us head pages. Calling pfn_to_page() > should give us the head page. We should only put head pages into SG lists. > Everywhere you see a struct page should only be a head page. > > I know we're far from that today, and there's lots of work to be done > to get there. But the current state of handling compound pages is awful > and confusing. One exception is THP compound pages which can also be mapped as regular pages in some page tables? -aneesh