Compare commits

...

10 Commits

Author SHA1 Message Date
openeuler-ci-bot
b19e06108d
!124 [sync] PR-120: Check the length of path
From: @openeuler-sync-bot 
Reviewed-by: @SuperSix173 
Signed-off-by: @SuperSix173
2025-03-18 02:11:17 +00:00
langfei
4d7ded18bd Check the length of path
Signed-off-by: langfei <langfei@huawei.com>
(cherry picked from commit 670ef67d4f9657a789fc8c5fde1b28cb7e50c0eb)
2025-03-18 09:32:22 +08:00
openeuler-ci-bot
ba9ce6fe41
!121 [sync] PR-119: 修复编译告警
From: @openeuler-sync-bot 
Reviewed-by: @SuperSix173 
Signed-off-by: @SuperSix173
2025-03-18 01:30:26 +00:00
lvgenggeng
557e3f24a4 backport community patches
Signed-off-by: lvgenggeng <lvgenggeng@uniontech.com>
(cherry picked from commit 39736e9054e0cd4edbe328a201bbadaa8849a698)
2025-03-17 20:26:15 +08:00
openeuler-ci-bot
d3f4890ab7
!111 [sync] PR-110: backport community patches
From: @openeuler-sync-bot 
Reviewed-by: @SuperSix173 
Signed-off-by: @SuperSix173
2024-05-08 01:24:34 +00:00
lihaoxiang
3945c42f79 backport community patches
Signed-off-by: langfei <langfei@huawei.com>
(cherry picked from commit 932ebb5b1d1eb8ca9cdf61de0f1e356577f588a8)
2024-05-07 21:41:40 +08:00
openeuler-ci-bot
d947502db0
!107 [sync] PR-101: backport community patches
From: @openeuler-sync-bot 
Reviewed-by: @SuperSix173 
Signed-off-by: @SuperSix173
2024-05-07 09:36:54 +00:00
yangpan
24db4431c5 backport community patches
(cherry picked from commit c371535d450a2dff7f59c236261e3b7da14468c4)
2024-05-07 17:10:12 +08:00
openeuler-ci-bot
d62aab053e
!84 irqbalance: fix memory leak in irq hotplug path
From: @chinyu0704 
Reviewed-by: @SuperSix173 
Signed-off-by: @SuperSix173
2023-02-13 11:21:35 +00:00
qinyu
d9a7000e39 irqbalance: fix memory leak in irq hotplug path
fix memory leak in irq hotplug path

Signed-off-by: qinyu <qinyu32@huawei.com>
2023-02-13 17:32:10 +08:00
20 changed files with 861 additions and 22 deletions

View File

@ -0,0 +1,144 @@
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] 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.28.0.windows.1

View File

@ -0,0 +1,51 @@
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] activate_mapping: make sure to catch all errors
Reference: https://github.com/Irqbalance/irqbalance/commit/470a64b190628574c28a266bdcf8960291463191
Conflict: NA
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.28.0.windows.1

View File

@ -0,0 +1,67 @@
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] activate_mapping: report error reason
Reference: https://github.com/Irqbalance/irqbalance/commit/9a1fd29a82c9762c3676f613075d44a8d1fcbe82
Conflict: NA
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.28.0.windows.1

View File

@ -0,0 +1,54 @@
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] activate_mapping: only blacklist irq if error is considered
permanent
Reference: https://github.com/Irqbalance/irqbalance/commit/eee7917ef5272691b9d4ee6341463f3c78f7f909
Conflict: NA
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.28.0.windows.1

View File

@ -0,0 +1,31 @@
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] activate_mapping: avoid logging error when there is none
Reference: https://github.com/Irqbalance/irqbalance/commit/bc7794dc78474c463a26926749537f23abc4c082
Conflict: NA
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.28.0.windows.1

View File

@ -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

View 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

View File

@ -0,0 +1,52 @@
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>
---
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
@@ -75,20 +75,6 @@ char socket_name[64];
char *banned_cpumask_from_ui = NULL;
#endif
-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

View 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

View File

@ -0,0 +1,84 @@
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: The community patch set the info->level flag. However, the
backport-feature-introduce-verifyhint-to-detect-hint-variatio.patch patch deletes the judgment of
info->moved in the activate_mapping function. As a result, the irqbalance prints logs every 10 seconds.
Therefore, the community patch is modified to add the judgment of info->level flag.
---
activate.c | 5 +++--
irqlist.c | 2 +-
types.h | 1 -
3 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/activate.c b/activate.c
index 548a401..4830f34 100644
--- a/activate.c
+++ b/activate.c
@@ -62,7 +62,7 @@ static void activate_mapping(struct irq_info *info, void *data __attribute__((un
if (!info->assigned_obj)
return;
- if (info->flags & IRQ_FLAG_AFFINITY_UNMANAGED)
+ if (info->level == BALANCE_NONE)
return;
/* activate only online cpus, otherwise writing to procfs returns EOVERFLOW */
@@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -0,0 +1,69 @@
From 1277ea524354fa628b4189e699af8d62f8be7021 Mon Sep 17 00:00:00 2001
From: Rosen Penev <rosenp@gmail.com>
Date: Sun, 31 Mar 2024 14:18:24 -0700
Subject: [PATCH 1/1] fix 32-bit formats
exposed with -Wformat when building on 32-bit systems
Signed-off-by: Rosen Penev <rosenp@gmail.com>
---
placement.c | 2 +-
ui/ui.c | 8 ++++----
2 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/placement.c b/placement.c
index 9fde8cb..dea7c23 100644
--- a/placement.c
+++ b/placement.c
@@ -172,7 +172,7 @@ static void validate_irq(struct irq_info *info, void *data)
{
if (info->assigned_obj != data)
log(TO_CONSOLE, LOG_INFO, "object validation error: irq %d is wrong, points to %p, should be %p\n",
- info->irq, info->assigned_obj, data);
+ info->irq, (void*)info->assigned_obj, data);
}
static void validate_object(struct topo_obj *d, void *data __attribute__((unused)))
diff --git a/ui/ui.c b/ui/ui.c
index bee6868..8354fc6 100644
--- a/ui/ui.c
+++ b/ui/ui.c
@@ -101,7 +101,7 @@ int get_valid_sleep_input(int column_offest)
if(input == NULL) {
curs_set(0);
attrset(COLOR_PAIR(1));
- mvprintw(2, column_offest, "%lu ", new_sleep);
+ mvprintw(2, column_offest, "%" PRIu64 " ", new_sleep);
move(LINES, COLS);
break;
}
@@ -125,7 +125,7 @@ int get_valid_sleep_input(int column_offest)
}
attrset(COLOR_PAIR(1));
- mvprintw(2, column_offest, "%lu ", new_sleep);
+ mvprintw(2, column_offest, "%" PRIu64 " ", new_sleep);
return new_sleep;
}
@@ -296,7 +296,7 @@ void handle_cpu_banning()
case '\r': {
attrset(COLOR_PAIR(3));
int banned = toggle_cpu(tmp, position + offset - 6);
- mvprintw(position, 3, "CPU %d ", position + offset - 6);
+ mvprintw(position, 3, "CPU %zu ", position + offset - 6);
if(banned) {
mvprintw(position, 19, "YES");
} else {
@@ -770,7 +770,7 @@ void display_tree_node_irqs(irq_t *irq, void *data)
if (max_offset >= offset && max_offset - offset < LINES - 5) {
snprintf(indent + strlen(indent), 32 - strlen(indent), "%s", (char *)data);
attrset(COLOR_PAIR(3));
- printw("%sIRQ %u, IRQs since last rebalance %lu\n",
+ printw("%sIRQ %u, IRQs since last rebalance %" PRIu64 "\n",
indent, irq->vector, irq->diff);
}
max_offset++;
--
2.20.1

View File

@ -0,0 +1,30 @@
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] 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.
Reference:https://github.com/Irqbalance/irqbalance/commit/ac4ba0667ba691985796f92e1a4b1932b03895a0
Conflict: NA
---
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.0

View File

@ -24,8 +24,8 @@ index 854282f..32c5e53 100644
/* Note: Last entry is a catchall */
static struct irq_match matches[] = {
{ "eth.*" ,{NULL} ,NULL, IRQ_TYPE_LEGACY, IRQ_GBETH },
+ { "hisi\\w*? *sas" ,{NULL} ,NULL, IRQ_TYPE_LEGACY, IRQ_SCSI},
+ { "hisi\\w*? *sata" ,{NULL} ,NULL, IRQ_TYPE_LEGACY, IRQ_SCSI},
+ { "hisi\\w*? *sas" ,{NULL}, NULL, IRQ_TYPE_LEGACY, IRQ_SCSI},
+ { "hisi\\w*? *sata" ,{NULL}, NULL, IRQ_TYPE_LEGACY, IRQ_SCSI},
{ "[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},

View File

@ -32,7 +32,7 @@ index 80d8fee..9f2be54 100644
irqbalance_SOURCES += thermal.c
endif
diff --git a/classify.c b/classify.c
index 4ea4b44..0bbe608 100644
index dac813c..7d7a933 100644
--- a/classify.c
+++ b/classify.c
@@ -627,12 +627,20 @@ static void add_new_irq(char *path, struct irq_info *hint)
@ -46,7 +46,7 @@ index 4ea4b44..0bbe608 100644
+ memset(&pol, -1, sizeof(struct user_irq_policy));
+ }
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
+ } else {
@ -58,8 +58,8 @@ index 4ea4b44..0bbe608 100644
if (!new)
log(TO_CONSOLE, LOG_WARNING, "add_new_irq: Failed to add irq %d\n", irq);
@@ -780,6 +788,7 @@ int proc_irq_hotplug(char *savedline, int irq, struct irq_info **pinfo)
add_new_irq(NULL, &tmp_info);
@@ -782,6 +790,7 @@ int proc_irq_hotplug(char *savedline, int irq, struct irq_info **pinfo)
*pinfo = get_irq_info(irq);
}
+

View File

@ -12,19 +12,19 @@ Signed-off-by: He Jingxian <hejingxian@huawei.com>
---
irqbalance.c | 4 +-
irqbalance.h | 1 +
ui/Makefile | 29 ++++
ui/client.c | 435 +++++++++++++++++++++++++++++++++++++++++++++++++
ui/irqbalance_client.h | 111 +++++++++++++
ui/Makefile | 29 +++
ui/client.c | 435 +++++++++++++++++++++++++++++++++++++++++
ui/irqbalance_client.h | 111 +++++++++++
5 files changed, 578 insertions(+), 2 deletions(-)
create mode 100644 ui/Makefile
create mode 100644 ui/client.c
create mode 100644 ui/irqbalance_client.h
diff --git a/irqbalance.c b/irqbalance.c
index 1af23c6..7c79087 100644
index f73fdbb..fd61e3f 100644
--- a/irqbalance.c
+++ b/irqbalance.c
@@ -452,12 +452,12 @@ void get_object_stat(struct topo_obj *object, void *data)
@@ -459,12 +459,12 @@ void get_object_stat(struct topo_obj *object, void *data)
#ifdef HAVE_IRQBALANCEUI
gboolean sock_handle(gint fd, GIOCondition condition, gpointer user_data __attribute__((unused)))
{
@ -40,10 +40,10 @@ index 1af23c6..7c79087 100644
msg.msg_iov = &iov;
msg.msg_iovlen = 1;
diff --git a/irqbalance.h b/irqbalance.h
index b2e5409..842cead 100644
index 2d2c5d3..97cb9d7 100644
--- a/irqbalance.h
+++ b/irqbalance.h
@@ -175,6 +175,7 @@ extern unsigned int log_mask;
@@ -174,6 +174,7 @@ extern unsigned int log_mask;
#define SOCKET_PATH "irqbalance"
#define SOCKET_TMPFS "/run/irqbalance"
#define MAX_CLIENT_NUM 32
@ -53,7 +53,7 @@ index b2e5409..842cead 100644
extern void get_mask_from_bitmap(char *line, void *mask);
diff --git a/ui/Makefile b/ui/Makefile
new file mode 100644
index 0000000..27e0fbf
index 0000000..933b0f0
--- /dev/null
+++ b/ui/Makefile
@@ -0,0 +1,29 @@
@ -88,7 +88,7 @@ index 0000000..27e0fbf
+ -$(RM) $(TARGET)
diff --git a/ui/client.c b/ui/client.c
new file mode 100644
index 0000000..027404b
index 0000000..1dcbcbb
--- /dev/null
+++ b/ui/client.c
@@ -0,0 +1,435 @@
@ -529,7 +529,7 @@ index 0000000..027404b
+
diff --git a/ui/irqbalance_client.h b/ui/irqbalance_client.h
new file mode 100644
index 0000000..8f18b79
index 0000000..88fb926
--- /dev/null
+++ b/ui/irqbalance_client.h
@@ -0,0 +1,111 @@
@ -645,5 +645,5 @@ index 0000000..8f18b79
+void irqbalance_set_pid(int pid);
+#endif
--
1.8.3.1
2.33.0

View File

@ -38,7 +38,7 @@ index 62cfd08..774a3b2 100644
--- a/activate.c
+++ b/activate.c
@@ -51,11 +51,6 @@ static void activate_mapping(struct irq_info *info, void *data __attribute__((un
int ret = 0;
int errsave, ret;
cpumask_t applied_mask;
- /*
@ -408,10 +408,10 @@ index 22940b4..710d496 100644
#ifdef __aarch64__
#define AARCH64
@@ -112,6 +113,10 @@ extern void free_cl_opts(void);
@@ -111,6 +112,10 @@ extern void free_cl_opts(void);
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);
+extern void force_rebalance_irq(struct irq_info *info, void *data __attribute__((unused)));
+extern gint compare_ints(gconstpointer a, gconstpointer b);
+extern int hint_enabled, poll_hint_interval;

View File

@ -1,7 +1,7 @@
Summary: A dynamic adaptive IRQ balancing daemon
Name: irqbalance
Version: 1.9.2
Release: 2
Release: 7
Epoch: 3
License: GPLv2
Source0: https://github.com/Irqbalance/irqbalance/archive/v%{version}.tar.gz#/irqbalance-%{version}.tar.gz
@ -23,6 +23,22 @@ Requires: numactl-libs
%define _hardened_build 1
Patch6000: backport-fix-memory-leak-in-irq-hotplug-path.patch
Patch6001: backport-0001-activate_mapping-avoid-use-after-free-when-affinity-.patch
Patch6002: backport-0002-activate_mapping-make-sure-to-catch-all-errors.patch
Patch6003: backport-0003-activate_mapping-report-error-reason.patch
Patch6004: backport-0004-activate_mapping-only-blacklist-irq-if-error-is-cons.patch
Patch6005: backport-0005-activate_mapping-avoid-logging-error-when-there-is-n.patch
Patch6006: backport-filter-console-only-output-when-using-journal-mode.patch
Patch6007: backport-Slience-.-rebalancing-messages-for-unmigratable-IRQs.patch
Patch6008: backport-Avoid-repeated-affinity-checks-when-no-change-is-nec.patch
Patch6009: backport-activate_mapping-set-errsave-before-first-jump-to-th.patch
Patch6010: backport-Fix-socket-API-being-blocked-for-10s.patch
Patch6011: backport-Flush-file-before-closing.patch
Patch6012: backport-Check-fflush-return-value.patch
Patch6013: backport-fix-32-bit-formats.patch
Patch6014: backport-check_platform_device-Check-the-length-of-path.patch
Patch9000: feature-aarch64-add-the-regular-to-get-the-correct-i.patch
Patch9001: feature-add-new-user-irq-policy-config-rule.patch
Patch9002: feature-add-the-switch-of-printing-log.patch
@ -118,6 +134,38 @@ fi
/sbin/chkconfig --del %{name} >/dev/null 2>&1 || :
%changelog
* Mon Mar 17 2025 langfei <langfei@huawei.com> - 3:1.9.2-7
- Type:bugfix
- ID:NA
- SUG:restart
- DESC: Check the length of path
* Fri Sep 06 2024 lvgenggeng <lvgenggeng@uniontech.com> - 3:1.9.2-6
- Type:bugfix
- ID:NA
- SUG:restart
- DESC: fix -Wformat when building on 32-bit systems
* Tue May 07 2024 langfei <langfei@huawei.com> - 3:1.9.2-5
- Type:bugfix
- ID:NA
- SUG:restart
- DESC: Fix socket API being blocked for 10s;
- Flush file brfore closing;
- Check fflush() return value.
* Wed Mar 27 2024 langfei <langfei@huawei.com> - 3:1.9.2-4
- Type:bugfix
- ID:NA
- SUG:restart
- DESC: backport community patches
* Mon Feb 13 2023 qinyu <qinyu32@huawei.com> - 3:1.9.2-3
- Type:bugfix
- ID:NA
- SUG:restart
- DESC: fix memory leak in irq hotplug path
* Wed Feb 1 2023 qinyu <qinyu32@huawei.com> - 3:1.9.2-2
- Type:bugfix
- ID:NA