public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/2] perf kmem: Show usage if no option is specified
@ 2009-12-10  7:21 Li Zefan
  2009-12-10  7:22 ` [PATCH 2/2] perf tools: Align long options which have no short forms Li Zefan
                   ` (3 more replies)
  0 siblings, 4 replies; 7+ messages in thread
From: Li Zefan @ 2009-12-10  7:21 UTC (permalink / raw)
  To: Ingo Molnar; +Cc: Pekka Enberg, LKML

As Ingo suggested, make "perf kmem" show help information.
"perf kmem stat [--caller] [--alloc] .." will show memory
statistics.

Signed-off-by: Li Zefan <lizf@cn.fujitsu.com>
---
 tools/perf/Documentation/perf-kmem.txt |   13 +++++---
 tools/perf/builtin-kmem.c              |   52 ++++++++++++++++++--------------
 2 files changed, 37 insertions(+), 28 deletions(-)

diff --git a/tools/perf/Documentation/perf-kmem.txt b/tools/perf/Documentation/perf-kmem.txt
index 44b0ce3..eac4d85 100644
--- a/tools/perf/Documentation/perf-kmem.txt
+++ b/tools/perf/Documentation/perf-kmem.txt
@@ -8,16 +8,16 @@ perf-kmem - Tool to trace/measure kernel memory(slab) properties
 SYNOPSIS
 --------
 [verse]
-'perf kmem' {record} [<options>]
+'perf kmem' {record|stat} [<options>]
 
 DESCRIPTION
 -----------
-There's two variants of perf kmem:
+There are two variants of perf kmem:
 
   'perf kmem record <command>' to record the kmem events
   of an arbitrary workload.
 
-  'perf kmem' to report kernel memory statistics.
+  'perf kmem stat' to report kernel memory statistics.
 
 OPTIONS
 -------
@@ -25,8 +25,11 @@ OPTIONS
 --input=<file>::
 	Select the input file (default: perf.data)
 
---stat=<caller|alloc>::
-	Select per callsite or per allocation statistics
+--caller::
+	Show per-callsite statistics
+
+--alloc::
+	Show per-allocation statistics
 
 -s <key[,key2...]>::
 --sort=<key[,key2...]>::
diff --git a/tools/perf/builtin-kmem.c b/tools/perf/builtin-kmem.c
index 7551a5f..1b04787 100644
--- a/tools/perf/builtin-kmem.c
+++ b/tools/perf/builtin-kmem.c
@@ -526,7 +526,7 @@ static int __cmd_kmem(void)
 }
 
 static const char * const kmem_usage[] = {
-	"perf kmem [<options>] {record}",
+	"perf kmem [<options>] {record|stat}",
 	NULL
 };
 
@@ -686,18 +686,17 @@ static int parse_sort_opt(const struct option *opt __used,
 	return 0;
 }
 
-static int parse_stat_opt(const struct option *opt __used,
+static int parse_caller_opt(const struct option *opt __used,
 			  const char *arg, int unset __used)
 {
-	if (!arg)
-		return -1;
+	caller_flag = (alloc_flag + 1);
+	return 0;
+}
 
-	if (strcmp(arg, "alloc") == 0)
-		alloc_flag = (caller_flag + 1);
-	else if (strcmp(arg, "caller") == 0)
-		caller_flag = (alloc_flag + 1);
-	else
-		return -1;
+static int parse_alloc_opt(const struct option *opt __used,
+			  const char *arg, int unset __used)
+{
+	alloc_flag = (caller_flag + 1);
 	return 0;
 }
 
@@ -722,14 +721,17 @@ static int parse_line_opt(const struct option *opt __used,
 static const struct option kmem_options[] = {
 	OPT_STRING('i', "input", &input_name, "file",
 		   "input file name"),
-	OPT_CALLBACK(0, "stat", NULL, "<alloc>|<caller>",
-		     "stat selector, Pass 'alloc' or 'caller'.",
-		     parse_stat_opt),
+	OPT_CALLBACK_NOOPT(0, "caller", NULL, NULL,
+			   "show per-callsite statistics",
+			   parse_caller_opt),
+	OPT_CALLBACK_NOOPT(0, "alloc", NULL, NULL,
+			   "show per-allocation statistics",
+			   parse_alloc_opt),
 	OPT_CALLBACK('s', "sort", NULL, "key[,key2...]",
 		     "sort by keys: ptr, call_site, bytes, hit, pingpong, frag",
 		     parse_sort_opt),
 	OPT_CALLBACK('l', "line", NULL, "num",
-		     "show n lins",
+		     "show n lines",
 		     parse_line_opt),
 	OPT_BOOLEAN(0, "raw-ip", &raw_ip, "show raw ip instead of symbol"),
 	OPT_END()
@@ -773,18 +775,22 @@ int cmd_kmem(int argc, const char **argv, const char *prefix __used)
 
 	argc = parse_options(argc, argv, kmem_options, kmem_usage, 0);
 
-	if (argc && !strncmp(argv[0], "rec", 3))
-		return __cmd_record(argc, argv);
-	else if (argc)
+	if (!argc)
 		usage_with_options(kmem_usage, kmem_options);
 
-	if (list_empty(&caller_sort))
-		setup_sorting(&caller_sort, default_sort_order);
-	if (list_empty(&alloc_sort))
-		setup_sorting(&alloc_sort, default_sort_order);
+	if (!strncmp(argv[0], "rec", 3)) {
+		return __cmd_record(argc, argv);
+	} else if (!strcmp(argv[0], "stat")) {
+		setup_cpunode_map();
+
+		if (list_empty(&caller_sort))
+			setup_sorting(&caller_sort, default_sort_order);
+		if (list_empty(&alloc_sort))
+			setup_sorting(&alloc_sort, default_sort_order);
 
-	setup_cpunode_map();
+		return __cmd_kmem();
+	}
 
-	return __cmd_kmem();
+	return 0;
 }
 
-- 
1.6.3



^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH 2/2] perf tools: Align long options which have no short forms
  2009-12-10  7:21 [PATCH 1/2] perf kmem: Show usage if no option is specified Li Zefan
@ 2009-12-10  7:22 ` Li Zefan
  2009-12-10  7:51   ` [tip:perf/urgent] " tip-bot for Li Zefan
  2009-12-10  7:23 ` [PATCH 1/2] perf kmem: Show usage if no option is specified Pekka Enberg
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 7+ messages in thread
From: Li Zefan @ 2009-12-10  7:22 UTC (permalink / raw)
  To: Ingo Molnar; +Cc: Pekka Enberg, LKML

Before:

$ ./perf kmem
...
    -l, --line <num>      show n lines
    --raw-ip              show raw ip instead of symbol

After:

$ ./perf kmem
...
    -l, --line <num>      show n lines
        --raw-ip          show raw ip instead of symbol

Signed-off-by: Li Zefan <lizf@cn.fujitsu.com>
---
 tools/perf/util/parse-options.c |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)

diff --git a/tools/perf/util/parse-options.c b/tools/perf/util/parse-options.c
index 6d8af48..efebd5b 100644
--- a/tools/perf/util/parse-options.c
+++ b/tools/perf/util/parse-options.c
@@ -430,6 +430,9 @@ int usage_with_options_internal(const char * const *usagestr,
 		pos = fprintf(stderr, "    ");
 		if (opts->short_name)
 			pos += fprintf(stderr, "-%c", opts->short_name);
+		else
+			pos += fprintf(stderr, "    ");
+
 		if (opts->long_name && opts->short_name)
 			pos += fprintf(stderr, ", ");
 		if (opts->long_name)
-- 
1.6.3

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH 1/2] perf kmem: Show usage if no option is specified
  2009-12-10  7:21 [PATCH 1/2] perf kmem: Show usage if no option is specified Li Zefan
  2009-12-10  7:22 ` [PATCH 2/2] perf tools: Align long options which have no short forms Li Zefan
@ 2009-12-10  7:23 ` Pekka Enberg
  2009-12-10  7:30   ` Ingo Molnar
  2009-12-10  7:50 ` [tip:perf/urgent] " tip-bot for Li Zefan
  2009-12-10  7:51 ` [tip:perf/urgent] perf kmem: Fix unused argument build warning tip-bot for Ingo Molnar
  3 siblings, 1 reply; 7+ messages in thread
From: Pekka Enberg @ 2009-12-10  7:23 UTC (permalink / raw)
  To: Li Zefan; +Cc: Ingo Molnar, LKML

Li Zefan kirjoitti:
> As Ingo suggested, make "perf kmem" show help information.
> "perf kmem stat [--caller] [--alloc] .." will show memory
> statistics.
> 
> Signed-off-by: Li Zefan <lizf@cn.fujitsu.com>

Acked-by: Pekka Enberg <penberg@cs.helsinki.fi>

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH 1/2] perf kmem: Show usage if no option is specified
  2009-12-10  7:23 ` [PATCH 1/2] perf kmem: Show usage if no option is specified Pekka Enberg
@ 2009-12-10  7:30   ` Ingo Molnar
  0 siblings, 0 replies; 7+ messages in thread
From: Ingo Molnar @ 2009-12-10  7:30 UTC (permalink / raw)
  To: Pekka Enberg; +Cc: Li Zefan, LKML


* Pekka Enberg <penberg@cs.helsinki.fi> wrote:

> Li Zefan kirjoitti:
> >As Ingo suggested, make "perf kmem" show help information.
> >"perf kmem stat [--caller] [--alloc] .." will show memory
> >statistics.
> >
> >Signed-off-by: Li Zefan <lizf@cn.fujitsu.com>
> 
> Acked-by: Pekka Enberg <penberg@cs.helsinki.fi>

Applied, thanks!

	Ingo

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [tip:perf/urgent] perf kmem: Show usage if no option is specified
  2009-12-10  7:21 [PATCH 1/2] perf kmem: Show usage if no option is specified Li Zefan
  2009-12-10  7:22 ` [PATCH 2/2] perf tools: Align long options which have no short forms Li Zefan
  2009-12-10  7:23 ` [PATCH 1/2] perf kmem: Show usage if no option is specified Pekka Enberg
@ 2009-12-10  7:50 ` tip-bot for Li Zefan
  2009-12-10  7:51 ` [tip:perf/urgent] perf kmem: Fix unused argument build warning tip-bot for Ingo Molnar
  3 siblings, 0 replies; 7+ messages in thread
From: tip-bot for Li Zefan @ 2009-12-10  7:50 UTC (permalink / raw)
  To: linux-tip-commits; +Cc: linux-kernel, hpa, mingo, penberg, lizf, tglx, mingo

Commit-ID:  90b86a9f7dc22e7ff8e8c79ed553860454ff8dd9
Gitweb:     http://git.kernel.org/tip/90b86a9f7dc22e7ff8e8c79ed553860454ff8dd9
Author:     Li Zefan <lizf@cn.fujitsu.com>
AuthorDate: Thu, 10 Dec 2009 15:21:57 +0800
Committer:  Ingo Molnar <mingo@elte.hu>
CommitDate: Thu, 10 Dec 2009 08:30:27 +0100

perf kmem: Show usage if no option is specified

As Ingo suggested, make "perf kmem" show help information.
"perf kmem stat [--caller] [--alloc] .." will show memory
statistics.

Signed-off-by: Li Zefan <lizf@cn.fujitsu.com>
Acked-by: Pekka Enberg <penberg@cs.helsinki.fi>
LKML-Reference: <4B20A195.8030106@cn.fujitsu.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
---
 tools/perf/Documentation/perf-kmem.txt |   13 +++++---
 tools/perf/builtin-kmem.c              |   52 ++++++++++++++++++--------------
 2 files changed, 37 insertions(+), 28 deletions(-)

diff --git a/tools/perf/Documentation/perf-kmem.txt b/tools/perf/Documentation/perf-kmem.txt
index 44b0ce3..eac4d85 100644
--- a/tools/perf/Documentation/perf-kmem.txt
+++ b/tools/perf/Documentation/perf-kmem.txt
@@ -8,16 +8,16 @@ perf-kmem - Tool to trace/measure kernel memory(slab) properties
 SYNOPSIS
 --------
 [verse]
-'perf kmem' {record} [<options>]
+'perf kmem' {record|stat} [<options>]
 
 DESCRIPTION
 -----------
-There's two variants of perf kmem:
+There are two variants of perf kmem:
 
   'perf kmem record <command>' to record the kmem events
   of an arbitrary workload.
 
-  'perf kmem' to report kernel memory statistics.
+  'perf kmem stat' to report kernel memory statistics.
 
 OPTIONS
 -------
@@ -25,8 +25,11 @@ OPTIONS
 --input=<file>::
 	Select the input file (default: perf.data)
 
---stat=<caller|alloc>::
-	Select per callsite or per allocation statistics
+--caller::
+	Show per-callsite statistics
+
+--alloc::
+	Show per-allocation statistics
 
 -s <key[,key2...]>::
 --sort=<key[,key2...]>::
diff --git a/tools/perf/builtin-kmem.c b/tools/perf/builtin-kmem.c
index 7551a5f..1b04787 100644
--- a/tools/perf/builtin-kmem.c
+++ b/tools/perf/builtin-kmem.c
@@ -526,7 +526,7 @@ static int __cmd_kmem(void)
 }
 
 static const char * const kmem_usage[] = {
-	"perf kmem [<options>] {record}",
+	"perf kmem [<options>] {record|stat}",
 	NULL
 };
 
@@ -686,18 +686,17 @@ static int parse_sort_opt(const struct option *opt __used,
 	return 0;
 }
 
-static int parse_stat_opt(const struct option *opt __used,
+static int parse_caller_opt(const struct option *opt __used,
 			  const char *arg, int unset __used)
 {
-	if (!arg)
-		return -1;
+	caller_flag = (alloc_flag + 1);
+	return 0;
+}
 
-	if (strcmp(arg, "alloc") == 0)
-		alloc_flag = (caller_flag + 1);
-	else if (strcmp(arg, "caller") == 0)
-		caller_flag = (alloc_flag + 1);
-	else
-		return -1;
+static int parse_alloc_opt(const struct option *opt __used,
+			  const char *arg, int unset __used)
+{
+	alloc_flag = (caller_flag + 1);
 	return 0;
 }
 
@@ -722,14 +721,17 @@ static int parse_line_opt(const struct option *opt __used,
 static const struct option kmem_options[] = {
 	OPT_STRING('i', "input", &input_name, "file",
 		   "input file name"),
-	OPT_CALLBACK(0, "stat", NULL, "<alloc>|<caller>",
-		     "stat selector, Pass 'alloc' or 'caller'.",
-		     parse_stat_opt),
+	OPT_CALLBACK_NOOPT(0, "caller", NULL, NULL,
+			   "show per-callsite statistics",
+			   parse_caller_opt),
+	OPT_CALLBACK_NOOPT(0, "alloc", NULL, NULL,
+			   "show per-allocation statistics",
+			   parse_alloc_opt),
 	OPT_CALLBACK('s', "sort", NULL, "key[,key2...]",
 		     "sort by keys: ptr, call_site, bytes, hit, pingpong, frag",
 		     parse_sort_opt),
 	OPT_CALLBACK('l', "line", NULL, "num",
-		     "show n lins",
+		     "show n lines",
 		     parse_line_opt),
 	OPT_BOOLEAN(0, "raw-ip", &raw_ip, "show raw ip instead of symbol"),
 	OPT_END()
@@ -773,18 +775,22 @@ int cmd_kmem(int argc, const char **argv, const char *prefix __used)
 
 	argc = parse_options(argc, argv, kmem_options, kmem_usage, 0);
 
-	if (argc && !strncmp(argv[0], "rec", 3))
-		return __cmd_record(argc, argv);
-	else if (argc)
+	if (!argc)
 		usage_with_options(kmem_usage, kmem_options);
 
-	if (list_empty(&caller_sort))
-		setup_sorting(&caller_sort, default_sort_order);
-	if (list_empty(&alloc_sort))
-		setup_sorting(&alloc_sort, default_sort_order);
+	if (!strncmp(argv[0], "rec", 3)) {
+		return __cmd_record(argc, argv);
+	} else if (!strcmp(argv[0], "stat")) {
+		setup_cpunode_map();
+
+		if (list_empty(&caller_sort))
+			setup_sorting(&caller_sort, default_sort_order);
+		if (list_empty(&alloc_sort))
+			setup_sorting(&alloc_sort, default_sort_order);
 
-	setup_cpunode_map();
+		return __cmd_kmem();
+	}
 
-	return __cmd_kmem();
+	return 0;
 }
 

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [tip:perf/urgent] perf tools: Align long options which have no short forms
  2009-12-10  7:22 ` [PATCH 2/2] perf tools: Align long options which have no short forms Li Zefan
@ 2009-12-10  7:51   ` tip-bot for Li Zefan
  0 siblings, 0 replies; 7+ messages in thread
From: tip-bot for Li Zefan @ 2009-12-10  7:51 UTC (permalink / raw)
  To: linux-tip-commits; +Cc: linux-kernel, hpa, mingo, penberg, lizf, tglx, mingo

Commit-ID:  bc3abfb1b50964ffbbd0fc4e1ffe598b1b63a8c7
Gitweb:     http://git.kernel.org/tip/bc3abfb1b50964ffbbd0fc4e1ffe598b1b63a8c7
Author:     Li Zefan <lizf@cn.fujitsu.com>
AuthorDate: Thu, 10 Dec 2009 15:22:17 +0800
Committer:  Ingo Molnar <mingo@elte.hu>
CommitDate: Thu, 10 Dec 2009 08:30:28 +0100

perf tools: Align long options which have no short forms

Before:

$ ./perf kmem
...
    -l, --line <num>      show n lines
    --raw-ip              show raw ip instead of symbol

After:

$ ./perf kmem
...
    -l, --line <num>      show n lines
        --raw-ip          show raw ip instead of symbol

Signed-off-by: Li Zefan <lizf@cn.fujitsu.com>
Cc: Pekka Enberg <penberg@cs.helsinki.fi>
LKML-Reference: <4B20A1A9.3040104@cn.fujitsu.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
---
 tools/perf/util/parse-options.c |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)

diff --git a/tools/perf/util/parse-options.c b/tools/perf/util/parse-options.c
index 6d8af48..efebd5b 100644
--- a/tools/perf/util/parse-options.c
+++ b/tools/perf/util/parse-options.c
@@ -430,6 +430,9 @@ int usage_with_options_internal(const char * const *usagestr,
 		pos = fprintf(stderr, "    ");
 		if (opts->short_name)
 			pos += fprintf(stderr, "-%c", opts->short_name);
+		else
+			pos += fprintf(stderr, "    ");
+
 		if (opts->long_name && opts->short_name)
 			pos += fprintf(stderr, ", ");
 		if (opts->long_name)

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [tip:perf/urgent] perf kmem: Fix unused argument build warning
  2009-12-10  7:21 [PATCH 1/2] perf kmem: Show usage if no option is specified Li Zefan
                   ` (2 preceding siblings ...)
  2009-12-10  7:50 ` [tip:perf/urgent] " tip-bot for Li Zefan
@ 2009-12-10  7:51 ` tip-bot for Ingo Molnar
  3 siblings, 0 replies; 7+ messages in thread
From: tip-bot for Ingo Molnar @ 2009-12-10  7:51 UTC (permalink / raw)
  To: linux-tip-commits; +Cc: linux-kernel, hpa, mingo, penberg, lizf, tglx, mingo

Commit-ID:  7931241694b25589658b1ceb02218d2750540ae0
Gitweb:     http://git.kernel.org/tip/7931241694b25589658b1ceb02218d2750540ae0
Author:     Ingo Molnar <mingo@elte.hu>
AuthorDate: Thu, 10 Dec 2009 08:43:34 +0100
Committer:  Ingo Molnar <mingo@elte.hu>
CommitDate: Thu, 10 Dec 2009 08:44:39 +0100

perf kmem: Fix unused argument build warning

Fix:

 builtin-kmem.c: In function 'parse_caller_opt':
 builtin-kmem.c:690: error: unused parameter 'arg'
 builtin-kmem.c: In function 'parse_alloc_opt':
 builtin-kmem.c:697: error: unused parameter 'arg'

Cc: Li Zefan <lizf@cn.fujitsu.com>
Cc: Pekka Enberg <penberg@cs.helsinki.fi>
LKML-Reference: <4B20A195.8030106@cn.fujitsu.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
---
 tools/perf/builtin-kmem.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/tools/perf/builtin-kmem.c b/tools/perf/builtin-kmem.c
index 1b04787..5f20951 100644
--- a/tools/perf/builtin-kmem.c
+++ b/tools/perf/builtin-kmem.c
@@ -687,14 +687,14 @@ static int parse_sort_opt(const struct option *opt __used,
 }
 
 static int parse_caller_opt(const struct option *opt __used,
-			  const char *arg, int unset __used)
+			  const char *arg __used, int unset __used)
 {
 	caller_flag = (alloc_flag + 1);
 	return 0;
 }
 
 static int parse_alloc_opt(const struct option *opt __used,
-			  const char *arg, int unset __used)
+			  const char *arg __used, int unset __used)
 {
 	alloc_flag = (caller_flag + 1);
 	return 0;

^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2009-12-10  7:52 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-12-10  7:21 [PATCH 1/2] perf kmem: Show usage if no option is specified Li Zefan
2009-12-10  7:22 ` [PATCH 2/2] perf tools: Align long options which have no short forms Li Zefan
2009-12-10  7:51   ` [tip:perf/urgent] " tip-bot for Li Zefan
2009-12-10  7:23 ` [PATCH 1/2] perf kmem: Show usage if no option is specified Pekka Enberg
2009-12-10  7:30   ` Ingo Molnar
2009-12-10  7:50 ` [tip:perf/urgent] " tip-bot for Li Zefan
2009-12-10  7:51 ` [tip:perf/urgent] perf kmem: Fix unused argument build warning tip-bot for Ingo Molnar

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox