From: Naoya Horiguchi Date: Thu, 22 May 2014 00:42:39 +0000 (+1000) Subject: mm-hugetlbfs-fix-rmapping-for-anonymous-hugepages-with-page_pgoff-v3 X-Git-Tag: next-20140530~2^2~403 X-Git-Url: https://git.karo-electronics.de/?a=commitdiff_plain;h=b0ae7bd9ba66b53f7838566c61410d7bfd605e60;p=karo-tx-linux.git mm-hugetlbfs-fix-rmapping-for-anonymous-hugepages-with-page_pgoff-v3 - add comment on page_size_order() - use compound_order(compound_head(page)) instead of huge_page_size_order() - use page_pgoff() in rmap_walk_file() too - use page_size_order() in kill_proc() - fix space indent Signed-off-by: Naoya Horiguchi Cc: Sasha Levin Cc: Rik van Riel Signed-off-by: Andrew Morton --- diff --git a/include/linux/hugetlb_inline.h b/include/linux/hugetlb_inline.h index e939975f0cba..4d60c82e9fda 100644 --- a/include/linux/hugetlb_inline.h +++ b/include/linux/hugetlb_inline.h @@ -11,7 +11,6 @@ static inline int is_vm_hugetlb_page(struct vm_area_struct *vma) } int PageHuge(struct page *page); -unsigned int huge_page_size_order(struct page *page); #else @@ -25,11 +24,6 @@ static inline int PageHuge(struct page *page) return 0; } -static inline unsigned int huge_page_size_order(struct page *page) -{ - return 0; -} - #endif #endif diff --git a/include/linux/pagemap.h b/include/linux/pagemap.h index 6f04bcd51a4e..3510155057a2 100644 --- a/include/linux/pagemap.h +++ b/include/linux/pagemap.h @@ -316,10 +316,22 @@ static inline loff_t page_file_offset(struct page *page) return ((loff_t)page_file_index(page)) << PAGE_CACHE_SHIFT; } +/* + * Getting page order of a given page in the context of the pagecache which + * each page belongs to. + * + * Pagecache unit size is not a fixed value (hugetlbfs is an example), but + * vma_interval_tree and anon_vma_internval_tree APIs assume that its indices + * are in PAGE_SIZE unit. So this routine helps us to get normalized indices. + * + * This page should be called only for pagecache pages/hugepages and anonymous + * pages/hugepages, because pagecache unit size is irrelevant except for those + * pages. + */ static inline unsigned int page_size_order(struct page *page) { return unlikely(PageHuge(page)) ? - huge_page_size_order(page) : + compound_order(compound_head(page)) : (PAGE_CACHE_SHIFT - PAGE_SHIFT); } @@ -329,7 +341,7 @@ static inline unsigned int page_size_order(struct page *page) */ static inline pgoff_t page_pgoff(struct page *page) { - return page->index << page_size_order(page); + return page->index << page_size_order(page); } extern pgoff_t linear_hugepage_index(struct vm_area_struct *vma, diff --git a/mm/hugetlb.c b/mm/hugetlb.c index 6b1f77b635c2..ea42b584661a 100644 --- a/mm/hugetlb.c +++ b/mm/hugetlb.c @@ -766,11 +766,6 @@ pgoff_t __basepage_index(struct page *page) return (index << compound_order(page_head)) + compound_idx; } -unsigned int huge_page_size_order(struct page *page) -{ - return huge_page_order(page_hstate(page)); -} - static struct page *alloc_fresh_huge_page_node(struct hstate *h, int nid) { struct page *page; diff --git a/mm/memory-failure.c b/mm/memory-failure.c index 3715443f550d..5a6a5aa2b73d 100644 --- a/mm/memory-failure.c +++ b/mm/memory-failure.c @@ -202,7 +202,7 @@ static int kill_proc(struct task_struct *t, unsigned long addr, int trapno, #ifdef __ARCH_SI_TRAPNO si.si_trapno = trapno; #endif - si.si_addr_lsb = compound_order(compound_head(page)) + PAGE_SHIFT; + si.si_addr_lsb = page_size_order(page) + PAGE_SHIFT; if ((flags & MF_ACTION_REQUIRED) && t == current) { si.si_code = BUS_MCEERR_AR; diff --git a/mm/rmap.c b/mm/rmap.c index 9916787c1843..79f21809a9ec 100644 --- a/mm/rmap.c +++ b/mm/rmap.c @@ -1646,7 +1646,7 @@ static int rmap_walk_anon(struct page *page, struct rmap_walk_control *rwc) static int rmap_walk_file(struct page *page, struct rmap_walk_control *rwc) { struct address_space *mapping = page->mapping; - pgoff_t pgoff = page->index << compound_order(page); + pgoff_t pgoff = page_pgoff(page); struct vm_area_struct *vma; int ret = SWAP_AGAIN;