summaryrefslogtreecommitdiffstats
path: root/tools/perf
diff options
context:
space:
mode:
authorAdrian Hunter <adrian.hunter@intel.com>2019-06-04 15:00:12 +0200
committerArnaldo Carvalho de Melo <acme@redhat.com>2019-06-10 21:20:12 +0200
commitb16bfeb3db1b50273e95f539953c337be759500d (patch)
tree50377f501e7ee9cacd12fdeea9ba7844c4d52137 /tools/perf
parentperf time-utils: Factor out set_percent_time() (diff)
downloadlinux-b16bfeb3db1b50273e95f539953c337be759500d.tar.xz
linux-b16bfeb3db1b50273e95f539953c337be759500d.zip
perf time-utils: Prevent percentage time range overlap
Prevent percentage time range overlap. This is only a 1 nanosecond change but makes the results more logical e.g. a sample cannot be in both the first 10% and the second 20%. Note, there is a later patch that adds a test for time-utils. Signed-off-by: Adrian Hunter <adrian.hunter@intel.com> Cc: Jin Yao <yao.jin@linux.intel.com> Cc: Jiri Olsa <jolsa@redhat.com> Link: http://lkml.kernel.org/r/20190604130017.31207-15-adrian.hunter@intel.com Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf')
-rw-r--r--tools/perf/util/time-utils.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/tools/perf/util/time-utils.c b/tools/perf/util/time-utils.c
index 69441faab3d0..3e87c21c293c 100644
--- a/tools/perf/util/time-utils.c
+++ b/tools/perf/util/time-utils.c
@@ -148,6 +148,9 @@ static int set_percent_time(struct perf_time_interval *ptime, double start_pcnt,
ptime->start = start + round(start_pcnt * total);
ptime->end = start + round(end_pcnt * total);
+ if (ptime->end > ptime->start && ptime->end != end)
+ ptime->end -= 1;
+
return 0;
}