diff --git a/Add-irqbalance-ui.1-to-dist_man_MANS.patch b/Add-irqbalance-ui.1-to-dist_man_MANS.patch new file mode 100644 index 0000000..b5046fd --- /dev/null +++ b/Add-irqbalance-ui.1-to-dist_man_MANS.patch @@ -0,0 +1,26 @@ +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 new file mode 100644 index 0000000..da1f22b --- /dev/null +++ b/Add-optional-config-file-in-usr-lib.patch @@ -0,0 +1,33 @@ +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 new file mode 100644 index 0000000..8db4eca --- /dev/null +++ b/Add-stub-manpage-for-irqbalance-ui.patch @@ -0,0 +1,59 @@ +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 new file mode 100644 index 0000000..91153d8 --- /dev/null +++ b/Capitalize-HOMEPAGE-in-irqbalance.1.patch @@ -0,0 +1,24 @@ +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 index 30266a3..2c4a962 100644 --- a/Checking-return-value-of-strdup-in-collect_full_irq_.patch +++ b/Checking-return-value-of-strdup-in-collect_full_irq_.patch @@ -1,7 +1,7 @@ -From 7dafc4d5c8d8229f107c90d97f33a4094eb89c6e Mon Sep 17 00:00:00 2001 -From: liuchao173 -Date: Thu, 7 Nov 2019 09:12:42 +0000 -Subject: [PATCH 1/8] backport: Checking return value of strdup() in +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 @@ -13,10 +13,10 @@ Signed-off-by: Yunfeng Ye 1 file changed, 2 insertions(+) diff --git a/procinterrupts.c b/procinterrupts.c -index 2c8118a..87fae2f 100644 +index 44c5c76..f3f57ad 100644 --- a/procinterrupts.c +++ b/procinterrupts.c -@@ -188,6 +188,8 @@ GList* collect_full_irq_list() +@@ -189,6 +189,8 @@ GList* collect_full_irq_list() continue; savedline = strdup(line); @@ -26,4 +26,5 @@ index 2c8118a..87fae2f 100644 if (strstr(irq_name, "xen-dyn") != NULL) is_xen_dyn = 1; -- -2.19.1 +2.23.0 + diff --git a/Clarify-the-README-description.patch b/Clarify-the-README-description.patch new file mode 100644 index 0000000..3ade695 --- /dev/null +++ b/Clarify-the-README-description.patch @@ -0,0 +1,31 @@ +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 new file mode 100644 index 0000000..99ed120 --- /dev/null +++ b/Correct-typos-in-irqbalance.c.patch @@ -0,0 +1,43 @@ +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/Don-t-leak-socket-fd-on-connection-error.patch b/Don-t-leak-socket-fd-on-connection-error.patch deleted file mode 100644 index 055ccff..0000000 --- a/Don-t-leak-socket-fd-on-connection-error.patch +++ /dev/null @@ -1,65 +0,0 @@ -From f2623176c2997e7803d485084fa5150556caddcf Mon Sep 17 00:00:00 2001 -From: Kairui Song -Date: Mon, 5 Nov 2018 17:18:49 +0800 -Subject: [PATCH 102/112] Don't leak socket fd on connection error - -Signed-off-by: Kairui Song ---- - irqbalance.c | 7 ++++--- - ui/irqbalance-ui.c | 1 + - 2 files changed, 5 insertions(+), 3 deletions(-) - -diff --git a/irqbalance.c b/irqbalance.c -index 0946603..364ca72 100644 ---- a/irqbalance.c -+++ b/irqbalance.c -@@ -376,7 +376,7 @@ gboolean sock_handle(gint fd, GIOCondition condition, gpointer user_data __attri - } - if ((recv_size = recvmsg(sock, &msg, 0)) < 0) { - log(TO_ALL, LOG_WARNING, "Error while receiving data.\n"); -- goto out; -+ goto out_close; - } - cmsg = CMSG_FIRSTHDR(&msg); - if ((cmsg->cmsg_level == SOL_SOCKET) && -@@ -388,7 +388,7 @@ gboolean sock_handle(gint fd, GIOCondition condition, gpointer user_data __attri - } - if (!valid_user) { - log(TO_ALL, LOG_INFO, "Permission denied for user to connect to socket.\n"); -- goto out; -+ goto out_close; - } - - if (!strncmp(buff, "stats", strlen("stats"))) { -@@ -421,7 +421,7 @@ gboolean sock_handle(gint fd, GIOCondition condition, gpointer user_data __attri - need_rescan = 1; - if (!strncmp(irq_string, "NONE", strlen("NONE"))) { - free(irq_string); -- goto out; -+ goto out_close; - } - int irq = strtoul(irq_string, &end, 10); - do { -@@ -457,6 +457,7 @@ gboolean sock_handle(gint fd, GIOCondition condition, gpointer user_data __attri - free(setup); - } - -+out_close: - close(sock); - } - -diff --git a/ui/irqbalance-ui.c b/ui/irqbalance-ui.c -index 5a76ddf..005eea4 100644 ---- a/ui/irqbalance-ui.c -+++ b/ui/irqbalance-ui.c -@@ -66,6 +66,7 @@ int init_connection() - memset(&addr, 0, sizeof(struct sockaddr_un)); - addr.sun_family = AF_UNIX; - if (connect(socket_fd, (struct sockaddr *)&addr, sizeof(addr)) < 0) { -+ close(socket_fd); - return 0; - } - --- -1.8.3.1 - diff --git a/Fix-ambiguous-parsing-of-node-entries-in-sys.patch b/Fix-ambiguous-parsing-of-node-entries-in-sys.patch deleted file mode 100644 index eb68d23..0000000 --- a/Fix-ambiguous-parsing-of-node-entries-in-sys.patch +++ /dev/null @@ -1,73 +0,0 @@ -From 721460664afad79e2d96bbcb173eda68eed9743b Mon Sep 17 00:00:00 2001 -From: Gerd Rausch -Date: Thu, 18 Oct 2018 11:21:40 -0700 -Subject: [PATCH 100/112] Fix ambiguous parsing of *node* entries in /sys. - -The code used to use strstr(..., "node") while iterating over -sysfs directories such as /sys/devices/system/cpu/cpu*. -It then made an assumption that the entry would start with "node", -which is not necessarily the case (e.g. the "firmware_node" entry). - -The code happened to work for as long as the node[0-9]* entry -would be processed before the "firmware_node" entry shows up. - -A change to the linux kernel "end_name_hash" function resulted -in a different hash, and ultimately in a different order -by which entries were returned by readdir(3). - -This led to the exposure of this bug. - -Signed-off-by: Gerd Rausch ---- - cputree.c | 11 ++++++++--- - numa.c | 5 ++++- - 2 files changed, 12 insertions(+), 4 deletions(-) - -diff --git a/cputree.c b/cputree.c -index c88143f..f08ce84 100644 ---- a/cputree.c -+++ b/cputree.c -@@ -368,9 +368,14 @@ static void do_one_cpu(char *path) - entry = readdir(dir); - if (!entry) - break; -- if (strstr(entry->d_name, "node")) { -- nodeid = strtoul(&entry->d_name[4], NULL, 10); -- break; -+ if (strncmp(entry->d_name, "node", 4) == 0) { -+ char *end; -+ int num; -+ num = strtol(entry->d_name + 4, &end, 10); -+ if (!*end && num >= 0) { -+ nodeid = num; -+ break; -+ } - } - } while (entry); - closedir(dir); -diff --git a/numa.c b/numa.c -index cd67ec8..f0b1a98 100644 ---- a/numa.c -+++ b/numa.c -@@ -29,6 +29,7 @@ - #include - #include - #include -+#include - #include - #include - -@@ -115,7 +116,9 @@ void build_numa_node_list(void) - entry = readdir(dir); - if (!entry) - break; -- if ((entry->d_type == DT_DIR) && (strstr(entry->d_name, "node"))) { -+ if ((entry->d_type == DT_DIR) && -+ (strncmp(entry->d_name, "node", 4) == 0) && -+ isdigit(entry->d_name[4])) { - add_one_node(entry->d_name); - } - } while (entry); --- -1.8.3.1 - diff --git a/Fix-an-possible-overflow-error.patch b/Fix-an-possible-overflow-error.patch deleted file mode 100644 index 2a56e3a..0000000 --- a/Fix-an-possible-overflow-error.patch +++ /dev/null @@ -1,34 +0,0 @@ -From 702cab67df2bafd9735a753387eae7febd74263b Mon Sep 17 00:00:00 2001 -From: Kairui Song -Date: Sun, 2 Sep 2018 23:40:45 +0800 -Subject: [PATCH 095/112] Fix an possible overflow error - -Got: -"specified bound 2048 exceeds the size 19 of the destination" -when -O2 is used, and a "*** buffer overflow detected ***" error output -with no backtrace. - -With -O0, it's gone, guess it's some gcc optimization problem, and the -size there is wrong anyway, this patch could fix it. ---- - irqbalance.c | 4 ++-- - 1 file changed, 2 insertions(+), 2 deletions(-) - -diff --git a/irqbalance.c b/irqbalance.c -index 81bf8d8..0946603 100644 ---- a/irqbalance.c -+++ b/irqbalance.c -@@ -444,8 +444,8 @@ 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); -- snprintf(setup, 2048, "SLEEP %d ", sleep_interval); -+ char *setup = calloc(strlen("SLEEP ") + 11 + 1, 1); -+ 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); - } --- -1.8.3.1 - diff --git a/Fix-irqbalance-ui-failing-to-connect-to-irqbalance-d.patch b/Fix-irqbalance-ui-failing-to-connect-to-irqbalance-d.patch deleted file mode 100644 index 68afbc3..0000000 --- a/Fix-irqbalance-ui-failing-to-connect-to-irqbalance-d.patch +++ /dev/null @@ -1,57 +0,0 @@ -From ce806df0081cf09344197285e32bd2113d86f554 Mon Sep 17 00:00:00 2001 -From: Kairui Song -Date: Mon, 3 Sep 2018 00:30:14 +0800 -Subject: [PATCH 23/58] Fix irqbalance ui failing to connect to irqbalance - daemon - -irqbalance ui is faling due to the changes in commit 19c25dd. -This patch align irqbalance-ui's socket connecting routine with -irqbalance.c ---- - ui/irqbalance-ui.c | 16 +++++++++++----- - ui/irqbalance-ui.h | 1 + - 2 files changed, 12 insertions(+), 5 deletions(-) - -diff --git a/ui/irqbalance-ui.c b/ui/irqbalance-ui.c -index 47dd5dc..5a76ddf 100644 ---- a/ui/irqbalance-ui.c -+++ b/ui/irqbalance-ui.c -@@ -57,12 +57,18 @@ int init_connection() - } - addr.sun_family = AF_UNIX; - char socket_name[64]; -- snprintf(socket_name, 64, "%s%d.sock", SOCKET_PATH, irqbalance_pid); -- strncpy(addr.sun_path, socket_name, strlen(addr.sun_path)); - -- if(connect(socket_fd, (struct sockaddr *)&addr, -- sizeof(sa_family_t) + strlen(socket_name) + 1) < 0) { -- return 0; -+ snprintf(socket_name, 64, "%s/%s%d.sock", SOCKET_TMPFS, SOCKET_PATH, irqbalance_pid); -+ strncpy(addr.sun_path, socket_name, strlen(socket_name)); -+ -+ if(connect(socket_fd, (struct sockaddr *)&addr, sizeof(addr)) < 0) { -+ /* Try connect to abstract */ -+ memset(&addr, 0, sizeof(struct sockaddr_un)); -+ addr.sun_family = AF_UNIX; -+ if (connect(socket_fd, (struct sockaddr *)&addr, sizeof(addr)) < 0) { -+ return 0; -+ } -+ - } - - return socket_fd; -diff --git a/ui/irqbalance-ui.h b/ui/irqbalance-ui.h -index f97fcb1..b32d58a 100644 ---- a/ui/irqbalance-ui.h -+++ b/ui/irqbalance-ui.h -@@ -8,6 +8,7 @@ - #include - - #define SOCKET_PATH "irqbalance" -+#define SOCKET_TMPFS "/var/run" - - #define STATS "stats" - #define SET_SLEEP "settings sleep " --- -1.8.3.1 - diff --git a/Fix-several-memleak-problems-found-by-covscan.patch b/Fix-several-memleak-problems-found-by-covscan.patch deleted file mode 100644 index 91c4d0b..0000000 --- a/Fix-several-memleak-problems-found-by-covscan.patch +++ /dev/null @@ -1,253 +0,0 @@ -From 85d37098a551034061d4b77be275d664e109c3fb Mon Sep 17 00:00:00 2001 -From: Kairui Song -Date: Thu, 30 Aug 2018 17:45:53 +0800 -Subject: [PATCH 094/112] Fix several memleak problems found by covscan - -Some memleak issues is found by static analysis tools, and can confirm -irqbalance is leaking memory slowly when there are incomming connection -to socket. - -This patch could solve the memleak problem. ---- - irqbalance.c | 16 ++++++++++++---- - ui/irqbalance-ui.c | 31 +++++++++++++++++++++++++++---- - ui/ui.c | 2 ++ - 3 files changed, 41 insertions(+), 8 deletions(-) - -diff --git a/irqbalance.c b/irqbalance.c -index bce9d56..81bf8d8 100644 ---- a/irqbalance.c -+++ b/irqbalance.c -@@ -372,11 +372,11 @@ gboolean sock_handle(gint fd, GIOCondition condition, gpointer user_data __attri - sock = accept(fd, NULL, NULL); - if (sock < 0) { - log(TO_ALL, LOG_WARNING, "Connection couldn't be accepted.\n"); -- return TRUE; -+ goto out; - } - if ((recv_size = recvmsg(sock, &msg, 0)) < 0) { - log(TO_ALL, LOG_WARNING, "Error while receiving data.\n"); -- return TRUE; -+ goto out; - } - cmsg = CMSG_FIRSTHDR(&msg); - if ((cmsg->cmsg_level == SOL_SOCKET) && -@@ -388,7 +388,7 @@ gboolean sock_handle(gint fd, GIOCondition condition, gpointer user_data __attri - } - if (!valid_user) { - log(TO_ALL, LOG_INFO, "Permission denied for user to connect to socket.\n"); -- return TRUE; -+ goto out; - } - - if (!strncmp(buff, "stats", strlen("stats"))) { -@@ -408,6 +408,7 @@ gboolean sock_handle(gint fd, GIOCondition condition, gpointer user_data __attri - if (new_iterval >= 1) { - sleep_interval = new_iterval; - } -+ free(sleep_string); - } else if (!(strncmp(buff + strlen("settings "), "ban irqs ", - strlen("ban irqs ")))) { - char *end; -@@ -419,12 +420,14 @@ gboolean sock_handle(gint fd, GIOCondition condition, gpointer user_data __attri - cl_banned_irqs = NULL; - need_rescan = 1; - if (!strncmp(irq_string, "NONE", strlen("NONE"))) { -- return TRUE; -+ free(irq_string); -+ goto out; - } - int irq = strtoul(irq_string, &end, 10); - do { - add_cl_banned_irq(irq); - } while((irq = strtoul(end, &end, 10))); -+ free(irq_string); - } else if (!(strncmp(buff + strlen("settings "), "cpus ", - strlen("cpus")))) { - char *cpu_ban_string = malloc( -@@ -436,6 +439,7 @@ gboolean sock_handle(gint fd, GIOCondition condition, gpointer user_data __attri - banned_cpumask_from_ui = NULL; - } - need_rescan = 1; -+ free(cpu_ban_string); - } - } - if (!strncmp(buff, "setup", strlen("setup"))) { -@@ -450,10 +454,14 @@ gboolean sock_handle(gint fd, GIOCondition condition, gpointer user_data __attri - snprintf(setup + strlen(setup), strlen(banned) + 7 + 1, - "BANNED %s", banned); - send(sock, setup, strlen(setup), 0); -+ free(setup); - } - - close(sock); - } -+ -+out: -+ free(msg.msg_control); - return TRUE; - } - -diff --git a/ui/irqbalance-ui.c b/ui/irqbalance-ui.c -index d4deee0..47dd5dc 100644 ---- a/ui/irqbalance-ui.c -+++ b/ui/irqbalance-ui.c -@@ -41,6 +41,7 @@ struct msghdr * create_credentials_msg() - cmsg->cmsg_len = CMSG_LEN(sizeof(struct ucred)); - memcpy(CMSG_DATA(cmsg), credentials, sizeof(struct ucred)); - -+ free(credentials); - return msg; - } - -@@ -87,6 +88,8 @@ void send_settings(char *data) - sendmsg(socket_fd, msg, 0); - - close(socket_fd); -+ free(msg->msg_control); -+ free(msg); - } - - char * get_data(char *string) -@@ -115,6 +118,8 @@ char * get_data(char *string) - int len = recv(socket_fd, data, 8192, 0); - close(socket_fd); - data[len] = '\0'; -+ free(msg->msg_control); -+ free(msg); - return data; - } - -@@ -123,6 +128,7 @@ void parse_setup(char *setup_data) - char *token, *ptr; - int i,j; - char *copy; -+ irq_t *new_irq = NULL; - if((setup_data == NULL) || (strlen(setup_data) == 0)) return; - copy = strdup(setup_data); - if (!copy) -@@ -136,7 +142,7 @@ void parse_setup(char *setup_data) - token = strtok_r(NULL, " ", &ptr); - /* Parse banned IRQ data */ - while(!strncmp(token, "IRQ", strlen("IRQ"))) { -- irq_t *new_irq = malloc(sizeof(irq_t)); -+ new_irq = malloc(sizeof(irq_t)); - new_irq->vector = strtol(strtok_r(NULL, " ", &ptr), NULL, 10); - token = strtok_r(NULL, " ", &ptr); - if(strncmp(token, "LOAD", strlen("LOAD"))) goto out; -@@ -151,6 +157,7 @@ void parse_setup(char *setup_data) - new_irq->assigned_to = NULL; - setup.banned_irqs = g_list_append(setup.banned_irqs, new_irq); - token = strtok_r(NULL, " ", &ptr); -+ new_irq = NULL; - } - - if(strncmp(token, "BANNED", strlen("BANNED"))) goto out; -@@ -165,6 +172,7 @@ void parse_setup(char *setup_data) - banned_cpu); - } - } -+ free(map); - - } - free(copy); -@@ -173,6 +181,9 @@ void parse_setup(char *setup_data) - out: { - /* Invalid data presented */ - printf("Invalid data sent. Unexpected token: %s", token); -+ if (new_irq) { -+ free(new_irq); -+ } - free(copy); - g_list_free(tree); - exit(1); -@@ -240,7 +251,9 @@ void parse_into_tree(char *data) - cpu_node_t *parent = NULL; - char *copy; - tree = NULL; -- -+ irq_t *new_irq = NULL; -+ cpu_node_t *new = NULL; -+ - if (!data || strlen(data) == 0) - return; - -@@ -255,7 +268,7 @@ void parse_into_tree(char *data) - free(copy); - goto out; - } -- cpu_node_t *new = malloc(sizeof(cpu_node_t)); -+ new = malloc(sizeof(cpu_node_t)); - new->irqs = NULL; - new->children = NULL; - new->cpu_list = NULL; -@@ -279,7 +292,7 @@ void parse_into_tree(char *data) - - /* Parse assigned IRQ data */ - while((token != NULL) && (!strncmp(token, "IRQ", strlen("IRQ")))) { -- irq_t *new_irq = malloc(sizeof(irq_t)); -+ new_irq = malloc(sizeof(irq_t)); - new_irq->vector = strtol(strtok_r(NULL, " ", &ptr), NULL, 10); - token = strtok_r(NULL, " ", &ptr); - if(strncmp(token, "LOAD", strlen("LOAD"))) goto out; -@@ -293,6 +306,7 @@ void parse_into_tree(char *data) - new_irq->is_banned = 0; - new->irqs = g_list_append(new->irqs, new_irq); - token = strtok_r(NULL, " ", &ptr); -+ new_irq = NULL; - } - - if((token == NULL) || (strncmp(token, "IRQ", strlen("IRQ")))) { -@@ -306,6 +320,8 @@ void parse_into_tree(char *data) - parent = new; - } - } -+ -+ new = NULL; - } - free(copy); - for_each_node(tree, assign_cpu_lists, NULL); -@@ -315,6 +331,12 @@ void parse_into_tree(char *data) - out: { - /* Invalid data presented */ - printf("Invalid data sent. Unexpected token: %s\n", token); -+ if (new_irq) { -+ free(new_irq); -+ } -+ if (new) { -+ free(new); -+ } - g_list_free(tree); - exit(1); - } -@@ -330,6 +352,7 @@ gboolean rescan_tree(gpointer data __attribute__((unused))) - display_tree(); - } - free(setup_data); -+ free(irqbalance_data); - return TRUE; - } - -diff --git a/ui/ui.c b/ui/ui.c -index 4054f0e..06ec472 100644 ---- a/ui/ui.c -+++ b/ui/ui.c -@@ -71,6 +71,7 @@ char * check_control_in_sleep_input(int max_len, int column_offest, int line_off - attrset(COLOR_PAIR(6)); - break; - case 27: -+ free(input_to); - return NULL; - default: - input_to[iteration] = new; -@@ -115,6 +116,7 @@ int get_valid_sleep_input(int column_offest) - input); - refresh(); - } -+ free(input); - } - - attrset(COLOR_PAIR(1)); --- -1.8.3.1 - diff --git a/Fix-some-string-copy-limitations.patch b/Fix-some-string-copy-limitations.patch deleted file mode 100644 index 852d5c9..0000000 --- a/Fix-some-string-copy-limitations.patch +++ /dev/null @@ -1,58 +0,0 @@ -From d6abbe898baa111207e1e9316dde75c38d555325 Mon Sep 17 00:00:00 2001 -From: Neil Horman -Date: Mon, 9 Jul 2018 10:12:41 -0400 -Subject: [PATCH 091/112] Fix some string copy limitations - -Latest gcc caught some errors in our string copying routines. Fix those -up - -Signed-off-by: Neil Horman ---- - irqbalance.c | 3 +-- - procinterrupts.c | 2 +- - ui/irqbalance-ui.c | 2 +- - 3 files changed, 3 insertions(+), 4 deletions(-) - -diff --git a/irqbalance.c b/irqbalance.c -index 66e56f8..2614719 100644 ---- a/irqbalance.c -+++ b/irqbalance.c -@@ -468,8 +468,7 @@ int init_socket(char *socket_name) - } - - addr.sun_family = AF_UNIX; -- addr.sun_path[0] = '\0'; -- strncpy(addr.sun_path + 1, socket_name, strlen(socket_name)); -+ strncpy(addr.sun_path, socket_name, strlen(addr.sun_path)); - if (bind(socket_fd, (struct sockaddr *)&addr, - sizeof(sa_family_t) + strlen(socket_name) + 1) < 0) { - log(TO_ALL, LOG_WARNING, "Daemon couldn't be bound to the socket.\n"); -diff --git a/procinterrupts.c b/procinterrupts.c -index 4ef8751..7283998 100644 ---- a/procinterrupts.c -+++ b/procinterrupts.c -@@ -274,7 +274,7 @@ void parse_proc_interrupts(void) - if (!c) - continue; - -- strncpy(savedline, line, sizeof(savedline)); -+ strncpy(savedline, line, sizeof(savedline)-1); - - *c = 0; - c++; -diff --git a/ui/irqbalance-ui.c b/ui/irqbalance-ui.c -index 3fc46af..d4deee0 100644 ---- a/ui/irqbalance-ui.c -+++ b/ui/irqbalance-ui.c -@@ -57,7 +57,7 @@ int init_connection() - addr.sun_family = AF_UNIX; - char socket_name[64]; - snprintf(socket_name, 64, "%s%d.sock", SOCKET_PATH, irqbalance_pid); -- strncpy(addr.sun_path + 1, socket_name, strlen(socket_name)); -+ strncpy(addr.sun_path, socket_name, strlen(addr.sun_path)); - - if(connect(socket_fd, (struct sockaddr *)&addr, - sizeof(sa_family_t) + strlen(socket_name) + 1) < 0) { --- -1.8.3.1 - diff --git a/Fix-spelling-errors.patch b/Fix-spelling-errors.patch new file mode 100644 index 0000000..7ab6048 --- /dev/null +++ b/Fix-spelling-errors.patch @@ -0,0 +1,48 @@ +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-string-truncation-issues-detected-by-GCC-8.patch b/Fix-string-truncation-issues-detected-by-GCC-8.patch deleted file mode 100644 index 7eecdbd..0000000 --- a/Fix-string-truncation-issues-detected-by-GCC-8.patch +++ /dev/null @@ -1,54 +0,0 @@ -From 8adbe9aacb93c5a160f3ecfc00adc10a64d27c14 Mon Sep 17 00:00:00 2001 -From: Sekhar Nori -Date: Tue, 19 Feb 2019 08:29:58 +0000 -Subject: [PATCH 108/112] Fix string truncation issues detected by GCC 8 - -This fixes string truncation warning generated by GCC of the form: - -irqbalance.c:485:2: warning: 'strncpy' output truncated before terminating nul copying as many bytes from a string as its length [-Wstringop-truncation] - strncpy(addr.sun_path, socket_name, strlen(socket_name)); - ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -Using source size in strncpy so fix that by using destination size. -For the instance of this issue in irqbalance-ui.c, fix the issue by -eliminating the unneeded temporary buffer. - -Signed-off-by: Sekhar Nori ---- - irqbalance.c | 2 +- - ui/irqbalance-ui.c | 5 ++--- - 2 files changed, 3 insertions(+), 4 deletions(-) - -diff --git a/irqbalance.c b/irqbalance.c -index 60d8a5e..c1a0e15 100644 ---- a/irqbalance.c -+++ b/irqbalance.c -@@ -482,7 +482,7 @@ int init_socket() - */ - addr.sun_family = AF_UNIX; - snprintf(socket_name, 64, "%s/%s%d.sock", SOCKET_TMPFS, SOCKET_PATH, getpid()); -- strncpy(addr.sun_path, socket_name, strlen(socket_name)); -+ strncpy(addr.sun_path, socket_name, sizeof(addr.sun_path)); - if (bind(socket_fd, (struct sockaddr *)&addr, sizeof(addr)) < 0) { - log(TO_ALL, LOG_WARNING, "Daemon couldn't be bound to the file-based socket.\n"); - -diff --git a/ui/irqbalance-ui.c b/ui/irqbalance-ui.c -index 005eea4..1119665 100644 ---- a/ui/irqbalance-ui.c -+++ b/ui/irqbalance-ui.c -@@ -56,10 +56,9 @@ int init_connection() - return 0; - } - addr.sun_family = AF_UNIX; -- char socket_name[64]; - -- snprintf(socket_name, 64, "%s/%s%d.sock", SOCKET_TMPFS, SOCKET_PATH, irqbalance_pid); -- strncpy(addr.sun_path, socket_name, strlen(socket_name)); -+ snprintf(addr.sun_path, sizeof(addr.sun_path), "%s/%s%d.sock", SOCKET_TMPFS, -+ SOCKET_PATH, irqbalance_pid); - - if(connect(socket_fd, (struct sockaddr *)&addr, sizeof(addr)) < 0) { - /* Try connect to abstract */ --- -1.8.3.1 - diff --git a/Fix-typo-in-service-unit-file.patch b/Fix-typo-in-service-unit-file.patch new file mode 100644 index 0000000..316c6b2 --- /dev/null +++ b/Fix-typo-in-service-unit-file.patch @@ -0,0 +1,28 @@ +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 new file mode 100644 index 0000000..a48f438 --- /dev/null +++ b/Update-classify.c.patch @@ -0,0 +1,25 @@ +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/add-a-catchall-guessing-mechanis.patch b/add-a-catchall-guessing-mechanis.patch deleted file mode 100644 index f989c57..0000000 --- a/add-a-catchall-guessing-mechanis.patch +++ /dev/null @@ -1,52 +0,0 @@ -From 0906c9dcf1754bb2f32f9247608cc937650d2a0e Mon Sep 17 00:00:00 2001 -From: Neil Horman -Date: Fri, 4 May 2018 06:15:51 -0400 -Subject: [PATCH] arm: Add a catchall guessing mechanism - -Instead of spamming the logs to indicate we are guessing at an irq type, -and then not finding one, add a catchall regex to match on everything -last to assign the type and class as legacy/other, and report that - -Signed-off-by: Neil Horman ---- - procinterrupts.c | 6 +++--- - 1 file changed, 3 insertions(+), 3 deletions(-) - -diff --git a/procinterrupts.c b/procinterrupts.c -index eb84a1c..1aa4413 100644 ---- a/procinterrupts.c -+++ b/procinterrupts.c -@@ -105,10 +105,12 @@ static void guess_arm_irq_hints(char *name, struct irq_info *info) - { - int i, rc; - static int compiled = 0; -+ /* Note: Last entry is a catchall */ - static struct irq_match matches[] = { - { "eth.*" ,{NULL} ,NULL, IRQ_TYPE_LEGACY, IRQ_GBETH }, - { "[A-Z0-9]{4}[0-9a-f]{4}", {NULL} ,check_platform_device, IRQ_TYPE_LEGACY, IRQ_OTHER}, - { "PNP[0-9a-f]{4}", {NULL} ,check_platform_device, IRQ_TYPE_LEGACY, IRQ_OTHER}, -+ { ".*", {NULL}, NULL, IRQ_TYPE_LEGACY, IRQ_OTHER}, - {NULL}, - }; - -@@ -134,8 +136,7 @@ static void guess_arm_irq_hints(char *name, struct irq_info *info) - info->class = matches[i].class; - if (matches[i].refine_match) - matches[i].refine_match(name, info); -- -- log(TO_ALL, LOG_DEBUG, "IRQ %s(%d) is class %d\n", name, info->irq,info->class); -+ log(TO_ALL, LOG_DEBUG, "IRQ %s(%d) guessed as class %d\n", name, info->irq,info->class); - } - } - -@@ -214,7 +215,6 @@ GList* collect_full_irq_list() - info->class = IRQ_VIRT_EVENT; - } else { - #ifdef AARCH64 -- log(TO_ALL, LOG_DEBUG, "GUESSING AARCH64 CLASS FOR %s\n", irq_name); - guess_arm_irq_hints(irq_name, info); - #else - info->type = IRQ_TYPE_LEGACY; --- -2.21.0.windows.1 - diff --git a/arm64-Add-irq-aff-change-check.patch b/arm64-Add-irq-aff-change-check.patch index 4c007d6..b4d9317 100644 --- a/arm64-Add-irq-aff-change-check.patch +++ b/arm64-Add-irq-aff-change-check.patch @@ -1,7 +1,7 @@ From 55c5c321c73e4c9b54e041ba8c7d542598685bae Mon Sep 17 00:00:00 2001 -From: liuchao +From: l00520965 Date: Wed, 11 Mar 2020 11:46:42 +0800 -Subject: [PATCH 48/48] arm64: Add irq aff change check For aarch64, the PPIs +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. @@ -11,15 +11,15 @@ Acctually, the PPIs cannot change aff, and it should not be added to interrupt d 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 | 32 +++++++++++++++++++++++++++----- + classify.c | 28 +++++++++++++++++++++++++--- irqbalance.h | 2 ++ - 3 files changed, 36 insertions(+), 6 deletions(-) + 3 files changed, 34 insertions(+), 4 deletions(-) diff --git a/activate.c b/activate.c -index 2812976..f933347 100644 +index ab9702d..065f880 100644 --- a/activate.c +++ b/activate.c -@@ -60,6 +60,7 @@ static void activate_mapping(struct irq_info *info, void *data __attribute__((un +@@ -48,6 +48,7 @@ static void activate_mapping(struct irq_info *info, void *data __attribute__((un { char buf[PATH_MAX]; FILE *file; @@ -27,7 +27,7 @@ index 2812976..f933347 100644 /* * only activate mappings for irqs that have moved -@@ -82,7 +83,12 @@ static void activate_mapping(struct irq_info *info, void *data __attribute__((un +@@ -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); @@ -42,10 +42,10 @@ index 2812976..f933347 100644 info->moved = 0; /*migration is done*/ } diff --git a/classify.c b/classify.c -index 2fa303a..b40fcc1 100644 +index fa900f4..9f588bc 100644 --- a/classify.c +++ b/classify.c -@@ -264,7 +264,7 @@ static gint compare_ints(gconstpointer a, gconstpointer b) +@@ -256,7 +256,7 @@ static gint compare_ints(gconstpointer a, gconstpointer b) return ai->irq - bi->irq; } @@ -54,7 +54,7 @@ index 2fa303a..b40fcc1 100644 { struct irq_info find, *new; GList *entry; -@@ -288,9 +288,14 @@ static void add_banned_irq(int irq, GList **list) +@@ -280,9 +280,14 @@ static void add_banned_irq(int irq, GList **list) return; } @@ -69,8 +69,8 @@ index 2fa303a..b40fcc1 100644 + __add_banned_irq(irq, &cl_banned_irqs); } - static int is_banned_irq(int irq) -@@ -429,6 +434,23 @@ out: + gint substr_find(gconstpointer a, gconstpointer b) +@@ -376,6 +381,23 @@ get_numa_node: return new; } @@ -94,38 +94,20 @@ index 2fa303a..b40fcc1 100644 static void parse_user_policy_key(char *buf, int irq, struct user_irq_policy *pol) { char *key, *value, *end; -@@ -636,7 +658,7 @@ static void build_one_dev_entry(const char *dirname, GList *tmp_irqs) - continue; - get_irq_user_policy(devpath, irqnum, &pol); - if ((pol.ban == 1) || (check_for_irq_ban(devpath, irqnum, tmp_irqs))) { -- add_banned_irq(irqnum, &banned_irqs); -+ __add_banned_irq(irqnum, &banned_irqs); - continue; - } - hint.irq = irqnum; -@@ -671,7 +693,7 @@ static void build_one_dev_entry(const char *dirname, GList *tmp_irqs) - goto done; - get_irq_user_policy(devpath, irqnum, &pol); - if ((pol.ban == 1) || (check_for_irq_ban(devpath, irqnum, tmp_irqs))) { -- add_banned_irq(irqnum, &banned_irqs); -+ __add_banned_irq(irqnum, &banned_irqs); - goto done; - } - -@@ -723,7 +745,7 @@ static void add_new_irq(int irq, struct irq_info *hint, GList *proc_interrupts) +@@ -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(NULL, irq, &pol); - if ((pol.ban == 1) || check_for_irq_ban(NULL, irq, proc_interrupts)) { /*FIXME*/ + 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(NULL, hint, &pol); + new = add_one_irq_to_db(path, hint, &pol); diff --git a/irqbalance.h b/irqbalance.h -index 6cdd9e2..3a78c7f 100644 +index cd93167..bc34d7e 100644 --- a/irqbalance.h +++ b/irqbalance.h -@@ -105,6 +105,8 @@ extern struct irq_info *get_irq_info(int irq); +@@ -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); @@ -133,7 +115,7 @@ index 6cdd9e2..3a78c7f 100644 +extern void remove_one_irq_from_db(int irq); #define irq_numa_node(irq) ((irq)->numa_node) - extern unsigned long migrate_val; + -- -1.8.3.1 +2.23.0 diff --git a/bugfix-fix-a-hole-that-flees-hotplug-event.patch b/bugfix-fix-a-hole-that-flees-hotplug-event.patch deleted file mode 100644 index 0759d43..0000000 --- a/bugfix-fix-a-hole-that-flees-hotplug-event.patch +++ /dev/null @@ -1,30 +0,0 @@ -From 2c040ddc5869635598e4fbf5c63217f60fdef5f1 Mon Sep 17 00:00:00 2001 -From: xiashuang -Date: Sun, 17 Mar 2019 18:59:09 -0400 -Subject: [PATCH 2/4] bugfix fix a hole that flees hotplug event - -from 1.0.9, original infoformation is missing ---- - irqbalance.c | 6 +++--- - 1 file changed, 3 insertions(+), 3 deletions(-) - -diff --git a/irqbalance.c b/irqbalance.c -index 6412447..2f699b8 100644 ---- a/irqbalance.c -+++ b/irqbalance.c -@@ -284,9 +284,9 @@ gboolean scan(gpointer data) - for_each_irq(NULL, force_rebalance_irq, NULL); - parse_proc_interrupts(); - parse_proc_stat(); -- sleep_approx(sleep_interval); -- clear_work_stats(); -- parse_proc_interrupts(); -+ -+ /* Still need to check hotplugged or not next round */ -+ return TRUE; - } - - parse_proc_stat(); --- -1.8.3.1 - diff --git a/bugfix-force-irq-into-rebalance-list-when-irq-removed-and-reinserted.patch b/bugfix-force-irq-into-rebalance-list-when-irq-removed-and-reinserted.patch deleted file mode 100644 index 15a0279..0000000 --- a/bugfix-force-irq-into-rebalance-list-when-irq-removed-and-reinserted.patch +++ /dev/null @@ -1,562 +0,0 @@ -From a501662e98e2937cb63f3308d6497e723f838238 Mon Sep 17 00:00:00 2001 -From: liuchao -Date: Wed, 18 Mar 2020 22:08:33 +0800 -Subject: [PATCH] force irq into rebalance list when irq removed and reinserted - -prevent irq may be inserted to rebalance list more than once and add one msi irq -at one time to prevent new msi irqs stay on one numa node - ---- - classify.c | 154 +++++++++++++++++++++++++++++++++++++++++++++++++------ - irqbalance.c | 6 ++- - irqbalance.h | 7 +++ - procinterrupts.c | 145 ++++++++++++++++++++++++++++++++++----------------- - types.h | 1 + - 5 files changed, 250 insertions(+), 63 deletions(-) - -diff --git a/classify.c b/classify.c -index b40fcc1..2dc93ca 100644 ---- a/classify.c -+++ b/classify.c -@@ -37,6 +37,7 @@ static GList *interrupts_dbs = NULL; - static GList *banned_irqs = NULL; - GList *cl_banned_irqs = NULL; - static GList *cl_banned_modules = NULL; -+extern int need_add_single; - - #define SYSFS_DIR "/sys" - #define SYSPCI_DIR "/sys/bus/pci/devices" -@@ -259,7 +259,7 @@ - return irq_class; - } - --static gint compare_ints(gconstpointer a, gconstpointer b) -+gint compare_ints(gconstpointer a, gconstpointer b) - { - const struct irq_info *ai = a; - const struct irq_info *bi = b; -@@ -584,11 +585,13 @@ static int check_for_irq_ban(char *path __attribute__((unused)), int irq, GList - /* - * Check to see if we banned module which the irq belongs to. - */ -- entry = g_list_find_custom(proc_interrupts, &find, compare_ints); -- if (entry) { -- res = entry->data; -- if (check_for_module_ban(res->name)) -- return 1; -+ if (proc_interrupts) { -+ entry = g_list_find_custom(proc_interrupts, &find, compare_ints); -+ if (entry) { -+ res = entry->data; -+ if (check_for_module_ban(res->name)) -+ return 1; -+ } - } - - #ifdef INCLUDE_BANSCRIPT -@@ -624,16 +627,32 @@ static int check_for_irq_ban(char *path __attribute__((unused)), int irq, GList - return 0; - } - -+int is_proc_irq_info_exist(int irq, GList *tmp_list) -+{ -+ GList *entry; -+ struct irq_info find; -+ -+ if (!tmp_list) { -+ return 1; -+ } -+ -+ find.irq = irq; -+ entry = g_list_find_custom(tmp_list, &find, compare_ints); -+ -+ return entry ? 1 : 0; -+} -+ - /* - * Figures out which interrupt(s) relate to the device we"re looking at in dirname - */ --static void build_one_dev_entry(const char *dirname, GList *tmp_irqs) -+struct irq_info *build_one_dev_entry(const char *dirname, GList *tmp_list) - { - struct dirent *entry; - DIR *msidir; - FILE *fd; - int irqnum; -- struct irq_info *new, hint; -+ struct irq_info *new = NULL; -+ struct irq_info hint; - char path[PATH_MAX]; - char devpath[PATH_MAX]; - struct user_irq_policy pol; -@@ -657,10 +676,16 @@ static void build_one_dev_entry(const char *dirname, GList *tmp_irqs) - if (new) - continue; - get_irq_user_policy(devpath, irqnum, &pol); -- if ((pol.ban == 1) || (check_for_irq_ban(devpath, irqnum, tmp_irqs))) { -+ if ((pol.ban == 1) || (check_for_irq_ban(devpath, irqnum, tmp_list))) { - __add_banned_irq(irqnum, &banned_irqs); - continue; - } -+ if (!is_proc_irq_info_exist(irqnum, tmp_list)) { -+ continue; -+ } -+ if (need_add_single && need_add_single != irqnum) { -+ continue; -+ } - hint.irq = irqnum; - hint.type = IRQ_TYPE_MSIX; - new = add_one_irq_to_db(devpath, &hint, &pol); -@@ -669,13 +694,13 @@ static void build_one_dev_entry(const char *dirname, GList *tmp_irqs) - } - } while (entry != NULL); - closedir(msidir); -- return; -+ return new; - } - - sprintf(path, "%s/%s/irq", SYSPCI_DIR, dirname); - fd = fopen(path, "r"); - if (!fd) -- return; -+ return new; - if (fscanf(fd, "%d", &irqnum) < 0) - goto done; - -@@ -692,10 +717,13 @@ 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(devpath, irqnum, tmp_irqs))) { -+ if ((pol.ban == 1) || (check_for_irq_ban(devpath, irqnum, tmp_list))) { - __add_banned_irq(irqnum, &banned_irqs); - goto done; - } -+ if (!is_proc_irq_info_exist(irqnum, tmp_list)) { -+ goto done; -+ } - - hint.irq = irqnum; - hint.type = IRQ_TYPE_LEGACY; -@@ -706,7 +734,60 @@ static void build_one_dev_entry(const char *dirname, GList *tmp_irqs) - - done: - fclose(fd); -- return; -+ return new; -+} -+ -+void find_irq_dev_path(int irq, char *dirname, int length) -+{ -+ char cmd[PATH_MAX + 128]; -+ FILE *output = NULL; -+ char path[PATH_MAX]; -+ char buffer[128]; -+ char *brc = NULL; -+ size_t dirlen; -+ -+ memset(dirname, 0, length); -+ /* Return defaults if irq is 0 */ -+ if (!irq) -+ return; -+ -+ sprintf(path, "%s/*/msi_irqs", SYSPCI_DIR); -+ sprintf(cmd, "exec find %s -type f -name %d | awk -F '/' '{print $6}' ", path, irq); -+ output = popen(cmd, "r"); -+ if (!output) { -+ log(TO_CONSOLE, LOG_WARNING, "Unable to execute IRQ %d path %s\n", irq, path); -+ return; -+ } -+ -+ brc = fgets(buffer, 128, output); -+ /* fgets will get a redundant \n */ -+ if (brc && (dirlen = strcspn(brc, "\n")) > 0) { -+ log(TO_CONSOLE, LOG_INFO, "msi_irqs IRQ %d dirname is %s\n", irq, brc); -+ brc[dirlen] = '\0'; -+ strncpy(dirname, brc, length); -+ pclose(output); -+ return; -+ } -+ pclose(output); -+ -+ sprintf(path, "%s/*/irq", SYSPCI_DIR); -+ sprintf(cmd, "exec grep -w %d %s | awk -F '/' '{print $6}' ", irq, path); -+ output = popen(cmd, "r"); -+ if (!output) { -+ log(TO_CONSOLE, LOG_WARNING, "Unable to execute IRQ %d path %s\n", irq, path); -+ return; -+ } -+ -+ brc = fgets(buffer, 128, output); -+ if (brc && (dirlen = strcspn(brc, "\n")) > 0) { -+ log(TO_CONSOLE, LOG_INFO, "IRQ %d dirname is %s\n", irq, brc); -+ brc[dirlen] = '\0'; -+ strncpy(dirname, brc, length); -+ pclose(output); -+ return; -+ } -+ pclose(output); -+ - } - - static void free_irq(struct irq_info *info, void *data __attribute__((unused))) -@@ -714,6 +795,45 @@ static void free_irq(struct irq_info *info, void *data __attribute__((unused))) - free(info); - } - -+static void remove_no_existing_irq(struct irq_info *info, void *data __attribute__((unused))) -+{ -+ GList *entry = NULL; -+ -+ if (info->existing) { -+ info->existing = 0; -+ return; -+ } -+ -+ entry = g_list_find_custom(interrupts_db, info, compare_ints); -+ if (entry) -+ interrupts_db = g_list_delete_link(interrupts_db, entry); -+ -+ entry = g_list_find_custom(banned_irqs, info, compare_ints); -+ if (entry) -+ banned_irqs = g_list_delete_link(banned_irqs, entry); -+ -+ entry = g_list_find_custom(rebalance_irq_list, info, compare_ints); -+ if (entry) -+ rebalance_irq_list = g_list_delete_link(rebalance_irq_list, entry); -+ -+ if(info->assigned_obj) { -+ entry = g_list_find_custom(info->assigned_obj->interrupts, info, compare_ints); -+ if (entry) { -+ info->assigned_obj->interrupts = g_list_delete_link(info->assigned_obj->interrupts, entry); -+ } -+ } -+ log(TO_CONSOLE, LOG_INFO, "IRQ %d is removed from interrupts_db.\n", info->irq); -+ free_irq(info, NULL); -+} -+ -+void clear_no_existing_irqs(void) -+{ -+ for_each_irq(NULL, remove_no_existing_irq, NULL); -+ if (banned_irqs){ -+ for_each_irq(banned_irqs, remove_no_existing_irq, NULL); -+ } -+} -+ - void free_irq_db(void) - { - for_each_irq(NULL, free_irq, NULL); -@@ -733,14 +853,14 @@ void free_cl_opts(void) - g_list_free(banned_irqs); - } - --static void add_new_irq(int irq, struct irq_info *hint, GList *proc_interrupts) -+struct irq_info *add_new_irq(int irq, struct irq_info *hint, GList *proc_interrupts) - { -- struct irq_info *new; -+ struct irq_info *new = NULL; - struct user_irq_policy pol; - - new = get_irq_info(irq); - if (new) -- return; -+ return new; - - /* Set NULL devpath for the irq has no sysfs entries */ - get_irq_user_policy(NULL, irq, &pol); -@@ -752,6 +872,8 @@ static void add_new_irq(int irq, struct irq_info *hint, GList *proc_interrupts) - - if (!new) - log(TO_CONSOLE, LOG_WARNING, "add_new_irq: Failed to add irq %d\n", irq); -+ -+ return new; - } - - static void add_missing_irq(struct irq_info *info, void *attr) -diff --git a/irqbalance.c b/irqbalance.c -index f965a2a..4d0a417 100644 ---- a/irqbalance.c -+++ b/irqbalance.c -@@ -251,11 +251,15 @@ static void dump_object_tree(void) - for_each_object(numa_nodes, dump_numa_node_info, NULL); - } - --static void force_rebalance_irq(struct irq_info *info, void *data __attribute__((unused))) -+void force_rebalance_irq(struct irq_info *info, void *data __attribute__((unused))) - { - if (info->level == BALANCE_NONE) - return; - -+ /* Prevent inserting a duplicate entry to avoid list chaos */ -+ if (g_list_find_custom(rebalance_irq_list, info, compare_ints)) -+ return; -+ - if (info->assigned_obj == NULL) - rebalance_irq_list = g_list_append(rebalance_irq_list, info); - else -diff --git a/irqbalance.h b/irqbalance.h -index 3a78c7f..9e28285 100644 ---- a/irqbalance.h -+++ b/irqbalance.h -@@ -109,6 +109,13 @@ extern void add_banned_irq(int irq); - extern void remove_one_irq_from_db(int irq); - #define irq_numa_node(irq) ((irq)->numa_node) - -+extern struct irq_info *build_one_dev_entry(const char *dirname, GList *tmp_list); -+extern void find_irq_dev_path(int irq, char *dirname, int length); -+extern struct irq_info *add_new_irq(int irq, struct irq_info *hint, GList *proc_interrupts); -+extern void clear_no_existing_irqs(void); -+extern void force_rebalance_irq(struct irq_info *info, void *data __attribute__((unused))); -+extern gint compare_ints(gconstpointer a, gconstpointer b); -+ - extern unsigned long migrate_val; - extern unsigned long load_limit; - /* -diff --git a/procinterrupts.c b/procinterrupts.c -index 70831b4..358458c 100644 ---- a/procinterrupts.c -+++ b/procinterrupts.c -@@ -42,6 +42,7 @@ - - static int proc_int_has_msi = 0; - static int msi_found_in_sysfs = 0; -+int need_add_single = 0; - - #ifdef AARCH64 - struct irq_match { -@@ -144,6 +145,52 @@ static void guess_arm_irq_hints(char *name, struct irq_info *info) - - } - #endif -+static void init_irq_class_and_type(char *savedline, struct irq_info *info, int irq) { -+ char *irq_name = NULL; -+ char *irq_mod = NULL; -+ char *savedptr = NULL; -+ char *last_token = NULL; -+ char *p = NULL; -+ int is_xen_dyn = 0; -+#ifdef AARCH64 -+ char *tmp = NULL; -+#endif -+ -+ irq_name = strtok_r(savedline, " ", &savedptr); -+ if (strstr(irq_name, "xen-dyn") != NULL) -+ is_xen_dyn = 1; -+ last_token = strtok_r(NULL, " ", &savedptr); -+ while ((p = strtok_r(NULL, " ", &savedptr))) { -+ irq_name = last_token; -+ if (strstr(irq_name, "xen-dyn") != NULL) -+ is_xen_dyn = 1; -+ last_token = p; -+ } -+ -+#ifdef AARCH64 -+ /* Of course the formatting for /proc/interrupts is different on different arches */ -+ irq_name = last_token; -+ tmp = strchr(irq_name, '\n'); -+ if (tmp) -+ *tmp = 0; -+#endif -+ irq_mod = last_token; -+ info->irq = irq; -+ -+ if (strstr(irq_name, "-event") != NULL && is_xen_dyn == 1) { -+ info->type = IRQ_TYPE_VIRT_EVENT; -+ info->class = IRQ_VIRT_EVENT; -+ } else { -+#ifdef AARCH64 -+ guess_arm_irq_hints(irq_name, info); -+#else -+ info->type = IRQ_TYPE_LEGACY; -+ info->class = IRQ_OTHER; -+#endif -+ } -+ info->name = strdupa(irq_mod); -+} -+ - - GList* collect_full_irq_list() - { -@@ -151,10 +198,6 @@ GList* collect_full_irq_list() - FILE *file; - char *line = NULL; - size_t size = 0; -- char *irq_name, *irq_mod, *savedptr, *last_token, *p; --#ifdef AARCH64 -- char *tmp; --#endif - - file = fopen("/proc/interrupts", "r"); - if (!file) -@@ -169,7 +212,6 @@ GList* collect_full_irq_list() - - while (!feof(file)) { - int number; -- int is_xen_dyn = 0; - struct irq_info *info; - char *c; - char *savedline = NULL; -@@ -191,45 +233,13 @@ GList* collect_full_irq_list() - savedline = strdup(line); - if (!savedline) - break; -- irq_name = strtok_r(savedline, " ", &savedptr); -- if (strstr(irq_name, "xen-dyn") != NULL) -- is_xen_dyn = 1; -- last_token = strtok_r(NULL, " ", &savedptr); -- while ((p = strtok_r(NULL, " ", &savedptr))) { -- irq_name = last_token; -- if (strstr(irq_name, "xen-dyn") != NULL) -- is_xen_dyn = 1; -- last_token = p; -- } -- --#ifdef AARCH64 -- /* Of course the formatting for /proc/interrupts is different on different arches */ -- irq_name = last_token; -- tmp = strchr(irq_name, '\n'); -- if (tmp) -- *tmp = 0; --#endif -- irq_mod = last_token; -- - *c = 0; - c++; - number = strtoul(line, NULL, 10); - - info = calloc(sizeof(struct irq_info), 1); - if (info) { -- info->irq = number; -- if (strstr(irq_name, "-event") != NULL && is_xen_dyn == 1) { -- info->type = IRQ_TYPE_VIRT_EVENT; -- info->class = IRQ_VIRT_EVENT; -- } else { --#ifdef AARCH64 -- guess_arm_irq_hints(irq_name, info); --#else -- info->type = IRQ_TYPE_LEGACY; -- info->class = IRQ_OTHER; --#endif -- } -- info->name = strdup(irq_mod); -+ init_irq_class_and_type(savedline, info, number); - tmp_list = g_list_append(tmp_list, info); - } - free(savedline); -@@ -239,6 +249,14 @@ GList* collect_full_irq_list() - return tmp_list; - } - -+/* parsing /proc/interrrupts to detect whether removed and reinserted IRQ -+* device happened or not. If yes, then IRQs have to be rescanning again; -+* However, in order to keep no impact on online running IRQs performance stable, -+* removed and reinserted IRQ added back into rebalance_irq_list, -+* for irq load re-calculation instead of trigger rescanning all IRQs. -+* specially, when a new IRQ is detected, it has to be checked what devpath is, -+* then it is added into database accordingly. -+*/ - void parse_proc_interrupts(void) - { - FILE *file; -@@ -262,7 +280,10 @@ void parse_proc_interrupts(void) - uint64_t count; - char *c, *c2; - struct irq_info *info; -- char savedline[1024]; -+ struct irq_info tmp_info = {0}; -+ char *savedline = NULL; -+ char dirname[PATH_MAX] = {'\0'}; -+ struct irq_info *lookup; - - if (getline(&line, &size, file)<=0) - break; -@@ -282,7 +303,9 @@ void parse_proc_interrupts(void) - if (!c) - continue; - -- strncpy(savedline, line, sizeof(savedline)-1); -+ savedline = strdup(line); -+ if (!savedline) -+ continue; - - *c = 0; - c++; -@@ -290,9 +313,37 @@ void parse_proc_interrupts(void) - - info = get_irq_info(number); - if (!info) { -- need_rescan = 1; -- break; -+ init_irq_class_and_type(savedline, &tmp_info, number); -+ find_irq_dev_path(number, dirname, PATH_MAX); -+ if (strlen(dirname) > 0) { -+ need_add_single = number; -+ info = build_one_dev_entry(dirname, NULL); -+ need_add_single = 0; -+ lookup = get_irq_info(number); -+ if (lookup != NULL) { -+ lookup->existing = 1; -+ info = lookup; -+ } -+ log(TO_CONSOLE, LOG_INFO, "new IRQ %d added into database, dirname %s\n", number, dirname); -+ } else { -+ info = add_new_irq(number, &tmp_info, NULL); -+ } -+ if (tmp_info.name) { -+ free(tmp_info.name); -+ tmp_info.name = NULL; -+ } -+ -+ if (info) { -+ force_rebalance_irq(info, NULL); -+ log(TO_CONSOLE, LOG_INFO, "new IRQ %d added into rebalance list\n", number); -+ } else { -+ need_rescan = 1; -+ free(savedline); -+ break; -+ } - } -+ free(savedline); -+ info->existing = 1; - - count = 0; - cpunr = 0; -@@ -316,17 +367,19 @@ void parse_proc_interrupts(void) - * cause an overflow and IRQ won't be rebalanced again - */ - if (count < info->irq_count) { -- need_rescan = 1; -- break; -+ log(TO_CONSOLE, LOG_INFO, "Removed and reinserted IRQ %d added into rebalance list\n", number); -+ force_rebalance_irq(info, NULL); - } - -- info->last_irq_count = info->irq_count; -+ info->last_irq_count = info->irq_count; - info->irq_count = count; - - /* is interrupt MSI based? */ - if ((info->type == IRQ_TYPE_MSI) || (info->type == IRQ_TYPE_MSIX)) - msi_found_in_sysfs = 1; -- } -+ } -+ clear_no_existing_irqs(); -+ - if ((proc_int_has_msi) && (!msi_found_in_sysfs) && (!need_rescan)) { - log(TO_ALL, LOG_WARNING, "WARNING: MSI interrupts found in /proc/interrupts\n"); - log(TO_ALL, LOG_WARNING, "But none found in sysfs, you need to update your kernel\n"); -diff --git a/types.h b/types.h -index a01d649..9693cf4 100644 ---- a/types.h -+++ b/types.h -@@ -70,6 +70,7 @@ struct irq_info { - uint64_t last_irq_count; - uint64_t load; - int moved; -+ int existing; - struct topo_obj *assigned_obj; - char *name; - }; --- -1.8.3.1 - diff --git a/change-irq-ban-check-path-to-devpath.patch b/change-irq-ban-check-path-to-devpath.patch deleted file mode 100644 index f0c41ce..0000000 --- a/change-irq-ban-check-path-to-devpath.patch +++ /dev/null @@ -1,29 +0,0 @@ -From 73c26ac2d6e856c5a9ffd1c48ed7c1abc85de3df Mon Sep 17 00:00:00 2001 -From: liuchao -Date: Sat, 12 Oct 2019 03:34:44 +0000 -Subject: [PATCH] irqbalance: change irq ban check 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 the path should keep consistent. ---- - classify.c | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/classify.c b/classify.c -index 7c97d47..3681c48 100644 ---- a/classify.c -+++ b/classify.c -@@ -719,7 +719,7 @@ struct irq_info *build_one_dev_entry(const char *dirname, GList *tmp_list) - 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.19.1 - diff --git a/change-path-to-devpath.patch b/change-path-to-devpath.patch new file mode 100644 index 0000000..e483bb4 --- /dev/null +++ b/change-path-to-devpath.patch @@ -0,0 +1,29 @@ +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/classify-remove-unused-label.patch b/classify-remove-unused-label.patch deleted file mode 100644 index 7f2b1ea..0000000 --- a/classify-remove-unused-label.patch +++ /dev/null @@ -1,28 +0,0 @@ -From ff28f445a0808677c983d85a3b8331e4c090d70d Mon Sep 17 00:00:00 2001 -From: Neil Horman -Date: Tue, 29 May 2018 10:27:37 -0400 -Subject: [PATCH 084/112] classify: remove unused label - -A recent refactoring in commit a4fbf90c2395ffa13176e8b002b7ef89a0ffc667 -left us with an unused label 'free' in rebuild_irq_db, just remove it - -Signed-off-by: Neil Horman ---- - classify.c | 1 - - 1 file changed, 1 deletion(-) - -diff --git a/classify.c b/classify.c -index 3394823..3136fc3 100644 ---- a/classify.c -+++ b/classify.c -@@ -777,7 +777,6 @@ void rebuild_irq_db(void) - - for_each_irq(tmp_irqs, add_missing_irq, interrupts_db); - --free: - g_list_free_full(tmp_irqs, free); - - } --- -1.8.3.1 - diff --git a/correct-to-use-realloc-function.patch b/correct-to-use-realloc-function.patch index 636bd4a..9fd7791 100644 --- a/correct-to-use-realloc-function.patch +++ b/correct-to-use-realloc-function.patch @@ -1,7 +1,7 @@ -From 22a40e9d0dd59ee58ff06d2b6360007e046d608f Mon Sep 17 00:00:00 2001 -From: liuchao173 -Date: Thu, 7 Nov 2019 09:33:47 +0000 -Subject: [PATCH 6/8] irqbalance: correct to use realloc() function +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: " @@ -20,10 +20,10 @@ Signed-off-by: Yunfeng Ye 1 file changed, 23 insertions(+), 10 deletions(-) diff --git a/irqbalance.c b/irqbalance.c -index c9378d0..cace4d8 100644 +index a06809c..e53bf65 100644 --- a/irqbalance.c +++ b/irqbalance.c -@@ -321,14 +321,18 @@ gboolean scan(gpointer data) +@@ -308,14 +308,18 @@ gboolean scan(gpointer data __attribute__((unused))) void get_irq_data(struct irq_info *irq, void *data) { char **irqdata = (char **)data; @@ -45,7 +45,7 @@ index c9378d0..cace4d8 100644 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); -@@ -338,6 +342,7 @@ void get_object_stat(struct topo_obj *object, void *data) +@@ -325,6 +329,7 @@ void get_object_stat(struct topo_obj *object, void *data) { char **stats = (char **)data; char *irq_data = NULL; @@ -53,7 +53,7 @@ index c9378d0..cace4d8 100644 size_t irqdlen; if (g_list_length(object->interrupts) > 0) { -@@ -355,13 +360,17 @@ void get_object_stat(struct topo_obj *object, void *data) +@@ -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) { @@ -74,11 +74,12 @@ index c9378d0..cace4d8 100644 sprintf(*stats + strlen(*stats), "TYPE %d NUMBER %d LOAD %lu SAVE_MODE %d %s", object->obj_type, object->number, object->load, -@@ -475,19 +484,23 @@ gboolean sock_handle(gint fd, GIOCondition condition, gpointer user_data __attri +@@ -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); @@ -103,4 +104,5 @@ index c9378d0..cace4d8 100644 } -- -2.19.1 +2.23.0 + diff --git a/cputree-adjust-snprintf-sizes-to-avoid-gcc-warnings.patch b/cputree-adjust-snprintf-sizes-to-avoid-gcc-warnings.patch deleted file mode 100644 index e2cafbc..0000000 --- a/cputree-adjust-snprintf-sizes-to-avoid-gcc-warnings.patch +++ /dev/null @@ -1,91 +0,0 @@ -From 0605850acfce6f2ae23759618604f02f946026c2 Mon Sep 17 00:00:00 2001 -From: Neil Horman -Date: Tue, 29 May 2018 10:26:00 -0400 -Subject: [PATCH 129/152] cputree: adjust snprintf sizes to avoid gcc warnings - -Gcc detects potential overruns in our use of PATH_MAX arrays when -parsing cpu topology. This commit corrects those issues by ensuing that -the print size is no longer than the array size in all cases - -Signed-off-by: Neil Horman ---- - cputree.c | 21 ++++++++++++++------- - 1 file changed, 14 insertions(+), 7 deletions(-) - -diff --git a/cputree.c b/cputree.c -index d09af43..c88143f 100644 ---- a/cputree.c -+++ b/cputree.c -@@ -241,7 +241,8 @@ static struct topo_obj* add_cpu_to_cache_domain(struct topo_obj *cpu, - - return cache; - } -- -+ -+#define ADJ_SIZE(r,s) PATH_MAX-strlen(r)-strlen(#s) - static void do_one_cpu(char *path) - { - struct topo_obj *cpu; -@@ -256,7 +257,7 @@ static void do_one_cpu(char *path) - unsigned int max_cache_index, cache_index, cache_stat; - - /* skip offline cpus */ -- snprintf(new_path, PATH_MAX, "%s/online", path); -+ snprintf(new_path, ADJ_SIZE(path,"/online"), "%s/online", path); - file = fopen(new_path, "r"); - if (file) { - char *line = NULL; -@@ -299,7 +300,8 @@ static void do_one_cpu(char *path) - - - /* try to read the package mask; if it doesn't exist assume solitary */ -- snprintf(new_path, PATH_MAX, "%s/topology/core_siblings", path); -+ snprintf(new_path, ADJ_SIZE(path, "/topology/core_siblings"), -+ "%s/topology/core_siblings", path); - file = fopen(new_path, "r"); - cpu_set(cpu->number, package_mask); - if (file) { -@@ -311,7 +313,8 @@ static void do_one_cpu(char *path) - free(line); - } - /* try to read the package id */ -- snprintf(new_path, PATH_MAX, "%s/topology/physical_package_id", path); -+ snprintf(new_path, ADJ_SIZE(path, "/topology/physical_package_id"), -+ "%s/topology/physical_package_id", path); - file = fopen(new_path, "r"); - if (file) { - char *line = NULL; -@@ -329,7 +332,9 @@ static void do_one_cpu(char *path) - cache_index = 1; - do { - struct stat sb; -- snprintf(new_path, PATH_MAX, "%s/cache/index%d/shared_cpu_map", path, cache_index); -+ /* Extra 10 subtraction is for the max character length of %d */ -+ snprintf(new_path, ADJ_SIZE(path, "/cache/index%d/shared_cpu_map") - 10, -+ "%s/cache/index%d/shared_cpu_map", path, cache_index); - cache_stat = stat(new_path, &sb); - if (!cache_stat) { - max_cache_index = cache_index; -@@ -340,7 +345,9 @@ static void do_one_cpu(char *path) - } while(!cache_stat); - - if (max_cache_index > 0) { -- snprintf(new_path, PATH_MAX, "%s/cache/index%d/shared_cpu_map", path, max_cache_index); -+ /* Extra 10 subtraction is for the max character length of %d */ -+ snprintf(new_path, ADJ_SIZE(path, "/cache/index%d/shared_cpu_map") - 10, -+ "%s/cache/index%d/shared_cpu_map", path, max_cache_index); - file = fopen(new_path, "r"); - if (file) { - char *line = NULL; -@@ -505,7 +512,7 @@ void parse_cpu_tree(void) - sscanf(entry->d_name, "cpu%d%c", &num, &pad) == 1 && - !strchr(entry->d_name, ' ')) { - char new_path[PATH_MAX]; -- sprintf(new_path, "/sys/devices/system/cpu/%s", entry->d_name); -+ snprintf(new_path, PATH_MAX, "/sys/devices/system/cpu/%s", entry->d_name); - do_one_cpu(new_path); - } - } while (entry); --- -1.8.3.1 - 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 new file mode 100644 index 0000000..8c73bcc --- /dev/null +++ b/delete-the-useless-free-for-banned_irqs-in-free_cl_o.patch @@ -0,0 +1,37 @@ +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 new file mode 100644 index 0000000..7be73e7 --- /dev/null +++ b/delete-unused-local-variables-in-parse_proc_interrup.patch @@ -0,0 +1,38 @@ +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/feature-add-new-user-irq-policy-config-rule.patch b/feature-add-new-user-irq-policy-config-rule.patch deleted file mode 100644 index 52df5fa..0000000 --- a/feature-add-new-user-irq-policy-config-rule.patch +++ /dev/null @@ -1,451 +0,0 @@ -From 0406d202af914881af1a6caf5247e7ac40564366 Mon Sep 17 00:00:00 2001 -From: hejingxian -Date: Tue, 17 Sep 2019 23:32:54 +0800 -Subject: [PATCH] add new user irq policy config rule - -When there is many irqs, the old user irq policy script will cost too much time. -Therefore, we introduce a new user irq policy config rule which avoid policy script running -for every irq. ---- - Makefile.am | 2 +- - classify.c | 32 +++++++-- - irqbalance.c | 38 +++++---- - irqbalance.h | 2 +- - placement.c | 3 +- - procinterrupts.c | 3 +- - rules_config.c | 172 ++++++++++++++++++++++++++++++++++++++++++++++++ - rules_config.h | 40 +++++++++++ - 9 files changed, 271 insertions(+), 23 deletions(-) - create mode 100644 rules_config.c - create mode 100644 rules_config.h - -diff --git a/Makefile.am b/Makefile.am -index 62ac482..9276bfb 100644 ---- a/Makefile.am -+++ b/Makefile.am -@@ -38,7 +38,7 @@ sbin_PROGRAMS += irqbalance-ui - endif - - irqbalance_SOURCES = activate.c bitmap.c classify.c cputree.c irqbalance.c \ -- irqlist.c numa.c placement.c procinterrupts.c -+ irqlist.c numa.c placement.c procinterrupts.c rules_config.c - irqbalance_LDADD = $(LIBCAP_NG_LIBS) $(GLIB2_LIBS) - if IRQBALANCEUI - irqbalance_ui_SOURCES = $(UI_DIR)/helpers.c $(UI_DIR)/irqbalance-ui.c \ -diff --git a/classify.c b/classify.c -index 65aeae2..7c97d47 100644 ---- a/classify.c -+++ b/classify.c -@@ -663,7 +663,7 @@ struct irq_info *build_one_dev_entry(const char *dirname, GList *tmp_list) - - sprintf(path, "%s/%s/msi_irqs", SYSPCI_DIR, dirname); - sprintf(devpath, "%s/%s", SYSPCI_DIR, dirname); -- -+ memset(&pol, -1, sizeof(struct user_irq_policy)); - /* Needs to be further classified */ - hint.class = IRQ_OTHER; - -@@ -679,7 +679,9 @@ struct irq_info *build_one_dev_entry(const char *dirname, GList *tmp_list) - new = get_irq_info(irqnum); - if (new) - continue; -- get_irq_user_policy(devpath, irqnum, &pol); -+ if (user_policy_list == NULL) { -+ get_irq_user_policy(devpath, irqnum, &pol); -+ } - if ((pol.ban == 1) || (check_for_irq_ban(devpath, irqnum, tmp_list))) { - __add_banned_irq(irqnum, &banned_irqs, 0); - continue; -@@ -714,7 +716,9 @@ struct irq_info *build_one_dev_entry(const char *dirname, GList *tmp_list) - new = get_irq_info(irqnum); - if (new) - goto done; -- get_irq_user_policy(devpath, irqnum, &pol); -+ if (user_policy_list == NULL) { -+ get_irq_user_policy(devpath, irqnum, &pol); -+ } - if ((pol.ban == 1) || (check_for_irq_ban(devpath, irqnum, tmp_list))) { - __add_banned_irq(irqnum, &banned_irqs, 0); - goto done; -@@ -855,17 +859,23 @@ struct irq_info *add_new_irq(int irq, struct irq_info *hint, GList *proc_interru - struct irq_info *new = NULL; - struct user_irq_policy pol; - -+ memset(&pol, -1, sizeof(struct user_irq_policy)); - new = get_irq_info(irq); - if (new) - return new; - - /* Set NULL devpath for the irq has no sysfs entries */ -- get_irq_user_policy(NULL, irq, &pol); -+ if (user_policy_list == NULL) { -+ get_irq_user_policy(NULL, irq, &pol); -+ } - if ((pol.ban == 1) || check_for_irq_ban(NULL, irq, proc_interrupts)) { /*FIXME*/ - __add_banned_irq(irq, &banned_irqs, 0); - new = get_irq_info(irq); -- } else -+ } else { - new = add_one_irq_to_db(NULL, hint, &pol); -+ if (new != NULL) -+ set_usr_irq_policy(hint->name, new); -+ } - - if (!new) - log(TO_CONSOLE, LOG_WARNING, "add_new_irq: Failed to add irq %d\n", irq); -@@ -880,6 +890,13 @@ static void add_missing_irq(struct irq_info *info, void *attr) - - if (!lookup) - add_new_irq(info->irq, info, proc_interrupts); -+ else -+ set_usr_irq_policy(info->name, lookup); -+ if (info->name) { -+ free(info->name); -+ info->name = NULL; -+ } -+ - } - - static void free_tmp_irqs(gpointer data) -diff --git a/irqbalance.c b/irqbalance.c -index 21d578a..d41753c 100644 ---- a/irqbalance.c -+++ b/irqbalance.c -@@ -99,6 +99,7 @@ struct option lopts[] = { - {"version", 0, NULL, 'V'}, - {"migrateval", 1, NULL, 'e'}, - {"loadlimit", 1, NULL, 'g'}, -+ {"rulesconfig", 1, NULL, 'r'}, - {0, 0, 0, 0} - }; - -@@ -106,6 +107,7 @@ static void usage(void) - log(TO_CONSOLE, LOG_INFO, "irqbalance [--oneshot | -o] [--debug | -d] [--foreground | -f] [--journal | -j] [--hintpolicy= | -h [exact|subset|ignore]]\n"); - log(TO_CONSOLE, LOG_INFO, " [--powerthresh= | -p | ] [--banirq= | -i ] [--banmod= | -m ] [--policyscript= | -l