Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp1368165ybb; Thu, 9 Apr 2020 00:11:28 -0700 (PDT) X-Google-Smtp-Source: APiQypKgwf6Q+mIMraIwKNb8bme7Te5YKTkM1LV7Kl8vKNRKyEC7v36MFRrpyjremeU0SEuUeCpa X-Received: by 2002:a9d:7a7:: with SMTP id 36mr8972570oto.283.1586416288503; Thu, 09 Apr 2020 00:11:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1586416288; cv=none; d=google.com; s=arc-20160816; b=PM64U8DUfLExnEN6Pok0a3+SQrwn2io7WB3IR/OWb2TPAc9tjNh3Nt4C7Jv4rLZZAQ yQMnzE3rUjSXXk51AlrcPU82jJKGQobXWRCcA/mGxtNmQ4obtIzPx/5g8QYlj5oK5dBc 8+uFMXYZsgptrnhQLJjkekZ1lInIrHLWCRRlF/5oEVS+Z/e0pG7xkl+l9MyiJK5YaTxN HtDlMcn/0ThaIUZ4Rk/YP1sBEeR5zibsr7sKckikhY8Heb2qkpAKsrRaqL72192wBLNe 7Yb5sPPmhOi4o/tH+FEFVF+VvQ2g6bM8xVC0oTkFF1Ki1o6K5ehvtOF1+qkjDqPhWCWp kMbg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :ironport-sdr:ironport-sdr; bh=ei7ucekUvdFo+Qa+c9ccDckz63kQm0jyWn7GBP/qwZY=; b=A3zhZcJ8mMiwgqRLeiluPwEzzjrtIzyiYaNaUydV6/ONYn1WmaXmLC8hdHYgzlHP9a GuVm/XXw8zunIWWbFa5QxyZbZrcZD0oJRRFsZ8Mt+eMtMyOzN+zjMttJitc79Vq+W9vi /Q0PiLcMoPxe9CSdBlVhz5/fncV1bZpIISIPEXj3o9wXp57gF0eTsGNN9ly6nh1Vii24 OoGk7WZ8JtmNA9UgKtJ+Ky1M33b8TcOFP/eJYzQPMq8/aAXCxIQAFsPgxe4s8Oge4kBl anZeBjziJBrYEap6GJ6f0xJOYdz0sh6YKHikd5XFlDyYzXfPRLqdaSb6x2lpzV3Tqgy6 Ct/g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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. [209.132.180.67]) by mx.google.com with ESMTP id v108si3518623otb.136.2020.04.09.00.11.13; Thu, 09 Apr 2020 00:11:28 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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 S1726620AbgDIHKF (ORCPT + 99 others); Thu, 9 Apr 2020 03:10:05 -0400 Received: from mga14.intel.com ([192.55.52.115]:29893 "EHLO mga14.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725795AbgDIHKB (ORCPT ); Thu, 9 Apr 2020 03:10:01 -0400 IronPort-SDR: LSmecBvBJAT6KiOL+jGpKh6J1VzRcLSZNXdFPaNcEwHgqotRpYPdlOpJK7b7xhV0LZ0CEvi7Tn T5N5edKGaqLw== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 Apr 2020 00:10:00 -0700 IronPort-SDR: 4VB3nF+R5QKwZ0SsgQHo8Po3NfB4+eC6+4SN+qar5tuOsS14D9h3K4NnqKXgBJhi012eXam+Pq C1nF8MBIwRaA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.72,361,1580803200"; d="scan'208";a="362078582" Received: from kbl-ppc.sh.intel.com ([10.239.159.118]) by fmsmga001.fm.intel.com with ESMTP; 09 Apr 2020 00:09:58 -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] perf stat: Zero ena and run for interval mode Date: Thu, 9 Apr 2020 15:07:55 +0800 Message-Id: <20200409070755.17261-1-yao.jin@linux.intel.com> X-Mailer: git-send-email 2.17.1 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org As the code comments in perf_stat_process_counter() say, we calculate counter's data every interval, and the display code shows ps->res_stats avg value. We need to zero the stats for interval mode. But the current code only zeros the res_stats[0], it doesn't zero the res_stats[1] and res_stats[2], which are for ena and run of counter. This patch zeros the whole res_stats[] for interval mode. Signed-off-by: Jin Yao --- tools/perf/util/stat.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tools/perf/util/stat.c b/tools/perf/util/stat.c index 5f26137b8d60..242476eb808c 100644 --- a/tools/perf/util/stat.c +++ b/tools/perf/util/stat.c @@ -368,8 +368,10 @@ int perf_stat_process_counter(struct perf_stat_config *config, * interval mode, otherwise overall avg running * averages will be shown for each interval. */ - if (config->interval) - init_stats(ps->res_stats); + if (config->interval) { + for (i = 0; i < 3; i++) + init_stats(&ps->res_stats[i]); + } if (counter->per_pkg) zero_per_pkg(counter); -- 2.17.1