irqbalance: separate cmomand line banned irqs from listed banned irqs

irqbalance was using one list for tracking banned irqs, but the list was being
used for disperate pruposes in different places.  It was tracking command line
banned irqs and irqs that were banned via banscript and policyscript.  The
former needs to be remembered accross db rebuilds, while the latter needs to be
rebuilt every time.  This patch separates the two in to two lists, so that we
don't stop banning command line specified irqs after the first db rebuild.

Signed-off-by: Neil Horman <nhorman@tuxdriver.com>
This commit is contained in:
Neil Horman 2014-05-16 10:10:36 -04:00
parent 699deffdd8
commit 7f072d94c9
3 changed files with 31 additions and 11 deletions

View file

@ -59,8 +59,9 @@ struct user_irq_policy {
int numa_node;
};
static GList *interrupts_db;
static GList *banned_irqs;
static GList *interrupts_db = NULL;
static GList *banned_irqs = NULL;
static GList *cl_banned_irqs = NULL;
#define SYSDEV_DIR "/sys/bus/pci/devices"
@ -72,13 +73,13 @@ static gint compare_ints(gconstpointer a, gconstpointer b)
return ai->irq - bi->irq;
}
void add_banned_irq(int irq)
void add_banned_irq(int irq, GList **list)
{
struct irq_info find, *new;
GList *entry;
find.irq = irq;
entry = g_list_find_custom(banned_irqs, &find, compare_ints);
entry = g_list_find_custom(*list, &find, compare_ints);
if (entry)
return;
@ -91,10 +92,16 @@ void add_banned_irq(int irq)
new->irq = irq;
new->flags |= IRQ_FLAG_BANNED;
banned_irqs = g_list_append(banned_irqs, new);
*list = g_list_append(*list, new);
return;
}
void add_cl_banned_irq(int irq)
{
add_banned_irq(irq, &cl_banned_irqs);
}
static int is_banned_irq(int irq)
{
GList *entry;
@ -324,10 +331,23 @@ static int check_for_irq_ban(char *path, int irq)
{
char *cmd;
int rc;
struct irq_info find;
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);
if (entry)
return 1;
if (!banscript)
return 0;
if (!path)
return 0;
cmd = alloca(strlen(path)+strlen(banscript)+32);
if (!cmd)
return 0;
@ -382,7 +402,7 @@ static void build_one_dev_entry(const char *dirname)
continue;
get_irq_user_policy(devpath, irqnum, &pol);
if ((pol.ban == 1) || (check_for_irq_ban(devpath, irqnum))) {
add_banned_irq(irqnum);
add_banned_irq(irqnum, &banned_irqs);
continue;
}
new = add_one_irq_to_db(devpath, irqnum, &pol);
@ -411,7 +431,7 @@ static void build_one_dev_entry(const char *dirname)
goto done;
get_irq_user_policy(devpath, irqnum, &pol);
if ((pol.ban == 1) || (check_for_irq_ban(path, irqnum))) {
add_banned_irq(irqnum);
add_banned_irq(irqnum, &banned_irqs);
goto done;
}
@ -497,8 +517,8 @@ struct irq_info *add_new_irq(int irq, struct irq_info *hint)
return NULL;
get_irq_user_policy("/sys", irq, &pol);
if (pol.ban == 1) {
add_banned_irq(irq);
if ((pol.ban == 1) || check_for_irq_ban(NULL, irq)) {
add_banned_irq(irq, &banned_irqs);
new = get_irq_info(irq);
} else
new = add_one_irq_to_db("/sys", irq, &pol);

View file

@ -151,7 +151,7 @@ static void parse_command_line(int argc, char **argv)
usage();
exit(1);
}
add_banned_irq((int)val);
add_cl_banned_irq((int)val);
break;
case 'l':
polscript = strdup(optarg);

View file

@ -106,7 +106,7 @@ extern int get_cpu_count(void);
*/
extern void rebuild_irq_db(void);
extern void free_irq_db(void);
extern void add_banned_irq(int irq);
extern void add_cl_banned_irq(int irq);
extern void for_each_irq(GList *list, void (*cb)(struct irq_info *info, void *data), void *data);
extern struct irq_info *get_irq_info(int irq);
extern void migrate_irq(GList **from, GList **to, struct irq_info *info);