Received: by 2002:a05:6a10:6744:0:0:0:0 with SMTP id w4csp5602079pxu; Thu, 22 Oct 2020 06:41:33 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwB1WEssrt8dnAYmMbYqeePSi67wcdJ0ejkKEohANvkz0cwH4y12wIJFtirxsIEQNFhrwz8 X-Received: by 2002:a17:906:3bc7:: with SMTP id v7mr2215480ejf.245.1603374093603; Thu, 22 Oct 2020 06:41:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1603374093; cv=none; d=google.com; s=arc-20160816; b=p6CPQx3zqO6eCkOpTdYSiJt5xFafkXm2sY8Nlp1RPKMOxBWMt/Q0ldZnyoSOSL917i glLbm+kWOBuIKX5qTcT9GVt5NMCXlZWFOQjVkxPXt902vPkvhLE5TBmUoqN9M4OyODO9 v6erZKFBxKjbWfSqZ+ggAGnkaUBKA+SdXVaEX1+H1ZN1TrijvYfTeLTPVQLpnHTT/1p1 YKr6SQquhImvrl1nfoPQf9S4QyuOhqoRzeQilswKv3JTbXErR8pnkrP4e5exRGQoJBzU QK8HGRqSVgXHciicptDXhjyq+rshQY8qnKmztQXKeCIf9O1uvXb6IZOS0UvR+B0yrZN8 Wp6A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:in-reply-to:message-id:date:subject :cc:to:from:dkim-signature; bh=ONnPqbEGpsHiC+7+xAJ566Uy7tk/a7WVPjlnbMKceyI=; b=N/h7PcG6UlNCwgOQf0x7WrSQDpOhOhg01Wjs4Uq//XcRb1NYfvW6RPD31uJhfaF6Sl toir+oG0mnbgUZA6CiRfoPSTbeApFcy7ZOWhXLIgPRKhJpmoN1zcLwjue9v2omgXW3aa FNc53oksDy+kaPqxfHkiUCv6bt+Pyu2Jnu+/YgmUgGZRryLM1RjaQZll/6Z7oTmhzBvE PKCZViKJjsC8Iby3CQUgImPYzIxnfQ3W5auAl8YmWFfpWffnBPwOsJAvJTBgsI+dkdpc 3fb6okSqw3DboKY96Pi4FnSLWnkp9JaldASPKXhcG574w+Njr9zatLdO/OlJh36FCQ2W dHdg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=iounUrno; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id m23si900875eja.217.2020.10.22.06.41.09; Thu, 22 Oct 2020 06:41:33 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=iounUrno; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2508103AbgJVF4p (ORCPT + 99 others); Thu, 22 Oct 2020 01:56:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38828 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2508098AbgJVF4p (ORCPT ); Thu, 22 Oct 2020 01:56:45 -0400 Received: from mail-pj1-x1043.google.com (mail-pj1-x1043.google.com [IPv6:2607:f8b0:4864:20::1043]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BA0E9C0613CE; Wed, 21 Oct 2020 22:56:43 -0700 (PDT) Received: by mail-pj1-x1043.google.com with SMTP id a17so421589pju.1; Wed, 21 Oct 2020 22:56:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=ONnPqbEGpsHiC+7+xAJ566Uy7tk/a7WVPjlnbMKceyI=; b=iounUrnoUrJZ/ErJbP/e7FMedE451AQknxPCSd6Kkk0QPcLgBtLBrckOmJPMOTl+E1 9JIbxrT/Cpw2dcmL8hULU/xBm72TaBolOMdCqlRwOxqC1r/JwoWDxYwp9Cxom6eGCKRa ujZUCCR17ib4G7JDNUU6VwcZ20qHie25+HbEHJfZkLikVblDY4IbgK3L1nqIflhm7mcp W6ZPOKroZKFUjGEoBqv+5jqhswg/U69FLGgs/yGY3OkX9KHHC5FdUa70QF15IogyJbQo sLmM2B8ME/cGw1Es3VeByfQsFDMUMtjngoNKfHMs9g2UiL+6SRerGR0m7WOJI+efc3kL SLfg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=ONnPqbEGpsHiC+7+xAJ566Uy7tk/a7WVPjlnbMKceyI=; b=EEH7R8+eCymoi1EL27N/9LyIFM3kCl4KHbOk4ZWD3aDcPrZAuaky0H+eA+Wi+f496D aDjMlXf+EKwwxPzG3DFJ87VYC3k/zYAawulnKlxHMu+ZImkNgHuWhEF3Ek4/IxK3nw7x UUfuXF0WSKQLRGNmAfmdVMGWgPcAtCrRNaYk+lUopcdi6hvg0aynCHgz82oMXI6iKgdB NfhAt9iWdMdoflote9hV7K7flXSFyN1yOfKr5bU/O5LD1+wNsr3uwys3/6k9bGXim06z TJgn5retbuB8Vzi2b7SQD7SUOJYldAZgHQr0FmohYLmOnUMq+SIrqadpe2PR4bdPQZl0 /GiA== X-Gm-Message-State: AOAM530mx8r1V3Lp4f9XBlkDOPCawivuoQFPZhDkUSyns/FrvoALv4h4 ixKeBD8jJnUgcppPtt5rNHx26bMKDQ== X-Received: by 2002:a17:90a:ca90:: with SMTP id y16mr21279pjt.113.1603346203179; Wed, 21 Oct 2020 22:56:43 -0700 (PDT) Received: from mylaptop.redhat.com ([209.132.188.80]) by smtp.gmail.com with ESMTPSA id c12sm830995pgi.14.2020.10.21.22.56.35 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 21 Oct 2020 22:56:42 -0700 (PDT) From: Pingfan Liu To: linux-kernel@vger.kernel.org Cc: Pingfan Liu , Thomas Gleixner , Peter Zijlstra , Jisheng Zhang , Andrew Morton , "Guilherme G. Piccoli" , Petr Mladek , Marc Zyngier , Linus Walleij , afzal mohammed , Lina Iyer , "Gustavo A. R. Silva" , Maulik Shah , Al Viro , Jonathan Corbet , Pawan Gupta , Mike Kravetz , Oliver Neukum , linux-doc@vger.kernel.org, kexec@lists.infradead.org Subject: [PATCH 2/3] kernel/watchdog: suppress max irq when irq floods Date: Thu, 22 Oct 2020 13:56:02 +0800 Message-Id: <1603346163-21645-3-git-send-email-kernelfans@gmail.com> X-Mailer: git-send-email 2.7.5 In-Reply-To: <1603346163-21645-1-git-send-email-kernelfans@gmail.com> References: <1603346163-21645-1-git-send-email-kernelfans@gmail.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The capture kernel should try its best to save the crash info. Normally, irq flood is caused by some trivial devices, which has no impact on saving vmcore. Introducing a parameter "irqflood_suppress" to enable suppress irq flood. Signed-off-by: Pingfan Liu Cc: Thomas Gleixner Cc: Peter Zijlstra Cc: Jisheng Zhang Cc: Andrew Morton Cc: "Guilherme G. Piccoli" Cc: Petr Mladek Cc: Marc Zyngier Cc: Linus Walleij Cc: afzal mohammed Cc: Lina Iyer Cc: "Gustavo A. R. Silva" Cc: Maulik Shah Cc: Al Viro Cc: Jonathan Corbet Cc: Pawan Gupta Cc: Mike Kravetz Cc: Oliver Neukum To: linux-kernel@vger.kernel.org Cc: linux-doc@vger.kernel.org Cc: kexec@lists.infradead.org --- include/linux/irq.h | 2 ++ kernel/irq/spurious.c | 32 ++++++++++++++++++++++++++++++++ kernel/watchdog.c | 9 ++++++++- 3 files changed, 42 insertions(+), 1 deletion(-) diff --git a/include/linux/irq.h b/include/linux/irq.h index 1b7f4df..140cb61 100644 --- a/include/linux/irq.h +++ b/include/linux/irq.h @@ -684,6 +684,8 @@ extern void note_interrupt(struct irq_desc *desc, irqreturn_t action_ret); /* Enable/disable irq debugging output: */ extern int noirqdebug_setup(char *str); +void suppress_max_irq(void); + /* Checks whether the interrupt can be requested by request_irq(): */ extern int can_request_irq(unsigned int irq, unsigned long irqflags); diff --git a/kernel/irq/spurious.c b/kernel/irq/spurious.c index f865e5f..d3d94d6 100644 --- a/kernel/irq/spurious.c +++ b/kernel/irq/spurious.c @@ -464,3 +464,35 @@ static int __init irqpoll_setup(char *str) } __setup("irqpoll", irqpoll_setup); + +#ifdef CONFIG_IRQ_TIME_ACCOUNTING + +static bool irqflood_suppress; + +static int __init irqflood_suppress_setup(char *str) +{ + irqflood_suppress = true; + pr_info("enable auto suppress irqflood\n"); + return 1; +} +__setup("irqflood_suppress", irqflood_suppress_setup); + +void suppress_max_irq(void) +{ + unsigned int tmp, maxirq = 0, max = 0; + int irq; + + if (!irqflood_suppress) + return; + for_each_active_irq(irq) { + tmp = kstat_irqs_cpu(irq, smp_processor_id()); + if (max < tmp) { + maxirq = irq; + max = tmp; + } + } + pr_warn("Suppress irq:%u, which is triggered %u times\n", + maxirq, max); + disable_irq_nosync(maxirq); +} +#endif diff --git a/kernel/watchdog.c b/kernel/watchdog.c index 230ac38..28a74e5 100644 --- a/kernel/watchdog.c +++ b/kernel/watchdog.c @@ -24,6 +24,7 @@ #include #include #include +#include #include #include @@ -364,9 +365,15 @@ static void check_irq_flood(void) percent = irqts * 100 / totalts; percent = percent < 100 ? percent : 100; __this_cpu_write(check_hint, -1); - if (percent >= 98) + if (percent >= 98) { pr_info("Irq flood occupies more than %lu%% of the past %lu seconds\n", percent, totalts >> 30); + /* + * Suppress top irq when scheduler does not work for long time and irq + * occupies too much time. + */ + suppress_max_irq(); + } } else if (cnt == 0) { __this_cpu_write(last_total_ts, totalts); __this_cpu_write(last_irq_ts, irqts); -- 2.7.5