mm/gup: Remove an assumption of a contiguous memmap

This assumption needs the inverse of nth_page(), which is temporarily
named page_nth() until it's renamed later in this series.
Signed-off-by: default avatarMatthew Wilcox (Oracle) <willy@infradead.org>
Reviewed-by: default avatarChristoph Hellwig <hch@lst.de>
Reviewed-by: default avatarJohn Hubbard <jhubbard@nvidia.com>
Reviewed-by: default avatarJason Gunthorpe <jgg@nvidia.com>
Reviewed-by: default avatarWilliam Kucharski <william.kucharski@oracle.com>
parent c228afb1
...@@ -212,8 +212,10 @@ int overcommit_policy_handler(struct ctl_table *, int, void *, size_t *, ...@@ -212,8 +212,10 @@ int overcommit_policy_handler(struct ctl_table *, int, void *, size_t *,
#if defined(CONFIG_SPARSEMEM) && !defined(CONFIG_SPARSEMEM_VMEMMAP) #if defined(CONFIG_SPARSEMEM) && !defined(CONFIG_SPARSEMEM_VMEMMAP)
#define nth_page(page,n) pfn_to_page(page_to_pfn((page)) + (n)) #define nth_page(page,n) pfn_to_page(page_to_pfn((page)) + (n))
#define page_nth(head, tail) (page_to_pfn(tail) - page_to_pfn(head))
#else #else
#define nth_page(page,n) ((page) + (n)) #define nth_page(page,n) ((page) + (n))
#define page_nth(head, tail) ((tail) - (head))
#endif #endif
/* to align the pointer to the (next) page boundary */ /* to align the pointer to the (next) page boundary */
......
...@@ -261,8 +261,8 @@ static inline struct page *compound_range_next(struct page *start, ...@@ -261,8 +261,8 @@ static inline struct page *compound_range_next(struct page *start,
next = nth_page(start, i); next = nth_page(start, i);
page = compound_head(next); page = compound_head(next);
if (PageHead(page)) if (PageHead(page))
nr = min_t(unsigned int, nr = min_t(unsigned int, npages - i,
page + compound_nr(page) - next, npages - i); compound_nr(page) - page_nth(page, next));
*ntails = nr; *ntails = nr;
return page; return page;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment