Message ID | 20250113093453.1932083-6-kirill.shutemov@linux.intel.com (mailing list archive) |
---|---|
State | New |
Headers | show |
Series | mm: Remove PG_reclaim | expand |
On 13.01.25 10:34, Kirill A. Shutemov wrote: > The recently introduced PG_dropbehind allows for freeing folios > immediately after writeback. Unlike PG_reclaim, it does not need vmscan > to be involved to get the folio freed. > > Instead of using folio_set_reclaim(), use folio_set_dropbehind() in > pageout(). > > It is safe to leave PG_dropbehind on the folio if, for some reason > (bug?), the folio is not in a writeback state after ->writepage(). > In these cases, the kernel had to clear PG_reclaim as it shared a page > flag bit with PG_readahead. > > Signed-off-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com> > --- > mm/vmscan.c | 9 +++------ > 1 file changed, 3 insertions(+), 6 deletions(-) > > diff --git a/mm/vmscan.c b/mm/vmscan.c > index a099876fa029..d15f80333d6b 100644 > --- a/mm/vmscan.c > +++ b/mm/vmscan.c > @@ -692,19 +692,16 @@ static pageout_t pageout(struct folio *folio, struct address_space *mapping, > if (shmem_mapping(mapping) && folio_test_large(folio)) > wbc.list = folio_list; > > - folio_set_reclaim(folio); > + folio_set_dropbehind(folio); > + > res = mapping->a_ops->writepage(&folio->page, &wbc); > if (res < 0) > handle_write_error(mapping, folio, res); > if (res == AOP_WRITEPAGE_ACTIVATE) { > - folio_clear_reclaim(folio); > + folio_clear_dropbehind(folio); > return PAGE_ACTIVATE; > } > > - if (!folio_test_writeback(folio)) { > - /* synchronous write or broken a_ops? */ > - folio_clear_reclaim(folio); > - } > trace_mm_vmscan_write_folio(folio); > node_stat_add_folio(folio, NR_VMSCAN_WRITE); > return PAGE_SUCCESS; Acked-by: David Hildenbrand <david@redhat.com>
diff --git a/mm/vmscan.c b/mm/vmscan.c index a099876fa029..d15f80333d6b 100644 --- a/mm/vmscan.c +++ b/mm/vmscan.c @@ -692,19 +692,16 @@ static pageout_t pageout(struct folio *folio, struct address_space *mapping, if (shmem_mapping(mapping) && folio_test_large(folio)) wbc.list = folio_list; - folio_set_reclaim(folio); + folio_set_dropbehind(folio); + res = mapping->a_ops->writepage(&folio->page, &wbc); if (res < 0) handle_write_error(mapping, folio, res); if (res == AOP_WRITEPAGE_ACTIVATE) { - folio_clear_reclaim(folio); + folio_clear_dropbehind(folio); return PAGE_ACTIVATE; } - if (!folio_test_writeback(folio)) { - /* synchronous write or broken a_ops? */ - folio_clear_reclaim(folio); - } trace_mm_vmscan_write_folio(folio); node_stat_add_folio(folio, NR_VMSCAN_WRITE); return PAGE_SUCCESS;
The recently introduced PG_dropbehind allows for freeing folios immediately after writeback. Unlike PG_reclaim, it does not need vmscan to be involved to get the folio freed. Instead of using folio_set_reclaim(), use folio_set_dropbehind() in pageout(). It is safe to leave PG_dropbehind on the folio if, for some reason (bug?), the folio is not in a writeback state after ->writepage(). In these cases, the kernel had to clear PG_reclaim as it shared a page flag bit with PG_readahead. Signed-off-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com> --- mm/vmscan.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-)