diff --git a/Add-IRQBALANCE_BANNED_CPULIST-to-env-file.patch b/Add-IRQBALANCE_BANNED_CPULIST-to-env-file.patch deleted file mode 100644 index a15b784..0000000 --- a/Add-IRQBALANCE_BANNED_CPULIST-to-env-file.patch +++ /dev/null @@ -1,39 +0,0 @@ -From 31c7d128fd6f083c7395b327f824a0c11d5e380f Mon Sep 17 00:00:00 2001 -From: Yunfeng Ye -Date: Sat, 21 Nov 2020 14:27:28 +0800 -Subject: [PATCH] Add IRQBALANCE_BANNED_CPULIST to env file - -Signed-off-by: Yunfeng Ye ---- - misc/irqbalance.env | 15 +++++++++++++++ - 1 file changed, 15 insertions(+) - -diff --git a/misc/irqbalance.env b/misc/irqbalance.env -index 23570b2..237e4af 100644 ---- a/misc/irqbalance.env -+++ b/misc/irqbalance.env -@@ -22,6 +22,21 @@ - #IRQBALANCE_BANNED_CPUS= - - # -+# IRQBALANCE_BANNED_CPULIST -+# The CPUs list which allows you to indicate which CPUs should -+# be skipped when reblancing IRQs. CPU numbers in CPUs list will -+# not have any IRQs assigned to them on rebalance. -+# -+# The format of CPUs list is: -+# ,..., -+# or a range: -+# - -+# or a mixture: -+# ,...,- -+# -+#IRQBALANCE_BANNED_CPULIST= -+ -+# - # IRQBALANCE_ARGS - # Append any args here to the irqbalance daemon as documented in the man - # page. --- -1.8.3.1 - diff --git a/backport-Add-hot-pull-method-for-irqbalance.patch b/backport-Add-hot-pull-method-for-irqbalance.patch new file mode 100644 index 0000000..2db673f --- /dev/null +++ b/backport-Add-hot-pull-method-for-irqbalance.patch @@ -0,0 +1,115 @@ +From ef9bf64affbca0b030f9128d93f302296d166dac Mon Sep 17 00:00:00 2001 +From: hejingxian 00273181 +Date: Mon, 4 Jan 2021 12:34:02 +0800 +Subject: [PATCH] Add hot pull method for irqbalance + +Conflict:NA +Reference:https://github.com/Irqbalance/irqbalance/commit/ef9bf64affbca0b030f9128d93f302296d166dac +--- + classify.c | 37 +++++++++++++++++++++++++++++++++++++ + irqbalance.h | 1 + + procinterrupts.c | 4 +++- + types.h | 1 + + 4 files changed, 42 insertions(+), 1 deletion(-) + +diff --git a/classify.c b/classify.c +index 4b6ffa8..beb2919 100644 +--- a/classify.c ++++ b/classify.c +@@ -852,3 +852,39 @@ void sort_irq_list(GList **list) + { + *list = g_list_sort(*list, sort_irqs); + } ++ ++static void remove_no_existing_irq(struct irq_info *info, void *data __attribute__((unused))) ++{ ++ GList *entry = NULL; ++ ++ if (info->existing) { ++ /* clear existing flag for next detection */ ++ 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(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); ++ } ++} ++ +diff --git a/irqbalance.h b/irqbalance.h +index d8e80a9..e7f6b94 100644 +--- a/irqbalance.h ++++ b/irqbalance.h +@@ -42,6 +42,7 @@ extern void set_interrupt_count(int number, uint64_t count); + extern void set_msi_interrupt_numa(int number); + extern void init_irq_class_and_type(char *savedline, struct irq_info *info, int irq); + extern int proc_irq_hotplug(char *line, int irq, struct irq_info **pinfo); ++extern void clear_no_existing_irqs(void); + + extern GList *rebalance_irq_list; + extern void force_rebalance_irq(struct irq_info *info, void *data __attribute__((unused))); +diff --git a/procinterrupts.c b/procinterrupts.c +index 0671be0..854282f 100644 +--- a/procinterrupts.c ++++ b/procinterrupts.c +@@ -248,7 +248,6 @@ GList* collect_full_irq_list() + return tmp_list; + } + +- + void parse_proc_interrupts(void) + { + FILE *file; +@@ -310,6 +309,7 @@ void parse_proc_interrupts(void) + break; + } + } ++ info->existing = 1; + free(savedline); + + count = 0; +@@ -354,6 +354,8 @@ void parse_proc_interrupts(void) + */ + msi_found_in_sysfs = 1; + } ++ if (!need_rescan) ++ clear_no_existing_irqs(); + fclose(file); + free(line); + } +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; + }; +-- +2.23.0 + diff --git a/backport-Add-log-for-hotplug-appropriately.patch b/backport-Add-log-for-hotplug-appropriately.patch new file mode 100644 index 0000000..d11c4eb --- /dev/null +++ b/backport-Add-log-for-hotplug-appropriately.patch @@ -0,0 +1,43 @@ +From 6ae114f8719a6a49cef73a32d820a77e900ddf08 Mon Sep 17 00:00:00 2001 +From: hejingxian 00273181 +Date: Thu, 17 Dec 2020 17:47:45 +0800 +Subject: [PATCH] Add log for hotplug appropriately + +Conflict:NA +Reference:https://github.com/Irqbalance/irqbalance/commit/6ae114f8719a6a49cef73a32d820a77e900ddf08 +--- + classify.c | 7 +++++-- + 1 file changed, 5 insertions(+), 2 deletions(-) + +diff --git a/classify.c b/classify.c +index 0d556e9..4b6ffa8 100644 +--- a/classify.c ++++ b/classify.c +@@ -644,12 +644,13 @@ static void build_one_dev_entry(const char *dirname, GList *tmp_irqs, int build_ + irqnum = strtol(entry->d_name, NULL, 10); + /* If build_irq is valid, only add irq when it's number equals to build_irq */ + if (irqnum && ((build_irq < 0) || (irqnum == build_irq))) { +- printf("add irq:%d %d for %s\n", irqnum, build_irq, path); + hint.irq = irqnum; + hint.type = IRQ_TYPE_MSIX; + add_new_irq(devpath, &hint, tmp_irqs); +- if (build_irq >= 0) ++ if (build_irq >= 0) { ++ log(TO_CONSOLE, LOG_INFO, "Hotplug dev irq: %d finished.\n", irqnum); + break; ++ } + } + } while (entry != NULL); + closedir(msidir); +@@ -674,6 +675,8 @@ static void build_one_dev_entry(const char *dirname, GList *tmp_irqs, int build_ + hint.irq = irqnum; + hint.type = IRQ_TYPE_LEGACY; + add_new_irq(devpath, &hint, tmp_irqs); ++ if (build_irq >= 0) ++ log(TO_CONSOLE, LOG_INFO, "Hotplug dev irq: %d finished.\n", irqnum); + } + } + +-- +2.23.0 + diff --git a/backport-Also-fetch-node-info-for-non-PCI-devices.patch b/backport-Also-fetch-node-info-for-non-PCI-devices.patch new file mode 100644 index 0000000..b2c960f --- /dev/null +++ b/backport-Also-fetch-node-info-for-non-PCI-devices.patch @@ -0,0 +1,39 @@ +From 31dea01f3a47aa6374560638486879e5129f9c94 Mon Sep 17 00:00:00 2001 +From: Kairui Song +Date: Thu, 28 Jan 2021 15:24:32 +0800 +Subject: [PATCH] Also fetch node info for non-PCI devices + +non-PCI devices could also be bind to a certain node. So if failed to +fetch the info from sysfs, try to get it from /proc/irq//node. + +Conflict:NA +Reference:https://github.com/Irqbalance/irqbalance/commit/31dea01f3a47aa6374560638486879e5129f9c94 +--- + classify.c | 11 ++++++++--- + 1 file changed, 8 insertions(+), 3 deletions(-) + +diff --git a/classify.c b/classify.c +index beb2919..105ecd6 100644 +--- a/classify.c ++++ b/classify.c +@@ -361,9 +361,14 @@ static struct irq_info *add_one_irq_to_db(const char *devpath, struct irq_info * + + get_numa_node: + numa_node = NUMA_NO_NODE; +- if (devpath != NULL && numa_avail) { +- sprintf(path, "%s/numa_node", devpath); +- process_one_line(path, get_int, &numa_node); ++ if (numa_avail) { ++ if (devpath != NULL) { ++ sprintf(path, "%s/numa_node", devpath); ++ process_one_line(path, get_int, &numa_node); ++ } else { ++ sprintf(path, "/proc/irq/%i/node", irq); ++ process_one_line(path, get_int, &numa_node); ++ } + } + + if (pol->numa_node_set == 1) +-- +2.23.0 + diff --git a/backport-Hotplug-may-occur-again-during-sleep-so-wait-until-t.patch b/backport-Hotplug-may-occur-again-during-sleep-so-wait-until-t.patch new file mode 100644 index 0000000..5eced5a --- /dev/null +++ b/backport-Hotplug-may-occur-again-during-sleep-so-wait-until-t.patch @@ -0,0 +1,28 @@ +From 518d81cdd8c54c820d16afb73658753b46032676 Mon Sep 17 00:00:00 2001 +From: SuperSix173 +Date: Tue, 6 Apr 2021 10:26:17 +0800 +Subject: [PATCH] Hotplug may occur again during sleep, so wait until there is + no hotplug + +Conflict:NA +Reference:https://github.com/Irqbalance/irqbalance/commit/518d81cdd8c54c820d16afb73658753b46032676 +--- + irqbalance.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/irqbalance.c b/irqbalance.c +index 458bb07..3f94847 100644 +--- a/irqbalance.c ++++ b/irqbalance.c +@@ -285,7 +285,7 @@ gboolean scan(gpointer data __attribute__((unused))) + + + /* cope with cpu hotplug -- detected during /proc/interrupts parsing */ +- if (need_rescan || need_rebuild) { ++ while (need_rescan || need_rebuild) { + int try_times = 0; + + need_rescan = 0; +-- +2.23.0 + diff --git a/backport-activate_mapping-activate-only-online-CPUs.patch b/backport-activate_mapping-activate-only-online-CPUs.patch new file mode 100644 index 0000000..0a50f7e --- /dev/null +++ b/backport-activate_mapping-activate-only-online-CPUs.patch @@ -0,0 +1,56 @@ +From c8757c6d870c4788da4980abaf21cb7369702ee9 Mon Sep 17 00:00:00 2001 +From: Paride Legovini +Date: Tue, 25 Aug 2020 23:18:27 +0200 +Subject: [PATCH] activate_mapping: activate only online CPUs + +When echoing a mask to /proc/irq/N/smp_affinity make sure to activate +only CPUs which are online. Activating a CPU which is not online results +in a EOVERFLOW. + +Originally fixed in Debian by Helge Deller . + +Conflict:NA +Reference:https://github.com/Irqbalance/irqbalance/commit/c8757c6d870c4788da4980abaf21cb7369702ee9 +--- + activate.c | 8 ++++++-- + 1 file changed, 6 insertions(+), 2 deletions(-) + +diff --git a/activate.c b/activate.c +index 065f880..62cfd08 100644 +--- a/activate.c ++++ b/activate.c +@@ -49,6 +49,7 @@ static void activate_mapping(struct irq_info *info, void *data __attribute__((un + char buf[PATH_MAX]; + FILE *file; + int ret = 0; ++ cpumask_t applied_mask; + + /* + * only activate mappings for irqs that have moved +@@ -59,10 +60,13 @@ static void activate_mapping(struct irq_info *info, void *data __attribute__((un + if (!info->assigned_obj) + return; + ++ /* activate only online cpus, otherwise writing to procfs returns EOVERFLOW */ ++ cpus_and(applied_mask, cpu_online_map, info->assigned_obj->mask); ++ + /* + * Don't activate anything for which we have an invalid mask + */ +- if (check_affinity(info, info->assigned_obj->mask)) ++ if (check_affinity(info, applied_mask)) + return; + + sprintf(buf, "/proc/irq/%i/smp_affinity", info->irq); +@@ -70,7 +74,7 @@ static void activate_mapping(struct irq_info *info, void *data __attribute__((un + if (!file) + return; + +- cpumask_scnprintf(buf, PATH_MAX, info->assigned_obj->mask); ++ cpumask_scnprintf(buf, PATH_MAX, applied_mask); + ret = fprintf(file, "%s", buf); + if (ret < 0) { + log(TO_ALL, LOG_WARNING, "cannot change irq %i's affinity, add it to banned list", info->irq); +-- +2.23.0 + diff --git a/add-env-variable-to-ban-cpus-using-cpulist-syntax.patch b/backport-add-env-variable-to-ban-cpus-using-cpulist-syntax.patch similarity index 92% rename from add-env-variable-to-ban-cpus-using-cpulist-syntax.patch rename to backport-add-env-variable-to-ban-cpus-using-cpulist-syntax.patch index 408dadc..477298c 100644 --- a/add-env-variable-to-ban-cpus-using-cpulist-syntax.patch +++ b/backport-add-env-variable-to-ban-cpus-using-cpulist-syntax.patch @@ -7,7 +7,8 @@ allows banning of cpus using the taskset cpulist syntax in addition to the bitmap syntax supported via the existing environment variable IRQBALANCE_BANNED_CPUS -Signed-off-by: Yunfeng Ye +Conflict:NA +Reference:https://github.com/Irqbalance/irqbalance/commit/677b686e223c74e64f5b230bdb4079555a5a62a9 --- cputree.c | 6 ++++++ irqbalance.1 | 6 ++++++ @@ -48,5 +49,5 @@ index 3005f6b..33ffd26 100644 .TP .B SIGHUP -- -1.8.3.1 +2.23.0 diff --git a/backport-add-irq-hotplug-feature-for-irqbalance.patch b/backport-add-irq-hotplug-feature-for-irqbalance.patch new file mode 100644 index 0000000..d96b536 --- /dev/null +++ b/backport-add-irq-hotplug-feature-for-irqbalance.patch @@ -0,0 +1,352 @@ +From 0ba4a60a2a732150e5016389e32b2e81906a72c2 Mon Sep 17 00:00:00 2001 +From: hejingxian 00273181 +Date: Fri, 4 Dec 2020 10:52:57 +0800 +Subject: [PATCH] add irq hotplug feature for irqbalance + +Conflict:NA +Reference:https://github.com/Irqbalance/irqbalance/commit/0ba4a60a2a732150e5016389e32b2e81906a72c2 +--- + classify.c | 70 +++++++++++++++++++++++-------- + irqbalance.c | 2 +- + irqbalance.h | 4 +- + procinterrupts.c | 104 ++++++++++++++++++++++++++++------------------- + 4 files changed, 120 insertions(+), 60 deletions(-) + +diff --git a/classify.c b/classify.c +index 9f588bc..0d556e9 100644 +--- a/classify.c ++++ b/classify.c +@@ -619,7 +619,7 @@ static void add_new_irq(char *path, struct irq_info *hint, GList *proc_interrupt + /* + * 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) ++static void build_one_dev_entry(const char *dirname, GList *tmp_irqs, int build_irq) + { + struct dirent *entry; + DIR *msidir; +@@ -642,10 +642,14 @@ static void build_one_dev_entry(const char *dirname, GList *tmp_irqs) + if (!entry) + break; + irqnum = strtol(entry->d_name, NULL, 10); +- if (irqnum) { ++ /* If build_irq is valid, only add irq when it's number equals to build_irq */ ++ if (irqnum && ((build_irq < 0) || (irqnum == build_irq))) { ++ printf("add irq:%d %d for %s\n", irqnum, build_irq, path); + hint.irq = irqnum; + hint.type = IRQ_TYPE_MSIX; + add_new_irq(devpath, &hint, tmp_irqs); ++ if (build_irq >= 0) ++ break; + } + } while (entry != NULL); + closedir(msidir); +@@ -665,9 +669,12 @@ static void build_one_dev_entry(const char *dirname, GList *tmp_irqs) + #else + if (irqnum) { + #endif +- hint.irq = irqnum; +- hint.type = IRQ_TYPE_LEGACY; +- add_new_irq(devpath, &hint, tmp_irqs); ++ /* If build_irq is valid, only add irq when it's number equals to build_irq */ ++ if ((build_irq < 0) || (irqnum == build_irq)) { ++ hint.irq = irqnum; ++ hint.type = IRQ_TYPE_LEGACY; ++ add_new_irq(devpath, &hint, tmp_irqs); ++ } + } + + done: +@@ -712,31 +719,60 @@ static void free_tmp_irqs(gpointer data) + free(info); + } + +-void rebuild_irq_db(void) ++static struct irq_info * build_dev_irqs(GList *tmp_irqs, int build_irq) + { + DIR *devdir; + struct dirent *entry; +- GList *tmp_irqs = NULL; +- +- free_irq_db(); +- +- tmp_irqs = collect_full_irq_list(); ++ struct irq_info *new_irq = NULL; + + devdir = opendir(SYSPCI_DIR); +- + if (devdir) { + do { + entry = readdir(devdir); +- + if (!entry) + break; +- +- build_one_dev_entry(entry->d_name, tmp_irqs); +- ++ /* when hotplug irqs, we add one irq at one time */ ++ build_one_dev_entry(entry->d_name, tmp_irqs, build_irq); ++ if (build_irq >= 0) { ++ new_irq = get_irq_info(build_irq); ++ if (new_irq) ++ break; ++ } + } while (entry != NULL); +- + closedir(devdir); + } ++ return new_irq; ++} ++ ++int proc_irq_hotplug(char *savedline, int irq, struct irq_info **pinfo) ++{ ++ struct irq_info tmp_info = {0}; ++ ++ /* firstly, init irq info by read device info */ ++ *pinfo = build_dev_irqs(interrupts_db, irq); ++ if (*pinfo == NULL) { ++ /* secondly, init irq info by parse savedline */ ++ init_irq_class_and_type(savedline, &tmp_info, irq); ++ add_new_irq(NULL, &tmp_info, interrupts_db); ++ *pinfo = get_irq_info(irq); ++ } ++ if (*pinfo == NULL) { ++ return -1; ++ } ++ ++ force_rebalance_irq(*pinfo, NULL); ++ return 0; ++} ++ ++void rebuild_irq_db(void) ++{ ++ GList *tmp_irqs = NULL; ++ ++ free_irq_db(); ++ ++ tmp_irqs = collect_full_irq_list(); ++ ++ build_dev_irqs(tmp_irqs, -1); + + for_each_irq(tmp_irqs, add_missing_irq, interrupts_db); + +diff --git a/irqbalance.c b/irqbalance.c +index eaa0ce1..9baa955 100644 +--- a/irqbalance.c ++++ b/irqbalance.c +@@ -249,7 +249,7 @@ 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; +diff --git a/irqbalance.h b/irqbalance.h +index acf0ed5..d8e80a9 100644 +--- a/irqbalance.h ++++ b/irqbalance.h +@@ -40,8 +40,11 @@ extern GList* collect_full_irq_list(); + extern void parse_proc_stat(void); + extern void set_interrupt_count(int number, uint64_t count); + extern void set_msi_interrupt_numa(int number); ++extern void init_irq_class_and_type(char *savedline, struct irq_info *info, int irq); ++extern int proc_irq_hotplug(char *line, int irq, struct irq_info **pinfo); + + extern GList *rebalance_irq_list; ++extern void force_rebalance_irq(struct irq_info *info, void *data __attribute__((unused))); + + void update_migration_status(void); + void dump_workloads(void); +@@ -52,7 +55,6 @@ void dump_tree(void); + void activate_mappings(void); + void clear_cpu_tree(void); + void free_cpu_topo(gpointer data); +- + /*===================NEW BALANCER FUNCTIONS============================*/ + + /* +diff --git a/procinterrupts.c b/procinterrupts.c +index 858b66b..0671be0 100644 +--- a/procinterrupts.c ++++ b/procinterrupts.c +@@ -145,16 +145,59 @@ static void guess_arm_irq_hints(char *name, struct irq_info *info) + } + #endif + ++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 ++ 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->numa_node = get_numa_node(0); ++ info->name = strdup(irq_mod); ++} ++ + GList* collect_full_irq_list() + { + GList *tmp_list = NULL; + 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,44 +233,12 @@ 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; + number = strtoul(line, NULL, 10); + + info = calloc(1, sizeof(struct irq_info)); + 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); +@@ -238,11 +248,13 @@ GList* collect_full_irq_list() + return tmp_list; + } + ++ + void parse_proc_interrupts(void) + { + FILE *file; + char *line = NULL; + size_t size = 0; ++ int ret; + + file = fopen("/proc/interrupts", "r"); + if (!file) +@@ -261,6 +273,7 @@ void parse_proc_interrupts(void) + uint64_t count; + char *c, *c2; + struct irq_info *info; ++ char *savedline = NULL; + + if (getline(&line, &size, file)<=0) + break; +@@ -280,15 +293,24 @@ void parse_proc_interrupts(void) + if (!c) + continue; + ++ savedline = strdup(line); ++ if (!savedline) ++ break; + *c = 0; + c++; + number = strtoul(line, NULL, 10); + + info = get_irq_info(number); + if (!info) { +- need_rescan = 1; +- break; ++ ret = proc_irq_hotplug(savedline, number, &info); ++ if (ret < 0) { ++ /* hotplug fail, need to rescan */ ++ need_rescan = 1; ++ free(savedline); ++ break; ++ } + } ++ free(savedline); + + count = 0; + cpunr = 0; +@@ -316,7 +338,7 @@ void parse_proc_interrupts(void) + break; + } + +- info->last_irq_count = info->irq_count; ++ info->last_irq_count = info->irq_count; + info->irq_count = count; + + /* is interrupt MSI based? */ +-- +2.23.0 + diff --git a/backport-log-correctly-for-isolated-and-nohz_full-cpus.patch b/backport-log-correctly-for-isolated-and-nohz_full-cpus.patch new file mode 100644 index 0000000..4dc95b9 --- /dev/null +++ b/backport-log-correctly-for-isolated-and-nohz_full-cpus.patch @@ -0,0 +1,57 @@ +From 6fe032945b69d8f382fa3e8de8e4fdce84063199 Mon Sep 17 00:00:00 2001 +From: Yunfeng Ye +Date: Fri, 20 Nov 2020 00:15:58 +0800 +Subject: [PATCH] log correctly for isolated and nohz_full cpus + +When the banded CPU is configured, and the "isolcpus" or "nohz_full" +is configured, the log for isolated and nohz CPUs are not correct. + +So only log relevant infomation when isolcpus and nohz_full has been +handled, also put the cpus_clear() closer. + +Conflict:NA +Reference:https://github.com/Irqbalance/irqbalance/commit/6fe032945b69d8f382fa3e8de8e4fdce84063199 +--- + cputree.c | 8 ++++---- + 1 file changed, 4 insertions(+), 4 deletions(-) + +diff --git a/cputree.c b/cputree.c +index 80a6d9d..eed20db 100644 +--- a/cputree.c ++++ b/cputree.c +@@ -112,9 +112,6 @@ static void setup_banned_cpus(void) + cpumask_t isolated_cpus; + char *env = NULL; + +- cpus_clear(isolated_cpus); +- cpus_clear(nohz_full); +- + /* A manually specified cpumask overrides auto-detection. */ + if (cpu_ban_string != NULL && banned_cpumask_from_ui != NULL) { + cpulist_parse(banned_cpumask_from_ui, +@@ -133,6 +130,9 @@ static void setup_banned_cpus(void) + goto out; + } + ++ cpus_clear(isolated_cpus); ++ cpus_clear(nohz_full); ++ + path = "/sys/devices/system/cpu/isolated"; + process_one_line(path, get_mask_from_cpulist, &isolated_cpus); + +@@ -141,11 +141,11 @@ static void setup_banned_cpus(void) + + cpus_or(banned_cpus, nohz_full, isolated_cpus); + +-out: + cpumask_scnprintf(buffer, 4096, isolated_cpus); + log(TO_CONSOLE, LOG_INFO, "Isolated CPUs: %s\n", buffer); + cpumask_scnprintf(buffer, 4096, nohz_full); + log(TO_CONSOLE, LOG_INFO, "Adaptive-ticks CPUs: %s\n", buffer); ++out: + cpumask_scnprintf(buffer, 4096, banned_cpus); + log(TO_CONSOLE, LOG_INFO, "Banned CPUs: %s\n", buffer); + } +-- +2.23.0 + diff --git a/feature-aarch64-add-the-regular-to-get-the-correct-i.patch b/feature-aarch64-add-the-regular-to-get-the-correct-i.patch new file mode 100644 index 0000000..6cbd886 --- /dev/null +++ b/feature-aarch64-add-the-regular-to-get-the-correct-i.patch @@ -0,0 +1,93 @@ +From c924f1df705a301a0ffc01fce4c7712756c8b1d2 Mon Sep 17 00:00:00 2001 +From: Zengruan Ye +Date: Sat, 13 Jul 2019 19:09:09 +0800 +Subject: [PATCH] feature: aarch64: add the regular to get the correct irq + class on hisi board + +First, get the full irq desc name, include that the name split by blank, just like +(hisi_sas_v2_hw sata). We use the irq type to mark the begin of the name. + +Second, for hisi bord, we consider to match the IRQ_SCSI class (which the +irqbalance service concerned, and the eth device match follow the +open community rule) by keywords group hisi & sas or hisi & sata. + +Signed-off-by: wanghaibin +--- + procinterrupts.c | 33 ++++++++++++++++++++++++++++++++- + 1 file changed, 32 insertions(+), 1 deletion(-) + +diff --git a/procinterrupts.c b/procinterrupts.c +index 854282f..32c5e53 100644 +--- a/procinterrupts.c ++++ b/procinterrupts.c +@@ -108,6 +108,8 @@ static void guess_arm_irq_hints(char *name, struct irq_info *info) + /* Note: Last entry is a catchall */ + static struct irq_match matches[] = { + { "eth.*" ,{NULL} ,NULL, IRQ_TYPE_LEGACY, IRQ_GBETH }, ++ { "hisi\\w*? *sas" ,{NULL} ,NULL, IRQ_TYPE_LEGACY, IRQ_SCSI}, ++ { "hisi\\w*? *sata" ,{NULL} ,NULL, IRQ_TYPE_LEGACY, IRQ_SCSI}, + { "[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}, +@@ -155,6 +157,8 @@ void init_irq_class_and_type(char *savedline, struct irq_info *info, int irq) + int is_xen_dyn = 0; + #ifdef AARCH64 + char *tmp = NULL; ++ int irq_fullname_valid = 1; ++ char irq_fullname[PATH_MAX] = {0}; + #endif + + irq_name = strtok_r(savedline, " ", &savedptr); +@@ -166,6 +170,16 @@ void init_irq_class_and_type(char *savedline, struct irq_info *info, int irq) + if (strstr(irq_name, "xen-dyn") != NULL) + is_xen_dyn = 1; + last_token = p; ++ ++#ifdef AARCH64 ++ /* ++ * /proc/interrupts format defined, after of interrupt type ++ * the reset string is mark the irq desc name. ++ */ ++ if (strncmp(irq_name, "Level", strlen("Level")) == 0 || ++ strncmp(irq_name, "Edge", strlen("Edge")) == 0) ++ break; ++#endif + } + + #ifdef AARCH64 +@@ -173,6 +187,17 @@ void init_irq_class_and_type(char *savedline, struct irq_info *info, int irq) + tmp = strchr(irq_name, '\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; +@@ -182,7 +207,13 @@ void init_irq_class_and_type(char *savedline, struct irq_info *info, int irq) + info->class = IRQ_VIRT_EVENT; + } else { + #ifdef AARCH64 +- 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.23.0 + diff --git a/feature-add-ability-to-set-hintpolicy-during-runtime.patch b/feature-add-ability-to-set-hintpolicy-during-runtime.patch new file mode 100644 index 0000000..318e12e --- /dev/null +++ b/feature-add-ability-to-set-hintpolicy-during-runtime.patch @@ -0,0 +1,34 @@ +From 7db6af3a25c9742febce616081a723e1c92889d1 Mon Sep 17 00:00:00 2001 +From: BiaoXiang Ye +Date: Wed, 1 Jul 2020 12:05:33 +0800 +Subject: [PATCH] feature: add ability to set hintpolicy during runtime + +irqbalance adds default config --hintpolicy=subset, so we need provide the ability to set +hintpolicy back to ignore during runtime. +--- + irqbalance.c | 9 +++++++++ + 1 file changed, 9 insertions(+) + +diff --git a/irqbalance.c b/irqbalance.c +index 859fd6a..ffbb191 100644 +--- a/irqbalance.c ++++ b/irqbalance.c +@@ -538,6 +538,15 @@ gboolean sock_handle(gint fd, GIOCondition condition, gpointer user_data __attri + cpu_ban_string = NULL; + } + need_rescan = 1; ++ } else if (!(strncmp(buff + strlen("settings "), "hintpolicy ", ++ strlen("hintpolicy ")))) { ++ if (!(strncmp(buff + strlen("settings hintpolicy "), "ignore", ++ strlen("ignore")))) { ++ hint_enabled = 0; ++ } else if (!(strncmp(buff + strlen("settings hintpolicy "), ++ "subset", strlen("subset")))) { ++ hint_enabled = 1; ++ } + } + } + if (!strncmp(buff, "setup", strlen("setup"))) { +-- +2.23.0 + diff --git a/feature-add-new-irq-migrate-rule-to-avoid-high-cpu-i.patch b/feature-add-new-irq-migrate-rule-to-avoid-high-cpu-i.patch new file mode 100644 index 0000000..ae40242 --- /dev/null +++ b/feature-add-new-irq-migrate-rule-to-avoid-high-cpu-i.patch @@ -0,0 +1,89 @@ +From 84a2df1c9962a87f55e1c0d3bd2118fd754a4b48 Mon Sep 17 00:00:00 2001 +From: hejingxian +Date: Fri, 3 Jan 2020 16:43:28 +0800 +Subject: [PATCH] feature: add new irq migrate rule to avoid high cpu irq load + +By the old irq migrate rule, the irqs cannot be moved if the adjustment_load will become smaller then +the min_load after moving irq. However, we can accept that the delta load become smaller after moving irq. +--- + irqbalance.c | 8 +++++++- + irqbalance.h | 1 + + irqlist.c | 3 ++- + 3 files changed, 10 insertions(+), 2 deletions(-) + +diff --git a/irqbalance.c b/irqbalance.c +index 9449e40..82ac3ea 100644 +--- a/irqbalance.c ++++ b/irqbalance.c +@@ -72,6 +72,7 @@ GMainLoop *main_loop; + char *cpu_ban_string = NULL; + char *banned_cpumask_from_ui = NULL; + unsigned long migrate_ratio = 0; ++unsigned long load_limit = 0; + + static void sleep_approx(int seconds) + { +@@ -106,6 +107,7 @@ struct option lopts[] = { + {"hintpolicy", 1, NULL, 'h'}, + {"verifyhint", 1, NULL, 'v'}, + {"notclearhint", 0, NULL, 'n'}, ++ {"loadlimit", 1, NULL, 'g'}, + {0, 0, 0, 0} + }; + +@@ -115,6 +117,7 @@ static void usage(void) + log(TO_CONSOLE, LOG_INFO, " [--powerthresh= | -p | ] [--banirq= | -i ] [--banmod= | -m ] [--policyscript= | -l