iqrdomain: Improve formatting in debugfs.
Subsystems (4)
PATCH 1/1 iqrdomain: Improve formatting in debugfs.
From: David Daney <[email protected]>
The irq_domain_mapping file has some interesting output when chip_data contains leading zeros:
virq hwirq chip name chip data domain name
.
.
.
103 0x00000 CIU2-W 0x 5e0000000000000 none 104 0x00000 CIU2-W 0x 5f0000000000000 none 105 0x00000 CIU2-M 0x (null) none 113 0x00000 CIU2-E 0x1080000000000000 none
.
.
.
I think there should be no space in there between the "0x" and the rest. Also the '(null)' entry doesn't make much sense at all with a "0x".
Instead I suggest:
.
.
.
103 0x00000 CIU2-W 0x05e0000000000000 none 104 0x00000 CIU2-W 0x05f0000000000000 none 105 0x00000 CIU2-M 0x0000000000000000 none 113 0x00000 CIU2-E 0x1080000000000000 none
.
.
.
This patch also prints the "chip data" as an 8 character wide number for 32-bit kernels, instead of the 16 characters wide in the 64-bit case.
--- kernel/irq/irqdomain.c | 8 +++++--- 1 files changed, 5 insertions(+), 3 deletions(-)
kernel/irq/irqdomain.c +5 -3
@@ -642,9 +642,10 @@ static int virq_debug_show(struct seq_file *m, void *private)static const char none[] ="none" ;void *data;int i; +int ptr_width =sizeof (void *) *2 ; -seq_printf (m,"%-5s %-7s %-15s %-18s %s\n" ,"virq" ,"hwirq" , -"chip name" ,"chip data" ,"domain name" ); +seq_printf (m,"%-5s %-7s %-15s %-*s %s\n" ,"virq" ,"hwirq" , +"chip name" , ptr_width +2 ,"chip data" ,"domain name" );for (i =1 ; i < nr_irqs; i++) { desc =irq_to_desc (i);
@@ -667,7 +668,8 @@ static int virq_debug_show(struct seq_file *m, void *private)seq_printf (m,"%-15s " , p); data =irq_desc_get_chip_data (desc); -seq_printf (m,"0x%16p " , data); +seq_printf (m,"0x%0*lx " , + ptr_width, (unsigned long )data);if (desc->irq_data.domain && desc->irq_data.domain->of_node) p = desc->irq_data.domain->of_node->full_name;
Signature · 1 line
1.7.2.3
Quoted 13 lines · David Daney
From: David Daney <[email protected]>
The
irq_domain_mappingfile has some interesting output whenchip_datacontains leading zeros:virq hwirq chip name chip data domain name
.
.
.103 0x00000 CIU2-W 0x 5e0000000000000 none 104 0x00000 CIU2-W 0x 5f0000000000000 none 105 0x00000 CIU2-M 0x (null) none 113 0x00000 CIU2-E 0x1080000000000000 none
Quoted 7 lines
.
.
.I think there should be no space in there between the "0x" and the rest. Also the '(null)' entry doesn't make much sense at all with a "0x".
Yeah, it doesn't make much sense with the '0x', but I don't want to supress the (null) output because it is really important to highlight when a domain isn't assigned to an active irq.
Fixing the zero pad is trivial to fix though. Just remove the precision from the %p format. Here's my counter-patch:
---
kernel/irq/irqdomain.c +3 -3
@@ -643,8 +643,8 @@ static int virq_debug_show(struct seq_file *m, void *private)void *data;int i; -seq_printf (m,"%-5s %-7s %-15s %-18s %s\n" ,"virq" ,"hwirq" , -"chip name" ,"chip data" ,"domain name" ); +seq_printf (m,"%-5s %-7s %-15s %-*s %s\n" ,"irq" ,"hwirq" , +"chip name" ,2 *sizeof (void *) +2 ,"chip data" ,"domain name" );for (i =1 ; i < nr_irqs; i++) { desc =irq_to_desc (i);
@@ -667,7 +667,7 @@ static int virq_debug_show(struct seq_file *m, void *private)seq_printf (m,"%-15s " , p); data =irq_desc_get_chip_data (desc); -seq_printf (m,"0x%16p " , data); +seq_printf (m, data ?"0x%p " :" %p " , data);if (desc->irq_data.domain && desc->irq_data.domain->of_node) p = desc->irq_data.domain->of_node->full_name;
kernel/irq/irqdomain.c static int virq_debug_show(struct seq_file *m, void *private) · line 670
Quoted 6 lines · Grant Likely
kernel/irq/irqdomain.c +1
-1@@ -667,7 +667,7 @@ static int virq_debug_show(struct seq_file *m, void *private)seq_printf (m,"%-15s " , p); data =irq_desc_get_chip_data (desc); -seq_printf (m,"0x%16p " , data); +seq_printf (m, data ?"0x%p " :" %p " , data);
You should be able to use %#p instead to let it add the prefix.
Andreas.
Signature · 3 lines
Andreas Schwab, [email protected] GPG Key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5 "And now for something completely different."
Quoted 10 lines · Andreas Schwab
kernel/irq/irqdomain.c static int virq_debug_show(struct seq_file *m, void *private) · line 670
Quoted 6 lines · Grant Likely
kernel/irq/irqdomain.c +1
-1@@ -667,7 +667,7 @@ static int virq_debug_show(struct seq_file *m, void *private) seq_printf(m, "%-15s ", p); data = irq_desc_get_chip_data(desc); - seq_printf(m, "0x%16p ", data); + seq_printf(m, data ? "0x%p " : " %p ", data);You should be able to use %#p instead to let it add the prefix.
That mostly works, but it doesn't round up the field size to account for the 2 characters in '0x'. Looks like the %p code needs to be tweaked to fix that.
Also, gcc complains about it:
/home/grant/hacking/linux/kernel/irq/irqdomain.c: In function ‘virq_debug_show’:/home/grant/hacking/linux/kernel/irq/irqdomain.c:670:4: warning: '#' flag used with ‘%p’ gnu_printf format [-Wformat]
Do you know how to suppress that?
Quoted 12 lines · Grant Likely
Quoted 10 lines · Andreas Schwab
Review static int virq_debug_show(struct seq_file *m, void *private) · line 670
Quoted 6 lines · Grant Likely
(quoted diff) +1
-1@@ -667,7 +667,7 @@ static int virq_debug_show(struct seq_file *m, void *private) seq_printf(m, "%-15s ", p); data = irq_desc_get_chip_data(desc); - seq_printf(m, "0x%16p ", data); + seq_printf(m, data ? "0x%p " : " %p ", data);You should be able to use %#p instead to let it add the prefix.
Quoted 3 lines
That mostly works, but it doesn't round up the field size to account for the 2 characters in '0x'. Looks like the %p code needs to be tweaked to fix that.
which this change does:
lib/vsprintf.c +0 -0
@@ -946,6 +946,8 @@ char *pointer(const char *fmt, char *buf, char
*end, void *ptr,
if (spec.field_width == -1) {
spec.field_width = 2 * sizeof(void *);
spec.flags |= ZEROPAD;
+ if (spec.flags & SPECIAL)
+ spec.field_width += 2;
}
spec.base = 16;Quoted 5 lines · Grant Likely
Also, gcc complains about it:
/home/grant/hacking/linux/kernel/irq/irqdomain.c: In function ‘virq_debug_show’:/home/grant/hacking/linux/kernel/irq/irqdomain.c:670:4: warning: '#' flag used with ‘%p’gnu_printfformat [-Wformat]
Then it's probably not such a good idea after all.
Andreas.
Signature · 3 lines
Andreas Schwab, [email protected] GPG Key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5 "And now for something completely different."
Quoted 9 lines · Andreas Schwab
Quoted 5 lines · Grant Likely
Also, gcc complains about it:
/home/grant/hacking/linux/kernel/irq/irqdomain.c: In function ‘virq_debug_show’:/home/grant/hacking/linux/kernel/irq/irqdomain.c:670:4: warning: '#' flag used with ‘%p’gnu_printfformat [-Wformat]Then it's probably not such a good idea after all.
It would be a good idea if the warning can be suppressed.
g.
David Daney
Acked-byQuoted 22 lines · Grant Likely
Quoted 13 lines · David Daney
From: David Daney<[email protected]>
The
irq_domain_mappingfile has some interesting output whenchip_datacontains leading zeros:virq hwirq chip name chip data domain name
.
.
.103 0x00000 CIU2-W 0x 5e0000000000000 none 104 0x00000 CIU2-W 0x 5f0000000000000 none 105 0x00000 CIU2-M 0x (null) none 113 0x00000 CIU2-E 0x1080000000000000 noneQuoted 7 lines
.
.
.I think there should be no space in there between the "0x" and the rest. Also the '(null)' entry doesn't make much sense at all with a "0x".
Quoted 6 lines
Yeah, it doesn't make much sense with the '0x', but I don't want to supress the (null) output because it is really important to highlight when a domain isn't assigned to an active irq.
Fixing the zero pad is trivial to fix though. Just remove the precision from the %p format. Here's my counter-patch:
This is good too.
FWIW:
Quoted 27 lines
---
kernel/irq/irqdomain.c +3
-3@@ -643,8 +643,8 @@ static int virq_debug_show(struct seq_file *m, void *private)void *data;int i; -seq_printf (m,"%-5s %-7s %-15s %-18s %s\n" ,"virq" ,"hwirq" , -"chip name" ,"chip data" ,"domain name" ); +seq_printf (m,"%-5s %-7s %-15s %-*s %s\n" ,"irq" ,"hwirq" , +"chip name" ,2 *sizeof (void *) +2 ,"chip data" ,"domain name" );for (i =1 ; i< nr_irqs; i++) { desc =irq_to_desc (i);@@ -667,7 +667,7 @@ static int virq_debug_show(struct seq_file *m, void *private)seq_printf (m,"%-15s " , p); data =irq_desc_get_chip_data (desc); -seq_printf (m,"0x%16p " , data); +seq_printf (m, data ?"0x%p " :" %p " , data);if (desc->irq_data.domain&& desc->irq_data.domain->of_node) p = desc->irq_data.domain->of_node->full_name;
kernel/irq/irqdomain.c static int virq_debug_show(struct seq_file *m, void *private) · line 647
Quoted 12 lines · Grant Likely
kernel/irq/irqdomain.c +2
-2@@ -643,8 +643,8 @@ static int virq_debug_show(struct seq_file *m, void *private)void *data;int i; -seq_printf (m,"%-5s %-7s %-15s %-18s %s\n" ,"virq" ,"hwirq" , -"chip name" ,"chip data" ,"domain name" ); +seq_printf (m,"%-5s %-7s %-15s %-*s %s\n" ,"irq" ,"hwirq" , +"chip name" ,2 *sizeof (void *) +2 ,"chip data" ,"domain name" );
kernel/irq/irqdomain.c:647:9: warning: field width specifier ‘*’ expects argument of type ‘int’, but argument 6 has type ‘long unsigned int’ [-Wformat]
Andreas.
Signature · 3 lines
Andreas Schwab, [email protected] GPG Key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5 "And now for something completely different."
Quoted 10 lines · Andreas Schwab
Quoted 8 lines · Grant Likely
kernel/irq/irqdomain.c +0
-0@@ -643,8 +643,8 @@ static int virq_debug_show(struct seq_file *m, void *private)void *data;int i;
Quoted 7 lines
kernel/irq/irqdomain.c static int virq_debug_show(struct seq_file *m, void *private) · line 647
Quoted 4 lines
kernel/irq/irqdomain.c +2
-2-seq_printf (m,"%-5s %-7s %-15s %-18s %s\n" ,"virq" ,"hwirq" , -"chip name" ,"chip data" ,"domain name" ); +seq_printf (m,"%-5s %-7s %-15s %-*s %s\n" ,"irq" ,"hwirq" , +"chip name" ,2 *sizeof (void *) +2 ,"chip data" ,"domain name" );
kernel/irq/irqdomain.c:647:9: warning: field width specifier ‘*’ expects argument of type ‘int’, but argument 6 has type ‘long unsigned int’ [-Wformat]
My original patch assigned the size to an int variable and then passed that to the seq_printf(), thus avoiding this issue. I suspect something like:
s/2 * sizeof(void *) + 2/(int)(2 * sizeof(void *) + 2)/
Would do the trick.
David Daney
Quoted 25 lines · David Daney
Quoted 12 lines · Andreas Schwab
Quoted 9 lines · Grant Likely
kernel/irq/irqdomain.c +0
-0@@ -643,8 +643,8 @@ static int virq_debug_show(struct seq_file *m, void *private) void *data; int i;Quoted 11 lines
kernel/irq/irqdomain.c static int virq_debug_show(struct seq_file *m, void *private)
Quoted 5 lines
kernel/irq/irqdomain.c +2
-2- seq_printf(m, "%-5s %-7s %-15s %-18s %s\n", "virq", "hwirq", - "chip name", "chip data", "domain name"); + seq_printf(m, "%-5s %-7s %-15s %-*s %s\n", "irq", "hwirq", + "chip name", 2 * sizeof(void *) + 2, "chip data","domain name" );
kernel/irq/irqdomain.c:647:9: warning: field width specifier ‘*’ expects argument of type ‘int’, but argument 6 has type ‘long unsigned int’ [-Wformat]
Quoted 6 lines
My original patch assigned the size to an int variable and then passed that to the
seq_printf(), thus avoiding this issue. I suspect something like:s/2 *
sizeof(void *)+ 2/(int)(2 *sizeof(void *)+ 2)/Would do the trick.
Yeah, I'll push out a fixup patch.
g