On Fri, May 3, 2024 at 2:31 AM Ryan Roberts <ryan.roberts@xxxxxxx> wrote: > > On 03/05/2024 01:50, Barry Song wrote: > > From: Barry Song <v-songbaohua@xxxxxxxx> > > > > To streamline maintenance efforts, we propose discontinuing the use of > > swap_free(). Instead, we can simply invoke swap_free_nr() with nr set > > to 1. This adjustment offers the advantage of enabling batch processing > > within kernel/power/swap.c. Furthermore, swap_free_nr() is designed with > > a bitmap consisting of only one long, resulting in overhead that can be > > ignored for cases where nr equals 1. > > > > Suggested-by: "Huang, Ying" <ying.huang@xxxxxxxxx> > > Signed-off-by: Barry Song <v-songbaohua@xxxxxxxx> > > Cc: "Rafael J. Wysocki" <rafael@xxxxxxxxxx> > > Cc: Pavel Machek <pavel@xxxxxx> > > Cc: Len Brown <len.brown@xxxxxxxxx> > > Cc: Hugh Dickins <hughd@xxxxxxxxxx> > > --- > > include/linux/swap.h | 5 ----- > > kernel/power/swap.c | 7 +++---- > > mm/memory.c | 2 +- > > mm/rmap.c | 4 ++-- > > mm/shmem.c | 4 ++-- > > mm/swapfile.c | 19 +++++-------------- > > 6 files changed, 13 insertions(+), 28 deletions(-) > > > > diff --git a/include/linux/swap.h b/include/linux/swap.h > > index d1d35e92d7e9..f03cb446124e 100644 > > --- a/include/linux/swap.h > > +++ b/include/linux/swap.h > > @@ -482,7 +482,6 @@ extern int add_swap_count_continuation(swp_entry_t, gfp_t); > > extern void swap_shmem_alloc(swp_entry_t); > > extern int swap_duplicate(swp_entry_t); > > extern int swapcache_prepare(swp_entry_t); > > -extern void swap_free(swp_entry_t); > > I wonder if it would be cleaner to: > > #define swap_free(entry) swap_free_nr((entry), 1) > > To save all the churn for the callsites that just want to pass a single entry? > Either way works. It will produce the same machine code. I have a slight inclination to just drop swap_free(entry) API so that it discourages the caller to do a for loop over swap_free(). Acked-by: Chris Li <chrisl@xxxxxxxxxx> Chris