Package init
This commit is contained in:
parent
72868d0397
commit
ad917abf90
43
bugfix-delete-no-existing-banned-irq.patch
Normal file
43
bugfix-delete-no-existing-banned-irq.patch
Normal file
@ -0,0 +1,43 @@
|
||||
From 0d6ed42e5d195f6a00d2f000ce8da11e89cb3010 Mon Sep 17 00:00:00 2001
|
||||
From: caihongda <caihongda@huawei.com>
|
||||
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 <caihongda@huawei.com>
|
||||
|
||||
diff --git a/classify.c b/classify.c
|
||||
index 9f72ae8..585f2dc 100644
|
||||
--- a/classify.c
|
||||
+++ b/classify.c
|
||||
@@ -331,6 +331,13 @@ static int is_banned_irq(int irq)
|
||||
return entry ? 1:0;
|
||||
}
|
||||
|
||||
+#ifdef TEST
|
||||
+int stub_is_banned_irq(int irq)
|
||||
+{
|
||||
+ return is_banned_irq(irq);
|
||||
+}
|
||||
+#endif
|
||||
+
|
||||
gint substr_find(gconstpointer a, gconstpointer b)
|
||||
{
|
||||
if (strstr(b, a))
|
||||
@@ -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
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
From 2c040ddc5869635598e4fbf5c63217f60fdef5f1 Mon Sep 17 00:00:00 2001
|
||||
From: xiashuang <xiashuang1@huawei.com>
|
||||
Date: Sun, 17 Mar 2019 18:59:09 -0400
|
||||
Subject: [PATCH 2/4] huawei bugfix fix a hole that flees hotplug event
|
||||
Subject: [PATCH 2/4] bugfix fix a hole that flees hotplug event
|
||||
|
||||
from 1.0.9, original infoformation is missing
|
||||
---
|
||||
|
||||
@ -0,0 +1,34 @@
|
||||
From f3c1502c83f5ae09202a707669c924fc2bd0cca4 Mon Sep 17 00:00:00 2001
|
||||
From: liuchao173 <liuchao173@huawei.com>
|
||||
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
|
||||
|
||||
161
bugfix-fix-new-irqs-in-hotplug-keep-stay-on-one-numa.patch
Normal file
161
bugfix-fix-new-irqs-in-hotplug-keep-stay-on-one-numa.patch
Normal file
@ -0,0 +1,161 @@
|
||||
From feeb95206e1f178e2bbf0393483861f364bd7d5b Mon Sep 17 00:00:00 2001
|
||||
From: liuchao173 <liuchao173@huawei.com>
|
||||
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;
|
||||
GList *vm_banned_irqs = NULL;
|
||||
+extern int need_add_single;
|
||||
|
||||
pthread_mutex_t cl_banned_list_mutex = PTHREAD_MUTEX_INITIALIZER;
|
||||
pthread_mutex_t vm_banned_list_mutex = PTHREAD_MUTEX_INITIALIZER;
|
||||
@@ -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
|
||||
|
||||
@ -0,0 +1,25 @@
|
||||
From d4fc2426a38728b912ec1acf3a3a990636e48b1d Mon Sep 17 00:00:00 2001
|
||||
From: liuchao173 <liuchao173@huawei.com>
|
||||
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
|
||||
|
||||
@ -0,0 +1,79 @@
|
||||
From f04d6488c12e215e2302b44c77bf66fce4950aef Mon Sep 17 00:00:00 2001
|
||||
From: liuchao <liuchao173@huawei.com>
|
||||
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 <liuchao173@huawei.com>
|
||||
---
|
||||
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
|
||||
|
||||
@ -1,81 +0,0 @@
|
||||
From 384cdfa4ef28415c3df50d1759951a20c6f0661f Mon Sep 17 00:00:00 2001
|
||||
From: caomeng <caomeng5@huawei.com>
|
||||
Date: Thu, 4 Jul 2019 03:47:20 +0800
|
||||
Subject: [PATCH] bugfix-fix-two-same-irq-insert-to-list
|
||||
|
||||
When the function force_rebalance_irq is executed,the same irq may be added into
|
||||
rebalance_irq_list again, resulting in failed irqbalance service. Thus, a function
|
||||
named irq_in_rebalance_list which is used to check if the irq is in rebalance_irq_list
|
||||
will be executed before force_rebalance_irq. And this patch fixex the bug introduced
|
||||
by feature-introduce-verifyhint-to-detect-hint-variation.patch.
|
||||
|
||||
---
|
||||
classify.c | 11 +++++++++++
|
||||
irqbalance.h | 2 +-
|
||||
procinterrupts.c | 8 ++++++--
|
||||
3 files changed, 18 insertions(+), 3 deletions(-)
|
||||
|
||||
diff --git a/classify.c b/classify.c
|
||||
index 0951c72..4d699da 100644
|
||||
--- a/classify.c
|
||||
+++ b/classify.c
|
||||
@@ -288,6 +288,17 @@ static void add_banned_irq(int irq, GList **list)
|
||||
return;
|
||||
}
|
||||
|
||||
+int irq_in_rebalance_list(int irq)
|
||||
+{
|
||||
+ GList *entry = NULL;
|
||||
+ struct irq_info find = {0};
|
||||
+
|
||||
+ find.irq = irq;
|
||||
+ entry = g_list_find_custom(rebalance_irq_list, &find, compare_ints);
|
||||
+
|
||||
+ return entry ? 1 : 0;
|
||||
+}
|
||||
+
|
||||
void add_cl_banned_irq(int irq)
|
||||
{
|
||||
add_banned_irq(irq, &cl_banned_irqs);
|
||||
diff --git a/irqbalance.h b/irqbalance.h
|
||||
index 80ec017..821de0e 100644
|
||||
--- a/irqbalance.h
|
||||
+++ b/irqbalance.h
|
||||
@@ -107,7 +107,7 @@ extern void free_cl_opts(void);
|
||||
extern void add_cl_banned_module(char *modname);
|
||||
#define irq_numa_node(irq) ((irq)->numa_node)
|
||||
extern void force_rebalance_irq(struct irq_info *info, void *data __attribute__((unused)));
|
||||
-
|
||||
+int irq_in_rebalance_list(int irq);
|
||||
/* huawei */
|
||||
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);
|
||||
diff --git a/procinterrupts.c b/procinterrupts.c
|
||||
index fc4641a..9e38e49 100644
|
||||
--- a/procinterrupts.c
|
||||
+++ b/procinterrupts.c
|
||||
@@ -348,7 +348,9 @@ void parse_proc_interrupts(void)
|
||||
*/
|
||||
if (count < info->irq_count) {
|
||||
log(TO_CONSOLE, LOG_INFO, "Removed and reinserted IRQ %d added into rebalance list\n", number);
|
||||
- force_rebalance_irq(info, NULL);
|
||||
+ if (!irq_in_rebalance_list(info->irq)) {
|
||||
+ force_rebalance_irq(info, NULL);
|
||||
+ }
|
||||
}
|
||||
|
||||
info->last_irq_count = info->irq_count;
|
||||
@@ -602,7 +604,9 @@ void update_affinity_hint(struct irq_info *info, void *data __attribute__((unuse
|
||||
cpumask_parse_user(line, len, current_affinity_hint);
|
||||
if (!cpus_equal(current_affinity_hint, info->affinity_hint)) {
|
||||
cpumask_copy(info->affinity_hint, current_affinity_hint);
|
||||
- force_rebalance_irq(info, data);
|
||||
+ if (!irq_in_rebalance_list(info->irq)) {
|
||||
+ force_rebalance_irq(info, data);
|
||||
+ }
|
||||
log(TO_ALL, LOG_INFO, "IRQ(%d): affinity hint modified\n", info->irq);
|
||||
}
|
||||
}
|
||||
--
|
||||
1.8.3.1
|
||||
|
||||
@ -244,11 +244,10 @@ diff --git a/irqbalance.h b/irqbalance.h
|
||||
index 8d5b329..73737ed 100644
|
||||
--- a/irqbalance.h
|
||||
+++ b/irqbalance.h
|
||||
@@ -107,6 +107,11 @@ extern void free_cl_opts(void);
|
||||
@@ -107,6 +107,10 @@ extern void free_cl_opts(void);
|
||||
extern void add_cl_banned_module(char *modname);
|
||||
#define irq_numa_node(irq) ((irq)->numa_node)
|
||||
|
||||
+/* huawei */
|
||||
+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);
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
From d57caa98c082fb3bf746b0877aa368544e8e62dc Mon Sep 17 00:00:00 2001
|
||||
From: Zengruan Ye <yezengruan@huawei.com>
|
||||
Date: Mon, 15 Jul 2019 21:37:39 +0800
|
||||
Subject: [PATCH 4/6] bugfix: irqbalance: fix wrong pid value in pid file
|
||||
From 948425c293615a9f4a30e9049d6ca4380c7b6c83 Mon Sep 17 00:00:00 2001
|
||||
From: hejingxian <hejingxian@huawei.com>
|
||||
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
|
||||
@ -13,14 +13,14 @@ been launched.
|
||||
|
||||
Signed-off-by: zhanghailiang <zhang.zhanghailiang@huawei.com>
|
||||
---
|
||||
irqbalance.c | 81 ++++++++++++++++++++++++++++++++++++++++++++++++++++++------
|
||||
1 file changed, 73 insertions(+), 8 deletions(-)
|
||||
irqbalance.c | 83 ++++++++++++++++++++++++++++++++++++++++++++++++++++++------
|
||||
1 file changed, 75 insertions(+), 8 deletions(-)
|
||||
|
||||
diff --git a/irqbalance.c b/irqbalance.c
|
||||
index 40ec65c..27cf2eb 100644
|
||||
index 18cd7de..467e968 100644
|
||||
--- a/irqbalance.c
|
||||
+++ b/irqbalance.c
|
||||
@@ -584,6 +584,77 @@ int init_socket()
|
||||
@@ -560,6 +560,78 @@ int init_socket()
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -94,11 +94,12 @@ index 40ec65c..27cf2eb 100644
|
||||
+ close(lf);
|
||||
+ return err;
|
||||
+}
|
||||
+
|
||||
+
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
struct sigaction action, hupaction;
|
||||
@@ -709,17 +782,12 @@ int main(int argc, char** argv)
|
||||
sigset_t sigset, old_sigset;
|
||||
@@ -652,17 +724,12 @@ int main(int argc, char** argv)
|
||||
}
|
||||
|
||||
if (!foreground_mode) {
|
||||
|
||||
@ -9,14 +9,14 @@ for every irq.
|
||||
---
|
||||
Makefile.am | 2 +-
|
||||
classify.c | 32 +++++++--
|
||||
irqbalance.c | 31 +++++----
|
||||
irqbalance.c | 34 +++++----
|
||||
irqbalance.h | 2 +-
|
||||
misc/irqbalance.service | 2 +-
|
||||
placement.c | 3 +-
|
||||
procinterrupts.c | 3 +-
|
||||
rules_config.c | 170 ++++++++++++++++++++++++++++++++++++++++++++++++
|
||||
rules_config.h | 38 +++++++++++
|
||||
9 files changed, 260 insertions(+), 23 deletions(-)
|
||||
9 files changed, 263 insertions(+), 23 deletions(-)
|
||||
create mode 100644 rules_config.c
|
||||
create mode 100644 rules_config.h
|
||||
|
||||
@ -117,35 +117,35 @@ diff --git a/irqbalance.c b/irqbalance.c
|
||||
index 21d578a..d41753c 100644
|
||||
--- a/irqbalance.c
|
||||
+++ b/irqbalance.c
|
||||
@@ -148,6 +148,7 @@ struct option lopts[] = {
|
||||
@@ -99,6 +99,7 @@ struct option lopts[] = {
|
||||
{"banmod", 1 , NULL, 'm'},
|
||||
{"interval", 1 , NULL, 't'},
|
||||
{"version", 0, NULL, 'V'},
|
||||
{"verifyhint", 1, NULL, 'v'},
|
||||
+ {"rulesconfig", 1, NULL, 'r'},
|
||||
{0, 0, 0, 0}
|
||||
};
|
||||
|
||||
@@ -155,7 +156,7 @@ static void usage(void)
|
||||
@@ -106,7 +107,7 @@ static void usage(void)
|
||||
{
|
||||
log(TO_CONSOLE, LOG_INFO, "irqbalance [--oneshot | -o] [--debug | -d] [--foreground | -f] [--journal | -j] [--hintpolicy | -h <subset>]\n");
|
||||
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 <off> | <n>] [--banirq= | -i <n>] [--banmod= | -m <module>] [--policyscript= | -l <script>]\n");
|
||||
- log(TO_CONSOLE, LOG_INFO, " [--pid= | -s <file>] [--deepestcache= | -c <n>] [--interval= | -t <n>] [--verifyhint= | -v n]\n");
|
||||
+ log(TO_CONSOLE, LOG_INFO, " [--pid= | -s <file>] [--deepestcache= | -c <n>] [--interval= | -t <n>] [--verifyhint= | -v n] [--rulesconfig= | -r <config>]\n");
|
||||
- log(TO_CONSOLE, LOG_INFO, " [--pid= | -s <file>] [--deepestcache= | -c <n>] [--interval= | -t <n>]\n");
|
||||
+ log(TO_CONSOLE, LOG_INFO, " [--pid= | -s <file>] [--deepestcache= | -c <n>] [--interval= | -t <n>] [--rulesconfig= | -r <config>]\n");
|
||||
}
|
||||
|
||||
static void version(void)
|
||||
@@ -170,7 +171,7 @@ static void parse_command_line(int argc, char **argv)
|
||||
@@ -121,7 +122,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:",
|
||||
+ "odfji:p:s:c:b:l:m:t:V:h:v:r:",
|
||||
- "odfji:p:s:c:b:l:m:t:V",
|
||||
+ "odfji:p:s:c:b:l:m:t:V:r",
|
||||
lopts, &longind)) != -1) {
|
||||
|
||||
switch(opt) {
|
||||
@@ -268,6 +269,9 @@ static void parse_command_line(int argc, char **argv)
|
||||
@@ -201,6 +202,9 @@ static void parse_command_line(int argc, char **argv)
|
||||
exit(1);
|
||||
}
|
||||
reset_verify_countdown();
|
||||
break;
|
||||
+ case 'r':
|
||||
+ rules_config_file = strdup(optarg);
|
||||
@ -153,10 +153,10 @@ index 21d578a..d41753c 100644
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -586,6 +590,22 @@ int main(int argc, char** argv)
|
||||
@@ -539,6 +543,21 @@ int main(int argc, char** argv)
|
||||
log(TO_ALL, LOG_WARNING, "Unable to determin HZ defaulting to 100\n");
|
||||
HZ = 100;
|
||||
}
|
||||
|
||||
+ if (!foreground_mode) {
|
||||
+ if (daemon(0,0)) {
|
||||
+ ret = EXIT_FAILURE;
|
||||
@ -172,11 +172,10 @@ index 21d578a..d41753c 100644
|
||||
+ if (read_user_policy_config() != 0) {
|
||||
+ log(TO_ALL, LOG_WARNING, "Read user policy config fail.\n");
|
||||
+ }
|
||||
+
|
||||
|
||||
build_object_tree();
|
||||
if (debug_mode)
|
||||
dump_object_tree();
|
||||
@@ -600,15 +617,6 @@ int main(int argc, char** argv)
|
||||
@@ -554,16 +573,6 @@ int main(int argc, char** argv)
|
||||
goto out;
|
||||
}
|
||||
|
||||
@ -189,18 +188,18 @@ index 21d578a..d41753c 100644
|
||||
- goto out;
|
||||
- }
|
||||
- }
|
||||
|
||||
action.sa_handler = handler;
|
||||
sigemptyset(&action.sa_mask);
|
||||
@@ -640,7 +649,7 @@ int main(int argc, char** argv)
|
||||
ret = EXIT_FAILURE;
|
||||
-
|
||||
g_unix_signal_add(SIGINT, handler, NULL);
|
||||
g_unix_signal_add(SIGTERM, handler, NULL);
|
||||
g_unix_signal_add(SIGUSR1, handler, NULL);
|
||||
@@ -589,6 +598,7 @@ int main(int argc, char** argv)
|
||||
goto out;
|
||||
}
|
||||
-
|
||||
+ log(TO_ALL, LOG_INFO, "irqbalance start scan.\n");
|
||||
while (keep_going) {
|
||||
cond_sleep();
|
||||
|
||||
+ log(TO_ALL, LOG_INFO, "irqbalance start scan.\n");
|
||||
main_loop = g_main_loop_new(NULL, FALSE);
|
||||
int *last_interval = &sleep_interval;
|
||||
g_timeout_add_seconds(sleep_interval, scan, last_interval);
|
||||
diff --git a/irqbalance.h b/irqbalance.h
|
||||
index 120bc9b..42f95cb 100644
|
||||
--- a/irqbalance.h
|
||||
|
||||
123
feature-add-switch-to-clear-affinity-hint.patch
Normal file
123
feature-add-switch-to-clear-affinity-hint.patch
Normal file
@ -0,0 +1,123 @@
|
||||
From e44eed4faef6ee1bd1ae41dd27a8513d37681f7f Mon Sep 17 00:00:00 2001
|
||||
From: liuchao <liuchao173@huawei.com>
|
||||
Date: Tue, 17 Dec 2019 02:54:57 +0000
|
||||
Subject: [PATCH] add switch to clear affinity hint
|
||||
|
||||
All irqs' affinity hints are cleared in update_affinity_hint and forced
|
||||
to rebalance. In some scenarios, it will affect performance.
|
||||
---
|
||||
hint_verify.c | 26 +++++++++++++++++++++++++-
|
||||
irqbalance.c | 10 ++++++++--
|
||||
2 files changed, 33 insertions(+), 3 deletions(-)
|
||||
|
||||
diff --git a/hint_verify.c b/hint_verify.c
|
||||
index 0718078..11ef868 100644
|
||||
--- a/hint_verify.c
|
||||
+++ b/hint_verify.c
|
||||
@@ -16,6 +16,7 @@ extern int keep_going;
|
||||
extern GMainLoop *main_loop;
|
||||
extern gboolean scan();
|
||||
extern int last_interval;
|
||||
+extern int clear_affinity_hint;
|
||||
|
||||
int real_sleep_interval;
|
||||
int sleep_interval_count;
|
||||
@@ -57,7 +58,8 @@ void update_affinity_hint(struct irq_info *info, void *data __attribute__((unuse
|
||||
if (!hint_enabled)
|
||||
return;
|
||||
|
||||
- cpus_clear(info->affinity_hint);
|
||||
+ if (clear_affinity_hint)
|
||||
+ cpus_clear(info->affinity_hint);
|
||||
sprintf(path, "/proc/irq/%d/affinity_hint", info->irq);
|
||||
file = fopen(path, "r");
|
||||
if (!file)
|
||||
@@ -80,6 +82,27 @@ void update_affinity_hint(struct irq_info *info, void *data __attribute__((unuse
|
||||
free(line);
|
||||
}
|
||||
|
||||
+static void check_clear()
|
||||
+{
|
||||
+ char *line = NULL;
|
||||
+ size_t size = 0;
|
||||
+ FILE *file;
|
||||
+
|
||||
+ file = fopen("/etc/sysconfig/irqbalance_clear", "r");
|
||||
+ if (!file)
|
||||
+ return;
|
||||
+ if (getline(&line, &size, file) <= 0)
|
||||
+ goto out;
|
||||
+ if (line != NULL && strstr(line, "0") != NULL)
|
||||
+ clear_affinity_hint = 0;
|
||||
+ else
|
||||
+ clear_affinity_hint = 1;
|
||||
+
|
||||
+out:
|
||||
+ fclose(file);
|
||||
+ free(line);
|
||||
+}
|
||||
+
|
||||
/*
|
||||
* This function is the main loop of irqbalance, which include:
|
||||
* 1. scan opration for irq balancing;
|
||||
@@ -104,6 +127,7 @@ gboolean poll_hint_affinity_and_scan(gpointer data __attribute__((unused)))
|
||||
sleep_count++;
|
||||
|
||||
if (need_verify_flag && hint_changed()) {
|
||||
+ check_clear();
|
||||
for_each_irq(NULL, update_affinity_hint, NULL);
|
||||
if (hint_has_changed) {
|
||||
hint_has_changed = FALSE;
|
||||
diff --git a/irqbalance.c b/irqbalance.c
|
||||
index 05eaa29..77076fa 100644
|
||||
--- a/irqbalance.c
|
||||
+++ b/irqbalance.c
|
||||
@@ -55,6 +55,7 @@ int foreground_mode;
|
||||
int numa_avail;
|
||||
int journal_logging = 0;
|
||||
int need_rescan;
|
||||
+int clear_affinity_hint = 1;
|
||||
unsigned int log_mask = TO_ALL;
|
||||
const char *log_indent;
|
||||
unsigned long power_thresh = ULONG_MAX;
|
||||
@@ -104,14 +105,16 @@ struct option lopts[] = {
|
||||
{"version", 0, NULL, 'V'},
|
||||
{"verifyhint", 1, NULL, 'v'},
|
||||
{"rulesconfig", 1, NULL, 'r'},
|
||||
+ {"notclearhint", 0, NULL, 'n'},
|
||||
{0, 0, 0, 0}
|
||||
};
|
||||
|
||||
static void usage(void)
|
||||
{
|
||||
log(TO_CONSOLE, LOG_INFO, "irqbalance [--oneshot | -o] [--debug | -d] [--foreground | -f] [--journal | -j] [--hintpolicy | -h <subset>]\n");
|
||||
log(TO_CONSOLE, LOG_INFO, " [--powerthresh= | -p <off> | <n>] [--banirq= | -i <n>] [--banmod= | -m <module>] [--policyscript= | -l <script>]\n");
|
||||
- log(TO_CONSOLE, LOG_INFO, " [--pid= | -s <file>] [--deepestcache= | -c <n>] [--interval= | -t <n>] [--verifyhint= | -v n] [--rulesconfig= | -r <config>]\n");
|
||||
+ log(TO_CONSOLE, LOG_INFO, " [--pid= | -s <file>] [--deepestcache= | -c <n>] [--interval= | -t <n>] [--verifyhint= | -v n]\n");
|
||||
+ log(TO_CONSOLE, LOG_INFO, " [--rulesconfig= | -r <config>] [--notclearhint | -n]\n");
|
||||
}
|
||||
|
||||
static void version(void)
|
||||
@@ -126,7 +128,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:",
|
||||
+ "odfji:p:s:c:b:l:m:t:V:h:v:r:n",
|
||||
lopts, &longind)) != -1) {
|
||||
|
||||
switch(opt) {
|
||||
@@ -225,6 +227,10 @@ static void parse_command_line(int argc, char **argv)
|
||||
case 'r':
|
||||
rules_config_file = strdup(optarg);
|
||||
break;
|
||||
+ case 'n':
|
||||
+ clear_affinity_hint = 0;
|
||||
+ break;
|
||||
+
|
||||
}
|
||||
}
|
||||
}
|
||||
--
|
||||
2.19.1
|
||||
|
||||
@ -0,0 +1,79 @@
|
||||
From 6f90062816b218809dc5d1e06ac7e0f7198368d6 Mon Sep 17 00:00:00 2001
|
||||
From: hejingxian <hejingxian@huawei.com>
|
||||
Date: Sun, 10 Nov 2019 17:24:43 +0800
|
||||
Subject: [PATCH] Add test interfaces for irqbalance core functions
|
||||
|
||||
There exists some core functions which can't be called by llt. Therefore,
|
||||
we add external functions for user calling the core functions.
|
||||
---
|
||||
classify.c | 7 +++++++
|
||||
procinterrupts.c | 34 ++++++++++++++++++++++++++++++++++
|
||||
2 files changed, 41 insertions(+)
|
||||
|
||||
diff --git a/classify.c b/classify.c
|
||||
index 3921710..5aed9e5 100644
|
||||
--- a/classify.c
|
||||
+++ b/classify.c
|
||||
@@ -1068,3 +1068,10 @@ int is_pci_assigned_irq(const char *line)
|
||||
|
||||
return 0;
|
||||
}
|
||||
+
|
||||
+#ifdef TEST
|
||||
+void get_irq_user_policy_test(char *path, int irq, struct user_irq_policy *pol)
|
||||
+{
|
||||
+ get_irq_user_policy(path, irq, pol);
|
||||
+}
|
||||
+#endif
|
||||
diff --git a/procinterrupts.c b/procinterrupts.c
|
||||
index 59df6d7..cd99f35 100644
|
||||
--- a/procinterrupts.c
|
||||
+++ b/procinterrupts.c
|
||||
@@ -148,6 +148,18 @@ static void guess_arm_irq_hints(char *name, struct irq_info *info)
|
||||
|
||||
}
|
||||
|
||||
+#ifdef TEST
|
||||
+void guess_arm_irq_hints_test(char *name, struct irq_info *info)
|
||||
+{
|
||||
+ guess_arm_irq_hints(name, info);
|
||||
+}
|
||||
+
|
||||
+int check_platform_device_test(char *name, struct irq_info *info)
|
||||
+{
|
||||
+ return check_platform_device(name, info);
|
||||
+}
|
||||
+#endif
|
||||
+
|
||||
/*
|
||||
* This check is only invoked at service startup, and avoid any impact on the system,
|
||||
* The scheme just only reads the irq's aff, and write it back. According to the result
|
||||
@@ -674,3 +686,25 @@ void parse_proc_stat(void)
|
||||
for_each_object(numa_nodes, compute_irq_branch_load_share, NULL);
|
||||
|
||||
}
|
||||
+
|
||||
+#ifdef TEST
|
||||
+void init_irq_class_and_type_test(char *savedline, struct irq_info *info, int irq)
|
||||
+{
|
||||
+ init_irq_class_and_type(savedline, info, irq);
|
||||
+}
|
||||
+
|
||||
+void set_load_test(struct topo_obj *d, void *data __attribute__((unused)))
|
||||
+{
|
||||
+ set_load(d, data);
|
||||
+}
|
||||
+
|
||||
+void compute_irq_branch_load_share_test(struct topo_obj *d, void *data __attribute__((unused)))
|
||||
+{
|
||||
+ compute_irq_branch_load_share(d, data);
|
||||
+}
|
||||
+
|
||||
+void accumulate_interrupts_test(struct topo_obj *d, void *data __attribute__((unused)))
|
||||
+{
|
||||
+ accumulate_interrupts(d, data);
|
||||
+}
|
||||
+#endif
|
||||
--
|
||||
1.8.3.1
|
||||
|
||||
114
feature-add-the-switch-of-printing-log.patch
Normal file
114
feature-add-the-switch-of-printing-log.patch
Normal file
@ -0,0 +1,114 @@
|
||||
From b697a97436dafa13f0ae3febde299bfc20498f9d Mon Sep 17 00:00:00 2001
|
||||
From: liuchao173 <liuchao173@huawei.com>
|
||||
Date: Wed, 23 Oct 2019 11:42:26 +0000
|
||||
Subject: [PATCH] irqbalance: add the switch of printing log
|
||||
|
||||
add the switch of printing log
|
||||
---
|
||||
cputree.c | 16 ++++++++--------
|
||||
irqbalance.c | 25 +++++++++++++++++++++++++-
|
||||
2 files changed, 32 insertions(+), 9 deletions(-)
|
||||
|
||||
diff --git a/cputree.c b/cputree.c
|
||||
index 99f14d2..1465103 100644
|
||||
--- a/cputree.c
|
||||
+++ b/cputree.c
|
||||
@@ -432,23 +432,23 @@ static void dump_irq(struct irq_info *info, void *data)
|
||||
indent[i] = log_indent[0];
|
||||
|
||||
indent[i] = '\0';
|
||||
- log(TO_CONSOLE, LOG_INFO, "%sInterrupt %i node_num is %d (%s/%lu:%lu) \n", indent,
|
||||
+ log(TO_ALL, LOG_INFO, "%sInterrupt %i node_num is %d (%s/%lu:%lu) \n", indent,
|
||||
info->irq, irq_numa_node(info)->number, classes[info->class], info->load, (info->irq_count - info->last_irq_count));
|
||||
free(indent);
|
||||
}
|
||||
|
||||
static void dump_numa_node_num(struct topo_obj *p, void *data __attribute__((unused)))
|
||||
{
|
||||
- log(TO_CONSOLE, LOG_INFO, "%d ", p->number);
|
||||
+ log(TO_ALL, LOG_INFO, "%d ", p->number);
|
||||
}
|
||||
|
||||
static void dump_balance_obj(struct topo_obj *d, void *data __attribute__((unused)))
|
||||
{
|
||||
struct topo_obj *c = (struct topo_obj *)d;
|
||||
- log(TO_CONSOLE, LOG_INFO, "%s%s%s%sCPU number %i numa_node is ",
|
||||
+ log(TO_ALL, LOG_INFO, "%s%s%s%sCPU number %i numa_node is ",
|
||||
log_indent, log_indent, log_indent, log_indent, c->number);
|
||||
for_each_object(cpu_numa_node(c), dump_numa_node_num, NULL);
|
||||
- log(TO_CONSOLE, LOG_INFO, "(load %lu)\n", (unsigned long)c->load);
|
||||
+ log(TO_ALL, LOG_INFO, "(load %lu)\n", (unsigned long)c->load);
|
||||
if (c->interrupts)
|
||||
for_each_irq(c->interrupts, dump_irq, (void *)18);
|
||||
}
|
||||
@@ -457,10 +457,10 @@ static void dump_cache_domain(struct topo_obj *d, void *data)
|
||||
{
|
||||
char *buffer = data;
|
||||
cpumask_scnprintf(buffer, 4095, d->mask);
|
||||
- log(TO_CONSOLE, LOG_INFO, "%s%sCache domain %i: numa_node is ",
|
||||
+ log(TO_ALL, LOG_INFO, "%s%sCache domain %i: numa_node is ",
|
||||
log_indent, log_indent, d->number);
|
||||
for_each_object(d->numa_nodes, dump_numa_node_num, NULL);
|
||||
- log(TO_CONSOLE, LOG_INFO, "cpu mask is %s (load %lu) \n", buffer,
|
||||
+ log(TO_ALL, LOG_INFO, "cpu mask is %s (load %lu) \n", buffer,
|
||||
(unsigned long)d->load);
|
||||
if (d->children)
|
||||
for_each_object(d->children, dump_balance_obj, NULL);
|
||||
@@ -472,9 +472,9 @@ static void dump_package(struct topo_obj *d, void *data)
|
||||
{
|
||||
char *buffer = data;
|
||||
cpumask_scnprintf(buffer, 4096, d->mask);
|
||||
- log(TO_CONSOLE, LOG_INFO, "Package %i: numa_node ", d->number);
|
||||
+ log(TO_ALL, LOG_INFO, "Package %i: numa_node ", d->number);
|
||||
for_each_object(d->numa_nodes, dump_numa_node_num, NULL);
|
||||
- log(TO_CONSOLE, LOG_INFO, "cpu mask is %s (load %lu)\n",
|
||||
+ log(TO_ALL, LOG_INFO, "cpu mask is %s (load %lu)\n",
|
||||
buffer, (unsigned long)d->load);
|
||||
if (d->children)
|
||||
for_each_object(d->children, dump_cache_domain, buffer);
|
||||
diff --git a/irqbalance.c b/irqbalance.c
|
||||
index d41753c..7d8d15c 100644
|
||||
--- a/irqbalance.c
|
||||
+++ b/irqbalance.c
|
||||
@@ -273,6 +273,29 @@ gboolean force_rescan(gpointer data __attribute__((unused)))
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
+static int check_debug()
|
||||
+{
|
||||
+ char *line = NULL;
|
||||
+ size_t size = 0;
|
||||
+ FILE *file;
|
||||
+
|
||||
+ file = fopen("/etc/sysconfig/irqbalance_debug", "r");
|
||||
+ if (!file)
|
||||
+ return 0;
|
||||
+ if (getline(&line, &size, file) <= 0) {
|
||||
+ goto out;
|
||||
+ }
|
||||
+ if (line != NULL && strstr(line, "1") != NULL) {
|
||||
+ fclose(file);
|
||||
+ free(line);
|
||||
+ return 1;
|
||||
+ }
|
||||
+out:
|
||||
+ fclose(file);
|
||||
+ free(line);
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
gboolean scan(gpointer data)
|
||||
{
|
||||
log(TO_CONSOLE, LOG_INFO, "\n\n\n-----------------------------------------------------------------------------\n");
|
||||
@@ -305,7 +328,7 @@ gboolean scan(gpointer data)
|
||||
calculate_placement();
|
||||
activate_mappings();
|
||||
|
||||
- if (debug_mode)
|
||||
+ if (debug_mode || check_debug())
|
||||
dump_tree();
|
||||
if (one_shot_mode)
|
||||
keep_going = 0;
|
||||
--
|
||||
2.19.1
|
||||
|
||||
@ -1,26 +1,43 @@
|
||||
From 8541a67cdc3cbaf5c6ed04e9a3b3e2c3f584cb33 Mon Sep 17 00:00:00 2001
|
||||
From: xiahuang <xiashuang1@huawei.com>
|
||||
Date: Thu, 21 Mar 2019 19:08:17 -0400
|
||||
Subject: [PATCH 2/2]
|
||||
feature-introduce-verifyhint-to-detect-hint-variation
|
||||
From e5b83ac140634830b8f8d9ca8d40a1d9d16d2d5b Mon Sep 17 00:00:00 2001
|
||||
From: hejingxian <hejingxian@huawei.com>
|
||||
Date: Tue, 12 Nov 2019 15:29:16 +0800
|
||||
Subject: [PATCH] feature: introduce affinity hint verify to detect user hint variation
|
||||
|
||||
adapt by xiashuang xiashuang1@huawei.com when upgrade to 1.4.0
|
||||
In order to make the user affinity hint becomes effective quickly,
|
||||
introduce the periodically affinity hint verify.
|
||||
---
|
||||
activate.c | 24 +++++-----
|
||||
Makefile.am | 2 +-
|
||||
activate.c | 24 +++++------
|
||||
classify.c | 18 ++++++--
|
||||
cpumask.h | 7 +++
|
||||
irqbalance.c | 135 +++++++++++++++++++++++++++++++++++++++++++------------
|
||||
irqbalance.h | 5 +++
|
||||
hint_verify.c | 147 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||
hint_verify.h | 19 +++++++++
|
||||
irqbalance.c | 39 +++++++++++------
|
||||
irqbalance.h | 4 ++
|
||||
placement.c | 14 ++++++
|
||||
procinterrupts.c | 57 +++++++++++++++++++++++
|
||||
types.h | 1 +
|
||||
8 files changed, 217 insertions(+), 44 deletions(-)
|
||||
10 files changed, 246 insertions(+), 29 deletions(-)
|
||||
create mode 100644 hint_verify.c
|
||||
create mode 100644 hint_verify.h
|
||||
|
||||
diff --git a/Makefile.am b/Makefile.am
|
||||
index 9276bfb..5fac265 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 sockapi.c rules_config.c
|
||||
+ irqlist.c numa.c placement.c procinterrupts.c sockapi.c rules_config.c hint_verify.c
|
||||
irqbalance_LDADD = $(LIBCAP_NG_LIBS) $(GLIB2_LIBS) -lpthread
|
||||
if IRQBALANCEUI
|
||||
irqbalance_ui_SOURCES = $(UI_DIR)/helpers.c $(UI_DIR)/irqbalance-ui.c \
|
||||
diff --git a/activate.c b/activate.c
|
||||
index 8fd3dd0..1c4b867 100644
|
||||
index d9e1fc3..87336f4 100644
|
||||
--- a/activate.c
|
||||
+++ b/activate.c
|
||||
@@ -61,26 +61,26 @@ static void activate_mapping(struct irq_info *info, void *data __attribute__((un
|
||||
@@ -88,26 +88,26 @@ static void activate_mapping(struct irq_info *info, void *data __attribute__((un
|
||||
char buf[PATH_MAX];
|
||||
FILE *file;
|
||||
cpumask_t applied_mask;
|
||||
@ -60,10 +77,10 @@ index 8fd3dd0..1c4b867 100644
|
||||
|
||||
sprintf(buf, "/proc/irq/%i/smp_affinity", info->irq);
|
||||
diff --git a/classify.c b/classify.c
|
||||
index 30a8d2a..aa391f4 100644
|
||||
index 5aed9e5..75677f4 100644
|
||||
--- a/classify.c
|
||||
+++ b/classify.c
|
||||
@@ -66,8 +66,6 @@ struct pci_info {
|
||||
@@ -71,8 +71,6 @@ struct pci_info {
|
||||
#define PCI_SUB_DEVICE_EMC_0568 0x0568
|
||||
#define PCI_SUB_DEVICE_EMC_dd00 0xdd00
|
||||
|
||||
@ -72,7 +89,7 @@ index 30a8d2a..aa391f4 100644
|
||||
/*
|
||||
* Apply software workarounds for some special devices
|
||||
*
|
||||
@@ -414,7 +412,7 @@ get_numa_node:
|
||||
@@ -448,7 +446,7 @@ get_numa_node:
|
||||
fd = fopen(path, "r");
|
||||
if (!fd) {
|
||||
cpus_setall(new->cpumask);
|
||||
@ -81,7 +98,7 @@ index 30a8d2a..aa391f4 100644
|
||||
}
|
||||
lcpu_mask = NULL;
|
||||
ret = getline(&lcpu_mask, &blen, fd);
|
||||
@@ -426,6 +424,20 @@ get_numa_node:
|
||||
@@ -460,6 +458,20 @@ get_numa_node:
|
||||
}
|
||||
free(lcpu_mask);
|
||||
|
||||
@ -127,318 +144,42 @@ index 0774a88..8dd3703 100644
|
||||
#define cpus_equal(src1, src2) __cpus_equal(&(src1), &(src2), NR_CPUS)
|
||||
static inline int __cpus_equal(const cpumask_t *src1p,
|
||||
const cpumask_t *src2p, int nbits)
|
||||
diff --git a/irqbalance.c b/irqbalance.c
|
||||
index e375a1a..bf9a2e4 100644
|
||||
--- a/irqbalance.c
|
||||
+++ b/irqbalance.c
|
||||
@@ -61,10 +61,38 @@ char *banscript = NULL;
|
||||
char *polscript = NULL;
|
||||
long HZ;
|
||||
int sleep_interval = SLEEP_INTERVAL;
|
||||
-GMainLoop *main_loop;
|
||||
+int hint_enabled = 0;
|
||||
+int poll_hint_interval = SLEEP_INTERVAL / 5;
|
||||
+unsigned int next_verify, next_balance;
|
||||
|
||||
char *banned_cpumask_from_ui = NULL;
|
||||
|
||||
+static inline void reset_verify_countdown(void)
|
||||
+{
|
||||
+ next_verify = poll_hint_interval;
|
||||
+}
|
||||
+
|
||||
+static inline void reset_balance_countdown(void)
|
||||
+{
|
||||
+ next_balance = sleep_interval;
|
||||
+}
|
||||
+
|
||||
+static inline int need_verify(void)
|
||||
+{
|
||||
+ return !(poll_hint_interval - next_verify);
|
||||
+}
|
||||
+
|
||||
+static inline int need_balance(void)
|
||||
+{
|
||||
+ return !(sleep_interval - next_balance);
|
||||
+}
|
||||
+
|
||||
+static inline void reset_countdown(void)
|
||||
+{
|
||||
+ reset_verify_countdown();
|
||||
+ reset_balance_countdown();
|
||||
+}
|
||||
+
|
||||
static void sleep_approx(int seconds)
|
||||
{
|
||||
struct timespec ts;
|
||||
@@ -79,6 +107,26 @@ static void sleep_approx(int seconds)
|
||||
nanosleep(&ts, NULL);
|
||||
}
|
||||
|
||||
+static void cond_sleep(void)
|
||||
+{
|
||||
+ unsigned int timeout;
|
||||
+
|
||||
+ if (next_verify < next_balance) {
|
||||
+ timeout = next_verify;
|
||||
+ next_balance -= timeout;
|
||||
+ reset_verify_countdown();
|
||||
+ } else if (next_verify > next_balance) {
|
||||
+ timeout = next_balance;
|
||||
+ next_verify -= timeout;
|
||||
+ reset_balance_countdown();
|
||||
+ } else {
|
||||
+ timeout = next_verify;
|
||||
+ reset_countdown();
|
||||
+ }
|
||||
+
|
||||
+ sleep_approx(timeout);
|
||||
+}
|
||||
+
|
||||
#ifdef HAVE_GETOPT_LONG
|
||||
struct option lopts[] = {
|
||||
{"oneshot", 0, NULL, 'o'},
|
||||
@@ -95,14 +143,15 @@ struct option lopts[] = {
|
||||
{"banmod", 1 , NULL, 'm'},
|
||||
{"interval", 1 , NULL, 't'},
|
||||
{"version", 0, NULL, 'V'},
|
||||
+ {"verifyhint", 1, NULL, 'v'},
|
||||
{0, 0, 0, 0}
|
||||
};
|
||||
|
||||
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, "irqbalance [--oneshot | -o] [--debug | -d] [--foreground | -f] [--journal | -j] [--hintpolicy | -h <subset>]\n");
|
||||
log(TO_CONSOLE, LOG_INFO, " [--powerthresh= | -p <off> | <n>] [--banirq= | -i <n>] [--banmod= | -m <module>] [--policyscript= | -l <script>]\n");
|
||||
- log(TO_CONSOLE, LOG_INFO, " [--pid= | -s <file>] [--deepestcache= | -c <n>] [--interval= | -t <n>]\n");
|
||||
+ log(TO_CONSOLE, LOG_INFO, " [--pid= | -s <file>] [--deepestcache= | -c <n>] [--interval= | -t <n>] [--verifyhint= | -v n]\n");
|
||||
}
|
||||
|
||||
static void version(void)
|
||||
@@ -117,7 +166,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",
|
||||
+ "odfji:p:s:c:b:l:m:t:V:h:v:",
|
||||
lopts, &longind)) != -1) {
|
||||
|
||||
switch(opt) {
|
||||
@@ -190,12 +239,30 @@ static void parse_command_line(int argc, char **argv)
|
||||
journal_logging=1;
|
||||
foreground_mode=1;
|
||||
break;
|
||||
- case 't':
|
||||
+ case 't':
|
||||
sleep_interval = strtol(optarg, NULL, 10);
|
||||
if (sleep_interval < 1) {
|
||||
usage();
|
||||
exit(1);
|
||||
}
|
||||
+ reset_balance_countdown();
|
||||
+ break;
|
||||
+ case 'h':
|
||||
+ if (!strncmp(optarg, "subset", strlen(optarg)))
|
||||
+ hint_enabled = 1;
|
||||
+ else {
|
||||
+ usage();
|
||||
+ exit(1);
|
||||
+ }
|
||||
+
|
||||
+ break;
|
||||
+ case 'v':
|
||||
+ poll_hint_interval = strtol(optarg, NULL, 10);
|
||||
+ if (poll_hint_interval < 1) {
|
||||
+ usage();
|
||||
+ exit(1);
|
||||
+ }
|
||||
+ reset_verify_countdown();
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -251,21 +318,18 @@ void force_rebalance_irq(struct irq_info *info, void *data __attribute__((unused
|
||||
info->assigned_obj = NULL;
|
||||
}
|
||||
|
||||
-gboolean handler(gpointer data __attribute__((unused)))
|
||||
+void handler(int signum __attribute__((unused)))
|
||||
{
|
||||
keep_going = 0;
|
||||
- g_main_loop_quit(main_loop);
|
||||
- return TRUE;
|
||||
}
|
||||
|
||||
-gboolean force_rescan(gpointer data __attribute__((unused)))
|
||||
+void force_rescan(int signum __attribute__((unused)))
|
||||
{
|
||||
if (cycle_count)
|
||||
need_rescan = 1;
|
||||
- return TRUE;
|
||||
}
|
||||
|
||||
-gboolean scan(gpointer data)
|
||||
+gboolean scan()
|
||||
{
|
||||
log(TO_CONSOLE, LOG_INFO, "\n\n\n-----------------------------------------------------------------------------\n");
|
||||
clear_work_stats();
|
||||
@@ -276,7 +340,7 @@ gboolean scan(gpointer data)
|
||||
if (need_rescan) {
|
||||
need_rescan = 0;
|
||||
cycle_count = 0;
|
||||
- log(TO_CONSOLE, LOG_INFO, "Rescanning cpu topology \n");
|
||||
+ reset_countdown();
|
||||
clear_work_stats();
|
||||
|
||||
free_object_tree();
|
||||
@@ -303,16 +367,9 @@ gboolean scan(gpointer data)
|
||||
keep_going = 0;
|
||||
cycle_count++;
|
||||
|
||||
- if (data != &sleep_interval) {
|
||||
- data = &sleep_interval;
|
||||
- g_timeout_add_seconds(sleep_interval, scan, data);
|
||||
- return FALSE;
|
||||
- }
|
||||
-
|
||||
if (keep_going) {
|
||||
return TRUE;
|
||||
} else {
|
||||
- g_main_loop_quit(main_loop);
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
@@ -501,6 +558,7 @@ int init_socket(char *socket_name)
|
||||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
+ struct sigaction action, hupaction;
|
||||
sigset_t sigset, old_sigset;
|
||||
int ret = EXIT_SUCCESS;
|
||||
|
||||
@@ -600,11 +658,19 @@ int main(int argc, char** argv)
|
||||
}
|
||||
}
|
||||
|
||||
- g_unix_signal_add(SIGINT, handler, NULL);
|
||||
- g_unix_signal_add(SIGTERM, handler, NULL);
|
||||
- g_unix_signal_add(SIGUSR1, handler, NULL);
|
||||
- g_unix_signal_add(SIGUSR2, handler, NULL);
|
||||
- g_unix_signal_add(SIGHUP, force_rescan, NULL);
|
||||
+ action.sa_handler = handler;
|
||||
+ sigemptyset(&action.sa_mask);
|
||||
+ action.sa_flags = 0;
|
||||
+ sigaction(SIGINT, &action, NULL);
|
||||
+ sigaction(SIGTERM, &action, NULL);
|
||||
+ sigaction(SIGUSR1, &action, NULL);
|
||||
+ sigaction(SIGUSR2, &action, NULL);
|
||||
+
|
||||
+ hupaction.sa_handler = force_rescan;
|
||||
+ sigemptyset(&hupaction.sa_mask);
|
||||
+ hupaction.sa_flags = 0;
|
||||
+ sigaction(SIGHUP, &hupaction, NULL);
|
||||
+
|
||||
sigprocmask(SIG_SETMASK, &old_sigset, NULL);
|
||||
|
||||
#ifdef HAVE_LIBCAP_NG
|
||||
@@ -625,12 +691,23 @@ int main(int argc, char** argv)
|
||||
ret = EXIT_FAILURE;
|
||||
goto out;
|
||||
}
|
||||
- main_loop = g_main_loop_new(NULL, FALSE);
|
||||
- int *last_interval = &sleep_interval;
|
||||
- g_timeout_add_seconds(sleep_interval, scan, last_interval);
|
||||
- g_main_loop_run(main_loop);
|
||||
|
||||
- g_main_loop_quit(main_loop);
|
||||
+ while (keep_going) {
|
||||
+ cond_sleep();
|
||||
+
|
||||
+ if (need_verify() && hint_changed()) {
|
||||
+ for_each_irq(NULL, update_affinity_hint, NULL);
|
||||
+ reset_countdown();
|
||||
+ }
|
||||
+
|
||||
+ if (!need_balance()) {
|
||||
+ continue;
|
||||
+ }
|
||||
+
|
||||
+ if (!scan()) {
|
||||
+ break;
|
||||
+ }
|
||||
+ }
|
||||
|
||||
out:
|
||||
free_object_tree();
|
||||
diff --git a/irqbalance.h b/irqbalance.h
|
||||
index 73737ed..b8141aa 100644
|
||||
--- a/irqbalance.h
|
||||
+++ b/irqbalance.h
|
||||
@@ -106,12 +106,17 @@ 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 void force_rebalance_irq(struct irq_info *info, void *data __attribute__((unused)));
|
||||
|
||||
/* huawei */
|
||||
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 update_affinity_hint(struct irq_info *info, void *data __attribute__((unused)));
|
||||
+extern int hint_changed(void);
|
||||
+
|
||||
+extern int hint_enabled, poll_hint_interval;
|
||||
|
||||
/*
|
||||
* Generic object functions
|
||||
diff --git a/placement.c b/placement.c
|
||||
index 5a82111..2085e09 100644
|
||||
--- a/placement.c
|
||||
+++ b/placement.c
|
||||
@@ -41,6 +41,7 @@ static void find_best_object(struct topo_obj *d, void *data)
|
||||
{
|
||||
struct obj_placement *best = (struct obj_placement *)data;
|
||||
uint64_t newload;
|
||||
+ cpumask_t subset;
|
||||
|
||||
/*
|
||||
* Don't consider the unspecified numa node here
|
||||
@@ -59,6 +60,19 @@ static void find_best_object(struct topo_obj *d, void *data)
|
||||
if (d->powersave_mode)
|
||||
return;
|
||||
|
||||
+ /*
|
||||
+ * If the hint feature is enabled, then we only want
|
||||
+ * to consider objects that are within the irqs hint, but
|
||||
+ * only if that irq in fact has published a hint
|
||||
diff --git a/hint_verify.c b/hint_verify.c
|
||||
new file mode 100644
|
||||
index 0000000..7a904b0
|
||||
--- /dev/null
|
||||
+++ b/hint_verify.c
|
||||
@@ -0,0 +1,147 @@
|
||||
+/*
|
||||
+ * Copyright (C) 2019. Huawei Technologies Co., Ltd. All rights reserved.
|
||||
+ *
|
||||
+ * This program is free software; you can redistribute it and/or modify
|
||||
+ * it under the terms of the MuLan PSL v1.
|
||||
+ *
|
||||
+ * This program is distributed in the hope that it will be useful,
|
||||
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MuLan PSL v1 for more details.
|
||||
+ */
|
||||
+ if (hint_enabled) {
|
||||
+ if (!cpus_empty(best->info->affinity_hint)) {
|
||||
+ cpus_and(subset, best->info->affinity_hint, d->mask);
|
||||
+ if (cpus_empty(subset))
|
||||
+ return;
|
||||
+ }
|
||||
+ }
|
||||
+#include <stdio.h>
|
||||
+#include <stdlib.h>
|
||||
+#include "irqbalance.h"
|
||||
+
|
||||
newload = d->load;
|
||||
if (newload < best->best_cost) {
|
||||
best->best = d;
|
||||
diff --git a/procinterrupts.c b/procinterrupts.c
|
||||
index d384860..b446c55 100644
|
||||
--- a/procinterrupts.c
|
||||
+++ b/procinterrupts.c
|
||||
@@ -544,3 +544,60 @@ void parse_proc_stat(void)
|
||||
for_each_object(numa_nodes, compute_irq_branch_load_share, NULL);
|
||||
|
||||
}
|
||||
+extern int keep_going;
|
||||
+extern GMainLoop *main_loop;
|
||||
+extern gboolean scan();
|
||||
+
|
||||
+int real_sleep_interval;
|
||||
+int sleep_interval_count;
|
||||
+int poll_hint_interval_count;
|
||||
+int sleep_count = 0;
|
||||
+gboolean hint_has_changed = FALSE;
|
||||
+
|
||||
+int hint_changed(void)
|
||||
+{
|
||||
+ FILE *file;
|
||||
+ char *line = NULL;
|
||||
+ size_t size = 0;
|
||||
+ int changed = 0;
|
||||
+ gboolean changed = FALSE;
|
||||
+
|
||||
+ file = fopen("/proc/irq/affinity_hint_notify", "r+");
|
||||
+ if (!file)
|
||||
@ -446,7 +187,7 @@ index d384860..b446c55 100644
|
||||
+
|
||||
+ if (getline(&line, &size, file) > 0 && *line != '0') {
|
||||
+ fprintf(file, "Done");
|
||||
+ changed = 1;
|
||||
+ changed = TRUE;
|
||||
+ }
|
||||
+
|
||||
+ fclose(file);
|
||||
@ -481,7 +222,8 @@ index d384860..b446c55 100644
|
||||
+ if (!cpus_equal(current_affinity_hint, info->affinity_hint)) {
|
||||
+ cpumask_copy(info->affinity_hint, current_affinity_hint);
|
||||
+ force_rebalance_irq(info, data);
|
||||
+ log(TO_ALL, LOG_INFO, "IRQ(%d): affinity hint modified\n", info->irq);
|
||||
+ hint_has_changed = TRUE;
|
||||
+ log(TO_ALL, LOG_INFO, "IRQ(%d): affinity hint modified %s\n", info->irq, line);
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
@ -489,11 +231,266 @@ index d384860..b446c55 100644
|
||||
+ free(line);
|
||||
+}
|
||||
+
|
||||
+/*
|
||||
+ * This function is the main loop of irqbalance, which include:
|
||||
+ * 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 need_verify_flag = FALSE;
|
||||
+ gboolean need_scan_flag = FALSE;
|
||||
+
|
||||
+ if (!sleep_interval_count)
|
||||
+ sleep_interval_count = 1;
|
||||
+ if (!poll_hint_interval_count)
|
||||
+ poll_hint_interval_count = 1;
|
||||
+
|
||||
+ if (sleep_count % sleep_interval_count == 0) {
|
||||
+ need_scan_flag = TRUE;
|
||||
+ }
|
||||
+ if (sleep_count % poll_hint_interval_count == 0) {
|
||||
+ need_verify_flag = TRUE;
|
||||
+ }
|
||||
+ sleep_count++;
|
||||
+
|
||||
+ if (need_verify_flag && hint_changed()) {
|
||||
+ for_each_irq(NULL, update_affinity_hint, NULL);
|
||||
+ if (hint_has_changed) {
|
||||
+ hint_has_changed = FALSE;
|
||||
+ sleep_count = 1;
|
||||
+ need_scan_flag = TRUE;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ if (need_scan_flag) {
|
||||
+ if (!scan()) {
|
||||
+ g_main_loop_quit(main_loop);
|
||||
+ return FALSE;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ if (data != &real_sleep_interval) {
|
||||
+ data = &real_sleep_interval;
|
||||
+ g_timeout_add_seconds(real_sleep_interval, poll_hint_affinity_and_scan, data);
|
||||
+ return FALSE;
|
||||
+ }
|
||||
+
|
||||
+ if (keep_going) {
|
||||
+ return TRUE;
|
||||
+ } else {
|
||||
+ g_main_loop_quit(main_loop);
|
||||
+ return FALSE;
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
+void update_interval_and_count()
|
||||
+{
|
||||
+ real_sleep_interval =
|
||||
+ sleep_interval > poll_hint_interval ? poll_hint_interval : sleep_interval;
|
||||
+ if (!real_sleep_interval) {
|
||||
+ sleep_interval_count = 1;
|
||||
+ poll_hint_interval_count = 1;
|
||||
+ return;
|
||||
+ }
|
||||
+ sleep_interval_count = sleep_interval / real_sleep_interval;
|
||||
+ poll_hint_interval_count = poll_hint_interval / real_sleep_interval;
|
||||
+}
|
||||
+
|
||||
diff --git a/hint_verify.h b/hint_verify.h
|
||||
new file mode 100644
|
||||
index 0000000..a309461
|
||||
--- /dev/null
|
||||
+++ b/hint_verify.h
|
||||
@@ -0,0 +1,19 @@
|
||||
+/*
|
||||
+ * Copyright (C) 2019. Huawei Technologies Co., Ltd. All rights reserved.
|
||||
+ *
|
||||
+ * This program is free software; you can redistribute it and/or modify
|
||||
+ * it under the terms of the MuLan PSL v1.
|
||||
+ *
|
||||
+ * This program is distributed in the hope that it will be useful,
|
||||
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MuLan PSL v1 for more details.
|
||||
+ */
|
||||
+
|
||||
+#ifndef _INCLUDE_HINT_VERIFY_H
|
||||
+#define _INCLUDE_HINT_VERIFY_H
|
||||
+
|
||||
+extern int real_sleep_interval;
|
||||
+extern gboolean poll_hint_affinity_and_scan();
|
||||
+extern void update_interval_and_count();
|
||||
+
|
||||
+#endif
|
||||
diff --git a/irqbalance.c b/irqbalance.c
|
||||
index faa8e6a..4a7eb39 100644
|
||||
--- a/irqbalance.c
|
||||
+++ b/irqbalance.c
|
||||
@@ -65,6 +65,8 @@ char *banscript = NULL;
|
||||
char *polscript = NULL;
|
||||
long HZ;
|
||||
int sleep_interval = SLEEP_INTERVAL;
|
||||
+int hint_enabled = 0;
|
||||
+int poll_hint_interval = SLEEP_INTERVAL / 5;
|
||||
GMainLoop *main_loop;
|
||||
|
||||
char *banned_cpumask_from_ui = NULL;
|
||||
@@ -99,15 +101,16 @@ struct option lopts[] = {
|
||||
{"banmod", 1 , NULL, 'm'},
|
||||
{"interval", 1 , NULL, 't'},
|
||||
{"version", 0, NULL, 'V'},
|
||||
+ {"verifyhint", 1, NULL, 'v'},
|
||||
{"rulesconfig", 1, NULL, 'r'},
|
||||
{0, 0, 0, 0}
|
||||
};
|
||||
|
||||
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, "irqbalance [--oneshot | -o] [--debug | -d] [--foreground | -f] [--journal | -j] [--hintpolicy | -h <subset>]\n");
|
||||
log(TO_CONSOLE, LOG_INFO, " [--powerthresh= | -p <off> | <n>] [--banirq= | -i <n>] [--banmod= | -m <module>] [--policyscript= | -l <script>]\n");
|
||||
- log(TO_CONSOLE, LOG_INFO, " [--pid= | -s <file>] [--deepestcache= | -c <n>] [--interval= | -t <n>] [--rulesconfig= | -r <config>]\n");
|
||||
+ log(TO_CONSOLE, LOG_INFO, " [--pid= | -s <file>] [--deepestcache= | -c <n>] [--interval= | -t <n>] [--verifyhint= | -v n] [--rulesconfig= | -r <config>]\n");
|
||||
}
|
||||
|
||||
static void version(void)
|
||||
@@ -122,7 +125,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:r",
|
||||
+ "odfji:p:s:c:b:l:m:t:V:h:v:r:",
|
||||
lopts, &longind)) != -1) {
|
||||
|
||||
switch(opt) {
|
||||
@@ -202,6 +205,22 @@ static void parse_command_line(int argc, char **argv)
|
||||
exit(1);
|
||||
}
|
||||
break;
|
||||
+ case 'h':
|
||||
+ if (!strncmp(optarg, "subset", strlen(optarg)))
|
||||
+ hint_enabled = 1;
|
||||
+ else {
|
||||
+ usage();
|
||||
+ exit(1);
|
||||
+ }
|
||||
+
|
||||
+ break;
|
||||
+ case 'v':
|
||||
+ poll_hint_interval = strtol(optarg, NULL, 10);
|
||||
+ if (poll_hint_interval < 1) {
|
||||
+ usage();
|
||||
+ exit(1);
|
||||
+ }
|
||||
+ break;
|
||||
case 'r':
|
||||
rules_config_file = strdup(optarg);
|
||||
break;
|
||||
@@ -300,7 +319,7 @@ out:
|
||||
return 0;
|
||||
}
|
||||
|
||||
-gboolean scan(gpointer data)
|
||||
+gboolean scan()
|
||||
{
|
||||
log(TO_CONSOLE, LOG_INFO, "\n\n\n-----------------------------------------------------------------------------\n");
|
||||
clear_work_stats();
|
||||
@@ -338,16 +357,9 @@ gboolean scan(gpointer data)
|
||||
keep_going = 0;
|
||||
cycle_count++;
|
||||
|
||||
- if (data != &sleep_interval) {
|
||||
- data = &sleep_interval;
|
||||
- g_timeout_add_seconds(sleep_interval, scan, data);
|
||||
- return FALSE;
|
||||
- }
|
||||
-
|
||||
if (keep_going) {
|
||||
return TRUE;
|
||||
} else {
|
||||
- g_main_loop_quit(main_loop);
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
@@ -626,9 +638,10 @@ 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 = &sleep_interval;
|
||||
- g_timeout_add_seconds(sleep_interval, scan, last_interval);
|
||||
+ int *last_interval = &real_sleep_interval;
|
||||
+ g_timeout_add_seconds(real_sleep_interval, poll_hint_affinity_and_scan, last_interval);
|
||||
g_main_loop_run(main_loop);
|
||||
|
||||
g_main_loop_quit(main_loop);
|
||||
diff --git a/irqbalance.h b/irqbalance.h
|
||||
index 1befb46..72e141b 100644
|
||||
--- a/irqbalance.h
|
||||
+++ b/irqbalance.h
|
||||
@@ -15,6 +15,7 @@
|
||||
#include "types.h"
|
||||
#include "config.h"
|
||||
#include "rules_config.h"
|
||||
+#include "hint_verify.h"
|
||||
#ifdef __aarch64__
|
||||
#define AARCH64
|
||||
#endif
|
||||
@@ -113,6 +114,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 void force_rebalance_irq(struct irq_info *info, void *data __attribute__((unused)));
|
||||
extern gint compare_ints(gconstpointer a, gconstpointer b);
|
||||
|
||||
extern struct irq_info *build_one_dev_entry(const char *dirname, GList *tmp_list);
|
||||
@@ -120,6 +122,8 @@ 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 int hint_enabled, poll_hint_interval;
|
||||
+extern int sleep_interval;
|
||||
|
||||
/*
|
||||
* Generic object functions
|
||||
diff --git a/placement.c b/placement.c
|
||||
index 48ac68b..d887c60 100644
|
||||
--- a/placement.c
|
||||
+++ b/placement.c
|
||||
@@ -41,6 +41,7 @@ static void find_best_object(struct topo_obj *d, void *data)
|
||||
{
|
||||
struct obj_placement *best = (struct obj_placement *)data;
|
||||
uint64_t newload;
|
||||
+ cpumask_t subset;
|
||||
|
||||
/*
|
||||
* Don't consider the unspecified numa node here
|
||||
@@ -58,6 +59,19 @@ static void find_best_object(struct topo_obj *d, void *data)
|
||||
if (d->powersave_mode)
|
||||
return;
|
||||
|
||||
+ /*
|
||||
+ * If the hint feature is enabled, then we only want
|
||||
+ * to consider objects that are within the irqs hint, but
|
||||
+ * only if that irq in fact has published a hint
|
||||
+ */
|
||||
+ if (hint_enabled) {
|
||||
+ if (!cpus_empty(best->info->affinity_hint)) {
|
||||
+ cpus_and(subset, best->info->affinity_hint, d->mask);
|
||||
+ if (cpus_empty(subset))
|
||||
+ return;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
newload = d->load;
|
||||
if (newload < best->best_cost) {
|
||||
best->best = d;
|
||||
diff --git a/types.h b/types.h
|
||||
index 9693cf4..62cc2bb 100644
|
||||
index e1f3dc6..c0950ee 100644
|
||||
--- a/types.h
|
||||
+++ b/types.h
|
||||
@@ -66,6 +66,7 @@ struct irq_info {
|
||||
@@ -67,6 +67,7 @@ struct irq_info {
|
||||
int flags;
|
||||
struct topo_obj *numa_node;
|
||||
cpumask_t cpumask;
|
||||
|
||||
@ -22,11 +22,11 @@ Signed-off-by: Xu Yandong <xuyandong2@huawei.com>
|
||||
Makefile.am | 6 +-
|
||||
classify.c | 20 ++-
|
||||
cputree.c | 5 +-
|
||||
irqbalance.c | 164 ++----------------------
|
||||
irqbalance.c | 185 +++--------------------------------------------------------
|
||||
irqbalance.h | 2 +
|
||||
sockapi.c | 400 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||
sockapi.c | 404 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||
sockapi.h | 18 +++
|
||||
7 files changed, 452 insertions(+), 163 deletions(-)
|
||||
7 files changed, 462 insertions(+), 179 deletions(-)
|
||||
create mode 100644 sockapi.c
|
||||
create mode 100644 sockapi.h
|
||||
|
||||
@ -175,7 +175,7 @@ index 27cf2eb..6e9de88 100644
|
||||
|
||||
volatile int keep_going = 1;
|
||||
volatile int ban_pci_assigned_irq = 1;
|
||||
@@ -430,178 +432,6 @@ void get_object_stat(struct topo_obj *object, void *data)
|
||||
@@ -388,178 +390,6 @@ void get_object_stat(struct topo_obj *object, void *data)
|
||||
}
|
||||
}
|
||||
|
||||
@ -354,28 +354,33 @@ index 27cf2eb..6e9de88 100644
|
||||
static int create_lock_pidfile(const char *lockfile)
|
||||
{
|
||||
struct flock lock = { 0 };
|
||||
@@ -691,7 +519,9 @@ error_close:
|
||||
@@ -633,6 +463,8 @@ error_close:
|
||||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
- struct sigaction action, hupaction;
|
||||
+ int err;
|
||||
+ pthread_t socket_tid;
|
||||
+ struct sigaction action, hupaction;
|
||||
sigset_t sigset, old_sigset;
|
||||
int ret = EXIT_SUCCESS;
|
||||
|
||||
@@ -781,7 +631,9 @@ int main(int argc, char** argv)
|
||||
@@ -750,10 +582,13 @@ int main(int argc, char** argv)
|
||||
parse_proc_interrupts();
|
||||
parse_proc_stat();
|
||||
|
||||
- if (init_socket()) {
|
||||
- ret = EXIT_FAILURE;
|
||||
- goto out;
|
||||
+ err = pthread_create(&socket_tid, NULL, &handle_socket_api_event, NULL);
|
||||
+ if (0 != err) {
|
||||
+ log(TO_CONSOLE, LOG_WARNING, "WARNING: Failed to create irqbalance socket thread, return %d.\n", err);
|
||||
ret = EXIT_FAILURE;
|
||||
goto out;
|
||||
+ ret = EXIT_FAILURE;
|
||||
+ goto out;
|
||||
}
|
||||
+
|
||||
main_loop = g_main_loop_new(NULL, FALSE);
|
||||
int *last_interval = &sleep_interval;
|
||||
g_timeout_add_seconds(sleep_interval, scan, last_interval);
|
||||
|
||||
diff --git a/irqbalance.h b/irqbalance.h
|
||||
index 339e2a3..f9b554e 100644
|
||||
--- a/irqbalance.h
|
||||
@ -394,17 +399,7 @@ new file mode 100644
|
||||
index 0000000..4a0e683
|
||||
--- /dev/null
|
||||
+++ b/sockapi.c
|
||||
@@ -0,0 +1,415 @@
|
||||
+/*
|
||||
+ * Copyright (C) 2019. Huawei Technologies Co., Ltd. All rights reserved.
|
||||
+ *
|
||||
+ * This program is free software; you can redistribute it and/or modify
|
||||
+ * it under the terms of the MuLan PSL v1.
|
||||
+ *
|
||||
+ * This program is distributed in the hope that it will be useful,
|
||||
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MuLan PSL v1 for more details.
|
||||
+ */
|
||||
@@ -0,0 +1,404 @@
|
||||
+#include <stdio.h>
|
||||
+#include <stdlib.h>
|
||||
+#include <unistd.h>
|
||||
@ -747,7 +742,6 @@ index 0000000..4a0e683
|
||||
+ memset((void*)events, 0, sizeof(struct epoll_event) * MAX_EVENTS);
|
||||
+
|
||||
+ banned_cpumask_from_ui = (char*)malloc(NR_CPUS + 1);
|
||||
+ banned_cpumask_from_ui = (char*)malloc(NR_CPUS + 1);
|
||||
+ if (!banned_cpumask_from_ui) {
|
||||
+ log(TO_ALL, LOG_WARNING, "Daemon faild to malloc banned_cpumask_from_ui space.\n");
|
||||
+ exit(-1);
|
||||
@ -815,17 +809,7 @@ new file mode 100644
|
||||
index 0000000..254dd3f
|
||||
--- /dev/null
|
||||
+++ b/sockapi.h
|
||||
@@ -0,0 +1,28 @@
|
||||
+/*
|
||||
+ * Copyright (C) 2019. Huawei Technologies Co., Ltd. All rights reserved.
|
||||
+ *
|
||||
+ * This program is free software; you can redistribute it and/or modify
|
||||
+ * it under the terms of the MuLan PSL v1.
|
||||
+ *
|
||||
+ * This program is distributed in the hope that it will be useful,
|
||||
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MuLan PSL v1 for more details.
|
||||
+ */
|
||||
@@ -0,0 +1,18 @@
|
||||
+#ifndef UVP_IRQBALANCE_SOCKAPI_H_
|
||||
+#define UVP_IRQBALANCE_SOCKAPI_H_
|
||||
+
|
||||
|
||||
@ -26,8 +26,8 @@ diff --git a/classify.c b/classify.c
|
||||
index 3a25d62..65cb4e5 100644
|
||||
--- a/classify.c
|
||||
+++ b/classify.c
|
||||
@@ -299,6 +299,13 @@ int irq_in_rebalance_list(int irq)
|
||||
return entry ? 1 : 0;
|
||||
@@ -299,6 +299,13 @@ static void add_banned_irq(int irq, GList **list, int extra_flag)
|
||||
return;
|
||||
}
|
||||
|
||||
+#ifdef AARCH64
|
||||
|
||||
@ -67,3 +67,4 @@ index cace4d8..5e5ef9b 100644
|
||||
}
|
||||
--
|
||||
2.19.1
|
||||
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
Summary: A dynamic adaptive IRQ balancing daemon
|
||||
Name: irqbalance
|
||||
Version: 1.4.0
|
||||
Release: 11
|
||||
Release: 13
|
||||
Epoch: 3
|
||||
|
||||
License: GPLv2
|
||||
@ -9,7 +9,7 @@ Source0: https://github.com/Irqbalance/irqbalance/archive/irqbalance-%{ve
|
||||
Source1: irqbalance.sysconfig
|
||||
Source2: irqbalance.rules
|
||||
Source3: irq_balancer
|
||||
Url: https://github.com/Irqbalance/irqbalance
|
||||
Url: https://github.com/irqbalance/irqbalance
|
||||
|
||||
BuildRequires: autoconf automake libtool libcap-ng systemd
|
||||
BuildRequires: glib2-devel pkgconf libcap-ng-devel ncurses-devel
|
||||
@ -51,21 +51,28 @@ Patch9000: irqbalance-1.0.4-env-file-path.patch
|
||||
Patch9001: bugfix-fix-a-hole-that-flees-hotplug-event.patch
|
||||
Patch9002: bugfix-use-policy-prior-to-the-default-values.patch
|
||||
Patch9003: bugfix-force-irq-into-rebalance-list-when-irq-removed-and-reinserted.patch
|
||||
Patch9004: feature-introduce-verifyhint-to-detect-hint-variation.patch
|
||||
Patch9005: bugfix-fix-two-same-irq-insert-to-list.patch
|
||||
Patch9006: feature-irqbalance-aarch64-add-the-regular-to-get-th.patch
|
||||
Patch9007: feature-irqbalance-arm64-Add-irq-aff-change-check.patch
|
||||
Patch9008: feature-irqbalance-auto-banned-pci-assigned-irq.patch
|
||||
Patch9009: bugfix-irqbalance-fix-wrong-pid-value-in-pid-file.patch
|
||||
Patch9010: feature-supplement-irqbalance-service-config.patch
|
||||
Patch9011: feature-irqbalance-Add-ability-for-socket-communicat.patch
|
||||
Patch9012: bugfix-fgets-will-get-a-redundant-new-line.patch
|
||||
Patch9013: bugfix-prevent-inserting-a-duplicate-entry-to-avoid-list-ch.patch
|
||||
Patch9014: bugfix-guess_arm_irq_hints.patch
|
||||
Patch9015: feature-add-new-user-irq-policy-config-rule.patch
|
||||
Patch9016: bugfix-make-the-return-value-of-getline-handled-correct.patch
|
||||
Patch9017: bugfix-change-irq-ban-check-path-to-devpath.patch
|
||||
Patch9018: bugfix-fix-strcat-may-cause-buffer-overrun.patch
|
||||
Patch9004: feature-irqbalance-aarch64-add-the-regular-to-get-th.patch
|
||||
Patch9005: feature-irqbalance-arm64-Add-irq-aff-change-check.patch
|
||||
Patch9006: feature-irqbalance-auto-banned-pci-assigned-irq.patch
|
||||
Patch9007: bugfix-irqbalance-fix-wrong-pid-value-in-pid-file.patch
|
||||
Patch9008: feature-supplement-irqbalance-service-config.patch
|
||||
Patch9009: feature-irqbalance-Add-ability-for-socket-communicat.patch
|
||||
Patch9010: bugfix-fgets-will-get-a-redundant-new-line.patch
|
||||
Patch9011: bugfix-Prevent-inserting-a-duplicate-entry-to-avoid-list-ch.patch
|
||||
Patch9012: bugfix-guess_arm_irq_hints.patch
|
||||
Patch9013: feature-add-new-user-irq-policy-config-rule.patch
|
||||
Patch9014: bugfix-make-the-return-value-of-getline-handled-correct.patch
|
||||
Patch9015: bugfix-change-irq-ban-check-path-to-devpath.patch
|
||||
Patch9016: bugfix-fix-new-irqs-in-hotplug-keep-stay-on-one-numa.patch
|
||||
Patch9017: feature-add-the-switch-of-printing-log.patch
|
||||
Patch9018: bugfix-fix-new-msi-irq-hasnot-been-added-to-rebalance-list.patch
|
||||
Patch9019: bugfix-delete-no-existing-banned-irq.patch
|
||||
Patch9020: feature-add-test-interfaces-for-irqbalance-core-functions.patch
|
||||
Patch9021: bugfix-fix-strcat-may-cause-buffer-overrun.patch
|
||||
Patch9022: feature-introduce-verifyhint-to-detect-hint-variation.patch
|
||||
Patch9023: bugfix-fix-memory-leak-of-strdup-in-collect_full_irq_list.patch
|
||||
Patch9024: bugfix-fix-sleep-interval-when-sleep_interval-is-changed-by.patch
|
||||
Patch9025: feature-add-switch-to-clear-affinity-hint.patch
|
||||
|
||||
%description
|
||||
Irqbalance is a daemon to help balance the cpu load generated by
|
||||
@ -126,6 +133,18 @@ fi
|
||||
/sbin/chkconfig --del %{name} >/dev/null 2>&1 || :
|
||||
|
||||
%changelog
|
||||
* Fri Dec 20 2019 caomeng<caomeng5@huawei.com> - 3:1.4.0-13
|
||||
- Type:NA
|
||||
- ID:NA
|
||||
- SUG:restart
|
||||
- DESC:change the url
|
||||
|
||||
* Fri Dec 20 2019 liuchao<liuchao173@huawei.com> - 3:1.4.0-12
|
||||
- Type:bugfix
|
||||
- ID:NA
|
||||
- SUG:restart
|
||||
- DESC:synchronize patches from R8
|
||||
|
||||
* Wed Nov 13 2019 liuchao<liuchao173@huawei.com> - 3:1.4.0-11
|
||||
- Type:other
|
||||
- ID:NA
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user