Received: by 2002:a05:6520:4d:b0:139:a872:a4c9 with SMTP id i13csp771778lkm; Wed, 22 Sep 2021 14:37:08 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyd5fnwl45P0eRIu3krn/NiUBuu5Z0qAmk1FKHb9ehOfn/otY6kagF5E1u2GS7oEUupjs+X X-Received: by 2002:a17:906:39cd:: with SMTP id i13mr1421509eje.227.1632346627955; Wed, 22 Sep 2021 14:37:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632346627; cv=none; d=google.com; s=arc-20160816; b=TIAYx84msDr2ildmcvXhfjGiNd1Dv5smX58gKrsCU81P5TWsMohwnT5MsgcvQY6/p1 9Su4WZxEly07ZL6+gQZHFro5VaZ/E1h3FrRrslKpO8YutfJ3B+sAg8fIQkXWMMe46lPw mG9nDMGqE8sT17lmm8PBOe1TlhudspiI6mfnx+jsbId/vOWGXguH2yyZABQEX45DJy96 P5jifmZsMQBKX9YmrMLHqZltV8iYjU49L410oMJTQ3YVBs9l+l9rdSt+nWvqTK0wSv1c Ikt8ieWOB8bJYO9AbbJr4XuOaB0269q7HcwV9kiE3dpHtB81mXdSMHriWREmFK2wrK97 FjWg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=tkHP6mmjG7SBJfcpCC261TiUWmXihHKnsMoMGcToTiQ=; b=0EItfvrt5sxYQypX2tYOHFQkCShb8IB7yIe0gu7toquWzR+fTpX9bqrDrjpMHLv6Ep 65mflxCeuWqMGRMbcwVI/Pj433xgmel8F2jixf67rpctdZgaKp2DqCyDz06FM3D6cbdY 6k8TU4mvbMel4WANjVWqZ+DWXwnez2GAFEh7c2gHakWBeZCnj7LNsk68eP/8f6dCfOzp 2kpG1q2Mf+7TlJGbvlqoAnaGmbva7LXE7DQFJwTtgoVBasrlgMRlzhs1the9B9yEJasP QF4xV5uLiNf7TBJQMbuI6laT6DTPS+zsSUNLLdhZFqTTc6YJv0mi99BRc+xGbuGHQ6ki TdvA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=AGAWeiEq; 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 bi14si3798946ejb.441.2021.09.22.14.36.43; Wed, 22 Sep 2021 14:37:07 -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=AGAWeiEq; 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 S238072AbhIVVg3 (ORCPT + 99 others); Wed, 22 Sep 2021 17:36:29 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:32075 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238033AbhIVVg0 (ORCPT ); Wed, 22 Sep 2021 17:36:26 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1632346496; 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=tkHP6mmjG7SBJfcpCC261TiUWmXihHKnsMoMGcToTiQ=; b=AGAWeiEqODphpUjFWRt4wwP/HxLrnj0KOg2CWFj+QB45CO01sj+kKQhQN7A1wfMVvRAxvP Z0qoPOabiUy3oYpBc/PV3RwHex8Z2UVlJSRELXG8bysMA7KxU8DyuyykE2hDQERycSHlTQ Ntm3Ci2Aqs33V4nfpihYCrBjrdVtA2g= Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-460-Ffs20lzvPCuLceU8QmO0ew-1; Wed, 22 Sep 2021 17:34:55 -0400 X-MC-Unique: Ffs20lzvPCuLceU8QmO0ew-1 Received: by mail-wr1-f72.google.com with SMTP id e1-20020adfa741000000b0015e424fdd01so3371205wrd.11 for ; Wed, 22 Sep 2021 14:34:54 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=tkHP6mmjG7SBJfcpCC261TiUWmXihHKnsMoMGcToTiQ=; b=VNh4jPj2CKGkc2Tx6cKuONL1EdMXdpvwqg2BFBBfBSN3oWLWhCEqMkZLqMDXBLvzof ej7Qu4LHOPNIQ7yOZ4wL4sVrhE9ITaRZT0tbuIILwnO5KKZ8uIGpWk6KXetjF6Kw+qc5 pVcnrk6HDfH4bxS0rrlJQnZsC0/eOPh8LzI6RBcyRdasuvaZ/tTxwg/BMZ+dLDwx6CpU E5iylrctsyqxjSLxV5Mg+AnQyJtXVphJUxwhyJ1hbFyNE16PR4f0TWUAN1qzXiSwjC+U xWu9wjQWjsW8HTX4ej/tcAcggx+Aablq5eBed9xy6R9152J6iCMiqOtng0VN/V4Z166T 11Tw== X-Gm-Message-State: AOAM532z9aVUtcwVBHfrLyAspTcLs4YFmksW6dq/YgWcAognUD7XmEV6 Llro6O7IwOUuf3mUNAlO1lg8WYg2Avk/aiWOYWwq0Y0p7dcEUrb2ZlMDCduweZNGxCgZ0lIupwR 5hPVmCJl5VC5CYky370g5FrdO X-Received: by 2002:a1c:4645:: with SMTP id t66mr1125847wma.130.1632346493722; Wed, 22 Sep 2021 14:34:53 -0700 (PDT) X-Received: by 2002:a1c:4645:: with SMTP id t66mr1125833wma.130.1632346493521; Wed, 22 Sep 2021 14:34:53 -0700 (PDT) Received: from krava ([83.240.63.48]) by smtp.gmail.com with ESMTPSA id n186sm7105048wme.31.2021.09.22.14.34.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 22 Sep 2021 14:34:53 -0700 (PDT) Date: Wed, 22 Sep 2021 23:34:51 +0200 From: Jiri Olsa To: Shunsuke Nakamura Cc: peterz@infradead.org, mingo@redhat.com, acme@kernel.org, mark.rutland@arm.com, alexander.shishkin@linux.intel.com, namhyung@kernel.org, linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org Subject: Re: [PATCH v2 1/2] libperf: Add processing to scale the counters obtained during the read() system call when multiplexing Message-ID: References: <20210922101627.3396398-1-nakamura.shun@fujitsu.com> <20210922101627.3396398-2-nakamura.shun@fujitsu.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210922101627.3396398-2-nakamura.shun@fujitsu.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Sep 22, 2021 at 07:16:26PM +0900, Shunsuke Nakamura wrote: > 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); > + } so I think perf stat expect raw values in there and does the scaling by itself, please check following code: read_counters read_affinity_counters read_counter_cpu read_single_counter evsel__read_counter perf_stat_process_counter process_counter_maps process_counter_values perf_counts_values__scale perhaps we could export perf_counts_values__scale if it'd be any help jirka > + > return 0; > } > > -- > 2.27.0 >