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: <20200717135138.GD528602@krava>
Date:   Fri, 17 Jul 2020 15:51:38 +0200
From:   Jiri Olsa <jolsa@...hat.com>
To:     Ian Rogers <irogers@...gle.com>
Cc:     Jiri Olsa <jolsa@...nel.org>,
        Arnaldo Carvalho de Melo <acme@...nel.org>,
        lkml <linux-kernel@...r.kernel.org>,
        Ingo Molnar <mingo@...nel.org>,
        Namhyung Kim <namhyung@...nel.org>,
        Alexander Shishkin <alexander.shishkin@...ux.intel.com>,
        Peter Zijlstra <a.p.zijlstra@...llo.nl>,
        Michael Petlan <mpetlan@...hat.com>,
        Andi Kleen <ak@...ux.intel.com>,
        Kajol Jain <kjain@...ux.ibm.com>,
        John Garry <john.garry@...wei.com>,
        "Paul A. Clarke" <pc@...ibm.com>,
        Stephane Eranian <eranian@...gle.com>
Subject: Re: [PATCH 11/18] perf metric: Add referenced metrics to hash data

On Wed, Jul 15, 2020 at 11:36:09PM +0200, Jiri Olsa wrote:
> On Wed, Jul 15, 2020 at 11:25:14AM -0700, Ian Rogers wrote:
> > On Sun, Jul 12, 2020 at 6:27 AM Jiri Olsa <jolsa@...nel.org> wrote:
> 
> SNIP
> 
> > > +int expr__add_ref(struct expr_parse_ctx *ctx, struct metric_ref *ref)
> > > +{
> > > +       struct expr_id_data *data_ptr = NULL, *old_data = NULL;
> > > +       char *old_key = NULL;
> > > +       char *name;
> > > +       int ret;
> > > +
> > > +       data_ptr = zalloc(sizeof(*data_ptr));
> > > +       if (!data_ptr)
> > > +               return -ENOMEM;
> > > +
> > > +       name = strdup(ref->metric_name);
> > > +       if (!name) {
> > > +               free(data_ptr);
> > > +               return -ENOMEM;
> > > +       }
> > > +
> > > +       data_ptr->ref.metric_name = ref->metric_name;
> > > +       data_ptr->ref.metric_expr = ref->metric_expr;
> > 
> > Having one owned string and one unowned makes the memory management
> > here somewhat complicated. Perhaps dupe both?
> 
> right, will check on this

actualy, both of them are pointers to const char strings from struct pmu_event,
so they don't need to be freed

the journey starts at __add_metric function, where we
get the struct pmu_event pointers:

	ref->metric_name = pe->metric_name;
	ref->metric_expr = pe->metric_expr;

then it's passed to struct metric_ref in metricgroup__setup_events:

	metric_refs[i].metric_name = ref->metric_name;
	metric_refs[i].metric_expr = ref->metric_expr;

still 'const char*'.. and ending up as part of the value in
expr__add_ref function:

	data_ptr->ref.metric_name = ref->metric_name;
	data_ptr->ref.metric_expr = ref->metric_expr;

I'll put comments in all those places so it's evident that it's intentional

jirka

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ