> On Aug 6, 2019, at 5:12 AM, Kirill A. Shutemov <kirill@xxxxxxxxxxxxx> wrote: > > IIUC, you are missing ->vm_pgoff from the picture. The newly allocated > page must land into page cache aligned on HPAGE_PMD_NR boundary. In other > word you cannout have huge page with ->index, let say, 1. > > VMA is only suitable for at least one file-THP page if: > > - (vma->vm_start >> PAGE_SHIFT) % (HPAGE_PMD_NR - 1) is equal to > vma->vm_pgoff % (HPAGE_PMD_NR - 1) > > This guarantees right alignment in the backing page cache. > > - *and* vma->vm_end - round_up(vma->vm_start, HPAGE_PMD_SIZE) is equal or > greater than HPAGE_PMD_SIZE. > > Does it make sense? It makes sense, but what I am thinking was say a vma->vm_start of 0x1ff000 and vma->vm_end of 0x400000. Assuming x86, that can be mapped with a PAGESIZE page at 0x1ff000 then a PMD page mapping 0x200000 - 0x400000. That doesn't mean a vma IS or COULD ever be configured that way, so you are correct with your comment, and I will change my check accordingly. >> In the current code, it's assumed it is not exposed, because a single read >> of a large page that does no readahead before the page is inserted into the >> cache means there are no external users of the page. > > You've exposed the page to the filesystem once you call ->readpage(). > It *may* track the page somehow after the call. OK, thanks again. I'll try to have a V4 available with these changes soon.