Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

perf: net_dropmonitor: Do not assume ordering of dictionaries

The sort order of dictionaries in Python is undocumented. Use
tuples instead, which are documented to be lexically ordered.

Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Ben Hutchings and committed by
David S. Miller
326017c7 5a1e99dd

+4 -4
+4 -4
tools/perf/scripts/python/net_dropmonitor.py
··· 32 32 j = j +1 33 33 if ((j % 100) == 0): 34 34 print "\r" + str(j) + "/" + str(linecount), 35 - kallsyms.append({ 'loc': loc, 'name' : name}) 35 + kallsyms.append((loc, name)) 36 36 37 37 print "\r" + str(j) + "/" + str(linecount) 38 38 kallsyms.sort() ··· 40 40 41 41 def get_sym(sloc): 42 42 loc = int(sloc) 43 - for i in kallsyms[::-1]: 44 - if loc >= i['loc']: 45 - return (i['name'], loc - i['loc']) 43 + for symloc, name in kallsyms[::-1]: 44 + if loc >= symloc: 45 + return (name, loc - symloc) 46 46 return (None, 0) 47 47 48 48 def print_drop_table():