From: Ben Hutchings <ben@decadent.org.uk>
To: Peter Zijlstra <a.p.zijlstra@chello.nl>,
Paul Mackerras <paulus@samba.org>, Ingo Molnar <mingo@redhat.com>
Cc: Neil Horman <nhorman@tuxdriver.com>,
netdev@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH 4/5] perf: net_dropmonitor: Use bisection in symbol lookup
Date: Tue, 21 May 2013 01:45:42 +0100 [thread overview]
Message-ID: <1369097142.3469.135.camel@deadeye.wl.decadent.org.uk> (raw)
In-Reply-To: <1369096976.3469.131.camel@deadeye.wl.decadent.org.uk>
[-- Attachment #1: Type: text/plain, Size: 1272 bytes --]
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
---
tools/perf/scripts/python/net_dropmonitor.py | 22 ++++++++++++++++++----
1 file changed, 18 insertions(+), 4 deletions(-)
diff --git a/tools/perf/scripts/python/net_dropmonitor.py b/tools/perf/scripts/python/net_dropmonitor.py
index 6acdc82e..32fcee0 100755
--- a/tools/perf/scripts/python/net_dropmonitor.py
+++ b/tools/perf/scripts/python/net_dropmonitor.py
@@ -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")
[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 828 bytes --]
next prev parent reply other threads:[~2013-05-21 0:45 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-05-21 0:42 [PATCH 0/5] perf: net_dropmonitor: Make it work and make it fast Ben Hutchings
2013-05-21 0:44 ` [PATCH 1/5] perf: net_dropmonitor: Fix trace parameter order Ben Hutchings
2013-05-21 0:45 ` [PATCH 2/5] perf: net_dropmonitor: Fix symbol-relative addresses Ben Hutchings
2013-05-21 0:45 ` [PATCH 3/5] perf: net_dropmonitor: Do not assume ordering of dictionaries Ben Hutchings
2013-05-21 0:45 ` Ben Hutchings [this message]
2013-05-21 0:45 ` [PATCH 5/5] perf: net_dropmonitor: Remove progress indicator Ben Hutchings
2013-05-21 13:33 ` [PATCH 0/5] perf: net_dropmonitor: Make it work and make it fast Neil Horman
2013-05-21 13:54 ` Ben Hutchings
2013-05-21 16:06 ` Neil Horman
2013-05-21 16:12 ` Neil Horman
2013-05-22 22:11 ` David Miller
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1369097142.3469.135.camel@deadeye.wl.decadent.org.uk \
--to=ben@decadent.org.uk \
--cc=a.p.zijlstra@chello.nl \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=netdev@vger.kernel.org \
--cc=nhorman@tuxdriver.com \
--cc=paulus@samba.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®