irqbalance/arm64-Add-irq-aff-change-check.patch
2020-03-24 11:44:22 +08:00

140 lines
4.5 KiB
Diff

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