Re: [PATCH v2] mm/vmscan: batch TLB flush during memory reclaim

From: Andrew Morton
Date: Thu Apr 03 2025 - 18:01:50 EST


On Fri, 28 Mar 2025 14:20:55 -0400 Rik van Riel <riel@xxxxxxxxxxx> wrote:

> The current implementation in shrink_folio_list() performs a full TLB
> flush for every individual folio reclaimed. This causes unnecessary
> overhead during memory reclaim.
>
> The current code:
> 1. Clears PTEs and unmaps each page individually
> 2. Performs a full TLB flush on every CPU the mm is running on
>
> The new code:
> 1. Clears PTEs and unmaps each page individually
> 2. Adds each unmapped page to pageout_folios
> 3. Flushes the TLB once before procesing pageout_folios
>
> This reduces the number of TLB flushes issued by the memory reclaim
> code by 1/N, where N is the number of mapped folios encountered in
> the batch processed by shrink_folio_list.

Were any runtime benefits observable?