irqbalance/improve-irq-migrate-rule-to-avoid-high-irq-load.patch
2020-07-03 17:09:39 +08:00

106 lines
3.2 KiB
Diff

From e9e28114036a198b311ee17dd542540f749e6a68 Mon Sep 17 00:00:00 2001
From: hejingxian 00273181 <hejingxian@huawei.com>
Date: Mon, 20 Jan 2020 23:20:47 +0800
Subject: [PATCH 48/53] improve irq migrate rule to avoid high irq load
---
irqbalance.c | 9 +++++++--
irqbalance.h | 1 +
irqlist.c | 10 +++++++++-
3 files changed, 17 insertions(+), 3 deletions(-)
diff --git a/irqbalance.c b/irqbalance.c
index be111f1..513ab5a 100644
--- a/irqbalance.c
+++ b/irqbalance.c
@@ -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;
}
}
}
diff --git a/irqbalance.h b/irqbalance.h
index 3e3ea5d..cd93167 100644
--- a/irqbalance.h
+++ b/irqbalance.h
@@ -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
diff --git a/irqlist.c b/irqlist.c
index 95ccc7a..9ab321a 100644
--- a/irqlist.c
+++ b/irqlist.c
@@ -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;
--
2.23.0