From: Naoya Horiguchi Date: Thu, 26 Jun 2014 00:42:35 +0000 (+1000) Subject: mm-hugetlbfs-fix-rmapping-for-anonymous-hugepages-with-page_pgoff-v2 X-Git-Url: https://git.karo-electronics.de/?a=commitdiff_plain;h=64a6bb27dfeb655d91a069f85264c9f376aab9ad;p=karo-tx-linux.git mm-hugetlbfs-fix-rmapping-for-anonymous-hugepages-with-page_pgoff-v2 - fix wrong shift direction - introduce page_size_order() and huge_page_size_order() - move the declaration of PageHuge() to include/linux/hugetlb_inline.h to avoid macro definition. Signed-off-by: Naoya Horiguchi Cc: Sasha Levin Cc: Rik van Riel Signed-off-by: Andrew Morton --- diff --git a/include/linux/hugetlb.h b/include/linux/hugetlb.h index 255cd5cc0754..6a836ef54661 100644 --- a/include/linux/hugetlb.h +++ b/include/linux/hugetlb.h @@ -41,8 +41,6 @@ extern int hugetlb_max_hstate __read_mostly; struct hugepage_subpool *hugepage_new_subpool(long nr_blocks); void hugepage_put_subpool(struct hugepage_subpool *spool); -int PageHuge(struct page *page); - void reset_vma_resv_huge_pages(struct vm_area_struct *vma); int hugetlb_sysctl_handler(struct ctl_table *, int, void __user *, size_t *, loff_t *); int hugetlb_overcommit_handler(struct ctl_table *, int, void __user *, size_t *, loff_t *); @@ -109,11 +107,6 @@ unsigned long hugetlb_change_protection(struct vm_area_struct *vma, #else /* !CONFIG_HUGETLB_PAGE */ -static inline int PageHuge(struct page *page) -{ - return 0; -} - static inline void reset_vma_resv_huge_pages(struct vm_area_struct *vma) { } diff --git a/include/linux/hugetlb_inline.h b/include/linux/hugetlb_inline.h index 2bb681fbeb35..e939975f0cba 100644 --- a/include/linux/hugetlb_inline.h +++ b/include/linux/hugetlb_inline.h @@ -10,6 +10,9 @@ static inline int is_vm_hugetlb_page(struct vm_area_struct *vma) return !!(vma->vm_flags & VM_HUGETLB); } +int PageHuge(struct page *page); +unsigned int huge_page_size_order(struct page *page); + #else static inline int is_vm_hugetlb_page(struct vm_area_struct *vma) @@ -17,6 +20,16 @@ static inline int is_vm_hugetlb_page(struct vm_area_struct *vma) return 0; } +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 4eb3b99a9440..c337d2af6199 100644 --- a/include/linux/pagemap.h +++ b/include/linux/pagemap.h @@ -411,18 +411,21 @@ static inline loff_t page_file_offset(struct page *page) return ((loff_t)page_file_index(page)) << PAGE_CACHE_SHIFT; } -extern pgoff_t hugepage_pgoff(struct page *page); +static inline unsigned int page_size_order(struct page *page) +{ + return unlikely(PageHuge(page)) ? + huge_page_size_order(page) : + (PAGE_CACHE_SHIFT - PAGE_SHIFT); +} /* * page->index stores pagecache index whose unit is not always PAGE_SIZE. * This function converts it into PAGE_SIZE offset. */ -#define page_pgoff(page) \ -({ \ - unlikely(PageHuge(page)) ? \ - hugepage_pgoff(page) : \ - page->index >> (PAGE_CACHE_SHIFT - PAGE_SHIFT); \ -}) +static inline pgoff_t page_pgoff(struct page *page) +{ + return page->index << page_size_order(page); +} extern pgoff_t linear_hugepage_index(struct vm_area_struct *vma, unsigned long address); diff --git a/mm/hugetlb.c b/mm/hugetlb.c index 63dd071296a1..cccec2b4c073 100644 --- a/mm/hugetlb.c +++ b/mm/hugetlb.c @@ -31,6 +31,7 @@ #include #include +#include #include #include #include "internal.h" @@ -981,9 +982,9 @@ pgoff_t __basepage_index(struct page *page) return (index << compound_order(page_head)) + compound_idx; } -pgoff_t hugepage_pgoff(struct page *page) +unsigned int huge_page_size_order(struct page *page) { - return page->index << huge_page_order(page_hstate(page)); + return huge_page_order(page_hstate(page)); } static struct page *alloc_fresh_huge_page_node(struct hstate *h, int nid)