Message ID | b03e331fc242b4c46e2adab124c7657bc3bb1340.1679084101.git.ehem+xen@m5p.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | Fixing error_interrupt()'s messages v2 | expand |
On 17.03.2023 20:45, Elliott Mitchell wrote: > Rather than adding ", " with each printf(), simply include them in the > string initially. Why is this better? You're now using more space in .rodata. (I haven't looked at patch 2 yet to see whether there's a possible reason there for the change here, but if there was it would need saying here.) Jan
On Mon, Mar 20, 2023 at 09:49:14AM +0100, Jan Beulich wrote: > On 17.03.2023 20:45, Elliott Mitchell wrote: > > Rather than adding ", " with each printf(), simply include them in the > > string initially. > > Why is this better? You're now using more space in .rodata. (I haven't > looked at patch 2 yet to see whether there's a possible reason there > for the change here, but if there was it would need saying here.) I would expect this to give trivially better performance. Instead of needing to needing copy some data from the format string, then strcat() from the arguments this turns it into a single strcat(). Other item is this sort of change is very often a precursor to replacing the use of a *printf()-type function with a str*cat()-type function. Though in this case I doubt there is a strlcatk() function so that is unlikely.
diff --git a/xen/arch/x86/apic.c b/xen/arch/x86/apic.c index f71474d47d..8cfb8cd71c 100644 --- a/xen/arch/x86/apic.c +++ b/xen/arch/x86/apic.c @@ -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"); }
Rather than adding ", " with each printf(), simply include them in the string initially. Signed-off-by: Elliott Mitchell <ehem+xen@m5p.com> --- xen/arch/x86/apic.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-)