linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
From: Thomas Gleixner <tglx@linutronix.de>
To: Bitao Hu <yaoma@linux.alibaba.com>,
	dianders@chromium.org, 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
Cc: yaoma@linux.alibaba.com, linuxppc-dev@lists.ozlabs.org,
	linux-kernel@vger.kernel.org, linux-parisc@vger.kernel.org,
	linux-mips@vger.kernel.org
Subject: Re: [PATCHv10 3/4] genirq: Avoid summation loops for /proc/interrupts
Date: Tue, 27 Feb 2024 10:26:55 +0100	[thread overview]
Message-ID: <87le769s0w.ffs@tglx> (raw)
In-Reply-To: <20240226020939.45264-4-yaoma@linux.alibaba.com>

On Mon, Feb 26 2024 at 10:09, Bitao Hu wrote:
> We could use the irq_desc::tot_count member to avoid the summation
> loop for interrupts which are not marked as 'PER_CPU' interrupts in
> 'show_interrupts'. This could reduce the time overhead of reading
> /proc/interrupts.

"Could" is not really a technical term. Either we do or we do not. Also
please provide context for your change and avoid the 'We'.

> --- a/include/linux/irqdesc.h
> +++ b/include/linux/irqdesc.h
> @@ -121,6 +121,8 @@ static inline void irq_unlock_sparse(void) { }
>  extern struct irq_desc irq_desc[NR_IRQS];
>  #endif
>
> +extern bool irq_is_nmi(struct irq_desc *desc);
> +

If at all this wants to be in kernel/irq/internal.h. There is zero
reason to expose this globally.

> -static bool irq_is_nmi(struct irq_desc *desc)
> +bool irq_is_nmi(struct irq_desc *desc)
>  {
>  	return desc->istate & IRQS_NMI;
>  }

If at all this really wants to be a static inline in internals.h, but
instead of blindly copying code this can be done smarter:

unsigned int kstat_irq_desc(struct irq_desc *desc)
{
	unsigned int sum = 0;
	int cpu;

	if (!irq_settings_is_per_cpu_devid(desc) &&
	    !irq_settings_is_per_cpu(desc) &&
	    !irq_is_nmi(desc))
		return data_race(desc->tot_count);

	for_each_possible_cpu(cpu)
		sum += data_race(*per_cpu_ptr(desc->kstat_irqs, cpu));
	return sum;
}

and then let kstat_irqs() and show_interrupts() use it. See?

With that a proper changelog would be:

   show_interrupts() unconditionally accumulates the per CPU interrupt
   statistics to determine whether an interrupt was ever raised.

   This can be avoided for all interrupts which are not strictly per CPU
   and not of type NMI because those interrupts provide already an
   accumulated counter. The required logic is already implemented in
   kstat_irqs().

   Split the inner access logic out of kstat_irqs() and use it for
   kstat_irqs() and show_interrupts() to avoid the accumulation loop
   when possible.

Thanks,

        tglx

  parent reply	other threads:[~2024-02-27  9:27 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-26  2:09 [PATCHv10 0/4] *** Detect interrupt storm in softlockup *** Bitao Hu
2024-02-26  2:09 ` [PATCHv10 1/4] watchdog/softlockup: low-overhead detection of interrupt storm Bitao Hu
2024-02-26  2:09 ` [PATCHv10 2/4] genirq: Provide a snapshot mechanism for interrupt statistics Bitao Hu
2024-02-27  4:10   ` Liu Song
2024-02-26  2:09 ` [PATCHv10 3/4] genirq: Avoid summation loops for /proc/interrupts Bitao Hu
2024-02-27  7:48   ` Liu Song
2024-02-27  9:26   ` Thomas Gleixner [this message]
2024-02-27 11:20     ` Bitao Hu
2024-02-27 15:39       ` Thomas Gleixner
2024-02-28  6:07         ` Bitao Hu
2024-02-26  2:09 ` [PATCHv10 4/4] watchdog/softlockup: report the most frequent interrupts Bitao Hu
2024-02-27  9:02   ` Liu Song

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87le769s0w.ffs@tglx \
    --to=tglx@linutronix.de \
    --cc=James.Bottomley@HansenPartnership.com \
    --cc=akpm@linux-foundation.org \
    --cc=deller@gmx.de \
    --cc=dianders@chromium.org \
    --cc=jan.kiszka@siemens.com \
    --cc=kernelfans@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mips@vger.kernel.org \
    --cc=linux-parisc@vger.kernel.org \
    --cc=linuxppc-dev@lists.ozlabs.org \
    --cc=liusong@linux.alibaba.com \
    --cc=npiggin@gmail.com \
    --cc=pmladek@suse.com \
    --cc=tsbogend@alpha.franken.de \
    --cc=yaoma@linux.alibaba.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).