fix parse_affinity for CPU numbers greater than 31 The function parse_affinity reports wrong results for CPU numbers greater than 31. The problem is caused by the function bitmastlist which parse_affinity calls. The fix treats the inpput line as a long hexbitmask instead of an array in order to produce correct results Signed-off-by: Jozef Bacik <jobacik@redhat.com> Signed-off-by: John Kacur <jkacur@redhat.com> Signed-off-by: Jiri Kastner <jkastner@redhat.com>
diff --git a/procfs/utilist.py b/procfs/utilist.py index 18645c0..0e7c24f 100755 --- a/procfs/utilist.py +++ b/procfs/utilist.py
@@ -37,18 +37,14 @@ return hexbitmask def bitmasklist(line, nr_entries): - fields = line.strip().split(",") + hexmask = line.strip().replace(",", "") bitmasklist = [] entry = 0 - for i in range(len(fields) - 1, -1, -1): - mask = int(fields[i], 16) - while mask != 0: - if mask & 1: - bitmasklist.append(entry) - mask >>= 1 - entry += 1 - if entry == nr_entries: - break + bitmask = bin(int(hexmask, 16))[2::] + for i in reversed(bitmask): + if int(i) & 1: + bitmasklist.append(entry) + entry +=1 if entry == nr_entries: break return bitmasklist