Fixing ACPI error reporting display
v3 cover Fixing ACPI error reporting display
This series has been seen previously. The issue is pretty simple, if ACPI errors occur there is a high probability they will occur on multiple cores at once. Since there is no locking for printk() there is a need to emit the entire error with a single printk().
I believe this is roughly where things left off. The loop adjustment had been requested to be broken into a separate step. I had also goofed when adjusting the handling and the string order had gotten reversed.
I'm unsure how best to make the printk() more maintainable. Yet more "%s" and entries[#] will be needed if additional bits get defined. I'm inclined to keep the string broken apart to hint as to how it matches the entry list. I'm okay with everything being fully concatenated if that is felt best.
Elliott Mitchell (3):
x86/APIC: include full string with error_interrupt() error messages x86/APIC: modify error_interrupt() to output using single printk() x86/APIC: adjustments to error_interrupt() loop
xen/arch/x86/apic.c | 32 +++++++++++++++++--------------- 1 file changed, 17 insertions(+), 15 deletions(-)
Signature · 1 line
2.30.2
PATCH v3 1/3 x86/APIC: include full string with error_interrupt() error messages
Rather than adding ", " with each printf(), simply include them in the string initially. This allows converting to strlcat() or other methods which strictly concatenate, rather than formatting.
---
v2:
One more sentence in the commit message.
--- xen/arch/x86/apic.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-)
xen/arch/x86/apic.c +9 -9
@@ -1401,14 +1401,14 @@ static void cf_check spurious_interrupt(struct cpu_user_regs *regs) static void cf_check error_interrupt(struct cpu_user_regs *regs) {static const char *const esr_fields[] = { -"Send CS error" , -"Receive CS error" , -"Send accept error" , -"Receive accept error" , -"Redirectable IPI" , -"Send illegal vector" , -"Received illegal vector" , -"Illegal register address" , +", Send CS error" , +", Receive CS error" , +", Send accept error" , +", Receive accept error" , +", Redirectable IPI" , +", Send illegal vector" , +", Received illegal vector" , +", Illegal register address" , };unsigned int v, v1;int i;
@@ -1423,7 +1423,7 @@ static void cf_check error_interrupt(struct cpu_user_regs *regs) smp_processor_id(), v , v1);for ( i =7 ; i >=0 ; --i )if ( v1 & (1 << i) ) -printk (", %s" , esr_fields[i]); +printk ("%s" , esr_fields[i]);printk ("\n" ); }
Signature · 1 line
2.30.2
Re: [PATCH v3 1/3] x86/APIC: include full string with error_interrupt() error messages
Quoted 5 lines · Elliott Mitchell
Rather than adding ", " with each
printf(), simply include them in the string initially. This allows converting tostrlcat()or other methods which strictly concatenate, rather than formatting.Signed-off-by Elliott Mitchell <[email protected]>
Nevertheless I wonder ...
Quoted 26 lines
xen/arch/x86/apic.c +8
-8@@ -1401,14 +1401,14 @@ static void cf_check spurious_interrupt(struct cpu_user_regs *regs) static void cf_check error_interrupt(struct cpu_user_regs *regs) {static const char *const esr_fields[] = { -"Send CS error" , -"Receive CS error" , -"Send accept error" , -"Receive accept error" , -"Redirectable IPI" , -"Send illegal vector" , -"Received illegal vector" , -"Illegal register address" , +", Send CS error" , +", Receive CS error" , +", Send accept error" , +", Receive accept error" , +", Redirectable IPI" , +", Send illegal vector" , +", Received illegal vector" , +", Illegal register address" , };unsigned int v, v1;int i;
xen/arch/x86/apic.c static void cf_check error_interrupt(struct cpu_user_regs *regs) · line 1426
Quoted 5 lines
xen/arch/x86/apic.c +1
-1@@ -1423,7 +1423,7 @@ static void cf_check error_interrupt(struct cpu_user_regs *regs) smp_processor_id(), v , v1);for ( i =7 ; i >=0 ; --i )if ( v1 & (1 << i) ) -printk (", %s" , esr_fields[i]); +printk ("%s" , esr_fields[i]);
... whether the extra level of indirection (by using %s) is then still
necessary: There are no % characters in any of the individual strings. Then again iirc this goes away anyway in the next patch ...
Jan
Re: [PATCH v3 1/3] x86/APIC: include full string with error_interrupt() error messages
Quoted 12 lines · Jan Beulich
Quoted 5 lines · Elliott Mitchell
Rather than adding ", " with each
printf(), simply include them in the string initially. This allows converting tostrlcat()or other methods which strictly concatenate, rather than formatting.Signed-off-by Elliott Mitchell <[email protected]>Acked-by Jan Beulich <[email protected]>Nevertheless I wonder ...
Quoted 10 lines
xen/arch/x86/apic.c static void cf_check error_interrupt(struct cpu_user_regs *regs) · line 1426
Quoted 6 lines
xen/arch/x86/apic.c +1
-1@@ -1423,7 +1423,7 @@ static void cf_check error_interrupt(struct cpu_user_regs *regs) smp_processor_id(), v , v1);for ( i =7 ; i >=0 ; --i )if ( v1 & (1 << i) ) -printk (", %s" , esr_fields[i]); +printk ("%s" , esr_fields[i]);... whether the extra level of indirection (by using %s) is then still
necessary: There are no % characters in any of the individual strings. Then again iirc this goes away anyway in the next patch ...
I suspect most development guidelines generally discourage this. Too easy for someone to later add a '%' to the string, or make it a dynamic string coming from some random location.
More notable is that last point. Emphasis here is the ", " being merged into the strings and the line is being completely replaced in the next patch. v0 was to strcpy() into a buffer, but this is simpler.
I also suspect "%s" may be faster if the string is sufficiently long, as this amounts to a strcpy() info printk's buffer. Whereas avoiding the indirection causes the string to be scanned for '%' which will be slower than strcpy().
Signature · 4 lines
(\___(\___(\______ --=> 8-) EHM <=-- ______/)___/)___/) \BS ( | [email protected] PGP 87145445 | ) / \_CS\ | _____ -O #include <stddisclaimer.h> O- _____ | / _/ 8A19\___\_|_/58D2 7E3D DDF4 7BA6 <-PGP-> 41D1 B375 37D0 8714\_|_/___/5445
PATCH v3 2/3 x86/APIC: modify error_interrupt() to output using single printk()
In reply to Elliott MitchellThis takes care of the issue of APIC errors tending to occur on multiple cores at once. In turn this tends to causes the error messages to be merged together, making understanding them difficult.
---
v2:
Splitting the loop adjustment off. Fixing the entry display
order.
--- xen/arch/x86/apic.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-)
xen/arch/x86/apic.c +7 -5
@@ -1410,6 +1410,7 @@ static void cf_check error_interrupt(struct cpu_user_regs *regs)", Received illegal vector" , ", Illegal register address", }; +const char *entries[ARRAY_SIZE (esr_fields)];unsigned int v, v1;int i;
@@ -1419,12 +1420,13 @@ static void cf_check error_interrupt(struct cpu_user_regs *regs) v1 =apic_read (APIC_ESR );ack_APIC_irq (); -printk (XENLOG_DEBUG "APIC error on CPU%u: %02x(%02x)" , -smp_processor_id (), v , v1);for ( i =7 ; i >=0 ; --i ) -if ( v1 & (1 << i) ) -printk ("%s" , esr_fields[i]); -printk ("\n" ); + entries[i] = v1 & (1 << i) ? esr_fields[i] :"" ; +printk (XENLOG_DEBUG "APIC error on CPU%u: %02x(%02x)" +"%s%s%s%s%s%s%s%s" "\n" , +smp_processor_id (), v , v1, + entries[7 ], entries[6 ], + entries[5 ], entries[4 ], entries[3 ], entries[2 ], entries[1 ], entries[0 ]); }/*
Signature · 1 line
2.30.2
Re: [PATCH v3 2/3] x86/APIC: modify error_interrupt() to output using single printk()
Quoted 16 lines · Elliott Mitchell
xen/arch/x86/apic.c +1
-2@@ -1410,6 +1410,7 @@ static void cf_check error_interrupt(struct cpu_user_regs *regs)", Received illegal vector" , ", Illegal register address", }; +const char *entries[ARRAY_SIZE (esr_fields)];unsigned int v, v1;int i;@@ -1419,12 +1420,13 @@ static void cf_check error_interrupt(struct cpu_user_regs *regs) v1 =apic_read (APIC_ESR );ack_APIC_irq (); -printk (XENLOG_DEBUG "APIC error on CPU%u: %02x(%02x)" , -smp_processor_id (), v , v1);
xen/arch/x86/apic.c static void cf_check error_interrupt(struct cpu_user_regs *regs) · line 1429
Quoted 10 lines
xen/arch/x86/apic.c +6
-3for ( i =7 ; i >=0 ; --i ) -if ( v1 & (1 << i) ) -printk ("%s" , esr_fields[i]); -printk ("\n" ); + entries[i] = v1 & (1 << i) ? esr_fields[i] :"" ; +printk (XENLOG_DEBUG "APIC error on CPU%u: %02x(%02x)" +"%s%s%s%s%s%s%s%s" "\n" , +smp_processor_id (), v , v1, + entries[7 ], entries[6 ], + entries[5 ], entries[4 ], entries[3 ], entries[2 ], entries[1 ], entries[0 ]);
While pre-existing in both cases, two nits: There's a stray blank before one of the commas, and indentation is wrong too.
Furthermore there's no reason to split the format string, especially not ahead of the \n. Plus line wrapping for the 8 entries[] references could also be done more evenly.
Since these are all cosmetic, I guess I'll do adjustments while committing:
Jan
Re: [PATCH v3 2/3] x86/APIC: modify error_interrupt() to output using single printk()
Quoted 7 lines · Jan Beulich
Quoted 6 lines · Elliott Mitchell
xen/arch/x86/apic.c +0
-0@@ -1419,12 +1420,13 @@ static void cf_check error_interrupt(struct cpu_user_regs *regs) v1 =apic_read (APIC_ESR );ack_APIC_irq ();
Quoted 15 lines
xen/arch/x86/apic.c static void cf_check error_interrupt(struct cpu_user_regs *regs) · line 1429
Quoted 12 lines
xen/arch/x86/apic.c +6
-5-printk (XENLOG_DEBUG "APIC error on CPU%u: %02x(%02x)" , -smp_processor_id (), v , v1);for ( i =7 ; i >=0 ; --i ) -if ( v1 & (1 << i) ) -printk ("%s" , esr_fields[i]); -printk ("\n" ); + entries[i] = v1 & (1 << i) ? esr_fields[i] :"" ; +printk (XENLOG_DEBUG "APIC error on CPU%u: %02x(%02x)" +"%s%s%s%s%s%s%s%s" "\n" , +smp_processor_id (), v , v1, + entries[7 ], entries[6 ], + entries[5 ], entries[4 ], entries[3 ], entries[2 ], entries[1 ], entries[0 ]);While pre-existing in both cases, two nits: There's a stray blank before one of the commas, and indentation is wrong too.
I don't see anything which could be called an indentation error. The very first added line is attached to the for (), therefore it correctly has one more indent.
I guess this is an advantage of rewriting the loop as part of this patch. The correct indentation is clearer.
Quoted 6 lines
Furthermore there's no reason to split the format string, especially not ahead of the \n. Plus line wrapping for the 8 entries[] references could also be done more evenly.
Since these are all cosmetic, I guess I'll do adjustments while committing:
Acked-by Jan Beulich <[email protected]>
Yeah, that seems the best approach here. I'm unsure how likely it is for additional bits in the ESR register to be allocated. Ideal is to format this in such a way that adding bits causes a smaller delta. I was thinking high-order bits were likely to be reportted at start, hence the last line would be best filled first.
Though one does not know the future and trying to anticipate it may well yield worse results. This really does seem a place where it should be adjusted to taste during final commit. Otherwise there are too many minor nits and things get bogged down in trivial issues.
Signature · 4 lines
(\___(\___(\______ --=> 8-) EHM <=-- ______/)___/)___/) \BS ( | [email protected] PGP 87145445 | ) / \_CS\ | _____ -O #include <stddisclaimer.h> O- _____ | / _/ 8A19\___\_|_/58D2 7E3D DDF4 7BA6 <-PGP-> 41D1 B375 37D0 8714\_|_/___/5445
Re: [PATCH v3 2/3] x86/APIC: modify error_interrupt() to output using single printk()
Quoted 24 lines · Elliott Mitchell
Quoted 7 lines · Jan Beulich
Quoted 6 lines · Elliott Mitchell
xen/arch/x86/apic.c +0
-0@@ -1419,12 +1420,13 @@ static void cf_check error_interrupt(struct cpu_user_regs *regs) v1 =apic_read (APIC_ESR );ack_APIC_irq ();Quoted 15 lines
xen/arch/x86/apic.c static void cf_check error_interrupt(struct cpu_user_regs *regs) · line 1429
Quoted 12 lines
xen/arch/x86/apic.c +6
-5-printk (XENLOG_DEBUG "APIC error on CPU%u: %02x(%02x)" , -smp_processor_id (), v , v1);for ( i =7 ; i >=0 ; --i ) -if ( v1 & (1 << i) ) -printk ("%s" , esr_fields[i]); -printk ("\n" ); + entries[i] = v1 & (1 << i) ? esr_fields[i] :"" ; +printk (XENLOG_DEBUG "APIC error on CPU%u: %02x(%02x)" +"%s%s%s%s%s%s%s%s" "\n" , +smp_processor_id (), v , v1, + entries[7 ], entries[6 ], + entries[5 ], entries[4 ], entries[3 ], entries[2 ], entries[1 ], entries[0 ]);While pre-existing in both cases, two nits: There's a stray blank before one of the commas, and indentation is wrong too.
Quoted 3 lines
I don't see anything which could be called an indentation error. The very first added line is attached to the
for (), therefore it correctly has one more indent.
It's the printk() invocation, where all continued lines lacked another 3 blanks.
Jan
PATCH v3 3/3 x86/APIC: adjustments to error_interrupt() loop
In reply to Elliott MitchellARRAY_SIZE() makes future maintainance easier and thus less likely for bugs to occur.
---
v2:
Breaking this miniscule tidbit off.
--- xen/arch/x86/apic.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
xen/arch/x86/apic.c +2 -2
@@ -1412,7 +1412,7 @@ static void cf_check error_interrupt(struct cpu_user_regs *regs) };const char *entries[ARRAY_SIZE (esr_fields)];unsigned int v, v1; -int i; +unsigned int i;/* First tickle the hardware, only then report what went on. -- REW */ v =apic_read (APIC_ESR );
@@ -1420,7 +1420,7 @@ static void cf_check error_interrupt(struct cpu_user_regs *regs) v1 =apic_read (APIC_ESR );ack_APIC_irq (); -for ( i =7 ; i >=0 ; --i ) +for ( i =0 ; i <ARRAY_SIZE (entries); ++i ) entries[i] = v1 & (1 << i) ? esr_fields[i] :"" ; printk(XENLOG_DEBUG "APIC error on CPU%u: %02x(%02x)" "%s%s%s%s%s%s%s%s" "\n",
Signature · 1 line
2.30.2
Re: [PATCH v3 3/3] x86/APIC: adjustments to error_interrupt() loop
Quoted 4 lines · Elliott Mitchell
ARRAY_SIZE()makes future maintainance easier and thus less likely for bugs to occur.Signed-off-by Elliott Mitchell <[email protected]>
Quoted 3 lines · Elliott Mitchell
This series has been seen previously. The issue is pretty simple, if ACPI errors occur there is a high probability they will occur on multiple cores at once.
Nit: Both here and in the title s/ACPI/APIC/, to not misguide people about the area the series touches (just in case a v4 might be needed).
Jan
Quoted 22 lines
Since there is no locking for
printk()there is a need
to emit the entire error with a singleprintk().I believe this is roughly where things left off. The loop adjustment had been requested to be broken into a separate step. I had also goofed when adjusting the handling and the string order had gotten reversed.
I'm unsure how best to make the
printk()more maintainable. Yet more "%s" and entries[#] will be needed if additional bits get defined. I'm inclined to keep the string broken apart to hint as to how it matches the entry list. I'm okay with everything being fully concatenated if that is felt best.Elliott Mitchell (3):
x86/APIC: include full string witherror_interrupt()error messages x86/APIC: modifyerror_interrupt()to output using singleprintk()x86/APIC: adjustments toerror_interrupt()loopxen/arch/x86/apic.c | 32 +++++++++++++++++--------------- 1 file changed, 17 insertions(+), 15 deletions(-)
Quoted 7 lines · Jan Beulich
Quoted 3 lines · Elliott Mitchell
This series has been seen previously. The issue is pretty simple, if ACPI errors occur there is a high probability they will occur on multiple cores at once.
Nit: Both here and in the title s/ACPI/APIC/, to not misguide people about the area the series touches (just in case a v4 might be needed).
Uh, yeah. Wonder how that got missed. Seems like the time for a Simpson's "doh!" Also in patch #2 there is "APIC errors".
It would be correct if English words had the transitivity property.
Signature · 4 lines
(\___(\___(\______ --=> 8-) EHM <=-- ______/)___/)___/) \BS ( | [email protected] PGP 87145445 | ) / \_CS\ | _____ -O #include <stddisclaimer.h> O- _____ | / _/ 8A19\___\_|_/58D2 7E3D DDF4 7BA6 <-PGP-> 41D1 B375 37D0 8714\_|_/___/5445
Quoted 6 lines · Elliott Mitchell
Quoted 5 lines · Jan Beulich
Quoted 3 lines · Elliott Mitchell
This series has been seen previously. The issue is pretty simple, if ACPI errors occur there is a high probability they will occur on multiple cores at once.
Quoted 7 lines
Quoted 2 lines
Nit: Both here and in the title s/ACPI/APIC/, to not misguide people about the area the series touches (just in case a v4 might be needed).
Uh, yeah. Wonder how that got missed. Seems like the time for a Simpson's "doh!" Also in patch #2 there is "APIC errors".
It would be correct if English words had the transitivity property.
Then re-check and realize I corrected things the wrong way. Acronyms become problematic when they are anagrams of each other.
Anyone up for Hitchhiker's Guide to the Galaxy quotes?
Signature · 4 lines
(\___(\___(\______ --=> 8-) EHM <=-- ______/)___/)___/) \BS ( | [email protected] PGP 87145445 | ) / \_CS\ | _____ -O #include <stddisclaimer.h> O- _____ | / _/ 8A19\___\_|_/58D2 7E3D DDF4 7BA6 <-PGP-> 41D1 B375 37D0 8714\_|_/___/5445