diff options
author | Jozef Bacik <jobacik@redhat.com> | 2016-08-24 11:05:05 +0100 |
---|---|---|
committer | Jiri Kastner <jkastner@redhat.com> | 2016-12-22 22:31:25 +0100 |
commit | 223c237f46fd57abaf90b289611c720dcc6ffa4e (patch) | |
tree | bf91b359fd0f2f021b67356d7ed2b4d24aad1dc5 | |
parent | f1c8bf461da1344ae48f456a129502f276f5fc14 (diff) | |
download | python-linux-procfs-223c237f46fd57abaf90b289611c720dcc6ffa4e.tar.gz |
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>
-rwxr-xr-x | procfs/utilist.py | 16 |
1 files changed, 6 insertions, 10 deletions
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 @@ 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 |