Cleanups for swap
Subsystems (2)
v2 cover Cleanups for swap
Hi all,
This series contains just cleanups to remove some unused variables, delete meaningless forward declarations and so on. More details can be found in the respective changelogs. Thanks!
v1->v2:
collect Reviewed-by tag
get rid of patch "mm/swap: simplify the code of find_get_incore_page()"
Miaohe Lin (4):
mm/swapfile: move get_swap_page_of_type() under CONFIG_HIBERNATION mm/swap: remove unused local variable nr_shadows mm/swap_slots.c: delete meaningless forward declarations mm/swap: remove unused global variable nr_swapper_spaces
mm/swap_slots.c | 2 -- mm/swap_state.c | 8 -------- mm/swapfile.c | 48 ++++++++++++++++++++++++------------------------ 3 files changed, 24 insertions(+), 34 deletions(-)
Signature · 1 line
2.23.0
PATCH v2 1/4 mm/swapfile: move get_swap_page_of_type() under CONFIG_HIBERNATION
We should move get_swap_page_of_type() under CONFIG_HIBERNATION since the only caller of this function is now suspend routine.
--- mm/swapfile.c | 48 ++++++++++++++++++++++++------------------------ 1 file changed, 24 insertions(+), 24 deletions(-)
mm/swapfile.c +24 -24
@@ -1137,30 +1137,6 @@ int get_swap_pages(int n_goal, swp_entry_t swp_entries[], int entry_size)return n_ret; } -/* The only caller of this function is now suspend routine */ -swp_entry_t get_swap_page_of_type (int type) -{ -struct swap_info_struct *si =swap_type_to_swap_info (type); -pgoff_t offset; - -if (!si) - goto fail; - -spin_lock (&si->lock); -if (si->flags &SWP_WRITEOK ) { -/* This is called for allocating swap entry, not cache */ - offset =scan_swap_map (si,1 ); -if (offset) { -atomic_long_dec (&nr_swap_pages); -spin_unlock (&si->lock); -return swp_entry (type, offset); - } - } -spin_unlock (&si->lock); -fail: -return (swp_entry_t ) {0 }; -} -static struct swap_info_struct *__swap_info_get (swp_entry_t entry) {struct swap_info_struct *p;
@@ -1812,6 +1788,30 @@ int free_swap_and_cache(swp_entry_t entry) }#ifdef CONFIG_HIBERNATION + +swp_entry_t get_swap_page_of_type (int type) +{ +struct swap_info_struct *si =swap_type_to_swap_info (type); +pgoff_t offset; + +if (!si) + goto fail; + +spin_lock (&si->lock); +if (si->flags &SWP_WRITEOK ) { +/* This is called for allocating swap entry, not cache */ + offset =scan_swap_map (si,1 ); +if (offset) { +atomic_long_dec (&nr_swap_pages); +spin_unlock (&si->lock); +return swp_entry (type, offset); + } + } +spin_unlock (&si->lock); +fail: +return (swp_entry_t ) {0 }; +} +/* * Find the swap type that corresponds to given device (if any). *
Signature · 1 line
2.23.0
PATCH v2 2/4 mm/swap: remove unused local variable nr_shadows
In reply to Miaohe LinSince commit 55c653b71e8c ("mm: stop accounting shadow entries"), nr_shadows is not used anymore.
--- mm/swap_state.c | 5 ----- 1 file changed, 5 deletions(-)
mm/swap_state.c +0 -5
@@ -114,8 +114,6 @@ int add_to_swap_cache(struct page *page, swp_entry_t entry,SetPageSwapCache (page); do { - unsigned long nr_shadows = 0; - xas_lock_irq(&xas); xas_create_range(&xas); if (xas_error(&xas))
@@ -124,7 +122,6 @@ int add_to_swap_cache(struct page *page, swp_entry_t entry,VM_BUG_ON_PAGE (xas.xa_index != idx + i, page); old =xas_load (&xas);if (xa_is_value (old)) { - nr_shadows++;if (shadowp) *shadowp = old; }
@@ -260,7 +257,6 @@ void clear_shadow_from_swap_cache(int type, unsigned long begin,void *old;for (;;) { -unsigned long nr_shadows =0 ;swp_entry_t entry =swp_entry (type, curr);struct address_space *address_space =swap_address_space (entry);XA_STATE (xas, &address_space->i_pages, curr);
@@ -270,7 +266,6 @@ void clear_shadow_from_swap_cache(int type, unsigned long begin,if (!xa_is_value (old))continue ;xas_store (&xas,NULL ); - nr_shadows++; }xa_unlock_irq (&address_space->i_pages);
Signature · 1 line
2.23.0
PATCH v2 3/4 mm/swap_slots.c: delete meaningless forward declarations
In reply to Miaohe Lindeactivate_swap_slots_cache() and reactivate_swap_slots_cache() are only called below their implementations. So these forward declarations are meaningless and should be removed.
--- mm/swap_slots.c | 2 -- 1 file changed, 2 deletions(-)
mm/swap_slots.c +0 -2
@@ -43,8 +43,6 @@ static DEFINE_MUTEX(swap_slots_cache_mutex);static DEFINE_MUTEX (swap_slots_cache_enable_mutex);static void __drain_swap_slots_cache (unsigned int type); -static void deactivate_swap_slots_cache (void ); -static void reactivate_swap_slots_cache (void );#define use_swap_slot_cache (swap_slot_cache_active && swap_slot_cache_enabled)#define SLOTS_CACHE 0x1
Signature · 1 line
2.23.0
PATCH v2 4/4 mm/swap: remove unused global variable nr_swapper_spaces
In reply to Miaohe LinSince commit b6038942480e ("mm: memcg: add swapcache stat for memcg v2"), the last user of nr_swapper_spaces is gone. So we remove this unused one.
--- mm/swap_state.c | 3 --- 1 file changed, 3 deletions(-)
mm/swap_state.c +0 -3
@@ -37,7 +37,6 @@ static const struct address_space_operations swap_aops = { };struct address_space *swapper_spaces[MAX_SWAPFILES ]__read_mostly ; -static unsigned int nr_swapper_spaces[MAX_SWAPFILES ]__read_mostly ;static bool enable_vma_readahead__read_mostly = true;#define SWAP_RA_WIN_SHIFT (PAGE_SHIFT / 2)
@@ -685,7 +684,6 @@ int init_swap_address_space(unsigned int type, unsigned long nr_pages)/* swap cache doesn't use writeback related tags */ mapping_set_no_writeback_tags (space); } - nr_swapper_spaces[type] = nr; swapper_spaces[type] = spaces;return 0 ;
@@ -694,7 +692,6 @@ int init_swap_address_space(unsigned int type, unsigned long nr_pages)void exit_swap_address_space (unsigned int type) {kvfree (swapper_spaces[type]); - nr_swapper_spaces[type] =0 ; swapper_spaces[type] =NULL ; }
Signature · 1 line
2.23.0