Skip to contentSkip to conversation

mm, swap: add swap_cluster_list

PATCH New [email protected] 1 participant 1 message Oct 7, 2016

Subsystems (2)
lore
Share & tools
lore

[email protected]

author maintainer
#0 lore raw

PATCH 38/127 mm, swap: add swap_cluster_list

From: Huang Ying <[email protected]>
Subject: mm, swap: add swap_cluster_list

This is a code clean up patch without functionality changes. The swap_cluster_list data structure and its operations are introduced to provide some better encapsulation for the free cluster and discard cluster list operations. This avoid some code duplication, improved the code readability, and reduced the total line number.

---

 include/linux/swap.h |   11 ++-
 mm/swapfile.c        |  133 +++++++++++++++++++----------------------
 2 files changed, 70 insertions(+), 74 deletions(-)
include/linux/swap.h renamed from include/linux/swap.h~mm-swap-add-swap_cluster_list +7 -4
diff -puN include/linux/swap.h~mm-swap-add-swap_cluster_list include/linux/swap.h
@@ -191,6 +191,11 @@ struct percpu_cluster {
 	unsigned int next; /* Likely next allocation offset */
 };
 
+struct swap_cluster_list {
+	struct swap_cluster_info head;
+	struct swap_cluster_info tail;
+};
+
 /*
  * The in-memory structure used to track swap areas.
  */
@@ -203,8 +208,7 @@ struct swap_info_struct {
 	unsigned int	max;		/* extent of the swap_map */
 	unsigned char *swap_map;	/* vmalloc'ed array of usage counts */
 	struct swap_cluster_info *cluster_info; /* cluster info. Only for SSD */
-	struct swap_cluster_info free_cluster_head; /* free cluster list head */
-	struct swap_cluster_info free_cluster_tail; /* free cluster list tail */
+	struct swap_cluster_list free_clusters; /* free clusters list */
 	unsigned int lowest_bit;	/* index of first free in swap_map */
 	unsigned int highest_bit;	/* index of last free in swap_map */
 	unsigned int pages;		/* total of usable pages of swap */
@@ -235,8 +239,7 @@ struct swap_info_struct {
 					 * first.
 					 */
 	struct work_struct discard_work; /* discard worker */
-	struct swap_cluster_info discard_cluster_head; /* list head of discard clusters */
-	struct swap_cluster_info discard_cluster_tail; /* list tail of discard clusters */
+	struct swap_cluster_list discard_clusters; /* discard clusters list */
 };
 
 /* linux/mm/workingset.c */
mm/swapfile.c renamed from mm/swapfile.c~mm-swap-add-swap_cluster_list +61 -64

184 lines not on this page · raw message