[PATCH] irqbalance: fix invalid cpu mask parsing
Tadeusz Struk
tadeusz.struk at intel.com
Wed Nov 30 15:32:22 PST 2016
Irq balancer scans the isolcpus and nohz_full kernel masks and adds the
corresponding CPUs to the banned_cpus mask. This works fine for valid masks,
but not for the default, emtpy masks. In this case when they read from the
sysfs they return empty strings, "\n" or "0x0, \n":
# xxd /sys/devices/system/cpu/nohz_full
0000000: 000a
# xxd /sys/devices/system/cpu/isolated
0000000: 0a
Irqbalancer reads them and blindly passes these values to the
__bitmap_parselist() function, which expects ASCII string format.
For this input the implementation always set the first bit indicating CPU 0.
Steps to Reproduce:
1. Make sure /sys/devices/system/cpu/nohz_full and
/sys/devices/system/cpu/isolated are empty
2. run $ /usr/sbin/irqbalance -d --oneshot | grep Isolated
Actual results:
Isolated CPUs: 00000001
Expected results:
Isolated CPUs: 00000000
Signed-off-by: Tadeusz Struk <tadeusz.struk at intel.com>
---
cputree.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/cputree.c b/cputree.c
index a188ead..8762b64 100644
--- a/cputree.c
+++ b/cputree.c
@@ -84,7 +84,8 @@ static void setup_banned_cpus(void)
file = fopen("/sys/devices/system/cpu/isolated", "r");
if (file) {
if (getline(&line, &size, file) > 0) {
- cpulist_parse(line, size, isolated_cpus);
+ if (strlen(line) && line[0] != '\n')
+ cpulist_parse(line, strlen(line), isolated_cpus);
free(line);
line = NULL;
size = 0;
@@ -95,7 +96,8 @@ static void setup_banned_cpus(void)
file = fopen("/sys/devices/system/cpu/nohz_full", "r");
if (file) {
if (getline(&line, &size, file) > 0) {
- cpulist_parse(line, size, nohz_full);
+ if (strlen(line) && line[0] != '\n')
+ cpulist_parse(line, strlen(line), nohz_full);
free(line);
line = NULL;
size = 0;
More information about the irqbalance
mailing list