From: Naoya Horiguchi Date: Thu, 26 Jun 2014 00:42:35 +0000 (+1000) Subject: mm-hugetlbfs-fix-rmapping-for-anonymous-hugepages-with-page_pgoff-v3 X-Git-Url: https://git.karo-electronics.de/?a=commitdiff_plain;h=6bbeb810e2b5a84e5d2d67607434cac7b7345eb7;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 c337d2af6199..54cb1eb98355 100644 --- a/include/linux/pagemap.h +++ b/include/linux/pagemap.h @@ -411,10 +411,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); } @@ -424,7 +436,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 cccec2b4c073..7faab717ba19 100644 --- a/mm/hugetlb.c +++ b/mm/hugetlb.c @@ -982,11 +982,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 d148b54f82a2..a7a89eb2f935 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->mm == current->mm) { si.si_code = BUS_MCEERR_AR; diff --git a/mm/rmap.c b/mm/rmap.c index 672ee4cebe80..e4c9f7856cd1 100644 --- a/mm/rmap.c +++ b/mm/rmap.c @@ -1676,7 +1676,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;