Skip to content

Commit

Permalink
perf: net_dropmonitor: Do not assume ordering of dictionaries
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Ben Hutchings authored and David S. Miller committed May 22, 2013
1 parent 5a1e99d commit 326017c
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions tools/perf/scripts/python/net_dropmonitor.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,17 +32,17 @@ def get_kallsyms_table():
j = j +1
if ((j % 100) == 0):
print "\r" + str(j) + "/" + str(linecount),
kallsyms.append({ 'loc': loc, 'name' : name})
kallsyms.append((loc, name))

print "\r" + str(j) + "/" + str(linecount)
kallsyms.sort()
return

def get_sym(sloc):
loc = int(sloc)
for i in kallsyms[::-1]:
if loc >= i['loc']:
return (i['name'], loc - i['loc'])
for symloc, name in kallsyms[::-1]:
if loc >= symloc:
return (name, loc - symloc)
return (None, 0)

def print_drop_table():
Expand Down

0 comments on commit 326017c

Please sign in to comment.