Release 1.9.4-1

Rebase to upstream commit (f2c8309a41)

Resolves: RHEL-29891
Resolves: RHEL-31797
Resolves: RHEL-33028

Signed-off-by: Tao Liu <ltao@redhat.com>
This commit is contained in:
Tao Liu 2024-05-01 18:41:40 +08:00
parent e2ec6d2e15
commit b09d93e364
26 changed files with 119 additions and 917 deletions

View File

@ -1,35 +0,0 @@
From 8bbc0aeca0187ad3f5f942408198bc0fc055b0f8 Mon Sep 17 00:00:00 2001
From: Tao Liu <ltao@redhat.com>
Date: Tue, 4 Jul 2023 10:04:10 +0800
Subject: [PATCH 1/7] activate_mapping: fflush the buffered data to
smp_affinity
Previously irqbalance uses the return value of fprintf() to decide whether
the modification of smp_affinity is successful or not. However it is not
reliable because fprintf() is stream buffered, a fflush() should be used to
check the buffered data been successfully written into the file before the
judgement.
This patch fixes the issue by introducing fflush() after fprintf().
Signed-off-by: Tao Liu <ltao@redhat.com>
---
activate.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/activate.c b/activate.c
index 62cfd08..6d0b096 100644
--- a/activate.c
+++ b/activate.c
@@ -76,7 +76,7 @@ static void activate_mapping(struct irq_info *info, void *data __attribute__((un
cpumask_scnprintf(buf, PATH_MAX, applied_mask);
ret = fprintf(file, "%s", buf);
- if (ret < 0) {
+ if (ret < 0 || fflush(file)) {
log(TO_ALL, LOG_WARNING, "cannot change irq %i's affinity, add it to banned list", info->irq);
add_banned_irq(info->irq);
remove_one_irq_from_db(info->irq);
--
2.40.1

View File

@ -0,0 +1,38 @@
From c0cd6149722ca525cf31a363dbe724689bef4d87 Mon Sep 17 00:00:00 2001
From: Tao Liu <ltao@redhat.com>
Date: Wed, 13 Mar 2024 14:30:48 +0800
Subject: [PATCH 1/3] irqbalance-ui: check if using a negative index of buffer
A negative index will be used when recv() fails, which is unexpected for
the data buffer. The issue was found by Static Application Security
Testing (SAST), which is a potential weakness.
This patch will check the negative index before data buffer referencing.
Signed-off-by: Tao Liu <ltao@redhat.com>
---
ui/irqbalance-ui.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/ui/irqbalance-ui.c b/ui/irqbalance-ui.c
index b7f9b62..c26eff6 100644
--- a/ui/irqbalance-ui.c
+++ b/ui/irqbalance-ui.c
@@ -127,9 +127,13 @@ try_again:
char *data = malloc(default_bufsz);
int len = recv(socket_fd, data, default_bufsz, MSG_TRUNC);
close(socket_fd);
- data[len] = '\0';
free(msg->msg_control);
free(msg);
+ if (len < 0) {
+ free(data);
+ return NULL;
+ }
+ data[len] = '\0';
if (len >= default_bufsz) {
/* msg was truncated, increase bufsz and try again */
default_bufsz += 8192;
--
2.40.1

View File

@ -1,26 +0,0 @@
From 7c18ffc9d0187d4d1983a53bb166aacad2a87dcc Mon Sep 17 00:00:00 2001
From: qyu <chinyu0704@icloud.com>
Date: Mon, 7 Nov 2022 17:01:38 +0800
Subject: [PATCH 01/13] optimize getting cpu number
cpu number has already been parsed and saved in cpunr, remove redudant strtoul().
---
cputree.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/cputree.c b/cputree.c
index eb1981e..d66be55 100644
--- a/cputree.c
+++ b/cputree.c
@@ -315,7 +315,7 @@ static void do_one_cpu(char *path)
cpu->obj_type = OBJ_TYPE_CPU;
- cpu->number = strtoul(&path[27], NULL, 10);
+ cpu->number = cpunr;
cpu_set(cpu->number, cpu_online_map);
--
2.33.1

View File

@ -0,0 +1,41 @@
From 8301666f3029ff4d9089a273a45ec47671d964c1 Mon Sep 17 00:00:00 2001
From: Andrew Zaborowski <andrew.zaborowski@intel.com>
Date: Fri, 29 Mar 2024 18:43:55 -0700
Subject: [PATCH 2/3] Check fflush() return value
Since fprintf() may buffer output, as noted in 470a64b19062, fclose()'s
error value was also being checked for the write errors. However in
8d7c78304fb9 an fflush() was added in between meaning that these
buffered write errors were again unchecked. Some actual errors were
not being logged, in my case -ENOSPCs.
Make the fclose and fflush branches look similar.
Fixes: 8d7c78304fb9 ("Flush file before closing")
---
activate.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/activate.c b/activate.c
index e30d0f0..0c1e7a1 100644
--- a/activate.c
+++ b/activate.c
@@ -82,10 +82,13 @@ static void activate_mapping(struct irq_info *info, void *data __attribute__((un
cpumask_scnprintf(buf, PATH_MAX, applied_mask);
ret = fprintf(file, "%s", buf);
errsave = errno;
- fflush(file);
+ if (ret >= 0 && fflush(file)) {
+ ret = -1;
+ errsave = errno;
+ }
if (fclose(file)) {
+ ret = -1;
errsave = errno;
- goto error;
}
if (ret < 0)
goto error;
--
2.40.1

View File

@ -1,30 +0,0 @@
From 4efc1923f8fd161d131d2b8e8930bf5c9ed66668 Mon Sep 17 00:00:00 2001
From: Neil Horman <neil.horman@secedge.com>
Date: Sun, 9 Jul 2023 10:09:17 -0400
Subject: [PATCH 2/7] Revert "activate_mapping: fflush the buffered data to
smp_affinity"
This reverts commit 8bbc0aeca0187ad3f5f942408198bc0fc055b0f8.
Was causing a segfault:
https://github.com/Irqbalance/irqbalance/issues/267
---
activate.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/activate.c b/activate.c
index 6d0b096..62cfd08 100644
--- a/activate.c
+++ b/activate.c
@@ -76,7 +76,7 @@ static void activate_mapping(struct irq_info *info, void *data __attribute__((un
cpumask_scnprintf(buf, PATH_MAX, applied_mask);
ret = fprintf(file, "%s", buf);
- if (ret < 0 || fflush(file)) {
+ if (ret < 0) {
log(TO_ALL, LOG_WARNING, "cannot change irq %i's affinity, add it to banned list", info->irq);
add_banned_irq(info->irq);
remove_one_irq_from_db(info->irq);
--
2.40.1

View File

@ -1,31 +0,0 @@
From efec4c69157d17024c4d9194a63eb834efcd79b9 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Dirk=20M=C3=BCller?= <dirk@dmllr.de>
Date: Fri, 11 Nov 2022 10:38:19 +0100
Subject: [PATCH 02/13] allow AF_NETLINK in the systemd service restrictions
AF_NETLINK is needed for communicating with the thermald daemon,
without that the start up logs a warning
thermal: socket bind failed, thermald may not be running.
because systemd prevents access to NETLINK.
---
misc/irqbalance.service | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/misc/irqbalance.service b/misc/irqbalance.service
index 0f79c3e..8544f66 100644
--- a/misc/irqbalance.service
+++ b/misc/irqbalance.service
@@ -11,7 +11,7 @@ EnvironmentFile=-/path/to/irqbalance.env
ExecStart=/usr/sbin/irqbalance --foreground $IRQBALANCE_ARGS
ReadOnlyPaths=/
ReadWritePaths=/proc/irq
-RestrictAddressFamilies=AF_UNIX
+RestrictAddressFamilies=AF_UNIX AF_NETLINK
RuntimeDirectory=irqbalance/
[Install]
--
2.33.1

View File

@ -0,0 +1,25 @@
From f2c8309a4198d8f51069a783905049c5b7eb7600 Mon Sep 17 00:00:00 2001
From: Neil Horman <nhorman@openssl.org>
Date: Mon, 1 Apr 2024 08:05:14 -0400
Subject: [PATCH 3/3] Drop ProtectKernelTunables
It makes /proc/irq read only
---
misc/irqbalance.service | 1 -
1 file changed, 1 deletion(-)
diff --git a/misc/irqbalance.service b/misc/irqbalance.service
index 87e19c1..b731cc6 100644
--- a/misc/irqbalance.service
+++ b/misc/irqbalance.service
@@ -23,7 +23,6 @@ PrivateNetwork=yes
PrivateUsers=true
ProtectHostname=yes
ProtectClock=yes
-ProtectKernelTunables=yes
ProtectKernelModules=yes
ProtectKernelLogs=yes
ProtectControlGroups=yes
--
2.40.1

View File

@ -1,144 +0,0 @@
From f589bdced6e1fe885969f2833fc3cacdfb60ea79 Mon Sep 17 00:00:00 2001
From: Robin Jarry <rjarry@redhat.com>
Date: Tue, 11 Jul 2023 15:17:55 +0200
Subject: [PATCH 3/7] activate_mapping: avoid use-after-free when affinity
cannot be set
add_banned_irq appends the irq_info to the banned_irqs list.
remove_one_irq_from_db removes it from the interrupts_db and free()s it.
This leaves an invalid pointer dangling in banned_irqs *and* potentially
in rebalance_irq_list which can cause use-after-free errors.
Do not move the irq_info around. Only add a flag to indicate that this
irq's affinity cannot be managed and ignore the irq when this flag is
set.
Link: https://github.com/Irqbalance/irqbalance/issues/267
Fixes: 55c5c321c73e ("arm64: Add irq aff change check For aarch64...")
Signed-off-by: Robin Jarry <rjarry@redhat.com>
---
activate.c | 8 +++++---
classify.c | 28 +++-------------------------
irqbalance.h | 2 --
types.h | 3 ++-
4 files changed, 10 insertions(+), 31 deletions(-)
diff --git a/activate.c b/activate.c
index 62cfd08..6f8af27 100644
--- a/activate.c
+++ b/activate.c
@@ -60,6 +60,9 @@ static void activate_mapping(struct irq_info *info, void *data __attribute__((un
if (!info->assigned_obj)
return;
+ if (info->flags & IRQ_FLAG_AFFINITY_UNMANAGED)
+ return;
+
/* activate only online cpus, otherwise writing to procfs returns EOVERFLOW */
cpus_and(applied_mask, cpu_online_map, info->assigned_obj->mask);
@@ -77,9 +80,8 @@ static void activate_mapping(struct irq_info *info, void *data __attribute__((un
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);
- add_banned_irq(info->irq);
- remove_one_irq_from_db(info->irq);
+ log(TO_ALL, LOG_WARNING, "cannot change IRQ %i affinity, will never try again\n", info->irq);
+ info->flags |= IRQ_FLAG_AFFINITY_UNMANAGED;
}
fclose(file);
info->moved = 0; /*migration is done*/
diff --git a/classify.c b/classify.c
index dac813c..1601a1e 100644
--- a/classify.c
+++ b/classify.c
@@ -257,7 +257,7 @@ static gint compare_ints(gconstpointer a, gconstpointer b)
return ai->irq - bi->irq;
}
-static void __add_banned_irq(int irq, GList **list)
+static void add_banned_irq(int irq, GList **list)
{
struct irq_info find, *new;
GList *entry;
@@ -281,14 +281,9 @@ static void __add_banned_irq(int irq, GList **list)
return;
}
-void add_banned_irq(int irq)
-{
- __add_banned_irq(irq, &banned_irqs);
-}
-
void add_cl_banned_irq(int irq)
{
- __add_banned_irq(irq, &cl_banned_irqs);
+ add_banned_irq(irq, &cl_banned_irqs);
}
gint substr_find(gconstpointer a, gconstpointer b)
@@ -392,23 +387,6 @@ get_numa_node:
return new;
}
-void remove_one_irq_from_db(int irq)
-{
- struct irq_info find, *tmp;
- GList *entry = NULL;
-
- find.irq = irq;
- entry = g_list_find_custom(interrupts_db, &find, compare_ints);
- if (!entry)
- return;
-
- tmp = entry->data;
- interrupts_db = g_list_remove(interrupts_db, tmp);
- free(tmp);
- log(TO_CONSOLE, LOG_INFO, "IRQ %d was removed from db.\n", irq);
- return;
-}
-
static void parse_user_policy_key(char *buf, int irq, struct user_irq_policy *pol)
{
char *key, *value, *end;
@@ -629,7 +607,7 @@ static void add_new_irq(char *path, struct irq_info *hint)
/* Set NULL devpath for the irq has no sysfs entries */
get_irq_user_policy(path, irq, &pol);
if ((pol.ban == 1) || check_for_irq_ban(hint, mod)) { /*FIXME*/
- __add_banned_irq(irq, &banned_irqs);
+ add_banned_irq(irq, &banned_irqs);
new = get_irq_info(irq);
} else
new = add_one_irq_to_db(path, hint, &pol);
diff --git a/irqbalance.h b/irqbalance.h
index e7f6b94..46e05ca 100644
--- a/irqbalance.h
+++ b/irqbalance.h
@@ -109,8 +109,6 @@ extern struct irq_info *get_irq_info(int irq);
extern void migrate_irq(GList **from, GList **to, struct irq_info *info);
extern void free_cl_opts(void);
extern void add_cl_banned_module(char *modname);
-extern void add_banned_irq(int irq);
-extern void remove_one_irq_from_db(int irq);
#define irq_numa_node(irq) ((irq)->numa_node)
diff --git a/types.h b/types.h
index 9693cf4..c63cfea 100644
--- a/types.h
+++ b/types.h
@@ -34,7 +34,8 @@
/*
* IRQ Internal tracking flags
*/
-#define IRQ_FLAG_BANNED 1
+#define IRQ_FLAG_BANNED (1ULL << 0)
+#define IRQ_FLAG_AFFINITY_UNMANAGED (1ULL << 1)
enum obj_type_e {
OBJ_TYPE_CPU,
--
2.40.1

View File

@ -1,33 +0,0 @@
From 178cf3b4311fab38b9731fc929feecf45b7cb2f0 Mon Sep 17 00:00:00 2001
From: "Chang S. Bae" <chang.seok.bae@intel.com>
Date: Fri, 18 Nov 2022 10:14:15 -0800
Subject: [PATCH 03/13] thermal: Fix the warning message
The commit febe697ac321 ("change the log level in thermal.c from error to
warning") happens to insert an unneeded message: "thermald may not be
running."
This is not true because the events come from the kernel and Netlink has
the multicast subscription model. So it has nothing to do with thermald.
Signed-off-by: Chang S. Bae <chang.seok.bae@intel.com>
---
thermal.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/thermal.c b/thermal.c
index 10e1083..7cd0807 100644
--- a/thermal.c
+++ b/thermal.c
@@ -99,7 +99,7 @@ static gboolean prepare_netlink(void)
rc = genl_connect(sock);
if (rc) {
- log(TO_ALL, LOG_INFO, "thermal: socket bind failed, thermald may not be running.\n");
+ log(TO_ALL, LOG_INFO, "thermal: socket bind failed.\n");
return TRUE;
}
--
2.33.1

View File

@ -1,48 +0,0 @@
From 470a64b190628574c28a266bdcf8960291463191 Mon Sep 17 00:00:00 2001
From: Robin Jarry <rjarry@redhat.com>
Date: Wed, 12 Jul 2023 08:51:08 +0200
Subject: [PATCH 4/7] activate_mapping: make sure to catch all errors
fprintf() is buffered and may not report an error which may be deferred
when fflush() is called (either explicitly or internally by fclose()).
Check for errors returned by fopen(), fprintf() and fclose() and add
IRQ_FLAG_AFFINITY_UNMANAGED accordingly.
Fixes: 55c5c321c73e ("arm64: Add irq aff change check For aarch64, ...")
Fixes: https://bugzilla.redhat.com/show_bug.cgi?id=2184735
Signed-off-by: Robin Jarry <rjarry@redhat.com>
---
activate.c | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/activate.c b/activate.c
index 6f8af27..a4112e0 100644
--- a/activate.c
+++ b/activate.c
@@ -75,16 +75,16 @@ static void activate_mapping(struct irq_info *info, void *data __attribute__((un
sprintf(buf, "/proc/irq/%i/smp_affinity", info->irq);
file = fopen(buf, "w");
if (!file)
- return;
+ goto error;
cpumask_scnprintf(buf, PATH_MAX, applied_mask);
ret = fprintf(file, "%s", buf);
- if (ret < 0) {
- log(TO_ALL, LOG_WARNING, "cannot change IRQ %i affinity, will never try again\n", info->irq);
- info->flags |= IRQ_FLAG_AFFINITY_UNMANAGED;
- }
- fclose(file);
+ if (fclose(file) || ret < 0)
+ goto error;
info->moved = 0; /*migration is done*/
+error:
+ log(TO_ALL, LOG_WARNING, "cannot change IRQ %i affinity, will never try again\n", info->irq);
+ info->flags |= IRQ_FLAG_AFFINITY_UNMANAGED;
}
void activate_mappings(void)
--
2.40.1

View File

@ -1,74 +0,0 @@
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 04/13] procinterrupts: Fix IRQ name parsing on certain arm64
SoC
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.1

View File

@ -1,64 +0,0 @@
From 9a1fd29a82c9762c3676f613075d44a8d1fcbe82 Mon Sep 17 00:00:00 2001
From: Robin Jarry <rjarry@redhat.com>
Date: Wed, 12 Jul 2023 08:59:45 +0200
Subject: [PATCH 5/7] activate_mapping: report error reason
If a given IRQ affinity cannot be set, include strerror in the warning
message.
Fixes: https://bugzilla.redhat.com/show_bug.cgi?id=2184735
Signed-off-by: Robin Jarry <rjarry@redhat.com>
---
activate.c | 15 ++++++++++++---
1 file changed, 12 insertions(+), 3 deletions(-)
diff --git a/activate.c b/activate.c
index a4112e0..4418cda 100644
--- a/activate.c
+++ b/activate.c
@@ -25,10 +25,12 @@
* of interrupts to the kernel.
*/
#include "config.h"
+#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <stdint.h>
+#include <string.h>
#include "irqbalance.h"
@@ -48,7 +50,7 @@ static void activate_mapping(struct irq_info *info, void *data __attribute__((un
{
char buf[PATH_MAX];
FILE *file;
- int ret = 0;
+ int errsave, ret;
cpumask_t applied_mask;
/*
@@ -79,11 +81,18 @@ static void activate_mapping(struct irq_info *info, void *data __attribute__((un
cpumask_scnprintf(buf, PATH_MAX, applied_mask);
ret = fprintf(file, "%s", buf);
- if (fclose(file) || ret < 0)
+ errsave = errno;
+ if (fclose(file)) {
+ errsave = errno;
+ goto error;
+ }
+ if (ret < 0)
goto error;
info->moved = 0; /*migration is done*/
error:
- log(TO_ALL, LOG_WARNING, "cannot change IRQ %i affinity, will never try again\n", info->irq);
+ log(TO_ALL, LOG_WARNING,
+ "Cannot change IRQ %i affinity: %s. Will never try again.\n",
+ info->irq, strerror(errsave));
info->flags |= IRQ_FLAG_AFFINITY_UNMANAGED;
}
--
2.40.1

View File

@ -1,27 +0,0 @@
From ac4ba0667ba691985796f92e1a4b1932b03895a0 Mon Sep 17 00:00:00 2001
From: qyu <qinyu32@huawei.com>
Date: Fri, 20 Jan 2023 15:29:45 +0800
Subject: [PATCH 05/13] irqbalance: fix memory leak in irq hotplug path
tmp_info.name duplicate a name string in init_irq_class_and_type(),
free() it before return.
---
classify.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/classify.c b/classify.c
index 4ea4b44..dac813c 100644
--- a/classify.c
+++ b/classify.c
@@ -778,6 +778,8 @@ int proc_irq_hotplug(char *savedline, int irq, struct irq_info **pinfo)
/* secondly, init irq info by parse savedline */
init_irq_class_and_type(savedline, &tmp_info, irq);
add_new_irq(NULL, &tmp_info);
+ free(tmp_info.name);
+
*pinfo = get_irq_info(irq);
}
if (*pinfo == NULL) {
--
2.33.1

View File

@ -1,51 +0,0 @@
From eee7917ef5272691b9d4ee6341463f3c78f7f909 Mon Sep 17 00:00:00 2001
From: Robin Jarry <rjarry@redhat.com>
Date: Wed, 12 Jul 2023 17:49:13 +0200
Subject: [PATCH 6/7] activate_mapping: only blacklist irq if error is
considered permanent
Some errors reported when writing to smp_affinity are transient. For
example, when a CPU interrupt controller does not have enough room to
map the IRQ, the kernel will return "No space left on device".
This kind of situation can change over time. Do not mark the IRQ
affinity as "unmanaged". Let irqbalance try again later.
Signed-off-by: Robin Jarry <rjarry@redhat.com>
---
activate.c | 18 ++++++++++++++++--
1 file changed, 16 insertions(+), 2 deletions(-)
diff --git a/activate.c b/activate.c
index 4418cda..7353692 100644
--- a/activate.c
+++ b/activate.c
@@ -91,9 +91,23 @@ static void activate_mapping(struct irq_info *info, void *data __attribute__((un
info->moved = 0; /*migration is done*/
error:
log(TO_ALL, LOG_WARNING,
- "Cannot change IRQ %i affinity: %s. Will never try again.\n",
+ "Cannot change IRQ %i affinity: %s\n",
info->irq, strerror(errsave));
- info->flags |= IRQ_FLAG_AFFINITY_UNMANAGED;
+ switch (errsave) {
+ case ENOSPC: /* Specified CPU APIC is full. */
+ case EAGAIN: /* Interrupted by signal. */
+ case EBUSY: /* Affinity change already in progress. */
+ case EINVAL: /* IRQ would be bound to no CPU. */
+ case ERANGE: /* CPU in mask is offline. */
+ case ENOMEM: /* Kernel cannot allocate CPU mask. */
+ /* Do not blacklist the IRQ on transient errors. */
+ break;
+ default:
+ /* Any other error is considered permanent. */
+ info->flags |= IRQ_FLAG_AFFINITY_UNMANAGED;
+ log(TO_ALL, LOG_WARNING, "IRQ %i affinity is now unmanaged\n",
+ info->irq);
+ }
}
void activate_mappings(void)
--
2.40.1

View File

@ -1,90 +0,0 @@
From f85c6c12d6fd9014d54cd0e3d791223723a29cdd Mon Sep 17 00:00:00 2001
From: Alexander Monakov <amonakov@ispras.ru>
Date: Sat, 21 Jan 2023 12:25:25 +0300
Subject: [PATCH 06/13] ui: do not force black background
Avoid repainting the entire terminal window with black background.
Instead, invoke 'use_default_colors' and use color index -1 to keep
user-configured background and foreground colors.
For pairs 1, 2, 3, 8, 9, 10, simply change background index to -1.
Keep pair 4, but enable the 'bold' attribute for text to improve
legibility. For pair 5 (white on red) use default foreground, and
instead of pair 6 (red on white) use reverse of pair 5 with bold.
This substantially improves legibility of the UI on a terminal
configured with a light background for me.
---
ui/ui.c | 27 ++++++++++++++-------------
1 file changed, 14 insertions(+), 13 deletions(-)
diff --git a/ui/ui.c b/ui/ui.c
index 897371b..bee6868 100644
--- a/ui/ui.c
+++ b/ui/ui.c
@@ -45,7 +45,7 @@ void show_footer()
while(strlen(footer) != (size_t)COLS - 1) {
snprintf(footer + strlen(footer), COLS - strlen(footer), " ");
}
- attrset(COLOR_PAIR(4));
+ attrset(COLOR_PAIR(4) | A_BOLD);
mvprintw(LINES - 1, 0, "%s", footer);
}
@@ -73,7 +73,7 @@ char * check_control_in_sleep_input(int max_len, int column_offest, int line_off
mvaddch(line_offset, column_offest + iteration, ' ');
}
move(line_offset, column_offest + iteration);
- attrset(COLOR_PAIR(6));
+ attrset(COLOR_PAIR(5) | A_REVERSE | A_BOLD);
break;
case 27:
free(input_to);
@@ -93,7 +93,7 @@ int get_valid_sleep_input(int column_offest)
while(1) {
attrset(COLOR_PAIR(5));
mvprintw(2, column_offest, " ");
- attrset(COLOR_PAIR(6));
+ attrset(COLOR_PAIR(5) | A_REVERSE | A_BOLD);
refresh();
move(2, column_offest);
curs_set(1);
@@ -115,7 +115,7 @@ int get_valid_sleep_input(int column_offest)
break;
} else {
new_sleep = setup.sleep;
- attrset(COLOR_PAIR(4));
+ attrset(COLOR_PAIR(4) | A_BOLD);
mvprintw(LINES - 2, 1,
"Invalid input: %s ",
input);
@@ -705,16 +705,17 @@ void init()
echo();
if(has_colors()) {
start_color();
- init_pair(1, COLOR_RED, COLOR_BLACK);
- init_pair(2, COLOR_YELLOW, COLOR_BLACK);
- init_pair(3, COLOR_GREEN, COLOR_BLACK);
+ use_default_colors();
+ init_pair(1, COLOR_RED, -1);
+ init_pair(2, COLOR_YELLOW, -1);
+ init_pair(3, COLOR_GREEN, -1);
init_pair(4, COLOR_WHITE, COLOR_BLUE);
- init_pair(5, COLOR_WHITE, COLOR_RED);
- init_pair(6, COLOR_RED, COLOR_WHITE);
- init_pair(7, COLOR_BLACK, COLOR_CYAN);
- init_pair(8, COLOR_BLUE, COLOR_BLACK);
- init_pair(9, COLOR_CYAN, COLOR_BLACK);
- init_pair(10, COLOR_MAGENTA, COLOR_BLACK);
+ init_pair(5, -1, COLOR_RED);
+ /* Pair 6 is unused */
+ /* Pair 7 is unused */
+ init_pair(8, COLOR_BLUE, -1);
+ init_pair(9, COLOR_CYAN, -1);
+ init_pair(10, COLOR_MAGENTA, -1);
}
offset = 0;
--
2.33.1

View File

@ -1,28 +0,0 @@
From bc7794dc78474c463a26926749537f23abc4c082 Mon Sep 17 00:00:00 2001
From: Robin Jarry <rjarry@redhat.com>
Date: Thu, 13 Jul 2023 20:49:16 +0200
Subject: [PATCH 7/7] activate_mapping: avoid logging error when there is none
Add missing return statement.
Fixes: 470a64b19062 ("activate_mapping: make sure to catch all errors")
Signed-off-by: Robin Jarry <rjarry@redhat.com>
---
activate.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/activate.c b/activate.c
index 7353692..548a401 100644
--- a/activate.c
+++ b/activate.c
@@ -89,6 +89,7 @@ static void activate_mapping(struct irq_info *info, void *data __attribute__((un
if (ret < 0)
goto error;
info->moved = 0; /*migration is done*/
+ return;
error:
log(TO_ALL, LOG_WARNING,
"Cannot change IRQ %i affinity: %s\n",
--
2.40.1

View File

@ -1,30 +0,0 @@
From c91bdf66e1156db0e8171a72a15b6d63148357e4 Mon Sep 17 00:00:00 2001
From: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Date: Tue, 24 Jan 2023 11:47:44 -0800
Subject: [PATCH 07/13] thermal: Fix log message for perf and efficiency
In the log message perf and efficiency fields are swapped. So, showing
perf field as efficiency and vice versa. Fix this to show correct
log message.
Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
---
thermal.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/thermal.c b/thermal.c
index 7cd0807..a45568a 100644
--- a/thermal.c
+++ b/thermal.c
@@ -407,7 +407,7 @@ static int handle_thermal_event(struct nl_msg *msg, void *arg __attribute__((unu
need_to_ban = !!(!event_data[INDEX_PERF] && !event_data[INDEX_EFFI]);
update_banned_cpus(cur_cpuidx, need_to_ban);
- log(TO_ALL, LOG_DEBUG, "thermal: event - CPU %d, efficiency %d, perf %d.\n",
+ log(TO_ALL, LOG_DEBUG, "thermal: event - CPU %d, perf %d, efficiency %d.\n",
cur_cpuidx, event_data[INDEX_PERF], event_data[INDEX_EFFI]);
}
--
2.33.1

View File

@ -1,25 +0,0 @@
From f166b00e732033bf0b6ea86cedc2dcea7f6c35ba Mon Sep 17 00:00:00 2001
From: middlingphys <phys314159265358979chem@gmail.com>
Date: Thu, 2 Feb 2023 16:17:38 +0900
Subject: [PATCH 08/13] fix CPU number condition in service file
---
misc/irqbalance.service | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/misc/irqbalance.service b/misc/irqbalance.service
index 8544f66..a2d919c 100644
--- a/misc/irqbalance.service
+++ b/misc/irqbalance.service
@@ -3,7 +3,7 @@ Description=irqbalance daemon
Documentation=man:irqbalance(1)
Documentation=https://github.com/Irqbalance/irqbalance
ConditionVirtualization=!container
-ConditionCPUs=>1
+ConditionCPUs>1
[Service]
EnvironmentFile=-/usr/lib/irqbalance/defaults.env
--
2.33.1

View File

@ -1,35 +0,0 @@
From 0e9acb608588aaeb998bdf5f47019ce7a61cc81e Mon Sep 17 00:00:00 2001
From: Neil Horman <neil.horman@privafy.com>
Date: Thu, 9 Mar 2023 07:54:47 -0500
Subject: [PATCH 09/13] Issue 259: select NL_SKIP / NL_STOP based on error
the handle_error function for thermal should skip EINTR errors, but stop
for everything else
---
thermal.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/thermal.c b/thermal.c
index a45568a..035e0ad 100644
--- a/thermal.c
+++ b/thermal.c
@@ -190,12 +190,14 @@ static int handle_groupid(struct nl_msg *msg, void *arg)
static int handle_error(struct sockaddr_nl *sk_addr __attribute__((unused)),
struct nlmsgerr *err, void *arg)
{
- if (arg) {
+ int rc = (err->error == NLE_INTR) ? NL_SKIP : NL_STOP;
+
+ if (arg && err->error != NLE_INTR) {
log(TO_ALL, LOG_INFO, "thermal: received a netlink error (%s).\n",
nl_geterror(err->error));
*((int *)arg) = err->error;
}
- return NL_SKIP;
+ return rc;
}
static int handle_end(struct nl_msg *msg __attribute__((unused)), void *arg)
--
2.33.1

View File

@ -1,25 +0,0 @@
From ea1e9a7a9105c834302ce7c72e9b4b1c90ec7866 Mon Sep 17 00:00:00 2001
From: middlingphys <38708390+middlingphys@users.noreply.github.com>
Date: Wed, 15 Mar 2023 22:33:22 +0900
Subject: [PATCH 10/13] Revert "Fix CPU number condition in service file"
---
misc/irqbalance.service | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/misc/irqbalance.service b/misc/irqbalance.service
index a2d919c..8544f66 100644
--- a/misc/irqbalance.service
+++ b/misc/irqbalance.service
@@ -3,7 +3,7 @@ Description=irqbalance daemon
Documentation=man:irqbalance(1)
Documentation=https://github.com/Irqbalance/irqbalance
ConditionVirtualization=!container
-ConditionCPUs>1
+ConditionCPUs=>1
[Service]
EnvironmentFile=-/usr/lib/irqbalance/defaults.env
--
2.33.1

View File

@ -1,28 +0,0 @@
From 3920e0687deff04c52ac73ebdbd950c13ef1f77e Mon Sep 17 00:00:00 2001
From: Neil Horman <neil.horman@privafy.com>
Date: Wed, 22 Mar 2023 17:30:01 -0400
Subject: [PATCH 11/13] Fix signedness of error handling
---
thermal.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/thermal.c b/thermal.c
index 035e0ad..902d7e9 100644
--- a/thermal.c
+++ b/thermal.c
@@ -190,9 +190,9 @@ static int handle_groupid(struct nl_msg *msg, void *arg)
static int handle_error(struct sockaddr_nl *sk_addr __attribute__((unused)),
struct nlmsgerr *err, void *arg)
{
- int rc = (err->error == NLE_INTR) ? NL_SKIP : NL_STOP;
+ int rc = (err->error == -NLE_INTR) ? NL_SKIP : NL_STOP;
- if (arg && err->error != NLE_INTR) {
+ if (arg && err->error != -NLE_INTR) {
log(TO_ALL, LOG_INFO, "thermal: received a netlink error (%s).\n",
nl_geterror(err->error));
*((int *)arg) = err->error;
--
2.33.1

View File

@ -1,26 +0,0 @@
From 0e051271bbf1cd87802628f3167faafe7218606f Mon Sep 17 00:00:00 2001
From: Neil Horman <neil.horman@privafy.com>
Date: Sat, 1 Apr 2023 13:07:05 -0400
Subject: [PATCH 12/13] Fix it so we actually stop when we hit an interrupt
condition
---
thermal.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/thermal.c b/thermal.c
index 902d7e9..ffff9bd 100644
--- a/thermal.c
+++ b/thermal.c
@@ -190,7 +190,7 @@ static int handle_groupid(struct nl_msg *msg, void *arg)
static int handle_error(struct sockaddr_nl *sk_addr __attribute__((unused)),
struct nlmsgerr *err, void *arg)
{
- int rc = (err->error == -NLE_INTR) ? NL_SKIP : NL_STOP;
+ int rc = (err->error == -NLE_INTR) ? NL_STOP : NL_SKIP;
if (arg && err->error != -NLE_INTR) {
log(TO_ALL, LOG_INFO, "thermal: received a netlink error (%s).\n",
--
2.33.1

View File

@ -1,37 +0,0 @@
From d02ec54e635da8da8439d35b0523ce2b5d5dbae1 Mon Sep 17 00:00:00 2001
From: psykose <alice@ayaya.dev>
Date: Wed, 19 Apr 2023 19:31:19 +0000
Subject: [PATCH 13/13] procinterrupts: fix initialisation of regex_t struct
{NULL} utilises the null pointer, but this is not valid, because null is a pointer:
procinterrupts.c:110:29: error: initialization of 'long unsigned int' from 'void *' makes integer from pointer without a cast [-Werror=int-conversion]
110 | { "eth.*" ,{NULL} ,NULL, IRQ_TYPE_LEGACY, IRQ_GBETH },
0-initialisation should be done with '0' instead of a pointer.
---
procinterrupts.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/procinterrupts.c b/procinterrupts.c
index ec7a52b..dfa95c6 100644
--- a/procinterrupts.c
+++ b/procinterrupts.c
@@ -107,10 +107,10 @@ static void guess_arm_irq_hints(char *name, struct irq_info *info)
static int compiled = 0;
/* Note: Last entry is a catchall */
static struct irq_match matches[] = {
- { "eth.*" ,{NULL} ,NULL, IRQ_TYPE_LEGACY, IRQ_GBETH },
- { "[A-Z0-9]{4}[0-9a-f]{4}", {NULL} ,check_platform_device, IRQ_TYPE_LEGACY, IRQ_OTHER},
- { "PNP[0-9a-f]{4}", {NULL} ,check_platform_device, IRQ_TYPE_LEGACY, IRQ_OTHER},
- { ".*", {NULL}, NULL, IRQ_TYPE_LEGACY, IRQ_OTHER},
+ { "eth.*" , {0},NULL, IRQ_TYPE_LEGACY, IRQ_GBETH },
+ { "[A-Z0-9]{4}[0-9a-f]{4}", {0}, check_platform_device, IRQ_TYPE_LEGACY, IRQ_OTHER},
+ { "PNP[0-9a-f]{4}", {0}, check_platform_device, IRQ_TYPE_LEGACY, IRQ_OTHER},
+ { ".*", {0}, NULL, IRQ_TYPE_LEGACY, IRQ_OTHER},
{NULL},
};
--
2.33.1

View File

@ -18,9 +18,8 @@ index 0f79c3e..9bc63b6 100644
-EnvironmentFile=-/usr/lib/irqbalance/defaults.env
-EnvironmentFile=-/path/to/irqbalance.env
+EnvironmentFile=-/etc/sysconfig/irqbalance
ExecStart=/usr/sbin/irqbalance --foreground $IRQBALANCE_ARGS
ReadOnlyPaths=/
ReadWritePaths=/proc/irq
ExecStart=/usr/sbin/irqbalance $IRQBALANCE_ARGS
CapabilityBoundingSet=
NoNewPrivileges=yes
--
2.37.1

View File

@ -1,6 +1,6 @@
Name: irqbalance
Version: 1.9.2
Release: 3%{?dist}
Version: 1.9.4
Release: 1%{?dist}
Epoch: 2
Summary: IRQ balancing daemon
@ -10,7 +10,7 @@ Source0: https://github.com/Irqbalance/irqbalance/archive/irqbalance-%{ve
BuildRequires: autoconf automake libtool libcap-ng
BuildRequires: glib2-devel pkgconf libcap-ng-devel
BuildRequires: systemd ncurses-devel
BuildRequires: systemd ncurses-devel systemd-devel
BuildRequires: make
Requires: ncurses-libs
%ifnarch %{arm}
@ -20,27 +20,10 @@ Requires: numactl-libs
ExcludeArch: s390 s390x
Patch1: 0001-optimize-getting-cpu-number.patch
Patch2: 0002-allow-AF_NETLINK-in-the-systemd-service-restrictions.patch
Patch3: 0003-thermal-Fix-the-warning-message.patch
Patch4: 0004-procinterrupts-Fix-IRQ-name-parsing-on-certain-arm64.patch
Patch5: 0005-irqbalance-fix-memory-leak-in-irq-hotplug-path.patch
Patch6: 0006-ui-do-not-force-black-background.patch
Patch7: 0007-thermal-Fix-log-message-for-perf-and-efficiency.patch
Patch8: 0008-fix-CPU-number-condition-in-service-file.patch
Patch9: 0009-Issue-259-select-NL_SKIP-NL_STOP-based-on-error.patch
Patch10: 0010-Revert-Fix-CPU-number-condition-in-service-file.patch
Patch11: 0011-Fix-signedness-of-error-handling.patch
Patch12: 0012-Fix-it-so-we-actually-stop-when-we-hit-an-interrupt-.patch
Patch13: 0013-procinterrupts-fix-initialisation-of-regex_t-struct.patch
Patch14: irqbalance-1.9.0-environment-file-sysconfig.patch
Patch15: 0001-activate_mapping-fflush-the-buffered-data-to-smp_aff.patch
Patch16: 0002-Revert-activate_mapping-fflush-the-buffered-data-to-.patch
Patch17: 0003-activate_mapping-avoid-use-after-free-when-affinity-.patch
Patch18: 0004-activate_mapping-make-sure-to-catch-all-errors.patch
Patch19: 0005-activate_mapping-report-error-reason.patch
Patch20: 0006-activate_mapping-only-blacklist-irq-if-error-is-cons.patch
Patch21: 0007-activate_mapping-avoid-logging-error-when-there-is-n.patch
Patch1: irqbalance-1.9.0-environment-file-sysconfig.patch
Patch2: 0001-irqbalance-ui-check-if-using-a-negative-index-of-buf.patch
Patch3: 0002-Check-fflush-return-value.patch
Patch4: 0003-Drop-ProtectKernelTunables.patch
%description
irqbalance is a daemon that evenly distributes IRQ load across
@ -51,7 +34,7 @@ multiple CPUs for enhanced performance.
%build
./autogen.sh
%configure
%configure --with-systemd
%{make_build}
%install
@ -83,6 +66,9 @@ make check
%systemd_postun_with_restart irqbalance.service
%changelog
* Wed May 01 2024 Tao Liu <ltao@redhat.com> - 2:1.9.4-1
- Rebase to upstream commit (f2c8309a41)
* Fri Jul 28 2023 Tao Liu <ltao@redhat.com> - 2:1.9.2-3
- Use misc/irqbalance.env as irqbalance.sysconfig
- Use new rpm macros: autosetup and make_build

View File

@ -1 +1 @@
SHA512 (irqbalance-1.9.2.tar.gz) = d0fb157fbfc096fa9cfb4562e51fd4c3f4fa8788f72377c58b27df67c70073b787bba05e39809dcbe17532bb5b8e74b6d27c5e5b3d9af09bc9ce1a9b6aab9378
SHA512 (irqbalance-1.9.4.tar.gz) = abdcac9dccabb18ae644b73dc2a8528c03279811c1f9182a5a5b0af43b30c5982d7bb14e79d4430b5d4f2cea8e17115e6038851c74de1ff3bdfc4e303392479a