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 02/14] irq: Use lockdep to assert IRQs are disabled/enabled
Date: Mon,  6 Nov 2017 16:01:18 +0100
Message-ID: <1509980490-4285-3-git-send-email-frederic@kernel.org> (raw)
In-Reply-To: <1509980490-4285-1-git-send-email-frederic@kernel.org>

Use lockdep to check that IRQs are enabled or disabled as expected. This
way the sanity check only shows overhead when concurrency correctness
debug code is enabled.

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>
---
 kernel/softirq.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/kernel/softirq.c b/kernel/softirq.c
index 4e09821..662f7b1b 100644
--- a/kernel/softirq.c
+++ b/kernel/softirq.c
@@ -137,7 +137,7 @@ EXPORT_SYMBOL(__local_bh_disable_ip);
 
 static void __local_bh_enable(unsigned int cnt)
 {
-	WARN_ON_ONCE(!irqs_disabled());
+	lockdep_assert_irqs_disabled();
 
 	if (softirq_count() == (cnt & SOFTIRQ_MASK))
 		trace_softirqs_on(_RET_IP_);
@@ -158,7 +158,8 @@ EXPORT_SYMBOL(_local_bh_enable);
 
 void __local_bh_enable_ip(unsigned long ip, unsigned int cnt)
 {
-	WARN_ON_ONCE(in_irq() || irqs_disabled());
+	WARN_ON_ONCE(in_irq());
+	lockdep_assert_irqs_enabled();
 #ifdef CONFIG_TRACE_IRQFLAGS
 	local_irq_disable();
 #endif
@@ -396,9 +397,8 @@ void irq_exit(void)
 #ifndef __ARCH_IRQ_EXIT_IRQS_DISABLED
 	local_irq_disable();
 #else
-	WARN_ON_ONCE(!irqs_disabled());
+	lockdep_assert_irqs_disabled();
 #endif
-
 	account_irq_exit_time(current);
 	preempt_count_sub(HARDIRQ_OFFSET);
 	if (!in_interrupt() && local_softirq_pending())
@@ -488,7 +488,7 @@ EXPORT_SYMBOL(__tasklet_hi_schedule);
 
 void __tasklet_hi_schedule_first(struct tasklet_struct *t)
 {
-	BUG_ON(!irqs_disabled());
+	lockdep_assert_irqs_disabled();
 
 	t->next = __this_cpu_read(tasklet_hi_vec.head);
 	__this_cpu_write(tasklet_hi_vec.head, t);
-- 
2.7.4

  parent 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 ` [PATCH 01/14] lockdep: Add IRQs disabled/enabled assertion Frederic Weisbecker
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 ` Frederic Weisbecker [this message]
2017-11-08 10:52   ` [tip:locking/core] irq/softirqs: Use lockdep to assert IRQs are disabled/enabled 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 02/14] irq: Use lockdep to assert IRQs are disabled/enabled 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-3-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

Example config snippet for mirrors

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