LKML Archive on lore.kernel.org
 help / color / Atom feed
From: Frederic Weisbecker <frederic@kernel.org>
To: Ingo Molnar <mingo@kernel.org>
Cc: LKML <linux-kernel@vger.kernel.org>,
	Frederic Weisbecker <frederic@kernel.org>,
	Tejun Heo <tj@kernel.org>, Peter Zijlstra <peterz@infradead.org>,
	"David S . Miller" <davem@davemloft.net>,
	Lai Jiangshan <jiangshanlai@gmail.com>,
	Thomas Gleixner <tglx@linutronix.de>,
	"Paul E . McKenney" <paulmck@linux.vnet.ibm.com>
Subject: [PATCH 01/14] lockdep: Add IRQs disabled/enabled assertion
Date: Mon,  6 Nov 2017 16:01:17 +0100
Message-ID: <1509980490-4285-2-git-send-email-frederic@kernel.org> (raw)
In-Reply-To: <1509980490-4285-1-git-send-email-frederic@kernel.org>

Checking whether IRQs are enabled or disabled is a very common sanity
check, however not free of overhead especially on fastpath where such
assertion is very common.

Lockdep is a good host for such concurrency correctness check and it
even already tracks down IRQs disablement state. Just reuse its
machinery. This will allow us to get rid of the flags pop and check
overhead from fast path when kernel is built for production.

Suggested-by: Peter Zijlstra <peterz@infradead.org>
Signed-off-by: Frederic Weisbecker <frederic@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
---
 include/linux/lockdep.h | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/include/linux/lockdep.h b/include/linux/lockdep.h
index b6662d0..68dc4bc 100644
--- a/include/linux/lockdep.h
+++ b/include/linux/lockdep.h
@@ -724,9 +724,24 @@ do {									\
 	lock_acquire(&(lock)->dep_map, 0, 0, 1, 1, NULL, _THIS_IP_);	\
 	lock_release(&(lock)->dep_map, 0, _THIS_IP_);			\
 } while (0)
+
+#define lockdep_assert_irqs_enabled()	do {				\
+		WARN_ONCE(debug_locks && !current->lockdep_recursion &&	\
+			  !current->hardirqs_enabled,			\
+			  "IRQs not enabled as expected\n");		\
+	} while (0)
+
+#define lockdep_assert_irqs_disabled()	do {				\
+		WARN_ONCE(debug_locks && !current->lockdep_recursion &&	\
+			  current->hardirqs_enabled,			\
+			  "IRQs not disabled as expected\n");		\
+	} while (0)
+
 #else
 # define might_lock(lock) do { } while (0)
 # define might_lock_read(lock) do { } while (0)
+# define lockdep_assert_irqs_enabled() do { } while (0)
+# define lockdep_assert_irqs_disabled() do { } while (0)
 #endif
 
 #ifdef CONFIG_LOCKDEP
-- 
2.7.4

  reply index

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-11-06 15:01 [GIT PULL] lockdep: Add lightweight IRQs disabled/enabled check v2 Frederic Weisbecker
2017-11-06 15:01 ` Frederic Weisbecker [this message]
2017-11-08 10:51   ` [tip:locking/core] locking/lockdep: Add IRQs disabled/enabled assertion APIs: lockdep_assert_irqs_enabled()/disabled() tip-bot for Frederic Weisbecker
2017-11-06 15:01 ` [PATCH 02/14] irq: Use lockdep to assert IRQs are disabled/enabled Frederic Weisbecker
2017-11-08 10:52   ` [tip:locking/core] irq/softirqs: " tip-bot for Frederic Weisbecker
2017-11-06 15:01 ` [PATCH 03/14] workqueue: " Frederic Weisbecker
2017-11-08 10:52   ` [tip:locking/core] " tip-bot for Frederic Weisbecker
2017-11-06 15:01 ` [PATCH 04/14] nohz: " Frederic Weisbecker
2017-11-08 10:53   ` [tip:locking/core] timers/nohz: " tip-bot for Frederic Weisbecker
2017-11-06 15:01 ` [PATCH 05/14] hrtimer: " Frederic Weisbecker
2017-11-08 10:53   ` [tip:locking/core] timers/hrtimer: " tip-bot for Frederic Weisbecker
2017-11-06 15:01 ` [PATCH 06/14] smp: " Frederic Weisbecker
2017-11-08 10:54   ` [tip:locking/core] smp/core: " tip-bot for Frederic Weisbecker
2017-11-06 15:01 ` [PATCH 07/14] x86: " Frederic Weisbecker
2017-11-08 10:54   ` [tip:locking/core] " tip-bot for Frederic Weisbecker
2017-11-06 15:01 ` [PATCH 08/14] perf: " Frederic Weisbecker
2017-11-08 10:54   ` [tip:locking/core] perf/core: " tip-bot for Frederic Weisbecker
2017-11-06 15:01 ` [PATCH 09/14] irq/timings: " Frederic Weisbecker
2017-11-08 10:55   ` [tip:locking/core] " tip-bot for Frederic Weisbecker
2017-11-06 15:01 ` [PATCH 10/14] irq_work: " Frederic Weisbecker
2017-11-08 10:55   ` [tip:locking/core] " tip-bot for Frederic Weisbecker
2017-11-06 15:01 ` [PATCH 11/14] sched: " Frederic Weisbecker
2017-11-08 10:56   ` [tip:locking/core] sched/clock, sched/cputime: " tip-bot for Frederic Weisbecker
2017-11-06 15:01 ` [PATCH 12/14] posix-cpu-timers: " Frederic Weisbecker
2017-11-08 10:56   ` [tip:locking/core] timers/posix-cpu-timers: " tip-bot for Frederic Weisbecker
2017-11-06 15:01 ` [PATCH 13/14] netpoll: " Frederic Weisbecker
2017-11-08 10:57   ` [tip:locking/core] " tip-bot for Frederic Weisbecker
2017-11-06 15:01 ` [PATCH 14/14] rcu: " Frederic Weisbecker
2017-11-08 10:57   ` [tip:locking/core] " tip-bot for Frederic Weisbecker
2017-11-08  9:58 ` [GIT PULL] lockdep: Add lightweight IRQs disabled/enabled check v2 Thomas Gleixner
  -- strict thread matches above, loose matches on Subject: below --
2017-10-20  0:55 [PATCH 00/14] lockdep: Add lightweight IRQs disabled/enabled check Frederic Weisbecker
2017-10-20  0:55 ` [PATCH 01/14] lockdep: Add IRQs disabled/enabled assertion Frederic Weisbecker

Reply instructions:

You may reply publically 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=1509980490-4285-2-git-send-email-frederic@kernel.org \
    --to=frederic@kernel.org \
    --cc=davem@davemloft.net \
    --cc=jiangshanlai@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=paulmck@linux.vnet.ibm.com \
    --cc=peterz@infradead.org \
    --cc=tglx@linutronix.de \
    --cc=tj@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

LKML Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/lkml/0 lkml/git/0.git
	git clone --mirror https://lore.kernel.org/lkml/1 lkml/git/1.git
	git clone --mirror https://lore.kernel.org/lkml/2 lkml/git/2.git
	git clone --mirror https://lore.kernel.org/lkml/3 lkml/git/3.git
	git clone --mirror https://lore.kernel.org/lkml/4 lkml/git/4.git
	git clone --mirror https://lore.kernel.org/lkml/5 lkml/git/5.git
	git clone --mirror https://lore.kernel.org/lkml/6 lkml/git/6.git
	git clone --mirror https://lore.kernel.org/lkml/7 lkml/git/7.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 lkml lkml/ https://lore.kernel.org/lkml \
		linux-kernel@vger.kernel.org linux-kernel@archiver.kernel.org
	public-inbox-index lkml


Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-kernel


AGPL code for this site: git clone https://public-inbox.org/ public-inbox