Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp918438pxk; Thu, 10 Sep 2020 02:01:13 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxWeLcZ1+O8R0oyH5Aw2bEr5ZJVmWOtMmdhH3yjar8Z7VbOSHbRXHCMmM8zPZMgn19eoeg+ X-Received: by 2002:a17:906:14c9:: with SMTP id y9mr8109046ejc.523.1599728473153; Thu, 10 Sep 2020 02:01:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1599728473; cv=none; d=google.com; s=arc-20160816; b=zDdhRBSGNbRvKaO1gl9RCU5gMh0z+6/C/9X8uL83SHWf5jy3dwiAa0Zaj603ZhdWgw 6drQ3vjnjYBXi4e+Io/YYJfVYgRTgL66KImgIZnm/5mzhL1ZlnAkZUm0FZiJAKPo48Cc EF8UC6kv9jk0lmH7trkRPHThg0QSKybCpkCHqPnNg8Mdjxi5U243MIwvG7qaZYGQPEm+ rjRhaHQhZsk7To2DL2U0oYG2hz3TIbxkvX11DLuNJ+FD16sk1FNFeeGw1WSCWKzrkYzX Dc+wnpI2HmdIR/PxMEpWJ9wWTo8tV7mhlu9wWgFLy4zXERRVIT4evz0QAldIYjQIqbyv JqtA== 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=2a/EJ89FfsuwaDD7HE+E0f+GMRTiKlf5IsOp1OnZBa4=; b=HEEERbXCijT2u9QU4YfHWdIlOKVWQbewK7l2g5wfD7izEACx4zc/6xlLsMpR+Q38vR TJXvPBDPZy/nSBwTThEjCzxAoFOuG/k1wuIFWT4gkzQvb1ZpXj64k6/CJE1Er1YWY6p5 3MTogsVeWTj8gJFERRTDIsthtrmlFa5GKRCNMuL8kcgQWrf2AuXAMtEbsBhmliwm/qx7 bh3keBiSq8AvhzqlJ/2p/ZnzsrhYqaR9cHdZP7NFQUwfcS3Hh8YD+chuEoFrMuM+4eRl eB/9g5Po8egEtWoIMYLb2FoJ/03SEQfSxgRWYNMdDcUlELKIZXTbeoUuNPdUdwEwjStr XpVg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=YNnndJOI; 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 p4si3026393ejj.664.2020.09.10.02.00.50; Thu, 10 Sep 2020 02:01:13 -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=YNnndJOI; 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 S1730172AbgIJI7i (ORCPT + 99 others); Thu, 10 Sep 2020 04:59:38 -0400 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:33999 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728626AbgIJI7g (ORCPT ); Thu, 10 Sep 2020 04:59:36 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1599728375; 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=2a/EJ89FfsuwaDD7HE+E0f+GMRTiKlf5IsOp1OnZBa4=; b=YNnndJOIOrHtwDXIs0XPVDBcZH4nx76P/5G4jTUiTiLLGvB3E6G5T73nDBDmrBiqRrjbOR THyAMyiyDg8COenXJziDiZn/c0EibpdPpn0xVlsLzMCfChO1FH34/2yPwAZUggP99qER6s 7QngAxqIms/aQCSADz1BwjswWosWYcA= 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-106-SlM1TaA1PcuzPgnmpyZtBw-1; Thu, 10 Sep 2020 04:59:31 -0400 X-MC-Unique: SlM1TaA1PcuzPgnmpyZtBw-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 482021882FA8; Thu, 10 Sep 2020 08:59:30 +0000 (UTC) Received: from krava (unknown [10.40.192.38]) by smtp.corp.redhat.com (Postfix) with SMTP id 71A8483562; Thu, 10 Sep 2020 08:59:27 +0000 (UTC) Date: Thu, 10 Sep 2020 10:59:26 +0200 From: Jiri Olsa To: Namhyung Kim Cc: Arnaldo Carvalho de Melo , Ingo Molnar , Peter Zijlstra , Mark Rutland , Alexander Shishkin , Stephane Eranian , LKML , Andi Kleen , Ian Rogers Subject: Re: [PATCH 1/4] perf evsel: Add evsel__clone() function Message-ID: <20200910085926.GC1627030@krava> References: <20200908044228.61197-1-namhyung@kernel.org> <20200908044228.61197-2-namhyung@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200908044228.61197-2-namhyung@kernel.org> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 jirka