y***@skhms.com
2016-06-22 19:58:35 UTC
Hi tuna-devel team,
wrong cpu number was observed from tuna cli as below and I found bitmasklist() casued it.
cpu bitmask = 80,00000000 (cpu 39 out of 40 cpus)
current cpu number = 7
expected cpu number = 39
(1) current code
def bitmasklist(line, nr_entries):
fields = line.strip().split(",")
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
if entry == nr_entries:
break
return bitmasklist
(2) code change proposal
def bitmasklist(line, nr_entries):
fields = line.strip().split(",")
bitmasklist = []
# entry = 0
for i in range(len(fields) - 1, -1, -1):
entry = 32 * (len(fields) - 1 - i)
mask = int(fields[i], 16)
while mask != 0:
if mask & 1:
bitmasklist.append(entry)
mask >>= 1
entry += 1
if entry == nr_entries:
break
if entry == nr_entries:
break
return bitmasklist
Please review on this code change proposal and deploy to the repository if ok.
Thanks,
YT
wrong cpu number was observed from tuna cli as below and I found bitmasklist() casued it.
cpu bitmask = 80,00000000 (cpu 39 out of 40 cpus)
current cpu number = 7
expected cpu number = 39
(1) current code
def bitmasklist(line, nr_entries):
fields = line.strip().split(",")
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
if entry == nr_entries:
break
return bitmasklist
(2) code change proposal
def bitmasklist(line, nr_entries):
fields = line.strip().split(",")
bitmasklist = []
# entry = 0
for i in range(len(fields) - 1, -1, -1):
entry = 32 * (len(fields) - 1 - i)
mask = int(fields[i], 16)
while mask != 0:
if mask & 1:
bitmasklist.append(entry)
mask >>= 1
entry += 1
if entry == nr_entries:
break
if entry == nr_entries:
break
return bitmasklist
Please review on this code change proposal and deploy to the repository if ok.
Thanks,
YT