Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp2300670ybt; Sun, 28 Jun 2020 14:59:37 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz0N8NmQG727PosiRkMxVVUFNbEL0opl10kC2CKTtnmnxz+/chwj5pLzItcULg6oLdB0yYp X-Received: by 2002:aa7:d353:: with SMTP id m19mr14106960edr.75.1593381577185; Sun, 28 Jun 2020 14:59:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1593381577; cv=none; d=google.com; s=arc-20160816; b=zCPIe53s30fVZ3sEK0KCIqP02b/Uk+FA6ynGiBIcY2dvh6jyJFt7bnYJ1s6XOHPAX/ 0biVWLDXSSH85yK30JPvHfuR5RPhXBbAvw3l+sUmzsPB+DkKG6QdNvZHLzRxOhB8X0n/ /nSChh4pQrsj1NSXaVGknOtThALS7kA81do4t5iKZ6+bHEf62OumeuhFfyIFrSRXLumN +L6+sGcMvMNO7RW3g7iyI8SB38QQxxvNrBbwMpdtYyRhFz/4tpoN0rtUzW/3IA7Warj3 WmgqKzvqH1XKTiZtJl3pjSg5u1Eg+rX/LRwS+iLgER90kQ6Ox0JSgbr3gevLEp9hsrdc F73Q== 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=nnIK6dyjkHa36+vFymOUq0a3L3byDyQpMtuF9uWKz/8=; b=m9I7BJWsJTofsFCap+xwVfcBwH6xwVRywY8hOw7Wk/yzbiv6Ny0KxzaTRdAgRocffB 1jurdRR+9oEXi3CXv2uu+c75mLlDZFcobcdgA2S2tEkVNl/2xOo0kSZxNVeqjWBJPS+a /GazkUWhFEo233RHJS7FXtKy9byQjOj4NqUy1goWL2J1cgJJ8k94a9Z8nTxYj2GmlsKv agwoE670Fy02vVKiuk0GJMfCNkdpv5Li23hyEGfYGY8CBni6wlQwhALi6H43shujqs8X 3LzQwVqHMyrSrv4TSdsa4eBF7PnizglQBqFAFoy7t+AfXHbC1pRgR15Vg+NxslHGKlh0 C8Xg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=O1bWFLqv; 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 ds10si6764340ejc.183.2020.06.28.14.59.14; Sun, 28 Jun 2020 14:59:37 -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=O1bWFLqv; 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 S1726443AbgF1V5B (ORCPT + 99 others); Sun, 28 Jun 2020 17:57:01 -0400 Received: from us-smtp-2.mimecast.com ([207.211.31.81]:37514 "EHLO us-smtp-delivery-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726104AbgF1V5A (ORCPT ); Sun, 28 Jun 2020 17:57:00 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1593381418; 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=nnIK6dyjkHa36+vFymOUq0a3L3byDyQpMtuF9uWKz/8=; b=O1bWFLqvc0e9H8tFdp5N+rUBWSWEwonph7rmXU9BV/VXXBnMxOWO6wKrIpxWNrTVmC/kbC Gt22SX6lAwtbd0lDYNJAXMFAiLr/ZQJXpZ6Kyz7B2QhiH3oIEIm8kJCtJkt5I8GLTm3Zav R4RtxfFjrFBFEw+cFtzHDv5KivJpoog= 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-253-iDB7MpKJPI-mhCVhS2U6tQ-1; Sun, 28 Jun 2020 17:56:54 -0400 X-MC-Unique: iDB7MpKJPI-mhCVhS2U6tQ-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 B18FA1005512; Sun, 28 Jun 2020 21:56:52 +0000 (UTC) Received: from krava (unknown [10.40.192.56]) by smtp.corp.redhat.com (Postfix) with SMTP id DD510100164D; Sun, 28 Jun 2020 21:56:49 +0000 (UTC) Date: Sun, 28 Jun 2020 23:56:48 +0200 From: Jiri Olsa To: Ian Rogers Cc: Jiri Olsa , Arnaldo Carvalho de Melo , lkml , Ingo Molnar , Namhyung Kim , Alexander Shishkin , Peter Zijlstra , Michael Petlan , Andi Kleen , Kajol Jain , John Garry , "Paul A. Clarke" , Stephane Eranian Subject: Re: [PATCH 08/10] perf tools: Add other metrics to hash data Message-ID: <20200628215648.GN2988321@krava> References: <20200626194720.2915044-1-jolsa@kernel.org> <20200626194720.2915044-9-jolsa@kernel.org> 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 Fri, Jun 26, 2020 at 02:16:30PM -0700, Ian Rogers wrote: > On Fri, Jun 26, 2020 at 12:48 PM Jiri Olsa wrote: > > > > Adding other metrics to the parsing context so they > > can be resolved during the metric processing. > > > > Adding expr__add_other function to store 'other' metrics > > into parse context. > > > > Signed-off-by: Jiri Olsa > > --- > > tools/perf/util/expr.c | 35 +++++++++++++++++++++++++++++++++++ > > tools/perf/util/expr.h | 13 ++++++++++++- > > tools/perf/util/stat-shadow.c | 19 +++++++++++++------ > > 3 files changed, 60 insertions(+), 7 deletions(-) > > > > diff --git a/tools/perf/util/expr.c b/tools/perf/util/expr.c > > index cd73dae4588c..32f7acac7c19 100644 > > --- a/tools/perf/util/expr.c > > +++ b/tools/perf/util/expr.c > > @@ -4,6 +4,8 @@ > > #include > > #include > > #include > > +#include "metricgroup.h" > > +#include "debug.h" > > #include "expr.h" > > #include "expr-bison.h" > > #include "expr-flex.h" > > @@ -61,6 +63,7 @@ int expr__add_val(struct expr_parse_ctx *ctx, const char *name, double val) > > if (!data_ptr) > > return -ENOMEM; > > data_ptr->val = val; > > + data_ptr->is_other = false; > > > > ret = hashmap__set(&ctx->ids, name, data_ptr, > > (const void **)&old_key, (void **)&old_data); > > @@ -69,6 +72,38 @@ int expr__add_val(struct expr_parse_ctx *ctx, const char *name, double val) > > return ret; > > } > > > > +int expr__add_other(struct expr_parse_ctx *ctx, struct metric_other *other) > > +{ > > + struct expr_parse_data *data_ptr = NULL, *old_data = NULL; > > + char *old_key = NULL; > > + char *name; > > + int ret; > > + > > + data_ptr = malloc(sizeof(*data_ptr)); > > + if (!data_ptr) > > + return -ENOMEM; > > + > > + name = strdup(other->metric_name); > > + if (!name) { > > + free(data_ptr); > > + return -ENOMEM; > > + } > > + > > + data_ptr->other.metric_name = other->metric_name; > > + data_ptr->other.metric_expr = other->metric_expr; > > + data_ptr->is_other = true; > > + > > + ret = hashmap__set(&ctx->ids, name, data_ptr, > > + (const void **)&old_key, (void **)&old_data); > > + > > + pr_debug2("adding other metric %s: %s\n", > > + other->metric_name, other->metric_expr); > > + > > + free(old_key); > > + free(old_data); > > + return ret; > > +} > > + > > int expr__get_id(struct expr_parse_ctx *ctx, const char *id, > > struct expr_parse_data **data) > > { > > diff --git a/tools/perf/util/expr.h b/tools/perf/util/expr.h > > index fd924bb4e5cd..ed60f9227b43 100644 > > --- a/tools/perf/util/expr.h > > +++ b/tools/perf/util/expr.h > > @@ -11,12 +11,22 @@ > > #include "util/hashmap.h" > > //#endif > > > > +struct metric_other; > > + > > struct expr_parse_ctx { > > struct hashmap ids; > > }; > > > > struct expr_parse_data { > > - double val; > > + bool is_other; > > + > > + union { > > + double val; > > + struct { > > + const char *metric_name; > > + const char *metric_expr; > > It is probably worth a comment why both the metric_name and the > metric's expression are required here? The parse and other data for > the metric won't be here. it's there to have it ready when processing the metric, I'll add some more comments in here thanks, jirka