Browse Source

Move all active IRQs from excluded cpus to another ones

Serj Kalichev 6 years ago
parent
commit
4534af0afa
3 changed files with 28 additions and 5 deletions
  1. 22 1
      balance.c
  2. 2 1
      balance.h
  3. 4 3
      birq.c

+ 22 - 1
balance.c

@@ -296,7 +296,8 @@ static cpu_t * most_overloaded_cpu(lub_list_t *cpus, float threshold)
    The IRQs with small number of interrupts have very low load or very
    high load (in a case of NAPI). */
 int choose_irqs_to_move(lub_list_t *cpus, lub_list_t *balance_irqs,
-	float threshold, birq_choose_strategy_e strategy)
+	float threshold, birq_choose_strategy_e strategy,
+	cpumask_t *exclude_cpus)
 {
 	lub_list_node_t *iter;
 	cpu_t *overloaded_cpu = NULL;
@@ -308,7 +309,27 @@ int choose_irqs_to_move(lub_list_t *cpus, lub_list_t *balance_irqs,
 
 	/* Stage 1: Try to move active IRQs from excluded-CPUs */
 
+	if (!cpus_empty(*exclude_cpus)) {
+		/* Iterate CPU list and find excluded ones */
+		for (iter = lub_list_iterator_init(cpus); iter;
+			iter = lub_list_iterator_next(iter)) {
+			lub_list_node_t *iter2;
+			cpu_t *cpu = (cpu_t *)lub_list_node__get_data(iter);
+			if (!cpu_isset(cpu->id, *exclude_cpus))
+				continue;
+			/* Move all active IRQs to another CPUs */
+			for (iter2 = lub_list_iterator_init(cpu->irqs); iter2;
+				iter2 = lub_list_iterator_next(iter2)) {
+				irq_t *irq = (irq_t *)lub_list_node__get_data(iter2);
+				if (irq->intr == 0)
+					continue;
+				lub_list_add(balance_irqs, irq);
+			}
+		}
+	}
+
 	/* Stage 2: Move IRQs from overloaded CPUs */
+
 	/* Search for overloaded CPUs */
 	if (!(overloaded_cpu = most_overloaded_cpu(cpus, threshold)))
 		return 0;

+ 2 - 1
balance.h

@@ -17,6 +17,7 @@ int balance(lub_list_t *cpus, lub_list_t *balance_irqs,
 	float load_limit, cpumask_t *exclude_cpus);
 int apply_affinity(lub_list_t *balance_irqs);
 int choose_irqs_to_move(lub_list_t *cpus, lub_list_t *balance_irqs,
-	float threshold, birq_choose_strategy_e strategy);
+	float threshold, birq_choose_strategy_e strategy,
+	cpumask_t *exclude_cpus);
 
 #endif

+ 4 - 3
birq.c

@@ -228,7 +228,7 @@ int main(int argc, char **argv)
 		show_statistics(cpus, opts->verbose);
 		/* Choose IRQ to move to another CPU. */
 		choose_irqs_to_move(cpus, balance_irqs,
-			opts->threshold, opts->strategy);
+			opts->threshold, opts->strategy, &opts->exclude_cpus);
 
 		/* Balance IRQs */
 		if (lub_list_len(balance_irqs) != 0) {
@@ -539,6 +539,7 @@ static void help(int status, const char *argv0)
 /* Parse config file */
 static int parse_config(const char *fname, struct options *opts)
 {
+	int ret = -1; /* Pessimistic retval */
 	lub_ini_t *ini;
 	const char *tmp = NULL;
 
@@ -574,8 +575,8 @@ static int parse_config(const char *fname, struct options *opts)
 			goto err;
 		}
 
-	return 0;
+	ret = 0;
 err:
 	lub_ini_free(ini);
-	return -1;
+	return ret;
 }