Discussion:
[PATCH] python-linux-procfs: fix parse_affinity for CPU numbers greater than 31
John Kacur
2016-08-24 10:38:33 UTC
Permalink
From: Jozef Bacik <***@redhat.com>

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 <***@redhat.com>
Signed-off-by: John Kacur <***@redhat.com>
---
procfs/utilist.py | 16 ++++++----------
1 file changed, 6 insertions(+), 10 deletions(-)

diff --git a/procfs/utilist.py b/procfs/utilist.py
index 18645c0ba45e..0e7c24f45cda 100755
--- a/procfs/utilist.py
+++ b/procfs/utilist.py
@@ -37,18 +37,14 @@ def hexbitmask(l, nr_entries):
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
--
2.4.11
Loading...