Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

mm/vmscan.c:shrink_folio_list(): save a tabstop

We have some needlessly deep indentation in this huge function due to

if (expr1) {
if (expr2) {
...
}
}

Convert this to

if (expr1 && expr2) {
...
}

Also, reflow that big block comment to fit in 80 cols.

Cc: Johannes Weiner <hannes@cmpxchg.org>
Cc: David Hildenbrand <david@kernel.org>
Cc: Michal Hocko <mhocko@kernel.org>
Cc: Qi Zheng <zhengqi.arch@bytedance.com>
Cc: Shakeel Butt <shakeel.butt@linux.dev>
Cc: Lorenzo Stoakes <lorenzo.stoakes@oracle.com>
Cc: Axel Rasmussen <axelrasmussen@google.com>
Cc: Yuanchu Xie <yuanchu@google.com>
Cc: Wei Xu <weixugc@google.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>

+49 -49
+49 -49
mm/vmscan.c
··· 1276 1276 * Try to allocate it some swap space here. 1277 1277 * Lazyfree folio could be freed directly 1278 1278 */ 1279 - if (folio_test_anon(folio) && folio_test_swapbacked(folio)) { 1280 - if (!folio_test_swapcache(folio)) { 1281 - if (!(sc->gfp_mask & __GFP_IO)) 1282 - goto keep_locked; 1283 - if (folio_maybe_dma_pinned(folio)) 1284 - goto keep_locked; 1285 - if (folio_test_large(folio)) { 1286 - /* cannot split folio, skip it */ 1287 - if (folio_expected_ref_count(folio) != 1288 - folio_ref_count(folio) - 1) 1289 - goto activate_locked; 1290 - /* 1291 - * Split partially mapped folios right away. 1292 - * We can free the unmapped pages without IO. 1293 - */ 1294 - if (data_race(!list_empty(&folio->_deferred_list) && 1295 - folio_test_partially_mapped(folio)) && 1296 - split_folio_to_list(folio, folio_list)) 1297 - goto activate_locked; 1298 - } 1299 - if (folio_alloc_swap(folio)) { 1300 - int __maybe_unused order = folio_order(folio); 1301 - 1302 - if (!folio_test_large(folio)) 1303 - goto activate_locked_split; 1304 - /* Fallback to swap normal pages */ 1305 - if (split_folio_to_list(folio, folio_list)) 1306 - goto activate_locked; 1307 - #ifdef CONFIG_TRANSPARENT_HUGEPAGE 1308 - if (nr_pages >= HPAGE_PMD_NR) { 1309 - count_memcg_folio_events(folio, 1310 - THP_SWPOUT_FALLBACK, 1); 1311 - count_vm_event(THP_SWPOUT_FALLBACK); 1312 - } 1313 - #endif 1314 - count_mthp_stat(order, MTHP_STAT_SWPOUT_FALLBACK); 1315 - if (folio_alloc_swap(folio)) 1316 - goto activate_locked_split; 1317 - } 1279 + if (folio_test_anon(folio) && folio_test_swapbacked(folio) && 1280 + !folio_test_swapcache(folio)) { 1281 + if (!(sc->gfp_mask & __GFP_IO)) 1282 + goto keep_locked; 1283 + if (folio_maybe_dma_pinned(folio)) 1284 + goto keep_locked; 1285 + if (folio_test_large(folio)) { 1286 + /* cannot split folio, skip it */ 1287 + if (folio_expected_ref_count(folio) != 1288 + folio_ref_count(folio) - 1) 1289 + goto activate_locked; 1318 1290 /* 1319 - * Normally the folio will be dirtied in unmap because its 1320 - * pte should be dirty. A special case is MADV_FREE page. The 1321 - * page's pte could have dirty bit cleared but the folio's 1322 - * SwapBacked flag is still set because clearing the dirty bit 1323 - * and SwapBacked flag has no lock protected. For such folio, 1324 - * unmap will not set dirty bit for it, so folio reclaim will 1325 - * not write the folio out. This can cause data corruption when 1326 - * the folio is swapped in later. Always setting the dirty flag 1327 - * for the folio solves the problem. 1291 + * Split partially mapped folios right away. 1292 + * We can free the unmapped pages without IO. 1328 1293 */ 1329 - folio_mark_dirty(folio); 1294 + if (data_race(!list_empty(&folio->_deferred_list) && 1295 + folio_test_partially_mapped(folio)) && 1296 + split_folio_to_list(folio, folio_list)) 1297 + goto activate_locked; 1330 1298 } 1299 + if (folio_alloc_swap(folio)) { 1300 + int __maybe_unused order = folio_order(folio); 1301 + 1302 + if (!folio_test_large(folio)) 1303 + goto activate_locked_split; 1304 + /* Fallback to swap normal pages */ 1305 + if (split_folio_to_list(folio, folio_list)) 1306 + goto activate_locked; 1307 + #ifdef CONFIG_TRANSPARENT_HUGEPAGE 1308 + if (nr_pages >= HPAGE_PMD_NR) { 1309 + count_memcg_folio_events(folio, 1310 + THP_SWPOUT_FALLBACK, 1); 1311 + count_vm_event(THP_SWPOUT_FALLBACK); 1312 + } 1313 + #endif 1314 + count_mthp_stat(order, MTHP_STAT_SWPOUT_FALLBACK); 1315 + if (folio_alloc_swap(folio)) 1316 + goto activate_locked_split; 1317 + } 1318 + /* 1319 + * Normally the folio will be dirtied in unmap because 1320 + * its pte should be dirty. A special case is MADV_FREE 1321 + * page. The page's pte could have dirty bit cleared but 1322 + * the folio's SwapBacked flag is still set because 1323 + * clearing the dirty bit and SwapBacked flag has no 1324 + * lock protected. For such folio, unmap will not set 1325 + * dirty bit for it, so folio reclaim will not write the 1326 + * folio out. This can cause data corruption when the 1327 + * folio is swapped in later. Always setting the dirty 1328 + * flag for the folio solves the problem. 1329 + */ 1330 + folio_mark_dirty(folio); 1331 1331 } 1332 1332 1333 1333 /*