diff mbox series

[WIP,v1,15/20] mm/rmap_id: verify precalculated subids with CONFIG_DEBUG_VM

Message ID 20231124132626.235350-16-david@redhat.com (mailing list archive)
State New
Headers show
Series mm: precise "mapped shared" vs. "mapped exclusively" detection for PTE-mapped THP / partially-mappable folios | expand

Commit Message

David Hildenbrand Nov. 24, 2023, 1:26 p.m. UTC
Let's verify the precalculated subids for 4/5/6 values.

Signed-off-by: David Hildenbrand <david@redhat.com>
---
 mm/rmap_id.c | 26 ++++++++++++++++++++++++++
 1 file changed, 26 insertions(+)
diff mbox series

Patch

diff --git a/mm/rmap_id.c b/mm/rmap_id.c
index 6c3187547741..421d8d2b646c 100644
--- a/mm/rmap_id.c
+++ b/mm/rmap_id.c
@@ -481,3 +481,29 @@  void free_rmap_id(int id)
 	ida_free(&rmap_ida, id);
 	spin_unlock(&rmap_id_lock);
 }
+
+#ifdef CONFIG_DEBUG_VM
+static int __init rmap_id_init(void)
+{
+	int i;
+
+	for (i = 0; i < ARRAY_SIZE(rmap_subids_4); i++)
+		WARN_ON_ONCE(calc_rmap_subid(1u << RMAP_SUBID_4_MAX_ORDER, i) !=
+			     rmap_subids_4[i]);
+
+#if MAX_ORDER >= RMAP_SUBID_5_MIN_ORDER
+	for (i = 0; i < ARRAY_SIZE(rmap_subids_5); i++)
+		WARN_ON_ONCE(calc_rmap_subid(1u << RMAP_SUBID_5_MAX_ORDER, i) !=
+			     rmap_subids_5[i]);
+#endif
+
+#if MAX_ORDER >= RMAP_SUBID_6_MIN_ORDER
+	for (i = 0; i < ARRAY_SIZE(rmap_subids_6); i++)
+		WARN_ON_ONCE(calc_rmap_subid(1u << RMAP_SUBID_6_MAX_ORDER, i) !=
+			     rmap_subids_6[i]);
+#endif
+
+	return 0;
+}
+module_init(rmap_id_init)
+#endif /* CONFIG_DEBUG_VM */