Kairui Song <ryncsn@xxxxxxxxx> writes: > From: Kairui Song <kasong@xxxxxxxxxxx> > > There is only one caller in swap subsystem now, where it can be inline > smoothly, avoid the memory access and function call overheads. > > Signed-off-by: Kairui Song <kasong@xxxxxxxxxxx> > --- > include/linux/swap.h | 6 ------ > mm/swap_state.c | 6 +++--- > mm/swapfile.c | 8 -------- > 3 files changed, 3 insertions(+), 17 deletions(-) > > diff --git a/include/linux/swap.h b/include/linux/swap.h > index 2401990d954d..64a37819a9b3 100644 > --- a/include/linux/swap.h > +++ b/include/linux/swap.h > @@ -485,7 +485,6 @@ int swap_type_of(dev_t device, sector_t offset); > int find_first_swap(dev_t *device); > extern unsigned int count_swap_pages(int, int); > extern sector_t swapdev_block(int, pgoff_t); > -extern int __swap_count(swp_entry_t entry); > extern int swap_swapcount(struct swap_info_struct *si, swp_entry_t entry); > extern int swp_swapcount(swp_entry_t entry); > extern struct swap_info_struct *page_swap_info(struct page *); > @@ -559,11 +558,6 @@ static inline void put_swap_folio(struct folio *folio, swp_entry_t swp) > { > } > > -static inline int __swap_count(swp_entry_t entry) > -{ > - return 0; > -} > - > static inline int swap_swapcount(struct swap_info_struct *si, swp_entry_t entry) > { > return 0; > diff --git a/mm/swap_state.c b/mm/swap_state.c > index fb78f7f18ed7..d87c20f9f7ec 100644 > --- a/mm/swap_state.c > +++ b/mm/swap_state.c > @@ -316,9 +316,9 @@ void free_pages_and_swap_cache(struct encoded_page **pages, int nr) > release_pages(pages, nr); > } > > -static inline bool swap_use_no_readahead(struct swap_info_struct *si, swp_entry_t entry) > +static inline bool swap_use_no_readahead(struct swap_info_struct *si, pgoff_t offset) > { > - return data_race(si->flags & SWP_SYNCHRONOUS_IO) && __swap_count(entry) == 1; > + return data_race(si->flags & SWP_SYNCHRONOUS_IO) && swap_count(si->swap_map[offset]) == 1; > } > > static inline bool swap_use_vma_readahead(struct swap_info_struct *si) > @@ -928,7 +928,7 @@ struct page *swapin_readahead(swp_entry_t entry, gfp_t gfp_mask, > > si = swp_swap_info(entry); > mpol = get_vma_policy(vmf->vma, vmf->address, 0, &ilx); > - if (swap_use_no_readahead(si, entry)) { > + if (swap_use_no_readahead(si, swp_offset(entry))) { > page = swapin_no_readahead(entry, gfp_mask, mpol, ilx, vmf->vma->vm_mm); > cached = false; > } else if (swap_use_vma_readahead(si)) { > diff --git a/mm/swapfile.c b/mm/swapfile.c > index a8ae472ed2b6..e15a6c464a38 100644 > --- a/mm/swapfile.c > +++ b/mm/swapfile.c > @@ -1431,14 +1431,6 @@ void swapcache_free_entries(swp_entry_t *entries, int n) > spin_unlock(&p->lock); > } > > -int __swap_count(swp_entry_t entry) > -{ > - struct swap_info_struct *si = swp_swap_info(entry); > - pgoff_t offset = swp_offset(entry); > - > - return swap_count(si->swap_map[offset]); > -} > - I'd rather keep __swap_count() in the original place together with other swap count related functions. And si->swap_map[] was hided in swapfile.c before. I don't think the change will have any real performance improvement. > /* > * How many references to @entry are currently swapped out? > * This does not give an exact answer when swap count is continued, -- Best Regards, Huang, Ying