[PATCH v12 1/3] mm: swap: introduce the swap tier as a swap priority
From: Youngjun Park
Date: Wed Dec 02 2026 - 03:48:44 EST
Per-cgroup swap device selection needs a notion of swap tier. Devices of
one priority are used round-robin and different priorities are strictly
ordered, so a priority already works as a tier. Add swap_tier() and
SWAP_TIER_MAX (no limit) to say so in code, instead of adding a separate
tier structure.
No functional change.
Suggested-by: Chris Li <chrisl@xxxxxxxxxx>
Signed-off-by: Youngjun Park <youngjun.park@xxxxxxx>
---
mm/swapfile.c | 12 ++++++++++++
1 file changed, 12 insertions(+)
diff --git a/mm/swapfile.c b/mm/swapfile.c
index d59fa8220862..95928d9f85da 100644
--- a/mm/swapfile.c
+++ b/mm/swapfile.c
@@ -1427,6 +1427,18 @@ static bool get_swap_device_info(struct swap_info_struct *si)
return true;
}
+/*
+ * A swap tier is a swap priority: devices of the same priority are used
+ * round-robin and different priorities are strictly ordered.
+ * SWAP_TIER_MAX means no tier limit.
+ */
+#define SWAP_TIER_MAX SHRT_MAX
+
+static inline short swap_tier(struct swap_info_struct *si)
+{
+ return si->prio;
+}
+
/*
* Fast path try to get swap entries with specified order from current
* CPU's swap entry pool (a cluster).
--
2.34.1