Skip to content

Commit

Permalink
irqbalance: fix invalid cpu mask parsing
Browse files Browse the repository at this point in the history
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":

0000000: 000a
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@intel.com>
Signed-off-by: Neil Horman <nhorman@tuxdriver.com.
  • Loading branch information
tstruk authored and Neil Horman committed Dec 1, 2016
1 parent aa04f78 commit 3c9a009
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions cputree.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down

0 comments on commit 3c9a009

Please sign in to comment.