linux-perf-users.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jiri Olsa <jolsa@redhat.com>
To: Shunsuke Nakamura <nakamura.shun@fujitsu.com>
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
Date: Wed, 22 Sep 2021 23:34:51 +0200	[thread overview]
Message-ID: <YUuhe7e0J0PSea+b@krava> (raw)
In-Reply-To: <20210922101627.3396398-2-nakamura.shun@fujitsu.com>

On Wed, Sep 22, 2021 at 07:16:26PM +0900, Shunsuke Nakamura wrote:
> From: nakamura shunsuke <nakamura.shun@fujitsu.com>
> 
> 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 <nakamura.shun@fujitsu.com>
> ---
>  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 <sys/ioctl.h>
>  #include <sys/mman.h>
>  #include <asm/bug.h>
> +#include <linux/math64.h>
>  
>  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
> 


  reply	other threads:[~2021-09-22 21:34 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-22 10:16 [PATCH v2 0/2] libperf: Add support for scaling counters obtained from the read() system call during multiplexing Shunsuke Nakamura
2021-09-22 10:16 ` [PATCH v2 1/2] libperf: Add processing to scale the counters obtained during the read() system call when multiplexing Shunsuke Nakamura
2021-09-22 21:34   ` Jiri Olsa [this message]
2021-09-28  9:53     ` nakamura.shun
2021-10-05 16:36       ` Rob Herring
2021-10-19  4:59         ` nakamura.shun
2021-10-07 17:17       ` Jiri Olsa
2021-10-19  5:00         ` nakamura.shun
2021-11-08  0:49           ` nakamura.shun
2021-11-14 16:16             ` Jiri Olsa
2021-09-22 10:16 ` [PATCH v2 2/2] libperf tests: Add test_stat_multiplexing test Shunsuke Nakamura
2021-10-08 19:11   ` Arnaldo Carvalho de Melo

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=YUuhe7e0J0PSea+b@krava \
    --to=jolsa@redhat.com \
    --cc=acme@kernel.org \
    --cc=alexander.shishkin@linux.intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-perf-users@vger.kernel.org \
    --cc=mark.rutland@arm.com \
    --cc=mingo@redhat.com \
    --cc=nakamura.shun@fujitsu.com \
    --cc=namhyung@kernel.org \
    --cc=peterz@infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).