Received: by 2002:a25:868d:0:0:0:0:0 with SMTP id z13csp1067500ybk; Wed, 13 May 2020 22:41:22 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyb0HP6NmbBPHsrqn+0RHKl93C9iaqK5XPS2BpeY1YVuW+Nsy0w6kPpdpN7ddqgKwcmrcwz X-Received: by 2002:a17:906:55c3:: with SMTP id z3mr2332545ejp.180.1589434882609; Wed, 13 May 2020 22:41:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1589434882; cv=none; d=google.com; s=arc-20160816; b=atJjls4IIed99PuuTmwcCPZOkBU8cfNiPGG+EbNvMx9FvNqqJ0k8Jpm8IgOIJQpOyf hKgMq+qpYmlAUS3rfMA+hVrk13F9/7EajGm89vGskUvPNC3kuRiIfZLy6OPTboyYksao z/DLDeGcuuFEEjLxwy+e+aLPo2UVnO5pOTvEf28s+U1HBxadpzfNgMlLJQnIlYuE7x2m h8TguzbDMmXWBQ0bUtFqWUiKUg8TddY5Cqa3Mns/l1zNx3ZWfZNAeZHcSN8zfDxCyssU E888Uuagt4kLu3BcuczL4S0L86Q/WJqJXXlfjV3PvSxtqSSFYpEvZxqF1JAEJXtKpdbH Lp0w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:ironport-sdr:ironport-sdr; bh=FAl496DcGZXzgCXvuJ2Jj4fKCuGHfc3OLnZABeAMYSw=; b=dH45lgdI6VGRTEdI9hRTK9tY3UgLye34wk221ouRrfzZBJzYZAW+E7xTGAv1tlqsGl zdqIWu0/YWIiewiTLk8YFfOAf0bW1SQUoA8juVJhE2QoDElAuz71QCsWOHEGuw4BYa8b 4ifwqFp1c5j/iu59yIvN3Dk9AE51EuIG6p5nmiqLkKvvuRSl/skuFq4BXUPgqqrMdMv7 RHYo93lew7pyn32nbWD4eIVCZ9pWnNekiAkDl/tssp/D07p0FamXgaOJa7F0Fc1M3ThY fTeHeUJulIrFkVmgC+iMQL31GVoF0Y/dPiuCCOhOIDrtrQ1dl1fk+p0dN1CfCsQA47do 5ygw== 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=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id yd21si1046000ejb.330.2020.05.13.22.40.50; Wed, 13 May 2020 22:41:22 -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=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726090AbgENFiw (ORCPT + 99 others); Thu, 14 May 2020 01:38:52 -0400 Received: from mga03.intel.com ([134.134.136.65]:62468 "EHLO mga03.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725794AbgENFiv (ORCPT ); Thu, 14 May 2020 01:38:51 -0400 IronPort-SDR: 00B8NHNdQCZKgC1mT5c/ScjSiPQSS64sUEqA6WiJjHddc5a7r00Upw9tOVHSGKc+/s46pf2vaz c3DSCg9iGqSQ== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 May 2020 22:38:51 -0700 IronPort-SDR: XnX1a0KEMLuazqbcENeFXrU4JnnSIgc+zvoXOko9Y1X91fYsASHWj2gidcQt306dDnp7vNxz9d CiiHdK0aCS1g== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.73,390,1583222400"; d="scan'208";a="287289074" Received: from kbl-ppc.sh.intel.com ([10.239.159.118]) by fmsmga004.fm.intel.com with ESMTP; 13 May 2020 22:38:48 -0700 From: Jin Yao To: acme@kernel.org, jolsa@kernel.org, peterz@infradead.org, mingo@redhat.com, alexander.shishkin@linux.intel.com Cc: Linux-kernel@vger.kernel.org, ak@linux.intel.com, kan.liang@intel.com, yao.jin@intel.com, Jin Yao Subject: [PATCH v5 4/5] perf stat: Save aggr value to first member of prev_raw_counts Date: Thu, 14 May 2020 13:36:37 +0800 Message-Id: <20200514053638.3736-5-yao.jin@linux.intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200514053638.3736-1-yao.jin@linux.intel.com> References: <20200514053638.3736-1-yao.jin@linux.intel.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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); } +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