Skip to content

Commit f087b90

Browse files
author
Matthew Wilcox (Oracle)
committed
mm: Add folio_pgoff()
This is the folio equivalent of page_to_pgoff(). Signed-off-by: Matthew Wilcox (Oracle) <[email protected]> Reviewed-by: Christoph Hellwig <[email protected]>
1 parent 346cf61 commit f087b90

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

include/linux/pagemap.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -817,6 +817,17 @@ static inline loff_t folio_file_pos(struct folio *folio)
817817
return page_file_offset(&folio->page);
818818
}
819819

820+
/*
821+
* Get the offset in PAGE_SIZE (even for hugetlb folios).
822+
* (TODO: hugetlb folios should have ->index in PAGE_SIZE)
823+
*/
824+
static inline pgoff_t folio_pgoff(struct folio *folio)
825+
{
826+
if (unlikely(folio_test_hugetlb(folio)))
827+
return hugetlb_basepage_index(&folio->page);
828+
return folio->index;
829+
}
830+
820831
extern pgoff_t linear_hugepage_index(struct vm_area_struct *vma,
821832
unsigned long address);
822833

0 commit comments

Comments
 (0)