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] [day] [month] [year] [list]
Message-ID: <OSBPR01MB4600E123FC87D7A27517A2DFF7669@OSBPR01MB4600.jpnprd01.prod.outlook.com>
Date:   Mon, 29 Nov 2021 07:59:05 +0000
From:   "nakamura.shun@...itsu.com" <nakamura.shun@...itsu.com>
To:     Arnaldo Carvalho de Melo <acme@...nel.org>,
        Jiri Olsa <jolsa@...hat.com>
CC:     "peterz@...radead.org" <peterz@...radead.org>,
        "mingo@...hat.com" <mingo@...hat.com>,
        "mark.rutland@....com" <mark.rutland@....com>,
        "alexander.shishkin@...ux.intel.com" 
        <alexander.shishkin@...ux.intel.com>,
        "namhyung@...nel.org" <namhyung@...nel.org>,
        "robh@...nel.org" <robh@...nel.org>,
        "linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
        "linux-perf-users@...r.kernel.org" <linux-perf-users@...r.kernel.org>
Subject: Re: [PATCH v3 1/3] libperf: Move perf_counts_values__scale to
 tools/lib/perf

Hi Arnaldo, jirka
Sorry for the late reply.

Em Sun, Nov 14, 2021 at 05:19:45PM +0100, Jiri Olsa escreveu:
> > On Tue, Nov 09, 2021 at 05:58:29PM +0900, Shunsuke Nakamura wrote:
> > > Move perf_counts_values__scale from tools/perf/util to tools/lib/perf
> > > so that it can be used with libperf.
> > > 
> > > Signed-off-by: Shunsuke Nakamura <nakamura.shun@...itsu.com>
> > > ---
> > >  tools/lib/perf/evsel.c              | 19 +++++++++++++++++++
> > >  tools/lib/perf/include/perf/evsel.h |  4 ++++
> > >  tools/lib/perf/libperf.map          |  1 +
> > >  tools/perf/util/evsel.c             | 19 -------------------
> > >  tools/perf/util/evsel.h             |  3 ---
> > >  5 files changed, 24 insertions(+), 22 deletions(-)
> > > 
> > > diff --git a/tools/lib/perf/evsel.c b/tools/lib/perf/evsel.c
> > > index 8441e3e1aaac..5097aadea37a 100644
> > > --- a/tools/lib/perf/evsel.c
> > > +++ b/tools/lib/perf/evsel.c
> > > @@ -431,3 +431,22 @@ void perf_evsel__free_id(struct perf_evsel *evsel)
> > >      zfree(&evsel->id);
> > >      evsel->ids = 0;
> > >  }
> > > +
> > > +void perf_counts_values__scale(struct perf_counts_values *count,
> > > +                          bool scale, s8 *pscaled)
> > > +{
> > > +   s8 scaled = 0;
> > > +
> > > +   if (scale) {
> > > +           if (count->run == 0) {
> > > +                   scaled = -1;
> > > +                   count->val = 0;
> > > +           } else if (count->run < count->ena) {
> > > +                   scaled = 1;
> > > +                   count->val = (u64)((double)count->val * count->ena / count->run);
> > > +           }
> > > +   }
> > > +
> > > +   if (pscaled)
> > > +           *pscaled = scaled;
> > > +}
> > > diff --git a/tools/lib/perf/include/perf/evsel.h b/tools/lib/perf/include/perf/evsel.h
> > > index 60eae25076d3..9013d73af22d 100644
> > > --- a/tools/lib/perf/include/perf/evsel.h
> > > +++ b/tools/lib/perf/include/perf/evsel.h
> > > @@ -4,6 +4,8 @@
> > >  
> > >  #include <stdint.h>
> > >  #include <perf/core.h>
> > > +#include <stdbool.h>
> > > +#include <linux/types.h>
> > >  
> > >  struct perf_evsel;
> > >  struct perf_event_attr;
> > > @@ -39,5 +41,7 @@ LIBPERF_API int perf_evsel__disable_cpu(struct perf_evsel *evsel, int cpu);
> > >  LIBPERF_API struct perf_cpu_map *perf_evsel__cpus(struct perf_evsel *evsel);
> > >  LIBPERF_API struct perf_thread_map *perf_evsel__threads(struct perf_evsel *evsel);
> > >  LIBPERF_API struct perf_event_attr *perf_evsel__attr(struct perf_evsel *evsel);
> > > +LIBPERF_API void perf_counts_values__scale(struct perf_counts_values *count,
> > > +                                      bool scale, s8 *pscaled);
> > 
> > not sure if we should use __s8 for pscaled now when it's exported?
> > it's just we use it everywhere else with '__' prefix, I forgot what's
> > the difference actually ;-)
> 
> I'm moving this to be __s8, following what is being used in
> tools/lib/bpf/bpf.h.
I will fix it.
 
> > but other that all looks good, for the patchset:
> > 
> > Acked-by: Jiri Olsa <jolsa@...nel.org>
Thanks for review.

Best Regards
Shunsuke

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ