irqbalance/bugfix-prevent-inserting-a-duplicate-entry-to-avoid-list-ch.patch
2019-09-30 10:53:30 -04:00

109 lines
3.7 KiB
Diff

From 3eab5a9cee8a3641988778b676caa4cf9dcb14ab Mon Sep 17 00:00:00 2001
From: xiashuang <xiashuang1@huawei.com>
Date: Sun, 11 Aug 2019 23:48:50 -0400
Subject: [PATCH] Prevent inserting a duplicate entry to avoid list chaos
Introduced by huawei-bugfix-force-irq-into-rebalance-list-when-irq-removed-and-reinserted.patch
and huawei-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
huawei-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 huawei-bugfix-fix-two-same-irq-insert-to-list.patch and add protection
in force_rebalance_irq instead.
---
classify.c | 13 +------------
irqbalance.c | 4 ++++
irqbalance.h | 3 ++-
procinterrupts.c | 8 ++------
4 files changed, 9 insertions(+), 19 deletions(-)
diff --git a/classify.c b/classify.c
index 34a2e9f..65aeae2 100644
--- a/classify.c
+++ b/classify.c
@@ -260,7 +260,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;
@@ -293,17 +293,6 @@ static void add_banned_irq(int irq, GList **list, int extra_flag)
return;
}
-int irq_in_rebalance_list(int irq)
-{
- GList *entry = NULL;
- struct irq_info find = {0};
-
- find.irq = irq;
- entry = g_list_find_custom(rebalance_irq_list, &find, compare_ints);
-
- return entry ? 1 : 0;
-}
-
#ifdef AARCH64
void add_banned_list_irq(int irq)
{
diff --git a/irqbalance.c b/irqbalance.c
index 6e9de88..fd72d44 100644
--- a/irqbalance.c
+++ b/irqbalance.c
@@ -314,6 +314,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 b6bdebd..120bc9b 100644
--- a/irqbalance.h
+++ b/irqbalance.h
@@ -114,7 +114,8 @@ extern void free_cl_opts(void);
extern void add_cl_banned_module(char *modname);
#define irq_numa_node(irq) ((irq)->numa_node)
extern void force_rebalance_irq(struct irq_info *info, void *data __attribute__((unused)));
-int irq_in_rebalance_list(int irq);
+extern gint compare_ints(gconstpointer a, gconstpointer b);
+
/* huawei */
extern struct irq_info *build_one_dev_entry(const char *dirname, GList *tmp_list);
extern void find_irq_dev_path(int irq, char *dirname, int length);
diff --git a/procinterrupts.c b/procinterrupts.c
index 6b25fef..4bc68d7 100644
--- a/procinterrupts.c
+++ b/procinterrupts.c
@@ -446,9 +446,7 @@ void parse_proc_interrupts(void)
*/
if (count < info->irq_count) {
log(TO_CONSOLE, LOG_INFO, "Removed and reinserted IRQ %d added into rebalance list\n", number);
- if (!irq_in_rebalance_list(info->irq)) {
- force_rebalance_irq(info, NULL);
- }
+ force_rebalance_irq(info, NULL);
}
info->last_irq_count = info->irq_count;
@@ -702,9 +700,7 @@ void update_affinity_hint(struct irq_info *info, void *data __attribute__((unuse
cpumask_parse_user(line, len, current_affinity_hint);
if (!cpus_equal(current_affinity_hint, info->affinity_hint)) {
cpumask_copy(info->affinity_hint, current_affinity_hint);
- if (!irq_in_rebalance_list(info->irq)) {
- force_rebalance_irq(info, data);
- }
+ force_rebalance_irq(info, data);
log(TO_ALL, LOG_INFO, "IRQ(%d): affinity hint modified\n", info->irq);
}
}
--
1.8.3.1