linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Arnaldo Carvalho de Melo <acme@kernel.org>
To: Ingo Molnar <mingo@kernel.org>
Cc: linux-kernel@vger.kernel.org, Jiri Olsa <jolsa@kernel.org>,
	David Ahern <dsahern@gmail.com>,
	Namhyung Kim <namhyung@kernel.org>,
	Peter Zijlstra <a.p.zijlstra@chello.nl>,
	Wang Nan <wangnan0@huawei.com>,
	Arnaldo Carvalho de Melo <acme@redhat.com>
Subject: [PATCH 11/13] perf record: Add switch-output size warning
Date: Wed, 11 Jan 2017 17:22:09 -0300	[thread overview]
Message-ID: <20170111202211.32137-12-acme@kernel.org> (raw)
In-Reply-To: <20170111202211.32137-1-acme@kernel.org>

From: Jiri Olsa <jolsa@kernel.org>

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 | 21 +++++++++++++++++++++
 tools/perf/util/evlist.c    |  2 +-
 tools/perf/util/evlist.h    |  2 ++
 3 files changed, 24 insertions(+), 1 deletion(-)

diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c
index 3fa64492ee62..93319e1be3ac 100644
--- a/tools/perf/builtin-record.c
+++ b/tools/perf/builtin-record.c
@@ -1377,6 +1377,23 @@ static int record__parse_mmap_pages(const struct option *opt,
 	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;
 }
 
diff --git a/tools/perf/util/evlist.c b/tools/perf/util/evlist.c
index dc4df3d2660e..b601f2814a30 100644
--- a/tools/perf/util/evlist.c
+++ b/tools/perf/util/evlist.c
@@ -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();
diff --git a/tools/perf/util/evlist.h b/tools/perf/util/evlist.h
index 4fd034f22d2f..389b9ccdf8c7 100644
--- a/tools/perf/util/evlist.h
+++ b/tools/perf/util/evlist.h
@@ -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);
-- 
2.9.3

  parent reply	other threads:[~2017-01-11 20:23 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-01-11 20:21 [GIT PULL 00/13] perf/core improvements and fixes Arnaldo Carvalho de Melo
2017-01-11 20:21 ` [PATCH 01/13] perf jvmti: Create libdir directory before installing libperf-jvmti.so Arnaldo Carvalho de Melo
2017-01-11 20:22 ` [PATCH 02/13] tools lib subcmd: Add missing linux/kernel.h include to subcmd.h Arnaldo Carvalho de Melo
2017-01-11 20:22 ` [PATCH 03/13] perf machine: Add a kallsyms loading constructor Arnaldo Carvalho de Melo
2017-01-11 20:22 ` [PATCH 04/13] perf kallsyms: Introduce tool to look for extended symbol information on the running kernel Arnaldo Carvalho de Melo
2017-01-11 20:22 ` [PATCH 05/13] perf trace: Allow specifying list of syscalls and events in -e/--expr/--event Arnaldo Carvalho de Melo
2017-01-11 20:22 ` [PATCH 06/13] perf evlist: Fix typo in perf_evlist__start_workload() Arnaldo Carvalho de Melo
2017-01-11 20:22 ` [PATCH 07/13] perf tools: Add unit_number__scnprintf function Arnaldo Carvalho de Melo
2017-01-11 20:22 ` [PATCH 08/13] perf record: Add struct switch_output Arnaldo Carvalho de Melo
2017-01-11 20:22 ` [PATCH 09/13] perf record: Change switch-output option to take optional argument Arnaldo Carvalho de Melo
2017-01-11 20:22 ` [PATCH 10/13] perf record: Add switch-output size option argument Arnaldo Carvalho de Melo
2017-01-11 20:22 ` Arnaldo Carvalho de Melo [this message]
2017-01-11 20:22 ` [PATCH 12/13] perf record: Add switch-output time " Arnaldo Carvalho de Melo
2017-01-11 20:22 ` [PATCH 13/13] tools: Sync x86's vmx.h with the kernel Arnaldo Carvalho de Melo
2017-01-12  8:25 ` [GIT PULL 00/13] perf/core improvements and fixes Ingo Molnar

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170111202211.32137-12-acme@kernel.org \
    --to=acme@kernel.org \
    --cc=a.p.zijlstra@chello.nl \
    --cc=acme@redhat.com \
    --cc=dsahern@gmail.com \
    --cc=jolsa@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=namhyung@kernel.org \
    --cc=wangnan0@huawei.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).