Received: by 2002:a25:868d:0:0:0:0:0 with SMTP id z13csp2694477ybk; Mon, 18 May 2020 05:50:48 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw82CesToT+virUH65iVRVrbVfWy8MUHookM/rVHXTWznq3WY02UAEXLo98lQjceHwCUGnl X-Received: by 2002:a05:6402:b14:: with SMTP id bm20mr12531350edb.297.1589806248351; Mon, 18 May 2020 05:50:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1589806248; cv=none; d=google.com; s=arc-20160816; b=YduxIc4YynzvOois79cLgnKKxk0tZUOSglDEWXJtFuS2dPSwCzSHwcvrwlzdT2h3a2 bvV/N3ZxLDC7Y2abylo9xutGfykZwu/Pd5TtV8zjwEzH+cvDizNO3K8RlmPukb2EXAW3 kjTgrVKTIlcyRpZZP18NmF5xNqzSACzHT9vMdipZCKj3ACjHVZR38xcwV47tvAvjiUEW /ofWTuewywCsch+qb9rcs76WlYBAjlhuJWDQXPgFmMO0e54S+hZ2A1OOwLv7zuimZP1J 1UgWb5YHfI4WmyuZ6N8IsRpPY/xLhjTAZEJnd8Z7R7iMyiDT27WeqK12elQb3OOiU8Bl cLXQ== 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=o4ExJo3ffdKAnYEo/Wg/KhFd/N7hrFLCbW9nHeiDoJU=; b=I/gzYkwti+/xyKUtC5rLMmmDAKa+bLPmcbQLxXS/gObgV0v6QCTRs6oO1KhhZQ/FWD gRDUnxZJzhltWPmN0IXnDDCcWfOsNea5UX88ZtctnCoCfgEiP+9iiiV1AIJpknE5/q7q piR7CBr+2VArdA1ATPxNf2+gjh2CUn4lQUyXq37AuFk3cU5x5Dtxx4JF2K16G7PN42lz LeqPlR+gm4zYg9R+2wVH5xPRqEAmz8vLqF8pTQjTZ6smNc5w/z7x+AP9V/T+O6pN9ZXS fU0WkPRTRaxdDccHXU8ztw4wwtruVnEgFlFd1NHWNBNKMs5FTHLN4Zd55Ktq6rxSTd/c ACMw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=CnIHeCus; 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 w21si6371727ejz.276.2020.05.18.05.50.23; Mon, 18 May 2020 05:50:48 -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=CnIHeCus; 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 S1726999AbgERMsh (ORCPT + 99 others); Mon, 18 May 2020 08:48:37 -0400 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:45692 "EHLO us-smtp-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726709AbgERMsg (ORCPT ); Mon, 18 May 2020 08:48:36 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1589806115; 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=o4ExJo3ffdKAnYEo/Wg/KhFd/N7hrFLCbW9nHeiDoJU=; b=CnIHeCus2+Qqh/WjI2JqRf+PfWzsmNJNO3BwLn1IdSvTidMu7u7oAHHZdD/zbNYsf2m1g4 kC6uL6xexWbE6RuzuKSRDP5NHUF4S5mp9c4PF6oBjgKC1Khzg5umMClW9QSR+izTvHU/41 2mTV6CBW+91VOnZg823JdxtS0aWi93E= 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-221-7xxaR3QQNF2-mL8dNxc_pQ-1; Mon, 18 May 2020 08:48:31 -0400 X-MC-Unique: 7xxaR3QQNF2-mL8dNxc_pQ-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 050391054F8B; Mon, 18 May 2020 12:48:30 +0000 (UTC) Received: from krava (unknown [10.40.196.18]) by smtp.corp.redhat.com (Postfix) with SMTP id 8CE6782ED0; Mon, 18 May 2020 12:48:27 +0000 (UTC) Date: Mon, 18 May 2020 14:48:26 +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 v5 4/5] perf stat: Save aggr value to first member of prev_raw_counts Message-ID: <20200518124826.GF3726797@krava> References: <20200514053638.3736-1-yao.jin@linux.intel.com> <20200514053638.3736-5-yao.jin@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200514053638.3736-5-yao.jin@linux.intel.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, May 14, 2020 at 01:36:37PM +0800, Jin Yao wrote: > To collect the overall statistics for interval mode, we copy the > counts from evsel->prev_raw_counts to evsel->counts. > > For AGGR_GLOBAL mode, because the perf_stat_process_counter creates > aggr values from per cpu values, but the per cpu values are 0, > so the calculated aggr values will be always 0. > > This patch uses a trick that saves the previous aggr value to > the first member of perf_counts, then aggr calculation in > process_counter_values can work correctly for AGGR_GLOBAL. > > Signed-off-by: Jin Yao > --- > tools/perf/util/stat.c | 10 ++++++++++ > tools/perf/util/stat.h | 1 + > 2 files changed, 11 insertions(+) > > diff --git a/tools/perf/util/stat.c b/tools/perf/util/stat.c > index aadc723ce871..fbabdd5b9b62 100644 > --- a/tools/perf/util/stat.c > +++ b/tools/perf/util/stat.c > @@ -249,6 +249,16 @@ void perf_evlist__copy_prev_raw_counts(struct evlist *evlist) > perf_evsel__copy_prev_raw_counts(evsel); > } > much better, please put some comments in here explaning wha is this for, because it's not obvious ;-) thanks, jirka > +void perf_evlist__save_aggr_prev_raw_counts(struct evlist *evlist) > +{ > + struct evsel *evsel; > + > + evlist__for_each_entry(evlist, evsel) { > + *perf_counts(evsel->prev_raw_counts, 0, 0) = > + evsel->prev_raw_counts->aggr; > + } > +} > + > static void zero_per_pkg(struct evsel *counter) > { > if (counter->per_pkg_mask) > diff --git a/tools/perf/util/stat.h b/tools/perf/util/stat.h > index 62cf72c71869..18ead55756cc 100644 > --- a/tools/perf/util/stat.h > +++ b/tools/perf/util/stat.h > @@ -199,6 +199,7 @@ void perf_evlist__free_stats(struct evlist *evlist); > void perf_evlist__reset_stats(struct evlist *evlist); > void perf_evlist__reset_prev_raw_counts(struct evlist *evlist); > void perf_evlist__copy_prev_raw_counts(struct evlist *evlist); > +void perf_evlist__save_aggr_prev_raw_counts(struct evlist *evlist); > > int perf_stat_process_counter(struct perf_stat_config *config, > struct evsel *counter); > -- > 2.17.1 >