Skip to content

Commit 0a3cc3a

Browse files
Jin Yaoacmel
authored andcommitted
perf report: Remove the time slices number limitation
Previously it was only allowed to use at most 10 time slices in 'perf report --time'. This patch removes this limitation. For example, following command line is OK (12 time slices) perf report --stdio --time 1%/1,1%/2,1%/3,1%/4,1%/5,1%/6,1%/7,1%/8,1%/9,1%/10,1%/11,1%/12 Signed-off-by: Jin Yao <[email protected]> Suggested-by: Arnaldo Carvalho de Melo <[email protected]> Reviewed-by: Jiri Olsa <[email protected]> Cc: Alexander Shishkin <[email protected]> Cc: Andi Kleen <[email protected]> Cc: Jiri Olsa <[email protected]> Cc: Kan Liang <[email protected]> Cc: Peter Zijlstra <[email protected]> Link: http://lkml.kernel.org/r/[email protected] [ No need to check for NULL to call free, use zfree ] Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
1 parent 5a031f8 commit 0a3cc3a

File tree

2 files changed

+17
-7
lines changed

2 files changed

+17
-7
lines changed

tools/perf/Documentation/perf-report.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -403,7 +403,7 @@ OPTIONS
403403
to end of file.
404404

405405
Also support time percent with multiple time range. Time string is
406-
'a%/n,b%/m,...' or 'a%-b%,c%-%d,...'. The maximum number of slices is 10.
406+
'a%/n,b%/m,...' or 'a%-b%,c%-%d,...'.
407407

408408
For example:
409409
Select the second 10% time slice:

tools/perf/builtin-report.c

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,6 @@
5454
#include <unistd.h>
5555
#include <linux/mman.h>
5656

57-
#define PTIME_RANGE_MAX 10
58-
5957
struct report {
6058
struct perf_tool tool;
6159
struct perf_session *session;
@@ -76,7 +74,8 @@ struct report {
7674
const char *cpu_list;
7775
const char *symbol_filter_str;
7876
const char *time_str;
79-
struct perf_time_interval ptime_range[PTIME_RANGE_MAX];
77+
struct perf_time_interval *ptime_range;
78+
int range_size;
8079
int range_num;
8180
float min_percent;
8281
u64 nr_entries;
@@ -1300,24 +1299,33 @@ int cmd_report(int argc, const char **argv)
13001299
if (symbol__init(&session->header.env) < 0)
13011300
goto error;
13021301

1302+
report.ptime_range = perf_time__range_alloc(report.time_str,
1303+
&report.range_size);
1304+
if (!report.ptime_range) {
1305+
ret = -ENOMEM;
1306+
goto error;
1307+
}
1308+
13031309
if (perf_time__parse_str(report.ptime_range, report.time_str) != 0) {
13041310
if (session->evlist->first_sample_time == 0 &&
13051311
session->evlist->last_sample_time == 0) {
13061312
pr_err("HINT: no first/last sample time found in perf data.\n"
13071313
"Please use latest perf binary to execute 'perf record'\n"
13081314
"(if '--buildid-all' is enabled, please set '--timestamp-boundary').\n");
1309-
return -EINVAL;
1315+
ret = -EINVAL;
1316+
goto error;
13101317
}
13111318

13121319
report.range_num = perf_time__percent_parse_str(
1313-
report.ptime_range, PTIME_RANGE_MAX,
1320+
report.ptime_range, report.range_size,
13141321
report.time_str,
13151322
session->evlist->first_sample_time,
13161323
session->evlist->last_sample_time);
13171324

13181325
if (report.range_num < 0) {
13191326
pr_err("Invalid time string\n");
1320-
return -EINVAL;
1327+
ret = -EINVAL;
1328+
goto error;
13211329
}
13221330
} else {
13231331
report.range_num = 1;
@@ -1333,6 +1341,8 @@ int cmd_report(int argc, const char **argv)
13331341
ret = 0;
13341342

13351343
error:
1344+
zfree(&report.ptime_range);
1345+
13361346
perf_session__delete(session);
13371347
return ret;
13381348
}

0 commit comments

Comments
 (0)