lkml.org 
[lkml]   [2009]   [May]   [26]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
SubjectRe: [PATCH 1/1 tip] perf: Don't assume /proc/kallsyms is ordered
From
Date
On Tue, 2009-05-26 at 12:21 -0300, Arnaldo Carvalho de Melo wrote:
> Please fix the previous fix with this:

You don't need a second walk through the RB-tree like that, simply
change the lookup function:

The below finds the first entry that has ->start > ip, we then walk
backwards until we find an entry that has start <= ip < end and end > ip
(should never be more than 1).

This way you can deal with holes (like userspace has), and deal with
entries without size (like kallsyms) by setting size to a random large
value.

---

Index: linux-2.6/Documentation/perf_counter/builtin-report.c
===================================================================
--- linux-2.6.orig/Documentation/perf_counter/builtin-report.c
+++ linux-2.6/Documentation/perf_counter/builtin-report.c
@@ -147,16 +147,25 @@ static struct symbol *dso__find_symbol(s
return NULL;

struct rb_node *n = self->syms.rb_node;
+ struct rb_node *last = NULL;
+ struct symbol *s;

while (n) {
- struct symbol *s = rb_entry(n, struct symbol, rb_node);
+ last = n;
+ s = rb_entry(n, struct symbol, rb_node);

if (ip < s->start)
n = n->rb_left;
- else if (ip > s->end)
- n = n->rb_right;
else
+ n = n->rb_right;
+ }
+
+ while (last) {
+ s = rb_entry(last, struct symbol, rb_node);
+ if (s->start <= ip && ip < s->end)
return s;
+
+ last = rb_prev(last);
}

return NULL;


\
 
 \ /
  Last update: 2009-05-26 19:59    [W:0.266 / U:0.184 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site