diff mbox series

[RFC,v1,2/5] mm: swap: Change SWAP_NEXT_INVALID to highest value

Message ID 20240618232648.4090299-3-ryan.roberts@arm.com (mailing list archive)
State New
Headers show
Series Alternative mTHP swap allocator improvements | expand

Commit Message

Ryan Roberts June 18, 2024, 11:26 p.m. UTC
We are about to introduce a scanning mechanism that can present 0 as a
valid cluster offset to scan_swap_map_try_ssd_cluster(), so let's change
SWAP_NEXT_INVALID to UINT_MAX, which is always invalid as an offset in
practice.

Signed-off-by: Ryan Roberts <ryan.roberts@arm.com>
---
 include/linux/swap.h | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

--
2.43.0
diff mbox series

Patch

diff --git a/include/linux/swap.h b/include/linux/swap.h
index bd450023b9a4..66566251ba31 100644
--- a/include/linux/swap.h
+++ b/include/linux/swap.h
@@ -261,12 +261,12 @@  struct swap_cluster_info {
 #define CLUSTER_FLAG_NEXT_NULL 2 /* This cluster has no next cluster */

 /*
- * The first page in the swap file is the swap header, which is always marked
- * bad to prevent it from being allocated as an entry. This also prevents the
- * cluster to which it belongs being marked free. Therefore 0 is safe to use as
- * a sentinel to indicate next is not valid in percpu_cluster.
+ * swap_info_struct::max is an unsigned int, so the maximum number of pages in
+ * the swap file is UINT_MAX. Therefore the highest legitimate index is
+ * UINT_MAX-1. Therefore UINT_MAX is safe to use as a sentinel to indicate next
+ * is not valid in percpu_cluster.
  */
-#define SWAP_NEXT_INVALID	0
+#define SWAP_NEXT_INVALID	UINT_MAX

 #ifdef CONFIG_THP_SWAP
 #define SWAP_NR_ORDERS		(PMD_ORDER + 1)