diff --git a/classify.c b/classify.c index 4b6ffa8..beb2919 100644 --- a/classify.c +++ b/classify.c @@ -852,3 +852,40 @@ void sort_irq_list(GList **list) { *list = g_list_sort(*list, sort_irqs); } + +static void remove_no_existing_irq(struct irq_info *info, void *data __attribute__((unused))) +{ + GList *entry = NULL; + + if (info->existing) { + /* clear existing flag for next detection */ + info->existing = 0; + return; + } + + entry = g_list_find_custom(interrupts_db, info, compare_ints); + if (entry) + interrupts_db = g_list_delete_link(interrupts_db, entry); + + entry = g_list_find_custom(rebalance_irq_list, info, compare_ints); + if (entry) + rebalance_irq_list = g_list_delete_link(rebalance_irq_list, entry); + + if(info->assigned_obj) { + entry = g_list_find_custom(info->assigned_obj->interrupts, info, compare_ints); + if (entry) { + info->assigned_obj->interrupts = g_list_delete_link(info->assigned_obj->interrupts, entry); + } + } + log(TO_CONSOLE, LOG_INFO, "IRQ %d is removed from interrupts_db.\n", info->irq); + free_irq(info, NULL); +} + +void clear_no_existing_irqs(void) +{ + for_each_irq(NULL, remove_no_existing_irq, NULL); + if (banned_irqs) { + for_each_irq(banned_irqs, remove_no_existing_irq, NULL); + } +} + diff --git a/irqbalance.h b/irqbalance.h index d8e80a9..e7f6b94 100644 --- a/irqbalance.h +++ b/irqbalance.h @@ -42,6 +42,7 @@ extern void set_interrupt_count(int number, uint64_t count); extern void set_msi_interrupt_numa(int number); extern void init_irq_class_and_type(char *savedline, struct irq_info *info, int irq); extern int proc_irq_hotplug(char *line, int irq, struct irq_info **pinfo); +extern void clear_no_existing_irqs(void); extern GList *rebalance_irq_list; extern void force_rebalance_irq(struct irq_info *info, void *data __attribute__((unused))); diff --git a/procinterrupts.c b/procinterrupts.c index 0671be0..854282f 100644 --- a/procinterrupts.c +++ b/procinterrupts.c @@ -248,7 +248,6 @@ GList* collect_full_irq_list() return tmp_list; } - void parse_proc_interrupts(void) { FILE *file; @@ -310,6 +309,7 @@ void parse_proc_interrupts(void) break; } } + info->existing = 1; free(savedline); count = 0; @@ -354,6 +354,8 @@ void parse_proc_interrupts(void) */ msi_found_in_sysfs = 1; } + if (!need_rescan) + clear_no_existing_irqs(); fclose(file); free(line); } diff --git a/types.h b/types.h index a01d649..9693cf4 100644 --- a/types.h +++ b/types.h @@ -70,6 +70,7 @@ struct irq_info { uint64_t last_irq_count; uint64_t load; int moved; + int existing; struct topo_obj *assigned_obj; char *name; };