From: Zhang Peng The activate_locked label in shrink_folio_list() handles swap cache reclaim, marks the folio active, and updates activation statistics. Extract this block into folio_active_bounce() to make shrink_folio_list() easier to follow. No functional change Suggested-by: Kairui Song Signed-off-by: Zhang Peng --- mm/vmscan.c | 30 +++++++++++++++++++----------- 1 file changed, 19 insertions(+), 11 deletions(-) diff --git a/mm/vmscan.c b/mm/vmscan.c index f3f03a44042e..0860a48d5bf3 100644 --- a/mm/vmscan.c +++ b/mm/vmscan.c @@ -1052,6 +1052,24 @@ static bool may_enter_fs(struct folio *folio, gfp_t gfp_mask) return !data_race(folio_swap_flags(folio) & SWP_FS_OPS); } +/* Mark folio as active and prepare to bounce back to head of LRU */ +static void folio_active_bounce(struct folio *folio, struct reclaim_stat *stat, + unsigned int nr_pages) +{ + /* Not a candidate for swapping, so reclaim swap space. */ + if (folio_test_swapcache(folio) && + (mem_cgroup_swap_full(folio) || folio_test_mlocked(folio))) + folio_free_swap(folio); + VM_BUG_ON_FOLIO(folio_test_active(folio), folio); + if (!folio_test_mlocked(folio)) { + int type = folio_is_file_lru(folio); + + folio_set_active(folio); + stat->nr_activate[type] += nr_pages; + count_memcg_folio_events(folio, PGACTIVATE, nr_pages); + } +} + /* * Reclaimed folios are counted in stat->nr_reclaimed. */ @@ -1527,17 +1545,7 @@ static void shrink_folio_list(struct list_head *folio_list, nr_pages = 1; } activate_locked: - /* Not a candidate for swapping, so reclaim swap space. */ - if (folio_test_swapcache(folio) && - (mem_cgroup_swap_full(folio) || folio_test_mlocked(folio))) - folio_free_swap(folio); - VM_BUG_ON_FOLIO(folio_test_active(folio), folio); - if (!folio_test_mlocked(folio)) { - int type = folio_is_file_lru(folio); - folio_set_active(folio); - stat->nr_activate[type] += nr_pages; - count_memcg_folio_events(folio, PGACTIVATE, nr_pages); - } + folio_active_bounce(folio, stat, nr_pages); keep_locked: folio_unlock(folio); keep: -- 2.43.7