refactor patches
This commit is contained in:
parent
638b879189
commit
da193a5c7f
139
arm64-Add-irq-aff-change-check.patch
Normal file
139
arm64-Add-irq-aff-change-check.patch
Normal file
@ -0,0 +1,139 @@
|
|||||||
|
From 55c5c321c73e4c9b54e041ba8c7d542598685bae Mon Sep 17 00:00:00 2001
|
||||||
|
From: liuchao <liuchao173@huawei.com>
|
||||||
|
Date: Wed, 11 Mar 2020 11:46:42 +0800
|
||||||
|
Subject: [PATCH 48/48] arm64: Add irq aff change check For aarch64, the PPIs
|
||||||
|
format in /proc/interrputs can be parsed and add to interrupt db, and next,
|
||||||
|
the number of interrupts is counted and used to calculate the load. Finally
|
||||||
|
these interrupts maybe scheduled between the NUMA domains.
|
||||||
|
|
||||||
|
Acctually, the PPIs cannot change aff, and it should not be added to interrupt db. This patch fix it.
|
||||||
|
|
||||||
|
Add a check before add a interrupt to db, just only reads the irq's aff, and write it back to avoid any impact on the system, According to the result of writing to fitler the irq.
|
||||||
|
---
|
||||||
|
activate.c | 8 +++++++-
|
||||||
|
classify.c | 32 +++++++++++++++++++++++++++-----
|
||||||
|
irqbalance.h | 2 ++
|
||||||
|
3 files changed, 36 insertions(+), 6 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/activate.c b/activate.c
|
||||||
|
index 2812976..f933347 100644
|
||||||
|
--- a/activate.c
|
||||||
|
+++ b/activate.c
|
||||||
|
@@ -60,6 +60,7 @@ static void activate_mapping(struct irq_info *info, void *data __attribute__((un
|
||||||
|
{
|
||||||
|
char buf[PATH_MAX];
|
||||||
|
FILE *file;
|
||||||
|
+ int ret = 0;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* only activate mappings for irqs that have moved
|
||||||
|
@@ -82,7 +83,12 @@ static void activate_mapping(struct irq_info *info, void *data __attribute__((un
|
||||||
|
return;
|
||||||
|
|
||||||
|
cpumask_scnprintf(buf, PATH_MAX, info->assigned_obj->mask);
|
||||||
|
- fprintf(file, "%s", buf);
|
||||||
|
+ ret = fprintf(file, "%s", buf);
|
||||||
|
+ if (ret < 0) {
|
||||||
|
+ log(TO_ALL, LOG_WARNING, "cannot change irq %i's affinity, add it to banned list", info->irq);
|
||||||
|
+ add_banned_irq(info->irq);
|
||||||
|
+ remove_one_irq_from_db(info->irq);
|
||||||
|
+ }
|
||||||
|
fclose(file);
|
||||||
|
info->moved = 0; /*migration is done*/
|
||||||
|
}
|
||||||
|
diff --git a/classify.c b/classify.c
|
||||||
|
index 2fa303a..b40fcc1 100644
|
||||||
|
--- a/classify.c
|
||||||
|
+++ b/classify.c
|
||||||
|
@@ -264,7 +264,7 @@ static gint compare_ints(gconstpointer a, gconstpointer b)
|
||||||
|
return ai->irq - bi->irq;
|
||||||
|
}
|
||||||
|
|
||||||
|
-static void add_banned_irq(int irq, GList **list)
|
||||||
|
+static void __add_banned_irq(int irq, GList **list)
|
||||||
|
{
|
||||||
|
struct irq_info find, *new;
|
||||||
|
GList *entry;
|
||||||
|
@@ -288,9 +288,14 @@ static void add_banned_irq(int irq, GList **list)
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
+void add_banned_irq(int irq)
|
||||||
|
+{
|
||||||
|
+ __add_banned_irq(irq, &banned_irqs);
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
void add_cl_banned_irq(int irq)
|
||||||
|
{
|
||||||
|
- add_banned_irq(irq, &cl_banned_irqs);
|
||||||
|
+ __add_banned_irq(irq, &cl_banned_irqs);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int is_banned_irq(int irq)
|
||||||
|
@@ -429,6 +434,23 @@ out:
|
||||||
|
return new;
|
||||||
|
}
|
||||||
|
|
||||||
|
+void remove_one_irq_from_db(int irq)
|
||||||
|
+{
|
||||||
|
+ struct irq_info find, *tmp;
|
||||||
|
+ GList *entry = NULL;
|
||||||
|
+
|
||||||
|
+ find.irq = irq;
|
||||||
|
+ entry = g_list_find_custom(interrupts_db, &find, compare_ints);
|
||||||
|
+ if (!entry)
|
||||||
|
+ return;
|
||||||
|
+
|
||||||
|
+ tmp = entry->data;
|
||||||
|
+ interrupts_db = g_list_remove(interrupts_db, tmp);
|
||||||
|
+ free(tmp);
|
||||||
|
+ log(TO_CONSOLE, LOG_INFO, "IRQ %d was removed from db.\n", irq);
|
||||||
|
+ return;
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
static void parse_user_policy_key(char *buf, int irq, struct user_irq_policy *pol)
|
||||||
|
{
|
||||||
|
char *key, *value, *end;
|
||||||
|
@@ -636,7 +658,7 @@ static void build_one_dev_entry(const char *dirname, GList *tmp_irqs)
|
||||||
|
continue;
|
||||||
|
get_irq_user_policy(devpath, irqnum, &pol);
|
||||||
|
if ((pol.ban == 1) || (check_for_irq_ban(devpath, irqnum, tmp_irqs))) {
|
||||||
|
- add_banned_irq(irqnum, &banned_irqs);
|
||||||
|
+ __add_banned_irq(irqnum, &banned_irqs);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
hint.irq = irqnum;
|
||||||
|
@@ -671,7 +693,7 @@ static void build_one_dev_entry(const char *dirname, GList *tmp_irqs)
|
||||||
|
goto done;
|
||||||
|
get_irq_user_policy(devpath, irqnum, &pol);
|
||||||
|
if ((pol.ban == 1) || (check_for_irq_ban(devpath, irqnum, tmp_irqs))) {
|
||||||
|
- add_banned_irq(irqnum, &banned_irqs);
|
||||||
|
+ __add_banned_irq(irqnum, &banned_irqs);
|
||||||
|
goto done;
|
||||||
|
}
|
||||||
|
|
||||||
|
@@ -723,7 +745,7 @@ static void add_new_irq(int irq, struct irq_info *hint, GList *proc_interrupts)
|
||||||
|
/* Set NULL devpath for the irq has no sysfs entries */
|
||||||
|
get_irq_user_policy(NULL, irq, &pol);
|
||||||
|
if ((pol.ban == 1) || check_for_irq_ban(NULL, irq, proc_interrupts)) { /*FIXME*/
|
||||||
|
- add_banned_irq(irq, &banned_irqs);
|
||||||
|
+ __add_banned_irq(irq, &banned_irqs);
|
||||||
|
new = get_irq_info(irq);
|
||||||
|
} else
|
||||||
|
new = add_one_irq_to_db(NULL, hint, &pol);
|
||||||
|
diff --git a/irqbalance.h b/irqbalance.h
|
||||||
|
index 6cdd9e2..3a78c7f 100644
|
||||||
|
--- a/irqbalance.h
|
||||||
|
+++ b/irqbalance.h
|
||||||
|
@@ -105,6 +105,8 @@ extern struct irq_info *get_irq_info(int irq);
|
||||||
|
extern void migrate_irq(GList **from, GList **to, struct irq_info *info);
|
||||||
|
extern void free_cl_opts(void);
|
||||||
|
extern void add_cl_banned_module(char *modname);
|
||||||
|
+extern void add_banned_irq(int irq);
|
||||||
|
+extern void remove_one_irq_from_db(int irq);
|
||||||
|
#define irq_numa_node(irq) ((irq)->numa_node)
|
||||||
|
|
||||||
|
extern unsigned long migrate_val;
|
||||||
|
--
|
||||||
|
1.8.3.1
|
||||||
|
|
||||||
@ -1,61 +0,0 @@
|
|||||||
From 07032f71ea956ca195c9b2386d09d24b07b7133f Mon Sep 17 00:00:00 2001
|
|
||||||
From: hejingxian <hejingxian@huawei.com>
|
|
||||||
Date: Tue, 12 Nov 2019 10:59:20 +0800
|
|
||||||
Subject: [PATCH] Prevent inserting a duplicate entry to avoid list chaos
|
|
||||||
|
|
||||||
Introduced by bugfix-force-irq-into-rebalance-list-when-irq-removed-and-reinserted.patch
|
|
||||||
and feature-introduce-verifyhint-to-detect-hint-variation.patch, irq may want be inserted to
|
|
||||||
rebalance list more then once, and we need to prevent this. we developped a solution in
|
|
||||||
bugfix-fix-two-same-irq-insert-to-list.patch, but we are likely to call irq_in_rebalance_list.
|
|
||||||
|
|
||||||
this patch remove the code in bugfix-fix-two-same-irq-insert-to-list.patch and add protection
|
|
||||||
in force_rebalance_irq instead.
|
|
||||||
---
|
|
||||||
classify.c | 2 +-
|
|
||||||
irqbalance.c | 4 ++++
|
|
||||||
irqbalance.h | 1 +
|
|
||||||
3 files changed, 6 insertions(+), 1 deletion(-)
|
|
||||||
|
|
||||||
diff --git a/classify.c b/classify.c
|
|
||||||
index f041054..5aed9e5 100644
|
|
||||||
--- a/classify.c
|
|
||||||
+++ b/classify.c
|
|
||||||
@@ -263,7 +263,7 @@ static int get_irq_class(const char *devpath)
|
|
||||||
return irq_class;
|
|
||||||
}
|
|
||||||
|
|
||||||
-static gint compare_ints(gconstpointer a, gconstpointer b)
|
|
||||||
+gint compare_ints(gconstpointer a, gconstpointer b)
|
|
||||||
{
|
|
||||||
const struct irq_info *ai = a;
|
|
||||||
const struct irq_info *bi = b;
|
|
||||||
diff --git a/irqbalance.c b/irqbalance.c
|
|
||||||
index 395669c..faa8e6a 100644
|
|
||||||
--- a/irqbalance.c
|
|
||||||
+++ b/irqbalance.c
|
|
||||||
@@ -251,6 +251,10 @@ void force_rebalance_irq(struct irq_info *info, void *data __attribute__((unused
|
|
||||||
if (info->level == BALANCE_NONE)
|
|
||||||
return;
|
|
||||||
|
|
||||||
+ /* Prevent inserting a duplicate entry to avoid list chaos */
|
|
||||||
+ if (g_list_find_custom(rebalance_irq_list, info, compare_ints))
|
|
||||||
+ return;
|
|
||||||
+
|
|
||||||
if (info->assigned_obj == NULL)
|
|
||||||
rebalance_irq_list = g_list_append(rebalance_irq_list, info);
|
|
||||||
else
|
|
||||||
diff --git a/irqbalance.h b/irqbalance.h
|
|
||||||
index c07a4fc..1befb46 100644
|
|
||||||
--- a/irqbalance.h
|
|
||||||
+++ b/irqbalance.h
|
|
||||||
@@ -113,6 +113,7 @@ extern void migrate_irq(GList **from, GList **to, struct irq_info *info);
|
|
||||||
extern void free_cl_opts(void);
|
|
||||||
extern void add_cl_banned_module(char *modname);
|
|
||||||
#define irq_numa_node(irq) ((irq)->numa_node)
|
|
||||||
+extern gint compare_ints(gconstpointer a, gconstpointer b);
|
|
||||||
|
|
||||||
extern struct irq_info *build_one_dev_entry(const char *dirname, GList *tmp_list);
|
|
||||||
extern void find_irq_dev_path(int irq, char *dirname, int length);
|
|
||||||
--
|
|
||||||
1.8.3.1
|
|
||||||
|
|
||||||
@ -1,29 +0,0 @@
|
|||||||
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
|
|
||||||
@@ -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,50 +0,0 @@
|
|||||||
From 0c8ecab9e6f5fae5860e7fbc795e988c112edede Mon Sep 17 00:00:00 2001
|
|
||||||
From: xiashuang <xiashuang1@huawei.com>
|
|
||||||
Date: Thu, 25 Jul 2019 22:38:32 -0400
|
|
||||||
Subject: [PATCH] fix fgets will get a redundant new line
|
|
||||||
|
|
||||||
this patch fix a bug introduced by bugfix-force-irq-into-rebalance-list-when-irq-removed-and-reinserted.patch.
|
|
||||||
the previous patch use fgets to get a directory name from buffer. but fgets will get a redundant newline,
|
|
||||||
so the directory name are always invalid, this patch just remove the '\n'.
|
|
||||||
---
|
|
||||||
classify.c | 8 ++++++--
|
|
||||||
1 file changed, 6 insertions(+), 2 deletions(-)
|
|
||||||
|
|
||||||
diff --git a/classify.c b/classify.c
|
|
||||||
index e61c39b..440576f 100644
|
|
||||||
--- a/classify.c
|
|
||||||
+++ b/classify.c
|
|
||||||
@@ -747,6 +747,7 @@ void find_irq_dev_path(int irq, char *dirname, int length)
|
|
||||||
char path[PATH_MAX];
|
|
||||||
char buffer[128];
|
|
||||||
char *brc = NULL;
|
|
||||||
+ size_t dirlen;
|
|
||||||
|
|
||||||
memset(dirname, 0, length);
|
|
||||||
/* Return defaults if irq is 0 */
|
|
||||||
@@ -762,8 +763,10 @@ void find_irq_dev_path(int irq, char *dirname, int length)
|
|
||||||
}
|
|
||||||
|
|
||||||
brc = fgets(buffer, 128, output);
|
|
||||||
- if (brc) {
|
|
||||||
+ /* fgets will get a redundant \n */
|
|
||||||
+ if (brc && (dirlen = strcspn(brc, "\n")) > 0) {
|
|
||||||
log(TO_CONSOLE, LOG_INFO, "msi_irqs IRQ %d dirname is %s\n", irq, brc);
|
|
||||||
+ brc[dirlen] = '\0';
|
|
||||||
strncpy(dirname, brc, length);
|
|
||||||
pclose(output);
|
|
||||||
return;
|
|
||||||
@@ -779,8 +782,9 @@ void find_irq_dev_path(int irq, char *dirname, int length)
|
|
||||||
}
|
|
||||||
|
|
||||||
brc = fgets(buffer, 128, output);
|
|
||||||
- if (brc) {
|
|
||||||
+ if (brc && (dirlen = strcspn(brc, "\n")) > 0) {
|
|
||||||
log(TO_CONSOLE, LOG_INFO, "IRQ %d dirname is %s\n", irq, brc);
|
|
||||||
+ brc[dirlen] = '\0';
|
|
||||||
strncpy(dirname, brc, length);
|
|
||||||
pclose(output);
|
|
||||||
return;
|
|
||||||
--
|
|
||||||
1.8.3.1
|
|
||||||
|
|
||||||
@ -1,34 +0,0 @@
|
|||||||
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
|
|
||||||
|
|
||||||
@ -1,161 +0,0 @@
|
|||||||
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;
|
|
||||||
static GList *vm_banned_irqs = NULL;
|
|
||||||
+extern int need_add_single;
|
|
||||||
|
|
||||||
#define SYSFS_DIR "/sys"
|
|
||||||
#define SYSPCI_DIR "/sys/bus/pci/devices"
|
|
||||||
@@ -646,6 +647,21 @@ static int check_for_irq_ban(char *path __attribute__((unused)), int irq, GList
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
+int is_proc_irq_info_exist(int irq, GList *tmp_list)
|
|
||||||
+{
|
|
||||||
+ GList *entry;
|
|
||||||
+ struct irq_info find;
|
|
||||||
+
|
|
||||||
+ if (!tmp_list) {
|
|
||||||
+ return 1;
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ find.irq = irq;
|
|
||||||
+ entry = g_list_find_custom(tmp_list, &find, compare_ints);
|
|
||||||
+
|
|
||||||
+ return entry ? 1 : 0;
|
|
||||||
+}
|
|
||||||
+
|
|
||||||
/*
|
|
||||||
* Figures out which interrupt(s) relate to the device we"re looking at in dirname
|
|
||||||
*/
|
|
||||||
@@ -686,6 +702,12 @@ struct irq_info *build_one_dev_entry(const char *dirname, GList *tmp_list)
|
|
||||||
add_banned_irq(irqnum, &banned_irqs, 0);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
+ if (!is_proc_irq_info_exist(irqnum, tmp_list)) {
|
|
||||||
+ continue;
|
|
||||||
+ }
|
|
||||||
+ if (need_add_single && need_add_single != irqnum) {
|
|
||||||
+ continue;
|
|
||||||
+ }
|
|
||||||
hint.irq = irqnum;
|
|
||||||
hint.type = IRQ_TYPE_MSIX;
|
|
||||||
new = add_one_irq_to_db(devpath, &hint, &pol);
|
|
||||||
@@ -723,6 +745,9 @@ struct irq_info *build_one_dev_entry(const char *dirname, GList *tmp_list)
|
|
||||||
add_banned_irq(irqnum, &banned_irqs, 0);
|
|
||||||
goto done;
|
|
||||||
}
|
|
||||||
+ if (!is_proc_irq_info_exist(irqnum, tmp_list)) {
|
|
||||||
+ goto done;
|
|
||||||
+ }
|
|
||||||
|
|
||||||
hint.irq = irqnum;
|
|
||||||
hint.type = IRQ_TYPE_LEGACY;
|
|
||||||
diff --git a/procinterrupts.c b/procinterrupts.c
|
|
||||||
index c32c1b2..f0dd608 100644
|
|
||||||
--- a/procinterrupts.c
|
|
||||||
+++ b/procinterrupts.c
|
|
||||||
@@ -43,6 +43,7 @@
|
|
||||||
static int proc_int_has_msi = 0;
|
|
||||||
static int msi_found_in_sysfs = 0;
|
|
||||||
extern int ban_pci_assigned_irq;
|
|
||||||
+int need_add_single = 0;
|
|
||||||
|
|
||||||
#ifdef AARCH64
|
|
||||||
struct irq_match {
|
|
||||||
@@ -361,9 +362,10 @@ void parse_proc_interrupts(void)
|
|
||||||
uint64_t count;
|
|
||||||
char *c, *c2;
|
|
||||||
struct irq_info *info;
|
|
||||||
- struct irq_info tmp_info;
|
|
||||||
- char savedline[1024];
|
|
||||||
+ struct irq_info tmp_info = {0};
|
|
||||||
+ char *savedline = NULL;
|
|
||||||
char dirname[PATH_MAX] = {'\0'};
|
|
||||||
+ struct irq_info *lookup;
|
|
||||||
|
|
||||||
if (getline(&line, &size, file)<=0)
|
|
||||||
break;
|
|
||||||
@@ -383,7 +385,9 @@ void parse_proc_interrupts(void)
|
|
||||||
if (!c)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
- strncpy(savedline, line, sizeof(savedline)-1);
|
|
||||||
+ savedline = strdup(line);
|
|
||||||
+ if (!savedline)
|
|
||||||
+ continue;
|
|
||||||
|
|
||||||
*c = 0;
|
|
||||||
c++;
|
|
||||||
@@ -391,23 +395,36 @@ void parse_proc_interrupts(void)
|
|
||||||
|
|
||||||
info = get_irq_info(number);
|
|
||||||
if (!info) {
|
|
||||||
+ init_irq_class_and_type(savedline, &tmp_info, number);
|
|
||||||
find_irq_dev_path(number, dirname, PATH_MAX);
|
|
||||||
if (strlen(dirname) > 0) {
|
|
||||||
+ need_add_single = number;
|
|
||||||
info = build_one_dev_entry(dirname, NULL);
|
|
||||||
+ need_add_single = 0;
|
|
||||||
+ lookup = get_irq_info(number);
|
|
||||||
+ if (lookup != NULL) {
|
|
||||||
+ lookup->existing = 1;
|
|
||||||
+ set_usr_irq_policy(tmp_info.name, lookup);
|
|
||||||
+ }
|
|
||||||
log(TO_CONSOLE, LOG_INFO, "new IRQ %d added into database, dirname %s\n", number, dirname);
|
|
||||||
} else {
|
|
||||||
- init_irq_class_and_type(savedline, &tmp_info, number);
|
|
||||||
info = add_new_irq(number, &tmp_info, NULL);
|
|
||||||
}
|
|
||||||
+ if (tmp_info.name) {
|
|
||||||
+ free(tmp_info.name);
|
|
||||||
+ tmp_info.name = NULL;
|
|
||||||
+ }
|
|
||||||
|
|
||||||
if (info) {
|
|
||||||
force_rebalance_irq(info, NULL);
|
|
||||||
log(TO_CONSOLE, LOG_INFO, "new IRQ %d added into rebalance list\n", number);
|
|
||||||
} else {
|
|
||||||
need_rescan = 1;
|
|
||||||
+ free(savedline);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
+ free(savedline);
|
|
||||||
info->existing = 1;
|
|
||||||
|
|
||||||
if (ban_pci_assigned_irq) {
|
|
||||||
diff --git a/rules_config.c b/rules_config.c
|
|
||||||
index 767e9e1..9313fc6 100644
|
|
||||||
--- a/rules_config.c
|
|
||||||
+++ b/rules_config.c
|
|
||||||
@@ -43,6 +43,10 @@ void set_usr_irq_policy(char *name, struct irq_info *info)
|
|
||||||
{
|
|
||||||
USER_IRQ_POLICY *user_policy;
|
|
||||||
|
|
||||||
+ if (user_policy_list == NULL) {
|
|
||||||
+ return;
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
user_policy = get_usr_irq_policy(name);
|
|
||||||
if (user_policy != NULL) {
|
|
||||||
if (user_policy->numa_node_set) {
|
|
||||||
--
|
|
||||||
2.19.1
|
|
||||||
|
|
||||||
@ -1,25 +0,0 @@
|
|||||||
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
|
|
||||||
|
|
||||||
@ -1,79 +0,0 @@
|
|||||||
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,64 +0,0 @@
|
|||||||
From f4d052d7b210612a7ffbdd7c3cfbce213c9a0e21 Mon Sep 17 00:00:00 2001
|
|
||||||
From: liuchao173 <liuchao173@huawei.com>
|
|
||||||
Date: Fri, 8 Nov 2019 08:47:43 +0000
|
|
||||||
Subject: [PATCH] irqbalance: fix strcat may cause buffer overrun
|
|
||||||
|
|
||||||
when the sum length of irq_name and saveptr is more than PATH_MAX, strcat will cause buffer overrun
|
|
||||||
---
|
|
||||||
procinterrupts.c | 26 ++++++++++++++++++--------
|
|
||||||
1 file changed, 18 insertions(+), 8 deletions(-)
|
|
||||||
|
|
||||||
diff --git a/procinterrupts.c b/procinterrupts.c
|
|
||||||
index 373d8b5..0b24b56 100644
|
|
||||||
--- a/procinterrupts.c
|
|
||||||
+++ b/procinterrupts.c
|
|
||||||
@@ -205,6 +205,7 @@ static void init_irq_class_and_type(char *savedline, struct irq_info *info, int
|
|
||||||
int is_xen_dyn = 0;
|
|
||||||
#ifdef AARCH64
|
|
||||||
char *tmp = NULL;
|
|
||||||
+ char irq_fullname_valid = 1;
|
|
||||||
char irq_fullname[PATH_MAX] = {0};
|
|
||||||
#endif
|
|
||||||
|
|
||||||
@@ -236,12 +237,16 @@ static void init_irq_class_and_type(char *savedline, struct irq_info *info, int
|
|
||||||
if (tmp)
|
|
||||||
*tmp = 0;
|
|
||||||
|
|
||||||
- strcat(irq_fullname, irq_name);
|
|
||||||
- strcat(irq_fullname, " ");
|
|
||||||
- strcat(irq_fullname, savedptr);
|
|
||||||
- tmp = strchr(irq_fullname, '\n');
|
|
||||||
- if (tmp)
|
|
||||||
- *tmp = 0;
|
|
||||||
+ if (strlen(irq_name) + strlen(savedptr) + 1 < PATH_MAX) {
|
|
||||||
+ strcat(irq_fullname, irq_name);
|
|
||||||
+ strcat(irq_fullname, " ");
|
|
||||||
+ strcat(irq_fullname, savedptr);
|
|
||||||
+ tmp = strchr(irq_fullname, '\n');
|
|
||||||
+ if (tmp)
|
|
||||||
+ *tmp = 0;
|
|
||||||
+ } else {
|
|
||||||
+ irq_fullname_valid = 0;
|
|
||||||
+ }
|
|
||||||
#endif
|
|
||||||
irq_mod = last_token;
|
|
||||||
info->irq = irq;
|
|
||||||
@@ -251,8 +256,13 @@ static void init_irq_class_and_type(char *savedline, struct irq_info *info, int
|
|
||||||
info->class = IRQ_VIRT_EVENT;
|
|
||||||
} else {
|
|
||||||
#ifdef AARCH64
|
|
||||||
- irq_name = irq_fullname;
|
|
||||||
- guess_arm_irq_hints(irq_name, info);
|
|
||||||
+ if (irq_fullname_valid) {
|
|
||||||
+ irq_name = irq_fullname;
|
|
||||||
+ guess_arm_irq_hints(irq_name, info);
|
|
||||||
+ } else {
|
|
||||||
+ info->type = IRQ_TYPE_LEGACY;
|
|
||||||
+ info->class = IRQ_OTHER;
|
|
||||||
+ }
|
|
||||||
#else
|
|
||||||
info->type = IRQ_TYPE_LEGACY;
|
|
||||||
info->class = IRQ_OTHER;
|
|
||||||
--
|
|
||||||
2.19.1
|
|
||||||
|
|
||||||
@ -1,35 +1,41 @@
|
|||||||
From 1ca314651ddc31cd52ef67893fdd7aac43ea5201 Mon Sep 17 00:00:00 2001
|
From a501662e98e2937cb63f3308d6497e723f838238 Mon Sep 17 00:00:00 2001
|
||||||
From: zhengshaoyu <zhengshaoyu@huawei.com>
|
From: liuchao <liuchao173@huawei.com>
|
||||||
Date: Thu, 22 Jun 2017 04:39:00 +0000
|
Date: Wed, 18 Mar 2020 22:08:33 +0800
|
||||||
Subject: [PATCH] irqbalance: bugfix popen and pclose
|
Subject: [PATCH] force irq into rebalance list when irq removed and reinserted
|
||||||
|
|
||||||
[Changelog]: bugfix popen and pclose
|
prevent irq may be inserted to rebalance list more than once and add one msi irq
|
||||||
[Author]:zhengshaoyu
|
at one time to prevent new msi irqs stay on one numa node
|
||||||
|
|
||||||
Date: Sun, 17 Mar 2019 20:07:28 -0400
|
|
||||||
|
|
||||||
---
|
---
|
||||||
classify.c | 126 ++++++++++++++++++++++++++++++++++++++++++++++++-------
|
classify.c | 154 +++++++++++++++++++++++++++++++++++++++++++++++++------
|
||||||
irqbalance.c | 2 +-
|
irqbalance.c | 6 ++-
|
||||||
irqbalance.h | 5 +++
|
irqbalance.h | 7 +++
|
||||||
procinterrupts.c | 112 +++++++++++++++++++++++++++++++------------------
|
procinterrupts.c | 145 ++++++++++++++++++++++++++++++++++-----------------
|
||||||
types.h | 1 +
|
types.h | 1 +
|
||||||
5 files changed, 190 insertions(+), 56 deletions(-)
|
5 files changed, 250 insertions(+), 63 deletions(-)
|
||||||
|
|
||||||
diff --git a/classify.c b/classify.c
|
diff --git a/classify.c b/classify.c
|
||||||
index 9868633..30a8d2a 100644
|
index b40fcc1..2dc93ca 100644
|
||||||
--- a/classify.c
|
--- a/classify.c
|
||||||
+++ b/classify.c
|
+++ b/classify.c
|
||||||
@@ -66,6 +66,8 @@ struct pci_info {
|
@@ -37,6 +37,7 @@ static GList *interrupts_dbs = NULL;
|
||||||
#define PCI_SUB_DEVICE_EMC_0568 0x0568
|
static GList *banned_irqs = NULL;
|
||||||
#define PCI_SUB_DEVICE_EMC_dd00 0xdd00
|
GList *cl_banned_irqs = NULL;
|
||||||
|
static GList *cl_banned_modules = NULL;
|
||||||
|
+extern int need_add_single;
|
||||||
|
|
||||||
+extern void force_rebalance_irq(struct irq_info *info, void *data __attribute__((unused)));
|
#define SYSFS_DIR "/sys"
|
||||||
+
|
#define SYSPCI_DIR "/sys/bus/pci/devices"
|
||||||
/*
|
@@ -259,7 +259,7 @@
|
||||||
* Apply software workarounds for some special devices
|
return irq_class;
|
||||||
*
|
}
|
||||||
@@ -562,11 +564,13 @@ static int check_for_irq_ban(char *path __attribute__((unused)), int irq, GList
|
|
||||||
|
-static gint compare_ints(gconstpointer a, gconstpointer b)
|
||||||
|
+gint compare_ints(gconstpointer a, gconstpointer b)
|
||||||
|
{
|
||||||
|
const struct irq_info *ai = a;
|
||||||
|
const struct irq_info *bi = b;
|
||||||
|
@@ -584,11 +585,13 @@ static int check_for_irq_ban(char *path __attribute__((unused)), int irq, GList
|
||||||
/*
|
/*
|
||||||
* Check to see if we banned module which the irq belongs to.
|
* Check to see if we banned module which the irq belongs to.
|
||||||
*/
|
*/
|
||||||
@ -48,7 +54,25 @@ index 9868633..30a8d2a 100644
|
|||||||
}
|
}
|
||||||
|
|
||||||
#ifdef INCLUDE_BANSCRIPT
|
#ifdef INCLUDE_BANSCRIPT
|
||||||
@@ -605,13 +609,14 @@ static int check_for_irq_ban(char *path __attribute__((unused)), int irq, GList
|
@@ -624,16 +627,32 @@ static int check_for_irq_ban(char *path __attribute__((unused)), int irq, GList
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
+int is_proc_irq_info_exist(int irq, GList *tmp_list)
|
||||||
|
+{
|
||||||
|
+ GList *entry;
|
||||||
|
+ struct irq_info find;
|
||||||
|
+
|
||||||
|
+ if (!tmp_list) {
|
||||||
|
+ return 1;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ find.irq = irq;
|
||||||
|
+ entry = g_list_find_custom(tmp_list, &find, compare_ints);
|
||||||
|
+
|
||||||
|
+ return entry ? 1 : 0;
|
||||||
|
+}
|
||||||
|
+
|
||||||
/*
|
/*
|
||||||
* Figures out which interrupt(s) relate to the device we"re looking at in dirname
|
* Figures out which interrupt(s) relate to the device we"re looking at in dirname
|
||||||
*/
|
*/
|
||||||
@ -65,16 +89,25 @@ index 9868633..30a8d2a 100644
|
|||||||
char path[PATH_MAX];
|
char path[PATH_MAX];
|
||||||
char devpath[PATH_MAX];
|
char devpath[PATH_MAX];
|
||||||
struct user_irq_policy pol;
|
struct user_irq_policy pol;
|
||||||
@@ -635,7 +640,7 @@ static void build_one_dev_entry(const char *dirname, GList *tmp_irqs)
|
@@ -657,10 +676,16 @@ static void build_one_dev_entry(const char *dirname, GList *tmp_irqs)
|
||||||
if (new)
|
if (new)
|
||||||
continue;
|
continue;
|
||||||
get_irq_user_policy(devpath, irqnum, &pol);
|
get_irq_user_policy(devpath, irqnum, &pol);
|
||||||
- if ((pol.ban == 1) || (check_for_irq_ban(devpath, irqnum, tmp_irqs))) {
|
- if ((pol.ban == 1) || (check_for_irq_ban(devpath, irqnum, tmp_irqs))) {
|
||||||
+ if ((pol.ban == 1) || (check_for_irq_ban(devpath, irqnum, tmp_list))) {
|
+ if ((pol.ban == 1) || (check_for_irq_ban(devpath, irqnum, tmp_list))) {
|
||||||
add_banned_irq(irqnum, &banned_irqs);
|
__add_banned_irq(irqnum, &banned_irqs);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@@ -647,13 +652,13 @@ static void build_one_dev_entry(const char *dirname, GList *tmp_irqs)
|
+ if (!is_proc_irq_info_exist(irqnum, tmp_list)) {
|
||||||
|
+ continue;
|
||||||
|
+ }
|
||||||
|
+ if (need_add_single && need_add_single != irqnum) {
|
||||||
|
+ continue;
|
||||||
|
+ }
|
||||||
|
hint.irq = irqnum;
|
||||||
|
hint.type = IRQ_TYPE_MSIX;
|
||||||
|
new = add_one_irq_to_db(devpath, &hint, &pol);
|
||||||
|
@@ -669,13 +694,13 @@ static void build_one_dev_entry(const char *dirname, GList *tmp_irqs)
|
||||||
}
|
}
|
||||||
} while (entry != NULL);
|
} while (entry != NULL);
|
||||||
closedir(msidir);
|
closedir(msidir);
|
||||||
@ -90,16 +123,22 @@ index 9868633..30a8d2a 100644
|
|||||||
if (fscanf(fd, "%d", &irqnum) < 0)
|
if (fscanf(fd, "%d", &irqnum) < 0)
|
||||||
goto done;
|
goto done;
|
||||||
|
|
||||||
@@ -670,7 +675,7 @@ static void build_one_dev_entry(const char *dirname, GList *tmp_irqs)
|
@@ -692,10 +717,13 @@ static void build_one_dev_entry(const char *dirname, GList *tmp_irqs)
|
||||||
if (new)
|
if (new)
|
||||||
goto done;
|
goto done;
|
||||||
get_irq_user_policy(devpath, irqnum, &pol);
|
get_irq_user_policy(devpath, irqnum, &pol);
|
||||||
- if ((pol.ban == 1) || (check_for_irq_ban(path, irqnum, tmp_irqs))) {
|
- if ((pol.ban == 1) || (check_for_irq_ban(devpath, irqnum, tmp_irqs))) {
|
||||||
+ if ((pol.ban == 1) || (check_for_irq_ban(path, irqnum, tmp_list))) {
|
+ if ((pol.ban == 1) || (check_for_irq_ban(devpath, irqnum, tmp_list))) {
|
||||||
add_banned_irq(irqnum, &banned_irqs);
|
__add_banned_irq(irqnum, &banned_irqs);
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
@@ -684,7 +689,56 @@ static void build_one_dev_entry(const char *dirname, GList *tmp_irqs)
|
+ if (!is_proc_irq_info_exist(irqnum, tmp_list)) {
|
||||||
|
+ goto done;
|
||||||
|
+ }
|
||||||
|
|
||||||
|
hint.irq = irqnum;
|
||||||
|
hint.type = IRQ_TYPE_LEGACY;
|
||||||
|
@@ -706,7 +734,60 @@ static void build_one_dev_entry(const char *dirname, GList *tmp_irqs)
|
||||||
|
|
||||||
done:
|
done:
|
||||||
fclose(fd);
|
fclose(fd);
|
||||||
@ -114,6 +153,7 @@ index 9868633..30a8d2a 100644
|
|||||||
+ char path[PATH_MAX];
|
+ char path[PATH_MAX];
|
||||||
+ char buffer[128];
|
+ char buffer[128];
|
||||||
+ char *brc = NULL;
|
+ char *brc = NULL;
|
||||||
|
+ size_t dirlen;
|
||||||
+
|
+
|
||||||
+ memset(dirname, 0, length);
|
+ memset(dirname, 0, length);
|
||||||
+ /* Return defaults if irq is 0 */
|
+ /* Return defaults if irq is 0 */
|
||||||
@ -129,8 +169,10 @@ index 9868633..30a8d2a 100644
|
|||||||
+ }
|
+ }
|
||||||
+
|
+
|
||||||
+ brc = fgets(buffer, 128, output);
|
+ brc = fgets(buffer, 128, output);
|
||||||
+ if (brc) {
|
+ /* fgets will get a redundant \n */
|
||||||
|
+ if (brc && (dirlen = strcspn(brc, "\n")) > 0) {
|
||||||
+ log(TO_CONSOLE, LOG_INFO, "msi_irqs IRQ %d dirname is %s\n", irq, brc);
|
+ log(TO_CONSOLE, LOG_INFO, "msi_irqs IRQ %d dirname is %s\n", irq, brc);
|
||||||
|
+ brc[dirlen] = '\0';
|
||||||
+ strncpy(dirname, brc, length);
|
+ strncpy(dirname, brc, length);
|
||||||
+ pclose(output);
|
+ pclose(output);
|
||||||
+ return;
|
+ return;
|
||||||
@ -146,8 +188,9 @@ index 9868633..30a8d2a 100644
|
|||||||
+ }
|
+ }
|
||||||
+
|
+
|
||||||
+ brc = fgets(buffer, 128, output);
|
+ brc = fgets(buffer, 128, output);
|
||||||
+ if (brc) {
|
+ if (brc && (dirlen = strcspn(brc, "\n")) > 0) {
|
||||||
+ log(TO_CONSOLE, LOG_INFO, "IRQ %d dirname is %s\n", irq, brc);
|
+ log(TO_CONSOLE, LOG_INFO, "IRQ %d dirname is %s\n", irq, brc);
|
||||||
|
+ brc[dirlen] = '\0';
|
||||||
+ strncpy(dirname, brc, length);
|
+ strncpy(dirname, brc, length);
|
||||||
+ pclose(output);
|
+ pclose(output);
|
||||||
+ return;
|
+ return;
|
||||||
@ -157,7 +200,7 @@ index 9868633..30a8d2a 100644
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void free_irq(struct irq_info *info, void *data __attribute__((unused)))
|
static void free_irq(struct irq_info *info, void *data __attribute__((unused)))
|
||||||
@@ -692,6 +750,42 @@ static void free_irq(struct irq_info *info, void *data __attribute__((unused)))
|
@@ -714,6 +795,45 @@ static void free_irq(struct irq_info *info, void *data __attribute__((unused)))
|
||||||
free(info);
|
free(info);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -195,12 +238,15 @@ index 9868633..30a8d2a 100644
|
|||||||
+void clear_no_existing_irqs(void)
|
+void clear_no_existing_irqs(void)
|
||||||
+{
|
+{
|
||||||
+ for_each_irq(NULL, remove_no_existing_irq, NULL);
|
+ 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)
|
void free_irq_db(void)
|
||||||
{
|
{
|
||||||
for_each_irq(NULL, free_irq, NULL);
|
for_each_irq(NULL, free_irq, NULL);
|
||||||
@@ -711,14 +805,14 @@ void free_cl_opts(void)
|
@@ -733,14 +853,14 @@ void free_cl_opts(void)
|
||||||
g_list_free(banned_irqs);
|
g_list_free(banned_irqs);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -218,7 +264,7 @@ index 9868633..30a8d2a 100644
|
|||||||
|
|
||||||
/* Set NULL devpath for the irq has no sysfs entries */
|
/* Set NULL devpath for the irq has no sysfs entries */
|
||||||
get_irq_user_policy(NULL, irq, &pol);
|
get_irq_user_policy(NULL, irq, &pol);
|
||||||
@@ -730,6 +824,8 @@ static void add_new_irq(int irq, struct irq_info *hint, GList *proc_interrupts)
|
@@ -752,6 +872,8 @@ static void add_new_irq(int irq, struct irq_info *hint, GList *proc_interrupts)
|
||||||
|
|
||||||
if (!new)
|
if (!new)
|
||||||
log(TO_CONSOLE, LOG_WARNING, "add_new_irq: Failed to add irq %d\n", irq);
|
log(TO_CONSOLE, LOG_WARNING, "add_new_irq: Failed to add irq %d\n", irq);
|
||||||
@ -228,10 +274,10 @@ index 9868633..30a8d2a 100644
|
|||||||
|
|
||||||
static void add_missing_irq(struct irq_info *info, void *attr)
|
static void add_missing_irq(struct irq_info *info, void *attr)
|
||||||
diff --git a/irqbalance.c b/irqbalance.c
|
diff --git a/irqbalance.c b/irqbalance.c
|
||||||
index 2f699b8..e375a1a 100644
|
index f965a2a..4d0a417 100644
|
||||||
--- a/irqbalance.c
|
--- a/irqbalance.c
|
||||||
+++ b/irqbalance.c
|
+++ b/irqbalance.c
|
||||||
@@ -238,7 +238,7 @@ static void dump_object_tree(void)
|
@@ -251,11 +251,15 @@ static void dump_object_tree(void)
|
||||||
for_each_object(numa_nodes, dump_numa_node_info, NULL);
|
for_each_object(numa_nodes, dump_numa_node_info, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -240,26 +286,45 @@ index 2f699b8..e375a1a 100644
|
|||||||
{
|
{
|
||||||
if (info->level == BALANCE_NONE)
|
if (info->level == BALANCE_NONE)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
+ /* Prevent inserting a duplicate entry to avoid list chaos */
|
||||||
|
+ if (g_list_find_custom(rebalance_irq_list, info, compare_ints))
|
||||||
|
+ return;
|
||||||
|
+
|
||||||
|
if (info->assigned_obj == NULL)
|
||||||
|
rebalance_irq_list = g_list_append(rebalance_irq_list, info);
|
||||||
|
else
|
||||||
diff --git a/irqbalance.h b/irqbalance.h
|
diff --git a/irqbalance.h b/irqbalance.h
|
||||||
index 8d5b329..73737ed 100644
|
index 3a78c7f..9e28285 100644
|
||||||
--- a/irqbalance.h
|
--- a/irqbalance.h
|
||||||
+++ b/irqbalance.h
|
+++ b/irqbalance.h
|
||||||
@@ -107,6 +107,10 @@ extern void free_cl_opts(void);
|
@@ -109,6 +109,13 @@ extern void add_banned_irq(int irq);
|
||||||
extern void add_cl_banned_module(char *modname);
|
extern void remove_one_irq_from_db(int irq);
|
||||||
#define irq_numa_node(irq) ((irq)->numa_node)
|
#define irq_numa_node(irq) ((irq)->numa_node)
|
||||||
|
|
||||||
+extern struct irq_info *build_one_dev_entry(const char *dirname, GList *tmp_list);
|
+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 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 struct irq_info *add_new_irq(int irq, struct irq_info *hint, GList *proc_interrupts);
|
||||||
+extern void clear_no_existing_irqs(void);
|
+extern void clear_no_existing_irqs(void);
|
||||||
|
+extern void force_rebalance_irq(struct irq_info *info, void *data __attribute__((unused)));
|
||||||
|
+extern gint compare_ints(gconstpointer a, gconstpointer b);
|
||||||
|
+
|
||||||
|
extern unsigned long migrate_val;
|
||||||
|
extern unsigned long load_limit;
|
||||||
/*
|
/*
|
||||||
* Generic object functions
|
|
||||||
diff --git a/procinterrupts.c b/procinterrupts.c
|
diff --git a/procinterrupts.c b/procinterrupts.c
|
||||||
index eb84a1c..d384860 100644
|
index 70831b4..358458c 100644
|
||||||
--- a/procinterrupts.c
|
--- a/procinterrupts.c
|
||||||
+++ b/procinterrupts.c
|
+++ b/procinterrupts.c
|
||||||
@@ -142,6 +142,52 @@ static void guess_arm_irq_hints(char *name, struct irq_info *info)
|
@@ -42,6 +42,7 @@
|
||||||
|
|
||||||
|
static int proc_int_has_msi = 0;
|
||||||
|
static int msi_found_in_sysfs = 0;
|
||||||
|
+int need_add_single = 0;
|
||||||
|
|
||||||
|
#ifdef AARCH64
|
||||||
|
struct irq_match {
|
||||||
|
@@ -144,6 +145,52 @@ static void guess_arm_irq_hints(char *name, struct irq_info *info)
|
||||||
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@ -312,7 +377,7 @@ index eb84a1c..d384860 100644
|
|||||||
|
|
||||||
GList* collect_full_irq_list()
|
GList* collect_full_irq_list()
|
||||||
{
|
{
|
||||||
@@ -149,10 +187,6 @@ GList* collect_full_irq_list()
|
@@ -151,10 +198,6 @@ GList* collect_full_irq_list()
|
||||||
FILE *file;
|
FILE *file;
|
||||||
char *line = NULL;
|
char *line = NULL;
|
||||||
size_t size = 0;
|
size_t size = 0;
|
||||||
@ -323,15 +388,15 @@ index eb84a1c..d384860 100644
|
|||||||
|
|
||||||
file = fopen("/proc/interrupts", "r");
|
file = fopen("/proc/interrupts", "r");
|
||||||
if (!file)
|
if (!file)
|
||||||
@@ -168,7 +206,6 @@ GList* collect_full_irq_list()
|
@@ -169,7 +212,6 @@ GList* collect_full_irq_list()
|
||||||
|
|
||||||
while (!feof(file)) {
|
while (!feof(file)) {
|
||||||
int number;
|
int number;
|
||||||
- int is_xen_dyn = 0;
|
- int is_xen_dyn = 0;
|
||||||
struct irq_info *info;
|
struct irq_info *info;
|
||||||
char *c;
|
char *c;
|
||||||
char *savedline = NULL;
|
char *savedline = NULL;
|
||||||
@@ -188,45 +222,13 @@ GList* collect_full_irq_list()
|
@@ -191,45 +233,13 @@ GList* collect_full_irq_list()
|
||||||
savedline = strdup(line);
|
savedline = strdup(line);
|
||||||
if (!savedline)
|
if (!savedline)
|
||||||
break;
|
break;
|
||||||
@ -378,7 +443,7 @@ index eb84a1c..d384860 100644
|
|||||||
tmp_list = g_list_append(tmp_list, info);
|
tmp_list = g_list_append(tmp_list, info);
|
||||||
}
|
}
|
||||||
free(savedline);
|
free(savedline);
|
||||||
@@ -230,6 +235,14 @@ GList* collect_full_irq_list()
|
@@ -239,6 +249,14 @@ GList* collect_full_irq_list()
|
||||||
return tmp_list;
|
return tmp_list;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -393,44 +458,70 @@ index eb84a1c..d384860 100644
|
|||||||
void parse_proc_interrupts(void)
|
void parse_proc_interrupts(void)
|
||||||
{
|
{
|
||||||
FILE *file;
|
FILE *file;
|
||||||
@@ -253,7 +266,9 @@ void parse_proc_interrupts(void)
|
@@ -262,7 +280,10 @@ void parse_proc_interrupts(void)
|
||||||
uint64_t count;
|
uint64_t count;
|
||||||
char *c, *c2;
|
char *c, *c2;
|
||||||
struct irq_info *info;
|
struct irq_info *info;
|
||||||
+ struct irq_info tmp_info;
|
- char savedline[1024];
|
||||||
char savedline[1024];
|
+ struct irq_info tmp_info = {0};
|
||||||
|
+ char *savedline = NULL;
|
||||||
+ char dirname[PATH_MAX] = {'\0'};
|
+ char dirname[PATH_MAX] = {'\0'};
|
||||||
|
+ struct irq_info *lookup;
|
||||||
|
|
||||||
if (getline(&line, &size, file)==0)
|
if (getline(&line, &size, file)<=0)
|
||||||
break;
|
break;
|
||||||
@@ -281,9 +296,24 @@ void parse_proc_interrupts(void)
|
@@ -282,7 +303,9 @@ void parse_proc_interrupts(void)
|
||||||
|
if (!c)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
- strncpy(savedline, line, sizeof(savedline)-1);
|
||||||
|
+ savedline = strdup(line);
|
||||||
|
+ if (!savedline)
|
||||||
|
+ continue;
|
||||||
|
|
||||||
|
*c = 0;
|
||||||
|
c++;
|
||||||
|
@@ -290,9 +313,37 @@ void parse_proc_interrupts(void)
|
||||||
|
|
||||||
info = get_irq_info(number);
|
info = get_irq_info(number);
|
||||||
if (!info) {
|
if (!info) {
|
||||||
- need_rescan = 1;
|
- need_rescan = 1;
|
||||||
- break;
|
- break;
|
||||||
|
+ init_irq_class_and_type(savedline, &tmp_info, number);
|
||||||
+ find_irq_dev_path(number, dirname, PATH_MAX);
|
+ find_irq_dev_path(number, dirname, PATH_MAX);
|
||||||
+ if (strlen(dirname) > 0) {
|
+ if (strlen(dirname) > 0) {
|
||||||
|
+ need_add_single = number;
|
||||||
+ info = build_one_dev_entry(dirname, NULL);
|
+ info = build_one_dev_entry(dirname, NULL);
|
||||||
|
+ need_add_single = 0;
|
||||||
|
+ lookup = get_irq_info(number);
|
||||||
|
+ if (lookup != NULL) {
|
||||||
|
+ lookup->existing = 1;
|
||||||
|
+ info = lookup;
|
||||||
|
+ }
|
||||||
+ log(TO_CONSOLE, LOG_INFO, "new IRQ %d added into database, dirname %s\n", number, dirname);
|
+ log(TO_CONSOLE, LOG_INFO, "new IRQ %d added into database, dirname %s\n", number, dirname);
|
||||||
+ } else {
|
+ } else {
|
||||||
+ init_irq_class_and_type(savedline, &tmp_info, number);
|
|
||||||
+ info = add_new_irq(number, &tmp_info, NULL);
|
+ info = add_new_irq(number, &tmp_info, NULL);
|
||||||
+ }
|
+ }
|
||||||
|
+ if (tmp_info.name) {
|
||||||
|
+ free(tmp_info.name);
|
||||||
|
+ tmp_info.name = NULL;
|
||||||
|
+ }
|
||||||
+
|
+
|
||||||
+ if (info) {
|
+ if (info) {
|
||||||
+ force_rebalance_irq(info, NULL);
|
+ force_rebalance_irq(info, NULL);
|
||||||
+ log(TO_CONSOLE, LOG_INFO, "new IRQ %d added into rebalance list\n", number);
|
+ log(TO_CONSOLE, LOG_INFO, "new IRQ %d added into rebalance list\n", number);
|
||||||
+ } else {
|
+ } else {
|
||||||
+ need_rescan = 1;
|
+ need_rescan = 1;
|
||||||
|
+ free(savedline);
|
||||||
+ break;
|
+ break;
|
||||||
+ }
|
+ }
|
||||||
}
|
}
|
||||||
|
+ free(savedline);
|
||||||
+ info->existing = 1;
|
+ info->existing = 1;
|
||||||
|
|
||||||
count = 0;
|
count = 0;
|
||||||
cpunr = 0;
|
cpunr = 0;
|
||||||
@@ -307,17 +337,19 @@ void parse_proc_interrupts(void)
|
@@ -316,17 +367,19 @@ void parse_proc_interrupts(void)
|
||||||
* cause an overflow and IRQ won't be rebalanced again
|
* cause an overflow and IRQ won't be rebalanced again
|
||||||
*/
|
*/
|
||||||
if (count < info->irq_count) {
|
if (count < info->irq_count) {
|
||||||
|
|||||||
@ -1,125 +0,0 @@
|
|||||||
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
|
|
||||||
wrong, that's because the way we forbid starting
|
|
||||||
multiple irqbalance instances is wrong.
|
|
||||||
|
|
||||||
Here we use fcntl to lock pid file to forbid another instance
|
|
||||||
been launched.
|
|
||||||
|
|
||||||
Signed-off-by: zhanghailiang <zhang.zhanghailiang@huawei.com>
|
|
||||||
---
|
|
||||||
irqbalance.c | 83 ++++++++++++++++++++++++++++++++++++++++++++++++++++++------
|
|
||||||
1 file changed, 75 insertions(+), 8 deletions(-)
|
|
||||||
|
|
||||||
diff --git a/irqbalance.c b/irqbalance.c
|
|
||||||
index 18cd7de..467e968 100644
|
|
||||||
--- a/irqbalance.c
|
|
||||||
+++ b/irqbalance.c
|
|
||||||
@@ -560,6 +560,78 @@ int init_socket()
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
+static int create_lock_pidfile(const char *lockfile)
|
|
||||||
+{
|
|
||||||
+ struct flock lock = { 0 };
|
|
||||||
+ char pid_s[16] = { 0 };
|
|
||||||
+ int lf = 0;
|
|
||||||
+ int err = -1;
|
|
||||||
+
|
|
||||||
+ lf = open(lockfile, O_WRONLY | O_CREAT, S_IRUSR | S_IWUSR);
|
|
||||||
+ if (lf == -1) {
|
|
||||||
+ err = -errno;
|
|
||||||
+ log(TO_ALL, LOG_WARNING, "irqbalance (%u): Can't create lock file.\n",
|
|
||||||
+ getpid());
|
|
||||||
+ return err;
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+retry_fcntl:
|
|
||||||
+ lock.l_type = F_WRLCK;
|
|
||||||
+ lock.l_start = 0;
|
|
||||||
+ lock.l_whence = SEEK_SET;
|
|
||||||
+ lock.l_len = 0;
|
|
||||||
+ if (fcntl (lf, F_SETLK, &lock) == -1) {
|
|
||||||
+ err = -errno;
|
|
||||||
+ switch (errno) {
|
|
||||||
+ case EINTR:
|
|
||||||
+ goto retry_fcntl;
|
|
||||||
+ case EAGAIN:
|
|
||||||
+ case EACCES:
|
|
||||||
+ log(TO_ALL, LOG_WARNING, "irqbalance (%u): Another instance is"
|
|
||||||
+ " already running, errno:%d.\n", getpid(), errno);
|
|
||||||
+ goto error_close;
|
|
||||||
+ default:
|
|
||||||
+ log(TO_ALL, LOG_WARNING, "irqbalance (%u): Can't aquire lock."
|
|
||||||
+ " errno %d.\n", getpid(), errno);
|
|
||||||
+ goto error_close;
|
|
||||||
+ }
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ if (ftruncate(lf, 0) == -1) {
|
|
||||||
+ err = -errno;
|
|
||||||
+ log(TO_ALL, LOG_WARNING, "irqbalance (%u): Can't truncate lock file."
|
|
||||||
+ " errno: %d.\n", getpid(), errno);
|
|
||||||
+ goto error_close_unlink;
|
|
||||||
+ }
|
|
||||||
+ if (snprintf(pid_s, sizeof(pid_s), "%u\n", getpid()) < 0) {
|
|
||||||
+ log(TO_ALL, LOG_WARNING, "irqbalance (%u): Can't printf pid string.\n", getpid());
|
|
||||||
+ err = -1;
|
|
||||||
+ goto error_close_unlink;
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+retry_write:
|
|
||||||
+ if ((size_t)write(lf, pid_s, strlen (pid_s)) != strlen (pid_s)) {
|
|
||||||
+ err = -errno;
|
|
||||||
+ if (errno == EINTR) {
|
|
||||||
+ goto retry_write;
|
|
||||||
+ } else {
|
|
||||||
+ log(TO_ALL, LOG_WARNING, "irqbalance (%u): Can't write pid to lock"
|
|
||||||
+ " file. errno %d\n", getpid(), errno);
|
|
||||||
+ goto error_close_unlink;
|
|
||||||
+ }
|
|
||||||
+ }
|
|
||||||
+ close(lf);
|
|
||||||
+ return 0;
|
|
||||||
+
|
|
||||||
+error_close_unlink:
|
|
||||||
+ (void) unlink(lockfile);
|
|
||||||
+
|
|
||||||
+error_close:
|
|
||||||
+ close(lf);
|
|
||||||
+ return err;
|
|
||||||
+}
|
|
||||||
+
|
|
||||||
+
|
|
||||||
int main(int argc, char** argv)
|
|
||||||
{
|
|
||||||
sigset_t sigset, old_sigset;
|
|
||||||
@@ -652,17 +724,12 @@ int main(int argc, char** argv)
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!foreground_mode) {
|
|
||||||
- int pidfd = -1;
|
|
||||||
if (daemon(0,0))
|
|
||||||
exit(EXIT_FAILURE);
|
|
||||||
/* Write pidfile */
|
|
||||||
- if (pidfile && (pidfd = open(pidfile,
|
|
||||||
- O_WRONLY | O_CREAT | O_EXCL | O_TRUNC,
|
|
||||||
- S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH)) >= 0) {
|
|
||||||
- char str[16];
|
|
||||||
- snprintf(str, sizeof(str), "%u\n", getpid());
|
|
||||||
- write(pidfd, str, strlen(str));
|
|
||||||
- close(pidfd);
|
|
||||||
+ if (pidfile && create_lock_pidfile(pidfile) < 0) {
|
|
||||||
+ ret = EXIT_FAILURE;
|
|
||||||
+ goto out;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
--
|
|
||||||
1.8.3.1
|
|
||||||
|
|
||||||
@ -1,27 +0,0 @@
|
|||||||
From cea147fc56b018266ac3235b82cdaf7d0ba74628 Mon Sep 17 00:00:00 2001
|
|
||||||
From: hejingxian <hejingxian@huawei.com>
|
|
||||||
Date: Fri, 10 Jan 2020 15:36:57 +0800
|
|
||||||
Subject: [PATCH] prevent version cmd need an argument
|
|
||||||
|
|
||||||
In order to prevent the version cmd need an argument,
|
|
||||||
the option 'V' can't be followed by ':'.
|
|
||||||
---
|
|
||||||
irqbalance.c | 2 +-
|
|
||||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
|
||||||
|
|
||||||
diff --git a/irqbalance.c b/irqbalance.c
|
|
||||||
index 15fb0fe..f182b3c 100644
|
|
||||||
--- a/irqbalance.c
|
|
||||||
+++ b/irqbalance.c
|
|
||||||
@@ -133,7 +133,7 @@ static void parse_command_line(int argc, char **argv)
|
|
||||||
unsigned long val;
|
|
||||||
|
|
||||||
while ((opt = getopt_long(argc, argv,
|
|
||||||
- "odfji:p:s:c:b:l:m:t:V:h:v:r:ne:g:",
|
|
||||||
+ "odfjVni:p:s:c:b:l:m:t:h:v:r:e:g:",
|
|
||||||
lopts, &longind)) != -1) {
|
|
||||||
|
|
||||||
switch(opt) {
|
|
||||||
--
|
|
||||||
1.8.3.1
|
|
||||||
|
|
||||||
@ -16,12 +16,12 @@ index 7c97d47..3681c48 100644
|
|||||||
--- a/classify.c
|
--- a/classify.c
|
||||||
+++ b/classify.c
|
+++ b/classify.c
|
||||||
@@ -719,7 +719,7 @@ struct irq_info *build_one_dev_entry(const char *dirname, GList *tmp_list)
|
@@ -719,7 +719,7 @@ struct irq_info *build_one_dev_entry(const char *dirname, GList *tmp_list)
|
||||||
if (user_policy_list == NULL) {
|
if (new)
|
||||||
get_irq_user_policy(devpath, irqnum, &pol);
|
goto done;
|
||||||
}
|
get_irq_user_policy(devpath, irqnum, &pol);
|
||||||
- if ((pol.ban == 1) || (check_for_irq_ban(path, irqnum, tmp_list))) {
|
- if ((pol.ban == 1) || (check_for_irq_ban(path, irqnum, tmp_irqs))) {
|
||||||
+ if ((pol.ban == 1) || (check_for_irq_ban(devpath, irqnum, tmp_list))) {
|
+ if ((pol.ban == 1) || (check_for_irq_ban(devpath, irqnum, tmp_irqs))) {
|
||||||
add_banned_irq(irqnum, &banned_irqs, 0);
|
add_banned_irq(irqnum, &banned_irqs);
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
--
|
--
|
||||||
@ -11,7 +11,6 @@ for every irq.
|
|||||||
classify.c | 32 +++++++--
|
classify.c | 32 +++++++--
|
||||||
irqbalance.c | 38 +++++----
|
irqbalance.c | 38 +++++----
|
||||||
irqbalance.h | 2 +-
|
irqbalance.h | 2 +-
|
||||||
misc/irqbalance.service | 2 +-
|
|
||||||
placement.c | 3 +-
|
placement.c | 3 +-
|
||||||
procinterrupts.c | 3 +-
|
procinterrupts.c | 3 +-
|
||||||
rules_config.c | 172 ++++++++++++++++++++++++++++++++++++++++++++++++
|
rules_config.c | 172 ++++++++++++++++++++++++++++++++++++++++++++++++
|
||||||
@ -55,7 +54,7 @@ index 65aeae2..7c97d47 100644
|
|||||||
+ get_irq_user_policy(devpath, irqnum, &pol);
|
+ get_irq_user_policy(devpath, irqnum, &pol);
|
||||||
+ }
|
+ }
|
||||||
if ((pol.ban == 1) || (check_for_irq_ban(devpath, irqnum, tmp_list))) {
|
if ((pol.ban == 1) || (check_for_irq_ban(devpath, irqnum, tmp_list))) {
|
||||||
add_banned_irq(irqnum, &banned_irqs, 0);
|
__add_banned_irq(irqnum, &banned_irqs, 0);
|
||||||
continue;
|
continue;
|
||||||
@@ -714,7 +716,9 @@ struct irq_info *build_one_dev_entry(const char *dirname, GList *tmp_list)
|
@@ -714,7 +716,9 @@ struct irq_info *build_one_dev_entry(const char *dirname, GList *tmp_list)
|
||||||
new = get_irq_info(irqnum);
|
new = get_irq_info(irqnum);
|
||||||
@ -65,10 +64,10 @@ index 65aeae2..7c97d47 100644
|
|||||||
+ if (user_policy_list == NULL) {
|
+ if (user_policy_list == NULL) {
|
||||||
+ get_irq_user_policy(devpath, irqnum, &pol);
|
+ get_irq_user_policy(devpath, irqnum, &pol);
|
||||||
+ }
|
+ }
|
||||||
if ((pol.ban == 1) || (check_for_irq_ban(path, irqnum, tmp_list))) {
|
if ((pol.ban == 1) || (check_for_irq_ban(devpath, irqnum, tmp_list))) {
|
||||||
add_banned_irq(irqnum, &banned_irqs, 0);
|
__add_banned_irq(irqnum, &banned_irqs, 0);
|
||||||
goto done;
|
goto done;
|
||||||
@@ -855,18 +859,24 @@ struct irq_info *add_new_irq(int irq, struct irq_info *hint, GList *proc_interru
|
@@ -855,17 +859,23 @@ struct irq_info *add_new_irq(int irq, struct irq_info *hint, GList *proc_interru
|
||||||
struct irq_info *new = NULL;
|
struct irq_info *new = NULL;
|
||||||
struct user_irq_policy pol;
|
struct user_irq_policy pol;
|
||||||
|
|
||||||
@ -83,28 +82,23 @@ index 65aeae2..7c97d47 100644
|
|||||||
+ get_irq_user_policy(NULL, irq, &pol);
|
+ get_irq_user_policy(NULL, irq, &pol);
|
||||||
+ }
|
+ }
|
||||||
if ((pol.ban == 1) || check_for_irq_ban(NULL, irq, proc_interrupts)) { /*FIXME*/
|
if ((pol.ban == 1) || check_for_irq_ban(NULL, irq, proc_interrupts)) { /*FIXME*/
|
||||||
add_banned_irq(irq, &banned_irqs, 0);
|
__add_banned_irq(irq, &banned_irqs, 0);
|
||||||
new = get_irq_info(irq);
|
new = get_irq_info(irq);
|
||||||
- } else
|
- } else
|
||||||
+ } else {
|
+ } else {
|
||||||
new = add_one_irq_to_db(NULL, hint, &pol);
|
new = add_one_irq_to_db(NULL, hint, &pol);
|
||||||
-
|
+ if (new != NULL)
|
||||||
+ if ((new != NULL) && (user_policy_list != NULL)) {
|
|
||||||
+ set_usr_irq_policy(hint->name, new);
|
+ set_usr_irq_policy(hint->name, new);
|
||||||
+ }
|
|
||||||
+ }
|
+ }
|
||||||
|
|
||||||
if (!new)
|
if (!new)
|
||||||
log(TO_CONSOLE, LOG_WARNING, "add_new_irq: Failed to add irq %d\n", irq);
|
log(TO_CONSOLE, LOG_WARNING, "add_new_irq: Failed to add irq %d\n", irq);
|
||||||
|
@@ -880,6 +890,13 @@ static void add_missing_irq(struct irq_info *info, void *attr)
|
||||||
@@ -880,6 +890,16 @@ static void add_missing_irq(struct irq_info *info, void *attr)
|
|
||||||
|
|
||||||
if (!lookup)
|
if (!lookup)
|
||||||
add_new_irq(info->irq, info, proc_interrupts);
|
add_new_irq(info->irq, info, proc_interrupts);
|
||||||
+ else {
|
+ else
|
||||||
+ if (user_policy_list != NULL) {
|
+ set_usr_irq_policy(info->name, lookup);
|
||||||
+ set_usr_irq_policy(info->name, lookup);
|
|
||||||
+ }
|
|
||||||
+ }
|
|
||||||
+ if (info->name) {
|
+ if (info->name) {
|
||||||
+ free(info->name);
|
+ free(info->name);
|
||||||
+ info->name = NULL;
|
+ info->name = NULL;
|
||||||
@ -118,34 +112,33 @@ index 21d578a..d41753c 100644
|
|||||||
--- a/irqbalance.c
|
--- a/irqbalance.c
|
||||||
+++ b/irqbalance.c
|
+++ b/irqbalance.c
|
||||||
@@ -99,6 +99,7 @@ struct option lopts[] = {
|
@@ -99,6 +99,7 @@ struct option lopts[] = {
|
||||||
{"banmod", 1 , NULL, 'm'},
|
|
||||||
{"interval", 1 , NULL, 't'},
|
|
||||||
{"version", 0, NULL, 'V'},
|
{"version", 0, NULL, 'V'},
|
||||||
|
{"migrateval", 1, NULL, 'e'},
|
||||||
|
{"loadlimit", 1, NULL, 'g'},
|
||||||
+ {"rulesconfig", 1, NULL, 'r'},
|
+ {"rulesconfig", 1, NULL, 'r'},
|
||||||
{0, 0, 0, 0}
|
{0, 0, 0, 0}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -106,7 +107,7 @@ static void usage(void)
|
@@ -106,6 +107,7 @@ static void usage(void)
|
||||||
{
|
log(TO_CONSOLE, LOG_INFO, "irqbalance [--oneshot | -o] [--debug | -d] [--foreground | -f] [--journal | -j] [--hintpolicy= | -h [exact|subset|ignore]]\n");
|
||||||
log(TO_CONSOLE, LOG_INFO, "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, " [--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>] [--migrateval= | -e <n>] [--loadlimit= | -g <n>]\n");
|
||||||
- log(TO_CONSOLE, LOG_INFO, " [--pid= | -s <file>] [--deepestcache= | -c <n>] [--interval= | -t <n>]\n");
|
+ log(TO_CONSOLE, LOG_INFO, " [--rulesconfig= | -r <config>]\n");
|
||||||
+ log(TO_CONSOLE, LOG_INFO, " [--pid= | -s <file>] [--deepestcache= | -c <n>] [--interval= | -t <n>] [--rulesconfig= | -r <config>]\n");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void version(void)
|
static void version(void)
|
||||||
@@ -121,7 +122,7 @@ static void parse_command_line(int argc, char **argv)
|
@@ -121,7 +123,7 @@ static void parse_command_line(int argc, char **argv)
|
||||||
unsigned long val;
|
unsigned long val;
|
||||||
|
|
||||||
while ((opt = getopt_long(argc, argv,
|
while ((opt = getopt_long(argc, argv,
|
||||||
- "odfji:p:s:c:b:l:m:t:V",
|
- "odfjVi:p:s:c:b:l:m:t:e:g:",
|
||||||
+ "odfji:p:s:c:b:l:m:t:V:r",
|
+ "odfjVi:p:s:c:b:l:m:t:e:g:r:",
|
||||||
lopts, &longind)) != -1) {
|
lopts, &longind)) != -1) {
|
||||||
|
|
||||||
switch(opt) {
|
switch(opt) {
|
||||||
@@ -201,6 +202,9 @@ static void parse_command_line(int argc, char **argv)
|
@@ -201,6 +203,9 @@ static void parse_command_line(int argc, char **argv)
|
||||||
exit(1);
|
case 'g':
|
||||||
}
|
load_limit = strtoul(optarg, NULL, 10);
|
||||||
break;
|
break;
|
||||||
+ case 'r':
|
+ case 'r':
|
||||||
+ rules_config_file = strdup(optarg);
|
+ rules_config_file = strdup(optarg);
|
||||||
@ -153,21 +146,10 @@ index 21d578a..d41753c 100644
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -539,6 +543,25 @@ int main(int argc, char** argv)
|
@@ -539,6 +544,14 @@ int main(int argc, char** argv)
|
||||||
log(TO_ALL, LOG_WARNING, "Unable to determin HZ defaulting to 100\n");
|
close(pidfd);
|
||||||
HZ = 100;
|
}
|
||||||
}
|
}
|
||||||
+ if (!foreground_mode) {
|
|
||||||
+ if (daemon(0,0)) {
|
|
||||||
+ ret = EXIT_FAILURE;
|
|
||||||
+ goto out;
|
|
||||||
+ }
|
|
||||||
+ /* Write pidfile */
|
|
||||||
+ if (pidfile && create_lock_pidfile(pidfile) < 0) {
|
|
||||||
+ ret = EXIT_FAILURE;
|
|
||||||
+ goto out;
|
|
||||||
+ }
|
|
||||||
+ }
|
|
||||||
+
|
+
|
||||||
+ if (read_user_policy_config() != 0) {
|
+ if (read_user_policy_config() != 0) {
|
||||||
+ log(TO_ALL, LOG_WARNING, "Read user policy config fail.\n");
|
+ log(TO_ALL, LOG_WARNING, "Read user policy config fail.\n");
|
||||||
@ -179,23 +161,6 @@ index 21d578a..d41753c 100644
|
|||||||
|
|
||||||
build_object_tree();
|
build_object_tree();
|
||||||
if (debug_mode)
|
if (debug_mode)
|
||||||
@@ -554,16 +573,6 @@ int main(int argc, char** argv)
|
|
||||||
goto out;
|
|
||||||
}
|
|
||||||
|
|
||||||
- if (!foreground_mode) {
|
|
||||||
- if (daemon(0,0))
|
|
||||||
- exit(EXIT_FAILURE);
|
|
||||||
- /* Write pidfile */
|
|
||||||
- if (pidfile && create_lock_pidfile(pidfile) < 0) {
|
|
||||||
- ret = EXIT_FAILURE;
|
|
||||||
- goto out;
|
|
||||||
- }
|
|
||||||
- }
|
|
||||||
-
|
|
||||||
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)
|
@@ -589,6 +598,7 @@ int main(int argc, char** argv)
|
||||||
ret = EXIT_FAILURE;
|
ret = EXIT_FAILURE;
|
||||||
goto out;
|
goto out;
|
||||||
@ -217,19 +182,6 @@ index 120bc9b..42f95cb 100644
|
|||||||
#ifdef __aarch64__
|
#ifdef __aarch64__
|
||||||
#define AARCH64
|
#define AARCH64
|
||||||
#endif
|
#endif
|
||||||
diff --git a/misc/irqbalance.service b/misc/irqbalance.service
|
|
||||||
index ce0022c..2c002b2 100644
|
|
||||||
--- a/misc/irqbalance.service
|
|
||||||
+++ b/misc/irqbalance.service
|
|
||||||
@@ -5,7 +5,7 @@ After=syslog.target
|
|
||||||
|
|
||||||
[Service]
|
|
||||||
OOMScoreAdjust=-500
|
|
||||||
-Type=simple
|
|
||||||
+Type=forking
|
|
||||||
PIDFile=/var/run/irqbalance.pid
|
|
||||||
EnvironmentFile=/etc/sysconfig/irqbalance
|
|
||||||
ExecStart=/usr/sbin/irq_balancer
|
|
||||||
diff --git a/placement.c b/placement.c
|
diff --git a/placement.c b/placement.c
|
||||||
index 19462bb..d887c60 100644
|
index 19462bb..d887c60 100644
|
||||||
--- a/placement.c
|
--- a/placement.c
|
||||||
@ -248,22 +200,29 @@ diff --git a/procinterrupts.c b/procinterrupts.c
|
|||||||
index 60b2545..18b3ceb 100644
|
index 60b2545..18b3ceb 100644
|
||||||
--- a/procinterrupts.c
|
--- a/procinterrupts.c
|
||||||
+++ b/procinterrupts.c
|
+++ b/procinterrupts.c
|
||||||
@@ -245,7 +245,8 @@ static void init_irq_class_and_type(char *savedline, struct irq_info *info, int
|
@@ -245,7 +245,7 @@ static void init_irq_class_and_type(char *savedline, struct irq_info *info, int
|
||||||
info->class = IRQ_OTHER;
|
info->class = IRQ_OTHER;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
- info->name = strdupa(irq_mod);
|
- info->name = strdupa(irq_mod);
|
||||||
+
|
|
||||||
+ info->name = strdup(irq_mod);
|
+ info->name = strdup(irq_mod);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@@ -391,6 +391,7 @@ void parse_proc_interrupts(void)
|
||||||
|
lookup = get_irq_info(number);
|
||||||
|
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);
|
||||||
diff --git a/rules_config.c b/rules_config.c
|
diff --git a/rules_config.c b/rules_config.c
|
||||||
new file mode 100644
|
new file mode 100644
|
||||||
index 0000000..1270ac7
|
index 0000000..1270ac7
|
||||||
--- /dev/null
|
--- /dev/null
|
||||||
+++ b/rules_config.c
|
+++ b/rules_config.c
|
||||||
@@ -0,0 +1,172 @@
|
@@ -0,0 +1,176 @@
|
||||||
+/*
|
+/*
|
||||||
+ * Copyright (C) 2019. Huawei Technologies Co., Ltd. All rights reserved.
|
+ * Copyright (C) 2019. Huawei Technologies Co., Ltd. All rights reserved.
|
||||||
+ *
|
+ *
|
||||||
@ -311,6 +270,10 @@ index 0000000..1270ac7
|
|||||||
+{
|
+{
|
||||||
+ USER_IRQ_POLICY *user_policy;
|
+ USER_IRQ_POLICY *user_policy;
|
||||||
+
|
+
|
||||||
|
+ if (user_policy_list == NULL) {
|
||||||
|
+ return;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
+ user_policy = get_usr_irq_policy(name);
|
+ user_policy = get_usr_irq_policy(name);
|
||||||
+ if (user_policy != NULL) {
|
+ if (user_policy != NULL) {
|
||||||
+ if (user_policy->numa_node_set) {
|
+ if (user_policy->numa_node_set) {
|
||||||
|
|||||||
@ -80,10 +80,10 @@ index 05eaa29..77076fa 100644
|
|||||||
unsigned int log_mask = TO_ALL;
|
unsigned int log_mask = TO_ALL;
|
||||||
const char *log_indent;
|
const char *log_indent;
|
||||||
unsigned long power_thresh = ULONG_MAX;
|
unsigned long power_thresh = ULONG_MAX;
|
||||||
@@ -104,14 +105,16 @@ struct option lopts[] = {
|
@@ -104,15 +105,16 @@ struct option lopts[] = {
|
||||||
{"version", 0, NULL, 'V'},
|
{"loadlimit", 1, NULL, 'g'},
|
||||||
{"verifyhint", 1, NULL, 'v'},
|
|
||||||
{"rulesconfig", 1, NULL, 'r'},
|
{"rulesconfig", 1, NULL, 'r'},
|
||||||
|
{"verifyhint", 1, NULL, 'v'},
|
||||||
+ {"notclearhint", 0, NULL, 'n'},
|
+ {"notclearhint", 0, NULL, 'n'},
|
||||||
{0, 0, 0, 0}
|
{0, 0, 0, 0}
|
||||||
};
|
};
|
||||||
@ -92,9 +92,9 @@ index 05eaa29..77076fa 100644
|
|||||||
{
|
{
|
||||||
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 <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, " [--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>] [--migrateval= | -e <n>] [--loadlimit= | -g <n>]\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>] [--verifyhint= | -v n]\n");
|
||||||
+ log(TO_CONSOLE, LOG_INFO, " [--rulesconfig= | -r <config>] [--notclearhint | -n]\n");
|
+ log(TO_CONSOLE, LOG_INFO, " [--rulesconfig= | -r <config>] [--verifyhint= | -v n] [--notclearhint | -n]\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
static void version(void)
|
static void version(void)
|
||||||
@ -102,19 +102,18 @@ index 05eaa29..77076fa 100644
|
|||||||
unsigned long val;
|
unsigned long val;
|
||||||
|
|
||||||
while ((opt = getopt_long(argc, argv,
|
while ((opt = getopt_long(argc, argv,
|
||||||
- "odfji:p:s:c:b:l:m:t:V:h:v:r:",
|
- "odfjVi:p:s:c:b:l:m:t:e:g:r:h:v:",
|
||||||
+ "odfji:p:s:c:b:l:m:t:V:h:v:r:n",
|
+ "odfjVni:p:s:c:b:l:m:t:e:g:r:h:v:",
|
||||||
lopts, &longind)) != -1) {
|
lopts, &longind)) != -1) {
|
||||||
|
|
||||||
switch(opt) {
|
switch(opt) {
|
||||||
@@ -225,6 +227,10 @@ static void parse_command_line(int argc, char **argv)
|
@@ -225,6 +227,9 @@ static void parse_command_line(int argc, char **argv)
|
||||||
case 'r':
|
case 'r':
|
||||||
rules_config_file = strdup(optarg);
|
rules_config_file = strdup(optarg);
|
||||||
break;
|
break;
|
||||||
+ case 'n':
|
+ case 'n':
|
||||||
+ clear_affinity_hint = 0;
|
+ clear_affinity_hint = 0;
|
||||||
+ break;
|
+ break;
|
||||||
+
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -13,11 +13,11 @@ Signed-off-by: He Jingxian <hejingxian@huawei.com>
|
|||||||
irqbalance.c | 4 +-
|
irqbalance.c | 4 +-
|
||||||
irqbalance.h | 2 +-
|
irqbalance.h | 2 +-
|
||||||
ui/Makefile | 30 ++++
|
ui/Makefile | 30 ++++
|
||||||
ui/client.c | 434 +++++++++++++++++++++++++++++++++++++++++++++++++
|
ui/client.c | 435 +++++++++++++++++++++++++++++++++++++++++++++++++
|
||||||
ui/irqbalance-ui.c | 4 +-
|
ui/irqbalance-ui.c | 4 +-
|
||||||
ui/irqbalance-ui.h | 1 +
|
ui/irqbalance-ui.h | 1 +
|
||||||
ui/irqbalance_client.h | 111 +++++++++++++
|
ui/irqbalance_client.h | 111 +++++++++++++
|
||||||
7 files changed, 581 insertions(+), 5 deletions(-)
|
7 files changed, 582 insertions(+), 5 deletions(-)
|
||||||
create mode 100644 ui/Makefile
|
create mode 100644 ui/Makefile
|
||||||
create mode 100644 ui/client.c
|
create mode 100644 ui/client.c
|
||||||
create mode 100644 ui/irqbalance_client.h
|
create mode 100644 ui/irqbalance_client.h
|
||||||
@ -94,7 +94,7 @@ new file mode 100644
|
|||||||
index 0000000..027404b
|
index 0000000..027404b
|
||||||
--- /dev/null
|
--- /dev/null
|
||||||
+++ b/ui/client.c
|
+++ b/ui/client.c
|
||||||
@@ -0,0 +1,434 @@
|
@@ -0,0 +1,435 @@
|
||||||
+/*
|
+/*
|
||||||
+ * Copyright (C) 2020. Huawei Technologies Co., Ltd. All rights reserved.
|
+ * Copyright (C) 2020. Huawei Technologies Co., Ltd. All rights reserved.
|
||||||
+ *
|
+ *
|
||||||
@ -452,6 +452,7 @@ index 0000000..027404b
|
|||||||
+ if (stats_data == NULL)
|
+ if (stats_data == NULL)
|
||||||
+ return NULL;
|
+ return NULL;
|
||||||
+ parse_into_tree(stats_data);
|
+ parse_into_tree(stats_data);
|
||||||
|
+ free(stats_data);
|
||||||
+ return tree;
|
+ return tree;
|
||||||
+}
|
+}
|
||||||
+
|
+
|
||||||
|
|||||||
@ -37,22 +37,21 @@ diff --git a/activate.c b/activate.c
|
|||||||
index d9e1fc3..87336f4 100644
|
index d9e1fc3..87336f4 100644
|
||||||
--- a/activate.c
|
--- a/activate.c
|
||||||
+++ b/activate.c
|
+++ b/activate.c
|
||||||
@@ -88,26 +88,26 @@ static void activate_mapping(struct irq_info *info, void *data __attribute__((un
|
@@ -88,20 +88,27 @@ static void activate_mapping(struct irq_info *info, void *data __attribute__((un
|
||||||
char buf[PATH_MAX];
|
char buf[PATH_MAX];
|
||||||
FILE *file;
|
FILE *file;
|
||||||
cpumask_t applied_mask;
|
int ret = 0;
|
||||||
- int valid_mask = 0;
|
+ cpumask_t applied_mask;
|
||||||
|
|
||||||
- /*
|
- /*
|
||||||
- * only activate mappings for irqs that have moved
|
- * only activate mappings for irqs that have moved
|
||||||
- */
|
- */
|
||||||
- if (!info->moved)
|
- if (!info->moved)
|
||||||
+ if (!info->assigned_obj)
|
- return;
|
||||||
|
-
|
||||||
|
if (!info->assigned_obj)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
- if (info->assigned_obj) {
|
|
||||||
- applied_mask = info->assigned_obj->mask;
|
|
||||||
- valid_mask = 1;
|
|
||||||
+ applied_mask = info->assigned_obj->mask;
|
+ applied_mask = info->assigned_obj->mask;
|
||||||
+
|
+
|
||||||
+ if (hint_enabled) {
|
+ if (hint_enabled) {
|
||||||
@ -63,32 +62,29 @@ index d9e1fc3..87336f4 100644
|
|||||||
+ return;
|
+ return;
|
||||||
+ }
|
+ }
|
||||||
+ }
|
+ }
|
||||||
}
|
+ }
|
||||||
|
+
|
||||||
/*
|
/*
|
||||||
* Don't activate anything for which we have an invalid mask
|
* Don't activate anything for which we have an invalid mask
|
||||||
*/
|
*/
|
||||||
- if (!valid_mask || check_affinity(info, applied_mask))
|
- if (check_affinity(info, info->assigned_obj->mask))
|
||||||
- return;
|
|
||||||
-
|
|
||||||
- if (!info->assigned_obj)
|
|
||||||
+ if (check_affinity(info, applied_mask))
|
+ if (check_affinity(info, applied_mask))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
sprintf(buf, "/proc/irq/%i/smp_affinity", info->irq);
|
sprintf(buf, "/proc/irq/%i/smp_affinity", info->irq);
|
||||||
|
@@ -120,7 +120,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);
|
||||||
|
if (ban_pci_assigned_irq) {
|
||||||
|
if (!is_still_pci_assigned_irq(info->irq)) {
|
||||||
|
ret = fprintf(file, "%s", buf);
|
||||||
diff --git a/classify.c b/classify.c
|
diff --git a/classify.c b/classify.c
|
||||||
index 5aed9e5..75677f4 100644
|
index 5aed9e5..75677f4 100644
|
||||||
--- a/classify.c
|
--- a/classify.c
|
||||||
+++ b/classify.c
|
+++ b/classify.c
|
||||||
@@ -71,8 +71,6 @@ struct pci_info {
|
|
||||||
#define PCI_SUB_DEVICE_EMC_0568 0x0568
|
|
||||||
#define PCI_SUB_DEVICE_EMC_dd00 0xdd00
|
|
||||||
|
|
||||||
-extern void force_rebalance_irq(struct irq_info *info, void *data __attribute__((unused)));
|
|
||||||
-
|
|
||||||
/*
|
|
||||||
* Apply software workarounds for some special devices
|
|
||||||
*
|
|
||||||
@@ -448,7 +446,7 @@ get_numa_node:
|
@@ -448,7 +446,7 @@ get_numa_node:
|
||||||
fd = fopen(path, "r");
|
fd = fopen(path, "r");
|
||||||
if (!fd) {
|
if (!fd) {
|
||||||
@ -338,15 +334,14 @@ index faa8e6a..4a7eb39 100644
|
|||||||
int last_interval;
|
int last_interval;
|
||||||
+int hint_enabled = 0;
|
+int hint_enabled = 0;
|
||||||
+int poll_hint_interval = SLEEP_INTERVAL / 5;
|
+int poll_hint_interval = SLEEP_INTERVAL / 5;
|
||||||
|
unsigned long migrate_val = 0;
|
||||||
|
unsigned long load_limit = 0;
|
||||||
GMainLoop *main_loop;
|
GMainLoop *main_loop;
|
||||||
|
|
||||||
char *cpu_ban_string = NULL;
|
|
||||||
@@ -99,15 +101,16 @@ struct option lopts[] = {
|
@@ -99,15 +101,16 @@ struct option lopts[] = {
|
||||||
{"banmod", 1 , NULL, 'm'},
|
{"migrateval", 1, NULL, 'e'},
|
||||||
{"interval", 1 , NULL, 't'},
|
{"loadlimit", 1, NULL, 'g'},
|
||||||
{"version", 0, NULL, 'V'},
|
|
||||||
+ {"verifyhint", 1, NULL, 'v'},
|
|
||||||
{"rulesconfig", 1, NULL, 'r'},
|
{"rulesconfig", 1, NULL, 'r'},
|
||||||
|
+ {"verifyhint", 1, NULL, 'v'},
|
||||||
{0, 0, 0, 0}
|
{0, 0, 0, 0}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -355,8 +350,9 @@ index faa8e6a..4a7eb39 100644
|
|||||||
- 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 [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, "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, " [--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>] [--migrateval= | -e <n>] [--loadlimit= | -g <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, " [--rulesconfig= | -r <config>]\n");
|
||||||
|
+ log(TO_CONSOLE, LOG_INFO, " [--rulesconfig= | -r <config>] [--verifyhint= | -v n]\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
static void version(void)
|
static void version(void)
|
||||||
@ -364,14 +360,14 @@ index faa8e6a..4a7eb39 100644
|
|||||||
unsigned long val;
|
unsigned long val;
|
||||||
|
|
||||||
while ((opt = getopt_long(argc, argv,
|
while ((opt = getopt_long(argc, argv,
|
||||||
- "odfji:p:s:c:b:l:m:t:V:r",
|
- "odfjVi:p:s:c:b:l:m:t:e:g:r:",
|
||||||
+ "odfji:p:s:c:b:l:m:t:V:h:v:r:",
|
+ "odfjVi:p:s:c:b:l:m:t:e:g:r:h:v:",
|
||||||
lopts, &longind)) != -1) {
|
lopts, &longind)) != -1) {
|
||||||
|
|
||||||
switch(opt) {
|
switch(opt) {
|
||||||
@@ -202,6 +205,22 @@ static void parse_command_line(int argc, char **argv)
|
@@ -202,6 +205,22 @@ static void parse_command_line(int argc, char **argv)
|
||||||
exit(1);
|
case 'g':
|
||||||
}
|
load_limit = strtoul(optarg, NULL, 10);
|
||||||
break;
|
break;
|
||||||
+ case 'h':
|
+ case 'h':
|
||||||
+ if (!strncmp(optarg, "subset", strlen(optarg)))
|
+ if (!strncmp(optarg, "subset", strlen(optarg)))
|
||||||
@ -444,23 +440,15 @@ index 1befb46..72e141b 100644
|
|||||||
#ifdef __aarch64__
|
#ifdef __aarch64__
|
||||||
#define AARCH64
|
#define AARCH64
|
||||||
#endif
|
#endif
|
||||||
@@ -113,6 +114,7 @@ extern void migrate_irq(GList **from, GList **to, struct irq_info *info);
|
@@ -120,6 +122,8 @@ extern gint compare_ints(gconstpointer a, gconstpointer b);
|
||||||
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);
|
extern unsigned long migrate_val;
|
||||||
@@ -120,6 +122,8 @@ extern struct irq_info *build_one_dev_entry(const char *dirname, GList *tmp_list
|
extern unsigned long load_limit;
|
||||||
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 hint_enabled, poll_hint_interval;
|
||||||
+extern int sleep_interval;
|
+extern int sleep_interval;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Generic object functions
|
* Generic object functions
|
||||||
|
*/
|
||||||
diff --git a/placement.c b/placement.c
|
diff --git a/placement.c b/placement.c
|
||||||
index 48ac68b..d887c60 100644
|
index 48ac68b..d887c60 100644
|
||||||
--- a/placement.c
|
--- a/placement.c
|
||||||
|
|||||||
@ -125,21 +125,19 @@ index dc8307d..1774eda 100644
|
|||||||
static void sleep_approx(int seconds)
|
static void sleep_approx(int seconds)
|
||||||
{
|
{
|
||||||
@@ -109,6 +111,7 @@ struct option lopts[] = {
|
@@ -109,6 +111,7 @@ struct option lopts[] = {
|
||||||
|
{"rulesconfig", 1, NULL, 'r'},
|
||||||
|
{"verifyhint", 1, NULL, 'v'},
|
||||||
{"notclearhint", 0, NULL, 'n'},
|
{"notclearhint", 0, NULL, 'n'},
|
||||||
{"migrateval", 1, NULL, 'e'},
|
|
||||||
{"loadlimit", 1, NULL, 'g'},
|
|
||||||
+ {"blocksocket", 0, NULL, 'k'},
|
+ {"blocksocket", 0, NULL, 'k'},
|
||||||
{0, 0, 0, 0}
|
{0, 0, 0, 0}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -116,8 +119,8 @@ static void usage(void)
|
@@ -116,7 +119,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 <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, " [--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>] [--migrateval= | -e <n>] [--loadlimit= | -g <n>]\n");
|
||||||
- log(TO_CONSOLE, LOG_INFO, " [--rulesconfig= | -r <config>] [--notclearhint | -n] [--migrateval= | -e <n>] [--loadlimit= | -g <n>]\n");
|
- log(TO_CONSOLE, LOG_INFO, " [--rulesconfig= | -r <config>] [--verifyhint= | -v n] [--notclearhint | -n]\n");
|
||||||
+ log(TO_CONSOLE, LOG_INFO, " [--pid= | -s <file>] [--deepestcache= | -c <n>] [--interval= | -t <n>] [--verifyhint= | -v n] [--blocksocket | -k]\n");
|
+ log(TO_CONSOLE, LOG_INFO, " [--rulesconfig= | -r <config>] [--verifyhint= | -v n] [--notclearhint | -n] [--blocksocket | -k]\n");
|
||||||
+ log(TO_CONSOLE, LOG_INFO, " [--rulesconfig= | -r <config>] [--notclearhint | -n] [--migrateval= | -e <n>] [--loadlimit= | -g <n>]\n");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void version(void)
|
static void version(void)
|
||||||
@ -147,16 +145,15 @@ index dc8307d..1774eda 100644
|
|||||||
unsigned long val;
|
unsigned long val;
|
||||||
|
|
||||||
while ((opt = getopt_long(argc, argv,
|
while ((opt = getopt_long(argc, argv,
|
||||||
- "odfjVni:p:s:c:b:l:m:t:h:v:r:e:g:",
|
- "odfjVni:p:s:c:b:l:m:t:e:g:r:h:v:",
|
||||||
+ "odfjVni:p:s:c:b:l:m:t:h:v:r:e:g:k",
|
+ "odfjVnki:p:s:c:b:l:m:t:e:g:r:h:v:",
|
||||||
lopts, &longind)) != -1) {
|
lopts, &longind)) != -1) {
|
||||||
|
|
||||||
switch(opt) {
|
switch(opt) {
|
||||||
@@ -240,7 +243,9 @@ static void parse_command_line(int argc, char **argv)
|
@@ -240,6 +243,9 @@ static void parse_command_line(int argc, char **argv)
|
||||||
case 'g':
|
case 'n':
|
||||||
load_limit = strtoul(optarg, NULL, 10);
|
clear_affinity_hint = 0;
|
||||||
break;
|
break;
|
||||||
-
|
|
||||||
+ case 'k':
|
+ case 'k':
|
||||||
+ use_unblock_socket = 0;
|
+ use_unblock_socket = 0;
|
||||||
+ break;
|
+ break;
|
||||||
|
|||||||
@ -31,10 +31,11 @@ index fc4641a..99bcf50 100644
|
|||||||
{ "[A-Z0-9]{4}[0-9a-f]{4}", {NULL} ,check_platform_device, IRQ_TYPE_LEGACY, IRQ_OTHER},
|
{ "[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},
|
{ "PNP[0-9a-f]{4}", {NULL} ,check_platform_device, IRQ_TYPE_LEGACY, IRQ_OTHER},
|
||||||
{ ".*", {NULL}, NULL, IRQ_TYPE_LEGACY, IRQ_OTHER},
|
{ ".*", {NULL}, NULL, IRQ_TYPE_LEGACY, IRQ_OTHER},
|
||||||
@@ -152,6 +154,7 @@ static void init_irq_class_and_type(char *savedline, struct irq_info *info, int
|
@@ -152,6 +154,8 @@ static void init_irq_class_and_type(char *savedline, struct irq_info *info, int
|
||||||
int is_xen_dyn = 0;
|
int is_xen_dyn = 0;
|
||||||
#ifdef AARCH64
|
#ifdef AARCH64
|
||||||
char *tmp = NULL;
|
char *tmp = NULL;
|
||||||
|
+ char irq_fullname_valid = 1;
|
||||||
+ char irq_fullname[PATH_MAX] = {0};
|
+ char irq_fullname[PATH_MAX] = {0};
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -56,28 +57,39 @@ index fc4641a..99bcf50 100644
|
|||||||
}
|
}
|
||||||
|
|
||||||
#ifdef AARCH64
|
#ifdef AARCH64
|
||||||
@@ -171,6 +184,13 @@ static void init_irq_class_and_type(char *savedline, struct irq_info *info, int
|
@@ -171,6 +184,17 @@ static void init_irq_class_and_type(char *savedline, struct irq_info *info, int
|
||||||
tmp = strchr(irq_name, '\n');
|
tmp = strchr(irq_name, '\n');
|
||||||
if (tmp)
|
if (tmp)
|
||||||
*tmp = 0;
|
*tmp = 0;
|
||||||
+
|
+
|
||||||
+ strcat(irq_fullname, irq_name);
|
+ if (strlen(irq_name) + strlen(savedptr) + 1 < PATH_MAX) {
|
||||||
+ strcat(irq_fullname, " ");
|
+ strcat(irq_fullname, irq_name);
|
||||||
+ strcat(irq_fullname, savedptr);
|
+ strcat(irq_fullname, " ");
|
||||||
+ tmp = strchr(irq_fullname, '\n');
|
+ strcat(irq_fullname, savedptr);
|
||||||
+ if (tmp)
|
+ tmp = strchr(irq_fullname, '\n');
|
||||||
+ *tmp = 0;
|
+ if (tmp)
|
||||||
|
+ *tmp = 0;
|
||||||
|
+ } else {
|
||||||
|
+ irq_fullname_valid = 0;
|
||||||
|
+ }
|
||||||
#endif
|
#endif
|
||||||
irq_mod = last_token;
|
irq_mod = last_token;
|
||||||
info->irq = irq;
|
info->irq = irq;
|
||||||
@@ -180,6 +200,7 @@ static void init_irq_class_and_type(char *savedline, struct irq_info *info, int
|
@@ -180,7 +200,13 @@ static void init_irq_class_and_type(char *savedline, struct irq_info *info, int
|
||||||
info->class = IRQ_VIRT_EVENT;
|
info->class = IRQ_VIRT_EVENT;
|
||||||
} else {
|
} else {
|
||||||
#ifdef AARCH64
|
#ifdef AARCH64
|
||||||
+ irq_name = irq_fullname;
|
- guess_arm_irq_hints(irq_name, info);
|
||||||
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
|
#else
|
||||||
info->type = IRQ_TYPE_LEGACY;
|
info->type = IRQ_TYPE_LEGACY;
|
||||||
|
info->class = IRQ_OTHER;
|
||||||
--
|
--
|
||||||
1.8.3.1
|
1.8.3.1
|
||||||
|
|
||||||
|
|||||||
@ -1,131 +0,0 @@
|
|||||||
From 0ddf835e21b4d33aba9d30755cc5674d1ee5a979 Mon Sep 17 00:00:00 2001
|
|
||||||
From: Zengruan Ye <yezengruan@huawei.com>
|
|
||||||
Date: Sat, 13 Jul 2019 19:12:29 +0800
|
|
||||||
Subject: [PATCH 2/6] feature: irqbalance: arm64: Add irq aff change check
|
|
||||||
|
|
||||||
For aarch64, the PPIs format in /proc/interrputs can be parsed
|
|
||||||
and add to interrupt db, and next, the number of interrupts
|
|
||||||
is counted and used to calculate the load. Finally these interrupts
|
|
||||||
maybe scheduled between the NUMA domains.
|
|
||||||
|
|
||||||
Acctually, the PPIs cannot change aff, and it should not be added
|
|
||||||
to interrupt db. This patch fix it.
|
|
||||||
|
|
||||||
Add a check before add a interrupt to db, just only reads the irq's
|
|
||||||
aff, and write it back to avoid any impact on the system,
|
|
||||||
According to the result of writing to fitler the irq.
|
|
||||||
|
|
||||||
Signed-off-by: wanghaibin <wanghaibin.wang@huawei.com>
|
|
||||||
---
|
|
||||||
classify.c | 7 +++++++
|
|
||||||
irqbalance.h | 3 +++
|
|
||||||
procinterrupts.c | 54 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
|
||||||
3 files changed, 64 insertions(+)
|
|
||||||
|
|
||||||
diff --git a/classify.c b/classify.c
|
|
||||||
index 3a25d62..65cb4e5 100644
|
|
||||||
--- a/classify.c
|
|
||||||
+++ b/classify.c
|
|
||||||
@@ -299,6 +299,13 @@ static void add_banned_irq(int irq, GList **list, int extra_flag)
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
+#ifdef AARCH64
|
|
||||||
+void add_banned_list_irq(int irq)
|
|
||||||
+{
|
|
||||||
+ add_banned_irq(irq, &banned_irqs);
|
|
||||||
+}
|
|
||||||
+#endif
|
|
||||||
+
|
|
||||||
void add_cl_banned_irq(int irq)
|
|
||||||
{
|
|
||||||
add_banned_irq(irq, &cl_banned_irqs);
|
|
||||||
diff --git a/irqbalance.h b/irqbalance.h
|
|
||||||
index 821de0e..c00430f 100644
|
|
||||||
--- a/irqbalance.h
|
|
||||||
+++ b/irqbalance.h
|
|
||||||
@@ -100,6 +100,9 @@ extern int get_cpu_count(void);
|
|
||||||
extern void rebuild_irq_db(void);
|
|
||||||
extern void free_irq_db(void);
|
|
||||||
extern void add_cl_banned_irq(int irq);
|
|
||||||
+#ifdef AARCH64
|
|
||||||
+extern void add_banned_list_irq(int irq);
|
|
||||||
+#endif
|
|
||||||
extern void for_each_irq(GList *list, void (*cb)(struct irq_info *info, void *data), void *data);
|
|
||||||
extern struct irq_info *get_irq_info(int irq);
|
|
||||||
extern void migrate_irq(GList **from, GList **to, struct irq_info *info);
|
|
||||||
diff --git a/procinterrupts.c b/procinterrupts.c
|
|
||||||
index 9e38e49..1f04a82 100644
|
|
||||||
--- a/procinterrupts.c
|
|
||||||
+++ b/procinterrupts.c
|
|
||||||
@@ -142,6 +142,42 @@ static void guess_arm_irq_hints(char *name, struct irq_info *info)
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
+
|
|
||||||
+/*
|
|
||||||
+ * 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
|
|
||||||
+ * of writing to fitler the irq.
|
|
||||||
+ * Return 0 means the irq can change aff. Other return values, on the contrary.
|
|
||||||
+ */
|
|
||||||
+static int is_arm_irq_aff_cannot_change(int irq)
|
|
||||||
+{
|
|
||||||
+ char buf[PATH_MAX] = { 0 };
|
|
||||||
+ FILE *file = NULL;
|
|
||||||
+ char *line = NULL;
|
|
||||||
+ size_t size = 0;
|
|
||||||
+ int ret = 0;
|
|
||||||
+
|
|
||||||
+ snprintf(buf, PATH_MAX - 1, "/proc/irq/%i/smp_affinity", irq);
|
|
||||||
+ file = fopen(buf, "r+");
|
|
||||||
+ if (!file)
|
|
||||||
+ return -1;
|
|
||||||
+
|
|
||||||
+ if (getline(&line, &size, file) <= 0) {
|
|
||||||
+ ret = -1;
|
|
||||||
+ goto out;
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ line[strlen(line) - 1] = '\0';
|
|
||||||
+
|
|
||||||
+ fprintf(file, "%s", line);
|
|
||||||
+ ret = fflush(file);
|
|
||||||
+
|
|
||||||
+out:
|
|
||||||
+ free(line);
|
|
||||||
+ fclose(file);
|
|
||||||
+
|
|
||||||
+ return ret;
|
|
||||||
+}
|
|
||||||
#endif
|
|
||||||
static void init_irq_class_and_type(char *savedline, struct irq_info *info, int irq) {
|
|
||||||
char *irq_name = NULL;
|
|
||||||
@@ -233,6 +269,24 @@ GList* collect_full_irq_list()
|
|
||||||
c++;
|
|
||||||
number = strtoul(line, NULL, 10);
|
|
||||||
|
|
||||||
+#ifdef AARCH64
|
|
||||||
+ if (is_arm_irq_aff_cannot_change(number)) {
|
|
||||||
+ /*
|
|
||||||
+ * This means that the irq affinity cannot be changed, just like:
|
|
||||||
+ * (1) the irq with IRQF_PERCPU flag, per cpu irq (in arm64, like PPI)
|
|
||||||
+ * (2) the irq with IRQD_NO_BALANCING flag, some driver request irq can
|
|
||||||
+ * set the flag according to themselves require. for example in arm64,
|
|
||||||
+ * for the passthrough doorbell irq (GICV4), in future.
|
|
||||||
+ * (3) the irq with IRQD_AFFINITY_MANAGED flag, some drivers can set
|
|
||||||
+ * specially irq affinity, and prohibit user to modify it.
|
|
||||||
+ *
|
|
||||||
+ * For these irqs, we can add these to banned irq list.
|
|
||||||
+ */
|
|
||||||
+ add_banned_list_irq(number);
|
|
||||||
+ continue;
|
|
||||||
+ }
|
|
||||||
+#endif
|
|
||||||
+
|
|
||||||
info = calloc(sizeof(struct irq_info), 1);
|
|
||||||
if (info) {
|
|
||||||
init_irq_class_and_type(savedline, info, number);
|
|
||||||
--
|
|
||||||
1.8.3.1
|
|
||||||
|
|
||||||
@ -66,21 +66,21 @@ index 1c4b867..ad60fde 100644
|
|||||||
@@ -89,7 +116,16 @@ static void activate_mapping(struct irq_info *info, void *data __attribute__((un
|
@@ -89,7 +116,16 @@ static void activate_mapping(struct irq_info *info, void *data __attribute__((un
|
||||||
return;
|
return;
|
||||||
|
|
||||||
cpumask_scnprintf(buf, PATH_MAX, applied_mask);
|
cpumask_scnprintf(buf, PATH_MAX, info->assigned_obj->mask);
|
||||||
- fprintf(file, "%s", buf);
|
- ret = fprintf(file, "%s", buf);
|
||||||
+ if (ban_pci_assigned_irq) {
|
+ if (ban_pci_assigned_irq) {
|
||||||
+ if (!is_still_pci_assigned_irq(info->irq)) {
|
+ if (!is_still_pci_assigned_irq(info->irq)) {
|
||||||
+ fprintf(file, "%s", buf);
|
+ ret = fprintf(file, "%s", buf);
|
||||||
+ } else {
|
+ } else {
|
||||||
+ log(TO_CONSOLE, LOG_INFO, "IRQ %d is turned into a PCI-assigned irq number.\n", info->irq);
|
+ log(TO_CONSOLE, LOG_INFO, "IRQ %d is turned into a PCI-assigned irq number.\n", info->irq);
|
||||||
+ need_rescan = 1;
|
+ need_rescan = 1;
|
||||||
+ }
|
+ }
|
||||||
+ } else {
|
+ } else {
|
||||||
+ fprintf(file, "%s", buf);
|
+ ret = fprintf(file, "%s", buf);
|
||||||
+ }
|
+ }
|
||||||
fclose(file);
|
if (ret < 0) {
|
||||||
info->moved = 0; /*migration is done*/
|
log(TO_ALL, LOG_WARNING, "cannot change irq %i's affinity, add it to banned list", info->irq);
|
||||||
}
|
add_banned_irq(info->irq);
|
||||||
diff --git a/classify.c b/classify.c
|
diff --git a/classify.c b/classify.c
|
||||||
index 37bfb29..52fd74a 100644
|
index 37bfb29..52fd74a 100644
|
||||||
--- a/classify.c
|
--- a/classify.c
|
||||||
@ -90,15 +90,15 @@ index 37bfb29..52fd74a 100644
|
|||||||
GList *cl_banned_irqs = NULL;
|
GList *cl_banned_irqs = NULL;
|
||||||
static GList *cl_banned_modules = NULL;
|
static GList *cl_banned_modules = NULL;
|
||||||
+static GList *vm_banned_irqs = NULL;
|
+static GList *vm_banned_irqs = NULL;
|
||||||
|
extern int need_add_single;
|
||||||
|
|
||||||
#define SYSFS_DIR "/sys"
|
#define SYSFS_DIR "/sys"
|
||||||
#define SYSPCI_DIR "/sys/bus/pci/devices"
|
|
||||||
@@ -264,7 +265,7 @@ static gint compare_ints(gconstpointer a, gconstpointer b)
|
@@ -264,7 +265,7 @@ static gint compare_ints(gconstpointer a, gconstpointer b)
|
||||||
return ai->irq - bi->irq;
|
return ai->irq - bi->irq;
|
||||||
}
|
}
|
||||||
|
|
||||||
-static void add_banned_irq(int irq, GList **list)
|
-static void __add_banned_irq(int irq, GList **list)
|
||||||
+static void add_banned_irq(int irq, GList **list, int extra_flag)
|
+static void __add_banned_irq(int irq, GList **list, int extra_flag)
|
||||||
{
|
{
|
||||||
struct irq_info find, *new;
|
struct irq_info find, *new;
|
||||||
GList *entry;
|
GList *entry;
|
||||||
@ -110,24 +110,23 @@ index 37bfb29..52fd74a 100644
|
|||||||
|
|
||||||
*list = g_list_append(*list, new);
|
*list = g_list_append(*list, new);
|
||||||
log(TO_CONSOLE, LOG_INFO, "IRQ %d was BANNED.\n", irq);
|
log(TO_CONSOLE, LOG_INFO, "IRQ %d was BANNED.\n", irq);
|
||||||
@@ -291,13 +293,18 @@ static void add_banned_irq(int irq, GList **list)
|
@@ -291,12 +293,17 @@ static void __add_banned_irq(int irq, GList **list)
|
||||||
#ifdef AARCH64
|
|
||||||
void add_banned_list_irq(int irq)
|
void add_banned_irq(int irq)
|
||||||
{
|
{
|
||||||
- add_banned_irq(irq, &banned_irqs);
|
- __add_banned_irq(irq, &banned_irqs);
|
||||||
+ add_banned_irq(irq, &banned_irqs, 0);
|
+ __add_banned_irq(irq, &banned_irqs, 0);
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
void add_cl_banned_irq(int irq)
|
void add_cl_banned_irq(int irq)
|
||||||
{
|
{
|
||||||
- add_banned_irq(irq, &cl_banned_irqs);
|
- __add_banned_irq(irq, &cl_banned_irqs);
|
||||||
+ add_banned_irq(irq, &cl_banned_irqs, 0);
|
+ __add_banned_irq(irq, &cl_banned_irqs, 0);
|
||||||
+}
|
+}
|
||||||
+
|
+
|
||||||
+void add_vm_banned_irq(int irq)
|
+void add_vm_banned_irq(int irq)
|
||||||
+{
|
+{
|
||||||
+ add_banned_irq(irq, &vm_banned_irqs, IRQ_FLAG_VM_BANNED);
|
+ __add_banned_irq(irq, &vm_banned_irqs, IRQ_FLAG_VM_BANNED);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int is_banned_irq(int irq)
|
static int is_banned_irq(int irq)
|
||||||
@ -147,20 +146,20 @@ index 37bfb29..52fd74a 100644
|
|||||||
continue;
|
continue;
|
||||||
get_irq_user_policy(devpath, irqnum, &pol);
|
get_irq_user_policy(devpath, irqnum, &pol);
|
||||||
if ((pol.ban == 1) || (check_for_irq_ban(devpath, irqnum, tmp_list))) {
|
if ((pol.ban == 1) || (check_for_irq_ban(devpath, irqnum, tmp_list))) {
|
||||||
- add_banned_irq(irqnum, &banned_irqs);
|
- __add_banned_irq(irqnum, &banned_irqs);
|
||||||
+ add_banned_irq(irqnum, &banned_irqs, 0);
|
+ __add_banned_irq(irqnum, &banned_irqs, 0);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
hint.irq = irqnum;
|
if (!is_proc_irq_info_exist(irqnum, tmp_list)) {
|
||||||
@@ -695,7 +705,7 @@ struct irq_info *build_one_dev_entry(const char *dirname, GList *tmp_list)
|
@@ -695,7 +705,7 @@ struct irq_info *build_one_dev_entry(const char *dirname, GList *tmp_list)
|
||||||
goto done;
|
goto done;
|
||||||
get_irq_user_policy(devpath, irqnum, &pol);
|
get_irq_user_policy(devpath, irqnum, &pol);
|
||||||
if ((pol.ban == 1) || (check_for_irq_ban(path, irqnum, tmp_list))) {
|
if ((pol.ban == 1) || (check_for_irq_ban(devpath, irqnum, tmp_list))) {
|
||||||
- add_banned_irq(irqnum, &banned_irqs);
|
- __add_banned_irq(irqnum, &banned_irqs);
|
||||||
+ add_banned_irq(irqnum, &banned_irqs, 0);
|
+ __add_banned_irq(irqnum, &banned_irqs, 0);
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
|
if (!is_proc_irq_info_exist(irqnum, tmp_list)) {
|
||||||
@@ -811,6 +821,9 @@ void free_irq_db(void)
|
@@ -811,6 +821,9 @@ void free_irq_db(void)
|
||||||
banned_irqs = NULL;
|
banned_irqs = NULL;
|
||||||
g_list_free(rebalance_irq_list);
|
g_list_free(rebalance_irq_list);
|
||||||
@ -175,8 +174,8 @@ index 37bfb29..52fd74a 100644
|
|||||||
/* Set NULL devpath for the irq has no sysfs entries */
|
/* Set NULL devpath for the irq has no sysfs entries */
|
||||||
get_irq_user_policy(NULL, irq, &pol);
|
get_irq_user_policy(NULL, irq, &pol);
|
||||||
if ((pol.ban == 1) || check_for_irq_ban(NULL, irq, proc_interrupts)) { /*FIXME*/
|
if ((pol.ban == 1) || check_for_irq_ban(NULL, irq, proc_interrupts)) { /*FIXME*/
|
||||||
- add_banned_irq(irq, &banned_irqs);
|
- __add_banned_irq(irq, &banned_irqs);
|
||||||
+ add_banned_irq(irq, &banned_irqs, 0);
|
+ __add_banned_irq(irq, &banned_irqs, 0);
|
||||||
new = get_irq_info(irq);
|
new = get_irq_info(irq);
|
||||||
} else
|
} else
|
||||||
new = add_one_irq_to_db(NULL, hint, &pol);
|
new = add_one_irq_to_db(NULL, hint, &pol);
|
||||||
@ -262,42 +261,41 @@ diff --git a/irqbalance.h b/irqbalance.h
|
|||||||
index 5016cc8..339e2a3 100644
|
index 5016cc8..339e2a3 100644
|
||||||
--- a/irqbalance.h
|
--- a/irqbalance.h
|
||||||
+++ b/irqbalance.h
|
+++ b/irqbalance.h
|
||||||
@@ -103,8 +103,10 @@ extern void add_cl_banned_irq(int irq);
|
@@ -103,6 +103,8 @@ extern void free_cl_opts(void);
|
||||||
#ifdef AARCH64
|
|
||||||
extern void add_banned_list_irq(int irq);
|
|
||||||
#endif
|
|
||||||
+extern void add_vm_banned_irq(int irq);
|
|
||||||
extern void for_each_irq(GList *list, void (*cb)(struct irq_info *info, void *data), void *data);
|
|
||||||
extern struct irq_info *get_irq_info(int irq);
|
|
||||||
+extern int is_pci_assigned_irq(const char *line);
|
|
||||||
extern void migrate_irq(GList **from, GList **to, struct irq_info *info);
|
|
||||||
extern void free_cl_opts(void);
|
|
||||||
extern void add_cl_banned_module(char *modname);
|
extern void add_cl_banned_module(char *modname);
|
||||||
|
extern void add_banned_irq(int irq);
|
||||||
|
extern void remove_one_irq_from_db(int irq);
|
||||||
|
+extern void add_vm_banned_irq(int irq);
|
||||||
|
+extern int is_pci_assigned_irq(const char *line);
|
||||||
|
#define irq_numa_node(irq) ((irq)->numa_node)
|
||||||
|
|
||||||
|
extern struct irq_info *build_one_dev_entry(const char *dirname, GList *tmp_list);
|
||||||
diff --git a/procinterrupts.c b/procinterrupts.c
|
diff --git a/procinterrupts.c b/procinterrupts.c
|
||||||
index 6cfa661..522b9a1 100644
|
index 6cfa661..522b9a1 100644
|
||||||
--- a/procinterrupts.c
|
--- a/procinterrupts.c
|
||||||
+++ b/procinterrupts.c
|
+++ b/procinterrupts.c
|
||||||
@@ -42,6 +42,7 @@
|
@@ -42,6 +42,7 @@
|
||||||
|
|
||||||
static int proc_int_has_msi = 0;
|
static int proc_int_has_msi = 0;
|
||||||
static int msi_found_in_sysfs = 0;
|
static int msi_found_in_sysfs = 0;
|
||||||
|
int need_add_single = 0;
|
||||||
+extern int ban_pci_assigned_irq;
|
+extern int ban_pci_assigned_irq;
|
||||||
|
|
||||||
#ifdef AARCH64
|
#ifdef AARCH64
|
||||||
struct irq_match {
|
struct irq_match {
|
||||||
@@ -290,6 +291,12 @@ GList* collect_full_irq_list()
|
@@ -269,6 +270,13 @@ GList* collect_full_irq_list()
|
||||||
c++;
|
c++;
|
||||||
number = strtoul(line, NULL, 10);
|
number = strtoul(line, NULL, 10);
|
||||||
|
|
||||||
+ if (ban_pci_assigned_irq && is_pci_assigned_irq(c)) {
|
+ if (ban_pci_assigned_irq && is_pci_assigned_irq(c)) {
|
||||||
+ log(TO_ALL, LOG_INFO, "Banned PCI-assigned irq %d.\n", number);
|
+ log(TO_ALL, LOG_INFO, "Banned PCI-assigned irq %d.\n", number);
|
||||||
+ add_vm_banned_irq(number);
|
+ add_vm_banned_irq(number);
|
||||||
|
+ free(savedline);
|
||||||
+ continue;
|
+ continue;
|
||||||
+ }
|
+ }
|
||||||
+
|
+
|
||||||
#ifdef AARCH64
|
info = calloc(sizeof(struct irq_info), 1);
|
||||||
if (is_arm_irq_aff_cannot_change(number)) {
|
if (info) {
|
||||||
/*
|
init_irq_class_and_type(savedline, info, number);
|
||||||
@@ -333,6 +340,7 @@ void parse_proc_interrupts(void)
|
@@ -333,6 +340,7 @@ void parse_proc_interrupts(void)
|
||||||
FILE *file;
|
FILE *file;
|
||||||
char *line = NULL;
|
char *line = NULL;
|
||||||
@ -307,7 +305,7 @@ index 6cfa661..522b9a1 100644
|
|||||||
file = fopen("/proc/interrupts", "r");
|
file = fopen("/proc/interrupts", "r");
|
||||||
if (!file)
|
if (!file)
|
||||||
@@ -400,6 +408,21 @@ void parse_proc_interrupts(void)
|
@@ -400,6 +408,21 @@ void parse_proc_interrupts(void)
|
||||||
}
|
free(savedline);
|
||||||
info->existing = 1;
|
info->existing = 1;
|
||||||
|
|
||||||
+ if (ban_pci_assigned_irq) {
|
+ if (ban_pci_assigned_irq) {
|
||||||
@ -336,7 +334,7 @@ index 62cc2bb..c0950ee 100644
|
|||||||
* IRQ Internal tracking flags
|
* IRQ Internal tracking flags
|
||||||
*/
|
*/
|
||||||
#define IRQ_FLAG_BANNED 1
|
#define IRQ_FLAG_BANNED 1
|
||||||
+#define IRQ_FLAG_VM_BANNED 2
|
+#define IRQ_FLAG_VM_BANNED 2
|
||||||
|
|
||||||
enum obj_type_e {
|
enum obj_type_e {
|
||||||
OBJ_TYPE_CPU,
|
OBJ_TYPE_CPU,
|
||||||
|
|||||||
@ -21,7 +21,7 @@ index 8a5b1f4..ce0022c 100644
|
|||||||
|
|
||||||
[Service]
|
[Service]
|
||||||
+OOMScoreAdjust=-500
|
+OOMScoreAdjust=-500
|
||||||
+Type=simple
|
+Type=forking
|
||||||
+PIDFile=/var/run/irqbalance.pid
|
+PIDFile=/var/run/irqbalance.pid
|
||||||
EnvironmentFile=/etc/sysconfig/irqbalance
|
EnvironmentFile=/etc/sysconfig/irqbalance
|
||||||
-ExecStart=/usr/sbin/irqbalance --foreground $IRQBALANCE_ARGS
|
-ExecStart=/usr/sbin/irqbalance --foreground $IRQBALANCE_ARGS
|
||||||
|
|||||||
@ -33,7 +33,7 @@ index cace4d8..5e5ef9b 100644
|
|||||||
+ goto out;
|
+ goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!foreground_mode) {
|
|
||||||
@@ -673,7 +674,8 @@ int main(int argc, char** argv)
|
@@ -673,7 +674,8 @@ int main(int argc, char** argv)
|
||||||
parse_proc_stat();
|
parse_proc_stat();
|
||||||
|
|
||||||
|
|||||||
65
fix-the-pid-file-generates-too-late-problem.patch
Normal file
65
fix-the-pid-file-generates-too-late-problem.patch
Normal file
@ -0,0 +1,65 @@
|
|||||||
|
From a23a3b9881eff000f79ca4cf9bd0e526399e6a68 Mon Sep 17 00:00:00 2001
|
||||||
|
From: hejingxian 00273181 <hejingxian@huawei.com>
|
||||||
|
Date: Fri, 6 Sep 2019 21:00:52 +0800
|
||||||
|
Subject: [PATCH 08/48] * fix the pid file generates too late problem
|
||||||
|
|
||||||
|
When the system processes many irqs with using user policy script,
|
||||||
|
the build_object_tree function will fork many child processes which costs several minutes.
|
||||||
|
In the irqbalance main process, the pid file generates after build_object_tree.
|
||||||
|
Therefore, the generation time of the pid file is several minutes later than the process start time.
|
||||||
|
When the irqbalance service is started by systemd based forking mode, systemd will check the pid file.
|
||||||
|
If the pid file generates too late, systemd will think the irqbalance service as starting failed.
|
||||||
|
---
|
||||||
|
irqbalance.c | 29 +++++++++++++++--------------
|
||||||
|
1 file changed, 15 insertions(+), 14 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/irqbalance.c b/irqbalance.c
|
||||||
|
index d424326..8199c06 100644
|
||||||
|
--- a/irqbalance.c
|
||||||
|
+++ b/irqbalance.c
|
||||||
|
@@ -573,6 +573,21 @@ int main(int argc, char** argv)
|
||||||
|
log(TO_ALL, LOG_WARNING, "Unable to determin HZ defaulting to 100\n");
|
||||||
|
HZ = 100;
|
||||||
|
}
|
||||||
|
+
|
||||||
|
+ if (!foreground_mode) {
|
||||||
|
+ int pidfd = -1;
|
||||||
|
+ if (daemon(0,0))
|
||||||
|
+ exit(EXIT_FAILURE);
|
||||||
|
+ /* Write pidfile which can be used to avoid starting mutiple instances */
|
||||||
|
+ if (pidfile && (pidfd = open(pidfile,
|
||||||
|
+ O_WRONLY | O_CREAT | O_EXCL | O_TRUNC,
|
||||||
|
+ S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH)) >= 0) {
|
||||||
|
+ char str[16];
|
||||||
|
+ snprintf(str, sizeof(str), "%u\n", getpid());
|
||||||
|
+ write(pidfd, str, strlen(str));
|
||||||
|
+ close(pidfd);
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
|
||||||
|
build_object_tree();
|
||||||
|
if (debug_mode)
|
||||||
|
@@ -588,20 +603,6 @@ int main(int argc, char** argv)
|
||||||
|
exit(EXIT_SUCCESS);
|
||||||
|
}
|
||||||
|
|
||||||
|
- if (!foreground_mode) {
|
||||||
|
- int pidfd = -1;
|
||||||
|
- if (daemon(0,0))
|
||||||
|
- exit(EXIT_FAILURE);
|
||||||
|
- /* Write pidfile */
|
||||||
|
- if (pidfile && (pidfd = open(pidfile,
|
||||||
|
- O_WRONLY | O_CREAT | O_EXCL | O_TRUNC,
|
||||||
|
- S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH)) >= 0) {
|
||||||
|
- char str[16];
|
||||||
|
- snprintf(str, sizeof(str), "%u\n", getpid());
|
||||||
|
- write(pidfd, str, strlen(str));
|
||||||
|
- close(pidfd);
|
||||||
|
- }
|
||||||
|
- }
|
||||||
|
|
||||||
|
g_unix_signal_add(SIGINT, handler, NULL);
|
||||||
|
g_unix_signal_add(SIGTERM, handler, NULL);
|
||||||
|
--
|
||||||
|
2.21.0.windows.1
|
||||||
|
|
||||||
@ -16,29 +16,29 @@ index 1ca401e..15fb0fe 100644
|
|||||||
--- a/irqbalance.c
|
--- a/irqbalance.c
|
||||||
+++ b/irqbalance.c
|
+++ b/irqbalance.c
|
||||||
@@ -69,6 +69,8 @@ int sleep_interval = SLEEP_INTERVAL;
|
@@ -69,6 +69,8 @@ int sleep_interval = SLEEP_INTERVAL;
|
||||||
|
long HZ;
|
||||||
|
int sleep_interval = SLEEP_INTERVAL;
|
||||||
int last_interval;
|
int last_interval;
|
||||||
int hint_enabled = 0;
|
|
||||||
int poll_hint_interval = SLEEP_INTERVAL / 5;
|
|
||||||
+unsigned long migrate_val = 0;
|
+unsigned long migrate_val = 0;
|
||||||
+unsigned long load_limit = 0;
|
+unsigned long load_limit = 0;
|
||||||
GMainLoop *main_loop;
|
GMainLoop *main_loop;
|
||||||
|
|
||||||
char *cpu_ban_string = NULL;
|
char *cpu_ban_string = NULL;
|
||||||
@@ -106,6 +108,8 @@ struct option lopts[] = {
|
@@ -106,6 +108,8 @@ struct option lopts[] = {
|
||||||
{"verifyhint", 1, NULL, 'v'},
|
{"banmod", 1 , NULL, 'm'},
|
||||||
{"rulesconfig", 1, NULL, 'r'},
|
{"interval", 1 , NULL, 't'},
|
||||||
{"notclearhint", 0, NULL, 'n'},
|
{"version", 0, NULL, 'V'},
|
||||||
+ {"migrateval", 1, NULL, 'e'},
|
+ {"migrateval", 1, NULL, 'e'},
|
||||||
+ {"loadlimit", 1, NULL, 'g'},
|
+ {"loadlimit", 1, NULL, 'g'},
|
||||||
{0, 0, 0, 0}
|
{0, 0, 0, 0}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -114,7 +118,7 @@ static void usage(void)
|
@@ -114,7 +118,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, " [--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>]\n");
|
||||||
- log(TO_CONSOLE, LOG_INFO, " [--rulesconfig= | -r <config>] [--notclearhint | -n]\n");
|
+ log(TO_CONSOLE, LOG_INFO, " [--pid= | -s <file>] [--deepestcache= | -c <n>] [--interval= | -t <n>] [--migrateval= | -e <n>] [--loadlimit= | -g <n>]\n");
|
||||||
+ log(TO_CONSOLE, LOG_INFO, " [--rulesconfig= | -r <config>] [--notclearhint | -n] [--migrateval= | -e <n>] [--loadlimit= | -g <n>]\n");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void version(void)
|
static void version(void)
|
||||||
@ -46,14 +46,14 @@ index 1ca401e..15fb0fe 100644
|
|||||||
unsigned long val;
|
unsigned long val;
|
||||||
|
|
||||||
while ((opt = getopt_long(argc, argv,
|
while ((opt = getopt_long(argc, argv,
|
||||||
- "odfji:p:s:c:b:l:m:t:V:h:v:r:n",
|
- "odfjVi:p:s:c:b:l:m:t:",
|
||||||
+ "odfji:p:s:c:b:l:m:t:V:h:v:r:ne:g:",
|
+ "odfjVi:p:s:c:b:l:m:t:e:g:",
|
||||||
lopts, &longind)) != -1) {
|
lopts, &longind)) != -1) {
|
||||||
|
|
||||||
switch(opt) {
|
switch(opt) {
|
||||||
@@ -231,6 +235,12 @@ static void parse_command_line(int argc, char **argv)
|
@@ -231,6 +235,12 @@ static void parse_command_line(int argc, char **argv)
|
||||||
case 'n':
|
exit(1);
|
||||||
clear_affinity_hint = 0;
|
}
|
||||||
break;
|
break;
|
||||||
+ case 'e':
|
+ case 'e':
|
||||||
+ migrate_val = strtoul(optarg, NULL, 10);
|
+ migrate_val = strtoul(optarg, NULL, 10);
|
||||||
@ -61,17 +61,17 @@ index 1ca401e..15fb0fe 100644
|
|||||||
+ case 'g':
|
+ case 'g':
|
||||||
+ load_limit = strtoul(optarg, NULL, 10);
|
+ load_limit = strtoul(optarg, NULL, 10);
|
||||||
+ break;
|
+ break;
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
diff --git a/irqbalance.h b/irqbalance.h
|
diff --git a/irqbalance.h b/irqbalance.h
|
||||||
index 72e141b..d4f6e7a 100644
|
index 72e141b..d4f6e7a 100644
|
||||||
--- a/irqbalance.h
|
--- a/irqbalance.h
|
||||||
+++ b/irqbalance.h
|
+++ b/irqbalance.h
|
||||||
@@ -124,7 +124,8 @@ extern struct irq_info *add_new_irq(int irq, struct irq_info *hint, GList *proc_
|
@@ -124,7 +124,8 @@ extern struct irq_info *add_new_irq(int irq, struct irq_info *hint, GList *proc_
|
||||||
extern void clear_no_existing_irqs(void);
|
extern void add_cl_banned_module(char *modname);
|
||||||
extern int hint_enabled, poll_hint_interval;
|
#define irq_numa_node(irq) ((irq)->numa_node)
|
||||||
extern int sleep_interval;
|
|
||||||
-
|
-
|
||||||
+extern unsigned long migrate_val;
|
+extern unsigned long migrate_val;
|
||||||
+extern unsigned long load_limit;
|
+extern unsigned long load_limit;
|
||||||
@ -1,7 +1,7 @@
|
|||||||
Summary: A dynamic adaptive IRQ balancing daemon
|
Summary: A dynamic adaptive IRQ balancing daemon
|
||||||
Name: irqbalance
|
Name: irqbalance
|
||||||
Version: 1.4.0
|
Version: 1.4.0
|
||||||
Release: 18
|
Release: 19
|
||||||
Epoch: 3
|
Epoch: 3
|
||||||
|
|
||||||
License: GPLv2
|
License: GPLv2
|
||||||
@ -33,52 +33,46 @@ Patch6: irqbalance-Add-support-for-file-based-socket-for-IPC.patch
|
|||||||
Patch7: Fix-several-memleak-problems-found-by-covscan.patch
|
Patch7: Fix-several-memleak-problems-found-by-covscan.patch
|
||||||
Patch8: Fix-an-possible-overflow-error.patch
|
Patch8: Fix-an-possible-overflow-error.patch
|
||||||
Patch9: Fix-irqbalance-ui-failing-to-connect-to-irqbalance-d.patch
|
Patch9: Fix-irqbalance-ui-failing-to-connect-to-irqbalance-d.patch
|
||||||
Patch10:procinterrupts-check-xen-dyn-event-more-flexible.patch
|
Patch10: procinterrupts-check-xen-dyn-event-more-flexible.patch
|
||||||
Patch11:Fix-ambiguous-parsing-of-node-entries-in-sys.patch
|
Patch11: Fix-ambiguous-parsing-of-node-entries-in-sys.patch
|
||||||
Patch12:Don-t-leak-socket-fd-on-connection-error.patch
|
Patch12: Don-t-leak-socket-fd-on-connection-error.patch
|
||||||
Patch13:Fix-string-truncation-issues-detected-by-GCC-8.patch
|
Patch13: Fix-string-truncation-issues-detected-by-GCC-8.patch
|
||||||
Patch14:fix-balancing-when-numa-information-isn-t-available.patch
|
Patch14: fix-balancing-when-numa-information-isn-t-available.patch
|
||||||
|
|
||||||
Patch6000: Checking-return-value-of-strdup-in-collect_full_irq_.patch
|
Patch6000: use-policy-prior-to-the-default-values.patch
|
||||||
Patch6001: getline-clean-up-freeing-of-lines-from-getline.patch
|
Patch6001: some-variable-and-judgement-are-unnecessary-in-activ.patch
|
||||||
Patch6002: free-the-memory-when-getline-fail-in-add_one_node.patch
|
Patch6002: fix-sleep-interval-when-sleep_interval-is-changed-by.patch
|
||||||
Patch6003: prevent-NULL-pointer-dereference-when-memory-allocat.patch
|
Patch6003: guess_arm_irq_hints.patch
|
||||||
Patch6004: fix-resource-leak-for-not-invoking-closedir-after-op.patch
|
Patch6004: fix-the-pid-file-generates-too-late-problem.patch
|
||||||
Patch6005: correct-to-use-realloc-function.patch
|
Patch6005: make-the-return-value-of-getline-handled-correct.patch
|
||||||
Patch6006: fix-the-problem-of-banmod-that-memory-is-freed-befor.patch
|
Patch6006: change-irq-ban-check-path-to-devpath.patch
|
||||||
Patch6007: fix-sleep-interval-when-sleep_interval-is-changed-by.patch
|
Patch6007: Checking-return-value-of-strdup-in-collect_full_irq_.patch
|
||||||
Patch6008: fix-resource-leak-on-the-error-paths-in-main.patch
|
Patch6008: getline-clean-up-freeing-of-lines-from-getline.patch
|
||||||
Patch6009: fix-invalid-pointer-dereference-banned_cpumask_from_.patch
|
Patch6009: free-the-memory-when-getline-fail-in-add_one_node.patch
|
||||||
Patch6010: free-cpu_ban_string-when-the-next-request-come.patch
|
Patch6010: prevent-NULL-pointer-dereference-when-memory-allocat.patch
|
||||||
|
Patch6011: fix-resource-leak-for-not-invoking-closedir-after-op.patch
|
||||||
|
Patch6012: correct-to-use-realloc-function.patch
|
||||||
|
Patch6013: fix-the-problem-of-banmod-that-memory-is-freed-befor.patch
|
||||||
|
Patch6014: fix-resource-leak-on-the-error-paths-in-main.patch
|
||||||
|
Patch6015: fix-invalid-pointer-dereference-banned_cpumask_from_.patch
|
||||||
|
Patch6016: free-cpu_ban_string-when-the-next-request-come.patch
|
||||||
|
Patch6017: make-the-option-V-closer-to-the-option-with-no-arg.patch
|
||||||
|
Patch6018: improve-irq-migrate-rule-to-avoid-high-irq-load.patch
|
||||||
|
Patch6019: arm64-Add-irq-aff-change-check.patch
|
||||||
|
|
||||||
Patch9000: irqbalance-1.0.4-env-file-path.patch
|
Patch9000: irqbalance-1.0.4-env-file-path.patch
|
||||||
Patch9001: bugfix-fix-a-hole-that-flees-hotplug-event.patch
|
Patch9001: bugfix-fix-a-hole-that-flees-hotplug-event.patch
|
||||||
Patch9002: bugfix-use-policy-prior-to-the-default-values.patch
|
Patch9002: bugfix-force-irq-into-rebalance-list-when-irq-removed-and-reinserted.patch
|
||||||
Patch9003: bugfix-force-irq-into-rebalance-list-when-irq-removed-and-reinserted.patch
|
Patch9003: feature-irqbalance-aarch64-add-the-regular-to-get-th.patch
|
||||||
Patch9004: feature-irqbalance-aarch64-add-the-regular-to-get-th.patch
|
Patch9004: feature-irqbalance-auto-banned-pci-assigned-irq.patch
|
||||||
Patch9005: feature-irqbalance-arm64-Add-irq-aff-change-check.patch
|
Patch9005: feature-supplement-irqbalance-service-config.patch
|
||||||
Patch9006: feature-irqbalance-auto-banned-pci-assigned-irq.patch
|
Patch9006: feature-add-new-user-irq-policy-config-rule.patch
|
||||||
Patch9007: bugfix-irqbalance-fix-wrong-pid-value-in-pid-file.patch
|
Patch9007: feature-add-the-switch-of-printing-log.patch
|
||||||
Patch9008: feature-supplement-irqbalance-service-config.patch
|
Patch9008: feature-introduce-verifyhint-to-detect-hint-variation.patch
|
||||||
Patch9009: bugfix-fgets-will-get-a-redundant-new-line.patch
|
Patch9009: feature-add-switch-to-clear-affinity-hint.patch
|
||||||
Patch9010: bugfix-Prevent-inserting-a-duplicate-entry-to-avoid-list-ch.patch
|
Patch9010: feature-encapsulate-and-compile-the-functions-in-irqbalance-ui.patch
|
||||||
Patch9011: bugfix-guess_arm_irq_hints.patch
|
Patch9011: feature-enable-irqbalance-to-link-with-multiple-clie.patch
|
||||||
Patch9012: feature-add-new-user-irq-policy-config-rule.patch
|
Patch9012: feature-irqbalance-Add-ability-for-socket-communicat.patch
|
||||||
Patch9013: bugfix-make-the-return-value-of-getline-handled-correct.patch
|
|
||||||
Patch9014: bugfix-change-irq-ban-check-path-to-devpath.patch
|
|
||||||
Patch9015: bugfix-fix-new-irqs-in-hotplug-keep-stay-on-one-numa.patch
|
|
||||||
Patch9016: feature-add-the-switch-of-printing-log.patch
|
|
||||||
Patch9017: bugfix-fix-new-msi-irq-hasnot-been-added-to-rebalance-list.patch
|
|
||||||
Patch9018: bugfix-delete-no-existing-banned-irq.patch
|
|
||||||
Patch9019: bugfix-fix-strcat-may-cause-buffer-overrun.patch
|
|
||||||
Patch9020: feature-introduce-verifyhint-to-detect-hint-variation.patch
|
|
||||||
Patch9021: bugfix-fix-memory-leak-of-strdup-in-collect_full_irq_list.patch
|
|
||||||
Patch9022: feature-add-switch-to-clear-affinity-hint.patch
|
|
||||||
Patch9023: feature-add-new-irq-migrate-rule-to-avoid-high-cpu-irq-load.patch
|
|
||||||
Patch9024: bugfix-prevent-version-cmd-need-an-argument.patch
|
|
||||||
Patch9025: feature-encapsulate-and-compile-the-functions-in-irqbalance-ui.patch
|
|
||||||
Patch9026: feature-enable-irqbalance-to-link-with-multiple-clie.patch
|
|
||||||
Patch9027: feature-irqbalance-Add-ability-for-socket-communicat.patch
|
|
||||||
|
|
||||||
%description
|
%description
|
||||||
Irqbalance is a daemon to help balance the cpu load generated by
|
Irqbalance is a daemon to help balance the cpu load generated by
|
||||||
@ -110,8 +104,9 @@ Shared librariy for irqbalanace client
|
|||||||
%build
|
%build
|
||||||
./autogen.sh
|
./autogen.sh
|
||||||
%configure
|
%configure
|
||||||
CFLAGS="%{optflags}" %make_build CFLAGS+='-fstack-protector-strong -fPIC'
|
CFLAGS="%{optflags}" %make_build CFLAGS+='-fstack-protector-strong '
|
||||||
cd ui
|
cd ui
|
||||||
|
rm -rf *.o
|
||||||
make
|
make
|
||||||
cd -
|
cd -
|
||||||
|
|
||||||
@ -164,6 +159,12 @@ fi
|
|||||||
/sbin/chkconfig --del %{name} >/dev/null 2>&1 || :
|
/sbin/chkconfig --del %{name} >/dev/null 2>&1 || :
|
||||||
|
|
||||||
%changelog
|
%changelog
|
||||||
|
* Tue Mar 24 2020 Liu chao <liuchao173@huawei.com> - 3:1.4.0-19
|
||||||
|
- Type:bugfix
|
||||||
|
- ID:NA
|
||||||
|
- SUG:restart
|
||||||
|
- DESC:refactor patches
|
||||||
|
|
||||||
* Tue Mar 24 2020 Shuaishuai Song <songshuaishuai2@huawei.com> - 3:1.4.0-18
|
* Tue Mar 24 2020 Shuaishuai Song <songshuaishuai2@huawei.com> - 3:1.4.0-18
|
||||||
- Type:bugfix
|
- Type:bugfix
|
||||||
- ID:NA
|
- ID:NA
|
||||||
|
|||||||
25
make-the-option-V-closer-to-the-option-with-no-arg.patch
Normal file
25
make-the-option-V-closer-to-the-option-with-no-arg.patch
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
From 7f77fc97cb259da3f6097be347e4fcacd4f864d9 Mon Sep 17 00:00:00 2001
|
||||||
|
From: hejingxian 00273181 <hejingxian@huawei.com>
|
||||||
|
Date: Mon, 20 Jan 2020 23:01:19 +0800
|
||||||
|
Subject: [PATCH 29/33] make the option 'V' closer to the option with no arg
|
||||||
|
|
||||||
|
---
|
||||||
|
irqbalance.c | 2 +-
|
||||||
|
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||||
|
|
||||||
|
diff --git a/irqbalance.c b/irqbalance.c
|
||||||
|
index e76d27b..be111f1 100644
|
||||||
|
--- a/irqbalance.c
|
||||||
|
+++ b/irqbalance.c
|
||||||
|
@@ -118,7 +118,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",
|
||||||
|
+ "odfjVi:p:s:c:b:l:m:t:",
|
||||||
|
lopts, &longind)) != -1) {
|
||||||
|
|
||||||
|
switch(opt) {
|
||||||
|
--
|
||||||
|
2.21.0.windows.1
|
||||||
|
|
||||||
@ -59,7 +59,7 @@ diff --git a/procinterrupts.c b/procinterrupts.c
|
|||||||
index 18b3ceb..c32c1b2 100644
|
index 18b3ceb..c32c1b2 100644
|
||||||
--- a/procinterrupts.c
|
--- a/procinterrupts.c
|
||||||
+++ b/procinterrupts.c
|
+++ b/procinterrupts.c
|
||||||
@@ -262,7 +262,7 @@ GList* collect_full_irq_list()
|
@@ -236,7 +236,7 @@ GList* collect_full_irq_list()
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
/* first line is the header we don't need; nuke it */
|
/* first line is the header we don't need; nuke it */
|
||||||
@ -68,7 +68,7 @@ index 18b3ceb..c32c1b2 100644
|
|||||||
free(line);
|
free(line);
|
||||||
fclose(file);
|
fclose(file);
|
||||||
return NULL;
|
return NULL;
|
||||||
@@ -274,7 +274,7 @@ GList* collect_full_irq_list()
|
@@ -248,7 +248,7 @@ GList* collect_full_irq_list()
|
||||||
char *c;
|
char *c;
|
||||||
char *savedline = NULL;
|
char *savedline = NULL;
|
||||||
|
|
||||||
@ -77,7 +77,7 @@ index 18b3ceb..c32c1b2 100644
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
/* lines with letters in front are special, like NMI count. Ignore */
|
/* lines with letters in front are special, like NMI count. Ignore */
|
||||||
@@ -349,7 +349,7 @@ void parse_proc_interrupts(void)
|
@@ -308,7 +308,7 @@ void parse_proc_interrupts(void)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
/* first line is the header we don't need; nuke it */
|
/* first line is the header we don't need; nuke it */
|
||||||
@ -86,9 +86,9 @@ index 18b3ceb..c32c1b2 100644
|
|||||||
free(line);
|
free(line);
|
||||||
fclose(file);
|
fclose(file);
|
||||||
return;
|
return;
|
||||||
@@ -365,7 +365,7 @@ void parse_proc_interrupts(void)
|
@@ -325,7 +325,7 @@ void parse_proc_interrupts(void)
|
||||||
|
struct irq_info *info;
|
||||||
char savedline[1024];
|
char savedline[1024];
|
||||||
char dirname[PATH_MAX] = {'\0'};
|
|
||||||
|
|
||||||
- if (getline(&line, &size, file)==0)
|
- if (getline(&line, &size, file)==0)
|
||||||
+ if (getline(&line, &size, file)<=0)
|
+ if (getline(&line, &size, file)<=0)
|
||||||
58
some-variable-and-judgement-are-unnecessary-in-activ.patch
Normal file
58
some-variable-and-judgement-are-unnecessary-in-activ.patch
Normal file
@ -0,0 +1,58 @@
|
|||||||
|
From cfe3d10d37e44be4bb94cb715dbe6fde9e8a60ff Mon Sep 17 00:00:00 2001
|
||||||
|
From: Pyxisha <xiashuang1@huawei.com>
|
||||||
|
Date: Mon, 15 Jul 2019 10:44:50 +0800
|
||||||
|
Subject: [PATCH 01/48] some variable and judgement are unnecessary in
|
||||||
|
activate_mappings
|
||||||
|
|
||||||
|
sign_off_by Shuang Xia <xiashuang1@huawei.com>
|
||||||
|
---
|
||||||
|
activate.c | 15 ++++-----------
|
||||||
|
1 file changed, 4 insertions(+), 11 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/activate.c b/activate.c
|
||||||
|
index 8fd3dd0..8fd9bde 100644
|
||||||
|
--- a/activate.c
|
||||||
|
+++ b/activate.c
|
||||||
|
@@ -60,8 +60,6 @@ static void activate_mapping(struct irq_info *info, void *data __attribute__((un
|
||||||
|
{
|
||||||
|
char buf[PATH_MAX];
|
||||||
|
FILE *file;
|
||||||
|
- cpumask_t applied_mask;
|
||||||
|
- int valid_mask = 0;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* only activate mappings for irqs that have moved
|
||||||
|
@@ -69,18 +67,13 @@ static void activate_mapping(struct irq_info *info, void *data __attribute__((un
|
||||||
|
if (!info->moved)
|
||||||
|
return;
|
||||||
|
|
||||||
|
- if (info->assigned_obj) {
|
||||||
|
- applied_mask = info->assigned_obj->mask;
|
||||||
|
- valid_mask = 1;
|
||||||
|
- }
|
||||||
|
+ if (!info->assigned_obj)
|
||||||
|
+ return;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Don't activate anything for which we have an invalid mask
|
||||||
|
*/
|
||||||
|
- if (!valid_mask || check_affinity(info, applied_mask))
|
||||||
|
- return;
|
||||||
|
-
|
||||||
|
- if (!info->assigned_obj)
|
||||||
|
+ if (check_affinity(info, info->assigned_obj->mask))
|
||||||
|
return;
|
||||||
|
|
||||||
|
sprintf(buf, "/proc/irq/%i/smp_affinity", info->irq);
|
||||||
|
@@ -88,7 +81,7 @@ static void activate_mapping(struct irq_info *info, void *data __attribute__((un
|
||||||
|
if (!file)
|
||||||
|
return;
|
||||||
|
|
||||||
|
- cpumask_scnprintf(buf, PATH_MAX, applied_mask);
|
||||||
|
+ cpumask_scnprintf(buf, PATH_MAX, info->assigned_obj->mask);
|
||||||
|
fprintf(file, "%s", buf);
|
||||||
|
fclose(file);
|
||||||
|
info->moved = 0; /*migration is done*/
|
||||||
|
--
|
||||||
|
2.21.0.windows.1
|
||||||
|
|
||||||
Loading…
x
Reference in New Issue
Block a user