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]
Date: Tue, 19 Mar 2024 11:09:58 -0700
From: Namhyung Kim <namhyung@...nel.org>
To: Arnaldo Carvalho de Melo <acme@...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 11:07 AM Arnaldo Carvalho de Melo
<acme@...nel.org> 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, ...);
>
> I can add that, to speed up the process, ok?

That would be great!

Thanks,
Namhyung

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ