[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20240809220141.341047-1-bottaawesome633@gmail.com>
Date: Sat, 10 Aug 2024 01:01:41 +0300
From: Ahmed Ehab <bottaawesome633@...il.com>
To: linux-kernel@...r.kernel.org,
Peter Zijlstra <peterz@...radead.org>,
Ingo Molnar <mingo@...hat.com>,
Will Deacon <will@...nel.org>,
Waiman Long <longman@...hat.com>,
Boqun Feng <boqun.feng@...il.com>,
Andrew Morton <akpm@...ux-foundation.org>
Subject: [PATCH v5 2/2] locking/lockdep: Testing lock class and subclass got the same name pointer
Checking if the lockdep_map.name will change when setting the subclass.
It shouldn't change so that the lock class and subclass will have the same
name
Signed-off-by: Ahmed Ehab <bottaawesome633@...il.com>
---
lib/locking-selftest.c | 28 ++++++++++++++++++++++++++++
1 file changed, 28 insertions(+)
diff --git a/lib/locking-selftest.c b/lib/locking-selftest.c
index 6f6a5fc85b42..2b4650bdf833 100644
--- a/lib/locking-selftest.c
+++ b/lib/locking-selftest.c
@@ -2710,6 +2710,32 @@ static void local_lock_3B(void)
}
+static void lock_class_subclass_X1(void)
+{
+ const char *name_before_setting_subclass = rwsem_X1.dep_map.name;
+ const char *name_after_setting_subclass;
+
+ lockdep_set_subclass(&rwsem_X1, 1);
+ name_after_setting_subclass = rwsem_X1.dep_map.name;
+ DEBUG_LOCKS_WARN_ON(name_before_setting_subclass != name_after_setting_subclass);
+}
+
+/*
+ * after setting the subclass the lockdep_map.name changes
+ * if we initialize a new string literal for the subclass
+ * we will have a new name pointer
+ */
+static void class_subclass_X1_name_test(void)
+{
+ printk(" --------------------------------------------------------------------------\n");
+ printk(" | class and subclass name test|\n");
+ printk(" ---------------------\n");
+
+ print_testname("lock class and subclass same name");
+ dotest(lock_class_subclass_X1, SUCCESS, LOCKTYPE_RWSEM);
+ pr_cont("\n");
+}
+
static void local_lock_tests(void)
{
printk(" --------------------------------------------------------------------------\n");
@@ -2920,6 +2946,8 @@ void locking_selftest(void)
dotest(hardirq_deadlock_softirq_not_deadlock, FAILURE, LOCKTYPE_SPECIAL);
pr_cont("\n");
+ class_subclass_X1_name_test();
+
if (unexpected_testcase_failures) {
printk("-----------------------------------------------------------------\n");
debug_locks = 0;
--
2.45.2
Powered by blists - more mailing lists