Compare commits
10 Commits
d8447c23b4
...
389a7dd312
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
389a7dd312 | ||
|
|
50a1840c61 | ||
|
|
62c92e588a | ||
|
|
a222ee5842 | ||
|
|
1ec6151e49 | ||
|
|
218abebe55 | ||
|
|
0b340fba64 | ||
|
|
f5cd8c4e0c | ||
|
|
7a850d304b | ||
|
|
ef8824010d |
@ -0,0 +1,151 @@
|
||||
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 1/5] activate_mapping: avoid use-after-free when affinity
|
||||
cannot be set
|
||||
|
||||
Conflict: 725d9b12888f0dcfce5038c24e2015a10b36a4e9 commit modified
|
||||
check_for_irq_ban input paras in function parse_user_policy_key(),so
|
||||
we modified this patch ensure that the patch can be installed.
|
||||
The details are as follows:
|
||||
check_for_irq_ban(hint,mod) changed to check_for_irq_ban(irq,
|
||||
proc_interrupts)
|
||||
|
||||
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 105ecd6..6242e6c 100644
|
||||
--- a/classify.c
|
||||
+++ b/classify.c
|
||||
@@ -256,7 +256,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;
|
||||
@@ -280,14 +280,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)
|
||||
@@ -386,23 +381,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;
|
||||
@@ -612,7 +590,7 @@ static void add_new_irq(char *path, struct irq_info *hint, GList *proc_interrupt
|
||||
/* 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(irq, proc_interrupts)) { /*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.33.0
|
||||
|
||||
@ -0,0 +1,48 @@
|
||||
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 2/5] 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.33.0
|
||||
|
||||
64
backport-0003-activate_mapping-report-error-reason.patch
Normal file
64
backport-0003-activate_mapping-report-error-reason.patch
Normal file
@ -0,0 +1,64 @@
|
||||
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 3/5] 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.33.0
|
||||
|
||||
@ -0,0 +1,51 @@
|
||||
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 4/5] 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.33.0
|
||||
|
||||
@ -0,0 +1,28 @@
|
||||
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 5/5] 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.33.0
|
||||
|
||||
@ -0,0 +1,40 @@
|
||||
From b4c377148dda6f10a5c25be535513eeab236141f Mon Sep 17 00:00:00 2001
|
||||
From: =?UTF-8?q?Stefan=20Br=C3=BCns?= <stefan.bruens@rwth-aachen.de>
|
||||
Date: Wed, 13 Dec 2023 20:09:34 +0100
|
||||
Subject: [PATCH] Avoid repeated affinity checks when no change is necessary
|
||||
|
||||
An IRQ may be migrated several times during one loop iteration, and end
|
||||
up with the same CPU affinity mask as before - the "moved" flag is merely
|
||||
a hint a affinity change may be necessary. This notably also happens
|
||||
during initial placement, but may happen also anytime later.
|
||||
|
||||
To avoid visiting each IRQ again and again unset the "moved" flag. This
|
||||
avoids the open/stat/read/close syscalls for unchanged interrupts.
|
||||
|
||||
Fixes: #285
|
||||
|
||||
Reference: https://github.com/Irqbalance/irqbalance/commit/b4c377148dda6f10a5c25be535513eeab236141f
|
||||
Conflict: NA
|
||||
---
|
||||
activate.c | 4 +++-
|
||||
1 file changed, 3 insertions(+), 1 deletion(-)
|
||||
|
||||
diff --git a/activate.c b/activate.c
|
||||
index 4830f34..724fbd5 100644
|
||||
--- a/activate.c
|
||||
+++ b/activate.c
|
||||
@@ -68,8 +68,10 @@ static void activate_mapping(struct irq_info *info, void *data __attribute__((un
|
||||
/*
|
||||
* Don't activate anything for which we have an invalid mask
|
||||
*/
|
||||
- if (check_affinity(info, applied_mask))
|
||||
+ if (check_affinity(info, applied_mask)) {
|
||||
+ info->moved = 0; /* nothing to do, mark as done */
|
||||
return;
|
||||
+ }
|
||||
|
||||
sprintf(buf, "/proc/irq/%i/smp_affinity", info->irq);
|
||||
file = fopen(buf, "w");
|
||||
--
|
||||
2.28.0.windows.1
|
||||
|
||||
44
backport-Check-fflush-return-value.patch
Normal file
44
backport-Check-fflush-return-value.patch
Normal file
@ -0,0 +1,44 @@
|
||||
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] 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")
|
||||
|
||||
Reference:https://github.com/Irqbalance/irqbalance/commit/8301666f3029ff4d9089a273a45ec47671d964c1
|
||||
Conflict:NA
|
||||
---
|
||||
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.28.0.windows.1
|
||||
|
||||
56
backport-Fix-socket-API-being-blocked-for-10s.patch
Normal file
56
backport-Fix-socket-API-being-blocked-for-10s.patch
Normal file
@ -0,0 +1,56 @@
|
||||
From de0fe4a799c0bd62afcaf11b0ff5fc85f0b24c3e Mon Sep 17 00:00:00 2001
|
||||
From: Etienne Champetier <e.champetier@ateme.com>
|
||||
Date: Wed, 13 Mar 2024 15:28:37 -0400
|
||||
Subject: [PATCH] Fix socket API being blocked for 10s
|
||||
|
||||
Instead of sleeping in scan() and blocking the main loop,
|
||||
return and let the main loop call back scan().
|
||||
|
||||
Signed-off-by: Etienne Champetier <e.champetier@ateme.com>
|
||||
|
||||
Reference:https://github.com/Irqbalance/irqbalance/commit/de0fe4a799c0bd62afcaf11b0ff5fc85f0b24c3e
|
||||
Conflict:The pre-dependency patch is not incorporated(4342acd8d7862e862e0b6611
|
||||
35b10671ffeac119), adapt the patch context.
|
||||
---
|
||||
irqbalance.c | 18 +-----------------
|
||||
1 file changed, 1 insertion(+), 17 deletions(-)
|
||||
|
||||
diff --git a/irqbalance.c b/irqbalance.c
|
||||
index f5f2c51..12302d7 100644
|
||||
--- a/irqbalance.c
|
||||
+++ b/irqbalance.c
|
||||
@@ -70,20 +70,6 @@ char *cpu_ban_string = NULL;
|
||||
char *banned_cpumask_from_ui = NULL;
|
||||
unsigned long migrate_ratio = 0;
|
||||
|
||||
-static void sleep_approx(int seconds)
|
||||
-{
|
||||
- struct timespec ts;
|
||||
- struct timeval tv;
|
||||
- gettimeofday(&tv, NULL);
|
||||
- ts.tv_sec = seconds;
|
||||
- ts.tv_nsec = -tv.tv_usec*1000;
|
||||
- while (ts.tv_nsec < 0) {
|
||||
- ts.tv_sec--;
|
||||
- ts.tv_nsec += 1000000000;
|
||||
- }
|
||||
- nanosleep(&ts, NULL);
|
||||
-}
|
||||
-
|
||||
#ifdef HAVE_GETOPT_LONG
|
||||
struct option lopts[] = {
|
||||
{"oneshot", 0, NULL, 'o'},
|
||||
@@ -317,9 +303,7 @@ gboolean scan(gpointer data __attribute__((unused)))
|
||||
for_each_irq(NULL, force_rebalance_irq, NULL);
|
||||
parse_proc_interrupts();
|
||||
parse_proc_stat();
|
||||
- sleep_approx(sleep_interval);
|
||||
- clear_work_stats();
|
||||
- parse_proc_interrupts();
|
||||
+ return TRUE;
|
||||
}
|
||||
|
||||
parse_proc_stat();
|
||||
--
|
||||
2.28.0.windows.1
|
||||
|
||||
31
backport-Flush-file-before-closing.patch
Normal file
31
backport-Flush-file-before-closing.patch
Normal file
@ -0,0 +1,31 @@
|
||||
From 8d7c78304fb994a519e2709024b196841e84238a Mon Sep 17 00:00:00 2001
|
||||
From: Robert Malz <robert.malz@canonical.com>
|
||||
Date: Thu, 14 Mar 2024 13:36:15 +0100
|
||||
Subject: [PATCH] Flush file before closing
|
||||
|
||||
After writing to file, before closing, flush is required.
|
||||
Without it fclose can randomly return IO error.
|
||||
|
||||
Signed-off-by: Robert Malz <robert.malz@canonical.com>
|
||||
|
||||
Reference:https://github.com/Irqbalance/irqbalance/commit/8d7c78304fb994a519e2709024b196841e84238a
|
||||
Conflict:NA
|
||||
---
|
||||
activate.c | 1 +
|
||||
1 file changed, 1 insertion(+)
|
||||
|
||||
diff --git a/activate.c b/activate.c
|
||||
index d3f99f7..e30d0f0 100644
|
||||
--- a/activate.c
|
||||
+++ b/activate.c
|
||||
@@ -82,6 +82,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);
|
||||
errsave = errno;
|
||||
+ fflush(file);
|
||||
if (fclose(file)) {
|
||||
errsave = errno;
|
||||
goto error;
|
||||
--
|
||||
2.28.0.windows.1
|
||||
|
||||
@ -0,0 +1,82 @@
|
||||
From ad0ea2c4c09d6aa76e6c3f87587047cbaddf254e Mon Sep 17 00:00:00 2001
|
||||
From: StefanBruens <stefan.bruens@rwth-aachen.de>
|
||||
Date: Wed, 13 Dec 2023 01:28:59 +0100
|
||||
Subject: [PATCH] Slience "... rebalancing" messages for unmigratable IRQs
|
||||
|
||||
It is fairly pointless to try migrating an IRQ which is known
|
||||
to be unmigratable.
|
||||
|
||||
Instead of using an extra flag, set the `level` to BALANCE_NONE,
|
||||
which shortcuts quite some code, and implicitly also disables
|
||||
the misleading repeated log message:
|
||||
|
||||
```
|
||||
Dez 10 02:52:55 varm irqbalance[828]: Selecting irq 75 for rebalancing
|
||||
Dez 10 02:52:55 varm irqbalance[828]: Cannot change IRQ 75 affinity: Input/output error
|
||||
Dez 10 02:52:55 varm irqbalance[828]: IRQ 75 affinity is now unmanaged
|
||||
...
|
||||
Dez 10 02:52:55 varm irqbalance[828]: Selecting irq 75 for rebalancing
|
||||
...
|
||||
Dez 10 02:52:55 varm irqbalance[828]: Selecting irq 75 for rebalancing
|
||||
```
|
||||
|
||||
Reference: https://github.com/Irqbalance/irqbalance/commit/ad0ea2c4c09d6aa76e6c3f87587047cbaddf254e
|
||||
Conflict: NA
|
||||
---
|
||||
activate.c | 6 ++----
|
||||
irqlist.c | 2 +-
|
||||
types.h | 1 -
|
||||
3 files changed, 3 insertions(+), 6 deletions(-)
|
||||
|
||||
diff --git a/activate.c b/activate.c
|
||||
index 548a401..4830f34 100644
|
||||
--- a/activate.c
|
||||
+++ b/activate.c
|
||||
@@ -62,9 +62,6 @@ 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);
|
||||
|
||||
@@ -105,7 +102,8 @@ error:
|
||||
break;
|
||||
default:
|
||||
/* Any other error is considered permanent. */
|
||||
- info->flags |= IRQ_FLAG_AFFINITY_UNMANAGED;
|
||||
+ info->level = BALANCE_NONE;
|
||||
+ info->moved = 0; /* migration impossible, mark as done */
|
||||
log(TO_ALL, LOG_WARNING, "IRQ %i affinity is now unmanaged\n",
|
||||
info->irq);
|
||||
}
|
||||
diff --git a/irqlist.c b/irqlist.c
|
||||
index 4dd4a83..0ba411e 100644
|
||||
--- a/irqlist.c
|
||||
+++ b/irqlist.c
|
||||
@@ -78,7 +78,7 @@ static void move_candidate_irqs(struct irq_info *info, void *data)
|
||||
struct load_balance_info *lb_info = data;
|
||||
unsigned long delta_load = 0;
|
||||
|
||||
- /* Don't rebalance irqs that don't want it */
|
||||
+ /* Don't rebalance irqs that don't want or support it */
|
||||
if (info->level == BALANCE_NONE)
|
||||
return;
|
||||
|
||||
diff --git a/types.h b/types.h
|
||||
index c63cfea..ea1fae8 100644
|
||||
--- a/types.h
|
||||
+++ b/types.h
|
||||
@@ -35,7 +35,6 @@
|
||||
* IRQ Internal tracking flags
|
||||
*/
|
||||
#define IRQ_FLAG_BANNED (1ULL << 0)
|
||||
-#define IRQ_FLAG_AFFINITY_UNMANAGED (1ULL << 1)
|
||||
|
||||
enum obj_type_e {
|
||||
OBJ_TYPE_CPU,
|
||||
--
|
||||
2.28.0.windows.1
|
||||
|
||||
@ -0,0 +1,29 @@
|
||||
From f4d987f82e64fd53ae5646d39b5174fb3cc572d2 Mon Sep 17 00:00:00 2001
|
||||
From: liuchao173 <liuchao173@huawei.com>
|
||||
Date: Fri, 29 Dec 2023 10:30:44 +0800
|
||||
Subject: [PATCH] activate_mapping: set errsave before first jump to the error
|
||||
label
|
||||
|
||||
if the fopen fails, errsave is used uninitialized
|
||||
|
||||
Reference: https://github.com/Irqbalance/irqbalance/commit/f4d987f82e64fd53ae5646d39b5174fb3cc572d2
|
||||
Conflict: NA
|
||||
---
|
||||
activate.c | 1 +
|
||||
1 file changed, 1 insertion(+)
|
||||
|
||||
diff --git a/activate.c b/activate.c
|
||||
index 4830f34..b08d4b0 100644
|
||||
--- a/activate.c
|
||||
+++ b/activate.c
|
||||
@@ -73,6 +73,7 @@ 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");
|
||||
+ errsave = errno;
|
||||
if (!file)
|
||||
goto error;
|
||||
|
||||
--
|
||||
2.28.0.windows.1
|
||||
|
||||
@ -0,0 +1,35 @@
|
||||
From d602002e1982a322d19034a4a64ca5a81bace7ef Mon Sep 17 00:00:00 2001
|
||||
From: Tao Liu <ltao@redhat.com>
|
||||
Date: Tue, 25 Feb 2025 16:35:34 +1300
|
||||
Subject: [PATCH] check_platform_device: Check the length of path
|
||||
|
||||
The default length of path is 512, but the strcat() is used without
|
||||
check if path is overflowed, otherwise a segfault is observed on
|
||||
some aarch64 machines. This patch will use snprintf instead of strcat
|
||||
for the buffer length checking.
|
||||
|
||||
Signed-off-by: Tao Liu <ltao@redhat.com>
|
||||
|
||||
Reference:https://github.com/Irqbalance/irqbalance/commit/d602002e1982a322d19034a4a64ca5a81bace7ef
|
||||
Conflict:NA
|
||||
---
|
||||
procinterrupts.c | 3 ++-
|
||||
1 file changed, 2 insertions(+), 1 deletion(-)
|
||||
|
||||
diff --git a/procinterrupts.c b/procinterrupts.c
|
||||
index 4d04bf2..e82fac7 100644
|
||||
--- a/procinterrupts.c
|
||||
+++ b/procinterrupts.c
|
||||
@@ -72,7 +72,8 @@ static int check_platform_device(char *name, struct irq_info *info)
|
||||
memset(path, 0, 512);
|
||||
|
||||
strcat(path, "/sys/devices/platform/");
|
||||
- strcat(path, name);
|
||||
+ snprintf(path + strlen(path), sizeof(path) - strlen(path) - 1,
|
||||
+ "%s", name);
|
||||
strcat(path, "/");
|
||||
dirfd = opendir(path);
|
||||
|
||||
--
|
||||
2.28.0.windows.1
|
||||
|
||||
@ -0,0 +1,30 @@
|
||||
From f3282f4ddc10be44e6c423de6de8db600f748f85 Mon Sep 17 00:00:00 2001
|
||||
From: Neil Horman <nhorman@openssl.org>
|
||||
Date: Thu, 30 Nov 2023 16:55:30 -0500
|
||||
Subject: [PATCH] filter console only output when using journal mode
|
||||
|
||||
Fixes #281
|
||||
|
||||
Reference: https://github.com/Irqbalance/irqbalance/commit/f3282f4ddc10be44e6c423de6de8db600f748f85
|
||||
Conflict: NA
|
||||
---
|
||||
irqbalance.h | 3 ++-
|
||||
1 file changed, 2 insertions(+), 1 deletion(-)
|
||||
|
||||
diff --git a/irqbalance.h b/irqbalance.h
|
||||
index 46e05ca..7b47cd1 100644
|
||||
--- a/irqbalance.h
|
||||
+++ b/irqbalance.h
|
||||
@@ -138,7 +138,8 @@ extern unsigned int log_mask;
|
||||
#ifdef HAVE_LIBSYSTEMD
|
||||
#define log(mask, lvl, fmt, args...) do { \
|
||||
if (journal_logging) { \
|
||||
- sd_journal_print(lvl, fmt, ##args); \
|
||||
+ if (log_mask & mask & TO_SYSLOG) \
|
||||
+ sd_journal_print(lvl, fmt, ##args); \
|
||||
if (log_mask & mask & TO_CONSOLE) \
|
||||
printf(fmt, ##args); \
|
||||
} else { \
|
||||
--
|
||||
2.28.0.windows.1
|
||||
|
||||
40
backport-remove-no-existing-irq-in-banned_irqs.patch
Normal file
40
backport-remove-no-existing-irq-in-banned_irqs.patch
Normal file
@ -0,0 +1,40 @@
|
||||
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
|
||||
---
|
||||
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
|
||||
@@ -847,8 +847,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)
|
||||
@@ -860,7 +868,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);
|
||||
}
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
Summary: A dynamic adaptive IRQ balancing daemon
|
||||
Name: irqbalance
|
||||
Version: 1.8.0
|
||||
Release: 9
|
||||
Release: 14
|
||||
Epoch: 3
|
||||
License: GPLv2
|
||||
Source0: https://github.com/Irqbalance/irqbalance/archive/v%{version}.tar.gz#/irqbalance-%{version}.tar.gz
|
||||
@ -29,6 +29,20 @@ 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
|
||||
Patch6008: backport-0001-activate_mapping-avoid-use-after-free-when-affinity-.patch
|
||||
Patch6009: backport-0002-activate_mapping-make-sure-to-catch-all-errors.patch
|
||||
Patch6010: backport-0003-activate_mapping-report-error-reason.patch
|
||||
Patch6011: backport-0004-activate_mapping-only-blacklist-irq-if-error-is-cons.patch
|
||||
Patch6012: backport-0005-activate_mapping-avoid-logging-error-when-there-is-n.patch
|
||||
Patch6013: backport-remove-no-existing-irq-in-banned_irqs.patch
|
||||
Patch6014: backport-filter-console-only-output-when-using-journal-mode.patch
|
||||
Patch6015: backport-Slience-.-rebalancing-messages-for-unmigratable-IRQs.patch
|
||||
Patch6016: backport-Avoid-repeated-affinity-checks-when-no-change-is-nec.patch
|
||||
Patch6017: backport-activate_mapping-set-errsave-before-first-jump-to-th.patch
|
||||
Patch6018: backport-Fix-socket-API-being-blocked-for-10s.patch
|
||||
Patch6019: backport-Flush-file-before-closing.patch
|
||||
Patch6020: backport-Check-fflush-return-value.patch
|
||||
Patch6021: backport-check_platform_device-Check-the-length-of-path.patch
|
||||
|
||||
%description
|
||||
Irqbalance is a daemon to help balance the cpu load generated by
|
||||
@ -86,6 +100,41 @@ fi
|
||||
/sbin/chkconfig --del %{name} >/dev/null 2>&1 || :
|
||||
|
||||
%changelog
|
||||
* Tue Mar 18 2025 langfei <langfei@huawei.com> - 3:1.8.0-14
|
||||
- Type:bugfix
|
||||
- ID:NA
|
||||
- SUG:restart
|
||||
- DESC: Check the length of path
|
||||
|
||||
* Tue May 07 2024 langfei <langfei@huawei.com> - 3:1.8.0-13
|
||||
- Type:bugfix
|
||||
- ID:NA
|
||||
- SUG:restart
|
||||
- DESC: Fix socket API being blocked for 10s;
|
||||
- Flush file brfore closing;
|
||||
- Check fflush() return value.
|
||||
|
||||
* Tue Feb 20 2024 langfei <langfei@huawei.com> - 3:1.8.0-12
|
||||
- Type:bugfix
|
||||
- ID:NA
|
||||
- SUG:restart
|
||||
- DESC: filter console only output when using journal mode;
|
||||
- Slience ... rebalancing messages for unmigratable IRQs;
|
||||
- Avoid repeated affinity checks when no change is necessary;
|
||||
- activate_mapping:set errsave before first jump to the error label.
|
||||
|
||||
* Sun Feb 04 2024 Paul Thomas <paulthomas100199@gmail.com> - 3:1.8.0-11
|
||||
- Type:bugfix
|
||||
- ID:NA
|
||||
- SUG:restart
|
||||
- DESC: remove no existing irq in banned_irqs
|
||||
|
||||
* Sun Oct 29 2023 volcanodragon <linfeilong@huawei.com> - 3:1.8.0-10
|
||||
- Type:bugfix
|
||||
- ID:NA
|
||||
- SUG:restart
|
||||
- DESC: fix activate_mapping bug
|
||||
|
||||
* Thu Dec 8 2022 qinyu <qinyu32@huawei.com> - 3:1.8.0-9
|
||||
- Type:bugfix
|
||||
- ID:NA
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user