aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf/builtin-kmem.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2012-10-12 21:20:11 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2012-10-12 21:20:11 -0400
commitade0899b298ba2c43bfd6abd8cbc2545944cde0c (patch)
treea448dfb440b3b958b6306bb43620cd5d76f504bf /tools/perf/builtin-kmem.c
parent871a0596cb2f51b57dc583d1a7c4be0186582fe7 (diff)
parent95cf59ea72331d0093010543b8951bb43f262cac (diff)
Merge branch 'perf-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip
Pull perf updates from Ingo Molnar: "This tree includes some late late perf items that missed the first round: tools: - Bash auto completion improvements, now we can auto complete the tools long options, tracepoint event names, etc, from Namhyung Kim. - Look up thread using tid instead of pid in 'perf sched'. - Move global variables into a perf_kvm struct, from David Ahern. - Hists refactorings, preparatory for improved 'diff' command, from Jiri Olsa. - Hists refactorings, preparatory for event group viewieng work, from Namhyung Kim. - Remove double negation on optional feature macro definitions, from Namhyung Kim. - Remove several cases of needless global variables, on most builtins. - misc fixes kernel: - sysfs support for IBS on AMD CPUs, from Robert Richter. - Support for an upcoming Intel CPU, the Xeon-Phi / Knights Corner HPC blade PMU, from Vince Weaver. - misc fixes" * 'perf-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: (46 commits) perf: Fix perf_cgroup_switch for sw-events perf: Clarify perf_cpu_context::active_pmu usage by renaming it to ::unique_pmu perf/AMD/IBS: Add sysfs support perf hists: Add more helpers for hist entry stat perf hists: Move he->stat.nr_events initialization to a template perf hists: Introduce struct he_stat perf diff: Removing the total_period argument from output code perf tool: Add hpp interface to enable/disable hpp column perf tools: Removing hists pair argument from output path perf hists: Separate overhead and baseline columns perf diff: Refactor diff displacement possition info perf hists: Add struct hists pointer to struct hist_entry perf tools: Complete tracepoint event names perf/x86: Add support for Intel Xeon-Phi Knights Corner PMU perf evlist: Remove some unused methods perf evlist: Introduce add_newtp method perf kvm: Move global variables into a perf_kvm struct perf tools: Convert to BACKTRACE_SUPPORT perf tools: Long option completion support for each subcommands perf tools: Complete long option names of perf command ...
Diffstat (limited to 'tools/perf/builtin-kmem.c')
-rw-r--r--tools/perf/builtin-kmem.c66
1 files changed, 26 insertions, 40 deletions
diff --git a/tools/perf/builtin-kmem.c b/tools/perf/builtin-kmem.c
index bc912c68f49a..14bf82f63659 100644
--- a/tools/perf/builtin-kmem.c
+++ b/tools/perf/builtin-kmem.c
@@ -21,8 +21,6 @@
21struct alloc_stat; 21struct alloc_stat;
22typedef int (*sort_fn_t)(struct alloc_stat *, struct alloc_stat *); 22typedef int (*sort_fn_t)(struct alloc_stat *, struct alloc_stat *);
23 23
24static const char *input_name;
25
26static int alloc_flag; 24static int alloc_flag;
27static int caller_flag; 25static int caller_flag;
28 26
@@ -31,8 +29,6 @@ static int caller_lines = -1;
31 29
32static bool raw_ip; 30static bool raw_ip;
33 31
34static char default_sort_order[] = "frag,hit,bytes";
35
36static int *cpunode_map; 32static int *cpunode_map;
37static int max_cpu_num; 33static int max_cpu_num;
38 34
@@ -481,7 +477,7 @@ static void sort_result(void)
481 __sort_result(&root_caller_stat, &root_caller_sorted, &caller_sort); 477 __sort_result(&root_caller_stat, &root_caller_sorted, &caller_sort);
482} 478}
483 479
484static int __cmd_kmem(void) 480static int __cmd_kmem(const char *input_name)
485{ 481{
486 int err = -EINVAL; 482 int err = -EINVAL;
487 struct perf_session *session; 483 struct perf_session *session;
@@ -520,11 +516,6 @@ out_delete:
520 return err; 516 return err;
521} 517}
522 518
523static const char * const kmem_usage[] = {
524 "perf kmem [<options>] {record|stat}",
525 NULL
526};
527
528static int ptr_cmp(struct alloc_stat *l, struct alloc_stat *r) 519static int ptr_cmp(struct alloc_stat *l, struct alloc_stat *r)
529{ 520{
530 if (l->ptr < r->ptr) 521 if (l->ptr < r->ptr)
@@ -720,41 +711,17 @@ static int parse_line_opt(const struct option *opt __maybe_unused,
720 return 0; 711 return 0;
721} 712}
722 713
723static const struct option kmem_options[] = { 714static int __cmd_record(int argc, const char **argv)
724 OPT_STRING('i', "input", &input_name, "file", 715{
725 "input file name"), 716 const char * const record_args[] = {
726 OPT_CALLBACK_NOOPT(0, "caller", NULL, NULL, 717 "record", "-a", "-R", "-f", "-c", "1",
727 "show per-callsite statistics",
728 parse_caller_opt),
729 OPT_CALLBACK_NOOPT(0, "alloc", NULL, NULL,
730 "show per-allocation statistics",
731 parse_alloc_opt),
732 OPT_CALLBACK('s', "sort", NULL, "key[,key2...]",
733 "sort by keys: ptr, call_site, bytes, hit, pingpong, frag",
734 parse_sort_opt),
735 OPT_CALLBACK('l', "line", NULL, "num",
736 "show n lines",
737 parse_line_opt),
738 OPT_BOOLEAN(0, "raw-ip", &raw_ip, "show raw ip instead of symbol"),
739 OPT_END()
740};
741
742static const char *record_args[] = {
743 "record",
744 "-a",
745 "-R",
746 "-f",
747 "-c", "1",
748 "-e", "kmem:kmalloc", 718 "-e", "kmem:kmalloc",
749 "-e", "kmem:kmalloc_node", 719 "-e", "kmem:kmalloc_node",
750 "-e", "kmem:kfree", 720 "-e", "kmem:kfree",
751 "-e", "kmem:kmem_cache_alloc", 721 "-e", "kmem:kmem_cache_alloc",
752 "-e", "kmem:kmem_cache_alloc_node", 722 "-e", "kmem:kmem_cache_alloc_node",
753 "-e", "kmem:kmem_cache_free", 723 "-e", "kmem:kmem_cache_free",
754}; 724 };
755
756static int __cmd_record(int argc, const char **argv)
757{
758 unsigned int rec_argc, i, j; 725 unsigned int rec_argc, i, j;
759 const char **rec_argv; 726 const char **rec_argv;
760 727
@@ -775,6 +742,25 @@ static int __cmd_record(int argc, const char **argv)
775 742
776int cmd_kmem(int argc, const char **argv, const char *prefix __maybe_unused) 743int cmd_kmem(int argc, const char **argv, const char *prefix __maybe_unused)
777{ 744{
745 const char * const default_sort_order = "frag,hit,bytes";
746 const char *input_name = NULL;
747 const struct option kmem_options[] = {
748 OPT_STRING('i', "input", &input_name, "file", "input file name"),
749 OPT_CALLBACK_NOOPT(0, "caller", NULL, NULL,
750 "show per-callsite statistics", parse_caller_opt),
751 OPT_CALLBACK_NOOPT(0, "alloc", NULL, NULL,
752 "show per-allocation statistics", parse_alloc_opt),
753 OPT_CALLBACK('s', "sort", NULL, "key[,key2...]",
754 "sort by keys: ptr, call_site, bytes, hit, pingpong, frag",
755 parse_sort_opt),
756 OPT_CALLBACK('l', "line", NULL, "num", "show n lines", parse_line_opt),
757 OPT_BOOLEAN(0, "raw-ip", &raw_ip, "show raw ip instead of symbol"),
758 OPT_END()
759 };
760 const char * const kmem_usage[] = {
761 "perf kmem [<options>] {record|stat}",
762 NULL
763 };
778 argc = parse_options(argc, argv, kmem_options, kmem_usage, 0); 764 argc = parse_options(argc, argv, kmem_options, kmem_usage, 0);
779 765
780 if (!argc) 766 if (!argc)
@@ -793,7 +779,7 @@ int cmd_kmem(int argc, const char **argv, const char *prefix __maybe_unused)
793 if (list_empty(&alloc_sort)) 779 if (list_empty(&alloc_sort))
794 setup_sorting(&alloc_sort, default_sort_order); 780 setup_sorting(&alloc_sort, default_sort_order);
795 781
796 return __cmd_kmem(); 782 return __cmd_kmem(input_name);
797 } else 783 } else
798 usage_with_options(kmem_usage, kmem_options); 784 usage_with_options(kmem_usage, kmem_options);
799 785