Re: [PATCH 51/75] mm/rmap: Convert try_to_unmap() to take a folio

From: Mauricio Faria de Oliveira
Date: Wed Feb 09 2022 - 09:24:56 EST


Hi Andrew and Matthew,

On Fri, Feb 4, 2022 at 5:00 PM Matthew Wilcox (Oracle)
<willy@xxxxxxxxxxxxx> wrote:
>
> Change both callers and the worker function try_to_unmap_one().
...
> diff --git a/mm/rmap.c b/mm/rmap.c
...
> @@ -1598,8 +1602,8 @@ static bool try_to_unmap_one(struct page *page, struct vm_area_struct *vma,
> }
>
> /* MADV_FREE page check */
> - if (!PageSwapBacked(page)) {
> - if (!PageDirty(page)) {
> + if (!folio_test_swapbacked(folio)) {
> + if (!folio_test_dirty(folio)) {
> /* Invalidate as we cleared the pte */
> mmu_notifier_invalidate_range(mm,
> address, address + PAGE_SIZE);
> @@ -1608,11 +1612,11 @@ static bool try_to_unmap_one(struct page *page, struct vm_area_struct *vma,
> }
>
> /*
> - * If the page was redirtied, it cannot be
> + * If the folio was redirtied, it cannot be
> * discarded. Remap the page to page table.
> */
> set_pte_at(mm, address, pvmw.pte, pteval);
> - SetPageSwapBacked(page);
> + folio_set_swapbacked(folio);
> ret = false;
> page_vma_mapped_walk_done(&pvmw);
> break;
...

This conflicts with patch [1], currently in mmotm, and I'll send
another version anyway.
Should that patch be on top of these folio changes, or the other way around?

The latter would help w/ the stable backports that don't have folios
yet, but I can
send backports there as well; not a problem.

Thanks,

[1] https://lkml.kernel.org/r/20220131230255.789059-1-mfo@xxxxxxxxxxxxx
[PATCH v3] mm: fix race between MADV_FREE reclaim and blkdev direct IO read

--
Mauricio Faria de Oliveira