Received: by 2002:ab2:3141:0:b0:1ed:23cc:44d1 with SMTP id i1csp1786795lqg; Mon, 4 Mar 2024 04:01:08 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXOn2/6sjCJjetijFR0A2PeANEDTCFxSNf5CtxMwX6IWGhw0gP7snGSr2gua7E5HkkMDRxonb/IamArvcTrY92VT5At16NGm8BXbeHuQQ== X-Google-Smtp-Source: AGHT+IHcd2Jmi7nP0tJenOjLZqooK4u1T0AroWjpFkChj2PGGlH1pjHMH8ieZkg3mP8ajAMILmQT X-Received: by 2002:a05:6402:94f:b0:565:ebf3:e28a with SMTP id h15-20020a056402094f00b00565ebf3e28amr6171399edz.31.1709553668768; Mon, 04 Mar 2024 04:01:08 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709553668; cv=pass; d=google.com; s=arc-20160816; b=ZjeDlOcR6yAL2LcbMuxxeAaC4T0b1w+5nMG+9w8ADRYUbWQIZVJ/RhRT5U4vAIrDX1 nqfzy2WflSg+fil58p27nodAW+yCte+24ljoF1KNwqDODVujJPuXWJkmXs7bPGTflOUi J498wXS8362xP05f3EfU8SplSeRoPCVx0RqzDs8vAW+HSIHvu0ObfFCb7R3X0AmL2Xt+ 99xs1jkrmb9npUnjWpUb+Nwp6Na0p6vW4y0mNESUuedYPnfIiur9ACd4MQz7oYK4fF1W +YQmqfflmAc+GDvHlsDDxGrDdAkLpIZpFHV6U0BN13QxnM2dveIXqbGZifRRtFZopy1f YloQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:content-language:references :cc:to:subject:from:user-agent:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:message-id:dkim-signature; bh=rtN+/ylfbynl2rH4WVBwWc3AC3awpv+1WF5WI7ypLYI=; fh=ZehyhdcpW6LJtvXfieC77f+TZKG/3Qzb9hvizJ6PGw0=; b=vb0cXhR5V7b1KxQg74npuOWK10od4UDIuWA5j7psB5mGZFeiuCGzmLsrWmxSw2H+Yo qR16Skl6gtpaZtIsti/Db9pq12tHVV7WhSMn2mozFrdL8v8W9jkPsjbGT1uumEhyV9iz cLFa9a10XZvoE29Vdr/Duf7iyINl/lDYeKkGZIz1xbzbAiU/bNj/LY+e2ivbjj6Dlo0a cK48u8RLg/e+cG6X9XIhfVHd+ux7NeD9cqcnq3KItjNLhpfDwUea5cLIhq8vFF1YuhoR UVdzV36pKIafH95Fng0NUeTJ1qRgBDlHAiKHgH+4CifeHwe0XS7oaNV2D51TK9i8cQRa Bi4w==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linux.alibaba.com header.s=default header.b=wMXYIEUi; 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-90540-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-90540-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. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id v16-20020a50d590000000b0056738ed3e4dsi1143120edi.399.2024.03.04.04.01.08 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Mar 2024 04:01:08 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-90540-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.alibaba.com header.s=default header.b=wMXYIEUi; 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-90540-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-90540-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 54DAD1F22838 for ; Mon, 4 Mar 2024 12:01:08 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id C731C3B784; Mon, 4 Mar 2024 12:01:00 +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="wMXYIEUi" Received: from out30-118.freemail.mail.aliyun.com (out30-118.freemail.mail.aliyun.com [115.124.30.118]) (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 CEB9A39AF1; Mon, 4 Mar 2024 12:00:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=115.124.30.118 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709553660; cv=none; b=LsCSH3rUGBgJm4Y7H6cBYY/t9DlsK62xvc4XL3WafV2f+eaS+UP1Xe3A/hFQuuPCErbLvITTF1GZhFTpiSBLe4X4ebyG4s4qFPiLWTbCj7phfg36FJUTyYi7LtzswQjqimGVOTDL5BjOnYjAiD7GSrhk5+4zD4zPHYNbRPLpeJY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709553660; c=relaxed/simple; bh=SRlbTG/jH+XLr3HBMhDyMWI2WxBCgIajzCfFemzedW0=; h=Message-ID:Date:MIME-Version:From:Subject:To:Cc:References: In-Reply-To:Content-Type; b=KzOd7jd/Wpanq1z3ByKpmEFzzx8nxeyRgQBsh5uYKZJBnSpiaULIf6z3AW4GUBepFRHPPvwywZbbcpFyM7o6j33+jVpUjQueAC3HGAERgEnAAWdCUu6SLkbw1lEZMHVlghIRLoY6JVaONAmEBpls6l0B1H8br8mhkfDjtN6G5uw= 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=wMXYIEUi; arc=none smtp.client-ip=115.124.30.118 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=1709553647; h=Message-ID:Date:MIME-Version:From:Subject:To:Content-Type; bh=rtN+/ylfbynl2rH4WVBwWc3AC3awpv+1WF5WI7ypLYI=; b=wMXYIEUiwoVJH/xnD1RvI2dR+AACaMqlSOE/kB1fCanYeBJcd+yiA3TmmUiLeBlTbeJ3QMKsldMGq+xh3PcplByOaChpd3P/WTjzH4pDPi/mUpBC1csmwDWf3XI/0vN0O2SNCbbIo939zRN84aiPQMYkn9Resxb+Nh9u6Jdlk2I= X-Alimail-AntiSpam:AC=PASS;BC=-1|-1;BR=01201311R201e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=ay29a033018045192;MF=yaoma@linux.alibaba.com;NM=1;PH=DS;RN=16;SR=0;TI=SMTPD_---0W1pZInn_1709553643; Received: from 30.178.88.130(mailfrom:yaoma@linux.alibaba.com fp:SMTPD_---0W1pZInn_1709553643) by smtp.aliyun-inc.com; Mon, 04 Mar 2024 20:00:45 +0800 Message-ID: <3a89fafb-f62e-472f-b40b-8bf97954e9e3@linux.alibaba.com> Date: Mon, 4 Mar 2024 20:00:43 +0800 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird From: Bitao Hu Subject: Re: [PATCHv11 2/4] genirq: Provide a snapshot mechanism for interrupt statistics To: Thomas Gleixner , Doug Anderson Cc: liusong@linux.alibaba.com, akpm@linux-foundation.org, pmladek@suse.com, kernelfans@gmail.com, deller@gmx.de, npiggin@gmail.com, tsbogend@alpha.franken.de, James.Bottomley@hansenpartnership.com, jan.kiszka@siemens.com, linux-kernel@vger.kernel.org, linux-mips@vger.kernel.org, linux-parisc@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, yaoma@linux.alibaba.com References: <20240228072216.95130-1-yaoma@linux.alibaba.com> <20240228072216.95130-3-yaoma@linux.alibaba.com> <87plwdwycx.ffs@tglx> Content-Language: en-US In-Reply-To: <87plwdwycx.ffs@tglx> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Hi, On 2024/3/2 03:22, Thomas Gleixner wrote: > Doug! > > On Wed, Feb 28 2024 at 14:44, Doug Anderson wrote: >> I won't insist on it, but I continue to worry about memory >> implications with large numbers of CPUs. With a 4-byte int, 8192 max >> CPUs, and 100 IRQs the extra "ref" value takes up over 3MB of memory >> (8192 * 4 bytes * 100). >> >> Technically, you could add a new symbol like "config >> NEED_IRQ_SNAPSHOTS". This wouldn't be a symbol selectable by the end >> user but would automatically be selected by "config >> SOFTLOCKUP_DETECTOR_INTR_STORM". If the config wasn't defined then the >> struct wouldn't contain "ref" and the snapshot routines would just be >> static inline stubs. >> >> Maybe Thomas has an opinion about whether this is something to worry >> about. Worst case it wouldn't be hard to do in a follow-up patch. > > I'd say it makes sense to give people a choice to save memory especially > when the softlock detector code is not enabled. > > It's rather straight forward to do. > > Thanks, > > tglx > --- > --- a/include/linux/irqdesc.h > +++ b/include/linux/irqdesc.h > @@ -24,7 +24,9 @@ struct pt_regs; > */ > struct irqstat { > unsigned int cnt; > +#ifdef CONFIG_GENIRQ_STAT_SNAPSHOT > unsigned int ref; > +#endif > }; > > /** > --- a/kernel/irq/irqdesc.c > +++ b/kernel/irq/irqdesc.c > @@ -978,6 +978,7 @@ static unsigned int kstat_irqs(unsigned > return sum; > } > > +#ifdef CONFIG_GENIRQ_STAT_SNAPSHOT > void kstat_snapshot_irqs(void) > { > struct irq_desc *desc; > @@ -998,6 +999,7 @@ unsigned int kstat_get_irq_since_snapsho > return 0; > return this_cpu_read(desc->kstat_irqs->cnt) - this_cpu_read(desc->kstat_irqs->ref); > } > +#endif > > /** > * kstat_irqs_usr - Get the statistics for an interrupt from thread context > --- a/kernel/irq/Kconfig > +++ b/kernel/irq/Kconfig > @@ -108,6 +108,10 @@ config GENERIC_IRQ_MATRIX_ALLOCATOR > config GENERIC_IRQ_RESERVATION_MODE > bool > > +# Snapshot for interrupt statistics > +config GENERIC_IRQ_STAT_SNAPSHOT > + bool > + > # Support forced irq threading > config IRQ_FORCED_THREADING > bool I think we should follow Douglas's suggestion by making "config GENERIC_IRQ_STAT_SNAPSHOT" automatically selectable by "config SOFTLOCKUP_DETECTOR_INTR_STORM". This can prevent users from inadvertently disabling "config GENERIC_IRQ_STAT_SNAPSHOT" while enabling "config SOFTLOCKUP_DETECTOR_INTR_STORM". Best Regards, Bitao Hu diff --git a/kernel/irq/Kconfig b/kernel/irq/Kconfig index 2531f3496ab6..9cf3b2d4c2a8 100644 --- a/kernel/irq/Kconfig +++ b/kernel/irq/Kconfig @@ -108,6 +108,15 @@ config GENERIC_IRQ_MATRIX_ALLOCATOR config GENERIC_IRQ_RESERVATION_MODE bool +# Snapshot for interrupt statistics +config GENERIC_IRQ_STAT_SNAPSHOT + bool + help + + Say Y here to enable the kernel to provide a snapshot mechanism + for interrupt statistics. + + # Support forced irq threading config IRQ_FORCED_THREADING bool diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug index 49f652674bd8..899b69fcb598 100644 --- a/lib/Kconfig.debug +++ b/lib/Kconfig.debug @@ -1032,6 +1032,7 @@ config SOFTLOCKUP_DETECTOR config SOFTLOCKUP_DETECTOR_INTR_STORM bool "Detect Interrupt Storm in Soft Lockups" depends on SOFTLOCKUP_DETECTOR && IRQ_TIME_ACCOUNTING + select GENERIC_IRQ_STAT_SNAPSHOT default y if NR_CPUS <= 128 help Say Y here to enable the kernel to detect interrupt storm