From: Frederic Weisbecker <frederic@kernel.org>
To: LKML <linux-kernel@vger.kernel.org>
Cc: Frederic Weisbecker <fweisbec@gmail.com>,
Sebastian Andrzej Siewior <bigeasy@linutronix.de>,
Peter Zijlstra <peterz@infradead.org>,
"David S . Miller" <davem@davemloft.net>,
Linus Torvalds <torvalds@linux-foundation.org>,
Thomas Gleixner <tglx@linutronix.de>,
Frederic Weisbecker <frederic@kernel.org>,
"Paul E . McKenney" <paulmck@linux.vnet.ibm.com>,
Ingo Molnar <mingo@kernel.org>,
Mauro Carvalho Chehab <mchehab@s-opensource.com>
Subject: [RFC PATCH 30/30] softirq: Tasklet/net-rx fixup
Date: Thu, 11 Oct 2018 01:12:17 +0200 [thread overview]
Message-ID: <1539213137-13953-31-git-send-email-frederic@kernel.org> (raw)
In-Reply-To: <1539213137-13953-1-git-send-email-frederic@kernel.org>
From: Frederic Weisbecker <fweisbec@gmail.com>
Tasklets and net-rx vectors don't quite get along. If one is interrupted
by another, we may run into a nasty spin_lock recursion:
[ 135.427198] Call Trace:
[ 135.429650] <IRQ>
[ 135.431690] dump_stack+0x67/0x95
[ 135.435024] spin_bug+0x95/0xf0
[ 135.438187] do_raw_spin_lock+0x77/0xa0
[ 135.442079] _raw_spin_lock_nested+0x40/0x50
[ 135.446439] ? tcp_v4_rcv+0x9da/0xb10
[ 135.450131] tcp_v4_rcv+0x9da/0xb10
[ 135.453650] ? ip_local_deliver+0x78/0x260
[ 135.457758] ip_local_deliver+0xdf/0x260
[ 135.461728] ip_rcv+0x4e/0x80
[ 135.464716] __netif_receive_skb_one_core+0x55/0x80
[ 135.469623] __netif_receive_skb+0x1b/0x70
[ 135.473757] netif_receive_skb_internal+0x92/0x390
[ 135.478574] napi_gro_receive+0xdf/0x1a0
[ 135.482545] rtl8169_poll+0x2b8/0x670
[ 135.486211] net_rx_action+0x1f8/0x3e0
[ 135.489989] __do_softirq+0x1a0/0x63c
[ 135.493691] irq_exit+0x10f/0x120
[ 135.497033] do_IRQ+0x71/0x130
[ 135.500137] common_interrupt+0xf/0xf
[ 135.503839] RIP: 0010:_raw_spin_unlock_irqrestore+0x59/0x70
[ 135.509471] Code: 75 21 53 9d e8 e8 1d a5 ff bf 01 00 00 00 e8 8e f6 97 ff 65 8b 05 ef 06 8d 7e 85 c0 74 0e 5b 41 5c 5d c3 e8 c9 20 a5 ff 53 9d <eb> dd e8 90 d4 8b ff 5b 41 5c 5d c3 66 66 2e 0f 1f 84 00 00 00 00
[ 135.528347] RSP: 0018:ffff88021fb03d28 EFLAGS: 00000246 ORIG_RAX: ffffffffffffffde
[ 135.535989] RAX: ffff880217762480 RBX: 0000000000000246 RCX: 0000000000000002
[ 135.543201] RDX: 0000000000000000 RSI: ffff880217762c70 RDI: ffff880217762480
[ 135.550332] RBP: ffff88021fb03d38 R08: 0000000000000001 R09: 0000000000000000
[ 135.557519] R10: 0000000000000000 R11: 0000000000000000 R12: ffff88021fa59b40
[ 135.564719] R13: ffff88021fa59b40 R14: 00000000fffd78b5 R15: 000000000e000001
[ 135.571905] ? common_interrupt+0xa/0xf
[ 135.575783] mod_timer+0x196/0x440
[ 135.579221] sk_reset_timer+0x18/0x30
[ 135.582940] tcp_schedule_loss_probe+0xe9/0x120
[ 135.587515] tcp_write_xmit+0x2c4/0x1240
[ 135.591468] tcp_tsq_write.part.46+0x5e/0xb0
[ 135.595756] tcp_tsq_handler+0xa3/0xb0
[ 135.599534] tcp_tasklet_func+0xdc/0x120
[ 135.603488] tasklet_action_common.isra.17+0xa3/0xb0
[ 135.608471] tasklet_action+0x2d/0x30
[ 135.612161] __do_softirq+0x1a0/0x63c
[ 135.615847] irq_exit+0x10f/0x120
[ 135.619173] do_IRQ+0x71/0x130
[ 135.622251] common_interrupt+0xf/0xf
[ 135.625949] </IRQ>
This is an ugly workaround until we find a proper solution.
Signed-off-by: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: David S. Miller <davem@davemloft.net>
Cc: Mauro Carvalho Chehab <mchehab@s-opensource.com>
Cc: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
---
kernel/softirq.c | 13 +++++++++++++
1 file changed, 13 insertions(+)
diff --git a/kernel/softirq.c b/kernel/softirq.c
index f4cb1ea..d95295f 100644
--- a/kernel/softirq.c
+++ b/kernel/softirq.c
@@ -320,6 +320,7 @@ asmlinkage __visible void __softirq_entry __do_softirq(void)
unsigned long old_flags = current->flags;
int max_restart = MAX_SOFTIRQ_RESTART;
struct softirq_action *h;
+ bool tasklet_enabled = false, net_rx_enabled = false;
bool in_hardirq;
__u32 pending;
int softirq_bit;
@@ -338,6 +339,10 @@ asmlinkage __visible void __softirq_entry __do_softirq(void)
in_hardirq = lockdep_softirq_start();
restart:
+ if (local_softirq_enabled() & TASKLET_SOFTIRQ)
+ tasklet_enabled = true;
+ if (local_softirq_enabled() & NET_RX_SOFTIRQ)
+ net_rx_enabled = true;
/* Reset the pending bitmask before enabling irqs */
softirq_pending_nand(pending);
@@ -358,8 +363,16 @@ asmlinkage __visible void __softirq_entry __do_softirq(void)
trace_softirq_entry(vec_nr);
softirq_enabled_nand(BIT(vec_nr));
+ if (vec_nr == NET_RX_SOFTIRQ && tasklet_enabled)
+ softirq_enabled_nand(BIT(TASKLET_SOFTIRQ));
+ if (vec_nr == TASKLET_SOFTIRQ && net_rx_enabled)
+ softirq_enabled_nand(BIT(NET_RX_SOFTIRQ));
barrier();
h->action(h);
+ if (vec_nr == TASKLET_SOFTIRQ && net_rx_enabled)
+ softirq_enabled_or(BIT(NET_RX_SOFTIRQ));
+ if (vec_nr == NET_RX_SOFTIRQ && tasklet_enabled)
+ softirq_enabled_or(BIT(TASKLET_SOFTIRQ));
softirq_enabled_or(BIT(vec_nr));
trace_softirq_exit(vec_nr);
if (unlikely(prev_count != preempt_count())) {
--
2.7.4
next prev parent reply other threads:[~2018-10-10 23:14 UTC|newest]
Thread overview: 40+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-10-10 23:11 [RFC PATCH 00/30] softirq: Make softirqs soft-interruptible (+ per vector disablement) Frederic Weisbecker
2018-10-10 23:11 ` [RFC PATCH 01/30] x86: Revert "x86/irq: Demote irq_cpustat_t::__softirq_pending to u16" Frederic Weisbecker
2018-10-10 23:11 ` [RFC PATCH 02/30] arch/softirq: Rename softirq_pending fields to softirq_data Frederic Weisbecker
2018-10-10 23:11 ` [RFC PATCH 03/30] softirq: Implement local_softirq_pending() below softirq vector definition Frederic Weisbecker
2018-10-10 23:11 ` [RFC PATCH 04/30] softirq: Normalize softirq_pending naming scheme Frederic Weisbecker
2018-10-10 23:11 ` [RFC PATCH 05/30] softirq: Convert softirq_pending_set() to softirq_pending_nand() Frederic Weisbecker
2018-10-10 23:11 ` [RFC PATCH 06/30] softirq: Introduce disabled softirq vectors bits Frederic Weisbecker
2018-10-10 23:11 ` [RFC PATCH 07/30] softirq: Rename _local_bh_enable() to local_bh_enable_no_softirq() Frederic Weisbecker
2018-10-10 23:11 ` [RFC PATCH 08/30] softirq: Move vectors bits to bottom_half.h Frederic Weisbecker
2018-10-10 23:11 ` [RFC PATCH 09/30] x86: Init softirq enabled field Frederic Weisbecker
2018-10-10 23:11 ` [RFC PATCH 10/30] softirq: Check enabled bits on the softirq loop Frederic Weisbecker
2018-10-10 23:11 ` [RFC PATCH 11/30] net: Prepare netif_tx_lock_bh/netif_tx_unlock_bh() for handling softirq mask Frederic Weisbecker
2018-10-10 23:11 ` [RFC PATCH 12/30] rcu: Prepare rcu_read_[un]lock_bh() " Frederic Weisbecker
2018-10-16 5:28 ` Joel Fernandes
2018-10-17 0:44 ` Frederic Weisbecker
2018-10-17 0:55 ` Joel Fernandes
2018-10-10 23:12 ` [RFC PATCH 13/30] net: Prepare tcp_get_md5sig_pool() " Frederic Weisbecker
2018-10-10 23:12 ` [RFC PATCH 14/30] softirq: Introduce local_bh_disable_all() Frederic Weisbecker
2018-10-10 23:12 ` [RFC PATCH 15/30] net: Prepare [un]lock_sock_fast() for handling softirq mask Frederic Weisbecker
2018-10-10 23:12 ` [RFC PATCH 16/30] net: Prepare nf_log_buf_open() " Frederic Weisbecker
2018-10-10 23:12 ` [RFC PATCH 17/30] isdn: Prepare isdn_net_get_locked_lp() " Frederic Weisbecker
2018-10-10 23:12 ` [RFC PATCH 18/30] softirq: Prepare local_bh_disable() " Frederic Weisbecker
2018-10-10 23:12 ` [RFC PATCH 19/30] diva: Prepare diva_os_enter_spin_lock() " Frederic Weisbecker
2018-10-10 23:12 ` [RFC PATCH 20/30] tg3: Prepare tg3_full_[un]lock() " Frederic Weisbecker
2018-10-10 23:12 ` [RFC PATCH 21/30] locking: Prepare spin_lock_bh() " Frederic Weisbecker
2018-10-10 23:12 ` [RFC PATCH 22/30] seqlock: Prepare write_seq[un]lock_bh() " Frederic Weisbecker
2018-10-10 23:12 ` [RFC PATCH 23/30] rwlock: Prepare write_[un]lock_bh() " Frederic Weisbecker
2018-10-10 23:12 ` [RFC PATCH 24/30] softirq: Introduce Local_bh_enter/exit() Frederic Weisbecker
2018-10-10 23:12 ` [RFC PATCH 25/30] softirq: Push down softirq mask to __local_bh_disable_ip() Frederic Weisbecker
2018-10-10 23:12 ` [RFC PATCH 26/30] softirq: Increment the softirq offset on top of enabled bits Frederic Weisbecker
2018-10-10 23:12 ` [RFC PATCH 27/30] softirq: Swap softirq serving VS disable on preempt mask layout Frederic Weisbecker
2018-10-10 23:12 ` [RFC PATCH 28/30] softirq: Disable vector on execution Frederic Weisbecker
2018-10-10 23:12 ` [RFC PATCH 29/30] softirq: Make softirq processing softinterruptible Frederic Weisbecker
2018-10-16 4:15 ` Pavan Kondeti
2018-10-17 0:26 ` Frederic Weisbecker
2018-10-22 8:12 ` Pavan Kondeti
2018-10-10 23:12 ` Frederic Weisbecker [this message]
2018-10-16 22:03 ` [RFC PATCH 00/30] softirq: Make softirqs soft-interruptible (+ per vector disablement) Jonathan Corbet
2018-10-16 23:37 ` Richard Cochran
2018-10-17 1:20 ` Frederic Weisbecker
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=1539213137-13953-31-git-send-email-frederic@kernel.org \
--to=frederic@kernel.org \
--cc=bigeasy@linutronix.de \
--cc=davem@davemloft.net \
--cc=fweisbec@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mchehab@s-opensource.com \
--cc=mingo@kernel.org \
--cc=paulmck@linux.vnet.ibm.com \
--cc=peterz@infradead.org \
--cc=tglx@linutronix.de \
--cc=torvalds@linux-foundation.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