mm/mempolicy: use a folio in do_mbind()

We actually add folios to the pagelist already, but then work with them as
pages.  Removes a call to compound_head() in PageKsm() and removes a
reference to page->index.

Link: https://lkml.kernel.org/r/20240229153015.1996829-1-willy@infradead.org
Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
Reviewed-by: Gregory Price <gregory.price@memverge.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
This commit is contained in:
Matthew Wilcox (Oracle) 2024-02-29 15:29:45 +00:00 committed by Andrew Morton
parent ac96cc4d1c
commit f1cce6f7fa
1 changed files with 8 additions and 7 deletions

View File

@ -1356,29 +1356,30 @@ static long do_mbind(unsigned long start, unsigned long len,
*/ */
if (new->mode == MPOL_INTERLEAVE || if (new->mode == MPOL_INTERLEAVE ||
new->mode == MPOL_WEIGHTED_INTERLEAVE) { new->mode == MPOL_WEIGHTED_INTERLEAVE) {
struct page *page; struct folio *folio;
unsigned int order; unsigned int order;
unsigned long addr = -EFAULT; unsigned long addr = -EFAULT;
list_for_each_entry(page, &pagelist, lru) { list_for_each_entry(folio, &pagelist, lru) {
if (!PageKsm(page)) if (!folio_test_ksm(folio))
break; break;
} }
if (!list_entry_is_head(page, &pagelist, lru)) { if (!list_entry_is_head(folio, &pagelist, lru)) {
vma_iter_init(&vmi, mm, start); vma_iter_init(&vmi, mm, start);
for_each_vma_range(vmi, vma, end) { for_each_vma_range(vmi, vma, end) {
addr = page_address_in_vma(page, vma); addr = page_address_in_vma(
folio_page(folio, 0), vma);
if (addr != -EFAULT) if (addr != -EFAULT)
break; break;
} }
} }
if (addr != -EFAULT) { if (addr != -EFAULT) {
order = compound_order(page); order = folio_order(folio);
/* We already know the pol, but not the ilx */ /* We already know the pol, but not the ilx */
mpol_cond_put(get_vma_policy(vma, addr, order, mpol_cond_put(get_vma_policy(vma, addr, order,
&mmpol.ilx)); &mmpol.ilx));
/* Set base from which to increment by index */ /* Set base from which to increment by index */
mmpol.ilx -= page->index >> order; mmpol.ilx -= folio->index >> order;
} }
} }
} }