From 0406d202af914881af1a6caf5247e7ac40564366 Mon Sep 17 00:00:00 2001 From: hejingxian Date: Tue, 17 Sep 2019 23:32:54 +0800 Subject: [PATCH] add new user irq policy config rule When there is many irqs, the old user irq policy script will cost too much time. Therefore, we introduce a new user irq policy config rule which avoid policy script running for every irq. --- Makefile.am | 2 +- classify.c | 21 ++++-- irqbalance.c | 15 ++++- irqbalance.h | 1 + placement.c | 3 +- rules_config.c | 174 +++++++++++++++++++++++++++++++++++++++++++++++++ rules_config.h | 40 ++++++++++++ 7 files changed, 246 insertions(+), 10 deletions(-) create mode 100644 rules_config.c create mode 100644 rules_config.h diff --git a/Makefile.am b/Makefile.am index 73988b3..3086d67 100644 --- a/Makefile.am +++ b/Makefile.am @@ -38,7 +38,7 @@ sbin_PROGRAMS += irqbalance-ui endif irqbalance_SOURCES = activate.c bitmap.c classify.c cputree.c irqbalance.c \ - irqlist.c numa.c placement.c procinterrupts.c + irqlist.c numa.c placement.c procinterrupts.c rules_config.c irqbalance_LDADD = $(LIBCAP_NG_LIBS) $(GLIB2_LIBS) $(NUMA_LIBS) if IRQBALANCEUI irqbalance_ui_SOURCES = $(UI_DIR)/helpers.c $(UI_DIR)/irqbalance-ui.c \ diff --git a/classify.c b/classify.c index 74103bf..254197e 100644 --- a/classify.c +++ b/classify.c @@ -625,12 +625,20 @@ static void add_new_irq(char *path, struct irq_info *hint, GList *proc_interrupt return; /* Set NULL devpath for the irq has no sysfs entries */ - get_irq_user_policy(path, irq, &pol); + if (user_policy_list == NULL) { + get_irq_user_policy(path, irq, &pol); + } else { + memset(&pol, -1, sizeof(struct user_irq_policy)); + } if ((pol.ban == 1) || check_for_irq_ban(irq, proc_interrupts)) { /*FIXME*/ __add_banned_irq(irq, &banned_irqs); new = get_irq_info(irq); - } else + } else { new = add_one_irq_to_db(path, hint, &pol); + if ((new != NULL) && (user_policy_list != NULL)) { + set_usr_irq_policy(hint->name, new); + } + } if (!new) log(TO_CONSOLE, LOG_WARNING, "add_new_irq: Failed to add irq %d\n", irq); @@ -781,14 +787,15 @@ int proc_irq_hotplug(char *savedline, int irq, struct irq_info **pinfo) { struct irq_info tmp_info = {0}; - /* firstly, init irq info by read device info */ + /* firstly, init irq info by parse savedline */ + init_irq_class_and_type(savedline, &tmp_info, irq); + /* secondly, init irq info by read device info */ *pinfo = build_dev_irqs(interrupts_db, irq); if (*pinfo == NULL) { - /* secondly, init irq info by parse savedline */ - init_irq_class_and_type(savedline, &tmp_info, irq); add_new_irq(NULL, &tmp_info, interrupts_db); *pinfo = get_irq_info(irq); - } + } else + set_usr_irq_policy(tmp_info.name, *pinfo); if (*pinfo == NULL) { return -1; } diff --git a/irqbalance.c b/irqbalance.c index 10e2b13..ecc3eca 100644 --- a/irqbalance.c +++ b/irqbalance.c @@ -99,6 +99,7 @@ struct option lopts[] = { {"interval", 1 , NULL, 't'}, {"version", 0, NULL, 'V'}, {"migrateval", 1, NULL, 'e'}, + {"rulesconfig", 1, NULL, 'r'}, {0, 0, 0, 0} }; @@ -107,6 +108,7 @@ static void usage(void) log(TO_CONSOLE, LOG_INFO, "irqbalance [--oneshot | -o] [--debug | -d] [--foreground | -f] [--journal | -j]\n"); log(TO_CONSOLE, LOG_INFO, " [--powerthresh= | -p | ] [--banirq= | -i ] [--banmod= | -m ] [--policyscript= | -l