vmscan.c (d1d8a3b4d06d8c9188f2b9b89ef053db0bf899de) vmscan.c (8927f6473e56e32e328ae8ed43736412f7f76a4e)
1// SPDX-License-Identifier: GPL-2.0
2/*
3 * Copyright (C) 1991, 1992, 1993, 1994 Linus Torvalds
4 *
5 * Swap reorganised 29.12.95, Stephen Tweedie.
6 * kswapd added: 7.1.96 sct
7 * Removed kswapd_ctl limits, and swap out as many pages as needed
8 * to bring the system back to freepages.high: 2.4.97, Rik van Riel.

--- 1228 unchanged lines hidden (view full) ---

1237
1238/*
1239 * Same as remove_mapping, but if the page is removed from the mapping, it
1240 * gets returned with a refcount of 0.
1241 */
1242static int __remove_mapping(struct address_space *mapping, struct page *page,
1243 bool reclaimed, struct mem_cgroup *target_memcg)
1244{
1// SPDX-License-Identifier: GPL-2.0
2/*
3 * Copyright (C) 1991, 1992, 1993, 1994 Linus Torvalds
4 *
5 * Swap reorganised 29.12.95, Stephen Tweedie.
6 * kswapd added: 7.1.96 sct
7 * Removed kswapd_ctl limits, and swap out as many pages as needed
8 * to bring the system back to freepages.high: 2.4.97, Rik van Riel.

--- 1228 unchanged lines hidden (view full) ---

1237
1238/*
1239 * Same as remove_mapping, but if the page is removed from the mapping, it
1240 * gets returned with a refcount of 0.
1241 */
1242static int __remove_mapping(struct address_space *mapping, struct page *page,
1243 bool reclaimed, struct mem_cgroup *target_memcg)
1244{
1245 struct folio *folio = page_folio(page);
1245 int refcount;
1246 void *shadow = NULL;
1247
1248 BUG_ON(!PageLocked(page));
1249 BUG_ON(mapping != page_mapping(page));
1250
1251 if (!PageSwapCache(page))
1252 spin_lock(&mapping->host->i_lock);

--- 31 unchanged lines hidden (view full) ---

1284 page_ref_unfreeze(page, refcount);
1285 goto cannot_free;
1286 }
1287
1288 if (PageSwapCache(page)) {
1289 swp_entry_t swap = { .val = page_private(page) };
1290 mem_cgroup_swapout(page, swap);
1291 if (reclaimed && !mapping_exiting(mapping))
1246 int refcount;
1247 void *shadow = NULL;
1248
1249 BUG_ON(!PageLocked(page));
1250 BUG_ON(mapping != page_mapping(page));
1251
1252 if (!PageSwapCache(page))
1253 spin_lock(&mapping->host->i_lock);

--- 31 unchanged lines hidden (view full) ---

1285 page_ref_unfreeze(page, refcount);
1286 goto cannot_free;
1287 }
1288
1289 if (PageSwapCache(page)) {
1290 swp_entry_t swap = { .val = page_private(page) };
1291 mem_cgroup_swapout(page, swap);
1292 if (reclaimed && !mapping_exiting(mapping))
1292 shadow = workingset_eviction(page, target_memcg);
1293 shadow = workingset_eviction(folio, target_memcg);
1293 __delete_from_swap_cache(page, swap, shadow);
1294 xa_unlock_irq(&mapping->i_pages);
1295 put_swap_page(page, swap);
1296 } else {
1297 void (*freepage)(struct page *);
1298
1299 freepage = mapping->a_ops->freepage;
1300 /*

--- 9 unchanged lines hidden (view full) ---

1310 * We also don't store shadows for DAX mappings because the
1311 * only page cache pages found in these are zero pages
1312 * covering holes, and because we don't want to mix DAX
1313 * exceptional entries and shadow exceptional entries in the
1314 * same address_space.
1315 */
1316 if (reclaimed && page_is_file_lru(page) &&
1317 !mapping_exiting(mapping) && !dax_mapping(mapping))
1294 __delete_from_swap_cache(page, swap, shadow);
1295 xa_unlock_irq(&mapping->i_pages);
1296 put_swap_page(page, swap);
1297 } else {
1298 void (*freepage)(struct page *);
1299
1300 freepage = mapping->a_ops->freepage;
1301 /*

--- 9 unchanged lines hidden (view full) ---

1311 * We also don't store shadows for DAX mappings because the
1312 * only page cache pages found in these are zero pages
1313 * covering holes, and because we don't want to mix DAX
1314 * exceptional entries and shadow exceptional entries in the
1315 * same address_space.
1316 */
1317 if (reclaimed && page_is_file_lru(page) &&
1318 !mapping_exiting(mapping) && !dax_mapping(mapping))
1318 shadow = workingset_eviction(page, target_memcg);
1319 __delete_from_page_cache(page, shadow);
1319 shadow = workingset_eviction(folio, target_memcg);
1320 __filemap_remove_folio(folio, shadow);
1320 xa_unlock_irq(&mapping->i_pages);
1321 if (mapping_shrinkable(mapping))
1322 inode_add_lru(mapping->host);
1323 spin_unlock(&mapping->host->i_lock);
1324
1325 if (freepage != NULL)
1326 freepage(page);
1327 }

--- 3561 unchanged lines hidden ---
1321 xa_unlock_irq(&mapping->i_pages);
1322 if (mapping_shrinkable(mapping))
1323 inode_add_lru(mapping->host);
1324 spin_unlock(&mapping->host->i_lock);
1325
1326 if (freepage != NULL)
1327 freepage(page);
1328 }

--- 3561 unchanged lines hidden ---