106 lines
3.4 KiB
Diff
106 lines
3.4 KiB
Diff
From e44eed4faef6ee1bd1ae41dd27a8513d37681f7f Mon Sep 17 00:00:00 2001
|
|
From: liuchao <liuchao173@huawei.com>
|
|
Date: Tue, 17 Dec 2019 02:54:57 +0000
|
|
Subject: [PATCH] feature: add switch to clear affinity hint
|
|
|
|
All irqs' affinity hints are cleared in update_affinity_hint and forced
|
|
to rebalance. In some scenarios, it will affect performance.
|
|
---
|
|
hint_verify.c | 10 +++++++++-
|
|
irqbalance.c | 9 +++++++--
|
|
2 files changed, 16 insertions(+), 3 deletions(-)
|
|
|
|
diff --git a/hint_verify.c b/hint_verify.c
|
|
index 3492902..2f895be 100644
|
|
--- a/hint_verify.c
|
|
+++ b/hint_verify.c
|
|
@@ -18,6 +18,7 @@ extern int keep_going;
|
|
extern GMainLoop *main_loop;
|
|
extern gboolean scan();
|
|
extern int last_interval;
|
|
+extern int clear_affinity_hint;
|
|
|
|
int real_sleep_interval;
|
|
int sleep_interval_count;
|
|
@@ -55,7 +56,8 @@ void update_affinity_hint(struct irq_info *info, void *data __attribute__((unuse
|
|
if (!hint_enabled)
|
|
return;
|
|
|
|
- cpus_clear(info->affinity_hint);
|
|
+ if (clear_affinity_hint)
|
|
+ cpus_clear(info->affinity_hint);
|
|
sprintf(path, "/proc/irq/%d/affinity_hint", info->irq);
|
|
process_one_line(path, get_mask_from_bitmap, ¤t_affinity_hint);
|
|
|
|
@@ -68,6 +70,11 @@ void update_affinity_hint(struct irq_info *info, void *data __attribute__((unuse
|
|
}
|
|
}
|
|
|
|
+static void check_clear()
|
|
+{
|
|
+ process_one_line("/etc/sysconfig/irqbalance_clear", get_int, &clear_affinity_hint);
|
|
+}
|
|
+
|
|
/*
|
|
* This function is the main loop of irqbalance, which include:
|
|
* 1. scan opration for irq balancing;
|
|
@@ -92,6 +99,7 @@ gboolean poll_hint_affinity_and_scan(gpointer data __attribute__((unused)))
|
|
sleep_count++;
|
|
|
|
if (need_verify_flag && hint_changed()) {
|
|
+ check_clear();
|
|
for_each_irq(NULL, update_affinity_hint, NULL);
|
|
if (hint_has_changed) {
|
|
hint_has_changed = FALSE;
|
|
diff --git a/irqbalance.c b/irqbalance.c
|
|
index c7a1488..de7f4e4 100644
|
|
--- a/irqbalance.c
|
|
+++ b/irqbalance.c
|
|
@@ -54,6 +54,7 @@ int numa_avail;
|
|
int journal_logging = 0;
|
|
int need_rescan;
|
|
int need_rebuild;
|
|
+int clear_affinity_hint = 1;
|
|
unsigned int log_mask = TO_ALL;
|
|
const char *log_indent;
|
|
unsigned long power_thresh = ULONG_MAX;
|
|
@@ -109,6 +110,7 @@ struct option lopts[] = {
|
|
{"rulesconfig", 1, NULL, 'r'},
|
|
{"hintpolicy", 1, NULL, 'h'},
|
|
{"verifyhint", 1, NULL, 'v'},
|
|
+ {"notclearhint", 0, NULL, 'n'},
|
|
{0, 0, 0, 0}
|
|
};
|
|
|
|
@@ -117,7 +119,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>] [--migrateval= | -e <n>]\n");
|
|
- log(TO_CONSOLE, LOG_INFO, " [--rulesconfig= | -r <config>] [--hintpolicy | -h <subset>] [--verifyhint= | -v n]\n");
|
|
+ log(TO_CONSOLE, LOG_INFO, " [--rulesconfig= | -r <config>] [--hintpolicy | -h <subset>] [--verifyhint= | -v n] [--notclearhint | -n]\n");
|
|
}
|
|
|
|
static void version(void)
|
|
@@ -133,7 +135,7 @@ static void parse_command_line(int argc, char **argv)
|
|
char *endptr;
|
|
|
|
while ((opt = getopt_long(argc, argv,
|
|
- "odfjVi:p:s:c:l:m:t:e:r:h:v:",
|
|
+ "odfjVni:p:s:c:l:m:t:e:r:h:v:",
|
|
lopts, &longind)) != -1) {
|
|
|
|
switch(opt) {
|
|
@@ -228,6 +230,9 @@ static void parse_command_line(int argc, char **argv)
|
|
exit(1);
|
|
}
|
|
break;
|
|
+ case 'n':
|
|
+ clear_affinity_hint = 0;
|
|
+ break;
|
|
}
|
|
}
|
|
}
|
|
--
|
|
2.33.0
|
|
|