Received: by 2002:a25:1104:0:0:0:0:0 with SMTP id 4csp133670ybr; Fri, 22 May 2020 02:55:34 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyEI496L247JtbM1ZKUFKwSrhhfbZlQptdncCP/kaHrqzA14AxwqRe8aztk+yN+2oSR5xtY X-Received: by 2002:a17:906:e090:: with SMTP id gh16mr7558834ejb.41.1590141334400; Fri, 22 May 2020 02:55:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1590141334; cv=none; d=google.com; s=arc-20160816; b=cQjeTs8Hrt1TYNmUMiohuLlC6/1f2YLqaDnQBhAgNluk+VyTUpBYiGGxQrQyqm6vTR m/xeXYTIX1zFTphb5zYx6mcESelRMLVDOqpy2OpoOGuKv2thu3oYnIt+wDLDf3TWmeqE /xhEkfGmU2i2/isSlzg2CbmXgCEgfacUWW1czVjUxQIgUuTsLnTiyBeUkjHMLzic6To1 ONGDl9GRIQJuR90hMQ34qfvcWjvZ/dyFh5lJfiuhd6hlEOxBBimv+ljeN4auxU4xHVAn 7KDazQ636Q1kcZq76pw6Bz1Utqy9adO+mgREzAujvp1hI2F5pCceVk4S6qZW1AtifKse tVVA== 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=phT8Jdcjb8WhmeRHEo/eXl/PflCfxX/KJwitxNs5m9k=; b=EjZApF8yjdzaBt4+QTJ/Cx05tTkcrN1IhjyLYFGtYLBjAioQ8R6PYx+NBcmtKhlGjX 2f2boyq1ICRj70NeMYt38tOl1v+4hsF6gW2tOZTM9wcii6gZVMWzxbwZy1Cg3YvbAiH7 y86mgc7HjXtkvt1ENmsPasZqEPARCSXFHQCyufXzQzhyAjMaSa/Q9R6Ao2AbRXAJdf0L uzh4dGzC3pI2stYrYJSqgFKHSdlDHepBsuEe4dtSNplIqOqTeBxLItHCPFIQiWxCJdiA YHoV37YOS1QmR729eVryvuMGva/qaS1GVIzKqA9D2xS/cu/sxP5bLw8fI4ofsso+9+gq BS8g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=b4bOQEFR; 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 gf6si4465218ejb.338.2020.05.22.02.55.10; Fri, 22 May 2020 02:55:34 -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=b4bOQEFR; 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 S1728478AbgEVJx1 (ORCPT + 99 others); Fri, 22 May 2020 05:53:27 -0400 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:57823 "EHLO us-smtp-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728425AbgEVJx0 (ORCPT ); Fri, 22 May 2020 05:53:26 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1590141204; 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=phT8Jdcjb8WhmeRHEo/eXl/PflCfxX/KJwitxNs5m9k=; b=b4bOQEFRYpnHoccuAED+XhLnr1isFDdqcLpakw/FXMl+b2h1OPJzUTQJMo5qmqUrPnXx+V 6/xiwsXhGWA9VkXLem6hjI1BxZ2c0MfNoD3e0k060v3IGgv8+nZytw6dM7WXlqZsuZ5lpN 2+0jEln55Ye90DZPTtciEi2KGKln22M= 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-441-kGdR8j8pO1iQEfkv9udLCg-1; Fri, 22 May 2020 05:53:22 -0400 X-MC-Unique: kGdR8j8pO1iQEfkv9udLCg-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 241608018A2; Fri, 22 May 2020 09:53:21 +0000 (UTC) Received: from krava (unknown [10.40.195.217]) by smtp.corp.redhat.com (Postfix) with SMTP id 0B81160CD0; Fri, 22 May 2020 09:53:14 +0000 (UTC) Date: Fri, 22 May 2020 11:53:14 +0200 From: Jiri Olsa To: Jin Yao Cc: acme@kernel.org, jolsa@kernel.org, peterz@infradead.org, mingo@redhat.com, alexander.shishkin@linux.intel.com, Linux-kernel@vger.kernel.org, ak@linux.intel.com, kan.liang@intel.com, yao.jin@intel.com Subject: Re: [PATCH] perf evlist: Ensure grouped events with same cpu map Message-ID: <20200522095314.GD264196@krava> References: <20200521062240.18865-1-yao.jin@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200521062240.18865-1-yao.jin@linux.intel.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, May 21, 2020 at 02:22:40PM +0800, Jin Yao wrote: SNIP > --- > tools/perf/builtin-stat.c | 3 +++ > tools/perf/util/evlist.c | 32 ++++++++++++++++++++++++++++++++ > tools/perf/util/evlist.h | 5 +++++ > 3 files changed, 40 insertions(+) > > diff --git a/tools/perf/builtin-stat.c b/tools/perf/builtin-stat.c > index 377e575f9645..0e4fc6b3323c 100644 > --- a/tools/perf/builtin-stat.c > +++ b/tools/perf/builtin-stat.c > @@ -584,6 +584,9 @@ static int __run_perf_stat(int argc, const char **argv, int run_idx) > if (affinity__setup(&affinity) < 0) > return -1; > > + if (!evlist__cpus_matched(evsel_list)) > + evlist__force_disable_group(evsel_list); > + > evlist__for_each_cpu (evsel_list, i, cpu) { > affinity__set(&affinity, cpu); > > diff --git a/tools/perf/util/evlist.c b/tools/perf/util/evlist.c > index 2a9de6491700..fc6e410ca63b 100644 > --- a/tools/perf/util/evlist.c > +++ b/tools/perf/util/evlist.c > @@ -1704,3 +1704,35 @@ struct evsel *perf_evlist__reset_weak_group(struct evlist *evsel_list, > } > return leader; > } > + > +bool evlist__cpus_matched(struct evlist *evlist) > +{ > + struct evsel *prev = evlist__first(evlist), *evsel = prev; > + > + if (prev->core.nr_members <= 1) > + return true; hum, this assumes there's only one group in evlist? how about case like A,{B,C},D,{E,F} also please add automated tests for this > + > + evlist__for_each_entry_continue(evlist, evsel) { > + if (evsel->core.cpus->nr != prev->core.cpus->nr) > + return false; > + > + for (int i = 0; i < evsel->core.cpus->nr; i++) { > + if (evsel->core.cpus->map[i] != prev->core.cpus->map[i]) > + return false; > + } > + > + prev = evsel; > + } > + > + return true; > +} > + > +void evlist__force_disable_group(struct evlist *evlist) > +{ > + struct evsel *evsel; we need to put some warning for user in here thanks, jirka > + > + evlist__for_each_entry(evlist, evsel) { > + evsel->leader = evsel; > + evsel->core.nr_members = 0; > + } > +} > diff --git a/tools/perf/util/evlist.h b/tools/perf/util/evlist.h > index b6f325dfb4d2..ea7a53166cbd 100644 > --- a/tools/perf/util/evlist.h > +++ b/tools/perf/util/evlist.h > @@ -355,4 +355,9 @@ void perf_evlist__force_leader(struct evlist *evlist); > struct evsel *perf_evlist__reset_weak_group(struct evlist *evlist, > struct evsel *evsel, > bool close); > + > +bool evlist__cpus_matched(struct evlist *evlist); > + > +void evlist__force_disable_group(struct evlist *evlist); > + > #endif /* __PERF_EVLIST_H */ > -- > 2.17.1 >