aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHuang Ying <[email protected]>2021-06-28 19:37:16 -0700
committerLinus Torvalds <[email protected]>2021-06-29 10:53:49 -0700
commiteea4a5011ae520c98d0a14474ecde44f29659861 (patch)
tree2f10ab099dbacfe6f68b953cd8d5e6910cfcfbb7
parentf4c4a3f48480730214c4f02ffa480f6bf5b0718f (diff)
swap: check mapping_empty() for swap cache before being freed
To check whether all pages and shadow entries in swap cache has been removed before swap cache is freed. Link: https://lkml.kernel.org/r/[email protected] Signed-off-by: "Huang, Ying" <[email protected]> Cc: Miaohe Lin <[email protected]> Cc: Matthew Wilcox <[email protected]> Cc: Minchan Kim <[email protected]> Cc: Joonsoo Kim <[email protected]> Cc: Johannes Weiner <[email protected]> Cc: Vlastimil Babka <[email protected]> Cc: Hugh Dickins <[email protected]> Cc: Mel Gorman <[email protected]> Cc: Michal Hocko <[email protected]> Cc: Dan Williams <[email protected]> Cc: Christoph Hellwig <[email protected]> Cc: Ilya Dryomov <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
-rw-r--r--mm/swap_state.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/mm/swap_state.c b/mm/swap_state.c
index 4f8a912ff692..c56aa9ac050d 100644
--- a/mm/swap_state.c
+++ b/mm/swap_state.c
@@ -693,7 +693,12 @@ int init_swap_address_space(unsigned int type, unsigned long nr_pages)
void exit_swap_address_space(unsigned int type)
{
- kvfree(swapper_spaces[type]);
+ int i;
+ struct address_space *spaces = swapper_spaces[type];
+
+ for (i = 0; i < nr_swapper_spaces[type]; i++)
+ VM_WARN_ON_ONCE(!mapping_empty(&spaces[i]));
+ kvfree(spaces);
nr_swapper_spaces[type] = 0;
swapper_spaces[type] = NULL;
}