[<prev] [next>] [day] [month] [year] [list]
Message-Id: <20140228151427.dd232b07960dcf876112e191@linux-foundation.org>
Date: Fri, 28 Feb 2014 15:14:27 -0800
From: Andrew Morton <akpm@...ux-foundation.org>
To: Naoya Horiguchi <n-horiguchi@...jp.nec.com>
Cc: sasha.levin@...cle.com, linux-mm@...ck.org,
linux-kernel@...r.kernel.org, riel@...hat.com
Subject: Re: [PATCH v2] mm, hugetlbfs: fix rmapping for anonymous hugepages
with page_pgoff()
On Fri, 28 Feb 2014 14:59:02 -0500 Naoya Horiguchi <n-horiguchi@...jp.nec.com> 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 from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists