Skip to contentSkip to conversation

xen/x86: pretty print interrupt CPU affinity masks

PATCH In review Roger Pau Monne 4 participants 6 messages May 15, 2024 – May 17, 2024

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 xen/x86: pretty print interrupt CPU affinity masks

Print the CPU affinity masks as numeric ranges instead of plain hexadecimal bitfields.

---
 xen/arch/x86/irq.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
xen/arch/x86/irq.c +5 -5
index 80ba8d9fe912..3b951d81bd6d 100644
@@ -1934,10 +1934,10 @@ void do_IRQ(struct cpu_user_regs *regs)
                 if ( ~irq < nr_irqs && irq_desc_initialized(desc) )
                 {
                     spin_lock(&desc->lock);
-                    printk("IRQ%d a=%04lx[%04lx,%04lx] v=%02x[%02x] t=%s s=%08x\n",
-                           ~irq, *cpumask_bits(desc->affinity),
-                           *cpumask_bits(desc->arch.cpu_mask),
-                           *cpumask_bits(desc->arch.old_cpu_mask),
+                    printk("IRQ%d a={%*pbl}[{%*pbl},{%*pbl}] v=%02x[%02x] t=%s s=%08x\n",
+                           ~irq, CPUMASK_PR(desc->affinity),
+                           CPUMASK_PR(desc->arch.cpu_mask),
+                           CPUMASK_PR(desc->arch.old_cpu_mask),
                            desc->arch.vector, desc->arch.old_vector,
                            desc->handler->typename, desc->status);
                     spin_unlock(&desc->lock);
@@ -2638,7 +2638,7 @@ void fixup_irqs(const cpumask_t *mask, bool verbose)
         if ( !set_affinity )
             printk("Cannot set affinity for IRQ%u\n", irq);
         else if ( break_affinity )
-            printk("Broke affinity for IRQ%u, new: %*pb\n",
+            printk("Broke affinity for IRQ%u, new: {%*pbl}\n",
                    irq, CPUMASK_PR(affinity));
     }
 
Signature · 1 line
2.44.0
#3 lore raw
In reply to Roger Pau Monne
Quoted 13 lines · Roger Pau Monne

Print the CPU affinity masks as numeric ranges instead of plain hexadecimal bitfields.

---
 xen/arch/x86/irq.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
xen/arch/x86/irq.c +0 -0
index 80ba8d9fe912..3b951d81bd6d 100644

xen/arch/x86/irq.c void do_IRQ(struct cpu_user_regs *regs) · line 1937

Quoted 8 lines
xen/arch/x86/irq.c +1 -4
@@ -1934,10 +1934,10 @@ void do_IRQ(struct cpu_user_regs *regs)
                 if ( ~irq < nr_irqs && irq_desc_initialized(desc) )
                 {
                     spin_lock(&desc->lock);
-                    printk("IRQ%d a=%04lx[%04lx,%04lx] v=%02x[%02x] t=%s s=%08x\n",
-                           ~irq, *cpumask_bits(desc->affinity),
-                           *cpumask_bits(desc->arch.cpu_mask),
-                           *cpumask_bits(desc->arch.old_cpu_mask),
+                    printk("IRQ%d a={%*pbl}[{%*pbl},{%*pbl}] v=%02x[%02x] t=%s s=%08x\n",

Looking at this more closely, there's still some information obfuscation going on.

How about "... a={} o={} n={} v=..."

so affinity, old and new masks are all stated explicitly, instead of having to remember what the square brackets mean, and in particular that the masks are backwards?

Happy to adjust on commit.

~Andrew

#4 lore raw
Quoted 26 lines · Andrew Cooper
Quoted 13 lines · Roger Pau Monne

Print the CPU affinity masks as numeric ranges instead of plain hexadecimal bitfields.

---
 xen/arch/x86/irq.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
xen/arch/x86/irq.c +0 -0
index 80ba8d9fe912..3b951d81bd6d 100644

xen/arch/x86/irq.c void do_IRQ(struct cpu_user_regs *regs) · line 1937

Quoted 8 lines
xen/arch/x86/irq.c +1 -4
@@ -1934,10 +1934,10 @@ void do_IRQ(struct cpu_user_regs *regs)
                 if ( ~irq < nr_irqs && irq_desc_initialized(desc) )
                 {
                     spin_lock(&desc->lock);
-                    printk("IRQ%d a=%04lx[%04lx,%04lx] v=%02x[%02x] t=%s s=%08x\n",
-                           ~irq, *cpumask_bits(desc->affinity),
-                           *cpumask_bits(desc->arch.cpu_mask),
-                           *cpumask_bits(desc->arch.old_cpu_mask),
+                    printk("IRQ%d a={%*pbl}[{%*pbl},{%*pbl}] v=%02x[%02x] t=%s s=%08x\n",

Looking at this more closely, there's still some information obfuscation going on.

Quoted 7 lines

How about "... a={} o={} n={} v=..."

so affinity, old and new masks are all stated explicitly, instead of having to remember what the square brackets mean, and in particular that the masks are backwards?

Happy to adjust on commit.

Sure, I guess I got used to it and didn't think of adjusting the format. The only risk is anyone having an automated parser to consume that information, but I think it's unlikely.

Thanks, Roger.

#5 lore raw
In reply to Andrew Cooper
Quoted 26 lines · Andrew Cooper
Quoted 13 lines · Roger Pau Monne

Print the CPU affinity masks as numeric ranges instead of plain hexadecimal bitfields.

---
 xen/arch/x86/irq.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
xen/arch/x86/irq.c +0 -0
index 80ba8d9fe912..3b951d81bd6d 100644

xen/arch/x86/irq.c void do_IRQ(struct cpu_user_regs *regs) · line 1937

Quoted 8 lines
xen/arch/x86/irq.c +1 -4
@@ -1934,10 +1934,10 @@ void do_IRQ(struct cpu_user_regs *regs)
                 if ( ~irq < nr_irqs && irq_desc_initialized(desc) )
                 {
                     spin_lock(&desc->lock);
-                    printk("IRQ%d a=%04lx[%04lx,%04lx] v=%02x[%02x] t=%s s=%08x\n",
-                           ~irq, *cpumask_bits(desc->affinity),
-                           *cpumask_bits(desc->arch.cpu_mask),
-                           *cpumask_bits(desc->arch.old_cpu_mask),
+                    printk("IRQ%d a={%*pbl}[{%*pbl},{%*pbl}] v=%02x[%02x] t=%s s=%08x\n",

Looking at this more closely, there's still some information obfuscation going on.

Quoted 5 lines

How about "... a={} o={} n={} v=..."

so affinity, old and new masks are all stated explicitly, instead of having to remember what the square brackets mean, and in particular that the masks are backwards?

Just one question: Why put old ahead of new? Aiui that's what you refer to with "backwards", yet I don't see what's backwards about it. Old would possibly matter only when the IRQ was recently moved, whereas new (actually:
Why "new"?) would matter at all times. I'd see "... a={} m={} o={} v=..." as more appropriate.

Jan