All of lore.kernel.org
 help / color / mirror / Atom feed
From: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
To: linux-kernel@vger.kernel.org
Cc: Ben Segall <bsegall@google.com>,
	Boqun Feng <boqun.feng@gmail.com>,
	Daniel Bristot de Oliveira <bristot@redhat.com>,
	Dietmar Eggemann <dietmar.eggemann@arm.com>,
	Ingo Molnar <mingo@redhat.com>,
	Juri Lelli <juri.lelli@redhat.com>, Mel Gorman <mgorman@suse.de>,
	Peter Zijlstra <peterz@infradead.org>,
	Steven Rostedt <rostedt@goodmis.org>,
	Thomas Gleixner <tglx@linutronix.de>,
	Vincent Guittot <vincent.guittot@linaro.org>,
	Waiman Long <longman@redhat.com>, Will Deacon <will@kernel.org>,
	Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Subject: [PATCH 06/11] lockdep/selftests: Avoid using local_lock_{acquire|release}().
Date: Mon, 29 Nov 2021 18:46:49 +0100	[thread overview]
Message-ID: <20211129174654.668506-7-bigeasy@linutronix.de> (raw)
In-Reply-To: <20211129174654.668506-1-bigeasy@linutronix.de>

The local_lock related functions
  local_lock_acquire()
  local_lock_release()

are part of the internal implementation and should be avoided.
Define the lock as DEFINE_PER_CPU so the normal local_lock() function
can be used.

Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
---
 lib/locking-selftest.c | 32 ++++++++++++++++----------------
 1 file changed, 16 insertions(+), 16 deletions(-)

diff --git a/lib/locking-selftest.c b/lib/locking-selftest.c
index 71652e1c397cf..4d614c74e6ec5 100644
--- a/lib/locking-selftest.c
+++ b/lib/locking-selftest.c
@@ -139,7 +139,7 @@ static DEFINE_RT_MUTEX(rtmutex_Z2);
 
 #endif
 
-static local_lock_t local_A = INIT_LOCAL_LOCK(local_A);
+static DEFINE_PER_CPU(local_lock_t, local_A);
 
 /*
  * non-inlined runtime initializers, to let separate locks share
@@ -1320,7 +1320,7 @@ GENERATE_PERMUTATIONS_3_EVENTS(irq_read_recursion3_soft_wlock)
 # define I_MUTEX(x)	lockdep_reset_lock(&mutex_##x.dep_map)
 # define I_RWSEM(x)	lockdep_reset_lock(&rwsem_##x.dep_map)
 # define I_WW(x)	lockdep_reset_lock(&x.dep_map)
-# define I_LOCAL_LOCK(x) lockdep_reset_lock(&local_##x.dep_map)
+# define I_LOCAL_LOCK(x) lockdep_reset_lock(this_cpu_ptr(&local_##x.dep_map))
 #ifdef CONFIG_RT_MUTEXES
 # define I_RTMUTEX(x)	lockdep_reset_lock(&rtmutex_##x.dep_map)
 #endif
@@ -1380,7 +1380,7 @@ static void reset_locks(void)
 	init_shared_classes();
 	raw_spin_lock_init(&raw_lock_A);
 	raw_spin_lock_init(&raw_lock_B);
-	local_lock_init(&local_A);
+	local_lock_init(this_cpu_ptr(&local_A));
 
 	ww_mutex_init(&o, &ww_lockdep); ww_mutex_init(&o2, &ww_lockdep); ww_mutex_init(&o3, &ww_lockdep);
 	memset(&t, 0, sizeof(t)); memset(&t2, 0, sizeof(t2));
@@ -2646,8 +2646,8 @@ static void wait_context_tests(void)
 
 static void local_lock_2(void)
 {
-	local_lock_acquire(&local_A);	/* IRQ-ON */
-	local_lock_release(&local_A);
+	local_lock(&local_A);	/* IRQ-ON */
+	local_unlock(&local_A);
 
 	HARDIRQ_ENTER();
 	spin_lock(&lock_A);		/* IN-IRQ */
@@ -2656,18 +2656,18 @@ static void local_lock_2(void)
 
 	HARDIRQ_DISABLE();
 	spin_lock(&lock_A);
-	local_lock_acquire(&local_A);	/* IN-IRQ <-> IRQ-ON cycle, false */
-	local_lock_release(&local_A);
+	local_lock(&local_A);	/* IN-IRQ <-> IRQ-ON cycle, false */
+	local_unlock(&local_A);
 	spin_unlock(&lock_A);
 	HARDIRQ_ENABLE();
 }
 
 static void local_lock_3A(void)
 {
-	local_lock_acquire(&local_A);	/* IRQ-ON */
+	local_lock(&local_A);	/* IRQ-ON */
 	spin_lock(&lock_B);		/* IRQ-ON */
 	spin_unlock(&lock_B);
-	local_lock_release(&local_A);
+	local_unlock(&local_A);
 
 	HARDIRQ_ENTER();
 	spin_lock(&lock_A);		/* IN-IRQ */
@@ -2676,18 +2676,18 @@ static void local_lock_3A(void)
 
 	HARDIRQ_DISABLE();
 	spin_lock(&lock_A);
-	local_lock_acquire(&local_A);	/* IN-IRQ <-> IRQ-ON cycle only if we count local_lock(), false */
-	local_lock_release(&local_A);
+	local_lock(&local_A);	/* IN-IRQ <-> IRQ-ON cycle only if we count local_lock(), false */
+	local_unlock(&local_A);
 	spin_unlock(&lock_A);
 	HARDIRQ_ENABLE();
 }
 
 static void local_lock_3B(void)
 {
-	local_lock_acquire(&local_A);	/* IRQ-ON */
+	local_lock(&local_A);	/* IRQ-ON */
 	spin_lock(&lock_B);		/* IRQ-ON */
 	spin_unlock(&lock_B);
-	local_lock_release(&local_A);
+	local_unlock(&local_A);
 
 	HARDIRQ_ENTER();
 	spin_lock(&lock_A);		/* IN-IRQ */
@@ -2696,8 +2696,8 @@ static void local_lock_3B(void)
 
 	HARDIRQ_DISABLE();
 	spin_lock(&lock_A);
-	local_lock_acquire(&local_A);	/* IN-IRQ <-> IRQ-ON cycle only if we count local_lock(), false */
-	local_lock_release(&local_A);
+	local_lock(&local_A);	/* IN-IRQ <-> IRQ-ON cycle only if we count local_lock(), false */
+	local_unlock(&local_A);
 	spin_unlock(&lock_A);
 	HARDIRQ_ENABLE();
 
@@ -2812,7 +2812,7 @@ void locking_selftest(void)
 	printk("------------------------\n");
 	printk("| Locking API testsuite:\n");
 	printk("----------------------------------------------------------------------------\n");
-	printk("                                 | spin |wlock |rlock |mutex | wsem | rsem |\n");
+	printk("                                 | spin |wlock |rlock |mutex | wsem | rsem |rtmutex\n");
 	printk("  --------------------------------------------------------------------------\n");
 
 	init_shared_classes();
-- 
2.34.0


  parent reply	other threads:[~2021-11-29 17:50 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-11-29 17:46 [PATCH 00/11] lockdep: Unbreak lockdep's selftest work on PREEMPT_RT Sebastian Andrzej Siewior
2021-11-29 17:46 ` [PATCH 01/11] sched: Trigger warning if ->migration_disabled counter underflows Sebastian Andrzej Siewior
2021-12-02 21:02   ` Peter Zijlstra
2021-12-06 15:15   ` [tip: locking/core] " tip-bot2 for Sebastian Andrzej Siewior
2021-11-29 17:46 ` [PATCH 02/11] locking: Remove rt_rwlock_is_contended() Sebastian Andrzej Siewior
2021-12-06 15:15   ` [tip: locking/core] " tip-bot2 for Sebastian Andrzej Siewior
2021-11-29 17:46 ` [PATCH 03/11] locking/rtmutex: Squash self-deadlock check for ww_rt_mutex Sebastian Andrzej Siewior
2021-12-06 15:15   ` [tip: locking/core] " tip-bot2 for Peter Zijlstra
2021-11-29 17:46 ` [PATCH 04/11] locking/rtmutex: Add rt_mutex_lock_nest_lock() and rt_mutex_lock_killable() Sebastian Andrzej Siewior
2021-12-06 15:15   ` [tip: locking/core] " tip-bot2 for Sebastian Andrzej Siewior
2021-11-29 17:46 ` [PATCH 05/11] lockdep: Remove softirq accounting on PREEMPT_RT Sebastian Andrzej Siewior
2021-12-06 15:15   ` [tip: locking/core] " tip-bot2 for Thomas Gleixner
2021-11-29 17:46 ` Sebastian Andrzej Siewior [this message]
2021-12-06 15:15   ` [tip: locking/core] lockdep/selftests: Avoid using local_lock_{acquire|release}() tip-bot2 for Sebastian Andrzej Siewior
2021-11-29 17:46 ` [PATCH 07/11] lockdep/selftests: Unbalanced migrate_disable() & rcu_read_lock() Sebastian Andrzej Siewior
2021-12-06 15:15   ` [tip: locking/core] " tip-bot2 for Sebastian Andrzej Siewior
2021-11-29 17:46 ` [PATCH 08/11] lockdep/selftests: Skip the softirq related tests on PREEMPT_RT Sebastian Andrzej Siewior
2021-12-06 15:15   ` [tip: locking/core] " tip-bot2 for Sebastian Andrzej Siewior
2021-11-29 17:46 ` [PATCH 09/11] lockdep/selftests: Adapt ww-tests for PREEMPT_RT Sebastian Andrzej Siewior
2021-12-06 15:15   ` [tip: locking/core] " tip-bot2 for Sebastian Andrzej Siewior
2021-11-29 17:46 ` [PATCH 10/11] x86/mm: Include spinlock_t definition in pgtable Sebastian Andrzej Siewior
2021-12-07 14:22   ` [tip: locking/core] " tip-bot2 for Sebastian Andrzej Siewior
2021-11-29 17:46 ` [PATCH 11/11] locking: Allow to include asm/spinlock_types.h from linux/spinlock_types_raw.h Sebastian Andrzej Siewior
2021-11-29 17:46   ` Sebastian Andrzej Siewior
2021-11-29 17:46   ` Sebastian Andrzej Siewior
2021-11-29 17:46   ` Sebastian Andrzej Siewior
2021-11-29 17:46   ` Sebastian Andrzej Siewior
2021-11-29 17:46   ` Sebastian Andrzej Siewior
2021-12-07 14:22   ` [tip: locking/core] " tip-bot2 for Sebastian Andrzej Siewior
2021-12-02 21:12 ` [PATCH 00/11] lockdep: Unbreak lockdep's selftest work on PREEMPT_RT Peter Zijlstra
2021-12-06 15:26   ` Sebastian Andrzej Siewior
2021-12-06 15:43     ` Peter Zijlstra
2021-12-07 14:19       ` Peter Zijlstra
2021-12-07 14:30         ` Sebastian Andrzej Siewior

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20211129174654.668506-7-bigeasy@linutronix.de \
    --to=bigeasy@linutronix.de \
    --cc=boqun.feng@gmail.com \
    --cc=bristot@redhat.com \
    --cc=bsegall@google.com \
    --cc=dietmar.eggemann@arm.com \
    --cc=juri.lelli@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=longman@redhat.com \
    --cc=mgorman@suse.de \
    --cc=mingo@redhat.com \
    --cc=peterz@infradead.org \
    --cc=rostedt@goodmis.org \
    --cc=tglx@linutronix.de \
    --cc=vincent.guittot@linaro.org \
    --cc=will@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.