File irqbalance-properly-check-if-irq-is-banned.patch of Package irqbalance.27245
From: Nick Child <nick.child@ibm.com>
Subject: irqbalance: properly check if irq is banned
References: bnc#1204962
Patch-Mainline: v1.9.1
Git-commit: 725d9b12888f0dcfce5038c24e2015a10b36a4e9
Git-repo: https://github.com/Irqbalance/irqbalance.git.git
When checking if a new irq should be banned, make sure
to compare the irq's name against the list of banned modules regardless
of whether or not the new irq is in a known list of interrupts.
Therefore, for the new irq in question, pass the entire irq_info data
structure to check_for_irq_ban() instead of just the irq number.
As a result, tracking the GList of interrupts is not needed in
check_for_irq_ban() so cleanup these unused parameters across
applicable functions in the the call trace.
Signed-off-by: Nick Child <nick.child@ibm.com>
Signed-off-by: <trenn@suse.com>
Index: irqbalance-1.4.0/classify.c
===================================================================
--- irqbalance-1.4.0.orig/classify.c
+++ irqbalance-1.4.0/classify.c
@@ -547,28 +547,22 @@ static int check_for_module_ban(char *na
return 0;
}
-static int check_for_irq_ban(int irq, GList *proc_interrupts)
+static int check_for_irq_ban(struct irq_info *irq)
{
- struct irq_info find, *res;
GList *entry;
/*
* Check to see if we banned this irq on the command line
*/
- find.irq = irq;
- entry = g_list_find_custom(cl_banned_irqs, &find, compare_ints);
+ entry = g_list_find_custom(cl_banned_irqs, irq, compare_ints);
if (entry)
return 1;
/*
- * Check to see if we banned module which the irq belongs to.
+ * Check if any banned modules are substrings in irq->name
*/
- entry = g_list_find_custom(proc_interrupts, &find, compare_ints);
- if (entry) {
- res = entry->data;
- if (check_for_module_ban(res->name))
- return 1;
- }
+ if (irq->name != NULL && strlen(irq->name) > 0 && check_for_module_ban(irq->name))
+ return 1;
#ifdef INCLUDE_BANSCRIPT
char *cmd;
@@ -606,7 +600,7 @@ static int check_for_irq_ban(int irq, GL
/*
* Figures out which interrupt(s) relate to the device we"re looking at in dirname
*/
-static void build_one_dev_entry(const char *dirname, GList *tmp_irqs)
+static void build_one_dev_entry(const char *dirname)
{
struct dirent *entry;
DIR *msidir;
@@ -616,6 +610,7 @@ static void build_one_dev_entry(const ch
char path[PATH_MAX];
char devpath[PATH_MAX];
struct user_irq_policy pol;
+ struct irq_info find;
sprintf(path, "%s/%s/msi_irqs", SYSDEV_DIR, dirname);
sprintf(devpath, "%s/%s", SYSDEV_DIR, dirname);
@@ -633,9 +628,10 @@ static void build_one_dev_entry(const ch
if (new)
continue;
get_irq_user_policy(devpath, irqnum, &pol);
- if ((pol.ban == 1) || (check_for_irq_ban(irqnum, tmp_irqs))) {
- add_banned_irq(irqnum, &banned_irqs);
- continue;
+ find.irq = irqnum;
+ if ((pol.ban == 1) || (check_for_irq_ban(&find))) {
+ add_banned_irq(irqnum, &banned_irqs);
+ continue;
}
new = add_one_irq_to_db(devpath, irqnum, &pol);
if (!new)
@@ -667,7 +663,8 @@ static void build_one_dev_entry(const ch
if (new)
goto done;
get_irq_user_policy(devpath, irqnum, &pol);
- if ((pol.ban == 1) || (check_for_irq_ban(irqnum, tmp_irqs))) {
+ find.irq = irqnum;
+ if ((pol.ban == 1) || (check_for_irq_ban(&find))) {
add_banned_irq(irqnum, &banned_irqs);
goto done;
}
@@ -707,7 +704,7 @@ void free_cl_opts(void)
g_list_free(banned_irqs);
}
-static void add_new_irq(int irq, struct irq_info *hint, GList *proc_interrupts)
+static void add_new_irq(int irq, struct irq_info *hint)
{
struct irq_info *new;
struct user_irq_policy pol;
@@ -718,7 +715,7 @@ static void add_new_irq(int irq, struct
/* 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(irq, proc_interrupts)) { /*FIXME*/
+ if ((pol.ban == 1) || check_for_irq_ban(hint)) { /*FIXME*/
add_banned_irq(irq, &banned_irqs);
new = get_irq_info(irq);
} else
@@ -743,10 +740,9 @@ static void add_new_irq(int irq, struct
static void add_missing_irq(struct irq_info *info, void *attr)
{
struct irq_info *lookup = get_irq_info(info->irq);
- GList *proc_interrupts = (GList *) attr;
if (!lookup)
- add_new_irq(info->irq, info, proc_interrupts);
+ add_new_irq(info->irq, info);
}
@@ -770,14 +766,14 @@ void rebuild_irq_db(void)
if (!entry)
break;
- build_one_dev_entry(entry->d_name, tmp_irqs);
+ build_one_dev_entry(entry->d_name);
} while (entry != NULL);
closedir(devdir);
- for_each_irq(tmp_irqs, add_missing_irq, interrupts_db);
+ for_each_irq(tmp_irqs, add_missing_irq, NULL);
free:
g_list_free_full(tmp_irqs, free);