linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Namhyung Kim <namhyung@kernel.org>
To: Arnaldo Carvalho de Melo <acme@kernel.org>
Cc: Ingo Molnar <mingo@kernel.org>,
	Peter Zijlstra <a.p.zijlstra@chello.nl>,
	Jiri Olsa <jolsa@redhat.com>, LKML <linux-kernel@vger.kernel.org>,
	David Ahern <dsahern@gmail.com>, Joonsoo Kim <js1304@gmail.com>,
	Minchan Kim <minchan@kernel.org>,
	Pekka Enberg <penberg@kernel.org>,
	linux-mm@kvack.org, Taeung Song <treeze.taeung@gmail.com>
Subject: [PATCH 5/6] perf kmem: Add kmem.default config option
Date: Tue, 21 Apr 2015 13:55:06 +0900	[thread overview]
Message-ID: <1429592107-1807-6-git-send-email-namhyung@kernel.org> (raw)
In-Reply-To: <1429592107-1807-1-git-send-email-namhyung@kernel.org>

Currently perf kmem command will select --slab if neither --slab nor
--page is given for backward compatibility.  Add kmem.default config
option to select the default value ('page' or 'slab').

  # cat ~/.perfconfig
  [kmem]
  	default = page

  # perf kmem stat

  SUMMARY (page allocator)
  ========================
  Total allocation requests     :            1,518   [            6,096 KB ]
  Total free requests           :            1,431   [            5,748 KB ]

  Total alloc+freed requests    :            1,330   [            5,344 KB ]
  Total alloc-only requests     :              188   [              752 KB ]
  Total free-only requests      :              101   [              404 KB ]

  Total allocation failures     :                0   [                0 KB ]
  ...

Acked-by: Pekka Enberg <penberg@kernel.org>
Cc: Taeung Song <treeze.taeung@gmail.com>
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
---
 tools/perf/builtin-kmem.c | 32 +++++++++++++++++++++++++++++---
 1 file changed, 29 insertions(+), 3 deletions(-)

diff --git a/tools/perf/builtin-kmem.c b/tools/perf/builtin-kmem.c
index 1c668953c7ec..828b7284e547 100644
--- a/tools/perf/builtin-kmem.c
+++ b/tools/perf/builtin-kmem.c
@@ -28,6 +28,10 @@ static int	kmem_slab;
 static int	kmem_page;
 
 static long	kmem_page_size;
+static enum {
+	KMEM_SLAB,
+	KMEM_PAGE,
+} kmem_default = KMEM_SLAB;  /* for backward compatibility */
 
 struct alloc_stat;
 typedef int (*sort_fn_t)(void *, void *);
@@ -1710,7 +1714,8 @@ static int parse_sort_opt(const struct option *opt __maybe_unused,
 	if (!arg)
 		return -1;
 
-	if (kmem_page > kmem_slab) {
+	if (kmem_page > kmem_slab ||
+	    (kmem_page == 0 && kmem_slab == 0 && kmem_default == KMEM_PAGE)) {
 		if (caller_flag > alloc_flag)
 			return setup_page_sorting(&page_caller_sort, arg);
 		else
@@ -1826,6 +1831,22 @@ static int __cmd_record(int argc, const char **argv)
 	return cmd_record(i, rec_argv, NULL);
 }
 
+static int kmem_config(const char *var, const char *value, void *cb)
+{
+	if (!strcmp(var, "kmem.default")) {
+		if (!strcmp(value, "slab"))
+			kmem_default = KMEM_SLAB;
+		else if (!strcmp(value, "page"))
+			kmem_default = KMEM_PAGE;
+		else
+			pr_err("invalid default value ('slab' or 'page' required): %s\n",
+			       value);
+		return 0;
+	}
+
+	return perf_default_config(var, value, cb);
+}
+
 int cmd_kmem(int argc, const char **argv, const char *prefix __maybe_unused)
 {
 	const char * const default_slab_sort = "frag,hit,bytes";
@@ -1862,14 +1883,19 @@ int cmd_kmem(int argc, const char **argv, const char *prefix __maybe_unused)
 	struct perf_session *session;
 	int ret = -1;
 
+	perf_config(kmem_config, NULL);
 	argc = parse_options_subcommand(argc, argv, kmem_options,
 					kmem_subcommands, kmem_usage, 0);
 
 	if (!argc)
 		usage_with_options(kmem_usage, kmem_options);
 
-	if (kmem_slab == 0 && kmem_page == 0)
-		kmem_slab = 1;  /* for backward compatibility */
+	if (kmem_slab == 0 && kmem_page == 0) {
+		if (kmem_default == KMEM_SLAB)
+			kmem_slab = 1;
+		else
+			kmem_page = 1;
+	}
 
 	if (!strncmp(argv[0], "rec", 3)) {
 		symbol__init(NULL);
-- 
2.3.4

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

  parent reply	other threads:[~2015-04-21  5:00 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-04-21  4:55 [PATCHSET 0/6] perf kmem: Implement page allocation analysis (v8) Namhyung Kim
2015-04-21  4:55 ` [PATCH 1/6] perf kmem: Implement stat --page --caller Namhyung Kim
2015-05-04 15:38   ` Arnaldo Carvalho de Melo
2015-05-04 16:11     ` Arnaldo Carvalho de Melo
2015-04-21  4:55 ` [PATCH 2/6] perf kmem: Support sort keys on page analysis Namhyung Kim
2015-04-21  4:55 ` [PATCH 3/6] perf kmem: Add --live option for current allocation stat Namhyung Kim
2015-04-21  4:55 ` [PATCH 4/6] perf kmem: Print gfp flags in human readable string Namhyung Kim
2015-05-11 14:35   ` Arnaldo Carvalho de Melo
2015-05-11 14:41     ` Arnaldo Carvalho de Melo
2015-05-11 15:26       ` Namhyung Kim
2015-04-21  4:55 ` Namhyung Kim [this message]
2015-04-21  4:55 ` [PATCH 6/6] perf kmem: Show warning when trying to run stat without record Namhyung Kim
2015-05-04 16:15   ` Arnaldo Carvalho de Melo
2015-05-05  0:58     ` [PATCH v2] " Namhyung Kim
2015-05-05 14:07       ` Arnaldo Carvalho de Melo
2015-05-05 14:16         ` Pekka Enberg
2015-05-05 14:52           ` [PATCH v3 6/6] " Namhyung Kim
2015-05-05 15:01             ` Arnaldo Carvalho de Melo
2015-05-02 14:55 ` [PATCHSET 0/6] perf kmem: Implement page allocation analysis (v8) Namhyung Kim
  -- strict thread matches above, loose matches on Subject: below --
2015-04-14  2:52 [PATCHSET 0/6] perf kmem: Implement page allocation analysis (v7) Namhyung Kim
2015-04-14  2:52 ` [PATCH 5/6] perf kmem: Add kmem.default config option Namhyung Kim

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=1429592107-1807-6-git-send-email-namhyung@kernel.org \
    --to=namhyung@kernel.org \
    --cc=a.p.zijlstra@chello.nl \
    --cc=acme@kernel.org \
    --cc=dsahern@gmail.com \
    --cc=jolsa@redhat.com \
    --cc=js1304@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=minchan@kernel.org \
    --cc=mingo@kernel.org \
    --cc=penberg@kernel.org \
    --cc=treeze.taeung@gmail.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).