From 9cb09daefcab6db8272ad20127e465da303f065b Mon Sep 17 00:00:00 2001 From: langfei Date: Wed, 21 Feb 2024 01:23:07 +0000 Subject: [PATCH 1/4] upload community patche Signed-off-by: langfei --- ...ncing-messages-for-unmigratable-IRQs.patch | 79 +++++++++++++++++++ 1 file changed, 79 insertions(+) create mode 100644 0001-Slience-.-rebalancing-messages-for-unmigratable-IRQs.patch diff --git a/0001-Slience-.-rebalancing-messages-for-unmigratable-IRQs.patch b/0001-Slience-.-rebalancing-messages-for-unmigratable-IRQs.patch new file mode 100644 index 0000000..95f758b --- /dev/null +++ b/0001-Slience-.-rebalancing-messages-for-unmigratable-IRQs.patch @@ -0,0 +1,79 @@ +From ad0ea2c4c09d6aa76e6c3f87587047cbaddf254e Mon Sep 17 00:00:00 2001 +From: StefanBruens +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 +``` +--- + 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 + -- Gitee From 8ed77079c8ff7e030274068dc1a7d7eda05befa1 Mon Sep 17 00:00:00 2001 From: langfei Date: Sat, 23 Mar 2024 07:35:12 +0000 Subject: [PATCH 2/4] backport community patches Signed-off-by: langfei --- ...ffinity-checks-when-no-change-is-nec.patch | 40 +++++++++ ...ncing-messages-for-unmigratable-IRQs.patch | 84 +++++++++++++++++++ ...-set-errsave-before-first-jump-to-th.patch | 29 +++++++ ...-only-output-when-using-journal-mode.patch | 30 +++++++ 4 files changed, 183 insertions(+) create mode 100644 backport-Avoid-repeated-affinity-checks-when-no-change-is-nec.patch create mode 100644 backport-Slience-.-rebalancing-messages-for-unmigratable-IRQs.patch create mode 100644 backport-activate_mapping-set-errsave-before-first-jump-to-th.patch create mode 100644 backport-filter-console-only-output-when-using-journal-mode.patch diff --git a/backport-Avoid-repeated-affinity-checks-when-no-change-is-nec.patch b/backport-Avoid-repeated-affinity-checks-when-no-change-is-nec.patch new file mode 100644 index 0000000..9b3c85b --- /dev/null +++ b/backport-Avoid-repeated-affinity-checks-when-no-change-is-nec.patch @@ -0,0 +1,40 @@ +From b4c377148dda6f10a5c25be535513eeab236141f Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Stefan=20Br=C3=BCns?= +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 + diff --git a/backport-Slience-.-rebalancing-messages-for-unmigratable-IRQs.patch b/backport-Slience-.-rebalancing-messages-for-unmigratable-IRQs.patch new file mode 100644 index 0000000..5603bd0 --- /dev/null +++ b/backport-Slience-.-rebalancing-messages-for-unmigratable-IRQs.patch @@ -0,0 +1,84 @@ +From ad0ea2c4c09d6aa76e6c3f87587047cbaddf254e Mon Sep 17 00:00:00 2001 +From: StefanBruens +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 + diff --git a/backport-activate_mapping-set-errsave-before-first-jump-to-th.patch b/backport-activate_mapping-set-errsave-before-first-jump-to-th.patch new file mode 100644 index 0000000..0c29e89 --- /dev/null +++ b/backport-activate_mapping-set-errsave-before-first-jump-to-th.patch @@ -0,0 +1,29 @@ +From f4d987f82e64fd53ae5646d39b5174fb3cc572d2 Mon Sep 17 00:00:00 2001 +From: liuchao173 +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 + diff --git a/backport-filter-console-only-output-when-using-journal-mode.patch b/backport-filter-console-only-output-when-using-journal-mode.patch new file mode 100644 index 0000000..9fe8740 --- /dev/null +++ b/backport-filter-console-only-output-when-using-journal-mode.patch @@ -0,0 +1,30 @@ +From f3282f4ddc10be44e6c423de6de8db600f748f85 Mon Sep 17 00:00:00 2001 +From: Neil Horman +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 + -- Gitee From 024a351f7dbd3ccd5b0d7ba15b360601cc135d60 Mon Sep 17 00:00:00 2001 From: yangpan Date: Sat, 23 Mar 2024 16:09:40 +0800 Subject: [PATCH 3/4] backport community patches --- ...ncing-messages-for-unmigratable-IRQs.patch | 79 ------------------- irqbalance.spec | 4 + 2 files changed, 4 insertions(+), 79 deletions(-) delete mode 100644 0001-Slience-.-rebalancing-messages-for-unmigratable-IRQs.patch diff --git a/0001-Slience-.-rebalancing-messages-for-unmigratable-IRQs.patch b/0001-Slience-.-rebalancing-messages-for-unmigratable-IRQs.patch deleted file mode 100644 index 95f758b..0000000 --- a/0001-Slience-.-rebalancing-messages-for-unmigratable-IRQs.patch +++ /dev/null @@ -1,79 +0,0 @@ -From ad0ea2c4c09d6aa76e6c3f87587047cbaddf254e Mon Sep 17 00:00:00 2001 -From: StefanBruens -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 -``` ---- - 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 - diff --git a/irqbalance.spec b/irqbalance.spec index abdeed1..5085049 100644 --- a/irqbalance.spec +++ b/irqbalance.spec @@ -24,6 +24,10 @@ Requires: numactl-libs %define _hardened_build 1 Patch6000: backport-fix-memory-leak-in-irq-hotplug-path.patch +Patch6001: backport-filter-console-only-output-when-using-journal-mode.patch +Patch6002: backport-Slience-.-rebalancing-messages-for-unmigratable-IRQs.patch +Patch6003: backport-Avoid-repeated-affinity-checks-when-no-change-is-nec.patch +Patch6004: backport-activate_mapping-set-errsave-before-first-jump-to-th.patch Patch9000: feature-aarch64-add-the-regular-to-get-the-correct-i.patch Patch9001: feature-add-new-user-irq-policy-config-rule.patch -- Gitee From e4d000d74527cc8a5014b6906ebd8357291c8046 Mon Sep 17 00:00:00 2001 From: langfei Date: Sat, 23 Mar 2024 08:37:43 +0000 Subject: [PATCH 4/4] backport community patches Signed-off-by: langfei --- irqbalance.spec | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/irqbalance.spec b/irqbalance.spec index 5085049..9e2f2ae 100644 --- a/irqbalance.spec +++ b/irqbalance.spec @@ -1,7 +1,7 @@ Summary: A dynamic adaptive IRQ balancing daemon Name: irqbalance Version: 1.9.2 -Release: 3 +Release: 4 Epoch: 3 License: GPLv2 Source0: https://github.com/Irqbalance/irqbalance/archive/v%{version}.tar.gz#/irqbalance-%{version}.tar.gz @@ -124,6 +124,12 @@ fi /sbin/chkconfig --del %{name} >/dev/null 2>&1 || : %changelog +* Sat Mar 23 2024 lnagfei - 3:1.9.2-4 +- Type:bugfix +- ID:NA +- SUG:restart +- DESC: backport community patches + * Mon Feb 13 2023 qinyu - 3:1.9.2-3 - Type:bugfix - ID:NA -- Gitee