perf record: Add switch-output size warning
authorJiri Olsa <jolsa@kernel.org>
Mon, 9 Jan 2017 09:51:59 +0000 (10:51 +0100)
committerArnaldo Carvalho de Melo <acme@redhat.com>
Wed, 11 Jan 2017 19:48:02 +0000 (16:48 -0300)
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 <jolsa@kernel.org>
Suggested-and-Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Wang Nan <wangnan0@huawei.com>
Link: http://lkml.kernel.org/r/1483955520-29063-6-git-send-email-jolsa@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
tools/perf/builtin-record.c
tools/perf/util/evlist.c
tools/perf/util/evlist.h

index 3fa64492ee62c65e716f5e2d0bb2c88fbb4f1f7f..93319e1be3ac131725f5db86dfe054d78972d788 100644 (file)
@@ -1377,6 +1377,23 @@ out_free:
        return ret;
 }
 
+static void switch_output_size_warn(struct record *rec)
+{
+       u64 wakeup_size = perf_evlist__mmap_size(rec->opts.mmap_pages);
+       struct switch_output *s = &rec->switch_output;
+
+       wakeup_size /= 2;
+
+       if (s->size < wakeup_size) {
+               char buf[100];
+
+               unit_number__scnprintf(buf, sizeof(buf), wakeup_size);
+               pr_warning("WARNING: switch-output data size lower than "
+                          "wakeup kernel buffer size (%s) "
+                          "expect bigger perf.data sizes\n", buf);
+       }
+}
+
 static int switch_output_setup(struct record *rec)
 {
        struct switch_output *s = &rec->switch_output;
@@ -1410,6 +1427,10 @@ static int switch_output_setup(struct record *rec)
 enabled:
        rec->timestamp_filename = true;
        s->enabled              = true;
+
+       if (s->size && !rec->opts.no_buffering)
+               switch_output_size_warn(rec);
+
        return 0;
 }
 
index dc4df3d2660e6d085c27ba28b19a0ca20494d82d..b601f2814a30e9d7d2b6f689b5e495659c34e600 100644 (file)
@@ -1184,7 +1184,7 @@ unsigned long perf_event_mlock_kb_in_pages(void)
        return pages;
 }
 
-static size_t perf_evlist__mmap_size(unsigned long pages)
+size_t perf_evlist__mmap_size(unsigned long pages)
 {
        if (pages == UINT_MAX)
                pages = perf_event_mlock_kb_in_pages();
index 4fd034f22d2fc2c2bd6b1050a42447313b9207cb..389b9ccdf8c75db39d8e2163d6909a4db01e65a8 100644 (file)
@@ -218,6 +218,8 @@ int perf_evlist__mmap(struct perf_evlist *evlist, unsigned int pages,
                      bool overwrite);
 void perf_evlist__munmap(struct perf_evlist *evlist);
 
+size_t perf_evlist__mmap_size(unsigned long pages);
+
 void perf_evlist__disable(struct perf_evlist *evlist);
 void perf_evlist__enable(struct perf_evlist *evlist);
 void perf_evlist__toggle_enable(struct perf_evlist *evlist);