mm/swap: allocate swap slots in batches
Subsystems (2)
[email protected]
maintainerPATCH 116/142 mm/swap: allocate swap slots in batches
From: Tim Chen <[email protected]>
Subject: mm/swap: allocate swap slots in batches
Currently, the swap slots are allocated one page at a time, causing contention to the swap_info lock protecting the swap partition on every page being swapped.
This patch adds new functions get_swap_pages and scan_swap_map_slots to request multiple swap slots at once. This will reduces the lock contention on the swap_info lock. Also scan_swap_map_slots can operate more efficiently as swap slots often occurs in clusters close to each other on a swap device and it is quicker to allocate them together.
Link http://lkml.kernel.org/r/9fec2845544371f62c3763d43510045e33d286a6.1484082593.git.tim.c.chen@linux.intel.com open here
Signed-off-by Tim Chen <[email protected]>
Signed-off-by "Huang, Ying" <[email protected]>
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]>
Signed-off-by Andrew Morton <[email protected]>
---
include/linux/swap.h | 2 mm/swapfile.c | 136 +++++++++++++++++++++++++++++++++-------- 2 files changed, 113 insertions(+), 25 deletions(-)
include/linux/swap.h renamed from include/linux/swap.h~mm-swap-allocate-swap-slots-in-batches +2 -0
@@ -27,6 +27,7 @@ struct bio;#define SWAP_FLAGS_VALID (SWAP_FLAG_PRIO_MASK | SWAP_FLAG_PREFER | \ SWAP_FLAG_DISCARD | SWAP_FLAG_DISCARD_ONCE | \ SWAP_FLAG_DISCARD_PAGES) +#define SWAP_BATCH 64static inline int current_is_kswapd (void ) {
@@ -386,6 +387,7 @@ static inline long get_nr_swap_pages(voiextern void si_swapinfo (struct sysinfo *);extern swp_entry_t get_swap_page (void );extern swp_entry_t get_swap_page_of_type (int ); +extern int get_swap_pages (int n,swp_entry_t swp_entries[]);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 );
mm/swapfile.c renamed from mm/swapfile.c~mm-swap-allocate-swap-slots-in-batches +111 -25
220 lines not on this page · raw message
_