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 for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAM9d7cim4ETcSUUdSL2d_gLXe+4LJo4KUw7iTUJ=35sZNOkcqQ@mail.gmail.com>
Date:   Fri, 3 Nov 2023 11:48:23 -0700
From:   Namhyung Kim <namhyung@...nel.org>
To:     Ian Rogers <irogers@...gle.com>
Cc:     Arnaldo Carvalho de Melo <acme@...nel.org>,
        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
Subject: Re: [PATCH 1/5] perf annotate: Split struct cycles_info

Hi Ian,

On Thu, Nov 2, 2023 at 3:53 PM Ian Rogers <irogers@...gle.com> wrote:
>
> On Thu, Nov 2, 2023 at 3:26 PM Namhyung Kim <namhyung@...nel.org> wrote:
> >
> > The cycles info is used only when branch stack is provided.  Split them
> > into a separate struct and lazy allocate them to save some memory.
> >
> > Signed-off-by: Namhyung Kim <namhyung@...nel.org>
> > ---
> >  tools/perf/ui/browsers/annotate.c |  2 +-
> >  tools/perf/util/annotate.c        | 34 ++++++++++++++++++-------------
> >  tools/perf/util/annotate.h        | 14 ++++++++-----
> >  3 files changed, 30 insertions(+), 20 deletions(-)
> >
> > diff --git a/tools/perf/ui/browsers/annotate.c b/tools/perf/ui/browsers/annotate.c
> > index ccdb2cd11fbf..d2470f87344d 100644
> > --- a/tools/perf/ui/browsers/annotate.c
> > +++ b/tools/perf/ui/browsers/annotate.c
> > @@ -337,7 +337,7 @@ static void annotate_browser__calc_percent(struct annotate_browser *browser,
> >                                 max_percent = percent;
> >                 }
> >
> > -               if (max_percent < 0.01 && pos->al.ipc == 0) {
> > +               if (max_percent < 0.01 && (!pos->al.cycles || pos->al.cycles->ipc == 0)) {
> >                         RB_CLEAR_NODE(&pos->al.rb_node);
> >                         continue;
> >                 }
> > diff --git a/tools/perf/util/annotate.c b/tools/perf/util/annotate.c
> > index 82956adf9963..3e7f75827270 100644
> > --- a/tools/perf/util/annotate.c
> > +++ b/tools/perf/util/annotate.c
> > @@ -1100,8 +1100,8 @@ static void annotation__count_and_fill(struct annotation *notes, u64 start, u64
> >                 for (offset = start; offset <= end; offset++) {
> >                         struct annotation_line *al = notes->offsets[offset];
> >
> > -                       if (al && al->ipc == 0.0) {
> > -                               al->ipc = ipc;
> > +                       if (al && al->cycles && al->cycles->ipc == 0.0) {
> > +                               al->cycles->ipc = ipc;
> >                                 cover_insn++;
> >                         }
> >                 }
> > @@ -1134,13 +1134,18 @@ void annotation__compute_ipc(struct annotation *notes, size_t size)
> >                 if (ch && ch->cycles) {
> >                         struct annotation_line *al;
> >
> > +                       al = notes->offsets[offset];
> > +                       if (al && al->cycles == NULL) {
> > +                               al->cycles = zalloc(sizeof(*al->cycles));
> > +                               if (al->cycles == NULL)
> > +                                       continue;
> > +                       }
> >                         if (ch->have_start)
> >                                 annotation__count_and_fill(notes, ch->start, offset, ch);
> > -                       al = notes->offsets[offset];
> >                         if (al && ch->num_aggr) {
> > -                               al->cycles = ch->cycles_aggr / ch->num_aggr;
> > -                               al->cycles_max = ch->cycles_max;
> > -                               al->cycles_min = ch->cycles_min;
>
> Thanks for doing this! Would it make sense to do the zalloc here to be
> lazier about allocation?

annotation__count_and_fill() also needs it.

Thanks,
Namhyung

>
> Ian
>
> > +                               al->cycles->avg = ch->cycles_aggr / ch->num_aggr;
> > +                               al->cycles->max = ch->cycles_max;
> > +                               al->cycles->min = ch->cycles_min;
> >                         }
> >                         notes->have_cycles = true;

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ