lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Thu, 15 Nov 2018 15:17:45 +0100
From:   Jiri Olsa <jolsa@...hat.com>
To:     Ravi Bangoria <ravi.bangoria@...ux.ibm.com>
Cc:     acme@...nel.org, alexander.shishkin@...ux.intel.com,
        namhyung@...nel.org, yao.jin@...ux.intel.com,
        linux-kernel@...r.kernel.org, yuzhoujian@...ichuxing.com,
        tmricht@...ux.vnet.ibm.com, anton@...ba.org
Subject: Re: [RFC 2/2] perf stat: Fix shadow stats for clock events

On Thu, Nov 15, 2018 at 03:25:33PM +0530, Ravi Bangoria wrote:
> Commit 0aa802a79469 ("perf stat: Get rid of extra clock display
> function") introduced scale and unit for clock events. Thus,
> perf_stat__update_shadow_stats() now saves scaled values of
> clock events in msecs, instead of original nsecs. But while
> calculating values of shadow stats we still consider clock
> event values in nsecs. This results in a wrong shadow stat
> values. Ex,
> 
>   # ./perf stat -e task-clock,cycles ls
>     <SNIP>
>               2.62 msec task-clock:u    #    0.624 CPUs utilized
>          2,501,536      cycles:u        # 1250768.000 GHz
> 
> Fix this by considering clock events's saved stats in msecs:
> 
>   # ./perf stat -e task-clock,cycles ls
>     <SNIP>
>               2.42 msec task-clock:u    #    0.754 CPUs utilized
>          2,338,747      cycles:u        #    1.169 GHz
> 
> Note:
> The problem with this approach is, we are losing fractional part
> while converting nsecs to msecs. This results in a sightly different
> values of shadow stats.

yea, could we just leave the NSEC instead? like below

jirka


---
diff --git a/tools/perf/util/stat-shadow.c b/tools/perf/util/stat-shadow.c
index f4bad808bdd9..da8857df238e 100644
--- a/tools/perf/util/stat-shadow.c
+++ b/tools/perf/util/stat-shadow.c
@@ -209,11 +209,12 @@ void perf_stat__update_shadow_stats(struct perf_evsel *counter, u64 count,
 				    int cpu, struct runtime_stat *st)
 {
 	int ctx = evsel_context(counter);
+	u64 count_ns = count;
 
 	count *= counter->scale;
 
 	if (perf_evsel__is_clock(counter))
-		update_runtime_stat(st, STAT_NSECS, 0, cpu, count);
+		update_runtime_stat(st, STAT_NSECS, 0, cpu, count_ns);
 	else if (perf_evsel__match(counter, HARDWARE, HW_CPU_CYCLES))
 		update_runtime_stat(st, STAT_CYCLES, ctx, cpu, count);
 	else if (perf_stat_evsel__is(counter, CYCLES_IN_TX))

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ