Received: by 2002:a4a:311b:0:0:0:0:0 with SMTP id k27-v6csp4793153ooa; Tue, 14 Aug 2018 10:37:20 -0700 (PDT) X-Google-Smtp-Source: AA+uWPx+aZJGVFl+KaPqxc3CF+hhRdG3S0+xBbUjTrXHpaFYUJwGig2ezrJbjezz4XZP4A5qwrxJ X-Received: by 2002:a63:4450:: with SMTP id t16-v6mr22098298pgk.102.1534268240836; Tue, 14 Aug 2018 10:37:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1534268240; cv=none; d=google.com; s=arc-20160816; b=aYn/VOKeITHBAd9FazewGtisuUPJMTwHYPy04CfU4oqQ4fZCjUsLyar0uWbAKPgomJ SaVZcU7D9HqIDF3M7aumhsAzxqViTtD+YgNNu1d3tn/gKT3M79+fmYvpDeX3FrS/qjTb 8r770zwoMy9fYiU4lTPDRyxLfyJXf47ChfSfuG4XAlGcXQ4kCG0u8xXWFTXfhIO9+4YZ soBZ267QGn93XtxGRBEN5raICUZBulPb/653+7XPrMyRsPE3XLaSreQ/HFvIfBkuB62s OL31rI2Un2qm/T/lP5XROwoX8VigFohoMxezBLXBUVpgGcQys9xIeXu6a5EKmdxIs5+T H6bg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=+F0ctzNbSNckNWWK9GF7gQQ3inW28XmNhs08n9rkRnY=; b=pTE77mHaeZC0azWe+SX+i7IA75XtxPal56rQ0580YoC2W9J8sG15U0T8vv9f6flH87 TAIZAGkGqu2JQi5lVprbhE4p8m2JGrE7M+hws2D9KNAnHn2preOmctz52XDUHlWrKgPr hLFthnQgEcs7XH7NhLniAqjUnJMHw0lKdbzoQvSexxzvzIdbH072QzbZHQQJtiDS2Uj2 CkmR3eNfSuhfO+dRne7uXnn1R5pqwuc30LrpZMcgmg3arAGUQQ6S26qkH3YQOEAx6av4 qaHbZhHvSdK0oFJuoeLPh7rQQSbvKQUAyJCVwpcuJ1zmrrcJ9UwbijaweVu6W3zceyD4 as5w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id k80-v6si22340931pfg.42.2018.08.14.10.37.05; Tue, 14 Aug 2018 10:37:20 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729157AbeHNUXO (ORCPT + 99 others); Tue, 14 Aug 2018 16:23:14 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:57170 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725873AbeHNUXN (ORCPT ); Tue, 14 Aug 2018 16:23:13 -0400 Received: from localhost (unknown [194.244.16.108]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 464F1E1B; Tue, 14 Aug 2018 17:35:04 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Mauro Carvalho Chehab , Alan Stern , Eric Dumazet , Ingo Molnar , Linus Torvalds Subject: [PATCH 4.14 007/104] Mark HI and TASKLET softirq synchronous Date: Tue, 14 Aug 2018 19:16:21 +0200 Message-Id: <20180814171515.729923862@linuxfoundation.org> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180814171515.270692185@linuxfoundation.org> References: <20180814171515.270692185@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.14-stable review patch. If anyone has any objections, please let me know. ------------------ From: Linus Torvalds commit 3c53776e29f81719efcf8f7a6e30cdf753bee94d upstream. Way back in 4.9, we committed 4cd13c21b207 ("softirq: Let ksoftirqd do its job"), and ever since we've had small nagging issues with it. For example, we've had: 1ff688209e2e ("watchdog: core: make sure the watchdog_worker is not deferred") 8d5755b3f77b ("watchdog: softdog: fire watchdog even if softirqs do not get to run") 217f69743681 ("net: busy-poll: allow preemption in sk_busy_loop()") all of which worked around some of the effects of that commit. The DVB people have also complained that the commit causes excessive USB URB latencies, which seems to be due to the USB code using tasklets to schedule USB traffic. This seems to be an issue mainly when already living on the edge, but waiting for ksoftirqd to handle it really does seem to cause excessive latencies. Now Hanna Hawa reports that this issue isn't just limited to USB URB and DVB, but also causes timeout problems for the Marvell SoC team: "I'm facing kernel panic issue while running raid 5 on sata disks connected to Macchiatobin (Marvell community board with Armada-8040 SoC with 4 ARMv8 cores of CA72) Raid 5 built with Marvell DMA engine and async_tx mechanism (ASYNC_TX_DMA [=y]); the DMA driver (mv_xor_v2) uses a tasklet to clean the done descriptors from the queue" The latency problem causes a panic: mv_xor_v2 f0400000.xor: dma_sync_wait: timeout! Kernel panic - not syncing: async_tx_quiesce: DMA error waiting for transaction We've discussed simply just reverting the original commit entirely, and also much more involved solutions (with per-softirq threads etc). This patch is intentionally stupid and fairly limited, because the issue still remains, and the other solutions either got sidetracked or had other issues. We should probably also consider the timer softirqs to be synchronous and not be delayed to ksoftirqd (since they were the issue with the earlier watchdog problems), but that should be done as a separate patch. This does only the tasklet cases. Reported-and-tested-by: Hanna Hawa Reported-and-tested-by: Josef Griebichler Reported-by: Mauro Carvalho Chehab Cc: Alan Stern Cc: Greg Kroah-Hartman Cc: Eric Dumazet Cc: Ingo Molnar Signed-off-by: Linus Torvalds Signed-off-by: Greg Kroah-Hartman --- kernel/softirq.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) --- a/kernel/softirq.c +++ b/kernel/softirq.c @@ -79,12 +79,16 @@ static void wakeup_softirqd(void) /* * If ksoftirqd is scheduled, we do not want to process pending softirqs - * right now. Let ksoftirqd handle this at its own rate, to get fairness. + * right now. Let ksoftirqd handle this at its own rate, to get fairness, + * unless we're doing some of the synchronous softirqs. */ -static bool ksoftirqd_running(void) +#define SOFTIRQ_NOW_MASK ((1 << HI_SOFTIRQ) | (1 << TASKLET_SOFTIRQ)) +static bool ksoftirqd_running(unsigned long pending) { struct task_struct *tsk = __this_cpu_read(ksoftirqd); + if (pending & SOFTIRQ_NOW_MASK) + return false; return tsk && (tsk->state == TASK_RUNNING); } @@ -324,7 +328,7 @@ asmlinkage __visible void do_softirq(voi pending = local_softirq_pending(); - if (pending && !ksoftirqd_running()) + if (pending && !ksoftirqd_running(pending)) do_softirq_own_stack(); local_irq_restore(flags); @@ -351,7 +355,7 @@ void irq_enter(void) static inline void invoke_softirq(void) { - if (ksoftirqd_running()) + if (ksoftirqd_running(local_softirq_pending())) return; if (!force_irqthreads) {