From 929bd2a1772c91159b7a26fb559c8e4cde0d3dc3 Mon Sep 17 00:00:00 2001 From: David Wang <00107082@163.com> Date: Sat, 9 Nov 2024 00:11:23 +0800 Subject: [PATCH 1/4] sparc/irq: use seq_put_decimal_ull_width() for decimal values Performance improvement for reading /proc/interrupts on arch sparc Signed-off-by: David Wang <00107082@163.com> Reviewed-by: Andreas Larsson Tested-by: Andreas Larsson Link: https://lore.kernel.org/r/20241108161123.9637-1-00107082@163.com Signed-off-by: Andreas Larsson --- arch/sparc/kernel/irq_32.c | 12 ++++++------ arch/sparc/kernel/irq_64.c | 4 ++-- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/arch/sparc/kernel/irq_32.c b/arch/sparc/kernel/irq_32.c index 8605dd710f3c..5210991429d5 100644 --- a/arch/sparc/kernel/irq_32.c +++ b/arch/sparc/kernel/irq_32.c @@ -199,18 +199,18 @@ int arch_show_interrupts(struct seq_file *p, int prec) int j; #ifdef CONFIG_SMP - seq_printf(p, "RES: "); + seq_printf(p, "RES:"); for_each_online_cpu(j) - seq_printf(p, "%10u ", cpu_data(j).irq_resched_count); + seq_put_decimal_ull_width(p, " ", cpu_data(j).irq_resched_count, 10); seq_printf(p, " IPI rescheduling interrupts\n"); - seq_printf(p, "CAL: "); + seq_printf(p, "CAL:"); for_each_online_cpu(j) - seq_printf(p, "%10u ", cpu_data(j).irq_call_count); + seq_put_decimal_ull_width(p, " ", cpu_data(j).irq_call_count, 10); seq_printf(p, " IPI function call interrupts\n"); #endif - seq_printf(p, "NMI: "); + seq_printf(p, "NMI:"); for_each_online_cpu(j) - seq_printf(p, "%10u ", cpu_data(j).counter); + seq_put_decimal_ull_width(p, " ", cpu_data(j).counter, 10); seq_printf(p, " Non-maskable interrupts\n"); return 0; } diff --git a/arch/sparc/kernel/irq_64.c b/arch/sparc/kernel/irq_64.c index 01ee800efde3..9ab6e79b617b 100644 --- a/arch/sparc/kernel/irq_64.c +++ b/arch/sparc/kernel/irq_64.c @@ -304,9 +304,9 @@ int arch_show_interrupts(struct seq_file *p, int prec) { int j; - seq_printf(p, "NMI: "); + seq_printf(p, "NMI:"); for_each_online_cpu(j) - seq_printf(p, "%10u ", cpu_data(j).__nmi_count); + seq_put_decimal_ull_width(p, " ", cpu_data(j).__nmi_count, 10); seq_printf(p, " Non-maskable interrupts\n"); return 0; } From f4ab186830222a18e2c232b425f2945b408e2607 Mon Sep 17 00:00:00 2001 From: Zhang Kunbo Date: Wed, 18 Dec 2024 07:44:39 +0000 Subject: [PATCH 2/4] sparc: replace zero-length array with flexible-array member The current codebase makes use of the zero-length array language extension to the C90 standard, but the preferred mechanism to declare variable-length types such as these ones is a flexible array member[1], introduced in C99: struct foo { int stuff; struct boo array[]; }; By making use of the mechanism above, we will get a compiler warning in case the flexible array does not occur last, which is beneficial to cultivate a high-quality code.[2] This issue was found with the help of Coccinelle. [1] https://gcc.gnu.org/onlinedocs/gcc/Zero-Length.html [2] commit 76497732932f ("cxgb3/l2t: Fix undefined behaviour") Signed-off-by: Zhang Kunbo Reviewed-by: Andreas Larsson Link: https://lore.kernel.org/r/20241218074439.3271397-1-zhangkunbo@huawei.com Signed-off-by: Andreas Larsson --- arch/sparc/kernel/pci.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/sparc/kernel/pci.c b/arch/sparc/kernel/pci.c index 50a0927a84a6..ddac216a2aff 100644 --- a/arch/sparc/kernel/pci.c +++ b/arch/sparc/kernel/pci.c @@ -932,7 +932,7 @@ static void pci_bus_slot_names(struct device_node *node, struct pci_bus *bus) { const struct pci_slot_names { u32 slot_mask; - char names[0]; + char names[]; } *prop; const char *sp; int len, i; From 4b9f0bdc2071aa0c04f8bb1f624ee678221d938e Mon Sep 17 00:00:00 2001 From: Thorsten Blum Date: Wed, 15 Jan 2025 10:03:43 +0100 Subject: [PATCH 3/4] sparc/irq: Use str_enabled_disabled() helper function Remove hard-coded strings by using the str_enabled_disabled() helper function. Signed-off-by: Thorsten Blum Reviewed-by: Andreas Larsson Link: https://lore.kernel.org/r/20250115090344.918290-2-thorsten.blum@linux.dev Signed-off-by: Andreas Larsson --- arch/sparc/kernel/irq_64.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/arch/sparc/kernel/irq_64.c b/arch/sparc/kernel/irq_64.c index 9ab6e79b617b..944659f5ae48 100644 --- a/arch/sparc/kernel/irq_64.c +++ b/arch/sparc/kernel/irq_64.c @@ -22,6 +22,7 @@ #include #include #include +#include #include #include @@ -170,7 +171,7 @@ static void __init irq_init_hv(void) pr_info("SUN4V: Using IRQ API major %d, cookie only virqs %s\n", hv_irq_version, - sun4v_cookie_only_virqs() ? "enabled" : "disabled"); + str_enabled_disabled(sun4v_cookie_only_virqs())); } /* This function is for the timer interrupt.*/ From 2cec2c4dc90cbf5194c1acef08c1e74f0437af95 Mon Sep 17 00:00:00 2001 From: Thorsten Blum Date: Tue, 14 Jan 2025 21:25:00 +0100 Subject: [PATCH 4/4] sparc/irq: Remove unneeded if check in sun4v_cookie_only_virqs() Remove the unnecessary if check and return the result directly. Signed-off-by: Thorsten Blum Reviewed-by: Andreas Larsson Link: https://lore.kernel.org/r/20250114202502.912690-1-thorsten.blum@linux.dev Signed-off-by: Andreas Larsson --- arch/sparc/kernel/irq_64.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/arch/sparc/kernel/irq_64.c b/arch/sparc/kernel/irq_64.c index 944659f5ae48..ded463c82abd 100644 --- a/arch/sparc/kernel/irq_64.c +++ b/arch/sparc/kernel/irq_64.c @@ -146,9 +146,7 @@ static int hv_irq_version; */ static bool sun4v_cookie_only_virqs(void) { - if (hv_irq_version >= 3) - return true; - return false; + return hv_irq_version >= 3; } static void __init irq_init_hv(void)