improve irq migrate rule to avoid high irq load

This commit is contained in:
hejingxian 00273181 2020-01-20 23:20:47 +08:00
parent 7f77fc97cb
commit e9e2811403
3 changed files with 17 additions and 3 deletions

View file

@ -67,6 +67,7 @@ GMainLoop *main_loop;
char *cpu_ban_string = NULL;
char *banned_cpumask_from_ui = NULL;
unsigned long migrate_ratio = 0;
static void sleep_approx(int seconds)
{
@ -96,6 +97,7 @@ struct option lopts[] = {
{"banmod", 1 , NULL, 'm'},
{"interval", 1 , NULL, 't'},
{"version", 0, NULL, 'V'},
{"migrateval", 1, NULL, 'e'},
{0, 0, 0, 0}
};
@ -103,7 +105,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 <off> | <n>] [--banirq= | -i <n>] [--banmod= | -m <module>] [--policyscript= | -l <script>]\n");
log(TO_CONSOLE, LOG_INFO, " [--pid= | -s <file>] [--deepestcache= | -c <n>] [--interval= | -t <n>]\n");
log(TO_CONSOLE, LOG_INFO, " [--pid= | -s <file>] [--deepestcache= | -c <n>] [--interval= | -t <n>] [--migrateval= | -e <n>]\n");
}
static void version(void)
@ -118,7 +120,7 @@ static void parse_command_line(int argc, char **argv)
unsigned long val;
while ((opt = getopt_long(argc, argv,
"odfjVi:p:s:c:l:m:t:",
"odfjVi:p:s:c:l:m:t:e:",
lopts, &longind)) != -1) {
switch(opt) {
@ -187,6 +189,9 @@ static void parse_command_line(int argc, char **argv)
exit(1);
}
break;
case 'e':
migrate_ratio = strtoul(optarg, NULL, 10);
break;
}
}
}

View file

@ -77,6 +77,7 @@ extern char *polscript;
extern cpumask_t banned_cpus;
extern cpumask_t unbanned_cpus;
extern long HZ;
extern unsigned long migrate_ratio;
/*
* Numa node access routines

View file

@ -76,6 +76,7 @@ static void compute_deviations(struct topo_obj *obj, void *data)
static void move_candidate_irqs(struct irq_info *info, void *data)
{
struct load_balance_info *lb_info = data;
unsigned long delta_load = 0;
/* Don't rebalance irqs that don't want it */
if (info->level == BALANCE_NONE)
@ -91,10 +92,17 @@ static void move_candidate_irqs(struct irq_info *info, void *data)
if (info->load <= 1)
return;
if (migrate_ratio > 0) {
delta_load = (lb_info->adjustment_load - lb_info->min_load) / migrate_ratio;
}
/* If we can migrate an irq without swapping the imbalance do it. */
if ((lb_info->adjustment_load - info->load) > (lb_info->min_load + info->load)) {
if ((lb_info->min_load + info->load) - (lb_info->adjustment_load - info->load) < delta_load) {
lb_info->adjustment_load -= info->load;
lb_info->min_load += info->load;
if (lb_info->min_load > lb_info->adjustment_load) {
lb_info->min_load = lb_info->adjustment_load;
}
} else
return;