Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 175435
b: refs/heads/master
c: 90b86a9
h: refs/heads/master
i:
  175433: 4ba391b
  175431: 36db7d6
v: v3
  • Loading branch information
Li Zefan authored and Ingo Molnar committed Dec 10, 2009
1 parent c7a99ad commit dd49ce9
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 29 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 1bbfa6f25673019dc0acc9308b667c96f6cda8bf
refs/heads/master: 90b86a9f7dc22e7ff8e8c79ed553860454ff8dd9
13 changes: 8 additions & 5 deletions trunk/tools/perf/Documentation/perf-kmem.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,25 +8,28 @@ 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
-------
-i <file>::
--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...]>::
Expand Down
52 changes: 29 additions & 23 deletions trunk/tools/perf/builtin-kmem.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
};

Expand Down Expand Up @@ -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;
}

Expand All @@ -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()
Expand Down Expand Up @@ -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;
}

0 comments on commit dd49ce9

Please sign in to comment.