diff --git a/arm64-Add-irq-aff-change-check.patch b/arm64-Add-irq-aff-change-check.patch new file mode 100644 index 0000000..4c007d6 --- /dev/null +++ b/arm64-Add-irq-aff-change-check.patch @@ -0,0 +1,139 @@ +From 55c5c321c73e4c9b54e041ba8c7d542598685bae Mon Sep 17 00:00:00 2001 +From: liuchao +Date: Wed, 11 Mar 2020 11:46:42 +0800 +Subject: [PATCH 48/48] 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 | 32 +++++++++++++++++++++++++++----- + irqbalance.h | 2 ++ + 3 files changed, 36 insertions(+), 6 deletions(-) + +diff --git a/activate.c b/activate.c +index 2812976..f933347 100644 +--- a/activate.c ++++ b/activate.c +@@ -60,6 +60,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 +@@ -82,7 +83,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 2fa303a..b40fcc1 100644 +--- a/classify.c ++++ b/classify.c +@@ -264,7 +264,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; +@@ -288,9 +288,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); + } + + static int is_banned_irq(int irq) +@@ -429,6 +434,23 @@ out: + 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; +@@ -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) + /* 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*/ +- 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); +diff --git a/irqbalance.h b/irqbalance.h +index 6cdd9e2..3a78c7f 100644 +--- a/irqbalance.h ++++ b/irqbalance.h +@@ -105,6 +105,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) + + extern unsigned long migrate_val; +-- +1.8.3.1 + diff --git a/bugfix-Prevent-inserting-a-duplicate-entry-to-avoid-list-ch.patch b/bugfix-Prevent-inserting-a-duplicate-entry-to-avoid-list-ch.patch deleted file mode 100644 index 6fafcc1..0000000 --- a/bugfix-Prevent-inserting-a-duplicate-entry-to-avoid-list-ch.patch +++ /dev/null @@ -1,61 +0,0 @@ -From 07032f71ea956ca195c9b2386d09d24b07b7133f Mon Sep 17 00:00:00 2001 -From: hejingxian -Date: Tue, 12 Nov 2019 10:59:20 +0800 -Subject: [PATCH] Prevent inserting a duplicate entry to avoid list chaos - -Introduced by bugfix-force-irq-into-rebalance-list-when-irq-removed-and-reinserted.patch -and feature-introduce-verifyhint-to-detect-hint-variation.patch, irq may want be inserted to -rebalance list more then once, and we need to prevent this. we developped a solution in -bugfix-fix-two-same-irq-insert-to-list.patch, but we are likely to call irq_in_rebalance_list. - -this patch remove the code in bugfix-fix-two-same-irq-insert-to-list.patch and add protection -in force_rebalance_irq instead. ---- - classify.c | 2 +- - irqbalance.c | 4 ++++ - irqbalance.h | 1 + - 3 files changed, 6 insertions(+), 1 deletion(-) - -diff --git a/classify.c b/classify.c -index f041054..5aed9e5 100644 ---- a/classify.c -+++ b/classify.c -@@ -263,7 +263,7 @@ static int get_irq_class(const char *devpath) - 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; -diff --git a/irqbalance.c b/irqbalance.c -index 395669c..faa8e6a 100644 ---- a/irqbalance.c -+++ b/irqbalance.c -@@ -251,6 +251,10 @@ 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 c07a4fc..1befb46 100644 ---- a/irqbalance.h -+++ b/irqbalance.h -@@ -113,6 +113,7 @@ 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); - #define irq_numa_node(irq) ((irq)->numa_node) -+extern gint compare_ints(gconstpointer a, gconstpointer b); - - 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); --- -1.8.3.1 - diff --git a/bugfix-delete-no-existing-banned-irq.patch b/bugfix-delete-no-existing-banned-irq.patch deleted file mode 100644 index d532f53..0000000 --- a/bugfix-delete-no-existing-banned-irq.patch +++ /dev/null @@ -1,29 +0,0 @@ -From 0d6ed42e5d195f6a00d2f000ce8da11e89cb3010 Mon Sep 17 00:00:00 2001 -From: caihongda -Date: Fri, 1 Nov 2019 10:06:03 +0800 -Subject: [PATCH] irqbalance: bufix in banned irq delete - -reason: The banned irq will not be added int interrupts_db, so - we need to additionaly delete it if it is no_existing. - To test this in llt, we add a stub for function - is_banned_irq. - -Signed-off-by: caihongda - -diff --git a/classify.c b/classify.c -index 9f72ae8..585f2dc 100644 ---- a/classify.c -+++ b/classify.c -@@ -853,6 +860,9 @@ static void remove_no_existing_irq(struct irq_info *info, void *data __attribute - 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) --- -2.19.1 - diff --git a/bugfix-fgets-will-get-a-redundant-new-line.patch b/bugfix-fgets-will-get-a-redundant-new-line.patch deleted file mode 100644 index ec6e270..0000000 --- a/bugfix-fgets-will-get-a-redundant-new-line.patch +++ /dev/null @@ -1,50 +0,0 @@ -From 0c8ecab9e6f5fae5860e7fbc795e988c112edede Mon Sep 17 00:00:00 2001 -From: xiashuang -Date: Thu, 25 Jul 2019 22:38:32 -0400 -Subject: [PATCH] fix fgets will get a redundant new line - -this patch fix a bug introduced by bugfix-force-irq-into-rebalance-list-when-irq-removed-and-reinserted.patch. -the previous patch use fgets to get a directory name from buffer. but fgets will get a redundant newline, -so the directory name are always invalid, this patch just remove the '\n'. ---- - classify.c | 8 ++++++-- - 1 file changed, 6 insertions(+), 2 deletions(-) - -diff --git a/classify.c b/classify.c -index e61c39b..440576f 100644 ---- a/classify.c -+++ b/classify.c -@@ -747,6 +747,7 @@ void find_irq_dev_path(int irq, char *dirname, int length) - char path[PATH_MAX]; - char buffer[128]; - char *brc = NULL; -+ size_t dirlen; - - memset(dirname, 0, length); - /* Return defaults if irq is 0 */ -@@ -762,8 +763,10 @@ void find_irq_dev_path(int irq, char *dirname, int length) - } - - brc = fgets(buffer, 128, output); -- if (brc) { -+ /* 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; -@@ -779,8 +782,9 @@ void find_irq_dev_path(int irq, char *dirname, int length) - } - - brc = fgets(buffer, 128, output); -- if (brc) { -+ 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; --- -1.8.3.1 - diff --git a/bugfix-fix-memory-leak-of-strdup-in-collect_full_irq_list.patch b/bugfix-fix-memory-leak-of-strdup-in-collect_full_irq_list.patch deleted file mode 100644 index 8d8a05a..0000000 --- a/bugfix-fix-memory-leak-of-strdup-in-collect_full_irq_list.patch +++ /dev/null @@ -1,34 +0,0 @@ -From f3c1502c83f5ae09202a707669c924fc2bd0cca4 Mon Sep 17 00:00:00 2001 -From: liuchao173 -Date: Mon, 18 Nov 2019 13:57:11 +0000 -Subject: [PATCH] irqblance: fix memory leak of strdup - - fix memory leak of strdup in collect_full_irq_list(), when continue -in if branch, the savedline isn't freed ---- - procinterrupts.c | 2 ++ - 1 file changed, 2 insertions(+) - -diff --git a/procinterrupts.c b/procinterrupts.c -index e36fcac..bde31f4 100644 ---- a/procinterrupts.c -+++ b/procinterrupts.c -@@ -321,6 +321,7 @@ GList* collect_full_irq_list() - if (ban_pci_assigned_irq && is_pci_assigned_irq(c)) { - log(TO_ALL, LOG_INFO, "Banned PCI-assigned irq %d.\n", number); - add_vm_banned_irq(number); -+ free(savedline); - continue; - } - -@@ -338,6 +339,7 @@ GList* collect_full_irq_list() - * For these irqs, we can add these to banned irq list. - */ - add_banned_list_irq(number); -+ free(savedline); - continue; - } - #endif --- -2.19.1 - diff --git a/bugfix-fix-new-irqs-in-hotplug-keep-stay-on-one-numa.patch b/bugfix-fix-new-irqs-in-hotplug-keep-stay-on-one-numa.patch deleted file mode 100644 index 0b07079..0000000 --- a/bugfix-fix-new-irqs-in-hotplug-keep-stay-on-one-numa.patch +++ /dev/null @@ -1,161 +0,0 @@ -From feeb95206e1f178e2bbf0393483861f364bd7d5b Mon Sep 17 00:00:00 2001 -From: liuchao173 -Date: Wed, 23 Oct 2019 11:38:17 +0000 -Subject: [PATCH] irqbalance: fix new irqs in hotplug keep stay on one numa node - - when the number of cpus is huge, hotplug occurs and new irqs will stay on one numa node ---- - classify.c | 25 +++++++++++++++++++++++++ - procinterrupts.c | 24 +++++++++++++++++++++--- - rules_config.c | 4 ++++ - 3 files changed, 50 insertions(+), 3 deletions(-) - -diff --git a/classify.c b/classify.c -index 3681c48..54f27f0 100644 ---- a/classify.c -+++ b/classify.c -@@ -38,6 +38,7 @@ static GList *banned_irqs = NULL; - GList *cl_banned_irqs = NULL; - static GList *cl_banned_modules = NULL; - static GList *vm_banned_irqs = NULL; -+extern int need_add_single; - - #define SYSFS_DIR "/sys" - #define SYSPCI_DIR "/sys/bus/pci/devices" -@@ -646,6 +647,21 @@ 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 - */ -@@ -686,6 +702,12 @@ struct irq_info *build_one_dev_entry(const char *dirname, GList *tmp_list) - add_banned_irq(irqnum, &banned_irqs, 0); - 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); -@@ -723,6 +745,9 @@ struct irq_info *build_one_dev_entry(const char *dirname, GList *tmp_list) - add_banned_irq(irqnum, &banned_irqs, 0); - goto done; - } -+ if (!is_proc_irq_info_exist(irqnum, tmp_list)) { -+ goto done; -+ } - - hint.irq = irqnum; - hint.type = IRQ_TYPE_LEGACY; -diff --git a/procinterrupts.c b/procinterrupts.c -index c32c1b2..f0dd608 100644 ---- a/procinterrupts.c -+++ b/procinterrupts.c -@@ -43,6 +43,7 @@ - static int proc_int_has_msi = 0; - static int msi_found_in_sysfs = 0; - extern int ban_pci_assigned_irq; -+int need_add_single = 0; - - #ifdef AARCH64 - struct irq_match { -@@ -361,9 +362,10 @@ void parse_proc_interrupts(void) - uint64_t count; - char *c, *c2; - struct irq_info *info; -- struct irq_info tmp_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; -@@ -383,7 +385,9 @@ void parse_proc_interrupts(void) - if (!c) - continue; - -- strncpy(savedline, line, sizeof(savedline)-1); -+ savedline = strdup(line); -+ if (!savedline) -+ continue; - - *c = 0; - c++; -@@ -391,23 +395,36 @@ void parse_proc_interrupts(void) - - info = get_irq_info(number); - if (!info) { -+ 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; -+ set_usr_irq_policy(tmp_info.name, lookup); -+ } - log(TO_CONSOLE, LOG_INFO, "new IRQ %d added into database, dirname %s\n", number, dirname); - } else { -- init_irq_class_and_type(savedline, &tmp_info, number); - 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; - - if (ban_pci_assigned_irq) { -diff --git a/rules_config.c b/rules_config.c -index 767e9e1..9313fc6 100644 ---- a/rules_config.c -+++ b/rules_config.c -@@ -43,6 +43,10 @@ void set_usr_irq_policy(char *name, struct irq_info *info) - { - USER_IRQ_POLICY *user_policy; - -+ if (user_policy_list == NULL) { -+ return; -+ } -+ - user_policy = get_usr_irq_policy(name); - if (user_policy != NULL) { - if (user_policy->numa_node_set) { --- -2.19.1 - diff --git a/bugfix-fix-new-msi-irq-hasnot-been-added-to-rebalance-list.patch b/bugfix-fix-new-msi-irq-hasnot-been-added-to-rebalance-list.patch deleted file mode 100644 index a2bbe3d..0000000 --- a/bugfix-fix-new-msi-irq-hasnot-been-added-to-rebalance-list.patch +++ /dev/null @@ -1,25 +0,0 @@ -From d4fc2426a38728b912ec1acf3a3a990636e48b1d Mon Sep 17 00:00:00 2001 -From: liuchao173 -Date: Fri, 1 Nov 2019 02:42:19 +0000 -Subject: [PATCH] irqbalance: fix new msi irq hasnot been added to rebalance list - - fix new msi irq hasnot been added to rebalance_irq_list ---- - procinterrupts.c | 1 + - 1 file changed, 1 insertion(+) - -diff --git a/procinterrupts.c b/procinterrupts.c -index 64b462a..33e72ea 100644 ---- a/procinterrupts.c -+++ b/procinterrupts.c -@@ -405,6 +405,7 @@ void parse_proc_interrupts(void) - if (lookup != NULL) { - lookup->existing = 1; - set_usr_irq_policy(tmp_info.name, lookup); -+ info = lookup; - } - log(TO_CONSOLE, LOG_INFO, "new IRQ %d added into database, dirname %s\n", number, dirname); - } else { --- -2.19.1 - diff --git a/bugfix-fix-sleep-interval-when-sleep_interval-is-changed-by.patch b/bugfix-fix-sleep-interval-when-sleep_interval-is-changed-by.patch deleted file mode 100644 index 2c8452c..0000000 --- a/bugfix-fix-sleep-interval-when-sleep_interval-is-changed-by.patch +++ /dev/null @@ -1,79 +0,0 @@ -From f04d6488c12e215e2302b44c77bf66fce4950aef Mon Sep 17 00:00:00 2001 -From: liuchao -Date: Thu, 5 Dec 2019 15:28:14 +0800 -Subject: [PATCH] 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. - -Signed-off-by: liuchao ---- - hint_verify.c | 10 ++++++---- - irqbalance.c | 5 +++-- - 2 files changed, 9 insertions(+), 6 deletions(-) - -diff --git a/hint_verify.c b/hint_verify.c -index b3175ae..0718078 100644 ---- a/hint_verify.c -+++ b/hint_verify.c -@@ -15,6 +15,7 @@ - extern int keep_going; - extern GMainLoop *main_loop; - extern gboolean scan(); -+extern int last_interval; - - int real_sleep_interval; - int sleep_interval_count; -diff --git a/hint_verify.c b/hint_verify.c -index b3175ae..4258557 100644 ---- a/hint_verify.c -+++ b/hint_verify.c -@@ -84,7 +84,7 @@ void update_affinity_hint(struct irq_info *info, void *data __attribute__((unuse - * 1. scan opration for irq balancing; - * 2. poll irq affinity hint changes for quickly applying them. - */ --gboolean poll_hint_affinity_and_scan(gpointer data) -+gboolean poll_hint_affinity_and_scan(gpointer data __attribute__((unused))) - { - gboolean need_verify_flag = FALSE; - gboolean need_scan_flag = FALSE; -@@ -118,9 +118,10 @@ gboolean poll_hint_affinity_and_scan(gpointer data) - } - } - -- if (data != &real_sleep_interval) { -- data = &real_sleep_interval; -- g_timeout_add_seconds(real_sleep_interval, poll_hint_affinity_and_scan, data); -+ update_interval_and_count(); -+ if (last_interval != real_sleep_interval) { -+ last_interval = real_sleep_interval; -+ g_timeout_add_seconds(real_sleep_interval, poll_hint_affinity_and_scan, NULL); - return FALSE; - } - -diff --git a/irqbalance.c b/irqbalance.c -index 3fc00db..05eaa29 100644 ---- a/irqbalance.c -+++ b/irqbalance.c -@@ -67,6 +67,7 @@ long HZ; - int sleep_interval = SLEEP_INTERVAL; - int hint_enabled = 0; - int poll_hint_interval = SLEEP_INTERVAL / 5; -+int last_interval; - GMainLoop *main_loop; - - char *banned_cpumask_from_ui = NULL; -@@ -641,8 +642,8 @@ int main(int argc, char** argv) - log(TO_ALL, LOG_INFO, "irqbalance start scan.\n"); - update_interval_and_count(); - main_loop = g_main_loop_new(NULL, FALSE); -- int *last_interval = &real_sleep_interval; -- g_timeout_add_seconds(real_sleep_interval, poll_hint_affinity_and_scan, last_interval); -+ last_interval = real_sleep_interval; -+ g_timeout_add_seconds(real_sleep_interval, poll_hint_affinity_and_scan, NULL); - g_main_loop_run(main_loop); - - g_main_loop_quit(main_loop); --- -2.19.1 - diff --git a/bugfix-fix-strcat-may-cause-buffer-overrun.patch b/bugfix-fix-strcat-may-cause-buffer-overrun.patch deleted file mode 100644 index 4c571c4..0000000 --- a/bugfix-fix-strcat-may-cause-buffer-overrun.patch +++ /dev/null @@ -1,64 +0,0 @@ -From f4d052d7b210612a7ffbdd7c3cfbce213c9a0e21 Mon Sep 17 00:00:00 2001 -From: liuchao173 -Date: Fri, 8 Nov 2019 08:47:43 +0000 -Subject: [PATCH] irqbalance: fix strcat may cause buffer overrun - -when the sum length of irq_name and saveptr is more than PATH_MAX, strcat will cause buffer overrun ---- - procinterrupts.c | 26 ++++++++++++++++++-------- - 1 file changed, 18 insertions(+), 8 deletions(-) - -diff --git a/procinterrupts.c b/procinterrupts.c -index 373d8b5..0b24b56 100644 ---- a/procinterrupts.c -+++ b/procinterrupts.c -@@ -205,6 +205,7 @@ static void init_irq_class_and_type(char *savedline, struct irq_info *info, int - int is_xen_dyn = 0; - #ifdef AARCH64 - char *tmp = NULL; -+ char irq_fullname_valid = 1; - char irq_fullname[PATH_MAX] = {0}; - #endif - -@@ -236,12 +237,16 @@ static void init_irq_class_and_type(char *savedline, struct irq_info *info, int - if (tmp) - *tmp = 0; - -- strcat(irq_fullname, irq_name); -- strcat(irq_fullname, " "); -- strcat(irq_fullname, savedptr); -- tmp = strchr(irq_fullname, '\n'); -- if (tmp) -- *tmp = 0; -+ if (strlen(irq_name) + strlen(savedptr) + 1 < PATH_MAX) { -+ strcat(irq_fullname, irq_name); -+ strcat(irq_fullname, " "); -+ strcat(irq_fullname, savedptr); -+ tmp = strchr(irq_fullname, '\n'); -+ if (tmp) -+ *tmp = 0; -+ } else { -+ irq_fullname_valid = 0; -+ } - #endif - irq_mod = last_token; - info->irq = irq; -@@ -251,8 +256,13 @@ static void init_irq_class_and_type(char *savedline, struct irq_info *info, int - info->class = IRQ_VIRT_EVENT; - } else { - #ifdef AARCH64 -- irq_name = irq_fullname; -- guess_arm_irq_hints(irq_name, info); -+ if (irq_fullname_valid) { -+ irq_name = irq_fullname; -+ guess_arm_irq_hints(irq_name, info); -+ } else { -+ info->type = IRQ_TYPE_LEGACY; -+ info->class = IRQ_OTHER; -+ } - #else - info->type = IRQ_TYPE_LEGACY; - info->class = IRQ_OTHER; --- -2.19.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 index 4faa9bb..15a0279 100644 --- 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 @@ -1,35 +1,41 @@ -From 1ca314651ddc31cd52ef67893fdd7aac43ea5201 Mon Sep 17 00:00:00 2001 -From: zhengshaoyu -Date: Thu, 22 Jun 2017 04:39:00 +0000 -Subject: [PATCH] irqbalance: bugfix popen and pclose +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 -[Changelog]: bugfix popen and pclose -[Author]:zhengshaoyu - -Date: Sun, 17 Mar 2019 20:07:28 -0400 +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 | 126 ++++++++++++++++++++++++++++++++++++++++++++++++------- - irqbalance.c | 2 +- - irqbalance.h | 5 +++ - procinterrupts.c | 112 +++++++++++++++++++++++++++++++------------------ + classify.c | 154 +++++++++++++++++++++++++++++++++++++++++++++++++------ + irqbalance.c | 6 ++- + irqbalance.h | 7 +++ + procinterrupts.c | 145 ++++++++++++++++++++++++++++++++++----------------- types.h | 1 + - 5 files changed, 190 insertions(+), 56 deletions(-) + 5 files changed, 250 insertions(+), 63 deletions(-) diff --git a/classify.c b/classify.c -index 9868633..30a8d2a 100644 +index b40fcc1..2dc93ca 100644 --- a/classify.c +++ b/classify.c -@@ -66,6 +66,8 @@ struct pci_info { - #define PCI_SUB_DEVICE_EMC_0568 0x0568 - #define PCI_SUB_DEVICE_EMC_dd00 0xdd00 +@@ -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; -+extern void force_rebalance_irq(struct irq_info *info, void *data __attribute__((unused))); -+ - /* - * Apply software workarounds for some special devices - * -@@ -562,11 +564,13 @@ static int check_for_irq_ban(char *path __attribute__((unused)), int irq, GList + #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. */ @@ -48,7 +54,25 @@ index 9868633..30a8d2a 100644 } #ifdef INCLUDE_BANSCRIPT -@@ -605,13 +609,14 @@ static int check_for_irq_ban(char *path __attribute__((unused)), int irq, GList +@@ -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 */ @@ -65,16 +89,25 @@ index 9868633..30a8d2a 100644 char path[PATH_MAX]; char devpath[PATH_MAX]; struct user_irq_policy pol; -@@ -635,7 +640,7 @@ static void build_one_dev_entry(const char *dirname, GList *tmp_irqs) +@@ -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); + __add_banned_irq(irqnum, &banned_irqs); continue; } -@@ -647,13 +652,13 @@ static void build_one_dev_entry(const char *dirname, GList *tmp_irqs) ++ 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); @@ -90,16 +123,22 @@ index 9868633..30a8d2a 100644 if (fscanf(fd, "%d", &irqnum) < 0) goto done; -@@ -670,7 +675,7 @@ static void build_one_dev_entry(const char *dirname, GList *tmp_irqs) +@@ -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(path, irqnum, tmp_irqs))) { -+ if ((pol.ban == 1) || (check_for_irq_ban(path, irqnum, tmp_list))) { - add_banned_irq(irqnum, &banned_irqs); +- 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; } -@@ -684,7 +689,56 @@ static void build_one_dev_entry(const char *dirname, GList *tmp_irqs) ++ 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); @@ -114,6 +153,7 @@ index 9868633..30a8d2a 100644 + char path[PATH_MAX]; + char buffer[128]; + char *brc = NULL; ++ size_t dirlen; + + memset(dirname, 0, length); + /* Return defaults if irq is 0 */ @@ -129,8 +169,10 @@ index 9868633..30a8d2a 100644 + } + + brc = fgets(buffer, 128, output); -+ if (brc) { ++ /* 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; @@ -146,8 +188,9 @@ index 9868633..30a8d2a 100644 + } + + brc = fgets(buffer, 128, output); -+ if (brc) { ++ 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; @@ -157,7 +200,7 @@ index 9868633..30a8d2a 100644 } static void free_irq(struct irq_info *info, void *data __attribute__((unused))) -@@ -692,6 +750,42 @@ 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); } @@ -195,12 +238,15 @@ index 9868633..30a8d2a 100644 +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); -@@ -711,14 +805,14 @@ void free_cl_opts(void) +@@ -733,14 +853,14 @@ void free_cl_opts(void) g_list_free(banned_irqs); } @@ -218,7 +264,7 @@ index 9868633..30a8d2a 100644 /* Set NULL devpath for the irq has no sysfs entries */ get_irq_user_policy(NULL, irq, &pol); -@@ -730,6 +824,8 @@ static void add_new_irq(int irq, struct irq_info *hint, GList *proc_interrupts) +@@ -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); @@ -228,10 +274,10 @@ index 9868633..30a8d2a 100644 static void add_missing_irq(struct irq_info *info, void *attr) diff --git a/irqbalance.c b/irqbalance.c -index 2f699b8..e375a1a 100644 +index f965a2a..4d0a417 100644 --- a/irqbalance.c +++ b/irqbalance.c -@@ -238,7 +238,7 @@ static void dump_object_tree(void) +@@ -251,11 +251,15 @@ static void dump_object_tree(void) for_each_object(numa_nodes, dump_numa_node_info, NULL); } @@ -240,26 +286,45 @@ index 2f699b8..e375a1a 100644 { 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 8d5b329..73737ed 100644 +index 3a78c7f..9e28285 100644 --- a/irqbalance.h +++ b/irqbalance.h -@@ -107,6 +107,10 @@ extern void free_cl_opts(void); - extern void add_cl_banned_module(char *modname); +@@ -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; /* - * Generic object functions diff --git a/procinterrupts.c b/procinterrupts.c -index eb84a1c..d384860 100644 +index 70831b4..358458c 100644 --- a/procinterrupts.c +++ b/procinterrupts.c -@@ -142,6 +142,52 @@ static void guess_arm_irq_hints(char *name, struct irq_info *info) +@@ -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 @@ -312,7 +377,7 @@ index eb84a1c..d384860 100644 GList* collect_full_irq_list() { -@@ -149,10 +187,6 @@ GList* collect_full_irq_list() +@@ -151,10 +198,6 @@ GList* collect_full_irq_list() FILE *file; char *line = NULL; size_t size = 0; @@ -323,15 +388,15 @@ index eb84a1c..d384860 100644 file = fopen("/proc/interrupts", "r"); if (!file) -@@ -168,7 +206,6 @@ GList* collect_full_irq_list() - - while (!feof(file)) { - int number; +@@ -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; -@@ -188,45 +222,13 @@ GList* collect_full_irq_list() + struct irq_info *info; + char *c; + char *savedline = NULL; +@@ -191,45 +233,13 @@ GList* collect_full_irq_list() savedline = strdup(line); if (!savedline) break; @@ -378,7 +443,7 @@ index eb84a1c..d384860 100644 tmp_list = g_list_append(tmp_list, info); } free(savedline); -@@ -230,6 +235,14 @@ GList* collect_full_irq_list() +@@ -239,6 +249,14 @@ GList* collect_full_irq_list() return tmp_list; } @@ -393,44 +458,70 @@ index eb84a1c..d384860 100644 void parse_proc_interrupts(void) { FILE *file; -@@ -253,7 +266,9 @@ void parse_proc_interrupts(void) +@@ -262,7 +280,10 @@ void parse_proc_interrupts(void) uint64_t count; char *c, *c2; struct irq_info *info; -+ struct irq_info tmp_info; - char savedline[1024]; +- 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) + if (getline(&line, &size, file)<=0) break; -@@ -281,9 +296,24 @@ void parse_proc_interrupts(void) +@@ -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 { -+ init_irq_class_and_type(savedline, &tmp_info, number); + 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; -@@ -307,17 +337,19 @@ void parse_proc_interrupts(void) +@@ -316,17 +367,19 @@ void parse_proc_interrupts(void) * cause an overflow and IRQ won't be rebalanced again */ if (count < info->irq_count) { diff --git a/bugfix-irqbalance-fix-wrong-pid-value-in-pid-file.patch b/bugfix-irqbalance-fix-wrong-pid-value-in-pid-file.patch deleted file mode 100644 index 3eb3108..0000000 --- a/bugfix-irqbalance-fix-wrong-pid-value-in-pid-file.patch +++ /dev/null @@ -1,125 +0,0 @@ -From 948425c293615a9f4a30e9049d6ca4380c7b6c83 Mon Sep 17 00:00:00 2001 -From: hejingxian -Date: Wed, 13 Nov 2019 13:13:28 +0800 -Subject: [PATCH] bugfix: irqbalance: fix wrong pid value in pid file - -If irqbalance is killed by SIGKILL or SIGTERM, -after restarting irqbalance, the pid in pid file is -wrong, that's because the way we forbid starting -multiple irqbalance instances is wrong. - -Here we use fcntl to lock pid file to forbid another instance -been launched. - -Signed-off-by: zhanghailiang ---- - irqbalance.c | 83 ++++++++++++++++++++++++++++++++++++++++++++++++++++++------ - 1 file changed, 75 insertions(+), 8 deletions(-) - -diff --git a/irqbalance.c b/irqbalance.c -index 18cd7de..467e968 100644 ---- a/irqbalance.c -+++ b/irqbalance.c -@@ -560,6 +560,78 @@ int init_socket() - return 0; - } - -+static int create_lock_pidfile(const char *lockfile) -+{ -+ struct flock lock = { 0 }; -+ char pid_s[16] = { 0 }; -+ int lf = 0; -+ int err = -1; -+ -+ lf = open(lockfile, O_WRONLY | O_CREAT, S_IRUSR | S_IWUSR); -+ if (lf == -1) { -+ err = -errno; -+ log(TO_ALL, LOG_WARNING, "irqbalance (%u): Can't create lock file.\n", -+ getpid()); -+ return err; -+ } -+ -+retry_fcntl: -+ lock.l_type = F_WRLCK; -+ lock.l_start = 0; -+ lock.l_whence = SEEK_SET; -+ lock.l_len = 0; -+ if (fcntl (lf, F_SETLK, &lock) == -1) { -+ err = -errno; -+ switch (errno) { -+ case EINTR: -+ goto retry_fcntl; -+ case EAGAIN: -+ case EACCES: -+ log(TO_ALL, LOG_WARNING, "irqbalance (%u): Another instance is" -+ " already running, errno:%d.\n", getpid(), errno); -+ goto error_close; -+ default: -+ log(TO_ALL, LOG_WARNING, "irqbalance (%u): Can't aquire lock." -+ " errno %d.\n", getpid(), errno); -+ goto error_close; -+ } -+ } -+ -+ if (ftruncate(lf, 0) == -1) { -+ err = -errno; -+ log(TO_ALL, LOG_WARNING, "irqbalance (%u): Can't truncate lock file." -+ " errno: %d.\n", getpid(), errno); -+ goto error_close_unlink; -+ } -+ if (snprintf(pid_s, sizeof(pid_s), "%u\n", getpid()) < 0) { -+ log(TO_ALL, LOG_WARNING, "irqbalance (%u): Can't printf pid string.\n", getpid()); -+ err = -1; -+ goto error_close_unlink; -+ } -+ -+retry_write: -+ if ((size_t)write(lf, pid_s, strlen (pid_s)) != strlen (pid_s)) { -+ err = -errno; -+ if (errno == EINTR) { -+ goto retry_write; -+ } else { -+ log(TO_ALL, LOG_WARNING, "irqbalance (%u): Can't write pid to lock" -+ " file. errno %d\n", getpid(), errno); -+ goto error_close_unlink; -+ } -+ } -+ close(lf); -+ return 0; -+ -+error_close_unlink: -+ (void) unlink(lockfile); -+ -+error_close: -+ close(lf); -+ return err; -+} -+ -+ - int main(int argc, char** argv) - { - sigset_t sigset, old_sigset; -@@ -652,17 +724,12 @@ int main(int argc, char** argv) - } - - 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); -+ if (pidfile && create_lock_pidfile(pidfile) < 0) { -+ ret = EXIT_FAILURE; -+ goto out; - } - } - --- -1.8.3.1 - diff --git a/bugfix-prevent-version-cmd-need-an-argument.patch b/bugfix-prevent-version-cmd-need-an-argument.patch deleted file mode 100644 index baa481a..0000000 --- a/bugfix-prevent-version-cmd-need-an-argument.patch +++ /dev/null @@ -1,27 +0,0 @@ -From cea147fc56b018266ac3235b82cdaf7d0ba74628 Mon Sep 17 00:00:00 2001 -From: hejingxian -Date: Fri, 10 Jan 2020 15:36:57 +0800 -Subject: [PATCH] prevent version cmd need an argument - -In order to prevent the version cmd need an argument, -the option 'V' can't be followed by ':'. ---- - irqbalance.c | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/irqbalance.c b/irqbalance.c -index 15fb0fe..f182b3c 100644 ---- a/irqbalance.c -+++ b/irqbalance.c -@@ -133,7 +133,7 @@ static void parse_command_line(int argc, char **argv) - unsigned long val; - - while ((opt = getopt_long(argc, argv, -- "odfji:p:s:c:b:l:m:t:V:h:v:r:ne:g:", -+ "odfjVni:p:s:c:b:l:m:t:h:v:r:e:g:", - lopts, &longind)) != -1) { - - switch(opt) { --- -1.8.3.1 - diff --git a/bugfix-change-irq-ban-check-path-to-devpath.patch b/change-irq-ban-check-path-to-devpath.patch similarity index 79% rename from bugfix-change-irq-ban-check-path-to-devpath.patch rename to change-irq-ban-check-path-to-devpath.patch index 8045c61..f0c41ce 100644 --- a/bugfix-change-irq-ban-check-path-to-devpath.patch +++ b/change-irq-ban-check-path-to-devpath.patch @@ -16,12 +16,12 @@ 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 (user_policy_list == NULL) { - get_irq_user_policy(devpath, irqnum, &pol); - } -- if ((pol.ban == 1) || (check_for_irq_ban(path, irqnum, tmp_list))) { -+ if ((pol.ban == 1) || (check_for_irq_ban(devpath, irqnum, tmp_list))) { - add_banned_irq(irqnum, &banned_irqs, 0); + 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; } -- diff --git a/feature-add-new-user-irq-policy-config-rule.patch b/feature-add-new-user-irq-policy-config-rule.patch index b2fe8e7..52df5fa 100644 --- a/feature-add-new-user-irq-policy-config-rule.patch +++ b/feature-add-new-user-irq-policy-config-rule.patch @@ -11,7 +11,6 @@ for every irq. classify.c | 32 +++++++-- irqbalance.c | 38 +++++---- irqbalance.h | 2 +- - misc/irqbalance.service | 2 +- placement.c | 3 +- procinterrupts.c | 3 +- rules_config.c | 172 ++++++++++++++++++++++++++++++++++++++++++++++++ @@ -55,7 +54,7 @@ index 65aeae2..7c97d47 100644 + 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); + __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); @@ -65,10 +64,10 @@ index 65aeae2..7c97d47 100644 + if (user_policy_list == NULL) { + get_irq_user_policy(devpath, irqnum, &pol); + } - if ((pol.ban == 1) || (check_for_irq_ban(path, irqnum, tmp_list))) { - add_banned_irq(irqnum, &banned_irqs, 0); + if ((pol.ban == 1) || (check_for_irq_ban(devpath, irqnum, tmp_list))) { + __add_banned_irq(irqnum, &banned_irqs, 0); goto done; -@@ -855,18 +859,24 @@ struct irq_info *add_new_irq(int irq, struct irq_info *hint, GList *proc_interru +@@ -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; @@ -83,28 +82,23 @@ index 65aeae2..7c97d47 100644 + 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); + __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) && (user_policy_list != NULL)) { ++ 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,16 @@ static void add_missing_irq(struct irq_info *info, void *attr) +@@ -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 { -+ if (user_policy_list != NULL) { -+ set_usr_irq_policy(info->name, lookup); -+ } -+ } ++ else ++ set_usr_irq_policy(info->name, lookup); + if (info->name) { + free(info->name); + info->name = NULL; @@ -118,34 +112,33 @@ index 21d578a..d41753c 100644 --- a/irqbalance.c +++ b/irqbalance.c @@ -99,6 +99,7 @@ struct option lopts[] = { - {"banmod", 1 , NULL, 'm'}, - {"interval", 1 , NULL, 't'}, {"version", 0, NULL, 'V'}, + {"migrateval", 1, NULL, 'e'}, + {"loadlimit", 1, NULL, 'g'}, + {"rulesconfig", 1, NULL, 'r'}, {0, 0, 0, 0} }; -@@ -106,7 +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