Skip to contentSkip to conversation

mm/swap: skip readahead for unreferenced swap slots

PATCH New [email protected] 1 participant 1 message Feb 22, 2017

Subsystems (2)
lore
Share & tools
lore

[email protected]

author maintainer
#0 lore raw

PATCH 115/142 mm/swap: skip readahead for unreferenced swap slots

From: Tim Chen <[email protected]>
Subject: mm/swap: skip readahead 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.

Cc Aaron Lu <[email protected]>
Cc Andi Kleen <[email protected]>
Cc Andrea Arcangeli <[email protected]>
Cc Christian Borntraeger <[email protected]>
Cc Dave Hansen <[email protected]>
Cc Hillf Danton <[email protected]>
Cc Huang Ying <[email protected]>
Cc Hugh Dickins <[email protected]>
Cc Johannes Weiner <[email protected]>
Cc Jonathan Corbet <[email protected]> escreveu:
Cc Kirill A. Shutemov <[email protected]>
Cc Michal Hocko <[email protected]>
Cc Minchan Kim <[email protected]>
Cc Rik van Riel <[email protected]>
Cc Shaohua Li <[email protected]>
Cc Vladimir Davydov <[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 renamed from include/linux/swap.h~mm-swap-skip-read-ahead-for-unreferenced-swap-slots +6 -0
diff -puN include/linux/swap.h~mm-swap-skip-read-ahead-for-unreferenced-swap-slots include/linux/swap.h
@@ -398,6 +398,7 @@ extern unsigned int count_swap_pages(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 *);
@@ -491,6 +492,11 @@ static inline int page_swapcount(struct
 {
 	return 0;
 }
+
+static inline int __swp_swapcount(swp_entry_t entry)
+{
+	return 0;
+}
 
 static inline int swp_swapcount(swp_entry_t entry)
 {
mm/swap_state.c renamed from mm/swap_state.c~mm-swap-skip-read-ahead-for-unreferenced-swap-slots +4 -0
diff -puN mm/swap_state.c~mm-swap-skip-read-ahead-for-unreferenced-swap-slots mm/swap_state.c
@@ -323,6 +323,10 @@ struct page *__read_swap_cache_async(swp
 		if (found_page)
 			break;
 
+		/* Just skip read ahead for unused swap slot */
+		if (!__swp_swapcount(entry))
+			return NULL;
+
 		/*
 		 * Get a new page to read into from swap.
 		 */
mm/swapfile.c renamed from mm/swapfile.c~mm-swap-skip-read-ahead-for-unreferenced-swap-slots +41 -6

73 lines not on this page · raw message

_