Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp790154pxb; Tue, 19 Oct 2021 13:05:28 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzmhgLn4/YBv+PqkdIHvVzeDJcpyu96Nv3Dj07t6g6hbdBaVo/LADAhRSVDdTTiR6PEXKl0 X-Received: by 2002:a17:907:9727:: with SMTP id jg39mr30393364ejc.533.1634673927784; Tue, 19 Oct 2021 13:05:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1634673927; cv=none; d=google.com; s=arc-20160816; b=PuV6xHPrrU+vvz221Qv7xlapZc8vHI1bDS4+qp6LXYE5JXPkamaS7zxQUISqYeTTIS FqMDLeO3VfjLbiXPRLqv0MvdmXM943dW1XOSmzLaY5EbNceU9DHpECbSd/zBDDBCxIFt SaOzhNbRb0jAakpn/Atzi/aNV3pgGwDuHZrl13afLjQzEzazcJk041ZcQobRWtxf9wjX Ta+XO3XW1GttosyAK5p8mOy2Go7Jz7fTI2tVsxqQbnACC7d956TcVskaW2370C0E9sge cgMYFkW1oH1VajeVv5HoPbI7DLwY0KqUx6m+ozgmDG4w7Ojdr4QwKPFXCqiqw2O29h3L uQwQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=9NU9PI5h+XIjdFaV8cJFhnAUvW54J00YhhaMQMKLO8o=; b=H+VM1LM2XtgyvAL5IXK095uJVJ0pbtD0pFqI1LvzG07T+4UYnuqwF7J1i8lWyehH7c vqV2lfCb1xoR2CICYA0fpdCuRbBubrBJuo7WarQaNxGENAe4BJZafR6qTpIjfHZpt34L Kzxbg1rGkuNSQi+6zfybWyfKl5z+SbT8rn+TW2olMqocxj+BYE8g//63U1C2mXVYsJxC Ger6lzVnUGpZltYwfgVbrU0tA5Rv3SIjJ5mBr8S9CGciWVWQTPy48AinGkHA7eV6I3iN DYZ+N9SstO6y1MKQnxnbSHEC1WiulDLSsQ43W9A9wX4ZzkKQ7qVPfj/X8G50EYIeyXJ6 shMQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=JqOvObYO; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id d6si68072edo.217.2021.10.19.13.05.03; Tue, 19 Oct 2021 13:05:27 -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=@google.com header.s=20210112 header.b=JqOvObYO; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230432AbhJSUCv (ORCPT + 99 others); Tue, 19 Oct 2021 16:02:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56342 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229701AbhJSUCu (ORCPT ); Tue, 19 Oct 2021 16:02:50 -0400 Received: from mail-il1-x12c.google.com (mail-il1-x12c.google.com [IPv6:2607:f8b0:4864:20::12c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 83CEFC06161C for ; Tue, 19 Oct 2021 13:00:37 -0700 (PDT) Received: by mail-il1-x12c.google.com with SMTP id k3so19671005ilu.2 for ; Tue, 19 Oct 2021 13:00:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=9NU9PI5h+XIjdFaV8cJFhnAUvW54J00YhhaMQMKLO8o=; b=JqOvObYObmHnMw/K5VX2OvTdj7KV86fkY/1/00npJRjr4O56ZHVu9hpu31vU+2esAw upoaZHzqKeITLw+FmxVqOTnhdxJlV5hD/GcE9HKPB716Fby5Q1sfqTvA2S5um/SYCPVl aLoVSxXZkrlPCsNLgKv+fw1iOMqO7nAkpgD5ETA9d2ionMfzs+vItT/+TyD8L8TszHc+ tW3eoeWdwzbg5ompA1VYx3Eq1t82BjpbcL3TI21Evry4qKiZS8TbgYW06UO5ZMrdE0zv X6/vaJjlLo5jQqGpMZK/PokiXpCZx9g08UXmzEUbz0Y9ZE1nPxp2WOoOClPNyhF6gpQD 6NAQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=9NU9PI5h+XIjdFaV8cJFhnAUvW54J00YhhaMQMKLO8o=; b=0eNT9ByinWp2zsB6vuP1y6KfoMr1oG/yr4f2141JdKwYfoZck3gxv+FX8F7JGq+wZP lAK/R82hBUmHUO7DPEtgdD0mfnKmqbRLKK4vwRKYesj+uVfNjCcjt5B++3Hltbcvfvyu OUWgo146SJHC8kQXF+K6KNWMyNDlhoNOqfEOtXiULQRPMcZ87AUHPXnDu+rfKfY+C7IH MoXUNxfX1OJjnPJjcMj5bfbxHU32S6YYUGbOMxt/78ZGJqzzqgc28AdU8MszJAz1dn+T 2N2PfQ3Hki/u9BuqIAblOv5PRy1AXs9UJyEaGYPxLOY1dqXbXfztBgZ0Q80gJINjiSNR GgPw== X-Gm-Message-State: AOAM532bWpQZIqmVu+8d4sEqOAex4a/xehsTb78Jkv0uDPCsxB3owPo6 46Tu7YG8e4QX6+w2kXVlwaL+Z1ctZzOqRPwib1YHEg== X-Received: by 2002:a05:6e02:1ca8:: with SMTP id x8mr20827199ill.150.1634673636531; Tue, 19 Oct 2021 13:00:36 -0700 (PDT) MIME-Version: 1.0 References: <20211015172132.1162559-1-irogers@google.com> <20211015172132.1162559-22-irogers@google.com> In-Reply-To: From: Ian Rogers Date: Tue, 19 Oct 2021 13:00:23 -0700 Message-ID: Subject: Re: [PATCH v2 21/21] perf metric: Allow modifiers on metrics. To: Arnaldo Carvalho de Melo Cc: Andi Kleen , Jiri Olsa , Jin Yao , Namhyung Kim , John Garry , Kajol Jain , "Paul A . Clarke" , Riccardo Mancini , Kan Liang , Peter Zijlstra , Ingo Molnar , Mark Rutland , Alexander Shishkin , Kees Cook , Sami Tolvanen , Nick Desaulniers , Andrew Morton , Jacob Keller , Zhen Lei , ToastC , Joakim Zhang , Felix Fietkau , Jiapeng Chong , Song Liu , Fabian Hemmer , Alexander Antonov , Nicholas Fraser , Adrian Hunter , Denys Zagorui , Wan Jiabing , Thomas Richter , Sumanth Korikkar , Heiko Carstens , Changbin Du , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, Andrew Kilroy , Stephane Eranian Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Oct 19, 2021 at 8:18 AM Arnaldo Carvalho de Melo wrote: > > Em Tue, Oct 19, 2021 at 12:17:10PM -0300, Arnaldo Carvalho de Melo escrev= eu: > > Em Tue, Oct 19, 2021 at 12:13:52PM -0300, Arnaldo Carvalho de Melo escr= eveu: > > > Em Tue, Oct 19, 2021 at 12:06:17PM -0300, Arnaldo Carvalho de Melo es= creveu: > > > > Em Fri, Oct 15, 2021 at 10:21:32AM -0700, Ian Rogers escreveu: > > > > > By allowing modifiers on metrics we can, for example, gather the > > > > > same metric for kernel and user mode. On a SkylakeX with > > > > > TopDownL1 this gives: > > > > > > > > > > $ perf stat -M TopDownL1:u,TopDownL1:k -a sleep 2 > > > > > > > > > > Performance counter stats for 'system wide': > > > > > > > > Hi Ian, can you please take a look on this? this is on my perf/core > > > > branch. > > > > > > I processed the first version of this series, reviewed by Andi, can y= ou > > > please submit the diff from one to the other? > > > > The interdiff from the 21st patch on the first batch versus on the v2 > > batch is below, but it doesn't apply to my current perf/core branch, > > lemme push it to tmp.perf/core... > > It was there already, what I have locally is what is in tmp.perf/core. Hi Arnaldo, The last change I see in tmp.perf/core is: https://git.kernel.org/pub/scm/linux/kernel/git/acme/linux.git/commit/?h=3D= tmp.perf/core&id=3D5f43061b84d815c0f6477c1a8836bf0c6fec15a2 The difference between v2 and v1 which fixes this bug is: +@@ -1500,7 +1568,10 @@ int metricgroup__copy_metric_events(struct evlist *evlist, struct cgroup *cgrp, + return -ENOMEM; + + new_expr->metric_expr =3D old_expr->metric_expr; +- new_expr->metric_name =3D old_expr->metric_name; ++ new_expr->metric_name =3D strdup(old_expr->metric_n= ame); ++ if (!new_expr->metric_name) ++ return -ENOMEM; ++ + new_expr->metric_unit =3D old_expr->metric_unit; + new_expr->runtime =3D old_expr->runtime; + I also cleaned up some checkpatch line length warnings in v2, which I think is the reason for the other changes. Ideally I'd prefer the v2 patch set over the v1, but they are largely identical. Both were based on acme/perf/core. Let me know how I can help. Thanks, Ian > > - Arnaldo > > > > =E2=AC=A2[acme@toolbox perf]$ interdiff ~/wb/old.patch ~/wb/new.patch > > diff -u b/tools/perf/util/metricgroup.c b/tools/perf/util/metricgroup.c > > --- b/tools/perf/util/metricgroup.c > > +++ b/tools/perf/util/metricgroup.c > > @@ -1308,8 +1308,7 @@ > > int ret; > > > > *out_evlist =3D NULL; > > - ret =3D metricgroup__build_event_string(&events, ids, modifier, > > - has_constraint); > > + ret =3D metricgroup__build_event_string(&events, ids, has_constra= int); > > if (ret) > > return ret; > > > > @@ -1324,7 +1323,8 @@ > > > > ids__insert(ids->ids, tmp); > > } > > - ret =3D metricgroup__build_event_string(&events, ids, has_constra= int); > > + ret =3D metricgroup__build_event_string(&events, ids, modifier, > > + has_constraint); > > if (ret) > > return ret; > > > > @@ -1568,7 +1568,10 @@ > > return -ENOMEM; > > > > new_expr->metric_expr =3D old_expr->metric_expr; > > - new_expr->metric_name =3D old_expr->metric_name; > > + new_expr->metric_name =3D strdup(old_expr->metric= _name); > > + if (!new_expr->metric_name) > > + return -ENOMEM; > > + > > new_expr->metric_unit =3D old_expr->metric_unit; > > new_expr->runtime =3D old_expr->runtime; > > > > =E2=AC=A2[acme@toolbox perf]$ > > -- > > - Arnaldo