提交 90b86a9f 编写于 作者: L Li Zefan 提交者: Ingo Molnar

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: NLi Zefan <lizf@cn.fujitsu.com>
Acked-by: NPekka Enberg <penberg@cs.helsinki.fi>
LKML-Reference: <4B20A195.8030106@cn.fujitsu.com>
Signed-off-by: NIngo Molnar <mingo@elte.hu>
上级 1bbfa6f2
...@@ -8,16 +8,16 @@ perf-kmem - Tool to trace/measure kernel memory(slab) properties ...@@ -8,16 +8,16 @@ perf-kmem - Tool to trace/measure kernel memory(slab) properties
SYNOPSIS SYNOPSIS
-------- --------
[verse] [verse]
'perf kmem' {record} [<options>] 'perf kmem' {record|stat} [<options>]
DESCRIPTION DESCRIPTION
----------- -----------
There's two variants of perf kmem: There are two variants of perf kmem:
'perf kmem record <command>' to record the kmem events 'perf kmem record <command>' to record the kmem events
of an arbitrary workload. of an arbitrary workload.
'perf kmem' to report kernel memory statistics. 'perf kmem stat' to report kernel memory statistics.
OPTIONS OPTIONS
------- -------
...@@ -25,8 +25,11 @@ OPTIONS ...@@ -25,8 +25,11 @@ OPTIONS
--input=<file>:: --input=<file>::
Select the input file (default: perf.data) Select the input file (default: perf.data)
--stat=<caller|alloc>:: --caller::
Select per callsite or per allocation statistics Show per-callsite statistics
--alloc::
Show per-allocation statistics
-s <key[,key2...]>:: -s <key[,key2...]>::
--sort=<key[,key2...]>:: --sort=<key[,key2...]>::
......
...@@ -526,7 +526,7 @@ static int __cmd_kmem(void) ...@@ -526,7 +526,7 @@ static int __cmd_kmem(void)
} }
static const char * const kmem_usage[] = { static const char * const kmem_usage[] = {
"perf kmem [<options>] {record}", "perf kmem [<options>] {record|stat}",
NULL NULL
}; };
...@@ -686,18 +686,17 @@ static int parse_sort_opt(const struct option *opt __used, ...@@ -686,18 +686,17 @@ static int parse_sort_opt(const struct option *opt __used,
return 0; 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) const char *arg, int unset __used)
{ {
if (!arg) caller_flag = (alloc_flag + 1);
return -1; return 0;
}
if (strcmp(arg, "alloc") == 0) static int parse_alloc_opt(const struct option *opt __used,
alloc_flag = (caller_flag + 1); const char *arg, int unset __used)
else if (strcmp(arg, "caller") == 0) {
caller_flag = (alloc_flag + 1); alloc_flag = (caller_flag + 1);
else
return -1;
return 0; return 0;
} }
...@@ -722,14 +721,17 @@ static int parse_line_opt(const struct option *opt __used, ...@@ -722,14 +721,17 @@ static int parse_line_opt(const struct option *opt __used,
static const struct option kmem_options[] = { static const struct option kmem_options[] = {
OPT_STRING('i', "input", &input_name, "file", OPT_STRING('i', "input", &input_name, "file",
"input file name"), "input file name"),
OPT_CALLBACK(0, "stat", NULL, "<alloc>|<caller>", OPT_CALLBACK_NOOPT(0, "caller", NULL, NULL,
"stat selector, Pass 'alloc' or 'caller'.", "show per-callsite statistics",
parse_stat_opt), parse_caller_opt),
OPT_CALLBACK_NOOPT(0, "alloc", NULL, NULL,
"show per-allocation statistics",
parse_alloc_opt),
OPT_CALLBACK('s', "sort", NULL, "key[,key2...]", OPT_CALLBACK('s', "sort", NULL, "key[,key2...]",
"sort by keys: ptr, call_site, bytes, hit, pingpong, frag", "sort by keys: ptr, call_site, bytes, hit, pingpong, frag",
parse_sort_opt), parse_sort_opt),
OPT_CALLBACK('l', "line", NULL, "num", OPT_CALLBACK('l', "line", NULL, "num",
"show n lins", "show n lines",
parse_line_opt), parse_line_opt),
OPT_BOOLEAN(0, "raw-ip", &raw_ip, "show raw ip instead of symbol"), OPT_BOOLEAN(0, "raw-ip", &raw_ip, "show raw ip instead of symbol"),
OPT_END() OPT_END()
...@@ -773,18 +775,22 @@ int cmd_kmem(int argc, const char **argv, const char *prefix __used) ...@@ -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); argc = parse_options(argc, argv, kmem_options, kmem_usage, 0);
if (argc && !strncmp(argv[0], "rec", 3)) if (!argc)
return __cmd_record(argc, argv);
else if (argc)
usage_with_options(kmem_usage, kmem_options); usage_with_options(kmem_usage, kmem_options);
if (list_empty(&caller_sort)) if (!strncmp(argv[0], "rec", 3)) {
setup_sorting(&caller_sort, default_sort_order); return __cmd_record(argc, argv);
if (list_empty(&alloc_sort)) } else if (!strcmp(argv[0], "stat")) {
setup_sorting(&alloc_sort, default_sort_order); 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;
} }
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册