return ((loff_t)page_file_index(page)) << PAGE_CACHE_SHIFT;
}
+/*
+ * Getting page order of a given page in the context of the pagecache which
+ * each page belongs to.
+ *
+ * Pagecache unit size is not a fixed value (hugetlbfs is an example), but
+ * vma_interval_tree and anon_vma_internval_tree APIs assume that its indices
+ * are in PAGE_SIZE unit. So this routine helps us to get normalized indices.
+ *
+ * This page should be called only for pagecache pages/hugepages and anonymous
+ * pages/hugepages, because pagecache unit size is irrelevant except for those
+ * pages.
+ */
static inline unsigned int page_size_order(struct page *page)
{
return unlikely(PageHuge(page)) ?
- huge_page_size_order(page) :
+ compound_order(compound_head(page)) :
(PAGE_CACHE_SHIFT - PAGE_SHIFT);
}
*/
static inline pgoff_t page_pgoff(struct page *page)
{
- return page->index << page_size_order(page);
+ return page->index << page_size_order(page);
}
extern pgoff_t linear_hugepage_index(struct vm_area_struct *vma,
return (index << compound_order(page_head)) + compound_idx;
}
-unsigned int huge_page_size_order(struct page *page)
-{
- return huge_page_order(page_hstate(page));
-}
-
static struct page *alloc_fresh_huge_page_node(struct hstate *h, int nid)
{
struct page *page;
#ifdef __ARCH_SI_TRAPNO
si.si_trapno = trapno;
#endif
- si.si_addr_lsb = compound_order(compound_head(page)) + PAGE_SHIFT;
+ si.si_addr_lsb = page_size_order(page) + PAGE_SHIFT;
if ((flags & MF_ACTION_REQUIRED) && t == current) {
si.si_code = BUS_MCEERR_AR;
static int rmap_walk_file(struct page *page, struct rmap_walk_control *rwc)
{
struct address_space *mapping = page->mapping;
- pgoff_t pgoff = page->index << compound_order(page);
+ pgoff_t pgoff = page_pgoff(page);
struct vm_area_struct *vma;
int ret = SWAP_AGAIN;