Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp333373pxb; Wed, 22 Sep 2021 03:19:34 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxiBKZKw/18xSoJhpDuGRS72Y6oDIUt4Ed8Fmaz2WBX0MSIC52lEk6gkxnbymE4uVDUf83e X-Received: by 2002:a50:becb:: with SMTP id e11mr40971432edk.161.1632305974061; Wed, 22 Sep 2021 03:19:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632305974; cv=none; d=google.com; s=arc-20160816; b=wvB+0l29hVN8uIPfGygSf9OvXBgeY6S96ZpAlWM5TxHiC9e01bSWuzxuR57SamIyfo TzsspE4Hd57KLaylwEX0V5lzTTO2OA7CwNtjlyjZXEMtCJV9soD6pBgAlYcl5MlRUV0K EImcDH0CS7xsdZsDbMVSfWffyx+242LsLqlAOFbVfI8MJrLRMb47LymMYjicnQ1mG3qe 9gKAu3wP3EsKJ/DMDq5sJXHeuumHXDDfG1QfwpHj6P98DnmqBvaciffRFPt/IilpKNDF wRtoNZWKi5R31YXwxC1qxeNIVFYmujZ0fPtKjwFpV6JJLhM0CdkqPtXu4VQyLm/6UrsF ywUA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :ironport-sdr; bh=SQmCUmNRbrQ68zygsDneocH0sbFYQpoZlyXY2+I2yzQ=; b=AfaEdX3RTAMEzxU+nSsIAmKRfwkuCSknRRSRLJe2m84vcJVnUeiXy8iLDCF1TalgOG 2rsrQzHEyQzZyyOKXMO40wDNIMQwK5JSt1itbLfVJrjLa5Ftu+IDJx8HxKzU0yXLo+Fk 6aV57sfs01UXD7Gdd67ReHPG1d99f+ekj4HtlYSD0VXhtK/eyl/kotgjQrrUtRt3W9b4 /TXmWd15MQPHT++A2tXSssh1Zco3FGTReQszsoFEheI4eNte4THGB5NnMty/WamiynBF gWkA1wDXJEscfJt2p8q2IvY6gI5ltI6Zv4c6rKExKsYQfcA1+3vUHUYdbj0TlTLKwOJL 8L8w== 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=fujitsu.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id kx3si2604183ejc.108.2021.09.22.03.19.09; Wed, 22 Sep 2021 03:19: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; 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=fujitsu.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234749AbhIVKSg (ORCPT + 99 others); Wed, 22 Sep 2021 06:18:36 -0400 Received: from esa7.hc1455-7.c3s2.iphmx.com ([139.138.61.252]:44405 "EHLO esa7.hc1455-7.c3s2.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234499AbhIVKSL (ORCPT ); Wed, 22 Sep 2021 06:18:11 -0400 IronPort-SDR: FeTWYrLK/Q4GpKi4zlGtaRM9NIRwdbZjVEDUrMGuitFBTDhGnVgMG5RvyF8jpK33zCHdc3iJTO NjnfNwmJff1tt655UvIpDRMeS5k0oH3mUCmpGOi5OGB7vxn5jE7cyP+6xQa2dBcYXRxRZfdmxJ u1+1PYdJGcId3CyXSJN1L0N/t1te6eD9aYcmdrTkSgtKwALjBxSHwRq5ptmZu1v5qm9eswd06M YeN/nX7UWxf0+KR1erKj3m2UJO5k3P1KAvqQT5F8pw68zPaIKLNXplXl2ucxESgrMQlYtkL3ht 3q5j+ZYsA5wZc/SxAcsxNPOB X-IronPort-AV: E=McAfee;i="6200,9189,10114"; a="24913021" X-IronPort-AV: E=Sophos;i="5.85,313,1624287600"; d="scan'208";a="24913021" Received: from unknown (HELO oym-r2.gw.nic.fujitsu.com) ([210.162.30.90]) by esa7.hc1455-7.c3s2.iphmx.com with ESMTP; 22 Sep 2021 19:16:32 +0900 Received: from oym-m2.gw.nic.fujitsu.com (oym-nat-oym-m2.gw.nic.fujitsu.com [192.168.87.59]) by oym-r2.gw.nic.fujitsu.com (Postfix) with ESMTP id 9A9D6E6800; Wed, 22 Sep 2021 19:16:31 +0900 (JST) Received: from yto-om2.fujitsu.com (yto-om2.o.css.fujitsu.com [10.128.89.163]) by oym-m2.gw.nic.fujitsu.com (Postfix) with ESMTP id C5ECCFF44; Wed, 22 Sep 2021 19:16:30 +0900 (JST) Received: from pumpkin.openstacklocal (pumpkin.fct.css.fujitsu.com [10.130.70.189]) by yto-om2.fujitsu.com (Postfix) with ESMTP id A52DE400C007A; Wed, 22 Sep 2021 19:16:30 +0900 (JST) From: Shunsuke Nakamura To: peterz@infradead.org, mingo@redhat.com, acme@kernel.org, mark.rutland@arm.com, alexander.shishkin@linux.intel.com, jolsa@redhat.com, namhyung@kernel.org Cc: linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org Subject: [PATCH v2 1/2] libperf: Add processing to scale the counters obtained during the read() system call when multiplexing Date: Wed, 22 Sep 2021 19:16:26 +0900 Message-Id: <20210922101627.3396398-2-nakamura.shun@fujitsu.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210922101627.3396398-1-nakamura.shun@fujitsu.com> References: <20210922101627.3396398-1-nakamura.shun@fujitsu.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-TM-AS-GCONF: 00 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: nakamura shunsuke perf_evsel__read() scales counters obtained by RDPMC during multiplexing, but does not scale counters obtained by read() system call. Add processing to perf_evsel__read() to scale the counters obtained during the read() system call when multiplexing. Signed-off-by: Shunsuke Nakamura --- tools/lib/perf/evsel.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/tools/lib/perf/evsel.c b/tools/lib/perf/evsel.c index 8441e3e1aaac..0ebd1d34436f 100644 --- a/tools/lib/perf/evsel.c +++ b/tools/lib/perf/evsel.c @@ -18,6 +18,7 @@ #include #include #include +#include void perf_evsel__init(struct perf_evsel *evsel, struct perf_event_attr *attr, int idx) @@ -321,6 +322,11 @@ int perf_evsel__read(struct perf_evsel *evsel, int cpu, int thread, if (readn(*fd, count->values, size) <= 0) return -errno; + if (count->ena != count->run) { + if (count->run != 0) + count->val = mul_u64_u64_div64(count->val, count->ena, count->run); + } + return 0; } -- 2.27.0