Blame SOURCES/irqbalance-1.0.8-parse-isolcpus-and-nohz-cpus-from-sysfs.patch

25610a
diff -up irqbalance-1.0.7/cputree.c.orig irqbalance-1.0.7/cputree.c
25610a
--- irqbalance-1.0.7/cputree.c.orig	2016-01-09 20:15:41.928969895 +0100
25610a
+++ irqbalance-1.0.7/cputree.c	2016-01-09 20:16:23.502347264 +0100
25610a
@@ -59,8 +59,8 @@ cpumask_t cpu_possible_map;
25610a
 cpumask_t unbanned_cpus;
25610a
 
25610a
 /*
25610a
- * By default do not place IRQs on CPUs the kernel keeps isolated,
25610a
- * as specified through the isolcpus= boot commandline. Users can
25610a
+ * By default do not place IRQs on CPUs the kernel keeps isolated or
25610a
+ * nohz_full, as specified through the boot commandline. Users can
25610a
  * override this with the IRQBALANCE_BANNED_CPUS environment variable.
25610a
  */
25610a
 static void setup_banned_cpus(void)
25610a
@@ -69,7 +69,13 @@ static void setup_banned_cpus(void)
25610a
 	char *c, *line = NULL;
25610a
 	size_t size = 0;
25610a
 	const char *isolcpus = "isolcpus=";
25610a
+	const char *nohz_full_s = "nohz_full=";
25610a
 	char buffer[4096];
25610a
+	cpumask_t nohz_full;
25610a
+	cpumask_t isolated_cpus;
25610a
+
25610a
+	cpus_clear(isolated_cpus);
25610a
+	cpus_clear(nohz_full);
25610a
 
25610a
 	/* A manually specified cpumask overrides auto-detection. */
25610a
 	if (getenv("IRQBALANCE_BANNED_CPUS"))  {
25610a
@@ -77,6 +83,33 @@ static void setup_banned_cpus(void)
25610a
 		goto out;
25610a
 	}
25610a
 
25610a
+	file = fopen("/sys/devices/system/cpu/nohz_full", "r");
25610a
+	if (!file)
25610a
+		goto cmdline;
25610a
+
25610a
+	if (getline(&line, &size, file) > 0) {
25610a
+		cpulist_parse(line, size, nohz_full);
25610a
+		free(line);
25610a
+		line = NULL;
25610a
+		size = 0;
25610a
+	}
25610a
+	fclose(file);
25610a
+
25610a
+	file = fopen("/sys/devices/system/cpu/isolated", "r");
25610a
+	if (file) {
25610a
+		if (getline(&line, &size, file) > 0) {
25610a
+			cpulist_parse(line, size, isolated_cpus);
25610a
+			free(line);
25610a
+			line = NULL;
25610a
+			size = 0;
25610a
+		}
25610a
+		fclose(file);
25610a
+	}
25610a
+
25610a
+	goto out2;
25610a
+
25610a
+ cmdline:
25610a
+
25610a
 	file = fopen("/proc/cmdline", "r");
25610a
 	if (!file)
25610a
 		goto out;
25610a
@@ -92,12 +125,31 @@ static void setup_banned_cpus(void)
25610a
 		for (end = c; *end != ' ' && *end != '\0' && *end != '\n'; end++);
25610a
 		len = end - c;
25610a
 
25610a
-		cpulist_parse(c, len, banned_cpus);
25610a
+		cpulist_parse(c, len, isolated_cpus);
25610a
 	}
25610a
 
25610a
+	if ((c = strstr(line, nohz_full_s))) {
25610a
+		char *end;
25610a
+		int len;
25610a
+
25610a
+		c += strlen(nohz_full_s);
25610a
+		for (end = c; *end != ' ' && *end != '\0' && *end != '\n'; end++);
25610a
+		len = end - c;
25610a
+
25610a
+		cpulist_parse(c, len, nohz_full);
25610a
+	}
25610a
+
25610a
+	free(line);
25610a
+	fclose(file);
25610a
+
25610a
+ out2:
25610a
+	cpus_or(banned_cpus, nohz_full, isolated_cpus);
25610a
+
25610a
  out:
25610a
-	cpumask_scnprintf(buffer, 4096, banned_cpus);
25610a
+	cpumask_scnprintf(buffer, 4096, isolated_cpus);
25610a
 	log(TO_CONSOLE, LOG_INFO, "Isolated CPUs: %s\n", buffer);
25610a
+	cpumask_scnprintf(buffer, 4096, nohz_full);
25610a
+	log(TO_CONSOLE, LOG_INFO, "Adaptive-ticks CPUs: %s\n", buffer);
25610a
 }
25610a
 
25610a
 static struct topo_obj* add_cache_domain_to_package(struct topo_obj *cache,