]> 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, 26 Jun 2014 00:42:35 +0000 (10:42 +1000)
committerStephen Rothwell <sfr@canb.auug.org.au>
Thu, 26 Jun 2014 00:42:35 +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 255cd5cc07541034fd0f80e1d944ca775b6c78df..6a836ef54661b6cace29137a43ff219caeaa65d5 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 4eb3b99a9440bb6e95bd232c6511ddb43f2c9a7b..c337d2af6199830058c54ce284ba637a80c60ce3 100644 (file)
@@ -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);
index 63dd071296a1c4d1a547c5e48033115c7fae1a05..cccec2b4c07319bdce21027aea63404bb5416f20 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"
@@ -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)