mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Radu Rendec <radu@rendec.net>
To: Thomas Gleixner <tglx@kernel.org>, LKML <linux-kernel@vger.kernel.org>
Cc: x86@kernel.org, Michael Kelley <mhklinux@outlook.com>,
	Dmitry Ilvokhin <d@ilvokhin.com>,
	Jan Kiszka <jan.kiszka@siemens.com>,
	Kieran Bingham <kbingham@kernel.org>,
	Florian Fainelli <florian.fainelli@broadcom.com>,
	 Marc Zyngier <maz@kernel.org>
Subject: Re: [patch V5 07/15] scripts/gdb: Update x86 interrupts to the array based storage
Date: Thu, 02 Apr 2026 13:11:36 -0400	[thread overview]
Message-ID: <160cd0288aabf32fc17e4fde518cb9e7921ad2aa.camel@rendec.net> (raw)
In-Reply-To: <20260401201348.491212585@kernel.org>

On Wed, 2026-04-01 at 23:52 +0200, Thomas Gleixner wrote:
> From: Thomas Gleixner <tglx@kernel.org>
> 
> x86 changed the interrupt statistics from a struct with individual members
> to an counter array. It also provides a corresponding info array with the
> strings for prefix and description and an indicator to skip the entry.
> 
> Update the already out of sync GDB script to use the counter and the info
> array, which keeps the GDB script in sync automatically.
> 
> Signed-off-by: Thomas Gleixner <tglx@kernel.org>
> Tested-by: Florian Fainelli <florian.fainelli@broadcom.com>
> Reviewed-by: Florian Fainelli <florian.fainelli@broadcom.com>
> ---
> V5: Bring the show_err_irq() back as it is used on mips
>     Fix the index calculation for the show bitmap so it works with more than one
>     unsigned long.
> V4: Adopted to irq_stat_count_show bitmap and removed the duplicate ERR/MIS output
> V3: New patch - Radu
> ---
>  scripts/gdb/linux/interrupts.py |   81 +++++++++++-----------------------------
>  1 file changed, 23 insertions(+), 58 deletions(-)
> --- a/scripts/gdb/linux/interrupts.py
> +++ b/scripts/gdb/linux/interrupts.py
> @@ -90,71 +90,29 @@ irq_desc_type = utils.CachedType("struct
>  
>      return text
>  
> -def show_irq_err_count(prec):
> -    cnt = utils.gdb_eval_or_none("irq_err_count")
> -    text = ""
> -    if cnt is not None:
> -        text += "%*s: %10u\n" % (prec, "ERR", cnt['counter'])
> -    return text
> -

Nit: show_irq_err_count() is unchanged, and I see no obvious reason to
move it down below. Keeping it here would exclude it from the patch
altogether, making the patch shorter and easier to read/review.

> -def x86_show_irqstat(prec, pfx, field, desc):
> -    irq_stat = gdb.parse_and_eval("&irq_stat")
> +def x86_show_irqstat(prec, pfx, idx, desc):
> +    irq_stat = gdb.parse_and_eval("&irq_stat.counts[%d]" %idx)
>      text = "%*s: " % (prec, pfx)
>      for cpu in cpus.each_online_cpu():
>          stat = cpus.per_cpu(irq_stat, cpu)
> -        text += "%10u " % (stat[field])
> -    text += "  %s\n" % (desc)
> -    return text
> -
> -def x86_show_mce(prec, var, pfx, desc):
> -    pvar = gdb.parse_and_eval(var)
> -    text = "%*s: " % (prec, pfx)
> -    for cpu in cpus.each_online_cpu():
> -        text += "%10u " % (cpus.per_cpu(pvar, cpu).dereference())
> -    text += "  %s\n" % (desc)
> +        text += "%10u " % (stat.dereference())

Something is wrong here. The counters for the arch specific interrupts
are not aligned with the generic ones. Sample from my VM setup:

(gdb) lx-interruptlist 
           CPU0       CPU1       CPU2       CPU3       
  1:          0         0         9         0   IO-APIC    1-edge      i8042
  4:          0         0         0       267   IO-APIC    4-edge      ttyS0
  9:          0         0         0         0   IO-APIC    9-fasteoi   acpi
 12:          0        15         0         0   IO-APIC   12-edge      i8042
[...]
NMI:          0          0          0          0   Non-maskable interrupts
LOC:       3925       3997       4281       3972   Local timer interrupts
PMI:          0          0          0          0   Performance monitoring interrupts
[...]

If I remove the space in "%10u " it becomes aligned but then the
description is no longer aligned.

> +    text += desc
>      return text
>  
>  def x86_show_interupts(prec):
> -    text = x86_show_irqstat(prec, "NMI", '__nmi_count', 'Non-maskable interrupts')
> +    info_type = gdb.lookup_type('struct irq_stat_info')
> +    info = gdb.parse_and_eval('irq_stat_info')
> +    bitmap = gdb.parse_and_eval('irq_stat_count_show')
> +    bitsperlong = 8 * int(bitmap.type.target().sizeof)
>  
> -    if constants.LX_CONFIG_X86_LOCAL_APIC:
> -        text += x86_show_irqstat(prec, "LOC", 'apic_timer_irqs', "Local timer interrupts")
> -        text += x86_show_irqstat(prec, "SPU", 'irq_spurious_count', "Spurious interrupts")
> -        text += x86_show_irqstat(prec, "PMI", 'apic_perf_irqs', "Performance monitoring interrupts")
> -        text += x86_show_irqstat(prec, "IWI", 'apic_irq_work_irqs', "IRQ work interrupts")
> -        text += x86_show_irqstat(prec, "RTR", 'icr_read_retry_count', "APIC ICR read retries")
> -        if utils.gdb_eval_or_none("x86_platform_ipi_callback") is not None:
> -            text += x86_show_irqstat(prec, "PLT", 'x86_platform_ipis', "Platform interrupts")
> -
> -    if constants.LX_CONFIG_SMP:
> -        text += x86_show_irqstat(prec, "RES", 'irq_resched_count', "Rescheduling interrupts")
> -        text += x86_show_irqstat(prec, "CAL", 'irq_call_count', "Function call interrupts")
> -        text += x86_show_irqstat(prec, "TLB", 'irq_tlb_count', "TLB shootdowns")
> -
> -    if constants.LX_CONFIG_X86_THERMAL_VECTOR:
> -        text += x86_show_irqstat(prec, "TRM", 'irq_thermal_count', "Thermal events interrupts")
> -
> -    if constants.LX_CONFIG_X86_MCE_THRESHOLD:
> -        text += x86_show_irqstat(prec, "THR", 'irq_threshold_count', "Threshold APIC interrupts")
> -
> -    if constants.LX_CONFIG_X86_MCE_AMD:
> -        text += x86_show_irqstat(prec, "DFR", 'irq_deferred_error_count', "Deferred Error APIC interrupts")
> -
> -    if constants.LX_CONFIG_X86_MCE:
> -        text += x86_show_mce(prec, "&mce_exception_count", "MCE", "Machine check exceptions")
> -        text += x86_show_mce(prec, "&mce_poll_count", "MCP", "Machine check polls")
> -
> -    text += show_irq_err_count(prec)
> -
> -    if constants.LX_CONFIG_X86_IO_APIC:
> -        cnt = utils.gdb_eval_or_none("irq_mis_count")
> -        if cnt is not None:
> -            text += "%*s: %10u\n" % (prec, "MIS", cnt['counter'])
> -
> -    if constants.LX_CONFIG_KVM:
> -        text += x86_show_irqstat(prec, "PIN", 'kvm_posted_intr_ipis', 'Posted-interrupt notification event')
> -        text += x86_show_irqstat(prec, "NPI", 'kvm_posted_intr_nested_ipis', 'Nested posted-interrupt event')
> -        text += x86_show_irqstat(prec, "PIW", 'kvm_posted_intr_wakeup_ipis', 'Posted-interrupt wakeup event')
> +    text = ""
> +    for idx in range(int(info.type.sizeof / info_type.sizeof)):
> +        show = bitmap[int(idx / bitsperlong)]
> +        if not show & 1 << int(idx % bitsperlong):
> +            continue
> +        pfx = info[idx]['symbol'].string()
> +        desc = info[idx]['text'].string()
> +        text += x86_show_irqstat(prec, pfx, idx, desc)
>  
>      return text
>  
> @@ -187,6 +145,13 @@ irq_desc_type = utils.CachedType("struct
>      text += "%*s: %10lu\n" % (prec, "ERR", gdb.parse_and_eval("irq_err_count"))
>      return text
>  
> +def show_irq_err_count(prec):
> +    cnt = utils.gdb_eval_or_none("irq_err_count")
> +    text = ""
> +    if cnt is not None:
> +        text += "%*s: %10u\n" % (prec, "ERR", cnt['counter'])
> +    return text
> +
>  def arch_show_interrupts(prec):
>      text = ""
>      if utils.is_target_arch("x86"):

  reply	other threads:[~2026-04-02 17:11 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-04-01 21:51 [patch V5 00/15] Improve /proc/interrupts further Thomas Gleixner
2026-04-01 21:51 ` [patch V5 01/15] x86/irq: Optimize interrupts decimals printing Thomas Gleixner
2026-04-01 21:51 ` [patch V5 02/15] genirq/proc: Avoid formatting zero counts in /proc/interrupts Thomas Gleixner
2026-04-01 21:51 ` [patch V5 03/15] genirq/proc: Utilize irq_desc::tot_count to avoid evaluation Thomas Gleixner
2026-04-01 21:51 ` [patch V5 04/15] x86/irq: Make irqstats array based Thomas Gleixner
2026-04-01 21:51 ` [patch V5 05/15] x86/irq: Suppress unlikely interrupt stats by default Thomas Gleixner
2026-04-02 16:39   ` Radu Rendec
2026-05-11 14:38     ` Thomas Gleixner
2026-04-01 21:52 ` [patch V5 06/15] x86/irq: Move IOAPIC misrouted and PIC/APIC error counts into irq_stats Thomas Gleixner
2026-04-02 16:41   ` Radu Rendec
2026-04-01 21:52 ` [patch V5 07/15] scripts/gdb: Update x86 interrupts to the array based storage Thomas Gleixner
2026-04-02 17:11   ` Radu Rendec [this message]
2026-04-01 21:52 ` [patch V5 08/15] genirq: Expose nr_irqs in core code Thomas Gleixner
2026-04-01 21:52 ` [patch V5 09/15] genirq/manage: Make NMI cleanup RT safe Thomas Gleixner
2026-04-01 21:52 ` [patch V5 10/15] genirq: Cache the condition for /proc/interrupts exposure Thomas Gleixner
2026-04-02 17:27   ` Radu Rendec
2026-04-01 21:52 ` [patch V5 11/15] genirq: Calculate precision only when required Thomas Gleixner
2026-04-01 21:52 ` [patch V5 12/15] genirq: Add rcuref count to struct irq_desc Thomas Gleixner
2026-04-01 21:52 ` [patch V5 13/15] genirq: Expose irq_find_desc_at_or_after() in core code Thomas Gleixner
2026-04-01 21:52 ` [patch V5 14/15] genirq/proc: Runtime size the chip name Thomas Gleixner
2026-04-01 21:52 ` [patch V5 15/15] genirq/proc: Speed up /proc/interrupts iteration Thomas Gleixner
2026-04-02  2:32 ` [patch V5 00/15] Improve /proc/interrupts further Michael Kelley
2026-04-02 13:46   ` Thomas Gleixner
2026-05-11 15:45   ` Thomas Gleixner

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=160cd0288aabf32fc17e4fde518cb9e7921ad2aa.camel@rendec.net \
    --to=radu@rendec.net \
    --cc=d@ilvokhin.com \
    --cc=florian.fainelli@broadcom.com \
    --cc=jan.kiszka@siemens.com \
    --cc=kbingham@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=maz@kernel.org \
    --cc=mhklinux@outlook.com \
    --cc=tglx@kernel.org \
    --cc=x86@kernel.org \
    /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

all inboxes | Powered by JetHome®