Received: by 2002:a05:7412:798b:b0:fc:a2b0:25d7 with SMTP id fb11csp227854rdb; Thu, 22 Feb 2024 01:35:37 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCVCtB+SO99WvIh46x7Uyr2/C8ya8KHTr21aGiukLqoxGqgoQw1r25kxCz4hg/bu+UWoALb7+65mGJWrUB7gkQ2IQjhc2r/XBaQQ9jCX7A== X-Google-Smtp-Source: AGHT+IEbHypOX9Apfh6IRepTAB2dK6epfHzZg9Se2YDq7HCs6CV/3Yhj+S62WCNCPpEx1bs4wLaY X-Received: by 2002:a17:906:fa19:b0:a3e:f83d:f8a0 with SMTP id lo25-20020a170906fa1900b00a3ef83df8a0mr5873014ejb.52.1708594536846; Thu, 22 Feb 2024 01:35:36 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708594536; cv=pass; d=google.com; s=arc-20160816; b=oEWXNJoe7L+J3vq+RE/DT7kX204kyMUzpT05vtzyTH1HDaue5LXTwTxGTrW7HJkMlJ NofT0WHOvgnNUC5k75tgp2A9eUlXZgAQUEhlZ1/y8FHTWt5voQS/QjDD2uDyHwgLg/qi NrvUS5IdpVI/cZoBNuuvvdc2lqonQh0bTCQXRu3egqelNAYerlQ3XXo6yxksrSeWdKsS Z4pNn+9Umgv6hCBu/8/dEd2PkSrGKfQyERhBrncLmsy4onQ6tu0dg8MrvfxFe5TmFHIk CLV/v/3WFAj6iw1ovzXKny0DHTmpKh9WTjATUyJAV3E+G+dBK/OI73aVa4CebrE9NFM1 +Wdw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :from:dkim-signature; bh=aPig5fqEBfNoG36h6uMeosrEa0k4/Htbh0JalMplPlo=; fh=DAEIxaYwQs/UB0UnK4U0AKWKZBwQWk6ZmY1BK52GUeI=; b=KkWa2QxcLRuraiVhbLzFmKtyLIjXIyS6Sy4knK3kYfU0WLP4D3tUbY+Vll5PbRTxXp EL9lz3vvv+adjLs6P9xzPJxkUEnyExSg7WYIJRW+aApBJGGXSVc9pLMpg60t+qRYwqUm RL4vZy+UQmq2+JD+Cs/hLdqM2lQpfheskukNAyn965xEGp9hIo8ki9NrzNhvy0P8RniC HH7gfiQlFLjKnx6QdH3WNwp6ENrBIPdCRAQkSclL4qAv7oik3FlDdgXHg1psv0K8o3e8 U+dJ/dkN7q3B1cbx+R8T5hlBJRQ6fGsGitv44fl2H9A338QQco2g30mZb3nr0a0htaps x8jg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linux.alibaba.com header.s=default header.b=pSjxiIs+; arc=pass (i=1 spf=pass spfdomain=linux.alibaba.com dkim=pass dkdomain=linux.alibaba.com dmarc=pass fromdomain=linux.alibaba.com); spf=pass (google.com: domain of linux-kernel+bounces-76228-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-76228-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.alibaba.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id l9-20020a170906a40900b00a3e730bf328si4039933ejz.477.2024.02.22.01.35.36 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Feb 2024 01:35:36 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-76228-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.alibaba.com header.s=default header.b=pSjxiIs+; arc=pass (i=1 spf=pass spfdomain=linux.alibaba.com dkim=pass dkdomain=linux.alibaba.com dmarc=pass fromdomain=linux.alibaba.com); spf=pass (google.com: domain of linux-kernel+bounces-76228-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-76228-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.alibaba.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 97BA51F2567E for ; Thu, 22 Feb 2024 09:35:36 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 6BF5D3C480; Thu, 22 Feb 2024 09:34:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.alibaba.com header.i=@linux.alibaba.com header.b="pSjxiIs+" Received: from out30-131.freemail.mail.aliyun.com (out30-131.freemail.mail.aliyun.com [115.124.30.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4A45F381A1; Thu, 22 Feb 2024 09:34:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=115.124.30.131 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708594480; cv=none; b=ZmnJQYI6tJ07b0yjH6f7zRLF/PEPQR/BA8cHsru44N2QeZpLWbV6SIzBxVOhANBmltN5Ed9/En0Sa3cj/tl+xN/lVYfOj99bAxI4tpJcqltzkDKSq+GCq208f4JlsF+JRu3g8D8yYnfSsOA5oJvK2B/dgP4JZN13Tr9lHd4Z66Q= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708594480; c=relaxed/simple; bh=ddiKFBdz5yw2bRiLYr1cMFs/PV9Ya2hfGGttmLwie/k=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version:Content-Type; b=JVVY2jXf7DJdzgX4dXUEcd/H6k8vNofF7/jPyDs80TJ4x3h5WpGU/NrmPWIs/hijVQhnDJpmJTRF6a05AueGGEvd/4FpiwJ/djpV/vlkslt5LpI2Hx+RswRAuZevKM/BKoVkvc8/gvPf30fRZQmumJifkWKGwLxu2xlgsgm2lnw= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.alibaba.com; spf=pass smtp.mailfrom=linux.alibaba.com; dkim=pass (1024-bit key) header.d=linux.alibaba.com header.i=@linux.alibaba.com header.b=pSjxiIs+; arc=none smtp.client-ip=115.124.30.131 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.alibaba.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.alibaba.com DKIM-Signature:v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.alibaba.com; s=default; t=1708594468; h=From:To:Subject:Date:Message-Id:MIME-Version:Content-Type; bh=aPig5fqEBfNoG36h6uMeosrEa0k4/Htbh0JalMplPlo=; b=pSjxiIs+te3WS8N5jEH8tOy9f7idvpg5NmPvjJEI4OBpgjav2q6bD9CcxGBuW62fpxlGwkaJkAGeyyQIhu+3A3SrpPHZNKtUHu2Fgy385Bx07JXQrOvYfTmi+6v4h+g6ZxhknKilwnMjgrWvgybvdSGX4IBM/WuDJkos61ZTGhM= X-Alimail-AntiSpam:AC=PASS;BC=-1|-1;BR=01201311R171e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=ay29a033018046050;MF=yaoma@linux.alibaba.com;NM=1;PH=DS;RN=16;SR=0;TI=SMTPD_---0W10inwv_1708594464; Received: from localhost.localdomain(mailfrom:yaoma@linux.alibaba.com fp:SMTPD_---0W10inwv_1708594464) by smtp.aliyun-inc.com; Thu, 22 Feb 2024 17:34:26 +0800 From: Bitao Hu To: dianders@chromium.org, akpm@linux-foundation.org, liusong@linux.alibaba.com, tglx@linutronix.de, pmladek@suse.com, kernelfans@gmail.com, deller@gmx.de, npiggin@gmail.com, tsbogend@alpha.franken.de, James.Bottomley@HansenPartnership.com, jan.kiszka@siemens.com Cc: linux-kernel@vger.kernel.org, linux-mips@vger.kernel.org, linux-parisc@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, yaoma@linux.alibaba.com Subject: [PATCHv9 0/3] *** Detect interrupt storm in softlockup *** Date: Thu, 22 Feb 2024 17:34:17 +0800 Message-Id: <20240222093420.13956-1-yaoma@linux.alibaba.com> X-Mailer: git-send-email 2.37.1 (Apple Git-137.1) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Hi, guys. I have implemented a low-overhead method for detecting interrupt storm in softlockup. Please review it, all comments are welcome. Changes from v8 to v9: - Patch #1 remains unchanged. - From Thomas Gleixner, split patch #2 into two patches. Interrupt infrastructure first and then the actual usage site in the watchdog code. Changes from v7 to v8: - From Thomas Gleixner, implement statistics within the interrupt core code and provide sensible interfaces for the watchdog code. - Patch #1 remains unchanged. Patch #2 has significant changes based on Thomas's suggestions, which is why I have removed Liu Song and Douglas's Reviewed-by from patch #2. Please review it again, and all comments are welcome. Changes from v6 to v7: - Remove "READ_ONCE" in "start_counting_irqs" - Replace the hard-coded 5 with "NUM_SAMPLE_PERIODS" macro in "set_sample_period". - Add empty lines to help with reading the code. - Remove the branch that processes IRQs where "counts_diff = 0". - Add the Reviewed-by of Liu Song and Douglas. Changes from v5 to v6: - Use "./scripts/checkpatch.pl --strict" to get a few extra style nits and fix them. - Squash patch #3 into patch #1, and wrapp the help text to 80 columns. - Sort existing headers alphabetically in watchdog.c - Drop "softlockup_hardirq_cpus", just read "hardirq_counts" and see if it's non-NULL. - Store "nr_irqs" in a local variable. - Simplify the calculation of "cpu_diff". Changes from v4 to v5: - Rearranging variable placement to make code look neater. Changes from v3 to v4: - Renaming some variable and function names to make the code logic more readable. - Change the code location to avoid predeclaring. - Just swap rather than a double loop in tabulate_irq_count. - Since nr_irqs has the potential to grow at runtime, bounds-check logic has been implemented. - Add SOFTLOCKUP_DETECTOR_INTR_STORM Kconfig knob. Changes from v2 to v3: - From Liu Song, using enum instead of macro for cpu_stats, shortening the name 'idx_to_stat' to 'stats', adding 'get_16bit_precesion' instead of using right shift operations, and using 'struct irq_counts'. - From kernel robot test, using '__this_cpu_read' and '__this_cpu_write' instead of accessing to an per-cpu array directly, in order to avoid this warning. 'sparse: incorrect type in initializer (different modifiers)' Changes from v1 to v2: - From Douglas, optimize the memory of cpustats. With the maximum number of CPUs, that's now this. 2 * 8192 * 4 + 1 * 8192 * 5 * 4 + 1 * 8192 = 237,568 bytes. - From Liu Song, refactor the code format and add necessary comments. - From Douglas, use interrupt counts instead of interrupt time to determine the cause of softlockup. - Remove the cmdline parameter added in PATCHv1. Bitao Hu (3): watchdog/softlockup: low-overhead detection of interrupt storm irq: use a struct for the kstat_irqs in the interrupt descriptor watchdog/softlockup: report the most frequent interrupts arch/mips/dec/setup.c | 2 +- arch/parisc/kernel/smp.c | 2 +- arch/powerpc/kvm/book3s_hv_rm_xics.c | 2 +- include/linux/irqdesc.h | 9 +- include/linux/kernel_stat.h | 3 + kernel/irq/internals.h | 2 +- kernel/irq/irqdesc.c | 34 ++++- kernel/irq/proc.c | 9 +- kernel/watchdog.c | 213 ++++++++++++++++++++++++++- lib/Kconfig.debug | 13 ++ scripts/gdb/linux/interrupts.py | 6 +- 11 files changed, 268 insertions(+), 27 deletions(-) -- 2.37.1 (Apple Git-137.1)