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: rename swap_swapcount() to swap_entry_swapped()

The new function name can reflect the real behaviour of the function more
clearly and more accurately. And the renaming avoids the confusion
between swap_swapcount() and swp_swapcount().

Link: https://lkml.kernel.org/r/20250205092721.9395-11-bhe@redhat.com
Signed-off-by: Baoquan He <bhe@redhat.com>
Cc: Chris Li <chrisl@kernel.org>
Cc: Kairui Song <ryncsn@gmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>

authored by

Baoquan He and committed by
Andrew Morton
c523aa89 ac2d3268

+7 -7
+3 -3
include/linux/swap.h
··· 499 499 extern unsigned int count_swap_pages(int, int); 500 500 extern sector_t swapdev_block(int, pgoff_t); 501 501 extern int __swap_count(swp_entry_t entry); 502 - extern int swap_swapcount(struct swap_info_struct *si, swp_entry_t entry); 502 + extern bool swap_entry_swapped(struct swap_info_struct *si, swp_entry_t entry); 503 503 extern int swp_swapcount(swp_entry_t entry); 504 504 struct swap_info_struct *swp_swap_info(swp_entry_t entry); 505 505 struct backing_dev_info; ··· 582 582 return 0; 583 583 } 584 584 585 - static inline int swap_swapcount(struct swap_info_struct *si, swp_entry_t entry) 585 + static inline bool swap_entry_swapped(struct swap_info_struct *si, swp_entry_t entry) 586 586 { 587 - return 0; 587 + return false; 588 588 } 589 589 590 590 static inline int swp_swapcount(swp_entry_t entry)
+1 -1
mm/swap_state.c
··· 457 457 * as SWAP_HAS_CACHE. That's done in later part of code or 458 458 * else swap_off will be aborted if we return NULL. 459 459 */ 460 - if (!swap_swapcount(si, entry) && swap_slot_cache_enabled) 460 + if (!swap_entry_swapped(si, entry) && swap_slot_cache_enabled) 461 461 goto put_and_return; 462 462 463 463 /*
+3 -3
mm/swapfile.c
··· 1620 1620 * This does not give an exact answer when swap count is continued, 1621 1621 * but does include the high COUNT_CONTINUED flag to allow for that. 1622 1622 */ 1623 - int swap_swapcount(struct swap_info_struct *si, swp_entry_t entry) 1623 + bool swap_entry_swapped(struct swap_info_struct *si, swp_entry_t entry) 1624 1624 { 1625 1625 pgoff_t offset = swp_offset(entry); 1626 1626 struct swap_cluster_info *ci; ··· 1629 1629 ci = lock_cluster(si, offset); 1630 1630 count = swap_count(si->swap_map[offset]); 1631 1631 unlock_cluster(ci); 1632 - return count; 1632 + return !!count; 1633 1633 } 1634 1634 1635 1635 /* ··· 1715 1715 return false; 1716 1716 1717 1717 if (!IS_ENABLED(CONFIG_THP_SWAP) || likely(!folio_test_large(folio))) 1718 - return swap_swapcount(si, entry) != 0; 1718 + return swap_entry_swapped(si, entry); 1719 1719 1720 1720 return swap_page_trans_huge_swapped(si, entry, folio_order(folio)); 1721 1721 }