diff --git a/include/linux/hugetlb.h b/include/linux/hugetlb.h index 831e8b654ab8179dc3f42f038ba755fc34e74eaa..6831b24defd6411f7f83e0445f2f16d881b623d1 100644 --- a/include/linux/hugetlb.h +++ b/include/linux/hugetlb.h @@ -485,17 +485,6 @@ 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); -} - extern int dissolve_free_huge_page(struct page *page); extern int dissolve_free_huge_pages(unsigned long start_pfn, unsigned long end_pfn); @@ -590,11 +579,6 @@ static inline int hstate_index(struct hstate *h) return 0; } -static inline pgoff_t basepage_index(struct page *page) -{ - return page->index; -} - static inline int dissolve_free_huge_page(struct page *page) { return 0; diff --git a/include/linux/pagemap.h b/include/linux/pagemap.h index e889d992961592f2b70a1b7595aaf170fd40ffdc..085aed892ce5812b774046cc601f09caf5915c13 100644 --- a/include/linux/pagemap.h +++ b/include/linux/pagemap.h @@ -427,7 +427,7 @@ static inline struct page *read_mapping_page(struct address_space *mapping, } /* - * Get index of the page with in radix-tree + * Get index of the page within radix-tree (but not for hugetlb pages). * (TODO: remove once hugetlb pages will have ->index in PAGE_SIZE) */ static inline pgoff_t page_to_index(struct page *page) @@ -446,15 +446,16 @@ static inline pgoff_t page_to_index(struct page *page) return pgoff; } +extern pgoff_t hugetlb_basepage_index(struct page *page); + /* - * Get the offset in PAGE_SIZE. - * (TODO: hugepage should have ->index in PAGE_SIZE) + * Get the offset in PAGE_SIZE (even for hugetlb pages). + * (TODO: hugetlb pages should have ->index in PAGE_SIZE) */ static inline pgoff_t page_to_pgoff(struct page *page) { - if (unlikely(PageHeadHuge(page))) - return page->index << compound_order(page); - + if (unlikely(PageHuge(page))) + return hugetlb_basepage_index(page); return page_to_index(page); } diff --git a/kernel/futex.c b/kernel/futex.c index 13574134bbc44d846d252aab6a8fda2f2ee79bdc..a36a006e5b13814d2db6c3070425dfb2e5afb6bc 100644 --- a/kernel/futex.c +++ b/kernel/futex.c @@ -724,7 +724,7 @@ get_futex_key(u32 __user *uaddr, int fshared, union futex_key *key, enum futex_a key->both.offset |= FUT_OFF_INODE; /* inode-based key */ key->shared.i_seq = get_inode_sequence_number(inode); - key->shared.pgoff = basepage_index(tail); + key->shared.pgoff = page_to_pgoff(tail); rcu_read_unlock(); } diff --git a/mm/hugetlb.c b/mm/hugetlb.c index 27d03b7197eea6f7d240970dffbdae479333b791..5132fefb60c86a277b550c298acdcfadbf9d7de6 100644 --- a/mm/hugetlb.c +++ b/mm/hugetlb.c @@ -1409,15 +1409,12 @@ int PageHeadHuge(struct page *page_head) return get_compound_page_dtor(page_head) == free_huge_page; } -pgoff_t __basepage_index(struct page *page) +pgoff_t hugetlb_basepage_index(struct page *page) { struct page *page_head = compound_head(page); pgoff_t index = page_index(page_head); unsigned long compound_idx; - if (!PageHuge(page_head)) - return page_index(page); - if (compound_order(page_head) >= MAX_ORDER) compound_idx = page_to_pfn(page) - page_to_pfn(page_head); else