irqbalance/feature-add-new-irq-migrate-rule-to-avoid-high-cpu-i.patch

93 lines
3.2 KiB
Diff
Raw Normal View History

2021-04-09 14:45:12 +08:00
From 84a2df1c9962a87f55e1c0d3bd2118fd754a4b48 Mon Sep 17 00:00:00 2001
From: hejingxian <hejingxian@huawei.com>
Date: Fri, 3 Jan 2020 16:43:28 +0800
Subject: [PATCH] feature: add new irq migrate rule to avoid high cpu irq load
By the old irq migrate rule, the irqs cannot be moved if the adjustment_load will become smaller then
the min_load after moving irq. However, we can accept that the delta load become smaller after moving irq.
---
irqbalance.c | 8 +++++++-
irqbalance.h | 1 +
irqlist.c | 6 ++++-
2021-04-09 14:45:12 +08:00
3 files changed, 10 insertions(+), 2 deletions(-)
diff --git a/irqbalance.c b/irqbalance.c
index 9449e40..82ac3ea 100644
--- a/irqbalance.c
+++ b/irqbalance.c
@@ -72,6 +72,7 @@ GMainLoop *main_loop;
char *cpu_ban_string = NULL;
char *banned_cpumask_from_ui = NULL;
unsigned long migrate_ratio = 0;
+unsigned long load_limit = 0;
static void sleep_approx(int seconds)
{
@@ -106,6 +107,7 @@ struct option lopts[] = {
{"hintpolicy", 1, NULL, 'h'},
{"verifyhint", 1, NULL, 'v'},
{"notclearhint", 0, NULL, 'n'},
+ {"loadlimit", 1, NULL, 'g'},
{0, 0, 0, 0}
};
@@ -115,6 +117,7 @@ static void usage(void)
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>] [--migrateval= | -e <n>]\n");
log(TO_CONSOLE, LOG_INFO, " [--rulesconfig= | -r <config>] [--hintpolicy | -h <subset>] [--verifyhint= | -v n] [--notclearhint | -n]\n");
+ log(TO_CONSOLE, LOG_INFO, " [--loadlimit= | -g <n>]\n");
}
static void version(void)
@@ -129,7 +132,7 @@ static void parse_command_line(int argc, char **argv)
unsigned long val;
while ((opt = getopt_long(argc, argv,
- "odfjVni:p:s:c:l:m:t:e:r:h:v:",
+ "odfjVni:p:s:c:l:m:t:e:r:h:v:g:",
lopts, &longind)) != -1) {
switch(opt) {
@@ -223,6 +226,9 @@ static void parse_command_line(int argc, char **argv)
case 'n':
clear_affinity_hint = 0;
break;
+ case 'g':
+ load_limit = strtoul(optarg, NULL, 10);
+ break;
}
}
}
diff --git a/irqbalance.h b/irqbalance.h
index 4a73b83..9ff8f37 100644
--- a/irqbalance.h
+++ b/irqbalance.h
@@ -83,6 +83,7 @@ extern cpumask_t banned_cpus;
extern cpumask_t unbanned_cpus;
extern long HZ;
extern unsigned long migrate_ratio;
+extern unsigned long load_limit;
/*
* Numa node access routines
diff --git a/irqlist.c b/irqlist.c
index 9ab321a..98a4224 100644
--- a/irqlist.c
+++ b/irqlist.c
@@ -97,7 +97,11 @@ static void move_candidate_irqs(struct irq_info *info, void *data)
2021-04-09 14:45:12 +08:00
}
/* If we can migrate an irq without swapping the imbalance do it. */
- if ((lb_info->min_load + info->load) < delta_load + (lb_info->adjustment_load - info->load)) {
+ if ((lb_info->adjustment_load - info->load) > (lb_info->min_load + info->load)) {
+ lb_info->adjustment_load -= info->load;
+ lb_info->min_load += info->load;
+ } else if (delta_load && load_limit && (lb_info->adjustment_load > load_limit) &&
+ (lb_info->min_load + info->load) < (lb_info->adjustment_load - info->load) + delta_load) {
2021-04-09 14:45:12 +08:00
lb_info->adjustment_load -= info->load;
lb_info->min_load += info->load;
if (lb_info->min_load > lb_info->adjustment_load) {
--
2.23.0