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

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