futex: Take hugepages into account when generating futex_key
[firefly-linux-kernel-4.4.55.git] / include / linux / hugetlb.h
index 6b4890fa57e7191574da1efe41eec956077d72ae..feaf0c7fb7d8715fc43257be5a0f4f89dc9668e0 100644 (file)
@@ -358,6 +358,17 @@ static inline int hstate_index(struct hstate *h)
        return h - hstates;
 }
 
+pgoff_t __basepage_index(struct page *page);
+
+/* Return page->index in PAGE_SIZE units */
+static inline pgoff_t basepage_index(struct page *page)
+{
+       if (!PageCompound(page))
+               return page->index;
+
+       return __basepage_index(page);
+}
+
 #else  /* CONFIG_HUGETLB_PAGE */
 struct hstate {};
 #define alloc_huge_page_node(h, nid) NULL
@@ -378,6 +389,11 @@ static inline unsigned int pages_per_huge_page(struct hstate *h)
 }
 #define hstate_index_to_shift(index) 0
 #define hstate_index(h) 0
+
+static inline pgoff_t basepage_index(struct page *page)
+{
+       return page->index;
+}
 #endif /* CONFIG_HUGETLB_PAGE */
 
 #endif /* _LINUX_HUGETLB_H */