From: Peter Zijlstra <peterz@infradead.org>
To: Thomas Gleixner <tglx@linutronix.de>
Cc: LKML <linux-kernel@vger.kernel.org>,
Frederic Weisbecker <frederic@kernel.org>,
Paul McKenney <paulmck@kernel.org>,
Sebastian Andrzej Siewior <bigeasy@linutronix.de>,
Boqun Feng <boqun.feng@gmail.com>, Ingo Molnar <mingo@kernel.org>,
Will Deacon <will@kernel.org>
Subject: Re: [patch V2 4/9] softirq: Make softirq control and processing RT aware
Date: Wed, 9 Dec 2020 11:11:02 +0100 [thread overview]
Message-ID: <20201209101102.GJ2414@hirez.programming.kicks-ass.net> (raw)
In-Reply-To: <20201204170805.114951971@linutronix.de>
On Fri, Dec 04, 2020 at 06:01:55PM +0100, Thomas Gleixner wrote:
> From: Thomas Gleixner <tglx@linutronix.de>
>
> Provide a local lock based serialization for soft interrupts on RT which
> allows the local_bh_disabled() sections and servicing soft interrupts to be
> preemptible.
>
> Provide the necessary inline helpers which allow to reuse the bulk of the
> softirq processing code.
> +struct softirq_ctrl {
> + local_lock_t lock;
> + int cnt;
> +};
> +
> +static DEFINE_PER_CPU(struct softirq_ctrl, softirq_ctrl) = {
> + .lock = INIT_LOCAL_LOCK(softirq_ctrl.lock),
> +};
> +
> +void __local_bh_disable_ip(unsigned long ip, unsigned int cnt)
> +{
> + unsigned long flags;
> + int newcnt;
> +
> + WARN_ON_ONCE(in_hardirq());
> +
> + /* First entry of a task into a BH disabled section? */
> + if (!current->softirq_disable_cnt) {
> + if (preemptible()) {
> + local_lock(&softirq_ctrl.lock);
AFAICT this significantly changes the locking rules.
Where previously we could do:
spin_lock(&ponies)
spin_lock_bh(&foo);
vs
spin_lock_bh(&bar);
spin_lock(&ponies)
provided the rest of the code observed: bar -> ponies -> foo
and never takes ponies from in-softirq.
This is now a genuine deadlock on RT.
Also see:
https://lkml.kernel.org/r/X9CheYjuXWc75Spa@hirez.programming.kicks-ass.net
> + /* Required to meet the RCU bottomhalf requirements. */
> + rcu_read_lock();
> + } else {
> + DEBUG_LOCKS_WARN_ON(this_cpu_read(softirq_ctrl.cnt));
> + }
> + }
> +
> + /*
> + * Track the per CPU softirq disabled state. On RT this is per CPU
> + * state to allow preemption of bottom half disabled sections.
> + */
> + newcnt = __this_cpu_add_return(softirq_ctrl.cnt, cnt);
> + /*
> + * Reflect the result in the task state to prevent recursion on the
> + * local lock and to make softirq_count() & al work.
> + */
> + current->softirq_disable_cnt = newcnt;
> +
> + if (IS_ENABLED(CONFIG_TRACE_IRQFLAGS) && newcnt == cnt) {
> + raw_local_irq_save(flags);
> + lockdep_softirqs_off(ip);
> + raw_local_irq_restore(flags);
> + }
> +}
next prev parent reply other threads:[~2020-12-09 10:12 UTC|newest]
Thread overview: 38+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-12-04 17:01 [patch V2 0/9] softirq: Make it RT aware Thomas Gleixner
2020-12-04 17:01 ` [patch V2 1/9] softirq: Add RT specific softirq accounting Thomas Gleixner
2020-12-07 13:06 ` Frederic Weisbecker
2020-12-04 17:01 ` [patch V2 2/9] irqtime: Make accounting correct on RT Thomas Gleixner
2020-12-07 0:23 ` Frederic Weisbecker
2020-12-07 0:57 ` Thomas Gleixner
2020-12-07 1:14 ` Frederic Weisbecker
2020-12-07 13:27 ` Frederic Weisbecker
2020-12-07 14:44 ` Thomas Gleixner
2020-12-04 17:01 ` [patch V2 3/9] softirq: Move various protections into inline helpers Thomas Gleixner
2020-12-07 13:37 ` Frederic Weisbecker
2020-12-04 17:01 ` [patch V2 4/9] softirq: Make softirq control and processing RT aware Thomas Gleixner
2020-12-07 14:16 ` Frederic Weisbecker
2020-12-07 15:08 ` Thomas Gleixner
2020-12-08 0:08 ` Frederic Weisbecker
2020-12-09 10:11 ` Peter Zijlstra [this message]
2020-12-09 12:36 ` Thomas Gleixner
2020-12-09 12:42 ` Peter Zijlstra
2020-12-09 13:30 ` Thomas Gleixner
2020-12-09 10:34 ` Peter Zijlstra
2020-12-04 17:01 ` [patch V2 5/9] tick/sched: Prevent false positive softirq pending warnings on RT Thomas Gleixner
2020-12-08 12:23 ` Frederic Weisbecker
2020-12-04 17:01 ` [patch V2 6/9] rcu: Prevent false positive softirq warning " Thomas Gleixner
2020-12-04 17:59 ` Paul E. McKenney
2020-12-04 17:01 ` [patch V2 7/9] softirq: Replace barrier() with cpu_relax() in tasklet_unlock_wait() Thomas Gleixner
2020-12-07 11:39 ` Peter Zijlstra
2020-12-07 15:21 ` Thomas Gleixner
2020-12-04 17:01 ` [patch V2 8/9] tasklets: Use static inlines for stub implementations Thomas Gleixner
2020-12-04 17:02 ` [patch V2 9/9] tasklets: Prevent kill/unlock_wait deadlock on RT Thomas Gleixner
2020-12-07 11:47 ` Peter Zijlstra
2020-12-07 14:00 ` Sebastian Andrzej Siewior
2020-12-07 14:27 ` Peter Zijlstra
2020-12-07 17:55 ` Thomas Gleixner
2020-12-07 15:22 ` Thomas Gleixner
2020-12-07 15:39 ` Sebastian Andrzej Siewior
2020-12-07 17:49 ` Thomas Gleixner
2020-12-07 17:50 ` Thomas Gleixner
2020-12-06 10:05 ` [patch V2 0/9] softirq: Make it RT aware 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=20201209101102.GJ2414@hirez.programming.kicks-ass.net \
--to=peterz@infradead.org \
--cc=bigeasy@linutronix.de \
--cc=boqun.feng@gmail.com \
--cc=frederic@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=paulmck@kernel.org \
--cc=tglx@linutronix.de \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).