From: Thomas Gleixner <tglx@linutronix.de>
To: Adrian Huang <adrianhuang0701@gmail.com>
Cc: linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org,
Jiwei Sun <sunjw10@lenovo.com>,
Adrian Huang <ahuang12@lenovo.com>
Subject: Re: [PATCH 2/2] genirq/proc: Refine percpu kstat_irqs access logic
Date: Wed, 15 May 2024 01:04:41 +0200 [thread overview]
Message-ID: <87h6f0knau.ffs@tglx> (raw)
In-Reply-To: <20240513120548.14046-3-ahuang12@lenovo.com>
On Mon, May 13 2024 at 20:05, Adrian Huang wrote:
> @@ -461,7 +461,7 @@ int show_interrupts(struct seq_file *p, void *v)
> {
> static int prec;
>
> - unsigned long flags, any_count = 0;
> + unsigned long flags, print_irq = 1;
What's wrong with making print_irq boolean?
> int i = *(loff_t *) v, j;
> struct irqaction *action;
> struct irq_desc *desc;
> @@ -488,18 +488,28 @@ int show_interrupts(struct seq_file *p, void *v)
> if (!desc || irq_settings_is_hidden(desc))
> goto outsparse;
>
> - if (desc->kstat_irqs) {
> - for_each_online_cpu(j)
> - any_count |= data_race(*per_cpu_ptr(desc->kstat_irqs, j));
> + if ((!desc->action || irq_desc_is_chained(desc)) && desc->kstat_irqs) {
The condition is wrong. Look how the old code evaluated any_count.
> + print_irq = 0;
> + for_each_online_cpu(j) {
> + if (data_race(*per_cpu_ptr(desc->kstat_irqs, j))) {
> + print_irq = 1;
> + break;
> + }
> + }
Aside of that this code is just fundamentally wrong in several aspects:
1) Interrupts which have no action are completely uninteresting as
there is no real information attached, i.e. it shows that there
were interrupts on some CPUs, but there is zero information from
which device they originated.
Especially with sparse interrupts enabled they are usually gone
shortly after the last action was removed.
2) Chained interrupts do not have a count at all as they completely
evade the core kernel entry points.
So all of this can be avoided and the whole nonsense can be reduced to:
if (!desc->action || irq_desc_is_chained(desc) || !desc->kstat_irqs)
goto outsparse;
which in turn allows to convert this:
> - for_each_online_cpu(j)
> - seq_printf(p, "%10u ", desc->kstat_irqs ?
> - *per_cpu_ptr(desc->kstat_irqs, j) : 0);
into an unconditional:
for_each_online_cpu(j)
seq_printf(p, "%10u ", *per_cpu_ptr(desc->kstat_irqs, j));
Thanks,
tglx
prev parent reply other threads:[~2024-05-14 23:04 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-05-13 12:05 [PATCH 0/2] genirq/proc: Speed up show_interrupts() Adrian Huang
2024-05-13 12:05 ` [PATCH 1/2] genirq/proc: Try to jump over the unallocated irq hole whenever possible Adrian Huang
2024-05-13 12:05 ` [PATCH 2/2] genirq/proc: Refine percpu kstat_irqs access logic Adrian Huang
2024-05-14 23:04 ` Thomas Gleixner [this message]
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=87h6f0knau.ffs@tglx \
--to=tglx@linutronix.de \
--cc=adrianhuang0701@gmail.com \
--cc=ahuang12@lenovo.com \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=sunjw10@lenovo.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).