124 lines
3.7 KiB
Diff
124 lines
3.7 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] 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 | 26 +++++++++++++++++++++++++-
|
|
irqbalance.c | 10 ++++++++--
|
|
2 files changed, 33 insertions(+), 3 deletions(-)
|
|
|
|
diff --git a/hint_verify.c b/hint_verify.c
|
|
index 0718078..11ef868 100644
|
|
--- a/hint_verify.c
|
|
+++ b/hint_verify.c
|
|
@@ -16,6 +16,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;
|
|
@@ -57,7 +58,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);
|
|
file = fopen(path, "r");
|
|
if (!file)
|
|
@@ -80,6 +82,27 @@ void update_affinity_hint(struct irq_info *info, void *data __attribute__((unuse
|
|
free(line);
|
|
}
|
|
|
|
+static void check_clear()
|
|
+{
|
|
+ char *line = NULL;
|
|
+ size_t size = 0;
|
|
+ FILE *file;
|
|
+
|
|
+ file = fopen("/etc/sysconfig/irqbalance_clear", "r");
|
|
+ if (!file)
|
|
+ return;
|
|
+ if (getline(&line, &size, file) <= 0)
|
|
+ goto out;
|
|
+ if (line != NULL && strstr(line, "0") != NULL)
|
|
+ clear_affinity_hint = 0;
|
|
+ else
|
|
+ clear_affinity_hint = 1;
|
|
+
|
|
+out:
|
|
+ fclose(file);
|
|
+ free(line);
|
|
+}
|
|
+
|
|
/*
|
|
* This function is the main loop of irqbalance, which include:
|
|
* 1. scan opration for irq balancing;
|
|
@@ -104,6 +127,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 05eaa29..77076fa 100644
|
|
--- a/irqbalance.c
|
|
+++ b/irqbalance.c
|
|
@@ -55,6 +55,7 @@ int foreground_mode;
|
|
int numa_avail;
|
|
int journal_logging = 0;
|
|
int need_rescan;
|
|
+int clear_affinity_hint = 1;
|
|
unsigned int log_mask = TO_ALL;
|
|
const char *log_indent;
|
|
unsigned long power_thresh = ULONG_MAX;
|
|
@@ -104,14 +105,16 @@ struct option lopts[] = {
|
|
{"version", 0, NULL, 'V'},
|
|
{"verifyhint", 1, NULL, 'v'},
|
|
{"rulesconfig", 1, NULL, 'r'},
|
|
+ {"notclearhint", 0, NULL, 'n'},
|
|
{0, 0, 0, 0}
|
|
};
|
|
|
|
static void usage(void)
|
|
{
|
|
log(TO_CONSOLE, LOG_INFO, "irqbalance [--oneshot | -o] [--debug | -d] [--foreground | -f] [--journal | -j] [--hintpolicy | -h <subset>]\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>] [--verifyhint= | -v n] [--rulesconfig= | -r <config>]\n");
|
|
+ log(TO_CONSOLE, LOG_INFO, " [--pid= | -s <file>] [--deepestcache= | -c <n>] [--interval= | -t <n>] [--verifyhint= | -v n]\n");
|
|
+ log(TO_CONSOLE, LOG_INFO, " [--rulesconfig= | -r <config>] [--notclearhint | -n]\n");
|
|
}
|
|
|
|
static void version(void)
|
|
@@ -126,7 +128,7 @@ static void parse_command_line(int argc, char **argv)
|
|
unsigned long val;
|
|
|
|
while ((opt = getopt_long(argc, argv,
|
|
- "odfji:p:s:c:b:l:m:t:V:h:v:r:",
|
|
+ "odfji:p:s:c:b:l:m:t:V:h:v:r:n",
|
|
lopts, &longind)) != -1) {
|
|
|
|
switch(opt) {
|
|
@@ -225,6 +227,10 @@ static void parse_command_line(int argc, char **argv)
|
|
case 'r':
|
|
rules_config_file = strdup(optarg);
|
|
break;
|
|
+ case 'n':
|
|
+ clear_affinity_hint = 0;
|
|
+ break;
|
|
+
|
|
}
|
|
}
|
|
}
|
|
--
|
|
2.19.1
|
|
|