Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 376164
b: refs/heads/master
c: 0ce58ba
h: refs/heads/master
v: v3
  • Loading branch information
Ben Hutchings authored and David S. Miller committed May 22, 2013
1 parent 8fee07a commit 3ec5b94
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 5 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 326017c757e387007c6629797d7ae22fd33c1317
refs/heads/master: 0ce58bae851dc3728af1c0b83905cd6b4565417a
22 changes: 18 additions & 4 deletions trunk/tools/perf/scripts/python/net_dropmonitor.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,24 @@ def get_kallsyms_table():

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

# Invariant: kallsyms[i][0] <= loc for all 0 <= i <= start
# kallsyms[i][0] > loc for all end <= i < len(kallsyms)
start, end = -1, len(kallsyms)
while end != start + 1:
pivot = (start + end) // 2
if loc < kallsyms[pivot][0]:
end = pivot
else:
start = pivot

# Now (start == -1 or kallsyms[start][0] <= loc)
# and (start == len(kallsyms) - 1 or loc < kallsyms[start + 1][0])
if start >= 0:
symloc, name = kallsyms[start]
return (name, loc - symloc)
else:
return (None, 0)

def print_drop_table():
print "%25s %25s %25s" % ("LOCATION", "OFFSET", "COUNT")
Expand Down

0 comments on commit 3ec5b94

Please sign in to comment.