On Thu, Jul 02, 2020 at 11:39:07PM +0300, Kirill A. Shutemov wrote: > On Thu, Jul 02, 2020 at 06:19:08PM +0200, Vlastimil Babka wrote: > > Really? We are calculatting index (pgoff) of tail page, which should be index of > > head page plus n for n'th tail page; the unit is base pages. > > But ff HugeTLB head pages use the unit of huge page in page->index, and > > page_to_pgoff() translates it to unit of base pages, then we should do the same > > when calculating the index of tail page, no? Otherwise we are adding up units of > > huge pages (from head->index) with units of base page (n'th tail) and get > > garbage as a result, AFAICS? > > You are right. I guess we can get away with this because nobody calls > page_to_pgoff() on tail pages of hugetlb page. Except when something goes > wrong and dump_page() has to deal with it. > > I'm not sure if it's worth fixing and whether the fix should be inside > page_to_pgoff(). > > The best fix would be to remove hugetlb pages special-casing: it has to > have ->index in base pagesize, not huge page. https://lore.kernel.org/linux-mm/20200629152033.16175-1-willy@xxxxxxxxxxxxx/ would be a good place to start. We'll use 8 entries for an order-9 page instead of the 1 entry that we currently do, but that's a lot better than using 512 entries.