Blame SOURCES/irqbalance-1.0.8-separate-cmomand-line-banned-irqs.patch

57bf01
From 7f072d94c93174d30eb18426ee8f8727a9081c40 Mon Sep 17 00:00:00 2001
57bf01
From: Neil Horman <nhorman@tuxdriver.com>
57bf01
Date: Fri, 16 May 2014 10:10:36 -0400
57bf01
Subject: [PATCH] irqbalance: separate cmomand line banned irqs from listed
57bf01
 banned irqs
57bf01
57bf01
irqbalance was using one list for tracking banned irqs, but the list was being
57bf01
used for disperate pruposes in different places.  It was tracking command line
57bf01
banned irqs and irqs that were banned via banscript and policyscript.  The
57bf01
former needs to be remembered accross db rebuilds, while the latter needs to be
57bf01
rebuilt every time.  This patch separates the two in to two lists, so that we
57bf01
don't stop banning command line specified irqs after the first db rebuild.
57bf01
57bf01
Signed-off-by: Neil Horman <nhorman@tuxdriver.com>
57bf01
---
57bf01
 classify.c   | 38 +++++++++++++++++++++++++++++---------
57bf01
 irqbalance.c |  2 +-
57bf01
 irqbalance.h |  2 +-
57bf01
 3 files changed, 31 insertions(+), 11 deletions(-)
57bf01
57bf01
diff --git a/classify.c b/classify.c
57bf01
index 94b53b8..8c7d482 100644
57bf01
--- a/classify.c
57bf01
+++ b/classify.c
57bf01
@@ -59,8 +59,9 @@ struct user_irq_policy {
57bf01
 	int numa_node;
57bf01
 };
57bf01
 
57bf01
-static GList *interrupts_db;
57bf01
-static GList *banned_irqs;
57bf01
+static GList *interrupts_db = NULL;
57bf01
+static GList *banned_irqs = NULL;
57bf01
+static GList *cl_banned_irqs = NULL;
57bf01
 
57bf01
 #define SYSDEV_DIR "/sys/bus/pci/devices"
57bf01
 
57bf01
@@ -72,13 +73,13 @@ static gint compare_ints(gconstpointer a, gconstpointer b)
57bf01
 	return ai->irq - bi->irq;
57bf01
 }
57bf01
 
57bf01
-void add_banned_irq(int irq)
57bf01
+void add_banned_irq(int irq, GList **list)
57bf01
 {
57bf01
 	struct irq_info find, *new;
57bf01
 	GList *entry;
57bf01
 
57bf01
 	find.irq = irq;
57bf01
-	entry = g_list_find_custom(banned_irqs, &find, compare_ints);
57bf01
+	entry = g_list_find_custom(*list, &find, compare_ints);
57bf01
 	if (entry)
57bf01
 		return;
57bf01
 
57bf01
@@ -91,10 +92,16 @@ void add_banned_irq(int irq)
57bf01
 	new->irq = irq;
57bf01
 	new->flags |= IRQ_FLAG_BANNED;
57bf01
 
57bf01
-	banned_irqs = g_list_append(banned_irqs, new);
57bf01
+	*list = g_list_append(*list, new);
57bf01
 	return;
57bf01
 }
57bf01
 
57bf01
+void add_cl_banned_irq(int irq)
57bf01
+{
57bf01
+	add_banned_irq(irq, &cl_banned_irqs);
57bf01
+}
57bf01
+
57bf01
+
57bf01
 static int is_banned_irq(int irq)
57bf01
 {
57bf01
 	GList *entry;
57bf01
@@ -324,10 +331,23 @@ static int check_for_irq_ban(char *path, int irq)
57bf01
 {
57bf01
 	char *cmd;
57bf01
 	int rc;
57bf01
+	struct irq_info find;
57bf01
+	GList *entry;
57bf01
+
57bf01
+	/*
57bf01
+	 * Check to see if we banned this irq on the command line
57bf01
+	 */
57bf01
+	find.irq = irq;
57bf01
+	entry = g_list_find_custom(cl_banned_irqs, &find, compare_ints);
57bf01
+	if (entry)
57bf01
+		return 1;
57bf01
 
57bf01
 	if (!banscript)
57bf01
 		return 0;
57bf01
 
57bf01
+	if (!path)
57bf01
+		return 0;
57bf01
+
57bf01
 	cmd = alloca(strlen(path)+strlen(banscript)+32);
57bf01
 	if (!cmd)
57bf01
 		return 0;
57bf01
@@ -382,7 +402,7 @@ static void build_one_dev_entry(const char *dirname)
57bf01
 					continue;
57bf01
 				get_irq_user_policy(devpath, irqnum, &pol;;
57bf01
 				if ((pol.ban == 1) || (check_for_irq_ban(devpath, irqnum))) {
57bf01
-					add_banned_irq(irqnum);
57bf01
+					add_banned_irq(irqnum, &banned_irqs);
57bf01
 					continue;
57bf01
 				}
57bf01
 				new = add_one_irq_to_db(devpath, irqnum, &pol;;
57bf01
@@ -411,7 +431,7 @@ static void build_one_dev_entry(const char *dirname)
57bf01
 			goto done;
57bf01
 		get_irq_user_policy(devpath, irqnum, &pol;;
57bf01
 		if ((pol.ban == 1) || (check_for_irq_ban(path, irqnum))) {
57bf01
-			add_banned_irq(irqnum);
57bf01
+			add_banned_irq(irqnum, &banned_irqs);
57bf01
 			goto done;
57bf01
 		}
57bf01
 
57bf01
@@ -497,8 +517,8 @@ struct irq_info *add_new_irq(int irq, struct irq_info *hint)
57bf01
 		return NULL;
57bf01
 
57bf01
 	get_irq_user_policy("/sys", irq, &pol;;
57bf01
-	if (pol.ban == 1) {
57bf01
-		add_banned_irq(irq);
57bf01
+	if ((pol.ban == 1) || check_for_irq_ban(NULL, irq)) {
57bf01
+		add_banned_irq(irq, &banned_irqs);
57bf01
 		new = get_irq_info(irq);
57bf01
 	} else
57bf01
 		new = add_one_irq_to_db("/sys", irq, &pol;;
57bf01
diff --git a/irqbalance.c b/irqbalance.c
57bf01
index 2532242..e0b3cbe 100644
57bf01
--- a/irqbalance.c
57bf01
+++ b/irqbalance.c
57bf01
@@ -151,7 +151,7 @@ static void parse_command_line(int argc, char **argv)
57bf01
 					usage();
57bf01
 					exit(1);
57bf01
 				}
57bf01
-				add_banned_irq((int)val);
57bf01
+				add_cl_banned_irq((int)val);
57bf01
 				break;
57bf01
 			case 'l':
57bf01
 				polscript = strdup(optarg);
57bf01
diff --git a/irqbalance.h b/irqbalance.h
57bf01
index 04cf9d8..cb648a5 100644
57bf01
--- a/irqbalance.h
57bf01
+++ b/irqbalance.h
57bf01
@@ -106,7 +106,7 @@ extern int get_cpu_count(void);
57bf01
  */
57bf01
 extern void rebuild_irq_db(void);
57bf01
 extern void free_irq_db(void);
57bf01
-extern void add_banned_irq(int irq);
57bf01
+extern void add_cl_banned_irq(int irq);
57bf01
 extern void for_each_irq(GList *list, void (*cb)(struct irq_info *info,  void *data), void *data);
57bf01
 extern struct irq_info *get_irq_info(int irq);
57bf01
 extern void migrate_irq(GList **from, GList **to, struct irq_info *info);
57bf01
-- 
57bf01
2.4.3
57bf01