On 12.12.23 13:43, Matthew Wilcox wrote:
On Tue, Dec 12, 2023 at 01:32:50PM +0100, David Hildenbrand wrote:
+++ b/mm/swapfile.c
@@ -1749,11 +1749,13 @@ static int unuse_pte(struct vm_area_struct *vma, pmd_t *pmd,
int ret = 1;
swapcache = page;
- page = ksm_might_need_to_copy(page, vma, addr);
- if (unlikely(!page))
+ folio = ksm_might_need_to_copy(folio, vma, addr);
+ if (unlikely(!folio))
return -ENOMEM;
- else if (unlikely(PTR_ERR(page) == -EHWPOISON))
+ else if (unlikely(folio == ERR_PTR(-EHWPOISON)))
hwpoisoned = true;
+ else
+ page = folio_file_page(folio, swp_offset(entry));
Just to double-check:
assuming ksm_might_need_to_copy() in fact allocated a fresh (order-0) folio,
folio_file_page() will simply translate to "folio_page(folio, 0)" and should
be fine.
That's right:
static inline struct page *folio_file_page(struct folio *folio, pgoff_t index)
{
return folio_page(folio, index & (folio_nr_pages(folio) - 1));
}
so an order-0 folio will return the only page in the folio.
LGTM then
Reviewed-by: David Hildenbrand <david@xxxxxxxxxx>
--
Cheers,
David / dhildenb