mirror of
https://github.com/Fishwaldo/Star64_linux.git
synced 2025-06-23 23:21:46 +00:00
perf: net_dropmonitor: Use bisection in symbol lookup
Signed-off-by: Ben Hutchings <ben@decadent.org.uk> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
parent
326017c757
commit
0ce58bae85
1 changed files with 18 additions and 4 deletions
|
@ -40,9 +40,23 @@ def get_kallsyms_table():
|
||||||
|
|
||||||
def get_sym(sloc):
|
def get_sym(sloc):
|
||||||
loc = int(sloc)
|
loc = int(sloc)
|
||||||
for symloc, name in kallsyms[::-1]:
|
|
||||||
if loc >= symloc:
|
# 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)
|
return (name, loc - symloc)
|
||||||
|
else:
|
||||||
return (None, 0)
|
return (None, 0)
|
||||||
|
|
||||||
def print_drop_table():
|
def print_drop_table():
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue