From 3a0401770dc10e53b6b41fbd561a01f26d018872 Mon Sep 17 00:00:00 2001 From: root Date: Fri, 14 Aug 2020 14:28:45 +0800 Subject: [PATCH] rebase to v1.7.0 --- Add-irqbalance-ui.1-to-dist_man_MANS.patch | 26 -- Add-optional-config-file-in-usr-lib.patch | 33 -- Add-stub-manpage-for-irqbalance-ui.patch | 59 --- Capitalize-HOMEPAGE-in-irqbalance.1.patch | 24 -- ...value-of-strdup-in-collect_full_irq_.patch | 30 -- Clarify-the-README-description.patch | 31 -- Correct-typos-in-irqbalance.c.patch | 43 --- Fix-spelling-errors.patch | 48 --- Fix-typo-in-service-unit-file.patch | 28 -- Update-classify.c.patch | 25 -- arm64-Add-irq-aff-change-check.patch | 121 ------ change-path-to-devpath.patch | 29 -- correct-to-use-realloc-function.patch | 108 ------ ...ss-free-for-banned_irqs-in-free_cl_o.patch | 37 -- ...cal-variables-in-parse_proc_interrup.patch | 38 -- fix-guess_arm_irq_hints.patch | 29 -- ...ter-dereference-banned_cpumask_from_.patch | 96 ----- ...k-for-not-invoking-closedir-after-op.patch | 39 -- ...urce-leak-on-the-error-paths-in-main.patch | 70 ---- ...al-when-sleep_interval-is-changed-by.patch | 62 ---- ...-pid-file-generates-too-late-problem.patch | 65 ---- ...of-banmod-that-memory-is-freed-befor.patch | 67 ---- ...an_string-when-the-next-request-come.patch | 66 ---- free-polscript-if-irqbalance-exit.patch | 26 -- free-polscript-to-avoid-resource-leak.patch | 35 -- ...ry-when-getline-fail-in-add_one_node.patch | 35 -- ...ean-up-freeing-of-lines-from-getline.patch | 106 ------ improve-comments-in-env-file.patch | 55 --- ...-migrate-rule-to-avoid-high-irq-load.patch | 105 ------ irqbalance-1.6.0.tar.gz | Bin 55310 -> 0 bytes irqbalance-1.7.0.tar.gz | Bin 0 -> 54209 bytes ...alize-package_mask-before-using-in-d.patch | 50 --- ...y-the-order-of-input-parameter-for-c.patch | 91 ----- ...nt-NULL-pointer-dereference-in-do_on.patch | 154 -------- ...e-redundancy-check-in-add_one_irq_to.patch | 61 --- ...remove-unused-package_count-variable.patch | 59 --- ...UMA_NO_NODE-macro-instead-of-1-for-n.patch | 131 ------- ...dd_new_irq-instead-of-the-same-logic.patch | 138 ------- ...dd_one_node-to-create-unspecified-no.patch | 158 -------- ..._list_find-instead-of-the-search-log.patch | 135 ------- ...e-g_list_free_full-in-clear_cpu_tree.patch | 89 ----- ...sdigit-instead-of-the-logic-of-chara.patch | 36 -- ...e-num_online_cpus-instead-core_count.patch | 227 ------------ ...e-process_one_line-instead-of-fscanf.patch | 176 --------- irqbalance.spec | 61 +-- ...n-V-closer-to-the-option-with-no-arg.patch | 25 -- ...urn-value-of-getline-handled-correct.patch | 129 ------- ...nter-dereference-when-memory-allocat.patch | 114 ------ ...e-redundant-check-in-add_missing_irq.patch | 33 -- ...e-redundant-code-for-file-processing.patch | 347 ------------------ remove-c-in-parse_proc_interrupts.patch | 25 -- remove-unused-path-in-check_for_irq_ban.patch | 55 --- ...d-judgement-are-unnecessary-in-activ.patch | 58 --- use-policy-prior-to-the-default-values.patch | 152 -------- when-devpath-is-NULL-skip-reading-files.patch | 40 -- 55 files changed, 7 insertions(+), 4073 deletions(-) delete mode 100644 Add-irqbalance-ui.1-to-dist_man_MANS.patch delete mode 100644 Add-optional-config-file-in-usr-lib.patch delete mode 100644 Add-stub-manpage-for-irqbalance-ui.patch delete mode 100644 Capitalize-HOMEPAGE-in-irqbalance.1.patch delete mode 100644 Checking-return-value-of-strdup-in-collect_full_irq_.patch delete mode 100644 Clarify-the-README-description.patch delete mode 100644 Correct-typos-in-irqbalance.c.patch delete mode 100644 Fix-spelling-errors.patch delete mode 100644 Fix-typo-in-service-unit-file.patch delete mode 100644 Update-classify.c.patch delete mode 100644 arm64-Add-irq-aff-change-check.patch delete mode 100644 change-path-to-devpath.patch delete mode 100644 correct-to-use-realloc-function.patch delete mode 100644 delete-the-useless-free-for-banned_irqs-in-free_cl_o.patch delete mode 100644 delete-unused-local-variables-in-parse_proc_interrup.patch delete mode 100644 fix-guess_arm_irq_hints.patch delete mode 100644 fix-invalid-pointer-dereference-banned_cpumask_from_.patch delete mode 100644 fix-resource-leak-for-not-invoking-closedir-after-op.patch delete mode 100644 fix-resource-leak-on-the-error-paths-in-main.patch delete mode 100644 fix-sleep-interval-when-sleep_interval-is-changed-by.patch delete mode 100644 fix-the-pid-file-generates-too-late-problem.patch delete mode 100644 fix-the-problem-of-banmod-that-memory-is-freed-befor.patch delete mode 100644 free-cpu_ban_string-when-the-next-request-come.patch delete mode 100644 free-polscript-if-irqbalance-exit.patch delete mode 100644 free-polscript-to-avoid-resource-leak.patch delete mode 100644 free-the-memory-when-getline-fail-in-add_one_node.patch delete mode 100644 getline-clean-up-freeing-of-lines-from-getline.patch delete mode 100644 improve-comments-in-env-file.patch delete mode 100644 improve-irq-migrate-rule-to-avoid-high-irq-load.patch delete mode 100644 irqbalance-1.6.0.tar.gz create mode 100644 irqbalance-1.7.0.tar.gz delete mode 100644 irqbalance-initialize-package_mask-before-using-in-d.patch delete mode 100644 irqbalance-modify-the-order-of-input-parameter-for-c.patch delete mode 100644 irqbalance-prevent-NULL-pointer-dereference-in-do_on.patch delete mode 100644 irqbalance-remove-redundancy-check-in-add_one_irq_to.patch delete mode 100644 irqbalance-remove-unused-package_count-variable.patch delete mode 100644 irqbalance-use-NUMA_NO_NODE-macro-instead-of-1-for-n.patch delete mode 100644 irqbalance-use-add_new_irq-instead-of-the-same-logic.patch delete mode 100644 irqbalance-use-add_one_node-to-create-unspecified-no.patch delete mode 100644 irqbalance-use-g_list_find-instead-of-the-search-log.patch delete mode 100644 irqbalance-use-g_list_free_full-in-clear_cpu_tree.patch delete mode 100644 irqbalance-use-isdigit-instead-of-the-logic-of-chara.patch delete mode 100644 irqbalance-use-num_online_cpus-instead-core_count.patch delete mode 100644 irqbalance-use-process_one_line-instead-of-fscanf.patch delete mode 100644 make-the-option-V-closer-to-the-option-with-no-arg.patch delete mode 100644 make-the-return-value-of-getline-handled-correct.patch delete mode 100644 prevent-NULL-pointer-dereference-when-memory-allocat.patch delete mode 100644 reduce-redundant-check-in-add_missing_irq.patch delete mode 100644 reduce-redundant-code-for-file-processing.patch delete mode 100644 remove-c-in-parse_proc_interrupts.patch delete mode 100644 remove-unused-path-in-check_for_irq_ban.patch delete mode 100644 some-variable-and-judgement-are-unnecessary-in-activ.patch delete mode 100644 use-policy-prior-to-the-default-values.patch delete mode 100644 when-devpath-is-NULL-skip-reading-files.patch diff --git a/Add-irqbalance-ui.1-to-dist_man_MANS.patch b/Add-irqbalance-ui.1-to-dist_man_MANS.patch deleted file mode 100644 index b5046fd..0000000 --- a/Add-irqbalance-ui.1-to-dist_man_MANS.patch +++ /dev/null @@ -1,26 +0,0 @@ -From a79530b6d77456b304c58f7ea706bef869fa00a0 Mon Sep 17 00:00:00 2001 -From: Paride Legovini -Date: Sun, 21 Jul 2019 12:18:49 +0200 -Subject: [PATCH 08/53] Add irqbalance-ui.1 to dist_man_MANS - ---- - Makefile.am | 3 +++ - 1 file changed, 3 insertions(+) - -diff --git a/Makefile.am b/Makefile.am -index abf1e8d..73988b3 100644 ---- a/Makefile.am -+++ b/Makefile.am -@@ -47,6 +47,9 @@ irqbalance_ui_LDADD = $(GLIB2_LIBS) $(CURSES_LIBS) - endif - - dist_man_MANS = irqbalance.1 -+if IRQBALANCEUI -+dist_man_MANS += irqbalance-ui.1 -+endif - - CONFIG_CLEAN_FILES = debug*.list config/* - clean-generic: --- -2.23.0 - diff --git a/Add-optional-config-file-in-usr-lib.patch b/Add-optional-config-file-in-usr-lib.patch deleted file mode 100644 index da1f22b..0000000 --- a/Add-optional-config-file-in-usr-lib.patch +++ /dev/null @@ -1,33 +0,0 @@ -From 724243f1744a263b3777e920526c0a4a3c042ca6 Mon Sep 17 00:00:00 2001 -From: Neil Horman -Date: Tue, 17 Sep 2019 08:56:11 -0400 -Subject: [PATCH 13/53] Add optional config file in /usr/lib - -immutable distributions have a need for distribution specific configs in -a read only space, and so modify the service file to optionally read a -config file from /usr/lib/irqbalance/default.env - -Addresses https://github.com/Irqbalance/irqbalance/issues/118 - -Signed-off-by: Neil Horman ---- - misc/irqbalance.service | 3 ++- - 1 file changed, 2 insertions(+), 1 deletion(-) - -diff --git a/misc/irqbalance.service b/misc/irqbalance.service -index bb6ed98..cb7937a 100644 ---- a/misc/irqbalance.service -+++ b/misc/irqbalance.service -@@ -5,7 +5,8 @@ Documentation=https://github.com/Irqbalance/irqbalance - ConditionVirtualization=!container - - [Service] --EnvironmentFile=/path/to/irqbalance.env -+Environmentfile=-/usr/lib/irqbalance/defaults.env -+EnvironmentFile=-/path/to/irqbalance.env - ExecStart=/usr/sbin/irqbalance --foreground $IRQBALANCE_ARGS - CapabilityBoundingSet= - NoNewPrivileges=yes --- -2.23.0 - diff --git a/Add-stub-manpage-for-irqbalance-ui.patch b/Add-stub-manpage-for-irqbalance-ui.patch deleted file mode 100644 index 8db4eca..0000000 --- a/Add-stub-manpage-for-irqbalance-ui.patch +++ /dev/null @@ -1,59 +0,0 @@ -From 418d919c10be2430e60f81d5df35b262f072fbe5 Mon Sep 17 00:00:00 2001 -From: Paride Legovini -Date: Sun, 21 Jul 2019 12:15:14 +0200 -Subject: [PATCH 06/53] Add stub manpage for irqbalance-ui - ---- - irqbalance-ui.1 | 40 ++++++++++++++++++++++++++++++++++++++++ - 1 file changed, 40 insertions(+) - create mode 100644 irqbalance-ui.1 - -diff --git a/irqbalance-ui.1 b/irqbalance-ui.1 -new file mode 100644 -index 0000000..7ca4d28 ---- /dev/null -+++ b/irqbalance-ui.1 -@@ -0,0 +1,40 @@ -+.de Sh \" Subsection -+.br -+.if t .Sp -+.ne 5 -+.PP -+\fB\\$1\fR -+.PP -+.. -+.de Sp \" Vertical space (when we can't use .PP) -+.if t .sp .5v -+.if n .sp -+.. -+.de Ip \" List item -+.br -+.ie \\n(.$>=3 .ne \\$3 -+.el .ne 3 -+.IP "\\$1" \\$2 -+.. -+.TH "IRQBALANCE-UI" 1 "Jul 2019" "Linux" "irqbalance-ui" -+.SH NAME -+irqbalance-ui \- user interface for irqbalance -+.SH "SYNOPSIS" -+ -+.nf -+\fBirqbalance-ui\fR -+.fi -+ -+.SH "DESCRIPTION" -+ -+.PP -+\fBirqbalance-ui\fR provides an ncurses-based textual user interface to -+\fBirqbalance\fR, a daemon responsible for IRQ distribution on Linux systems. -+It shows how IRQs are distributed over CPUs at given moment, and allows one to -+setup of the sleep interval and the IRQ and CPU banning at runtime. -+ -+.SH "HOMEPAGE" -+https://github.com/Irqbalance/irqbalance -+ -+.SH "SEE ALSO" -+irqbalance(1) --- -2.23.0 - diff --git a/Capitalize-HOMEPAGE-in-irqbalance.1.patch b/Capitalize-HOMEPAGE-in-irqbalance.1.patch deleted file mode 100644 index 91153d8..0000000 --- a/Capitalize-HOMEPAGE-in-irqbalance.1.patch +++ /dev/null @@ -1,24 +0,0 @@ -From 30154d546fdaba74d45d1296b8d2bb8e7f139ca7 Mon Sep 17 00:00:00 2001 -From: Paride Legovini -Date: Sun, 21 Jul 2019 12:15:24 +0200 -Subject: [PATCH 07/53] Capitalize HOMEPAGE in irqbalance.1 - ---- - irqbalance.1 | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/irqbalance.1 b/irqbalance.1 -index aad27bc..3005f6b 100644 ---- a/irqbalance.1 -+++ b/irqbalance.1 -@@ -192,6 +192,6 @@ Ban listed IRQs from being balanced, all old values of banned IRQs are forgotten - irqbalance checks SCM_CREDENTIALS of sender (only root user is allowed to interact). - Based on chosen tools, ancillary message with credentials needs to be sent with request. - --.SH "Homepage" -+.SH "HOMEPAGE" - https://github.com/Irqbalance/irqbalance - --- -2.23.0 - diff --git a/Checking-return-value-of-strdup-in-collect_full_irq_.patch b/Checking-return-value-of-strdup-in-collect_full_irq_.patch deleted file mode 100644 index 2c4a962..0000000 --- a/Checking-return-value-of-strdup-in-collect_full_irq_.patch +++ /dev/null @@ -1,30 +0,0 @@ -From 7265665307ab991d0aa452e0b4590b3c1072d0a0 Mon Sep 17 00:00:00 2001 -From: Yunfeng Ye -Date: Sun, 22 Sep 2019 13:40:35 +0800 -Subject: [PATCH 18/53] Checking return value of strdup() in - collect_full_irq_list() - -strdup() may return NULL if memory allocation fail, checking the return -value before reference. - -Signed-off-by: Yunfeng Ye ---- - procinterrupts.c | 2 ++ - 1 file changed, 2 insertions(+) - -diff --git a/procinterrupts.c b/procinterrupts.c -index 44c5c76..f3f57ad 100644 ---- a/procinterrupts.c -+++ b/procinterrupts.c -@@ -189,6 +189,8 @@ GList* collect_full_irq_list() - continue; - - savedline = strdup(line); -+ if (!savedline) -+ break; - irq_name = strtok_r(savedline, " ", &savedptr); - if (strstr(irq_name, "xen-dyn") != NULL) - is_xen_dyn = 1; --- -2.23.0 - diff --git a/Clarify-the-README-description.patch b/Clarify-the-README-description.patch deleted file mode 100644 index 3ade695..0000000 --- a/Clarify-the-README-description.patch +++ /dev/null @@ -1,31 +0,0 @@ -From 77a3914fb48c4f5ef72c8b84bba43f8a852d1725 Mon Sep 17 00:00:00 2001 -From: Paride Legovini -Date: Fri, 5 Jul 2019 00:00:05 +0200 -Subject: [PATCH 02/53] Clarify the README description - ---- - README.md | 8 ++++---- - 1 file changed, 4 insertions(+), 4 deletions(-) - -diff --git a/README.md b/README.md -index 8e394bd..23427a9 100644 ---- a/README.md -+++ b/README.md -@@ -2,10 +2,10 @@ What is Irqbalance - ================== - - Irqbalance is a daemon to help balance the cpu load generated by interrupts --across all of a systems cpus. Irqbalance identifies the highest volume --interrupt sources, and isolates them to a single unique cpu, so that load is --spread as much as possible over an entire processor set, while minimizing cache --miss rates for irq handlers. -+across all of a systems cpus. Irqbalance identifies the highest volume -+interrupt sources, and isolates each of them to a single unique cpu, so that -+load is spread as much as possible over an entire processor set, while -+minimizing cache miss rates for irq handlers. - - ## Building and Installing [![Build Status](https://travis-ci.org/Irqbalance/irqbalance.svg?branch=master)](https://travis-ci.org/Irqbalance/irqbalance) - --- -2.23.0 - diff --git a/Correct-typos-in-irqbalance.c.patch b/Correct-typos-in-irqbalance.c.patch deleted file mode 100644 index 99ed120..0000000 --- a/Correct-typos-in-irqbalance.c.patch +++ /dev/null @@ -1,43 +0,0 @@ -From 761a3e73cfa0016e7a5f19fb2fe94702cc6925e9 Mon Sep 17 00:00:00 2001 -From: Felix Yan -Date: Tue, 25 Feb 2020 04:15:50 +0800 -Subject: [PATCH 50/53] Correct typos in irqbalance.c - ---- - irqbalance.c | 6 +++--- - 1 file changed, 3 insertions(+), 3 deletions(-) - -diff --git a/irqbalance.c b/irqbalance.c -index aa9941c..35c762d 100644 ---- a/irqbalance.c -+++ b/irqbalance.c -@@ -198,7 +198,7 @@ static void parse_command_line(int argc, char **argv) - #endif - - /* -- * This builds our object tree. The Heirarchy is typically pretty -+ * This builds our object tree. The Hierarchy is typically pretty - * straightforward. - * At the top are numa_nodes - * CPU packages belong to a single numa_node, unless the cache domains are in -@@ -633,7 +633,7 @@ int main(int argc, char** argv) - - HZ = sysconf(_SC_CLK_TCK); - if (HZ == -1) { -- log(TO_ALL, LOG_WARNING, "Unable to determin HZ defaulting to 100\n"); -+ log(TO_ALL, LOG_WARNING, "Unable to determine HZ defaulting to 100\n"); - HZ = 100; - } - -@@ -641,7 +641,7 @@ int main(int argc, char** argv) - int pidfd = -1; - if (daemon(0,0)) - exit(EXIT_FAILURE); -- /* Write pidfile which can be used to avoid starting mutiple instances */ -+ /* Write pidfile which can be used to avoid starting multiple instances */ - if (pidfile && (pidfd = open(pidfile, - O_WRONLY | O_CREAT | O_EXCL | O_TRUNC, - S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH)) >= 0) { --- -2.23.0 - diff --git a/Fix-spelling-errors.patch b/Fix-spelling-errors.patch deleted file mode 100644 index 7ab6048..0000000 --- a/Fix-spelling-errors.patch +++ /dev/null @@ -1,48 +0,0 @@ -From c30406b2b6f0e9c23b7b0e4b9c2024d871b01557 Mon Sep 17 00:00:00 2001 -From: Paride Legovini -Date: Thu, 4 Jul 2019 23:53:37 +0200 -Subject: [PATCH 01/53] Fix spelling errors - ---- - irqbalance.1 | 4 ++-- - ui/irqbalance-ui.c | 2 +- - 2 files changed, 3 insertions(+), 3 deletions(-) - -diff --git a/irqbalance.1 b/irqbalance.1 -index 07f47d8..aad27bc 100644 ---- a/irqbalance.1 -+++ b/irqbalance.1 -@@ -68,7 +68,7 @@ example to ban IRQs 43 and 44 from balancing, use the following command line: - - .TP - .B -m, --banmod= --Add the specified module to the set of banned modules, similiar to --banirq. -+Add the specified module to the set of banned modules, similar to --banirq. - irqbalance will not affect the affinity of any IRQs of given modules, allowing - them to be specified manually. This option is additive and can be specified - multiple times. For example to ban all IRQs of module foo and module bar from -@@ -131,7 +131,7 @@ This indicates that the script has no policy for the referenced irq, and that - script processing should continue - .TP - .I 2 --This indicates that an error has occured in the script, and it should be skipped -+This indicates that an error has occurred in the script, and it should be skipped - (further processing to continue) - - .TP -diff --git a/ui/irqbalance-ui.c b/ui/irqbalance-ui.c -index 1119665..fe00e94 100644 ---- a/ui/irqbalance-ui.c -+++ b/ui/irqbalance-ui.c -@@ -390,7 +390,7 @@ gboolean key_loop(gpointer data __attribute__((unused))) - int main(int argc, char **argv) - { - if(getuid() != 0) { -- printf("This program needs to be executed with root priviledges\n"); -+ printf("This program needs to be executed with root privileges\n"); - return EACCES; - } - if(argc > 1) { --- -2.23.0 - diff --git a/Fix-typo-in-service-unit-file.patch b/Fix-typo-in-service-unit-file.patch deleted file mode 100644 index 316c6b2..0000000 --- a/Fix-typo-in-service-unit-file.patch +++ /dev/null @@ -1,28 +0,0 @@ -From 3a19387fb712c509f8137f06dbf899350ad2f84c Mon Sep 17 00:00:00 2001 -From: Neil Horman -Date: Mon, 8 Jun 2020 06:24:56 -0400 -Subject: [PATCH 52/53] Fix typo in service unit file - -Environmentfile should be EnvironmentFile - -Signed-off-by: Neil Horman ---- - misc/irqbalance.service | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/misc/irqbalance.service b/misc/irqbalance.service -index cb7937a..e7a3336 100644 ---- a/misc/irqbalance.service -+++ b/misc/irqbalance.service -@@ -5,7 +5,7 @@ Documentation=https://github.com/Irqbalance/irqbalance - ConditionVirtualization=!container - - [Service] --Environmentfile=-/usr/lib/irqbalance/defaults.env -+EnvironmentFile=-/usr/lib/irqbalance/defaults.env - EnvironmentFile=-/path/to/irqbalance.env - ExecStart=/usr/sbin/irqbalance --foreground $IRQBALANCE_ARGS - CapabilityBoundingSet= --- -2.23.0 - diff --git a/Update-classify.c.patch b/Update-classify.c.patch deleted file mode 100644 index a48f438..0000000 --- a/Update-classify.c.patch +++ /dev/null @@ -1,25 +0,0 @@ -From 27335d21e392b1d17b030a7bfc1d99a9e61db421 Mon Sep 17 00:00:00 2001 -From: liuchao173 <55137861+liuchao173@users.noreply.github.com> -Date: Fri, 20 Sep 2019 11:31:04 +0800 -Subject: [PATCH 16/53] Update classify.c - ---- - classify.c | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/classify.c b/classify.c -index 15d0ab2..de78bba 100644 ---- a/classify.c -+++ b/classify.c -@@ -692,7 +692,7 @@ static void build_one_dev_entry(const char *dirname, GList *tmp_irqs) - new = get_irq_info(irqnum); - if (new) - goto done; -- get_irq_user_policy(irqnum, &pol); -+ get_irq_user_policy(devpath, irqnum, &pol); - if ((pol.ban == 1) || (check_for_irq_ban(irqnum, tmp_irqs))) { - add_banned_irq(irqnum, &banned_irqs); - goto done; --- -2.23.0 - diff --git a/arm64-Add-irq-aff-change-check.patch b/arm64-Add-irq-aff-change-check.patch deleted file mode 100644 index b4d9317..0000000 --- a/arm64-Add-irq-aff-change-check.patch +++ /dev/null @@ -1,121 +0,0 @@ -From 55c5c321c73e4c9b54e041ba8c7d542598685bae Mon Sep 17 00:00:00 2001 -From: l00520965 -Date: Wed, 11 Mar 2020 11:46:42 +0800 -Subject: [PATCH 51/53] arm64: Add irq aff change check For aarch64, the PPIs - format in /proc/interrputs can be parsed and add to interrupt db, and next, - the number of interrupts is counted and used to calculate the load. Finally - these interrupts maybe scheduled between the NUMA domains. - -Acctually, the PPIs cannot change aff, and it should not be added to interrupt db. This patch fix it. - -Add a check before add a interrupt to db, just only reads the irq's aff, and write it back to avoid any impact on the system, According to the result of writing to fitler the irq. ---- - activate.c | 8 +++++++- - classify.c | 28 +++++++++++++++++++++++++--- - irqbalance.h | 2 ++ - 3 files changed, 34 insertions(+), 4 deletions(-) - -diff --git a/activate.c b/activate.c -index ab9702d..065f880 100644 ---- a/activate.c -+++ b/activate.c -@@ -48,6 +48,7 @@ static void activate_mapping(struct irq_info *info, void *data __attribute__((un - { - char buf[PATH_MAX]; - FILE *file; -+ int ret = 0; - - /* - * only activate mappings for irqs that have moved -@@ -70,7 +71,12 @@ static void activate_mapping(struct irq_info *info, void *data __attribute__((un - return; - - cpumask_scnprintf(buf, PATH_MAX, info->assigned_obj->mask); -- fprintf(file, "%s", buf); -+ 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); -+ } - fclose(file); - info->moved = 0; /*migration is done*/ - } -diff --git a/classify.c b/classify.c -index fa900f4..9f588bc 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,9 +280,14 @@ 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) -@@ -376,6 +381,23 @@ 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; -@@ -585,7 +607,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 cd93167..bc34d7e 100644 ---- a/irqbalance.h -+++ b/irqbalance.h -@@ -106,6 +106,8 @@ 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) - - --- -2.23.0 - diff --git a/change-path-to-devpath.patch b/change-path-to-devpath.patch deleted file mode 100644 index e483bb4..0000000 --- a/change-path-to-devpath.patch +++ /dev/null @@ -1,29 +0,0 @@ -From 5cb5795d8be047b4bc23ccf47ac3086ac98f1b06 Mon Sep 17 00:00:00 2001 -From: liuchao173 <55137861+liuchao173@users.noreply.github.com> -Date: Tue, 10 Sep 2019 18:46:24 +0800 -Subject: [PATCH 12/53] change path to devpath - -keep the parameters 'path' of check_for_irq_ban function consistent with line 699. -In check_for_irq_ban, -sprintf(cmd, "%s %s %d > /dev/null",banscript, path, irq); -the banscript is unique, so i think the path should keep consistent. ---- - classify.c | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/classify.c b/classify.c -index f40ea99..9b0177d 100644 ---- a/classify.c -+++ b/classify.c -@@ -693,7 +693,7 @@ static void build_one_dev_entry(const char *dirname, GList *tmp_irqs) - if (new) - goto done; - get_irq_user_policy(devpath, irqnum, &pol); -- if ((pol.ban == 1) || (check_for_irq_ban(path, irqnum, tmp_irqs))) { -+ if ((pol.ban == 1) || (check_for_irq_ban(devpath, irqnum, tmp_irqs))) { - add_banned_irq(irqnum, &banned_irqs); - goto done; - } --- -2.23.0 - diff --git a/correct-to-use-realloc-function.patch b/correct-to-use-realloc-function.patch deleted file mode 100644 index 9fd7791..0000000 --- a/correct-to-use-realloc-function.patch +++ /dev/null @@ -1,108 +0,0 @@ -From 503a3e6e9fc8aa1d7dd9e8ba86fb21edcdcfe502 Mon Sep 17 00:00:00 2001 -From: Yunfeng Ye -Date: Fri, 11 Oct 2019 23:41:17 +0800 -Subject: [PATCH 23/53] correct to use realloc() function - -The man doc about realloc() say: - " - If realloc() fails the original block is left untouched; it is not - freed or move - " - -So make the handling of realloc() function correctly. - -In addition, there is another problem about parameter using in -sock_handle(), it should be use the address of @setup instead of @setup. - -Signed-off-by: Yunfeng Ye ---- - irqbalance.c | 33 +++++++++++++++++++++++---------- - 1 file changed, 23 insertions(+), 10 deletions(-) - -diff --git a/irqbalance.c b/irqbalance.c -index a06809c..e53bf65 100644 ---- a/irqbalance.c -+++ b/irqbalance.c -@@ -308,14 +308,18 @@ gboolean scan(gpointer data __attribute__((unused))) - void get_irq_data(struct irq_info *irq, void *data) - { - char **irqdata = (char **)data; -+ char *newptr = NULL; -+ - if (!*irqdata) -- *irqdata = calloc(24 + 1 + 11 + 20 + 20 + 11, 1); -+ newptr = calloc(24 + 1 + 11 + 20 + 20 + 11, 1); - else -- *irqdata = realloc(*irqdata, strlen(*irqdata) + 24 + 1 + 11 + 20 + 20 + 11); -+ newptr = realloc(*irqdata, strlen(*irqdata) + 24 + 1 + 11 + 20 + 20 + 11); - -- if (!*irqdata) -+ if (!newptr) - return; - -+ *irqdata = newptr; -+ - sprintf(*irqdata + strlen(*irqdata), - "IRQ %d LOAD %lu DIFF %lu CLASS %d ", irq->irq, irq->load, - (irq->irq_count - irq->last_irq_count), irq->class); -@@ -325,6 +329,7 @@ void get_object_stat(struct topo_obj *object, void *data) - { - char **stats = (char **)data; - char *irq_data = NULL; -+ char *newptr = NULL; - size_t irqdlen; - - if (g_list_length(object->interrupts) > 0) { -@@ -342,13 +347,17 @@ void get_object_stat(struct topo_obj *object, void *data) - * This should be adjusted if the string in the sprintf is changed - */ - if (!*stats) { -- *stats = calloc(irqdlen + 31 + 11 + 20 + 11 + 1, 1); -+ newptr = calloc(irqdlen + 31 + 11 + 20 + 11 + 1, 1); - } else { -- *stats = realloc(*stats, strlen(*stats) + irqdlen + 31 + 11 + 20 + 11 + 1); -+ newptr = realloc(*stats, strlen(*stats) + irqdlen + 31 + 11 + 20 + 11 + 1); - } - -- if (!*stats) -+ if (!newptr) { -+ free(irq_data); - return; -+ } -+ -+ *stats = newptr; - - sprintf(*stats + strlen(*stats), "TYPE %d NUMBER %d LOAD %lu SAVE_MODE %d %s", - object->obj_type, object->number, object->load, -@@ -465,20 +474,24 @@ gboolean sock_handle(gint fd, GIOCondition condition, gpointer user_data __attri - if (!strncmp(buff, "setup", strlen("setup"))) { - char banned[512]; - char *setup = calloc(strlen("SLEEP ") + 11 + 1, 1); -+ char *newptr = NULL; - - if (!setup) - goto out_close; - snprintf(setup, strlen("SLEEP ") + 11 + 1, "SLEEP %d ", sleep_interval); - if(g_list_length(cl_banned_irqs) > 0) { -- for_each_irq(cl_banned_irqs, get_irq_data, setup); -+ for_each_irq(cl_banned_irqs, get_irq_data, &setup); - } - cpumask_scnprintf(banned, 512, banned_cpus); -- setup = realloc(setup, strlen(setup) + strlen(banned) + 7 + 1); -- if (!setup) -- goto out_close; -+ newptr = realloc(setup, strlen(setup) + strlen(banned) + 7 + 1); -+ if (!newptr) -+ goto out_free_setup; -+ -+ setup = newptr; - snprintf(setup + strlen(setup), strlen(banned) + 7 + 1, - "BANNED %s", banned); - send(sock, setup, strlen(setup), 0); -+out_free_setup: - free(setup); - } - --- -2.23.0 - diff --git a/delete-the-useless-free-for-banned_irqs-in-free_cl_o.patch b/delete-the-useless-free-for-banned_irqs-in-free_cl_o.patch deleted file mode 100644 index 8c73bcc..0000000 --- a/delete-the-useless-free-for-banned_irqs-in-free_cl_o.patch +++ /dev/null @@ -1,37 +0,0 @@ -From 926fbbc1a6992917a8e23d40da164301cfcf7f3a Mon Sep 17 00:00:00 2001 -From: Yunfeng Ye -Date: Thu, 24 Oct 2019 22:17:40 +0800 -Subject: [PATCH 30/53] delete the useless free for banned_irqs in - free_cl_opts() - -free_cl_opts() is invoked after free_irq_db(), the list @banned_irqs has -alreadly be freed in free_irq_db(). - - main() - --> free_object_tree(); - --> free_irq_db(); - --> g_list_free(banned_irqs); - -- >free_cl_opts(); - -So delete the useless free for @banned_irqs list in free_cl_opts(). - -Signed-off-by: Yunfeng Ye ---- - classify.c | 1 - - 1 file changed, 1 deletion(-) - -diff --git a/classify.c b/classify.c -index 7454c5f..2c0e7ed 100644 ---- a/classify.c -+++ b/classify.c -@@ -718,7 +718,6 @@ void free_cl_opts(void) - { - g_list_free_full(cl_banned_modules, free); - g_list_free_full(cl_banned_irqs, free); -- g_list_free(banned_irqs); - } - - static void add_new_irq(int irq, struct irq_info *hint, GList *proc_interrupts) --- -2.23.0 - diff --git a/delete-unused-local-variables-in-parse_proc_interrup.patch b/delete-unused-local-variables-in-parse_proc_interrup.patch deleted file mode 100644 index 7be73e7..0000000 --- a/delete-unused-local-variables-in-parse_proc_interrup.patch +++ /dev/null @@ -1,38 +0,0 @@ -From 88af3aa8ddc395d187e2bb34f6d66e811c9a08d8 Mon Sep 17 00:00:00 2001 -From: Yunfeng Ye -Date: Sun, 22 Sep 2019 00:39:10 +0800 -Subject: [PATCH 17/53] delete unused local variables in - parse_proc_interrupts() - -The local variable @savedline[1024] is unused in parse_proc_interrupts(), -so delete it. - -Signed-off-by: Yunfeng Ye ---- - procinterrupts.c | 3 --- - 1 file changed, 3 deletions(-) - -diff --git a/procinterrupts.c b/procinterrupts.c -index 03b4593..44c5c76 100644 ---- a/procinterrupts.c -+++ b/procinterrupts.c -@@ -260,7 +260,6 @@ void parse_proc_interrupts(void) - uint64_t count; - char *c, *c2; - struct irq_info *info; -- char savedline[1024]; - - if (getline(&line, &size, file)<=0) - break; -@@ -280,8 +279,6 @@ void parse_proc_interrupts(void) - if (!c) - continue; - -- strncpy(savedline, line, sizeof(savedline)-1); -- - *c = 0; - c++; - number = strtoul(line, NULL, 10); --- -2.23.0 - diff --git a/fix-guess_arm_irq_hints.patch b/fix-guess_arm_irq_hints.patch deleted file mode 100644 index ba5eab7..0000000 --- a/fix-guess_arm_irq_hints.patch +++ /dev/null @@ -1,29 +0,0 @@ -From e4c249868cb33620691b77c570ea3b4064e4389f Mon Sep 17 00:00:00 2001 -From: Pyxisha -Date: Thu, 29 Aug 2019 14:31:25 +0800 -Subject: [PATCH 10/53] fix guess_arm_irq_hints in aarch64, irqbalance will - guess irq's class and type according to irq's name, but it did't work - properly now, a irq's name will be matched twice and class will always be - IRQ_OTHER. such as a nic interrupt, the debug log will be: IRQ eth3-tx0 - (109) guessed as class 5 IRQ eth3-tx0 (109) guessed as class 0 irq's - class should be IRQ_GBETH but is IRQ_OTHER. - ---- - procinterrupts.c | 1 + - 1 file changed, 1 insertion(+) - -diff --git a/procinterrupts.c b/procinterrupts.c -index 2088c58..3898b10 100644 ---- a/procinterrupts.c -+++ b/procinterrupts.c -@@ -137,6 +137,7 @@ static void guess_arm_irq_hints(char *name, struct irq_info *info) - if (matches[i].refine_match) - matches[i].refine_match(name, info); - log(TO_ALL, LOG_DEBUG, "IRQ %s(%d) guessed as class %d\n", name, info->irq,info->class); -+ break; - } - } - --- -2.23.0 - diff --git a/fix-invalid-pointer-dereference-banned_cpumask_from_.patch b/fix-invalid-pointer-dereference-banned_cpumask_from_.patch deleted file mode 100644 index 810f492..0000000 --- a/fix-invalid-pointer-dereference-banned_cpumask_from_.patch +++ /dev/null @@ -1,96 +0,0 @@ -From 6c350eb9af2e36c40f4c1f2122e4b5b270c011b2 Mon Sep 17 00:00:00 2001 -From: Weiping Zhang -Date: Fri, 8 Nov 2019 23:43:55 +0800 -Subject: [PATCH 41/53] fix invalid pointer dereference banned_cpumask_from_ui - -The memory of cpu_ban_string was release in sock_handle function, -so the banned_cpumask_from_ui will dereference an invalid memory. - -Fix this issue by delay release memory. - -Reproduce: -echo "settings cpus 0-3" | nc -U `find /var/run/irqbalance/ -name *sock` - -Signed-off-by: Weiping Zhang ---- - cputree.c | 7 ++++++- - irqbalance.c | 21 ++++++++++++++++++--- - 2 files changed, 24 insertions(+), 4 deletions(-) - -diff --git a/cputree.c b/cputree.c -index 305f617..4c5fdf5 100644 ---- a/cputree.c -+++ b/cputree.c -@@ -39,6 +39,7 @@ - #include "irqbalance.h" - - extern char *banned_cpumask_from_ui; -+extern char *cpu_ban_string; - - GList *cpus; - GList *cache_domains; -@@ -104,9 +105,13 @@ static void setup_banned_cpus(void) - cpus_clear(nohz_full); - - /* A manually specified cpumask overrides auto-detection. */ -- if (banned_cpumask_from_ui != NULL) { -+ if (cpu_ban_string != NULL && banned_cpumask_from_ui != NULL) { - cpulist_parse(banned_cpumask_from_ui, - strlen(banned_cpumask_from_ui), banned_cpus); -+ /* release it safety, it was allocated in sock_handle */ -+ free(cpu_ban_string); -+ cpu_ban_string = NULL; -+ banned_cpumask_from_ui = NULL; - goto out; - } - if (getenv("IRQBALANCE_BANNED_CPUS")) { -diff --git a/irqbalance.c b/irqbalance.c -index c9379ad..7630e38 100644 ---- a/irqbalance.c -+++ b/irqbalance.c -@@ -65,6 +65,7 @@ int sleep_interval = SLEEP_INTERVAL; - int last_interval; - GMainLoop *main_loop; - -+char *cpu_ban_string = NULL; - char *banned_cpumask_from_ui = NULL; - - static void sleep_approx(int seconds) -@@ -469,7 +470,14 @@ gboolean sock_handle(gint fd, GIOCondition condition, gpointer user_data __attri - free(irq_string); - } else if (!(strncmp(buff + strlen("settings "), "cpus ", - strlen("cpus")))) { -- char *cpu_ban_string = malloc( -+ /* -+ * if cpu_ban_string has not been consumed, -+ * just ignore this request. -+ */ -+ if (cpu_ban_string != NULL) -+ goto out_close; -+ -+ cpu_ban_string = malloc( - sizeof(char) * (recv_size - strlen("settings cpus "))); - - if (!cpu_ban_string) -@@ -479,9 +487,16 @@ gboolean sock_handle(gint fd, GIOCondition condition, gpointer user_data __attri - banned_cpumask_from_ui = strtok(cpu_ban_string, " "); - if (!strncmp(banned_cpumask_from_ui, "NULL", strlen("NULL"))) { - banned_cpumask_from_ui = NULL; -+ free(cpu_ban_string); -+ cpu_ban_string = NULL;; -+ } else { -+ /* -+ * don't free cpu_ban_string at here, it will be -+ * released after we have store it to @banned_cpus -+ * in setup_banned_cpus function. -+ */ -+ need_rescan = 1; - } -- need_rescan = 1; -- free(cpu_ban_string); - } - } - if (!strncmp(buff, "setup", strlen("setup"))) { --- -2.23.0 - diff --git a/fix-resource-leak-for-not-invoking-closedir-after-op.patch b/fix-resource-leak-for-not-invoking-closedir-after-op.patch deleted file mode 100644 index 1a36361..0000000 --- a/fix-resource-leak-for-not-invoking-closedir-after-op.patch +++ /dev/null @@ -1,39 +0,0 @@ -From d23f36745e4523122fbe986e53f7133e06b7d877 Mon Sep 17 00:00:00 2001 -From: Yunfeng Ye -Date: Fri, 11 Oct 2019 17:30:08 +0800 -Subject: [PATCH 22/53] fix resource leak for not invoking closedir() after - opendir() - -Signed-off-by: Yunfeng Ye ---- - classify.c | 1 + - ui/irqbalance-ui.c | 1 + - 2 files changed, 2 insertions(+) - -diff --git a/classify.c b/classify.c -index de78bba..be1ad0c 100644 ---- a/classify.c -+++ b/classify.c -@@ -583,6 +583,7 @@ static void get_irq_user_policy(char *path, int irq, struct user_irq_policy *pol - break; - } - } -+ closedir(poldir); - } - } - } -diff --git a/ui/irqbalance-ui.c b/ui/irqbalance-ui.c -index fe00e94..ed8f408 100644 ---- a/ui/irqbalance-ui.c -+++ b/ui/irqbalance-ui.c -@@ -424,6 +424,7 @@ int main(int argc, char **argv) - fclose(f); - } - } while((entry) && (irqbalance_pid == -1)); -+ closedir(dir); - } - if(irqbalance_pid == -1) { - printf("Unable to determine irqbalance PID\n"); --- -2.23.0 - diff --git a/fix-resource-leak-on-the-error-paths-in-main.patch b/fix-resource-leak-on-the-error-paths-in-main.patch deleted file mode 100644 index 76ca683..0000000 --- a/fix-resource-leak-on-the-error-paths-in-main.patch +++ /dev/null @@ -1,70 +0,0 @@ -From eab9ac80148b6c70dd025c18ecac86fae6d6bf8e Mon Sep 17 00:00:00 2001 -From: Yunfeng Ye -Date: Sun, 20 Oct 2019 22:48:22 +0800 -Subject: [PATCH 28/53] fix resource leak on the error paths in main() - -Currently, both checking for core count < 2 and init_socket() fail, just -return directly, so lead to resource leak. - -Make it correct to free resource when on these situation. - -Signed-off-by: Yunfeng Ye ---- - irqbalance.c | 12 ++++++++---- - 1 file changed, 8 insertions(+), 4 deletions(-) - -diff --git a/irqbalance.c b/irqbalance.c -index e53bf65..3ff5f13 100644 ---- a/irqbalance.c -+++ b/irqbalance.c -@@ -547,6 +547,7 @@ int init_socket() - int main(int argc, char** argv) - { - sigset_t sigset, old_sigset; -+ int ret = EXIT_SUCCESS; - - sigemptyset(&sigset); - sigaddset(&sigset,SIGINT); -@@ -637,7 +638,7 @@ int main(int argc, char** argv) - "single cpu. Shutting down\n"; - - log(TO_ALL, LOG_WARNING, "%s", msg); -- exit(EXIT_SUCCESS); -+ goto out; - } - - -@@ -660,7 +661,8 @@ int main(int argc, char** argv) - parse_proc_stat(); - - if (init_socket()) { -- return EXIT_FAILURE; -+ ret = EXIT_FAILURE; -+ goto out; - } - main_loop = g_main_loop_new(NULL, FALSE); - last_interval = sleep_interval; -@@ -669,6 +671,7 @@ int main(int argc, char** argv) - - g_main_loop_quit(main_loop); - -+out: - free_object_tree(); - free_cl_opts(); - -@@ -676,9 +679,10 @@ int main(int argc, char** argv) - if (!foreground_mode && pidfile) - unlink(pidfile); - /* Remove socket */ -- close(socket_fd); -+ if (socket_fd > 0) -+ close(socket_fd); - if (socket_name[0]) - unlink(socket_name); - -- return EXIT_SUCCESS; -+ return ret; - } --- -2.23.0 - diff --git a/fix-sleep-interval-when-sleep_interval-is-changed-by.patch b/fix-sleep-interval-when-sleep_interval-is-changed-by.patch deleted file mode 100644 index 798a1a2..0000000 --- a/fix-sleep-interval-when-sleep_interval-is-changed-by.patch +++ /dev/null @@ -1,62 +0,0 @@ -From 97730f051e042e67da5728a3b59528c9d0fb72d2 Mon Sep 17 00:00:00 2001 -From: Pyxisha -Date: Mon, 15 Jul 2019 20:47:07 +0800 -Subject: [PATCH 05/53] fix sleep interval when sleep_interval is changed by - socket - -currently, in scan, irqbalance compare sleep_interval's address to decide if sleep_interval is changed, accutually this judgement is always false now. - -sign_off_by: Shuang Xia ---- - irqbalance.c | 14 ++++++++------ - 1 file changed, 8 insertions(+), 6 deletions(-) - -diff --git a/irqbalance.c b/irqbalance.c -index c1a0e15..d424326 100644 ---- a/irqbalance.c -+++ b/irqbalance.c -@@ -61,6 +61,7 @@ char *pidfile = NULL; - char *polscript = NULL; - long HZ; - int sleep_interval = SLEEP_INTERVAL; -+int last_interval; - GMainLoop *main_loop; - - char *banned_cpumask_from_ui = NULL; -@@ -251,7 +252,7 @@ gboolean force_rescan(gpointer data __attribute__((unused))) - return TRUE; - } - --gboolean scan(gpointer data) -+gboolean scan(gpointer data __attribute__((unused))) - { - log(TO_CONSOLE, LOG_INFO, "\n\n\n-----------------------------------------------------------------------------\n"); - clear_work_stats(); -@@ -289,9 +290,10 @@ gboolean scan(gpointer data) - keep_going = 0; - cycle_count++; - -- if (data != &sleep_interval) { -- data = &sleep_interval; -- g_timeout_add_seconds(sleep_interval, scan, data); -+ /* sleep_interval may be changed by socket */ -+ if (last_interval != sleep_interval) { -+ last_interval = sleep_interval; -+ g_timeout_add_seconds(sleep_interval, scan, NULL); - return FALSE; - } - -@@ -623,8 +625,8 @@ int main(int argc, char** argv) - return EXIT_FAILURE; - } - main_loop = g_main_loop_new(NULL, FALSE); -- int *last_interval = &sleep_interval; -- g_timeout_add_seconds(sleep_interval, scan, last_interval); -+ last_interval = sleep_interval; -+ g_timeout_add_seconds(sleep_interval, scan, NULL); - g_main_loop_run(main_loop); - - g_main_loop_quit(main_loop); --- -2.23.0 - diff --git a/fix-the-pid-file-generates-too-late-problem.patch b/fix-the-pid-file-generates-too-late-problem.patch deleted file mode 100644 index 51d60f7..0000000 --- a/fix-the-pid-file-generates-too-late-problem.patch +++ /dev/null @@ -1,65 +0,0 @@ -From a23a3b9881eff000f79ca4cf9bd0e526399e6a68 Mon Sep 17 00:00:00 2001 -From: hejingxian 00273181 -Date: Fri, 6 Sep 2019 21:00:52 +0800 -Subject: [PATCH 11/53] * fix the pid file generates too late problem - -When the system processes many irqs with using user policy script, -the build_object_tree function will fork many child processes which costs several minutes. -In the irqbalance main process, the pid file generates after build_object_tree. -Therefore, the generation time of the pid file is several minutes later than the process start time. -When the irqbalance service is started by systemd based forking mode, systemd will check the pid file. -If the pid file generates too late, systemd will think the irqbalance service as starting failed. ---- - irqbalance.c | 29 +++++++++++++++-------------- - 1 file changed, 15 insertions(+), 14 deletions(-) - -diff --git a/irqbalance.c b/irqbalance.c -index d424326..8199c06 100644 ---- a/irqbalance.c -+++ b/irqbalance.c -@@ -573,6 +573,21 @@ int main(int argc, char** argv) - log(TO_ALL, LOG_WARNING, "Unable to determin HZ defaulting to 100\n"); - HZ = 100; - } -+ -+ if (!foreground_mode) { -+ int pidfd = -1; -+ if (daemon(0,0)) -+ exit(EXIT_FAILURE); -+ /* Write pidfile which can be used to avoid starting mutiple instances */ -+ if (pidfile && (pidfd = open(pidfile, -+ O_WRONLY | O_CREAT | O_EXCL | O_TRUNC, -+ S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH)) >= 0) { -+ char str[16]; -+ snprintf(str, sizeof(str), "%u\n", getpid()); -+ write(pidfd, str, strlen(str)); -+ close(pidfd); -+ } -+ } - - build_object_tree(); - if (debug_mode) -@@ -588,20 +603,6 @@ int main(int argc, char** argv) - exit(EXIT_SUCCESS); - } - -- if (!foreground_mode) { -- int pidfd = -1; -- if (daemon(0,0)) -- exit(EXIT_FAILURE); -- /* Write pidfile */ -- if (pidfile && (pidfd = open(pidfile, -- O_WRONLY | O_CREAT | O_EXCL | O_TRUNC, -- S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH)) >= 0) { -- char str[16]; -- snprintf(str, sizeof(str), "%u\n", getpid()); -- write(pidfd, str, strlen(str)); -- close(pidfd); -- } -- } - - g_unix_signal_add(SIGINT, handler, NULL); - g_unix_signal_add(SIGTERM, handler, NULL); --- -2.23.0 - diff --git a/fix-the-problem-of-banmod-that-memory-is-freed-befor.patch b/fix-the-problem-of-banmod-that-memory-is-freed-befor.patch deleted file mode 100644 index 4497676..0000000 --- a/fix-the-problem-of-banmod-that-memory-is-freed-befor.patch +++ /dev/null @@ -1,67 +0,0 @@ -From fc30c5e39428196a075aec92135bd6c10baae19b Mon Sep 17 00:00:00 2001 -From: Yunfeng Ye -Date: Mon, 14 Oct 2019 20:44:27 +0800 -Subject: [PATCH 25/53] fix the problem of banmod that memory is freed before - using - -Currently strdupa() is used to allocate memory for irq_info's name in -collect_full_irq_list(), we know that it allocate memory from stack, -when the invoking function return, the memory will be freed. so if the -irq_info's name is invalid, it will lead to check_for_module_ban() no -correct. - - check_for_irq_ban - check_for_module_ban(res->name) // res->name is not valid - -Use strdup() instead of strdupa(), and free the memory of irq_info's -name before freeing the irq_info. - -Signed-off-by: Yunfeng Ye ---- - classify.c | 9 ++++++++- - procinterrupts.c | 2 +- - 2 files changed, 9 insertions(+), 2 deletions(-) - -diff --git a/classify.c b/classify.c -index c1ac230..550f3b6 100644 ---- a/classify.c -+++ b/classify.c -@@ -750,6 +750,13 @@ static void add_missing_irq(struct irq_info *info, void *attr) - add_new_irq(info->irq, info, proc_interrupts); - } - -+static void free_tmp_irqs(gpointer data) -+{ -+ struct irq_info *info = data; -+ -+ free(info->name); -+ free(info); -+} - - void rebuild_irq_db(void) - { -@@ -779,7 +786,7 @@ void rebuild_irq_db(void) - - for_each_irq(tmp_irqs, add_missing_irq, interrupts_db); - -- g_list_free_full(tmp_irqs, free); -+ g_list_free_full(tmp_irqs, free_tmp_irqs); - - } - -diff --git a/procinterrupts.c b/procinterrupts.c -index f3f57ad..4a7a5d5 100644 ---- a/procinterrupts.c -+++ b/procinterrupts.c -@@ -229,7 +229,7 @@ GList* collect_full_irq_list() - info->class = IRQ_OTHER; - #endif - } -- info->name = strdupa(irq_mod); -+ info->name = strdup(irq_mod); - tmp_list = g_list_append(tmp_list, info); - } - free(savedline); --- -2.23.0 - diff --git a/free-cpu_ban_string-when-the-next-request-come.patch b/free-cpu_ban_string-when-the-next-request-come.patch deleted file mode 100644 index 9456773..0000000 --- a/free-cpu_ban_string-when-the-next-request-come.patch +++ /dev/null @@ -1,66 +0,0 @@ -From 0fab11043aef5b835ed5564dc15476cdbfb54d5b Mon Sep 17 00:00:00 2001 -From: SuperSix173 -Date: Thu, 6 Feb 2020 11:43:48 +0800 -Subject: [PATCH 49/53] free cpu_ban_string when the next request come - ---- - cputree.c | 4 ---- - irqbalance.c | 19 +++++-------------- - 2 files changed, 5 insertions(+), 18 deletions(-) - -diff --git a/cputree.c b/cputree.c -index 9aa4794..bef1f40 100644 ---- a/cputree.c -+++ b/cputree.c -@@ -118,10 +118,6 @@ static void setup_banned_cpus(void) - if (cpu_ban_string != NULL && banned_cpumask_from_ui != NULL) { - cpulist_parse(banned_cpumask_from_ui, - strlen(banned_cpumask_from_ui), banned_cpus); -- /* release it safety, it was allocated in sock_handle */ -- free(cpu_ban_string); -- cpu_ban_string = NULL; -- banned_cpumask_from_ui = NULL; - goto out; - } - if (getenv("IRQBALANCE_BANNED_CPUS")) { -diff --git a/irqbalance.c b/irqbalance.c -index e76d27b..9f65c88 100644 ---- a/irqbalance.c -+++ b/irqbalance.c -@@ -471,12 +471,9 @@ gboolean sock_handle(gint fd, GIOCondition condition, gpointer user_data __attri - free(irq_string); - } else if (!(strncmp(buff + strlen("settings "), "cpus ", - strlen("cpus")))) { -- /* -- * if cpu_ban_string has not been consumed, -- * just ignore this request. -- */ -- if (cpu_ban_string != NULL) -- goto out_close; -+ banned_cpumask_from_ui = NULL; -+ free(cpu_ban_string); -+ cpu_ban_string = NULL; - - cpu_ban_string = malloc( - sizeof(char) * (recv_size - strlen("settings cpus "))); -@@ -489,15 +486,9 @@ gboolean sock_handle(gint fd, GIOCondition condition, gpointer user_data __attri - if (!strncmp(banned_cpumask_from_ui, "NULL", strlen("NULL"))) { - banned_cpumask_from_ui = NULL; - free(cpu_ban_string); -- cpu_ban_string = NULL;; -- } else { -- /* -- * don't free cpu_ban_string at here, it will be -- * released after we have store it to @banned_cpus -- * in setup_banned_cpus function. -- */ -- need_rescan = 1; -+ cpu_ban_string = NULL; - } -+ need_rescan = 1; - } - } - if (!strncmp(buff, "setup", strlen("setup"))) { --- -2.23.0 - diff --git a/free-polscript-if-irqbalance-exit.patch b/free-polscript-if-irqbalance-exit.patch deleted file mode 100644 index 244f095..0000000 --- a/free-polscript-if-irqbalance-exit.patch +++ /dev/null @@ -1,26 +0,0 @@ -From 3768776c7b4f7f79f52dc025d50a5e2d214f5b2c Mon Sep 17 00:00:00 2001 -From: liuchao173 <55137861+liuchao173@users.noreply.github.com> -Date: Mon, 2 Dec 2019 19:46:53 +0800 -Subject: [PATCH 44/53] free polscript if irqbalance exit - -polscript is alloced in parse_command_line and isn't freed when irqbalance exit ---- - irqbalance.c | 2 ++ - 1 file changed, 2 insertions(+) - -diff --git a/irqbalance.c b/irqbalance.c -index 7630e38..5134f9d 100644 ---- a/irqbalance.c -+++ b/irqbalance.c -@@ -702,6 +702,8 @@ int main(int argc, char** argv) - out: - free_object_tree(); - free_cl_opts(); -+ if (polscript) -+ free(polscript); - - /* Remove pidfile */ - if (!foreground_mode && pidfile) --- -2.23.0 - diff --git a/free-polscript-to-avoid-resource-leak.patch b/free-polscript-to-avoid-resource-leak.patch deleted file mode 100644 index 508c579..0000000 --- a/free-polscript-to-avoid-resource-leak.patch +++ /dev/null @@ -1,35 +0,0 @@ -From 6e4ef7f8a13147c15ac542f829b5a7b6a93ce239 Mon Sep 17 00:00:00 2001 -From: liuchao173 <55137861+liuchao173@users.noreply.github.com> -Date: Tue, 3 Dec 2019 09:30:40 +0800 -Subject: [PATCH 45/53] free polscript to avoid resource leak - -free polscript when irqbalance exit or the same option is passed twice on the comand line ---- - irqbalance.c | 4 ++-- - 1 file changed, 2 insertions(+), 2 deletions(-) - -diff --git a/irqbalance.c b/irqbalance.c -index 5134f9d..e76d27b 100644 ---- a/irqbalance.c -+++ b/irqbalance.c -@@ -153,6 +153,7 @@ static void parse_command_line(int argc, char **argv) - add_cl_banned_irq((int)val); - break; - case 'l': -+ free(polscript); - polscript = strdup(optarg); - break; - case 'm': -@@ -702,8 +703,7 @@ int main(int argc, char** argv) - out: - free_object_tree(); - free_cl_opts(); -- if (polscript) -- free(polscript); -+ free(polscript); - - /* Remove pidfile */ - if (!foreground_mode && pidfile) --- -2.23.0 - diff --git a/free-the-memory-when-getline-fail-in-add_one_node.patch b/free-the-memory-when-getline-fail-in-add_one_node.patch deleted file mode 100644 index 94dd396..0000000 --- a/free-the-memory-when-getline-fail-in-add_one_node.patch +++ /dev/null @@ -1,35 +0,0 @@ -From 403b17259db89fed7a037a98948da3930fed6b24 Mon Sep 17 00:00:00 2001 -From: yeyunfeng -Date: Sun, 6 Oct 2019 22:04:22 +0800 -Subject: [PATCH 20/53] free the memory when getline() fail in add_one_node() - -when getline() fail, the memory still need to be freed. - -Signed-off-by: Yunfeng Ye ---- - numa.c | 7 +++---- - 1 file changed, 3 insertions(+), 4 deletions(-) - -diff --git a/numa.c b/numa.c -index f0b1a98..542e1f4 100644 ---- a/numa.c -+++ b/numa.c -@@ -74,12 +74,11 @@ static void add_one_node(const char *nodename) - cpus_clear(new->mask); - } else { - ret = getline(&cpustr, &blen, f); -- if (ret <= 0) { -+ if (ret <= 0) - cpus_clear(new->mask); -- } else { -+ else - cpumask_parse_user(cpustr, ret, new->mask); -- free(cpustr); -- } -+ free(cpustr); - } - fclose(f); - new->obj_type = OBJ_TYPE_NODE; --- -2.23.0 - diff --git a/getline-clean-up-freeing-of-lines-from-getline.patch b/getline-clean-up-freeing-of-lines-from-getline.patch deleted file mode 100644 index 641d79a..0000000 --- a/getline-clean-up-freeing-of-lines-from-getline.patch +++ /dev/null @@ -1,106 +0,0 @@ -From 50f7f4641534c8137b329f2c6cdeaa20987c9382 Mon Sep 17 00:00:00 2001 -From: Neil Horman -Date: Mon, 30 Sep 2019 11:46:37 -0400 -Subject: [PATCH 19/53] getline: clean up freeing of lines from getline - -It was noted that several calls to getline failed to free the resultant line, -which the man page for getline says to do even if the call fails. Clean that up -here - -And while we're at it, merge some of the free calls so they're common to a -function where they can be, and not strewn all over the place - -Signed-off-by: Neil Horman ---- - cputree.c | 29 +++++++++++++++++------------ - 1 file changed, 17 insertions(+), 12 deletions(-) - -diff --git a/cputree.c b/cputree.c -index 91c6111..a90cbbe 100644 ---- a/cputree.c -+++ b/cputree.c -@@ -91,10 +91,10 @@ static void setup_banned_cpus(void) - if (getline(&line, &size, file) > 0) { - if (strlen(line) && line[0] != '\n') - cpulist_parse(line, strlen(line), isolated_cpus); -- free(line); -- line = NULL; -- size = 0; - } -+ free(line); -+ line = NULL; -+ size = 0; - fclose(file); - } - -@@ -103,10 +103,10 @@ static void setup_banned_cpus(void) - if (getline(&line, &size, file) > 0) { - if (strlen(line) && line[0] != '\n') - cpulist_parse(line, strlen(line), nohz_full); -- free(line); -- line = NULL; -- size = 0; - } -+ free(line); -+ line = NULL; -+ size = 0; - fclose(file); - } - -@@ -271,6 +271,7 @@ static void do_one_cpu(char *path) - int nodeid; - int packageid = 0; - unsigned int max_cache_index, cache_index, cache_stat; -+ int ret = 1; - - /* skip offline cpus */ - snprintf(new_path, ADJ_SIZE(path,"/online"), "%s/online", path); -@@ -278,14 +279,12 @@ static void do_one_cpu(char *path) - if (file) { - char *line = NULL; - size_t size = 0; -- if (getline(&line, &size, file)<=0) -- return; -+ if (getline(&line, &size, file)>0) -+ ret = (line && line[0]=='0') ? 1 : 0; - fclose(file); -- if (line && line[0]=='0') { -- free(line); -- return; -- } - free(line); -+ if (ret) -+ return; - } - - cpu = calloc(sizeof(struct topo_obj), 1); -@@ -327,6 +326,8 @@ static void do_one_cpu(char *path) - cpumask_parse_user(line, strlen(line), package_mask); - fclose(file); - free(line); -+ line = NULL; -+ size = 0; - } - /* try to read the package id */ - snprintf(new_path, ADJ_SIZE(path, "/topology/physical_package_id"), -@@ -339,6 +340,8 @@ static void do_one_cpu(char *path) - packageid = strtoul(line, NULL, 10); - fclose(file); - free(line); -+ line = NULL; -+ size = 0; - } - - /* try to read the cache mask; if it doesn't exist assume solitary */ -@@ -372,6 +375,8 @@ static void do_one_cpu(char *path) - cpumask_parse_user(line, strlen(line), cache_mask); - fclose(file); - free(line); -+ line = NULL; -+ size = 0; - } - } - --- -2.23.0 - diff --git a/improve-comments-in-env-file.patch b/improve-comments-in-env-file.patch deleted file mode 100644 index a6b024e..0000000 --- a/improve-comments-in-env-file.patch +++ /dev/null @@ -1,55 +0,0 @@ -From 0a28c3a67e43ec8f96ed046e9e076fb8a454ab01 Mon Sep 17 00:00:00 2001 -From: Adrian Friedli -Date: Tue, 27 Aug 2019 22:30:22 +0200 -Subject: [PATCH 09/53] improve comments in env file - ---- - misc/irqbalance.env | 21 ++++++++++++--------- - 1 file changed, 12 insertions(+), 9 deletions(-) - -diff --git a/misc/irqbalance.env b/misc/irqbalance.env -index bd87e3d..23570b2 100644 ---- a/misc/irqbalance.env -+++ b/misc/irqbalance.env -@@ -1,26 +1,29 @@ - # irqbalance is a daemon process that distributes interrupts across --# CPUS on SMP systems. The default is to rebalance once every 10 --# seconds. This is the environment file that is specified to systemd via the -+# CPUs on SMP systems. The default is to rebalance once every 10 -+# seconds. This is the environment file that is specified to systemd via the - # EnvironmentFile key in the service unit file (or via whatever method the init --# system you're using has. -+# system you're using has). -+ - # --# ONESHOT=yes --# after starting, wait for a minute, then look at the interrupt -+# IRQBALANCE_ONESHOT -+# After starting, wait for a minute, then look at the interrupt - # load and balance it once; after balancing exit and do not change - # it again. -+# - #IRQBALANCE_ONESHOT= - - # - # IRQBALANCE_BANNED_CPUS --# 64 bit bitmask which allows you to indicate which cpu's should --# be skipped when reblancing irqs. Cpu numbers which have their -+# 64 bit bitmask which allows you to indicate which CPUs should -+# be skipped when reblancing IRQs. CPU numbers which have their - # corresponding bits set to one in this mask will not have any --# irq's assigned to them on rebalance -+# IRQs assigned to them on rebalance. - # - #IRQBALANCE_BANNED_CPUS= - - # - # IRQBALANCE_ARGS --# append any args here to the irqbalance daemon as documented in the man page -+# Append any args here to the irqbalance daemon as documented in the man -+# page. - # - #IRQBALANCE_ARGS= --- -2.23.0 - diff --git a/improve-irq-migrate-rule-to-avoid-high-irq-load.patch b/improve-irq-migrate-rule-to-avoid-high-irq-load.patch deleted file mode 100644 index 5f73bc6..0000000 --- a/improve-irq-migrate-rule-to-avoid-high-irq-load.patch +++ /dev/null @@ -1,105 +0,0 @@ -From e9e28114036a198b311ee17dd542540f749e6a68 Mon Sep 17 00:00:00 2001 -From: hejingxian 00273181 -Date: Mon, 20 Jan 2020 23:20:47 +0800 -Subject: [PATCH 48/53] improve irq migrate rule to avoid high irq load - ---- - irqbalance.c | 9 +++++++-- - irqbalance.h | 1 + - irqlist.c | 10 +++++++++- - 3 files changed, 17 insertions(+), 3 deletions(-) - -diff --git a/irqbalance.c b/irqbalance.c -index be111f1..513ab5a 100644 ---- a/irqbalance.c -+++ b/irqbalance.c -@@ -67,6 +67,7 @@ GMainLoop *main_loop; - - char *cpu_ban_string = NULL; - char *banned_cpumask_from_ui = NULL; -+unsigned long migrate_ratio = 0; - - static void sleep_approx(int seconds) - { -@@ -96,6 +97,7 @@ struct option lopts[] = { - {"banmod", 1 , NULL, 'm'}, - {"interval", 1 , NULL, 't'}, - {"version", 0, NULL, 'V'}, -+ {"migrateval", 1, NULL, 'e'}, - {0, 0, 0, 0} - }; - -@@ -103,7 +105,7 @@ static void usage(void) - { - log(TO_CONSOLE, LOG_INFO, "irqbalance [--oneshot | -o] [--debug | -d] [--foreground | -f] [--journal | -j]\n"); - log(TO_CONSOLE, LOG_INFO, " [--powerthresh= | -p | ] [--banirq= | -i ] [--banmod= | -m ] [--policyscript= | -l