Received: by 2002:a05:6a10:6006:0:0:0:0 with SMTP id w6csp411317pxa; Thu, 27 Aug 2020 06:01:20 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzbW0nll3t2DcVuv216e7VBD0VgGKuC0NiXVWge19e5ADvyVXNU4NIGns3aN/jVJMN16VFW X-Received: by 2002:a17:906:f107:: with SMTP id gv7mr20256862ejb.519.1598533280380; Thu, 27 Aug 2020 06:01:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1598533280; cv=none; d=google.com; s=arc-20160816; b=XO9CDKUPBsbzYA40HelJeUMs0kBzddBVoQLU5nJASkjfftXKeA59uX9W4p7OaxgDkH TmSaFfwKnXJSkhW/6YK3AaduTcl5oWxUO/2qd89/Lyfq/WYnRdyj9VmzNFDltGWx9TqA rLhvVPV0ySPgK2q88tmX6Fzu8jdaxryOmrVgz+7VcJlzmU1+LiiNZXQZbtbFTZ8fttus D9EL1UBQcMKprzKwri4C8jWrkXbzKHTyONWZOsTyLKI0y5mU6crDV5TwkNmG2o6kzDNL Wco/D2TiMAdyz+vfrx4Eh/zx6dofQExjp6oFAajW18U2sd+/2lhjJ9JkkM5DyeDs4Esk jLfw== 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:dkim-signature; bh=C3993iEI8cespXe9G6ubljnSqXfbCcQAx5wYMlYe4GE=; b=De4qd0ZihrDnlooHfVjjxDvBAJRt24/KLt26LDe9Y8oKA0oAvQ868uB3k5KmRPa1Bo 6oQazK16tQksTb/uVVoHo7HCXhqzK7Zx8/A8Olll2SuaADCVMDeAIfHStaM5aUcRoMXl HHJtP3rj5ceOBOiO9pWNnbgHjpTRMGrQ7HO44OUezR1QZ96aUpT1eARweZdilJ1vW5m1 5DtHcFl/pPuq68AVMC03R8FjmNAJV7/Qk+KE6tWlE3dNT/GbtuiQxRoM0fAjVDB226DB YpygYXfqs6TK3ZBaq1ot0Q0+hTm5JGBy50Y+lhCRCNEyDtLAlxZrJ5yVegWnOyJnkEey 7a8Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=BtIqOyZm; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=ibm.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id d8si1252965ejj.109.2020.08.27.06.00.57; Thu, 27 Aug 2020 06:01:20 -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; dkim=pass header.i=@ibm.com header.s=pp1 header.b=BtIqOyZm; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=ibm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727122AbgH0M56 (ORCPT + 99 others); Thu, 27 Aug 2020 08:57:58 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:19862 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726834AbgH0M5d (ORCPT ); Thu, 27 Aug 2020 08:57:33 -0400 Received: from pps.filterd (m0098394.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 07RCWHkq124207; Thu, 27 Aug 2020 08:57:25 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=subject : to : cc : references : from : message-id : date : mime-version : in-reply-to : content-type : content-transfer-encoding; s=pp1; bh=C3993iEI8cespXe9G6ubljnSqXfbCcQAx5wYMlYe4GE=; b=BtIqOyZmMcPA/mqrpRzomGZMOubzCktAITWa7NunGx6IZeKQG/MsK99aeZX4FrDWtQ6j Y/FGV+xk4FnOo3FtUy+l5dRcwdaIN4SWQUWlBI2391Azgiit2k7p7oeRskFvsY8E/XtR ORpTy1NjgVL3zD39mDmPbbaHtJxv1rv9/almqih4eTW35zMkmHWtTTGCmM2W2oRCJCNx vp6d/O/TrKg0MhINak9SyFbJ6RrBSyfzA2nDkRfBk60EfIuM3AweLhV1EfFxMNt1luMy 2Y4KdgOxmjWiFHcoRTAQil04DmqwZjeuKKlM6OpEYlLqmFtAfdjLZ/yjC767b6rwnkMf Ug== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com with ESMTP id 336ayhvbjr-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 27 Aug 2020 08:57:25 -0400 Received: from m0098394.ppops.net (m0098394.ppops.net [127.0.0.1]) by pps.reinject (8.16.0.36/8.16.0.36) with SMTP id 07RCWSxw125225; Thu, 27 Aug 2020 08:57:24 -0400 Received: from ppma05wdc.us.ibm.com (1b.90.2fa9.ip4.static.sl-reverse.com [169.47.144.27]) by mx0a-001b2d01.pphosted.com with ESMTP id 336ayhvbhw-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 27 Aug 2020 08:57:24 -0400 Received: from pps.filterd (ppma05wdc.us.ibm.com [127.0.0.1]) by ppma05wdc.us.ibm.com (8.16.0.42/8.16.0.42) with SMTP id 07RCqs7T005092; Thu, 27 Aug 2020 12:57:23 GMT Received: from b01cxnp22034.gho.pok.ibm.com (b01cxnp22034.gho.pok.ibm.com [9.57.198.24]) by ppma05wdc.us.ibm.com with ESMTP id 332uw7swxb-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 27 Aug 2020 12:57:23 +0000 Received: from b01ledav005.gho.pok.ibm.com (b01ledav005.gho.pok.ibm.com [9.57.199.110]) by b01cxnp22034.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 07RCvMmK55247148 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 27 Aug 2020 12:57:22 GMT Received: from b01ledav005.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id B6729AE05F; Thu, 27 Aug 2020 12:57:22 +0000 (GMT) Received: from b01ledav005.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 2AC5DAE05C; Thu, 27 Aug 2020 12:57:19 +0000 (GMT) Received: from localhost.localdomain (unknown [9.79.210.202]) by b01ledav005.gho.pok.ibm.com (Postfix) with ESMTP; Thu, 27 Aug 2020 12:57:18 +0000 (GMT) Subject: Re: [RFC] perf/jevents: Add new structure to pass json fields. To: John Garry , Jiri Olsa 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 References: <20200825074041.378520-1-kjain@linux.ibm.com> <20200826110046.GF703542@krava> <5d91b929-cffd-265a-dd0c-f63bc3d1565d@linux.ibm.com> From: kajoljain Message-ID: Date: Thu, 27 Aug 2020 18:27:17 +0530 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.9.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit X-TM-AS-GCONF: 00 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.235,18.0.687 definitions=2020-08-27_06:2020-08-27,2020-08-27 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 malwarescore=0 impostorscore=0 mlxlogscore=999 mlxscore=0 bulkscore=0 priorityscore=1501 adultscore=0 suspectscore=2 lowpriorityscore=0 spamscore=0 phishscore=0 clxscore=1015 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2006250000 definitions=main-2008270092 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 8/26/20 5:03 PM, John Garry wrote: > 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. Hi John, yes right we should free them as well. Thanks for pointing it, I will update. Thanks, Kajol Jain > >>>>>            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