Skip to content

Commit dd01b98

Browse files
namhyungacmel
authored andcommitted
perf ftrace: Check min/max latency only with bucket range
It's an optional feature and remains 0 when bucket range is not given. And it makes the histogram goes to the last entry always because any latency (num) is greater than or equal to 0. Before: $ sudo ./perf ftrace latency -a -T do_futex sleep 1 # DURATION | COUNT | GRAPH | 0 - 0 us | 0 | | 1 - 2 us | 0 | | 2 - 4 us | 0 | | 4 - 8 us | 0 | | 8 - 16 us | 0 | | 16 - 32 us | 0 | | 32 - 64 us | 0 | | 64 - 128 us | 0 | | 128 - 256 us | 0 | | 256 - 512 us | 0 | | 512 - 1024 us | 0 | | 1 - 2 ms | 0 | | 2 - 4 ms | 0 | | 4 - 8 ms | 0 | | 8 - 16 ms | 0 | | 16 - 32 ms | 0 | | 32 - 64 ms | 0 | | 64 - 128 ms | 0 | | 128 - 256 ms | 0 | | 256 - 512 ms | 0 | | 512 - 1024 ms | 0 | | 1 - ... s | 1353 | ############################################## | After: $ sudo ./perf ftrace latency -a -T do_futex sleep 1 # DURATION | COUNT | GRAPH | 0 - 0 us | 321 | ########### | 1 - 2 us | 132 | #### | 2 - 4 us | 202 | ####### | 4 - 8 us | 188 | ###### | 8 - 16 us | 16 | | 16 - 32 us | 12 | | 32 - 64 us | 30 | # | 64 - 128 us | 98 | ### | 128 - 256 us | 53 | # | 256 - 512 us | 57 | ## | 512 - 1024 us | 9 | | 1 - 2 ms | 9 | | 2 - 4 ms | 1 | | 4 - 8 ms | 98 | ### | 8 - 16 ms | 5 | | 16 - 32 ms | 7 | | 32 - 64 ms | 32 | # | 64 - 128 ms | 10 | | 128 - 256 ms | 10 | | 256 - 512 ms | 2 | | 512 - 1024 ms | 0 | | 1 - ... s | 0 | | Fixes: 690a052 ("perf ftrace latency: Add --max-latency option") Reviewed-by: Gabriele Monaco <[email protected]> Signed-off-by: Namhyung Kim <[email protected]> Tested-by: Arnaldo Carvalho de Melo <[email protected]> Tested-by: Gabriele Monaco <[email protected] Cc: Adrian Hunter <[email protected]> Cc: Ian Rogers <[email protected]> Cc: Ingo Molnar <[email protected]> Cc: Jiri Olsa <[email protected]> Cc: Kan Liang <[email protected]> Cc: Peter Zijlstra <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
1 parent 74c033b commit dd01b98

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

tools/perf/builtin-ftrace.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -796,8 +796,10 @@ static void make_histogram(struct perf_ftrace *ftrace, int buckets[],
796796
// than the min latency desired.
797797
if (num > 0) // 1st entry: [ 1 unit .. bucket_range units ]
798798
i = num / ftrace->bucket_range + 1;
799+
if (num >= max_latency - min_latency)
800+
i = NUM_BUCKET -1;
799801
}
800-
if (i >= NUM_BUCKET || num >= max_latency - min_latency)
802+
if (i >= NUM_BUCKET)
801803
i = NUM_BUCKET - 1;
802804

803805
num += min_latency;
@@ -1738,7 +1740,7 @@ int cmd_ftrace(int argc, const char **argv)
17381740
ret = -EINVAL;
17391741
goto out_delete_filters;
17401742
}
1741-
if (!ftrace.min_latency) {
1743+
if (ftrace.bucket_range && !ftrace.min_latency) {
17421744
/* default min latency should be the bucket range */
17431745
ftrace.min_latency = ftrace.bucket_range;
17441746
}
@@ -1749,7 +1751,7 @@ int cmd_ftrace(int argc, const char **argv)
17491751
ret = -EINVAL;
17501752
goto out_delete_filters;
17511753
}
1752-
if (!ftrace.max_latency) {
1754+
if (ftrace.bucket_range && !ftrace.max_latency) {
17531755
/* default max latency should depend on bucket range and num_buckets */
17541756
ftrace.max_latency = (NUM_BUCKET - 2) * ftrace.bucket_range +
17551757
ftrace.min_latency;

0 commit comments

Comments
 (0)