Received: by 2002:a05:6a10:6006:0:0:0:0 with SMTP id w6csp163077pxa; Wed, 26 Aug 2020 07:28:33 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx3GnJ/LVlbxyCQoh9TSznKcFE7AyGB/bA8v/QfupCOhtRKVcvu58d91YJR17J0uFq3HD9U X-Received: by 2002:a05:6402:339:: with SMTP id q25mr14524333edw.268.1598452113219; Wed, 26 Aug 2020 07:28:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1598452113; cv=none; d=google.com; s=arc-20160816; b=tX2x6zpzpOb8NpUTvqsClda149m0HwCbFrgEqvY7KlZMe31ONRzRYUmYDcMRZ54HGh SoxgH7pN6X0mb68201AfTmsGhRlz8413tpiajMbXmSvTfI9TElx2z2+ov+RQyX3acfED aGors3sTpDB6huCPJ8u4+M03g7amTJ2Dd7w5E0LCcApqD4ed53o7cf9Yp7RpepbiMrwn go+fkVePuo93SMabCW36tZbLTAUfchCRf3k/sO2KsR2DnLmW0qBnJREBmxH6tr+1p90t MYmrh0fI9BHUUiRwaAknYrCia36S4bPfI2dIKKOrKKzUQQ/P+qs8Oymdbvc0ZBKp/v3e 1heA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=KgKCdUXLgYBys45KQCqcG9pYMYXVWTrSeqUROvS9FGk=; b=zVvY1iwZcdGh0SQH2hCu5oYI2e1aifG0b93Be9Kibww3CSNMZ/g/U/oAUY2uNwsWxV V1fIAqa3t9pZipC+iewbSf1q9UfyE0NIJh8YSK6lVUajrC+N1uItOxTvpI+EkBsOvpW5 4InZ7FTHLLCdIk4uvf6s+w8jBkdiQIunp19zhDmkmhybu4poncmDM3zKI28KQ4R5Zrnh aeDILr6e+OwCxTIwJu/pzu2EFabnXFZzr+mKFym1zh18mQZhea9h9trNL61OxUVc6Gxl nfGi1lL6SmS7jztLYiX40QPuHUbTS2tGEyK74931PYCRFTMjlxa7P9HnkV5qlqLipimY EXqA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id r1si1505030edp.241.2020.08.26.07.28.10; Wed, 26 Aug 2020 07:28:33 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729098AbgHZLo0 (ORCPT + 99 others); Wed, 26 Aug 2020 07:44:26 -0400 Received: from lhrrgout.huawei.com ([185.176.76.210]:2692 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728995AbgHZLgi (ORCPT ); Wed, 26 Aug 2020 07:36:38 -0400 Received: from lhreml724-chm.china.huawei.com (unknown [172.18.7.106]) by Forcepoint Email with ESMTP id D483D9C856A5C6E4C3C4; Wed, 26 Aug 2020 12:35:39 +0100 (IST) Received: from [127.0.0.1] (10.47.10.200) by lhreml724-chm.china.huawei.com (10.201.108.75) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256) id 15.1.1913.5; Wed, 26 Aug 2020 12:35:39 +0100 Subject: Re: [RFC] perf/jevents: Add new structure to pass json fields. To: kajoljain , Jiri Olsa CC: , , , , , , , References: <20200825074041.378520-1-kjain@linux.ibm.com> <20200826110046.GF703542@krava> <5d91b929-cffd-265a-dd0c-f63bc3d1565d@linux.ibm.com> From: John Garry Message-ID: Date: Wed, 26 Aug 2020 12:33:12 +0100 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:68.0) Gecko/20100101 Thunderbird/68.1.2 MIME-Version: 1.0 In-Reply-To: <5d91b929-cffd-265a-dd0c-f63bc3d1565d@linux.ibm.com> Content-Type: text/plain; charset="utf-8"; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-Originating-IP: [10.47.10.200] X-ClientProxiedBy: lhreml707-chm.china.huawei.com (10.201.108.56) To lhreml724-chm.china.huawei.com (10.201.108.75) X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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