Received: by 2002:a05:6a10:6006:0:0:0:0 with SMTP id w6csp162108pxa; Wed, 26 Aug 2020 07:27:11 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwpIPgxylnXF4wo2/BGMnngsHL/HbH6A7GJb6+GUIgTZPoe8s75zS/dXfRf+LCe8JIlGHQ1 X-Received: by 2002:a17:907:42cc:: with SMTP id nz20mr16308145ejb.429.1598452031374; Wed, 26 Aug 2020 07:27:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1598452031; cv=none; d=google.com; s=arc-20160816; b=uL3rgFKEIwlALxUVxmm0f1Z+LiC2+PfxQyF1uz/b2KIRXotbgkEIB1DQb3EZnAebJD qubBoYoBPGuiva0fUzsgjXX+hqbLdyOAbq0XLwbEP/Ktqi5cG72SJBqpZNXBgsSvEp4n BnDrnYvycAnR893TjsKy2ikyjbITy82yWezG9lHpO8t44Kuj0aSdgQrvkRXvMTC7Zvpw eqhF5pJ4hAbdHRdE3A8VEG6Ff2N9tkZkySb7kRxVZOYljtLFlEfVpu7darahPBJ5cJj7 eSOcSiSaiJBnVyXFwRt8FodWOJ0dlCoNfjuTGA3VBviMb7rE4iGpck5F0RjXi5/oGkFW zNDQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=gZ+hqhThII7IwmcsnaMAeSwJTx05ieaUKU5K5IUdmV8=; b=OJst7BEQ7XPevLrhwVl2XASdphDGAptV59IqZkk8f1nYOlCoJFMeIyv58++GxSvq8I xyZKFKTk9hl3F/lyPkAsxLce0GURhKZ2+B8q5FfYUWCQThvp9VvYOPQliFJPviwKXlIW WBKX7rycTpCfy/KZAfh6n+G5qxgXhJqiRQzfrUfHnB/MpFyNNWDphRrR7PLvQLinzLTf NRthhrhWMM80K46ND0H+pnV0TLh4JWCTwkPCpixZVVBt+Xe5ApRxyoHYLJLG/QyCQTK8 cyY88k35UkQlD2/9g5RWycZfWNfwOlDHUM66BEBKPLdT9EPPDeN0RwfbtYGR16DRc7i7 ESqA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b="CB/99UXE"; 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=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id t9si1728597eji.436.2020.08.26.07.26.48; Wed, 26 Aug 2020 07:27:11 -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=@redhat.com header.s=mimecast20190719 header.b="CB/99UXE"; 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=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728864AbgHZLEG (ORCPT + 99 others); Wed, 26 Aug 2020 07:04:06 -0400 Received: from us-smtp-2.mimecast.com ([205.139.110.61]:44928 "EHLO us-smtp-1.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728787AbgHZLBX (ORCPT ); Wed, 26 Aug 2020 07:01:23 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1598439655; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=gZ+hqhThII7IwmcsnaMAeSwJTx05ieaUKU5K5IUdmV8=; b=CB/99UXETy0DoyDPWmGmYUD3M83/ls91GWyeCGOzbdj7uFKC5AAIBc2H6ptrMT2AQuF7Bn rFH5596x476dWKBXmXRfa+xTlLxKQQN8T/cBRB1Uvh2CjKaieyBHIpbPMlL5Md973NnPV/ c7yndQGMs6BkN2X8Pd5WV1tY26TcxlE= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-8-SMahhIo4OnmoYq_HW2SUvw-1; Wed, 26 Aug 2020 07:00:53 -0400 X-MC-Unique: SMahhIo4OnmoYq_HW2SUvw-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id A96EC807334; Wed, 26 Aug 2020 11:00:50 +0000 (UTC) Received: from krava (unknown [10.40.194.188]) by smtp.corp.redhat.com (Postfix) with SMTP id 3A7B010023A5; Wed, 26 Aug 2020 11:00:47 +0000 (UTC) Date: Wed, 26 Aug 2020 13:00:46 +0200 From: Jiri Olsa To: John Garry Cc: Kajol Jain , 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. Message-ID: <20200826110046.GF703542@krava> References: <20200825074041.378520-1-kjain@linux.ibm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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); > > 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 > > @@ -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 thanks, jirka