Skip to content

Commit 0c58244

Browse files
olsajiriacmel
authored andcommitted
perf record: Add switch-output size warning
Adding switch-output size warning if the requested size of lower than the wakeup ring buffer size. $ perf record --switch-output=1K ls WARNING: switch-output data size lower than wakeup kernel buffer size (258K) expect bigger perf.data sizes ... Signed-off-by: Jiri Olsa <[email protected]> Suggested-and-Tested-by: Arnaldo Carvalho de Melo <[email protected]> Cc: David Ahern <[email protected]> Cc: Namhyung Kim <[email protected]> Cc: Peter Zijlstra <[email protected]> Cc: Wang Nan <[email protected]> Link: http://lkml.kernel.org/r/[email protected] Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
1 parent dc0c612 commit 0c58244

File tree

3 files changed

+24
-1
lines changed

3 files changed

+24
-1
lines changed

tools/perf/builtin-record.c

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1377,6 +1377,23 @@ static int record__parse_mmap_pages(const struct option *opt,
13771377
return ret;
13781378
}
13791379

1380+
static void switch_output_size_warn(struct record *rec)
1381+
{
1382+
u64 wakeup_size = perf_evlist__mmap_size(rec->opts.mmap_pages);
1383+
struct switch_output *s = &rec->switch_output;
1384+
1385+
wakeup_size /= 2;
1386+
1387+
if (s->size < wakeup_size) {
1388+
char buf[100];
1389+
1390+
unit_number__scnprintf(buf, sizeof(buf), wakeup_size);
1391+
pr_warning("WARNING: switch-output data size lower than "
1392+
"wakeup kernel buffer size (%s) "
1393+
"expect bigger perf.data sizes\n", buf);
1394+
}
1395+
}
1396+
13801397
static int switch_output_setup(struct record *rec)
13811398
{
13821399
struct switch_output *s = &rec->switch_output;
@@ -1410,6 +1427,10 @@ static int switch_output_setup(struct record *rec)
14101427
enabled:
14111428
rec->timestamp_filename = true;
14121429
s->enabled = true;
1430+
1431+
if (s->size && !rec->opts.no_buffering)
1432+
switch_output_size_warn(rec);
1433+
14131434
return 0;
14141435
}
14151436

tools/perf/util/evlist.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1184,7 +1184,7 @@ unsigned long perf_event_mlock_kb_in_pages(void)
11841184
return pages;
11851185
}
11861186

1187-
static size_t perf_evlist__mmap_size(unsigned long pages)
1187+
size_t perf_evlist__mmap_size(unsigned long pages)
11881188
{
11891189
if (pages == UINT_MAX)
11901190
pages = perf_event_mlock_kb_in_pages();

tools/perf/util/evlist.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,8 @@ int perf_evlist__mmap(struct perf_evlist *evlist, unsigned int pages,
218218
bool overwrite);
219219
void perf_evlist__munmap(struct perf_evlist *evlist);
220220

221+
size_t perf_evlist__mmap_size(unsigned long pages);
222+
221223
void perf_evlist__disable(struct perf_evlist *evlist);
222224
void perf_evlist__enable(struct perf_evlist *evlist);
223225
void perf_evlist__toggle_enable(struct perf_evlist *evlist);

0 commit comments

Comments
 (0)