Received: by 2002:a05:6a10:d5a5:0:0:0:0 with SMTP id gn37csp4755934pxb; Tue, 5 Oct 2021 09:39:09 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyYErNM+ZONFXChRZydxldAjxm3CyUzYLN5TbNpKZY53YbLzB4b8Sf738FF5Y6JryyvAyfa X-Received: by 2002:a17:90a:c89:: with SMTP id v9mr4885417pja.71.1633451949104; Tue, 05 Oct 2021 09:39:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1633451949; cv=none; d=google.com; s=arc-20160816; b=Nh8TDw4U3Vb66bcxkXkkqMx4SqZ8Tyxq6S9Nr0GVGrVbksjq1FVDL04BzDx5liI7f0 jBRb5Mfh+gdTkRuYUJO/HsHlbp+Xn77KQvMkLOYVMr0XGQ3HLIcTXH8Yw/u3MPA0Y/Xq Vj2dpTlhnKLWsscdoRHYwYDZAZy5lVNDQz+Bova/TIZfkLK2qgZx6cK7Dpz7x79+sSEQ WTysIyguEpLNSBtL5cUhu+b34LYN3vwUETUtpYzcX6dhJS5NjIpNHqc/9ib+h22s8/6I I7EWoL130CXoZ9woRx+9UNMMZxkP1M+SGGastN4UMry6tJxftrKm/i21lvGtvDLJGOmt TtJA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=hkQPvValwTNxV//o+LCDJw18mMStmuvW+RhnpnrOj10=; b=DtMyOBMmGCBgcq1X9W0pJWfGeoxFrntGqJtj0Kwwg///Ddw75JUfniOh/79cSBJ5jn VgZY0EWXGddzoB5o480oD3RS1TtbiU2hUJJEqZcyZzPaYr/Gr5fvCXkPVoa/9a/vABqY SfkeklUJ1lL4ufsw85r+PAn+gmlwnuojrqiThWvAMebM6qpzYM7QeUJxoS+fkGSfLcS+ hltX9hQsgpyKYeqMkte7kgnFZ1/KcJFErwhC/EynFYwieKBmB4FqnEO0mu7xO/IDfUz7 E8NnUi6zRKHy+6MOMwNGRgPoH4TK4qXiL8dfOFiyhyNeMpEaCAadA+WVgWZ6hWrZBqpZ jTvA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=g4ehtVhC; 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=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id t10si25025682pgu.140.2021.10.05.09.38.52; Tue, 05 Oct 2021 09:39:09 -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=@kernel.org header.s=k20201202 header.b=g4ehtVhC; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236255AbhJEQiW (ORCPT + 99 others); Tue, 5 Oct 2021 12:38:22 -0400 Received: from mail.kernel.org ([198.145.29.99]:39260 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233896AbhJEQiW (ORCPT ); Tue, 5 Oct 2021 12:38:22 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 4213961501; Tue, 5 Oct 2021 16:36:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1633451791; bh=TE1byajMD4BEXyGVyWtNuptLh2myMAefZKocS/zdfIw=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=g4ehtVhCpXI/h0RcaVu7/cmGWYbaHpAuz4q0prTAJg+q8HEnovvV2EKJNNs1dgUdw fe7/KOJYfcOc4Qmv1KAMvS9cPfrD6KCQFW/bZRIyr4NiwpCa8Zm1QhcIpzR1Sw/pB+ 01WkZQinTAkqj3rWOWI0O8jJTWkBePImbHJ6kQnxoDqPpvwfTKfygrliV68HD6os2C PNlCGgYqozgP8PCU59i9ocbqaHlwFE22+fFb+mKgMqqoiNsQsCiYpULRe2Cs9eemB9 eAubFYgjPmAOPJBbf1AoAoz1B/m1T2FzfoejA8JPcnpBfO/83nE+c+WypdDXYj1M5q OSgWPcbkYFe2w== Received: by mail-ed1-f45.google.com with SMTP id z1so1093478edb.8; Tue, 05 Oct 2021 09:36:31 -0700 (PDT) X-Gm-Message-State: AOAM5300hjr+xHOKnsVtYs9QW/8dX4e9WbVmx6G4c83sfNLpi8peP5Y9 0m5tcFCZkr9i5av330/jLTGYIS/E8A4+NGwZSw== X-Received: by 2002:a50:a402:: with SMTP id u2mr6088428edb.164.1633451789787; Tue, 05 Oct 2021 09:36:29 -0700 (PDT) MIME-Version: 1.0 References: <20210922101627.3396398-1-nakamura.shun@fujitsu.com> <20210922101627.3396398-2-nakamura.shun@fujitsu.com> In-Reply-To: From: Rob Herring Date: Tue, 5 Oct 2021 11:36:18 -0500 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v2 1/2] libperf: Add processing to scale the counters obtained during the read() system call when multiplexing To: "nakamura.shun@fujitsu.com" Cc: Jiri Olsa , "peterz@infradead.org" , "mingo@redhat.com" , "acme@kernel.org" , "mark.rutland@arm.com" , "alexander.shishkin@linux.intel.com" , "namhyung@kernel.org" , "irogers@google.com" , "linux-perf-users@vger.kernel.org" , "linux-kernel@vger.kernel.org" Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Sep 28, 2021 at 7:41 AM nakamura.shun@fujitsu.com wrote: > > Hi Jirka > > > 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 > > Thank you for your comment. > > The purpose of this patch is to unify the counters obtained with > perf_evsel__read() to scaled or unscaled values. > > perf_evsel__read() gets counter by perf_mmap__read_self() if RDPMC is > available, else gets by readn(). In current implementation, caller > gets scaled counter if goes through RDPMC path, otherwise gets unscaled > counter via readn() path. > > However caller cannnot know which path were taken. > > If caller expects a raw value, I think the RDPMC path should also > return an unscaled counter. > > diff --git a/tools/lib/perf/mmap.c b/tools/lib/perf/mmap.c > index c89dfa5..aaa4579 100644 > --- a/tools/lib/perf/mmap.c > +++ b/tools/lib/perf/mmap.c > @@ -353,8 +353,6 @@ int perf_mmap__read_self(struct perf_mmap *map, struct perf_counts_values *count > count->ena += delta; > if (idx) > count->run += delta; > - > - cnt = mul_u64_u64_div64(cnt, count->ena, count->run); > } > > count->val = cnt; > > Rob, do you have any comments? Submit a proper patch with the above. Rob