Received: by 2002:ac0:946b:0:0:0:0:0 with SMTP id j40csp2719163imj; Mon, 18 Feb 2019 10:52:58 -0800 (PST) X-Google-Smtp-Source: AHgI3IYOc7Kqlbg2SQvPG8CQXIwSLukbzVXfcxGyb1ZNPWiGrqiIMHh2Sl7+9BLf+sx3eixsQvqW X-Received: by 2002:a17:902:aa06:: with SMTP id be6mr6211202plb.57.1550515978851; Mon, 18 Feb 2019 10:52:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550515978; cv=none; d=google.com; s=arc-20160816; b=d7QLwAj0JRQkhIVhI9YLLr96zgNUzNcSiLUQQvoK9HCM8XuPXyvyX8Y3yjML6iYf+d ZiBQ3TYiCia9mPF6UxBU/8mQpfMD3E6E9mnQjuaDctMuq6boh86nWgWvIFMrKuvKRtLV Lm8f9mQWw3Fi4O7JXX1pQDC45Cl/nNLKR4daPAoGgymnCvKWVjdX4zhjaqjnTHkQHyFA dVI7TkHk3chuCfUkqJiwHnUxfRBovUg3mnQ7ktXU4LABGOB8ffg3rCvUdh3rCEUyRXaS n+8m121VSEPDY7Kdu4PRyMapIaoaw5slRRbUC25puzZ4yAB1X/dZ8cj0r1p/WRSrl4rQ x1xQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:content-disposition :mime-version:message-id:subject:cc:to:from:date; bh=dWHCO0arcst2EvpltIUrjZTU6HQqKxDxhW0LBmtZy3o=; b=hl4AkTA7drEg8QGpTCFGtP4xWi4QJp+BHqNfgUY2XX1LWJ6QZSZGDEeK2BXe1pNGLq jNm/2DVo3fJ4sP10ZebsrIpKolropAa6s4MH1FJVQtZ5wTnnEaFtF2KSFspzPmbiYjbL OVQo3yIhHu6m6jqqnCNTmbVewxj4FHH+VrjRQQnjLmJEzR1pa/hbY1uDMsl40h8p5pPN z4dEMJ1NBcOwJtZz7E34+piV3mMkIu2TGP64O/TSBPd6gf4ZfXMpIhl2mAIHQJiiJits ZRCoTkjI9cUqCSszE+ZHtJQAW64JzTZ/1fva+ln8d7+YRacG5nVdFf4sNZzN+6cxtz2n 9nOA== 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 cm2si1946340plb.327.2019.02.18.10.52.43; Mon, 18 Feb 2019 10:52:58 -0800 (PST) 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 S2389258AbfBRQbM (ORCPT + 99 others); Mon, 18 Feb 2019 11:31:12 -0500 Received: from Galois.linutronix.de ([146.0.238.70]:57142 "EHLO Galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732378AbfBRQbL (ORCPT ); Mon, 18 Feb 2019 11:31:11 -0500 Received: from bigeasy by Galois.linutronix.de with local (Exim 4.80) (envelope-from ) id 1gvloy-000396-PA; Mon, 18 Feb 2019 17:31:08 +0100 Date: Mon, 18 Feb 2019 17:31:08 +0100 From: Sebastian Andrzej Siewior To: linux-rt-users@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Thomas Gleixner , Steven Rostedt Subject: [PATCH RT 1/2] softirq: Avoid "local_softirq_pending" messages if ksoftirqd is blocked Message-ID: <20190218163107.iwdpngwmbs6xyk7x@linutronix.de> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline User-Agent: NeoMutt/20180716 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org If the ksoftirqd thread has a softirq pending and is blocked on the `local_softirq_locks' lock then softirq_check_pending_idle() won't complain because the "lock owner" will mask away this softirq from the mask of pending softirqs. If ksoftirqd has an additional softirq pending then it won't be masked out because we never look at ksoftirqd's mask. If there are still pending softirqs while going to idle check ksoftirqd's and ktimersfotd's mask before complaining about unhandled softirqs. Cc: stable-rt@vger.kernel.org Signed-off-by: Sebastian Andrzej Siewior --- kernel/softirq.c | 58 +++++++++++++++++++++++++++++++++++------------- 1 file changed, 42 insertions(+), 16 deletions(-) diff --git a/kernel/softirq.c b/kernel/softirq.c index c15583162a559..8da664eb843a4 100644 --- a/kernel/softirq.c +++ b/kernel/softirq.c @@ -92,6 +92,31 @@ static inline void softirq_clr_runner(unsigned int sirq) sr->runner[sirq] = NULL; } +static bool softirq_check_runner_tsk(struct task_struct *tsk, + unsigned int *pending) +{ + bool ret = false; + + if (!tsk) + return ret; + + /* + * The wakeup code in rtmutex.c wakes up the task + * _before_ it sets pi_blocked_on to NULL under + * tsk->pi_lock. So we need to check for both: state + * and pi_blocked_on. + */ + raw_spin_lock(&tsk->pi_lock); + if (tsk->pi_blocked_on || tsk->state == TASK_RUNNING) { + /* Clear all bits pending in that task */ + *pending &= ~(tsk->softirqs_raised); + ret = true; + } + raw_spin_unlock(&tsk->pi_lock); + + return ret; +} + /* * On preempt-rt a softirq running context might be blocked on a * lock. There might be no other runnable task on this CPU because the @@ -104,6 +129,7 @@ static inline void softirq_clr_runner(unsigned int sirq) */ void softirq_check_pending_idle(void) { + struct task_struct *tsk; static int rate_limit; struct softirq_runner *sr = this_cpu_ptr(&softirq_runners); u32 warnpending; @@ -113,26 +139,26 @@ void softirq_check_pending_idle(void) return; warnpending = local_softirq_pending() & SOFTIRQ_STOP_IDLE_MASK; + if (!warnpending) + return; for (i = 0; i < NR_SOFTIRQS; i++) { - struct task_struct *tsk = sr->runner[i]; + tsk = sr->runner[i]; - /* - * The wakeup code in rtmutex.c wakes up the task - * _before_ it sets pi_blocked_on to NULL under - * tsk->pi_lock. So we need to check for both: state - * and pi_blocked_on. - */ - if (tsk) { - raw_spin_lock(&tsk->pi_lock); - if (tsk->pi_blocked_on || tsk->state == TASK_RUNNING) { - /* Clear all bits pending in that task */ - warnpending &= ~(tsk->softirqs_raised); - warnpending &= ~(1 << i); - } - raw_spin_unlock(&tsk->pi_lock); - } + if (softirq_check_runner_tsk(tsk, &warnpending)) + warnpending &= ~(1 << i); } + if (warnpending) { + tsk = __this_cpu_read(ksoftirqd); + softirq_check_runner_tsk(tsk, &warnpending); + } + + if (warnpending) { + tsk = __this_cpu_read(ktimer_softirqd); + softirq_check_runner_tsk(tsk, &warnpending); + } + + if (warnpending) { printk(KERN_ERR "NOHZ: local_softirq_pending %02x\n", warnpending); -- 2.20.1