mm/swap: skip read ahead for unreferenced swap slots
Subsystems (2)
PATCH 4/8 mm/swap: skip read ahead for unreferenced swap slots
We can avoid needlessly allocating page for swap slots that are not used by anyone. No pages have to be read in for these slots.
Signed-off-by Tim Chen <[email protected]>
Signed-off-by "Huang, Ying" <[email protected]>
--- include/linux/swap.h | 6 ++++++ mm/swap_state.c | 4 ++++ mm/swapfile.c | 47 +++++++++++++++++++++++++++++++++++++++++------ 3 files changed, 51 insertions(+), 6 deletions(-)
include/linux/swap.h +6 -0
@@ -422,6 +422,7 @@ extern unsigned int count_swap_pages(int, int);extern sector_t map_swap_page (struct page *,struct block_device **);extern sector_t swapdev_block (int ,pgoff_t );extern int page_swapcount (struct page *); +extern int __swp_swapcount (swp_entry_t entry);extern int swp_swapcount (swp_entry_t entry);extern struct swap_info_struct *page_swap_info (struct page *);extern bool reuse_swap_page (struct page *,int *);
@@ -516,6 +517,11 @@ static inline int page_swapcount(struct page *page)return 0 ; } +static inline int __swp_swapcount (swp_entry_t entry) +{ +return 0 ; +} +static inline int swp_swapcount (swp_entry_t entry) {return 0 ;
mm/swap_state.c +4 -0
@@ -316,6 +316,10 @@ struct page *__read_swap_cache_async(swp_entry_t entry, gfp_t gfp_mask, *new_page_allocated = false; do { + /* Just skip read ahead for unused swap slot */ + if (!__swp_swapcount(entry)) + return NULL; + /* * First check the swap cache. Since this is normally * called after lookup_swap_cache() failed, re-calling
mm/swapfile.c +41 -6
73 lines not on this page · raw message
Signature · 7 lines
2.5.5 -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"[email protected]"> [email protected] </a>