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: swap: factor out helper to drop cache of entries within a single cluster

Factor out helper swap_entries_put_cache() from put_swap_folio() to serve
as a general-purpose routine for dropping cache flag of entries within a
single cluster.

Link: https://lkml.kernel.org/r/20250325162528.68385-8-shikemeng@huaweicloud.com
Signed-off-by: Kemeng Shi <shikemeng@huaweicloud.com>
Reviewed-by: Tim Chen <tim.c.chen@linux.intel.com>
Reviewed-by: Baoquan He <bhe@redhat.com>
Cc: Kairui Song <kasong@tencent.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>

authored by

Kemeng Shi and committed by
Andrew Morton
d4f8000b 4d71d906

+17 -10
+17 -10
mm/swapfile.c
··· 1463 1463 return NULL; 1464 1464 } 1465 1465 1466 + static void swap_entries_put_cache(struct swap_info_struct *si, 1467 + swp_entry_t entry, int nr) 1468 + { 1469 + unsigned long offset = swp_offset(entry); 1470 + struct swap_cluster_info *ci; 1471 + 1472 + ci = lock_cluster(si, offset); 1473 + if (swap_only_has_cache(si, offset, nr)) 1474 + swap_entries_free(si, ci, entry, nr); 1475 + else { 1476 + for (int i = 0; i < nr; i++, entry.val++) 1477 + swap_entry_put_locked(si, ci, entry, SWAP_HAS_CACHE); 1478 + } 1479 + unlock_cluster(ci); 1480 + } 1481 + 1466 1482 static bool swap_entries_put_map(struct swap_info_struct *si, 1467 1483 swp_entry_t entry, int nr) 1468 1484 { ··· 1623 1607 */ 1624 1608 void put_swap_folio(struct folio *folio, swp_entry_t entry) 1625 1609 { 1626 - unsigned long offset = swp_offset(entry); 1627 - struct swap_cluster_info *ci; 1628 1610 struct swap_info_struct *si; 1629 1611 int size = 1 << swap_entry_order(folio_order(folio)); 1630 1612 ··· 1630 1616 if (!si) 1631 1617 return; 1632 1618 1633 - ci = lock_cluster(si, offset); 1634 - if (swap_only_has_cache(si, offset, size)) 1635 - swap_entries_free(si, ci, entry, size); 1636 - else { 1637 - for (int i = 0; i < size; i++, entry.val++) 1638 - swap_entry_put_locked(si, ci, entry, SWAP_HAS_CACHE); 1639 - } 1640 - unlock_cluster(ci); 1619 + swap_entries_put_cache(si, entry, size); 1641 1620 } 1642 1621 1643 1622 int __swap_count(swp_entry_t entry)