Skip to contentSkip to conversation

mm-swap-use-an-enum-to-define-all-cluster-flags-and-wrap-flags-changes.patch removed from -mm tree

merged mm-stable Andrew Morton 1 participant 1 message Jan 16, 2025

lore
Share & tools
lore

Andrew Morton

author tree notice Applied
#0 lore raw

The quilt patch titled
Subject: mm, swap: use an enum to define all cluster flags and wrap flags changes
has been removed from the -mm tree. Its filename was
mm-swap-use-an-enum-to-define-all-cluster-flags-and-wrap-flags-changes.patch

This patch was dropped because it was merged into the mm-stable branch of git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm

------------------------------------------------------
From: Kairui Song <[email protected]>
Subject: mm, swap: use an enum to define all cluster flags and wrap flags changes
Date: Tue, 14 Jan 2025 01:57:27 +0800

Currently, we are only using flags to indicate which list the cluster is on. Using one bit for each list type might be a waste, as the list type grows, we will consume too many bits. Additionally, the current mixed usage of '&' and '==' is a bit confusing.

Make it clean by using an enum to define all possible cluster statuses. Only an off-list cluster will have the NONE (0) flag. And use a wrapper to annotate and sanitize all flag settings and list movements.

---

 include/linux/swap.h |   17 +++++++--
 mm/swapfile.c        |   76 +++++++++++++++++++++--------------------
 2 files changed, 53 insertions(+), 40 deletions(-)
include/linux/swap.h renamed from include/linux/swap.h~mm-swap-use-an-enum-to-define-all-cluster-flags-and-wrap-flags-changes +13 -4
@@ -256,10 +256,19 @@ struct swap_cluster_info {
 	u8 order;
 	struct list_head list;
 };
-#define CLUSTER_FLAG_FREE 1 /* This cluster is free */
-#define CLUSTER_FLAG_NONFULL 2 /* This cluster is on nonfull list */
-#define CLUSTER_FLAG_FRAG 4 /* This cluster is on nonfull list */
-#define CLUSTER_FLAG_FULL 8 /* This cluster is on full list */
+
+/* All on-list cluster must have a non-zero flag. */
+enum swap_cluster_flags {
+	CLUSTER_FLAG_NONE = 0, /* For temporary off-list cluster */
+	CLUSTER_FLAG_FREE,
+	CLUSTER_FLAG_NONFULL,
+	CLUSTER_FLAG_FRAG,
+	/* Clusters with flags above are allocatable */
+	CLUSTER_FLAG_USABLE = CLUSTER_FLAG_FRAG,
+	CLUSTER_FLAG_FULL,
+	CLUSTER_FLAG_DISCARD,
+	CLUSTER_FLAG_MAX,
+};
 
 /*
  * The first page in the swap file is the swap header, which is always marked
mm/swapfile.c renamed from mm/swapfile.c~mm-swap-use-an-enum-to-define-all-cluster-flags-and-wrap-flags-changes +40 -36

137 lines not on this page · raw message

_

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