]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
mm-hugetlbfs-fix-rmapping-for-anonymous-hugepages-with-page_pgoff-v2
authorNaoya Horiguchi <n-horiguchi@ah.jp.nec.com>
Thu, 22 May 2014 00:42:38 +0000 (10:42 +1000)
committerStephen Rothwell <sfr@canb.auug.org.au>
Thu, 22 May 2014 00:42:38 +0000 (10:42 +1000)
- 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 <n-horiguchi@ah.jp.nec.com>
Cc: Sasha Levin <sasha.levin@oracle.com>
Cc: Rik van Riel <riel@redhat.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
include/linux/hugetlb.h
include/linux/hugetlb_inline.h
include/linux/pagemap.h
mm/hugetlb.c

index b65166de1d9d1f754f787aa1f58444e9d3da4ff0..63214868c5b2c37dd7b3715f280ac22e8c24eb96 100644 (file)
@@ -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)
 {
 }
index 2bb681fbeb35b3f4dcdece493931e0679c89d824..e939975f0cba3493739c77c3f9cd541abd6abd6b 100644 (file)
@@ -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
index f7c896cef20e3523c867d9e31497a69c1c437f97..6f04bcd51a4ebd86495f621e8b650817ef1f34ed 100644 (file)
@@ -316,18 +316,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);
index eedb6e4ef51c41d222ccc1f345a719105e137f1f..6b1f77b635c22bfc0911414057e8778e33085787 100644 (file)
@@ -31,6 +31,7 @@
 
 #include <linux/io.h>
 #include <linux/hugetlb.h>
+#include <linux/hugetlb_inline.h>
 #include <linux/hugetlb_cgroup.h>
 #include <linux/node.h>
 #include "internal.h"
@@ -765,9 +766,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)