Skip to contentSkip to conversation

swap-change-swap_list_head-to-plist-add-swap_avail_head.patch removed from -mm tree

merged [email protected] 1 participant 1 message Jun 5, 2014

Subsystems (2)
lore
Share & tools
lore

[email protected]

author maintainer
#0 lore raw

Subject: [merged] swap-change-swap_list_head-to-plist-add-swap_avail_head.patch removed from -mm tree
To: [email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected]
From: [email protected]
Date: Thu, 05 Jun 2014 12:52:07 -0700

The patch titled
Subject: swap: change swap_list_head to plist, add swap_avail_head
has been removed from the -mm tree. Its filename was
swap-change-swap_list_head-to-plist-add-swap_avail_head.patch

This patch was dropped because it was merged into mainline or a subsystem tree

------------------------------------------------------
From: Dan Streetman <[email protected]>
Subject: swap: change swap_list_head to plist, add swap_avail_head

Originally get_swap_page() started iterating through the singly-linked list of swap_info_structs using swap_list.next or highest_priority_index, which both were intended to point to the highest priority active swap target that was not full. The first patch in this series changed the singly-linked list to a doubly-linked list, and removed the logic to start at the highest priority non-full entry; it starts scanning at the highest priority entry each time, even if the entry is full.

Replace the manually ordered swap_list_head with a plist, swap_active_head. Add a new plist, swap_avail_head. The original swap_active_head plist contains all active swap_info_structs, as before, while the new swap_avail_head plist contains only swap_info_structs that are active and available, i.e. not full. Add a new spinlock, swap_avail_lock, to protect the swap_avail_head list.

Mel Gorman suggested using plists since they internally handle ordering the list entries based on priority, which is exactly what swap was doing manually. All the ordering code is now removed, and swap_info_struct entries and simply added to their corresponding plist and automatically ordered correctly.

Using a new plist for available swap_info_structs simplifies and optimizes get_swap_page(), which no longer has to iterate over full swap_info_structs. Using a new spinlock for swap_avail_head plist allows each swap_info_struct to add or remove themselves from the plist when they become full or not-full; previously they could not do so because the swap_info_struct->lock is held when they change from full<->not-full, and the swap_lock protecting the main swap_active_head must be ordered before any swap_info_struct->lock.

Cc Shaohua Li <[email protected]>
Cc Steven Rostedt <[email protected]>
Cc Peter Zijlstra <[email protected]>
Cc Hugh Dickins <[email protected]>
Cc Dan Streetman <[email protected]>
Cc Michal Hocko <[email protected]>
Cc Christian Ehrhardt <[email protected]>
Cc Weijie Yang <[email protected]>
Cc Rik van Riel <[email protected]>
Cc Johannes Weiner <[email protected]>
Cc Bob Liu <[email protected]>
Cc Paul Gortmaker <[email protected]>
Cc Thomas Gleixner <[email protected]>

---

 include/linux/swap.h     |    3 
 include/linux/swapfile.h |    2 
 mm/frontswap.c           |    6 -
 mm/swapfile.c            |  145 +++++++++++++++++++++++--------------
 4 files changed, 97 insertions(+), 59 deletions(-)
include/linux/swap.h renamed from include/linux/swap.h~swap-change-swap_list_head-to-plist-add-swap_avail_head +2 -1
diff -puN include/linux/swap.h~swap-change-swap_list_head-to-plist-add-swap_avail_head include/linux/swap.h
@@ -214,7 +214,8 @@ struct percpu_cluster {
 struct swap_info_struct {
 	unsigned long	flags;		/* SWP_USED etc: see above */
 	signed short	prio;		/* swap priority of this type */
-	struct list_head list;		/* entry in swap list */
+	struct plist_node list;		/* entry in swap_active_head */
+	struct plist_node avail_list;	/* entry in swap_avail_head */
 	signed char	type;		/* strange name for an index */
 	unsigned int	max;		/* extent of the swap_map */
 	unsigned char *swap_map;	/* vmalloc'ed array of usage counts */
include/linux/swapfile.h renamed from include/linux/swapfile.h~swap-change-swap_list_head-to-plist-add-swap_avail_head +1 -1
diff -puN include/linux/swapfile.h~swap-change-swap_list_head-to-plist-add-swap_avail_head include/linux/swapfile.h
@@ -6,7 +6,7 @@
  * want to expose them to the dozens of source files that include swap.h
  */
 extern spinlock_t swap_lock;
-extern struct list_head swap_list_head;
+extern struct plist_head swap_active_head;
 extern struct swap_info_struct *swap_info[];
 extern int try_to_unuse(unsigned int, bool, unsigned long);
 
mm/frontswap.c renamed from mm/frontswap.c~swap-change-swap_list_head-to-plist-add-swap_avail_head +3 -3
diff -puN mm/frontswap.c~swap-change-swap_list_head-to-plist-add-swap_avail_head mm/frontswap.c
@@ -331,7 +331,7 @@ static unsigned long __frontswap_curr_pa
 	struct swap_info_struct *si = NULL;
 
 	assert_spin_locked(&swap_lock);
-	list_for_each_entry(si, &swap_list_head, list)
+	plist_for_each_entry(si, &swap_active_head, list)
 		totalpages += atomic_read(&si->frontswap_pages);
 	return totalpages;
 }
@@ -346,7 +346,7 @@ static int __frontswap_unuse_pages(unsig
 	unsigned long pages = 0, pages_to_unuse = 0;
 
 	assert_spin_locked(&swap_lock);
-	list_for_each_entry(si, &swap_list_head, list) {
+	plist_for_each_entry(si, &swap_active_head, list) {
 		si_frontswap_pages = atomic_read(&si->frontswap_pages);
 		if (total_pages_to_unuse < si_frontswap_pages) {
 			pages = pages_to_unuse = total_pages_to_unuse;
@@ -408,7 +408,7 @@ void frontswap_shrink(unsigned long targ
 	/*
 	 * we don't want to hold swap_lock while doing a very
 	 * lengthy try_to_unuse, but swap_list may change
-	 * so restart scan from swap_list_head each time
+	 * so restart scan from swap_active_head each time
 	 */
 	spin_lock(&swap_lock);
 	ret = __frontswap_shrink(target_pages, &pages_to_unuse, &type);
mm/swapfile.c renamed from mm/swapfile.c~swap-change-swap_list_head-to-plist-add-swap_avail_head +91 -54

238 lines not on this page · raw message

_

Patches currently in -mm which might be from [email protected] are

origin.patch
linux-next.patch