Skip to content

Commit cc2ef58

Browse files
Jin Yaoacmel
authored andcommitted
perf script: Remove the time slices number limitation
Previously it was only allowed to use at most 10 time slices in 'perf script --time'. This patch removes this limitation. For example, following command line is OK (12 time slices) perf script --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: 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 0a3cc3a commit cc2ef58

File tree

2 files changed

+17
-9
lines changed

2 files changed

+17
-9
lines changed

tools/perf/Documentation/perf-script.txt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -351,19 +351,19 @@ include::itrace.txt[]
351351
to end of file.
352352

353353
Also support time percent with multipe time range. Time string is
354-
'a%/n,b%/m,...' or 'a%-b%,c%-%d,...'. The maximum number of slices is 10.
354+
'a%/n,b%/m,...' or 'a%-b%,c%-%d,...'.
355355

356356
For example:
357-
Select the second 10% time slice
357+
Select the second 10% time slice:
358358
perf script --time 10%/2
359359

360-
Select from 0% to 10% time slice
360+
Select from 0% to 10% time slice:
361361
perf script --time 0%-10%
362362

363-
Select the first and second 10% time slices
363+
Select the first and second 10% time slices:
364364
perf script --time 10%/1,10%/2
365365

366-
Select from 0% to 10% and 30% to 40% slices
366+
Select from 0% to 10% and 30% to 40% slices:
367367
perf script --time 0%-10%,30%-40%
368368

369369
--max-blocks::

tools/perf/builtin-script.c

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1480,8 +1480,6 @@ static int perf_sample__fprintf_synth(struct perf_sample *sample,
14801480
return 0;
14811481
}
14821482

1483-
#define PTIME_RANGE_MAX 10
1484-
14851483
struct perf_script {
14861484
struct perf_tool tool;
14871485
struct perf_session *session;
@@ -1496,7 +1494,8 @@ struct perf_script {
14961494
struct thread_map *threads;
14971495
int name_width;
14981496
const char *time_str;
1499-
struct perf_time_interval ptime_range[PTIME_RANGE_MAX];
1497+
struct perf_time_interval *ptime_range;
1498+
int range_size;
15001499
int range_num;
15011500
};
15021501

@@ -3445,6 +3444,13 @@ int cmd_script(int argc, const char **argv)
34453444
if (err < 0)
34463445
goto out_delete;
34473446

3447+
script.ptime_range = perf_time__range_alloc(script.time_str,
3448+
&script.range_size);
3449+
if (!script.ptime_range) {
3450+
err = -ENOMEM;
3451+
goto out_delete;
3452+
}
3453+
34483454
/* needs to be parsed after looking up reference time */
34493455
if (perf_time__parse_str(script.ptime_range, script.time_str) != 0) {
34503456
if (session->evlist->first_sample_time == 0 &&
@@ -3457,7 +3463,7 @@ int cmd_script(int argc, const char **argv)
34573463
}
34583464

34593465
script.range_num = perf_time__percent_parse_str(
3460-
script.ptime_range, PTIME_RANGE_MAX,
3466+
script.ptime_range, script.range_size,
34613467
script.time_str,
34623468
session->evlist->first_sample_time,
34633469
session->evlist->last_sample_time);
@@ -3476,6 +3482,8 @@ int cmd_script(int argc, const char **argv)
34763482
flush_scripting();
34773483

34783484
out_delete:
3485+
zfree(&script.ptime_range);
3486+
34793487
perf_evlist__free_stats(session->evlist);
34803488
perf_session__delete(session);
34813489

0 commit comments

Comments
 (0)