irqbalance: procinterrupts: Fix IRQ name parsing on certain arm64 SoC

procinterrupts: Fix IRQ name parsing on certain arm64 SoC

Signed-off-by: qinyu <qinyu32@huawei.com>
This commit is contained in:
qinyu 2022-12-08 21:13:26 +08:00
parent 5ba127f2c7
commit 46b5a2ed8f
6 changed files with 294 additions and 1 deletions

View File

@ -0,0 +1,49 @@
From ee6b3bdd15fdbaf5d6060c3c2df4e7e69dafbd06 Mon Sep 17 00:00:00 2001
From: Michael Neuling <mikey@neuling.org>
Date: Wed, 28 Apr 2021 10:24:05 +1000
Subject: [PATCH] Fix compile issue with none AARCH64 builds
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Reference: https://github.com/Irqbalance/irqbalance/commit/ee6b3bdd15fdbaf5d6060c3c2df4e7e69dafbd06
Conflict: NA
This recent commit broke compiling on non AARCH64 architectures:
commit d17bcc953c513f93553f531e5444553f2bf6ca46
Author: liuchao173 <55137861+liuchao173@users.noreply.github.com>
Date: Tue Apr 27 15:36:30 2021 +0800
Fix irqbalance cannot obtain the full name of irq
This results in:
procinterrupts.c:186:11: error: irq_fullname undeclared (first use in this function); did you mean irq_name?
186 | snprintf(irq_fullname, PATH_MAX, "%s", last_token);
| ^~~~~~~~~~~~
| irq_name
procinterrupts.c:186:11: note: each undeclared identifier is reported only once for each function it appears in
This fixes it.
Signed-off-by: Michael Neuling <mikey@neuling.org>
---
procinterrupts.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/procinterrupts.c b/procinterrupts.c
index 8673f2d..e372671 100644
--- a/procinterrupts.c
+++ b/procinterrupts.c
@@ -152,9 +152,9 @@ void init_irq_class_and_type(char *savedline, struct irq_info *info, int irq)
char *last_token = NULL;
char *p = NULL;
int is_xen_dyn = 0;
+ char irq_fullname[PATH_MAX] = {0};
#ifdef AARCH64
char *tmp = NULL;
- char irq_fullname[PATH_MAX] = {0};
#endif
irq_name = strtok_r(savedline, " ", &savedptr);
--
2.33.0

View File

@ -0,0 +1,87 @@
From d17bcc953c513f93553f531e5444553f2bf6ca46 Mon Sep 17 00:00:00 2001
From: liuchao173 <55137861+liuchao173@users.noreply.github.com>
Date: Tue, 27 Apr 2021 15:36:30 +0800
Subject: [PATCH] Fix irqbalance cannot obtain the full name of irq
I find some irqs are not banned when I use --banmod. Because the irq desc name in AARCH64 contains space, for example:
43: 1 0 0 0 ITS-MSI 16384 Edge PCIe PME, aerdrv, pciehp
info->name is "pciehp", so check_for_module_ban returns 0 when I use "--bannmod=aerdrv"
Reference:https://github.com/Irqbalance/irqbalance/commit/d17bcc953c513f93553f531e5444553f2bf6ca46
Conflict:NA
---
procinterrupts.c | 30 ++++++++++++++++++++----------
1 file changed, 20 insertions(+), 10 deletions(-)
diff --git a/procinterrupts.c b/procinterrupts.c
index 854282f..8673f2d 100644
--- a/procinterrupts.c
+++ b/procinterrupts.c
@@ -148,13 +148,13 @@ static void guess_arm_irq_hints(char *name, struct irq_info *info)
void init_irq_class_and_type(char *savedline, struct irq_info *info, int irq)
{
char *irq_name = NULL;
- char *irq_mod = NULL;
char *savedptr = NULL;
char *last_token = NULL;
char *p = NULL;
- int is_xen_dyn = 0;
+ int is_xen_dyn = 0;
#ifdef AARCH64
char *tmp = NULL;
+ char irq_fullname[PATH_MAX] = {0};
#endif
irq_name = strtok_r(savedline, " ", &savedptr);
@@ -166,30 +166,40 @@ void init_irq_class_and_type(char *savedline, struct irq_info *info, int irq)
if (strstr(irq_name, "xen-dyn") != NULL)
is_xen_dyn = 1;
last_token = p;
+#ifdef AARCH64
+ /*
+ * /proc/interrupts format defined, after of interrupt type
+ * the reset string is mark the irq desc name.
+ */
+ if (strncmp(irq_name, "Level", strlen("Level")) == 0 ||
+ strncmp(irq_name, "Edge", strlen("Edge")) == 0)
+ break;
+#endif
}
#ifdef AARCH64
- irq_name = last_token;
- tmp = strchr(irq_name, '\n');
- if (tmp)
- *tmp = 0;
+ snprintf(irq_fullname, PATH_MAX, "%s %s", last_token, savedptr);
+ tmp = strchr(irq_fullname, '\n');
+ if (tmp)
+ *tmp = 0;
+#else
+ snprintf(irq_fullname, PATH_MAX, "%s", last_token);
#endif
- irq_mod = last_token;
info->irq = irq;
- if (strstr(irq_name, "-event") != NULL && is_xen_dyn == 1) {
+ if (strstr(irq_fullname, "-event") != NULL && is_xen_dyn == 1) {
info->type = IRQ_TYPE_VIRT_EVENT;
info->class = IRQ_VIRT_EVENT;
} else {
#ifdef AARCH64
- guess_arm_irq_hints(irq_name, info);
+ guess_arm_irq_hints(irq_fullname, info);
#else
info->type = IRQ_TYPE_LEGACY;
info->class = IRQ_OTHER;
#endif
}
info->numa_node = get_numa_node(0);
- info->name = strdup(irq_mod);
+ info->name = strdup(irq_fullname);
}
GList* collect_full_irq_list()
--
2.23.0

View File

@ -0,0 +1,31 @@
From 522883505d3b02e3294f045f49007b61c00e2c31 Mon Sep 17 00:00:00 2001
From: Chao Liu <liuchao173@huawei.com>
Date: Wed, 8 Jun 2022 10:04:02 +0800
Subject: [PATCH] check whether savedptr is NULL before invoking strlen
Reference: https://github.com/Irqbalance/irqbalance/commit/522883505d3b02e3294f045f49007b61c00e2c31
Conflict: NA
savedptr can be null in musl libc, so the strlen(NULL) will segfault
Signed-off-by: Chao Liu <liuchao173@huawei.com>
---
procinterrupts.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/procinterrupts.c b/procinterrupts.c
index 9015177..57c8801 100644
--- a/procinterrupts.c
+++ b/procinterrupts.c
@@ -178,7 +178,7 @@ void init_irq_class_and_type(char *savedline, struct irq_info *info, int irq)
}
#ifdef AARCH64
- if (strlen(savedptr) > 0) {
+ if (savedptr && strlen(savedptr) > 0) {
snprintf(irq_fullname, PATH_MAX, "%s %s", last_token, savedptr);
tmp = strchr(irq_fullname, '\n');
if (tmp)
--
2.33.0

View File

@ -0,0 +1,39 @@
From a9f0290a6754a475eb95818dd38dc401370da071 Mon Sep 17 00:00:00 2001
From: liuchao173 <55137861+liuchao173@users.noreply.github.com>
Date: Mon, 23 Aug 2021 19:40:41 +0800
Subject: [PATCH] fix opendir fails in check_platform_device
Reference: https://github.com/Irqbalance/irqbalance/commit/a9f0290a6754a475eb95818dd38dc401370da071
Conflict: NA
When irq name does not contain spaces, savedptr is an empty string and irq_fullname will have a extra space at the end like "LNRO0005:00 ".
So opendir in check_platform_device will fail, and irqbalance prints log:
"No directory /sys/devices/platform/LNRO0005:00 /: No such file or directory"
---
procinterrupts.c | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
diff --git a/procinterrupts.c b/procinterrupts.c
index e372671..9015177 100644
--- a/procinterrupts.c
+++ b/procinterrupts.c
@@ -178,10 +178,12 @@ void init_irq_class_and_type(char *savedline, struct irq_info *info, int irq)
}
#ifdef AARCH64
- snprintf(irq_fullname, PATH_MAX, "%s %s", last_token, savedptr);
- tmp = strchr(irq_fullname, '\n');
- if (tmp)
- *tmp = 0;
+ if (strlen(savedptr) > 0) {
+ snprintf(irq_fullname, PATH_MAX, "%s %s", last_token, savedptr);
+ tmp = strchr(irq_fullname, '\n');
+ if (tmp)
+ *tmp = 0;
+ }
#else
snprintf(irq_fullname, PATH_MAX, "%s", last_token);
#endif
--
2.33.0

View File

@ -0,0 +1,76 @@
From bbcd9a42c3cec0935b960b7f2046f1fdfab4f7ef Mon Sep 17 00:00:00 2001
From: Vignesh Raghavendra <vigneshr@ti.com>
Date: Wed, 7 Dec 2022 19:46:19 +0530
Subject: [PATCH] procinterrupts: Fix IRQ name parsing on certain arm64 SoC
Reference: https://github.com/Irqbalance/irqbalance/commit/bbcd9a42c3cec0935b960b7f2046f1fdfab4f7ef
Conflict: NA
On arm64 SoCs like TI's K3 SoC and few other SoCs, IRQ names don't get
parsed correct due to which they end up being classified into wrong
class. Fix this by considering last token to contain IRQ name always.
Eg.: /proc/interrupt
cat /proc/interrupts
CPU0 CPU1 CPU2 CPU3
11: 7155 8882 7235 7791 GICv3 30 Level arch_timer
14: 0 0 0 0 GICv3 23 Level arm-pmu
15: 0 0 0 0 GICv3 208 Level 4b00000.spi
16: 0 0 0 0 GICv3 209 Level 4b10000.spi
116: 0 0 0 0 MSI-INTA 1716234 Level 485c0100.dma-controller chan6
134: 166 0 0 0 MSI-INTA 1970707 Level 8000000.ethernet-tx0
224: 149 0 0 0 MSI-INTA 1971731 Level 8000000.ethernet
W/o patch irqbalance -d
IRQ (11) guessed as class 0
IRQ (14) guessed as class 0
IRQ (15) guessed as class 0
IRQ (16) guessed as class 0
IRQ 485c0100.dma-controller chan6(116) guessed as class 0
IRQ (134) guessed as class 0
IRQ (224) guessed as class 0
W/ this patch
IRQ arch_timer(11) guessed as class 0
IRQ arm-pmu(14) guessed as class 0
IRQ 4b00000.spi(15) guessed as class 0
IRQ 4b10000.spi(16) guessed as class 0
IRQ 485c0100.dma-controller chan6(116) guessed as class 0
IRQ 8000000.ethernet-tx0(134) guessed as class 5
IRQ 8000000.ethernet(224) guessed as class 5
IRQ 8000000.ethernet(257) guessed as class 5
IRQ -davinci_gpio wl18xx(362) guessed as class
Signed-off-by: Vignesh Raghavendra <vigneshr@ti.com>
---
procinterrupts.c | 12 +++++++-----
1 file changed, 7 insertions(+), 5 deletions(-)
diff --git a/procinterrupts.c b/procinterrupts.c
index e91b203..ec7a52b 100644
--- a/procinterrupts.c
+++ b/procinterrupts.c
@@ -178,12 +178,14 @@ void init_irq_class_and_type(char *savedline, struct irq_info *info, int irq)
}
#ifdef AARCH64
- if (savedptr && strlen(savedptr) > 0) {
+ if (savedptr && strlen(savedptr) > 0)
snprintf(irq_fullname, PATH_MAX, "%s %s", last_token, savedptr);
- tmp = strchr(irq_fullname, '\n');
- if (tmp)
- *tmp = 0;
- }
+ else
+ snprintf(irq_fullname, PATH_MAX, "%s", last_token);
+
+ tmp = strchr(irq_fullname, '\n');
+ if (tmp)
+ *tmp = 0;
#else
snprintf(irq_fullname, PATH_MAX, "%s", last_token);
#endif
--
2.33.0

View File

@ -1,7 +1,7 @@
Summary: A dynamic adaptive IRQ balancing daemon
Name: irqbalance
Version: 1.8.0
Release: 8
Release: 9
Epoch: 3
License: GPLv2
Source0: https://github.com/Irqbalance/irqbalance/archive/v%{version}.tar.gz#/irqbalance-%{version}.tar.gz
@ -24,6 +24,11 @@ Requires: numactl-libs
Patch6000: bugfix-fix-unsigned-integer-subtraction-sign-overflow.patch
Patch6001: bugfix-parse_proc_interrupts-fix-parsing-interrupt-counts.patch
Patch6002: bugfix-add-keep_going-check-to-prevent-irqbalance-from-failing-to-exit-after-SIGTERM.patch
Patch6003: backport-Fix-irqbalance-cannot-obtain-the-full-name-of-irq.patch
Patch6004: backport-Fix-compile-issue-with-none-AARCH64-builds.patch
Patch6005: backport-fix-opendir-fails-in-check_platform_device.patch
Patch6006: backport-check-whether-savedptr-is-NULL-before-invoking-strle.patch
Patch6007: backport-procinterrupts-Fix-IRQ-name-parsing-on-certain-arm64.patch
%description
Irqbalance is a daemon to help balance the cpu load generated by
@ -81,6 +86,12 @@ fi
/sbin/chkconfig --del %{name} >/dev/null 2>&1 || :
%changelog
* Thu Dec 8 2022 qinyu <qinyu32@huawei.com> - 3:1.8.0-9
- Type:bugfix
- ID:NA
- SUG:restart
- DESC: procinterrupts: Fix IRQ name parsing on certain arm64 SoC
* Tue Jul 12 2022 qinyu <qinyu32@huawei.com> - 3:1.8.0-8
- Type:bugfix
- ID:NA