lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <ZfnU3DOZIPqlPhHf@x1>
Date: Tue, 19 Mar 2024 15:09:32 -0300
From: Arnaldo Carvalho de Melo <acme@...nel.org>
To: Namhyung Kim <namhyung@...nel.org>
Cc: Ian Rogers <irogers@...gle.com>, Jiri Olsa <jolsa@...nel.org>,
	Adrian Hunter <adrian.hunter@...el.com>,
	Peter Zijlstra <peterz@...radead.org>,
	Ingo Molnar <mingo@...nel.org>, LKML <linux-kernel@...r.kernel.org>,
	linux-perf-users@...r.kernel.org,
	Linus Torvalds <torvalds@...ux-foundation.org>,
	Stephane Eranian <eranian@...gle.com>,
	Masami Hiramatsu <mhiramat@...nel.org>,
	linux-toolchains@...r.kernel.org, linux-trace-devel@...r.kernel.org
Subject: Re: [PATCH 22/23] perf annotate-data: Add a cache for global
 variable types

On Tue, Mar 19, 2024 at 03:07:19PM -0300, Arnaldo Carvalho de Melo wrote:
> On Tue, Mar 19, 2024 at 11:05:04AM -0700, Namhyung Kim wrote:
> > On Mon, Mar 18, 2024 at 10:56 PM Namhyung Kim <namhyung@...nel.org> wrote:
> > >
> > > They are often searched by many different places.  Let's add a cache
> > > for them to reduce the duplicate DWARF access.
> > >
> > > Signed-off-by: Namhyung Kim <namhyung@...nel.org>
> > > ---
> > >  tools/perf/util/annotate-data.c | 107 +++++++++++++++++++++++++++++++-
> > >  tools/perf/util/annotate-data.h |   7 +++
> > >  tools/perf/util/dso.c           |   2 +
> > >  tools/perf/util/dso.h           |   6 +-
> > >  4 files changed, 118 insertions(+), 4 deletions(-)
> > >
> > > diff --git a/tools/perf/util/annotate-data.c b/tools/perf/util/annotate-data.c
> > > index 633fe125fcd8..4b3184b7c799 100644
> > > --- a/tools/perf/util/annotate-data.c
> > > +++ b/tools/perf/util/annotate-data.c
> > > @@ -433,6 +433,91 @@ static struct type_state_stack *findnew_stack_state(struct type_state *state,
> > >         return stack;
> > >  }
> > >
> > > +/* Maintain a cache for quick global variable lookup */
> > > +struct global_var_entry {
> > > +       struct rb_node node;
> > > +       char *name;
> > > +       u64 start;
> > > +       u64 end;
> > > +       u64 die_offset;
> > > +};
> > > +
> > > +static int global_var_cmp(const void *_key, const struct rb_node *node)
> > > +{
> > > +       const u64 addr = (uintptr_t)_key;
> > > +       struct global_var_entry *gvar;
> > > +
> > > +       gvar = rb_entry(node, struct global_var_entry, node);
> > > +
> > > +       if (gvar->start <= addr && addr < gvar->end)
> > > +               return 0;
> > > +       return gvar->start > addr ? -1 : 1;
> > > +}
> > > +
> > > +static bool global_var_less(struct rb_node *node_a, const struct rb_node *node_b)
> > > +{
> > > +       struct global_var_entry *gvar_a, *gvar_b;
> > > +
> > > +       gvar_a = rb_entry(node_a, struct global_var_entry, node);
> > > +       gvar_b = rb_entry(node_b, struct global_var_entry, node);
> > > +
> > > +       return gvar_a->start < gvar_b->start;
> > > +}
> > > +
> > > +static struct global_var_entry *global_var__find(struct data_loc_info *dloc, u64 addr)
> > > +{
> > > +       struct dso *dso = map__dso(dloc->ms->map);
> > > +       struct rb_node *node;
> > > +
> > > +       node = rb_find((void *)addr, &dso->global_vars, global_var_cmp);
> > 
> > It seems to cause a build error on 32-bit systems.  It needs one
> > more cast to suppress the "pointer cast w/ different size" warning.
> > 
> >     node = rb_find(void *)(uintptr_tr)addr, ...);

                               uintptr_t
> 
> I can add that, to speed up the process, ok?

Done

diff --git a/tools/perf/util/annotate-data.c b/tools/perf/util/annotate-data.c
index 4b3184b7c79942b4..969e2f82079cdec5 100644
--- a/tools/perf/util/annotate-data.c
+++ b/tools/perf/util/annotate-data.c
@@ -469,7 +469,7 @@ static struct global_var_entry *global_var__find(struct data_loc_info *dloc, u64
 	struct dso *dso = map__dso(dloc->ms->map);
 	struct rb_node *node;
 
-	node = rb_find((void *)addr, &dso->global_vars, global_var_cmp);
+	node = rb_find((void *)(uintptr_t)addr, &dso->global_vars, global_var_cmp);
 	if (node == NULL)
 		return NULL;
 

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ