linux-perf-users.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: John Garry <john.garry@huawei.com>
To: kajoljain <kjain@linux.ibm.com>, Jiri Olsa <jolsa@redhat.com>
Cc: acme@kernel.org, ak@linux.intel.com, yao.jin@linux.intel.com,
	linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org,
	irogers@google.com, maddy@linux.ibm.com,
	ravi.bangoria@linux.ibm.com
Subject: Re: [RFC] perf/jevents: Add new structure to pass json fields.
Date: Wed, 26 Aug 2020 12:33:12 +0100	[thread overview]
Message-ID: <ac9acc5f-7ce1-c9c9-91f5-598ca13a4a89@huawei.com> (raw)
In-Reply-To: <5d91b929-cffd-265a-dd0c-f63bc3d1565d@linux.ibm.com>

On 26/08/2020 12:24, kajoljain wrote:
> 
> 
> On 8/26/20 4:30 PM, Jiri Olsa wrote:
>> On Tue, Aug 25, 2020 at 09:14:11AM +0100, John Garry wrote:
>>
>> SNIP
>>
>>>>    				goto free_strings;
>>>>    		}
>>>> -		err = func(data, name, real_event(name, event), desc, long_desc,
>>>> -			   pmu, unit, perpkg, metric_expr, metric_name,
>>>> -			   metric_group, deprecated, metric_constraint);
>>>> +		je->event = real_event(je->name, je->event);
>>>> +		err = func(data, je);
>>>>    free_strings:
>>>> -		free(event);
>>>> -		free(desc);
>>>> -		free(name);
>>>> -		free(long_desc);
>>>>    		free(extra_desc);
>>>> -		free(pmu);
>>>>    		free(filter);
>>>> -		free(perpkg);
>>>> -		free(deprecated);
>>>> -		free(unit);
>>>> -		free(metric_expr);
>>>> -		free(metric_name);
>>>> -		free(metric_group);
>>>> -		free(metric_constraint);

Hi Kajol Jain,

Do we need to free je->metric_name and the rest still? From a glance, 
that memory is still separately alloc'ed in addfield.

>>>>    		free(arch_std);
>>>> +		free(je);
>>>>    		if (err)
>>>>    			break;
>>>> diff --git a/tools/perf/pmu-events/jevents.h b/tools/perf/pmu-events/jevents.h
>>>> index 2afc8304529e..e696edf70e9a 100644
>>>> --- a/tools/perf/pmu-events/jevents.h
>>>> +++ b/tools/perf/pmu-events/jevents.h
>>>
>>> Somewhat unrelated - this file only seems to be included in jevents.c, so I
>>> don't see why it exists...
>>
>> ah right.. I won't mind getting rid of it
> 
> Hi John and  Jiri
>       Thanks for reviewing the patch. I can remove this file and add these structure inside jevents.c

thanks

> 
> Thanks,
> Kajol Jain
>>   
>>>> @@ -2,14 +2,28 @@
>>>>    #ifndef JEVENTS_H
>>>>    #define JEVENTS_H 1
>>>> +#include "pmu-events.h"
>>>> +
>>>> +struct json_event {
>>>> +	char *name;
>>>> +	char *event;
>>>> +	char *desc;
>>>> +	char *topic;
>>>> +	char *long_desc;
>>>> +	char *pmu;
>>>> +	char *unit;
>>>> +	char *perpkg;
>>>> +	char *metric_expr;
>>>> +	char *metric_name;
>>>> +	char *metric_group;
>>>> +	char *deprecated;
>>>> +	char *metric_constraint;
>>>
>>> This looks very much like struct event_struct, so could look to consolidate:
>>>
>>> struct event_struct {
>>> 	struct list_head list;
>>> 	char *name;
>>> 	char *event;
>>> 	char *desc;
>>> 	char *long_desc;
>>> 	char *pmu;
>>> 	char *unit;
>>> 	char *perpkg;
>>> 	char *metric_expr;
>>> 	char *metric_name;
>>> 	char *metric_group;
>>> 	char *deprecated;
>>> 	char *metric_constraint;
>>> };
>>
>> as Andi said they come from different layers, I think it's
>> better to keep them separated even if they share some fields

I was just suggesting to make:
  struct event_struct {
	struct list_head list;
	struct json_event je;
  }

No biggie if against this.

Cheers,
John

  reply	other threads:[~2020-08-26 11:33 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-08-25  7:40 [RFC] perf/jevents: Add new structure to pass json fields Kajol Jain
2020-08-25  8:14 ` John Garry
2020-08-26 11:00   ` Jiri Olsa
2020-08-26 11:24     ` kajoljain
2020-08-26 11:33       ` John Garry [this message]
2020-08-27 12:57         ` kajoljain
2020-08-25 15:47 ` Andi Kleen
2020-08-26 11:25   ` kajoljain
2020-08-26 10:56 ` Jiri Olsa
2020-08-26 11:32   ` kajoljain
2020-08-26 11:59     ` Jiri Olsa
2020-08-27 12:58       ` kajoljain
2020-08-26 10:57 ` Jiri Olsa
2020-08-26 11:28   ` kajoljain
2020-08-26 10:57 ` Jiri Olsa
2020-08-26 11:33   ` kajoljain

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ac9acc5f-7ce1-c9c9-91f5-598ca13a4a89@huawei.com \
    --to=john.garry@huawei.com \
    --cc=acme@kernel.org \
    --cc=ak@linux.intel.com \
    --cc=irogers@google.com \
    --cc=jolsa@redhat.com \
    --cc=kjain@linux.ibm.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-perf-users@vger.kernel.org \
    --cc=maddy@linux.ibm.com \
    --cc=ravi.bangoria@linux.ibm.com \
    --cc=yao.jin@linux.intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).