Received: by 2002:a25:868d:0:0:0:0:0 with SMTP id z13csp2780439ybk; Mon, 18 May 2020 07:47:02 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxQG8FQJb0xTl9Oi7BTEj6SBPdzfFcmlP7zPrUYoSd0OrMWHIKXXfq5Fc1KTxegwOOqOCIU X-Received: by 2002:a50:fd97:: with SMTP id o23mr13935670edt.363.1589813222785; Mon, 18 May 2020 07:47:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1589813222; cv=none; d=google.com; s=arc-20160816; b=RaUk3IAL+UibB0VmE8DDaHe6eZD7jPRzepD3pFzZbhyCv8mUseVdJlZGXuHIWJ0DAN A8QAJhE1eAma2/+N23A7dz0QLtwt+YEwGjeWk+W210xoA/Bka8SPK5UgqBbNXit3Ozw7 yYApucz5pEE8uzFbodyyWB1VLXUM2sKA9d0fB57HTFwA24MlTFeB2JRsiGrBAZR/F9MF uj+tifrx3S+lUhXvKkZb71XMJkVzGhO4uoOP/iyHNa1NJhD86sZpjFFhx59twWLR13ta 6zCqA6yROtqtbCmbSZ9bylGipeCkUwL2kPIG4FNrjkck81BRGSQ+kNl9Oi06QFd6QEd5 BcSQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:ironport-sdr:ironport-sdr; bh=cNiidzkuPxUPMKxt/bqDXC0MyJJ+cY+wYPPB7hlpqxk=; b=Qkr/+ouHbJK2G3CsFLBkOKe/4eoGF4M+nSN4/uuBAyvjaqNsrxVHh+h8JwwmlWTQkq dEe1jyRAN2lTbHIjsvkoOQ2DIQK/EGMgyRfMknUQfgJeJMnbc6QQse/RClx4zOtWu/EZ ZSb4ekgSRaMYsQ0P86+BuaPmTmWxyNKmNmSOqGZYQ1AozhDbMliBxerhoZrVeuGzHw2u EUf/WoEpvC7AnrdDMleOiyCX/rhGyz+tl2p0vnLJedTrIRGLj+veGPd6FdPJntPIlK3Z mXC2gZNJb3ZCl6NCmsgxiNlr7P+V9DU/6pEgmuCIFsBZvgEypujuAJqCxZdxY2T1cpbK Fk3g== 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 b9si6690946eja.138.2020.05.18.07.46.39; Mon, 18 May 2020 07:47:02 -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 S1728127AbgEROpF (ORCPT + 99 others); Mon, 18 May 2020 10:45:05 -0400 Received: from mga03.intel.com ([134.134.136.65]:54773 "EHLO mga03.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726997AbgEROpE (ORCPT ); Mon, 18 May 2020 10:45:04 -0400 IronPort-SDR: EF5Lfdgy74IYwQ86r6wmatB8YvQZgY4mOO2VY8Hpc0r5bZlzckU+h0RJG30/qDXn4CzCiDVp7y AqOB7iLARSeg== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 May 2020 07:45:04 -0700 IronPort-SDR: u5e5rPM4MNDxyUv86aT/GN85X7sYKIzuJJ9PQTchWQ99t3JEN/+ExEJ5A3dAkHVdka8nRL/+6b /9izMuLA2scA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.73,407,1583222400"; d="scan'208";a="254460697" Received: from yjin15-mobl1.ccr.corp.intel.com (HELO [10.254.208.114]) ([10.254.208.114]) by fmsmga008.fm.intel.com with ESMTP; 18 May 2020 07:45:01 -0700 Subject: Re: [PATCH v5 4/5] perf stat: Save aggr value to first member of prev_raw_counts To: Jiri Olsa 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 References: <20200514053638.3736-1-yao.jin@linux.intel.com> <20200514053638.3736-5-yao.jin@linux.intel.com> <20200518124826.GF3726797@krava> From: "Jin, Yao" Message-ID: <8ea36c95-3b38-a31e-b05a-41c9ccbada51@linux.intel.com> Date: Mon, 18 May 2020 22:44:59 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:68.0) Gecko/20100101 Thunderbird/68.8.0 MIME-Version: 1.0 In-Reply-To: <20200518124826.GF3726797@krava> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 5/18/2020 8:48 PM, Jiri Olsa wrote: > 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 > Thanks, I will put some comments in v6. Thanks Jin Yao >> +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 >> >