On Fri, 28 Feb 2014 14:59:02 -0500 Naoya Horiguchi <n-horiguchi@xxxxxxxxxxxxx> wrote: > page->index stores pagecache index when the page is mapped into file mapping > region, and the index is in pagecache size unit, so it depends on the page > size. Some of users of reverse mapping obviously assumes that page->index > is in PAGE_CACHE_SHIFT unit, so they don't work for anonymous hugepage. > > For example, consider that we have 3-hugepage vma and try to mbind the 2nd > hugepage to migrate to another node. Then the vma is split and migrate_page() > is called for the 2nd hugepage (belonging to the middle vma.) > In migrate operation, rmap_walk_anon() tries to find the relevant vma to > which the target hugepage belongs, but here we miscalculate pgoff. > So anon_vma_interval_tree_foreach() grabs invalid vma, which fires VM_BUG_ON. > > This patch introduces a new API that is usable both for normal page and > hugepage to get PAGE_SIZE offset from page->index. Users should clearly > distinguish page_index for pagecache index and page_pgoff for page offset. > > .. > > --- a/include/linux/pagemap.h > +++ b/include/linux/pagemap.h > @@ -307,6 +307,22 @@ static inline loff_t page_file_offset(struct page *page) > return ((loff_t)page_file_index(page)) << PAGE_CACHE_SHIFT; > } > > +static inline unsigned int page_size_order(struct page *page) > +{ > + return unlikely(PageHuge(page)) ? > + huge_page_size_order(page) : > + (PAGE_CACHE_SHIFT - PAGE_SHIFT); > +} Could use some nice documentation, please. Why it exists, what it does. Particularly: what sort of pages it can and can't operate on, and why. The presence of PAGE_CACHE_SIZE is unfortunate - it at least implies that the page is a pagecache page. I dunno, maybe just use "0"? -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to majordomo@xxxxxxxxx. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"dont@xxxxxxxxx"> email@xxxxxxxxx </a>