!81 sync upstream bugfix commits

From: @chinyu0704 
Reviewed-by: @SuperSix173 
Signed-off-by: @SuperSix173
This commit is contained in:
openeuler-ci-bot 2023-01-05 12:37:11 +00:00 committed by Gitee
commit 7465df754a
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
18 changed files with 1358 additions and 1 deletions

View File

@ -0,0 +1,129 @@
From df7b5434bc19b3ea74af83393adbe901c2d11d8f Mon Sep 17 00:00:00 2001
From: liuchao173 <55137861+liuchao173@users.noreply.github.com>
Date: Wed, 1 Dec 2021 15:35:20 +0800
Subject: [PATCH] Add '\0' to the end of strings to avoid heap buffer overflow
Stroul, strlen, strtok will read or write out of bounds when recv_msg
doesn't include '\0'. Especially strtok will write '\0' when it find a
space, which may overwrite the head of the chunk in glibc, and
irqbalance will core dump.
core's stack:
(gdb) bt
#0 __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:51
#1 0x00007f7a4def7b41 in __GI_abort () at abort.c:79
#2 0x00007f7a4df3835b in __libc_message (action=action@entry=do_abort, fmt=fmt@entry=0x7f7a4e03f885 "%s\n") at ../sysdeps/posix/libc_fatal.c:181
#3 0x00007f7a4df3eaca in malloc_printerr (str=str@entry=0x7f7a4e040b08 "corrupted size vs. prev_size while consolidating") at malloc.c:5390
#4 0x00007f7a4df3f910 in _int_free (av=0x7f7a4e06eaa0 <main_arena>, p=0x55f837b201f0, have_lock=<optimized out>) at malloc.c:4332
#5 0x00007f7a4e2e4796 in magazine_cache_trim (stamp=<optimized out>, ix=<optimized out>, allocator=0x7f7a4e399dc0 <allocator>) at ../glib/gslice.c:678
#6 magazine_cache_push_magazine (ix=<optimized out>, magazine_chunks=<optimized out>, count=51) at ../glib/gslice.c:709
#7 0x00007f7a4e2e483c in thread_memory_magazine2_unload (tmem=tmem@entry=0x55f837af3660, ix=ix@entry=1) at ../glib/gslice.c:808
#8 0x00007f7a4e2e5dd9 in g_slice_free_chain_with_offset (mem_size=24, mem_chain=<optimized out>, next_offset=8) at ../glib/gslice.c:1198
#9 0x00007f7a4e2c2502 in g_list_free (list=<optimized out>) at ../glib/glist.c:182
#10 0x000055f836036210 in free_cpu_topo (data=0x55f837b77100) at cputree.c:544
#11 0x00007f7a4e2c2f6d in g_list_foreach (list=<optimized out>, list@entry=0x55f837b970c0, func=0x55f836036200 <free_cpu_topo>, user_data=user_data@entry=0x0) at ../glib/glist.c:1069
#12 0x00007f7a4e2c2f9b in g_list_free_full (list=0x55f837b970c0, free_func=<optimized out>) at ../glib/glist.c:223
#13 0x000055f83603780b in clear_cpu_tree () at cputree.c:559
#14 0x000055f83603873d in free_object_tree () at irqbalance.c:248
#15 0x000055f83603bb04 in scan (data=data@entry=0x0) at irqbalance.c:301
#16 0x00007f7a4e2c768d in g_timeout_dispatch (source=0x55f837afd000, callback=0x55f83603baa0 <poll_hint_affinity_and_scan>, user_data=0x0) at ../glib/gmain.c:4705
#17 0x00007f7a4e2c6ba4 in g_main_dispatch (context=0x55f837b39af0) at ../glib/gmain.c:3216
#18 g_main_context_dispatch (context=context@entry=0x55f837b39af0) at ../glib/gmain.c:3881
#19 0x00007f7a4e2c6f40 in g_main_context_iterate (context=0x55f837b39af0, block=block@entry=1, dispatch=dispatch@entry=1, self=self@entry=0x55f837b38000) at ../glib/gmain.c:3954
#20 0x00007f7a4e2c721d in g_main_loop_run (loop=0x55f837afc3e0) at ../glib/gmain.c:4148
#21 0x000055f836032ec8 in main (argc=3, argv=<optimized out>) at irqbalance.c:706
(gdb) x/128gx 0x55f837b20180
0x55f837b20180: 0x0000000000000000 0x0000000100000000
0x55f837b20190: 0x0000000000000000 0x000055f837b275d0
0x55f837b201a0: 0x0000000000000000 0x0000000000000051
0x55f837b201b0: 0x312c30312c392c34 0x2c37312c35312c33
0x55f837b201c0: 0x37322c34322c3232 0x332c32332c30332c
0x55f837b201d0: 0x2c34342c30342c38 0x39342c38342c3634
0x55f837b201e0: 0x352c32342c31322c 0x332c33322c312c32
0x55f837b201f0: 0x2c30322c32352c31 0x0000000000000001
0x55f837b20200: 0x000055f837bf23f0 0x000055f837b7c870
0x55f837b20210: 0x0000000000000000 0x0000000000000000
(gdb) p (char*)0x55f837b201b0
$1 = 0x55f837b201b0 "4,9,10,13,15,17,22,24,27,30,32,38,40,44,46,48,49,21,42,52,1,23,31,52,20,\001"
asan log:
==3703578==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x60600000011e at pc 0x7f86ade5687e bp 0x7ffce9f7ff60 sp 0x7ffce9f7f708
READ of size 63 at 0x60600000011e thread T0
#0 0x7f86ade5687d (/usr/lib64/libasan.so.4+0x5387d) ??:?
#1 0x56438e80affe (/usr/sbin/irqbalance+0x11ffe) /usr/src/debug/irqbalance-1.8.0.x86_64/cputree.c:121
#2 0x56438e80e97a (/usr/sbin/irqbalance+0x1597a) /usr/src/debug/irqbalance-1.8.0.x86_64/irqbalance.c:241
#3 0x56438e8167f7 (/usr/sbin/irqbalance+0x1d7f7) /usr/src/debug/irqbalance-1.8.0.x86_64/irqbalance.c:308
#4 0x7f86add1568c (/usr/lib64/libglib-2.0.so.0+0x5168c) ??:?
#5 0x7f86add14ba3 in g_main_context_dispatch (/usr/lib64/libglib-2.0.so.0+0x50ba3) ??:?
#6 0x7f86add14f3f (/usr/lib64/libglib-2.0.so.0+0x50f3f) ??:?
#7 0x7f86add1521c in g_main_loop_run (/usr/lib64/libglib-2.0.so.0+0x5121c) ??:?
#8 0x56438e8025e2 (/usr/sbin/irqbalance+0x95e2) /usr/src/debug/irqbalance-1.8.0.x86_64/irqbalance.c:706
#9 0x7f86ad930c86 in __libc_start_main (/usr/lib64/libc.so.6+0x25c86) /usr/src/debug/glibc-2.28/csu/../csu/libc-start.c:308
#10 0x56438e802919 (/usr/sbin/irqbalance+0x9919) ??:?
0x60600000011e is located 0 bytes to the right of 62-byte region [0x6060000000e0,0x60600000011e)
allocated by thread T0 here:
#0 0x7f86adee3e70 in __interceptor_malloc (/usr/lib64/libasan.so.4+0xe0e70) ??:?
#1 0x56438e80dfa8 (/usr/sbin/irqbalance+0x14fa8) /usr/src/debug/irqbalance-1.8.0.x86_64/irqbalance.c:505
#2 0x56438e81ab7f (/usr/sbin/irqbalance+0x21b7f) ??:0
Reference: https://github.com/Irqbalance/irqbalance/pull/195/commits/df7b5434bc19b3ea74af83393adbe901c2d11d8f
Conflict: NA
Signed-off-by: SuperSix173 <liuchao173@huawei.com>
---
irqbalance.c | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/irqbalance.c b/irqbalance.c
index 07a245f..e8d9ba9 100644
--- a/irqbalance.c
+++ b/irqbalance.c
@@ -463,12 +463,13 @@ gboolean sock_handle(gint fd, GIOCondition condition, gpointer user_data __attri
if (!(strncmp(buff + strlen("settings "), "sleep ",
strlen("sleep ")))) {
char *sleep_string = malloc(
- sizeof(char) * (recv_size - strlen("settings sleep ")));
+ sizeof(char) * (recv_size - strlen("settings sleep ") + 1));
if (!sleep_string)
goto out_close;
strncpy(sleep_string, buff + strlen("settings sleep "),
recv_size - strlen("settings sleep "));
+ sleep_string[recv_size - strlen("settings sleep ")] = '\0';
int new_iterval = strtoul(sleep_string, NULL, 10);
if (new_iterval >= 1) {
sleep_interval = new_iterval;
@@ -478,12 +479,13 @@ gboolean sock_handle(gint fd, GIOCondition condition, gpointer user_data __attri
strlen("ban irqs ")))) {
char *end;
char *irq_string = malloc(
- sizeof(char) * (recv_size - strlen("settings ban irqs ")));
+ sizeof(char) * (recv_size - strlen("settings ban irqs ") + 1));
if (!irq_string)
goto out_close;
strncpy(irq_string, buff + strlen("settings ban irqs "),
recv_size - strlen("settings ban irqs "));
+ irq_string[recv_size - strlen("settings ban irqs ")] = '\0';
g_list_free_full(cl_banned_irqs, free);
cl_banned_irqs = NULL;
need_rescan = 1;
@@ -503,12 +505,13 @@ gboolean sock_handle(gint fd, GIOCondition condition, gpointer user_data __attri
cpu_ban_string = NULL;
cpu_ban_string = malloc(
- sizeof(char) * (recv_size - strlen("settings cpus ")));
+ sizeof(char) * (recv_size - strlen("settings cpus ") + 1));
if (!cpu_ban_string)
goto out_close;
strncpy(cpu_ban_string, buff + strlen("settings cpus "),
recv_size - strlen("settings cpus "));
+ cpu_ban_string[recv_size - strlen("settings cpus ")] = '\0';
banned_cpumask_from_ui = strtok(cpu_ban_string, " ");
if (!strncmp(banned_cpumask_from_ui, "NULL", strlen("NULL"))) {
banned_cpumask_from_ui = NULL;
--
2.23.0

View File

@ -0,0 +1,115 @@
From ef9bf64affbca0b030f9128d93f302296d166dac Mon Sep 17 00:00:00 2001
From: hejingxian 00273181 <hejingxian@huawei.com>
Date: Mon, 4 Jan 2021 12:34:02 +0800
Subject: [PATCH] Add hot pull method for irqbalance
Conflict:NA
Reference:https://github.com/Irqbalance/irqbalance/commit/ef9bf64affbca0b030f9128d93f302296d166dac
---
classify.c | 37 +++++++++++++++++++++++++++++++++++++
irqbalance.h | 1 +
procinterrupts.c | 4 +++-
types.h | 1 +
4 files changed, 42 insertions(+), 1 deletion(-)
diff --git a/classify.c b/classify.c
index 4b6ffa8..beb2919 100644
--- a/classify.c
+++ b/classify.c
@@ -852,3 +852,39 @@ void sort_irq_list(GList **list)
{
*list = g_list_sort(*list, sort_irqs);
}
+
+static void remove_no_existing_irq(struct irq_info *info, void *data __attribute__((unused)))
+{
+ GList *entry = NULL;
+
+ if (info->existing) {
+ /* clear existing flag for next detection */
+ info->existing = 0;
+ return;
+ }
+
+ entry = g_list_find_custom(interrupts_db, info, compare_ints);
+ if (entry)
+ interrupts_db = g_list_delete_link(interrupts_db, entry);
+
+ entry = g_list_find_custom(rebalance_irq_list, info, compare_ints);
+ if (entry)
+ rebalance_irq_list = g_list_delete_link(rebalance_irq_list, entry);
+
+ if(info->assigned_obj) {
+ entry = g_list_find_custom(info->assigned_obj->interrupts, info, compare_ints);
+ if (entry) {
+ info->assigned_obj->interrupts = g_list_delete_link(info->assigned_obj->interrupts, entry);
+ }
+ }
+ log(TO_CONSOLE, LOG_INFO, "IRQ %d is removed from interrupts_db.\n", info->irq);
+ free_irq(info, NULL);
+}
+
+void clear_no_existing_irqs(void)
+{
+ for_each_irq(NULL, remove_no_existing_irq, NULL);
+ if (banned_irqs) {
+ for_each_irq(banned_irqs, remove_no_existing_irq, NULL);
+ }
+}
+
diff --git a/irqbalance.h b/irqbalance.h
index d8e80a9..e7f6b94 100644
--- a/irqbalance.h
+++ b/irqbalance.h
@@ -42,6 +42,7 @@ extern void set_interrupt_count(int number, uint64_t count);
extern void set_msi_interrupt_numa(int number);
extern void init_irq_class_and_type(char *savedline, struct irq_info *info, int irq);
extern int proc_irq_hotplug(char *line, int irq, struct irq_info **pinfo);
+extern void clear_no_existing_irqs(void);
extern GList *rebalance_irq_list;
extern void force_rebalance_irq(struct irq_info *info, void *data __attribute__((unused)));
diff --git a/procinterrupts.c b/procinterrupts.c
index 0671be0..854282f 100644
--- a/procinterrupts.c
+++ b/procinterrupts.c
@@ -248,7 +248,6 @@ GList* collect_full_irq_list()
return tmp_list;
}
-
void parse_proc_interrupts(void)
{
FILE *file;
@@ -310,6 +309,7 @@ void parse_proc_interrupts(void)
break;
}
}
+ info->existing = 1;
free(savedline);
count = 0;
@@ -354,6 +354,8 @@ void parse_proc_interrupts(void)
*/
msi_found_in_sysfs = 1;
}
+ if (!need_rescan)
+ clear_no_existing_irqs();
fclose(file);
free(line);
}
diff --git a/types.h b/types.h
index a01d649..9693cf4 100644
--- a/types.h
+++ b/types.h
@@ -70,6 +70,7 @@ struct irq_info {
uint64_t last_irq_count;
uint64_t load;
int moved;
+ int existing;
struct topo_obj *assigned_obj;
char *name;
};
--
2.23.0

View File

@ -0,0 +1,43 @@
From 6ae114f8719a6a49cef73a32d820a77e900ddf08 Mon Sep 17 00:00:00 2001
From: hejingxian 00273181 <hejingxian@huawei.com>
Date: Thu, 17 Dec 2020 17:47:45 +0800
Subject: [PATCH] Add log for hotplug appropriately
Conflict:NA
Reference:https://github.com/Irqbalance/irqbalance/commit/6ae114f8719a6a49cef73a32d820a77e900ddf08
---
classify.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/classify.c b/classify.c
index 0d556e9..4b6ffa8 100644
--- a/classify.c
+++ b/classify.c
@@ -644,12 +644,13 @@ static void build_one_dev_entry(const char *dirname, GList *tmp_irqs, int build_
irqnum = strtol(entry->d_name, NULL, 10);
/* If build_irq is valid, only add irq when it's number equals to build_irq */
if (irqnum && ((build_irq < 0) || (irqnum == build_irq))) {
- printf("add irq:%d %d for %s\n", irqnum, build_irq, path);
hint.irq = irqnum;
hint.type = IRQ_TYPE_MSIX;
add_new_irq(devpath, &hint, tmp_irqs);
- if (build_irq >= 0)
+ if (build_irq >= 0) {
+ log(TO_CONSOLE, LOG_INFO, "Hotplug dev irq: %d finished.\n", irqnum);
break;
+ }
}
} while (entry != NULL);
closedir(msidir);
@@ -674,6 +675,8 @@ static void build_one_dev_entry(const char *dirname, GList *tmp_irqs, int build_
hint.irq = irqnum;
hint.type = IRQ_TYPE_LEGACY;
add_new_irq(devpath, &hint, tmp_irqs);
+ if (build_irq >= 0)
+ log(TO_CONSOLE, LOG_INFO, "Hotplug dev irq: %d finished.\n", irqnum);
}
}
--
2.23.0

View File

@ -0,0 +1,39 @@
From 47f0f26d415b8a1fb2e1d04a39f27b1e4843e7b6 Mon Sep 17 00:00:00 2001
From: hejingxian 00273181 <hejingxian@huawei.com>
Date: Fri, 9 Apr 2021 13:32:08 +0800
Subject: [PATCH] Add return value check of opendir in do_one_cpu
Reference:https://github.com/Irqbalance/irqbalance/commit/47f0f26d415b8a1fb2e1d04a39f27b1e4843e7b6
Conflict:NA
---
cputree.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/cputree.c b/cputree.c
index a8dba73..e4695f2 100644
--- a/cputree.c
+++ b/cputree.c
@@ -366,7 +366,7 @@ static void do_one_cpu(char *path)
struct topo_obj *node;
dir = opendir(path);
- do {
+ while (dir) {
entry = readdir(dir);
if (!entry)
break;
@@ -379,8 +379,9 @@ static void do_one_cpu(char *path)
break;
}
}
- } while (entry);
- closedir(dir);
+ }
+ if (dir)
+ closedir(dir);
/*
* In case of multiple NUMA nodes within a CPU package,
--
2.23.0

View File

@ -0,0 +1,39 @@
From 31dea01f3a47aa6374560638486879e5129f9c94 Mon Sep 17 00:00:00 2001
From: Kairui Song <kasong@redhat.com>
Date: Thu, 28 Jan 2021 15:24:32 +0800
Subject: [PATCH] Also fetch node info for non-PCI devices
non-PCI devices could also be bind to a certain node. So if failed to
fetch the info from sysfs, try to get it from /proc/irq/<irq>/node.
Conflict:NA
Reference:https://github.com/Irqbalance/irqbalance/commit/31dea01f3a47aa6374560638486879e5129f9c94
---
classify.c | 11 ++++++++---
1 file changed, 8 insertions(+), 3 deletions(-)
diff --git a/classify.c b/classify.c
index beb2919..105ecd6 100644
--- a/classify.c
+++ b/classify.c
@@ -361,9 +361,14 @@ static struct irq_info *add_one_irq_to_db(const char *devpath, struct irq_info *
get_numa_node:
numa_node = NUMA_NO_NODE;
- if (devpath != NULL && numa_avail) {
- sprintf(path, "%s/numa_node", devpath);
- process_one_line(path, get_int, &numa_node);
+ if (numa_avail) {
+ if (devpath != NULL) {
+ sprintf(path, "%s/numa_node", devpath);
+ process_one_line(path, get_int, &numa_node);
+ } else {
+ sprintf(path, "/proc/irq/%i/node", irq);
+ process_one_line(path, get_int, &numa_node);
+ }
}
if (pol->numa_node_set == 1)
--
2.23.0

View File

@ -0,0 +1,29 @@
From 028082a6a1ff650d5cdf796ac55ac26a3874372a Mon Sep 17 00:00:00 2001
From: Liu Chao <liuchao173@huawei.com>
Date: Sat, 25 Jun 2022 14:13:10 +0800
Subject: [PATCH] add keep_going check to prevent irqbalance from failing to
exit after SIGTERM
Reference: https://github.com/Irqbalance/irqbalance/commit/028082a6a1ff650d5cdf796ac55ac26a3874372a
Conflict: NA
Signed-off-by: Liu Chao <liuchao173@huawei.com>
---
irqbalance.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/irqbalance.c b/irqbalance.c
index c520c11..5eae5b6 100644
--- a/irqbalance.c
+++ b/irqbalance.c
@@ -290,7 +290,7 @@ gboolean scan(gpointer data __attribute__((unused)))
/* cope with cpu hotplug -- detected during /proc/interrupts parsing */
- while (need_rescan || need_rebuild) {
+ while (keep_going && (need_rescan || need_rebuild)) {
int try_times = 0;
need_rescan = 0;
--
2.23.0

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
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.
Reference:https://github.com/Irqbalance/irqbalance/commit/ee6b3bdd15fdbaf5d6060c3c2df4e7e69dafbd06
Conflict:NA
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.23.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,29 @@
From 0a82dddbaf5702caded0d0d83a6eafaca743254d Mon Sep 17 00:00:00 2001
From: Andreas Schwab <schwab@suse.de>
Date: Mon, 27 Jun 2022 13:43:04 +0200
Subject: [PATCH] parse_proc_interrupts: fix parsing interrupt counts
The name of an interrupt chip can start with a number, stop before it.
Reference: https://github.com/Irqbalance/irqbalance/commit/0a82dddbaf5702caded0d0d83a6eafaca743254d
Conflict: NA
---
procinterrupts.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/procinterrupts.c b/procinterrupts.c
index 57c8801..d90bf6d 100644
--- a/procinterrupts.c
+++ b/procinterrupts.c
@@ -331,7 +331,7 @@ void parse_proc_interrupts(void)
while (1) {
uint64_t C;
C = strtoull(c, &c2, 10);
- if (c==c2) /* end of numbers */
+ if (c==c2 || !strchr(" \t", *c2)) /* end of numbers */
break;
count += C;
c=c2;
--
2.23.0

View File

@ -0,0 +1,28 @@
From 518d81cdd8c54c820d16afb73658753b46032676 Mon Sep 17 00:00:00 2001
From: SuperSix173 <liuchao173@huawei.com>
Date: Tue, 6 Apr 2021 10:26:17 +0800
Subject: [PATCH] Hotplug may occur again during sleep, so wait until there is
no hotplug
Conflict:NA
Reference:https://github.com/Irqbalance/irqbalance/commit/518d81cdd8c54c820d16afb73658753b46032676
---
irqbalance.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/irqbalance.c b/irqbalance.c
index 458bb07..3f94847 100644
--- a/irqbalance.c
+++ b/irqbalance.c
@@ -285,7 +285,7 @@ gboolean scan(gpointer data __attribute__((unused)))
/* cope with cpu hotplug -- detected during /proc/interrupts parsing */
- if (need_rescan || need_rebuild) {
+ while (need_rescan || need_rebuild) {
int try_times = 0;
need_rescan = 0;
--
2.23.0

View File

@ -0,0 +1,56 @@
From c8757c6d870c4788da4980abaf21cb7369702ee9 Mon Sep 17 00:00:00 2001
From: Paride Legovini <paride@debian.org>
Date: Tue, 25 Aug 2020 23:18:27 +0200
Subject: [PATCH] activate_mapping: activate only online CPUs
When echoing a mask to /proc/irq/N/smp_affinity make sure to activate
only CPUs which are online. Activating a CPU which is not online results
in a EOVERFLOW.
Originally fixed in Debian by Helge Deller <deller@gmx.de>.
Conflict:NA
Reference:https://github.com/Irqbalance/irqbalance/commit/c8757c6d870c4788da4980abaf21cb7369702ee9
---
activate.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/activate.c b/activate.c
index 065f880..62cfd08 100644
--- a/activate.c
+++ b/activate.c
@@ -49,6 +49,7 @@ static void activate_mapping(struct irq_info *info, void *data __attribute__((un
char buf[PATH_MAX];
FILE *file;
int ret = 0;
+ cpumask_t applied_mask;
/*
* only activate mappings for irqs that have moved
@@ -59,10 +60,13 @@ static void activate_mapping(struct irq_info *info, void *data __attribute__((un
if (!info->assigned_obj)
return;
+ /* activate only online cpus, otherwise writing to procfs returns EOVERFLOW */
+ cpus_and(applied_mask, cpu_online_map, info->assigned_obj->mask);
+
/*
* Don't activate anything for which we have an invalid mask
*/
- if (check_affinity(info, info->assigned_obj->mask))
+ if (check_affinity(info, applied_mask))
return;
sprintf(buf, "/proc/irq/%i/smp_affinity", info->irq);
@@ -70,7 +74,7 @@ static void activate_mapping(struct irq_info *info, void *data __attribute__((un
if (!file)
return;
- cpumask_scnprintf(buf, PATH_MAX, info->assigned_obj->mask);
+ cpumask_scnprintf(buf, PATH_MAX, applied_mask);
ret = fprintf(file, "%s", buf);
if (ret < 0) {
log(TO_ALL, LOG_WARNING, "cannot change irq %i's affinity, add it to banned list", info->irq);
--
2.23.0

View File

@ -0,0 +1,352 @@
From 0ba4a60a2a732150e5016389e32b2e81906a72c2 Mon Sep 17 00:00:00 2001
From: hejingxian 00273181 <hejingxian@huawei.com>
Date: Fri, 4 Dec 2020 10:52:57 +0800
Subject: [PATCH] add irq hotplug feature for irqbalance
Conflict:NA
Reference:https://github.com/Irqbalance/irqbalance/commit/0ba4a60a2a732150e5016389e32b2e81906a72c2
---
classify.c | 70 +++++++++++++++++++++++--------
irqbalance.c | 2 +-
irqbalance.h | 4 +-
procinterrupts.c | 104 ++++++++++++++++++++++++++++-------------------
4 files changed, 120 insertions(+), 60 deletions(-)
diff --git a/classify.c b/classify.c
index 9f588bc..0d556e9 100644
--- a/classify.c
+++ b/classify.c
@@ -619,7 +619,7 @@ static void add_new_irq(char *path, struct irq_info *hint, GList *proc_interrupt
/*
* Figures out which interrupt(s) relate to the device we"re looking at in dirname
*/
-static void build_one_dev_entry(const char *dirname, GList *tmp_irqs)
+static void build_one_dev_entry(const char *dirname, GList *tmp_irqs, int build_irq)
{
struct dirent *entry;
DIR *msidir;
@@ -642,10 +642,14 @@ static void build_one_dev_entry(const char *dirname, GList *tmp_irqs)
if (!entry)
break;
irqnum = strtol(entry->d_name, NULL, 10);
- if (irqnum) {
+ /* If build_irq is valid, only add irq when it's number equals to build_irq */
+ if (irqnum && ((build_irq < 0) || (irqnum == build_irq))) {
+ printf("add irq:%d %d for %s\n", irqnum, build_irq, path);
hint.irq = irqnum;
hint.type = IRQ_TYPE_MSIX;
add_new_irq(devpath, &hint, tmp_irqs);
+ if (build_irq >= 0)
+ break;
}
} while (entry != NULL);
closedir(msidir);
@@ -665,9 +669,12 @@ static void build_one_dev_entry(const char *dirname, GList *tmp_irqs)
#else
if (irqnum) {
#endif
- hint.irq = irqnum;
- hint.type = IRQ_TYPE_LEGACY;
- add_new_irq(devpath, &hint, tmp_irqs);
+ /* If build_irq is valid, only add irq when it's number equals to build_irq */
+ if ((build_irq < 0) || (irqnum == build_irq)) {
+ hint.irq = irqnum;
+ hint.type = IRQ_TYPE_LEGACY;
+ add_new_irq(devpath, &hint, tmp_irqs);
+ }
}
done:
@@ -712,31 +719,60 @@ static void free_tmp_irqs(gpointer data)
free(info);
}
-void rebuild_irq_db(void)
+static struct irq_info * build_dev_irqs(GList *tmp_irqs, int build_irq)
{
DIR *devdir;
struct dirent *entry;
- GList *tmp_irqs = NULL;
-
- free_irq_db();
-
- tmp_irqs = collect_full_irq_list();
+ struct irq_info *new_irq = NULL;
devdir = opendir(SYSPCI_DIR);
-
if (devdir) {
do {
entry = readdir(devdir);
-
if (!entry)
break;
-
- build_one_dev_entry(entry->d_name, tmp_irqs);
-
+ /* when hotplug irqs, we add one irq at one time */
+ build_one_dev_entry(entry->d_name, tmp_irqs, build_irq);
+ if (build_irq >= 0) {
+ new_irq = get_irq_info(build_irq);
+ if (new_irq)
+ break;
+ }
} while (entry != NULL);
-
closedir(devdir);
}
+ return new_irq;
+}
+
+int proc_irq_hotplug(char *savedline, int irq, struct irq_info **pinfo)
+{
+ struct irq_info tmp_info = {0};
+
+ /* firstly, init irq info by read device info */
+ *pinfo = build_dev_irqs(interrupts_db, irq);
+ if (*pinfo == NULL) {
+ /* secondly, init irq info by parse savedline */
+ init_irq_class_and_type(savedline, &tmp_info, irq);
+ add_new_irq(NULL, &tmp_info, interrupts_db);
+ *pinfo = get_irq_info(irq);
+ }
+ if (*pinfo == NULL) {
+ return -1;
+ }
+
+ force_rebalance_irq(*pinfo, NULL);
+ return 0;
+}
+
+void rebuild_irq_db(void)
+{
+ GList *tmp_irqs = NULL;
+
+ free_irq_db();
+
+ tmp_irqs = collect_full_irq_list();
+
+ build_dev_irqs(tmp_irqs, -1);
for_each_irq(tmp_irqs, add_missing_irq, interrupts_db);
diff --git a/irqbalance.c b/irqbalance.c
index eaa0ce1..9baa955 100644
--- a/irqbalance.c
+++ b/irqbalance.c
@@ -249,7 +249,7 @@ static void dump_object_tree(void)
for_each_object(numa_nodes, dump_numa_node_info, NULL);
}
-static void force_rebalance_irq(struct irq_info *info, void *data __attribute__((unused)))
+void force_rebalance_irq(struct irq_info *info, void *data __attribute__((unused)))
{
if (info->level == BALANCE_NONE)
return;
diff --git a/irqbalance.h b/irqbalance.h
index acf0ed5..d8e80a9 100644
--- a/irqbalance.h
+++ b/irqbalance.h
@@ -40,8 +40,11 @@ extern GList* collect_full_irq_list();
extern void parse_proc_stat(void);
extern void set_interrupt_count(int number, uint64_t count);
extern void set_msi_interrupt_numa(int number);
+extern void init_irq_class_and_type(char *savedline, struct irq_info *info, int irq);
+extern int proc_irq_hotplug(char *line, int irq, struct irq_info **pinfo);
extern GList *rebalance_irq_list;
+extern void force_rebalance_irq(struct irq_info *info, void *data __attribute__((unused)));
void update_migration_status(void);
void dump_workloads(void);
@@ -52,7 +55,6 @@ void dump_tree(void);
void activate_mappings(void);
void clear_cpu_tree(void);
void free_cpu_topo(gpointer data);
-
/*===================NEW BALANCER FUNCTIONS============================*/
/*
diff --git a/procinterrupts.c b/procinterrupts.c
index 858b66b..0671be0 100644
--- a/procinterrupts.c
+++ b/procinterrupts.c
@@ -145,16 +145,59 @@ static void guess_arm_irq_hints(char *name, struct irq_info *info)
}
#endif
+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;
+#ifdef AARCH64
+ char *tmp = NULL;
+#endif
+
+ irq_name = strtok_r(savedline, " ", &savedptr);
+ if (strstr(irq_name, "xen-dyn") != NULL)
+ is_xen_dyn = 1;
+ last_token = strtok_r(NULL, " ", &savedptr);
+ while ((p = strtok_r(NULL, " ", &savedptr))) {
+ irq_name = last_token;
+ if (strstr(irq_name, "xen-dyn") != NULL)
+ is_xen_dyn = 1;
+ last_token = p;
+ }
+
+#ifdef AARCH64
+ irq_name = last_token;
+ tmp = strchr(irq_name, '\n');
+ if (tmp)
+ *tmp = 0;
+#endif
+ irq_mod = last_token;
+ info->irq = irq;
+
+ if (strstr(irq_name, "-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);
+#else
+ info->type = IRQ_TYPE_LEGACY;
+ info->class = IRQ_OTHER;
+#endif
+ }
+ info->numa_node = get_numa_node(0);
+ info->name = strdup(irq_mod);
+}
+
GList* collect_full_irq_list()
{
GList *tmp_list = NULL;
FILE *file;
char *line = NULL;
size_t size = 0;
- char *irq_name, *irq_mod, *savedptr, *last_token, *p;
-#ifdef AARCH64
- char *tmp;
-#endif
file = fopen("/proc/interrupts", "r");
if (!file)
@@ -169,7 +212,6 @@ GList* collect_full_irq_list()
while (!feof(file)) {
int number;
- int is_xen_dyn = 0;
struct irq_info *info;
char *c;
char *savedline = NULL;
@@ -191,44 +233,12 @@ GList* collect_full_irq_list()
savedline = strdup(line);
if (!savedline)
break;
- irq_name = strtok_r(savedline, " ", &savedptr);
- if (strstr(irq_name, "xen-dyn") != NULL)
- is_xen_dyn = 1;
- last_token = strtok_r(NULL, " ", &savedptr);
- while ((p = strtok_r(NULL, " ", &savedptr))) {
- irq_name = last_token;
- if (strstr(irq_name, "xen-dyn") != NULL)
- is_xen_dyn = 1;
- last_token = p;
- }
-
-#ifdef AARCH64
- /* Of course the formatting for /proc/interrupts is different on different arches */
- irq_name = last_token;
- tmp = strchr(irq_name, '\n');
- if (tmp)
- *tmp = 0;
-#endif
- irq_mod = last_token;
-
*c = 0;
number = strtoul(line, NULL, 10);
info = calloc(1, sizeof(struct irq_info));
if (info) {
- info->irq = number;
- if (strstr(irq_name, "-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);
-#else
- info->type = IRQ_TYPE_LEGACY;
- info->class = IRQ_OTHER;
-#endif
- }
- info->name = strdup(irq_mod);
+ init_irq_class_and_type(savedline, info, number);
tmp_list = g_list_append(tmp_list, info);
}
free(savedline);
@@ -238,11 +248,13 @@ GList* collect_full_irq_list()
return tmp_list;
}
+
void parse_proc_interrupts(void)
{
FILE *file;
char *line = NULL;
size_t size = 0;
+ int ret;
file = fopen("/proc/interrupts", "r");
if (!file)
@@ -261,6 +273,7 @@ void parse_proc_interrupts(void)
uint64_t count;
char *c, *c2;
struct irq_info *info;
+ char *savedline = NULL;
if (getline(&line, &size, file)<=0)
break;
@@ -280,15 +293,24 @@ void parse_proc_interrupts(void)
if (!c)
continue;
+ savedline = strdup(line);
+ if (!savedline)
+ break;
*c = 0;
c++;
number = strtoul(line, NULL, 10);
info = get_irq_info(number);
if (!info) {
- need_rescan = 1;
- break;
+ ret = proc_irq_hotplug(savedline, number, &info);
+ if (ret < 0) {
+ /* hotplug fail, need to rescan */
+ need_rescan = 1;
+ free(savedline);
+ break;
+ }
}
+ free(savedline);
count = 0;
cpunr = 0;
@@ -316,7 +338,7 @@ void parse_proc_interrupts(void)
break;
}
- info->last_irq_count = info->irq_count;
+ info->last_irq_count = info->irq_count;
info->irq_count = count;
/* is interrupt MSI based? */
--
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,57 @@
From 6fe032945b69d8f382fa3e8de8e4fdce84063199 Mon Sep 17 00:00:00 2001
From: Yunfeng Ye <yeyunfeng@huawei.com>
Date: Fri, 20 Nov 2020 00:15:58 +0800
Subject: [PATCH] log correctly for isolated and nohz_full cpus
When the banded CPU is configured, and the "isolcpus" or "nohz_full"
is configured, the log for isolated and nohz CPUs are not correct.
So only log relevant infomation when isolcpus and nohz_full has been
handled, also put the cpus_clear() closer.
Conflict:NA
Reference:https://github.com/Irqbalance/irqbalance/commit/6fe032945b69d8f382fa3e8de8e4fdce84063199
---
cputree.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/cputree.c b/cputree.c
index 80a6d9d..eed20db 100644
--- a/cputree.c
+++ b/cputree.c
@@ -112,9 +112,6 @@ static void setup_banned_cpus(void)
cpumask_t isolated_cpus;
char *env = NULL;
- cpus_clear(isolated_cpus);
- cpus_clear(nohz_full);
-
/* A manually specified cpumask overrides auto-detection. */
if (cpu_ban_string != NULL && banned_cpumask_from_ui != NULL) {
cpulist_parse(banned_cpumask_from_ui,
@@ -133,6 +130,9 @@ static void setup_banned_cpus(void)
goto out;
}
+ cpus_clear(isolated_cpus);
+ cpus_clear(nohz_full);
+
path = "/sys/devices/system/cpu/isolated";
process_one_line(path, get_mask_from_cpulist, &isolated_cpus);
@@ -141,11 +141,11 @@ static void setup_banned_cpus(void)
cpus_or(banned_cpus, nohz_full, isolated_cpus);
-out:
cpumask_scnprintf(buffer, 4096, isolated_cpus);
log(TO_CONSOLE, LOG_INFO, "Isolated CPUs: %s\n", buffer);
cpumask_scnprintf(buffer, 4096, nohz_full);
log(TO_CONSOLE, LOG_INFO, "Adaptive-ticks CPUs: %s\n", buffer);
+out:
cpumask_scnprintf(buffer, 4096, banned_cpus);
log(TO_CONSOLE, LOG_INFO, "Banned CPUs: %s\n", buffer);
}
--
2.23.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

@ -0,0 +1,46 @@
From 066499ad5231a8a8d37f08a3af5dd6c38431ce6f Mon Sep 17 00:00:00 2001
From: liuchao173 <55137861+liuchao173@users.noreply.github.com>
Date: Fri, 7 May 2021 20:48:32 +0800
Subject: [PATCH] remove no existing irq in banned_irqs
when a banned irq doesn't exist, it won't be removed from banned_irqs
Conflict:NA
Reference:https://github.com/Irqbalance/irqbalance/pull/183/commits/066499ad5231a8a8d37f08a3af5dd6c38431ce6f
---
classify.c | 11 +++++++++--
1 file changed, 9 insertions(+), 2 deletions(-)
diff --git a/classify.c b/classify.c
index 105ecd6..c08144f 100644
--- a/classify.c
+++ b/classify.c
@@ -869,8 +869,16 @@ static void remove_no_existing_irq(struct irq_info *info, void *data __attribute
}
entry = g_list_find_custom(interrupts_db, info, compare_ints);
- if (entry)
+ if (entry) {
interrupts_db = g_list_delete_link(interrupts_db, entry);
+ log(TO_CONSOLE, LOG_INFO, "IRQ %d is removed from interrupts_db.\n", info->irq);
+ }
+
+ entry = g_list_find_custom(banned_irqs, info, compare_ints);
+ if (entry) {
+ banned_irqs = g_list_delete_link(banned_irqs, entry);
+ log(TO_CONSOLE, LOG_INFO, "IRQ %d is removed from banned_irqs.\n", info->irq);
+ }
entry = g_list_find_custom(rebalance_irq_list, info, compare_ints);
if (entry)
@@ -882,7 +890,6 @@ static void remove_no_existing_irq(struct irq_info *info, void *data __attribute
info->assigned_obj->interrupts = g_list_delete_link(info->assigned_obj->interrupts, entry);
}
}
- log(TO_CONSOLE, LOG_INFO, "IRQ %d is removed from interrupts_db.\n", info->irq);
free_irq(info, NULL);
}
--
2.23.0

View File

@ -1,7 +1,7 @@
Summary: A dynamic adaptive IRQ balancing daemon
Name: irqbalance
Version: 1.7.0
Release: 4
Release: 20
Epoch: 3
License: GPLv2
Source0: https://github.com/Irqbalance/irqbalance/archive/irqbalance-%{version}.tar.gz
@ -22,6 +22,23 @@ Requires: numactl-libs
%define _hardened_build 1
Patch6000: fix-unsigned-integer-subtraction-sign-overflow.patch
Patch6001: backport-activate_mapping-activate-only-online-CPUs.patch
Patch6002: backport-log-correctly-for-isolated-and-nohz_full-cpus.patch
Patch6003: backport-add-irq-hotplug-feature-for-irqbalance.patch
Patch6004: backport-Add-log-for-hotplug-appropriately.patch
Patch6005: backport-Add-hot-pull-method-for-irqbalance.patch
Patch6006: backport-Also-fetch-node-info-for-non-PCI-devices.patch
Patch6007: backport-Hotplug-may-occur-again-during-sleep-so-wait-until-t.patch
Patch6008: backport-Add-return-value-check-of-opendir-in-do_one_cpu.patch
Patch6009: backport-Fix-irqbalance-cannot-obtain-the-full-name-of-irq.patch
Patch6010: backport-Fix-compile-issue-with-none-AARCH64-builds.patch
Patch6011: backport-remove-no-existing-irq-in-banned_irqs.patch
Patch6012: backport-Add-0-to-the-end-of-strings-to-avoid-heap-buffer-ove.patch
Patch6013: backport-Fix-parse_proc_interrupts-fix-parsing-interrupt-counts.patch
Patch6014: backport-Fix-add-keep_going-check-to-prevent-irqbalance-from-failing-to-exit-after-SIGTERM.patch
Patch6015: backport-fix-opendir-fails-in-check_platform_device.patch
Patch6016: backport-check-whether-savedptr-is-NULL-before-invoking-strle.patch
Patch6017: backport-procinterrupts-Fix-IRQ-name-parsing-on-certain-arm64.patch
%description
Irqbalance is a daemon to help balance the cpu load generated by
@ -79,6 +96,102 @@ fi
/sbin/chkconfig --del %{name} >/dev/null 2>&1 || :
%changelog
* Thu Jan 5 2023 qinyu <qinyu32@huawei.com> - 3:1.7.0-20
- Type:bugfix
- ID:NA
- SUG:restart
- DESC: procinterrupts: Fix IRQ name parsing on certain arm64 SoC
* Thu Jan 5 2023 qinyu <qinyu32@huawei.com> - 3:1.7.0-19
- Type:bugfix
- ID:NA
- SUG:restart
- DESC: check whether savedptr is NULL before invoking strlen
* Thu Jan 5 2023 qinyu <qinyu32@huawei.com> - 3:1.7.0-18
- Type:bugfix
- ID:NA
- SUG:restart
- DESC: fix opendir fails in check_platform_device
* Thu Jan 5 2023 qinyu <qinyu32@huawei.com> - 3:1.7.0-17
- Type:bugfix
- ID:NA
- SUG:restart
- DESC: add keep_going check to prevent irqbalance from failing to exit after SIGTERM
* Thu Jan 5 2023 qinyu <qinyu32@huawei.com> - 3:1.7.0-16
- Type:bugfix
- ID:NA
- SUG:restart
- DESC: parse_proc_interrupts: fix parsing interrupt counts
* Thu Jan 5 2023 qinyu <qinyu32@huawei.com> - 3:1.7.0-15
- Type:bugfix
- ID:NA
- SUG:restart
- DESC: Add '\0' to the end of strings to avoid heap buffer overflow
* Thu Jan 5 2023 qinyu <qinyu32@huawei.com> - 3:1.7.0-14
- Type:bugfix
- ID:NA
- SUG:restart
- DESC: remove no existing irq in banned_irqs
* Thu Jan 5 2023 qinyu <qinyu32@huawei.com> - 3:1.7.0-13
- Type:bugfix
- ID:NA
- SUG:restart
- DESC: Fix compile issue with none AARCH64 builds
* Thu Jan 5 2023 qinyu <qinyu32@huawei.com> - 3:1.7.0-12
- Type:bugfix
- ID:NA
- SUG:restart
- DESC: Fix irqbalance cannot obtain the full name of irq
* Thu Jan 5 2023 qinyu <qinyu32@huawei.com> - 3:1.7.0-11
- Type:bugfix
- ID:NA
- SUG:restart
- DESC: Add return value check of opendir in do_one_cpu
* Thu Jan 5 2023 qinyu <qinyu32@huawei.com> - 3:1.7.0-10
- Type:bugfix
- ID:NA
- SUG:restart
- DESC: Hotplug may occur again during sleep, so wait until there is no hotplug
* Thu Jan 5 2023 qinyu <qinyu32@huawei.com> - 3:1.7.0-9
- Type:bugfix
- ID:NA
- SUG:restart
- DESC: Also fetch node info for non-PCI devices
* Thu Jan 5 2023 qinyu <qinyu32@huawei.com> - 3:1.7.0-8
- Type:bugfix
- ID:NA
- SUG:restart
- DESC: Add hot pull method for irqbalance
* Thu Jan 5 2023 qinyu <qinyu32@huawei.com> - 3:1.7.0-7
- Type:bugfix
- ID:NA
- SUG:restart
- DESC: add irq hotplug feature for irqbalance
* Thu Jan 5 2023 qinyu <qinyu32@huawei.com> - 3:1.7.0-6
- Type:bugfix
- ID:NA
- SUG:restart
- DESC: log correctly for isolated and nohz_full cpus
* Thu Jan 5 2023 qinyu <qinyu32@huawei.com> - 3:1.7.0-5
- Type:bugfix
- ID:NA
- SUG:restart
- DESC: activate_mapping: activate only online CPUs
* Wed Aug 25 2021 Liu Chao <liuchao173@huawei.com> - 3:1.7.0-4
- Type:bugfix
- ID:NA