Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp1069564pxk; Thu, 10 Sep 2020 06:24:01 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw9NLlSResGJ3Y+8ENhksCqlA18p0NZ7y4qtDy+5HXOe00JkKHKHrB2WDTc1QmnBtlzIjWi X-Received: by 2002:a17:906:6682:: with SMTP id z2mr9221581ejo.434.1599744240961; Thu, 10 Sep 2020 06:24:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1599744240; cv=none; d=google.com; s=arc-20160816; b=0zNCUitmVOVdSvUE/i99H8YQt6eMShutKTe1RVbN4Z8L11JpGTG3Lr0ABHDRnolTbo 1594qYLqBzi6QbqVh3StdIFiXzqiBWO/ezabHl9Ofif4INSDxbb6UXR5AKP8SZtu/u20 XtXjlfdw2qcFc1ko/0J1aPEd+ii2exKzmUiUbzZYfCeZVWsYu7AyAJNnM3JY/IYTX6mw u7LxE3acEjYpP1bwoASv+KmzHMawElEF2ONjidqkQb2VZ09WhlAF+goayXn44Le4KnYo DFcYlryfOAzmbf+T+S+uA9JN2woeYFpp75znn8InYdlBQ6IHLLb0wPfGjZ7i0CDd91f9 cqxQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version; bh=jBLcgxMKAbS1n+eV0fIrOxnLTOdgcrxYXmGgYjmbzNc=; b=GN+vX6CVc5wnqDWKxtTW0jS0LtTWNe1EJFp1WGiKSVvFuqx/HDekmgQqgYDhn1gFEg iAO4YMDIL9wZ0iMsb+5tefXgnB2Cub0evVcz6jvzYwSYxlE2UWINaPNmGC06prQYFY5I IEdT2cS4Pxoi1mMd0rrVVD7eRtLiTLFBldA5W6IuZjwDggWuFZyeiOmNyxJI3dm8T/JB pKODZGyg4psjNKyHdrAwRvG2ltaWFEdfkMzdQT2S/6ekb1NP2sxNYlyERi84F8WC2X5M hC0qDwWQGaFq8HCWIwvMBLI0jrJLNsafevrKcBw2YFrmPhkntEAy44RSRdQQLC3Zio9y +Zsw== 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id d12si904705edo.423.2020.09.10.06.23.37; Thu, 10 Sep 2020 06:24:00 -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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730484AbgIJNWQ (ORCPT + 99 others); Thu, 10 Sep 2020 09:22:16 -0400 Received: from mail-wr1-f66.google.com ([209.85.221.66]:44310 "EHLO mail-wr1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730637AbgIJNS4 (ORCPT ); Thu, 10 Sep 2020 09:18:56 -0400 Received: by mail-wr1-f66.google.com with SMTP id s12so6645175wrw.11 for ; Thu, 10 Sep 2020 06:18:36 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=jBLcgxMKAbS1n+eV0fIrOxnLTOdgcrxYXmGgYjmbzNc=; b=cYGgBsovPCI9GsQi3tgODPRsJ++Nk/Q1do7WRDofOANKw+ZuAQzf9RtkUVMgzmMGKd YULPVk1jC1sTsc8onNX/QUtCqR04n8HTSQdeJfc2Eu+4tZL2mm3/OzGkrv6z4L70kOPB J4UteWYTZzAzUfTiOul3mWqUqtadcZ/CRM98MypVbXilRjBEN3tpOUxtpiDZUtdyjf6v Vtge5yqh4wVFx3ugkCFeK7Tv4L13YiWe4XThXEi/IB3PORhc7eCGbO5KtKMfRH1ZHQ0d rXk+gx8rUC6sY9noBGEZ9JuG+2XpiOoPz6OaFSwiWnikk4QCEmMA6MTuI1XiX9nLjOaM E7cw== X-Gm-Message-State: AOAM533gjDvh948+ws7C3z76X2tAuaZg5zIeNE4zVOcSBHUQz9YEgaUT EzSAJIa4s5IvgcqjkrSxjRh7k+WAeVnwg09NdBw= X-Received: by 2002:adf:a3c9:: with SMTP id m9mr9159127wrb.80.1599743916042; Thu, 10 Sep 2020 06:18:36 -0700 (PDT) MIME-Version: 1.0 References: <20200908044228.61197-1-namhyung@kernel.org> <20200908044228.61197-2-namhyung@kernel.org> <20200910085926.GC1627030@krava> In-Reply-To: <20200910085926.GC1627030@krava> From: Namhyung Kim Date: Thu, 10 Sep 2020 22:18:25 +0900 Message-ID: Subject: Re: [PATCH 1/4] perf evsel: Add evsel__clone() function To: Jiri Olsa Cc: Arnaldo Carvalho de Melo , Ingo Molnar , Peter Zijlstra , Mark Rutland , Alexander Shishkin , Stephane Eranian , LKML , Andi Kleen , Ian Rogers Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Jiri, On Thu, Sep 10, 2020 at 5:59 PM Jiri Olsa wrote: > > On Tue, Sep 08, 2020 at 01:42:25PM +0900, Namhyung Kim wrote: > > The evsel__clone() is to create an exactly same evsel from same > > attributes. Note that metric events will be handled by later patch. > > > > It will be used by perf stat to generate separate events for each > > cgroup. > > > > Signed-off-by: Namhyung Kim > > --- > > tools/perf/util/evsel.c | 57 +++++++++++++++++++++++++++++++++++++++++ > > tools/perf/util/evsel.h | 1 + > > 2 files changed, 58 insertions(+) > > > > diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c > > index fd865002cbbd..4f50f9499973 100644 > > --- a/tools/perf/util/evsel.c > > +++ b/tools/perf/util/evsel.c > > @@ -331,6 +331,63 @@ struct evsel *evsel__new_cycles(bool precise) > > goto out; > > } > > > > +/** > > + * evsel__clone - create a new evsel copied from @orig > > + * @orig: original evsel > > + * > > + * The assumption is that @orig is not configured nor opened yet. > > + * So we only care about the attributes that can be set while it's parsed. > > + */ > > +struct evsel *evsel__clone(struct evsel *orig) > > +{ > > + struct evsel *evsel; > > + struct evsel_config_term *pos, *tmp; > > + > > + BUG_ON(orig->core.fd); > > + > > + evsel = evsel__new(&orig->core.attr); > > + if (evsel == NULL) > > + return NULL; > > + > > + *evsel = *orig; > > this seems wild ;-) I saw that assumption above, > but I wonder we could add some check or zero/init > the rest of the fields fields Alternatively, we could only copy relevant fields explicitly. Other fields will remain zero by evsel__new() above. But it might be easy to be missed by future changes.. Thanks Namhyung