Skip to content

Commit

Permalink
perf kmem: Print big numbers using thousands' group
Browse files Browse the repository at this point in the history
Like perf stat, this makes easy to read the numbers on stat like below:

  # perf kmem stat

  SUMMARY
  =======
  Total bytes requested: 9,770,900
  Total bytes allocated: 9,782,712
  Total bytes wasted on internal fragmentation: 11,812
  Internal fragmentation: 0.120744%
  Cross CPU allocations: 74/152,819

Suggested-by: Ingo Molnar <mingo@kernel.org>
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Joonsoo Kim <js1304@gmail.com>
Cc: Minchan Kim <minchan@kernel.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Link: http://lkml.kernel.org/r/1427092244-22764-2-git-send-email-namhyung@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
  • Loading branch information
Namhyung Kim authored and Arnaldo Carvalho de Melo committed Mar 24, 2015
1 parent 929a6bb commit 77cfe38
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions tools/perf/builtin-kmem.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

#include <linux/rbtree.h>
#include <linux/string.h>
#include <locale.h>

struct alloc_stat;
typedef int (*sort_fn_t)(struct alloc_stat *, struct alloc_stat *);
Expand Down Expand Up @@ -325,13 +326,13 @@ static void __print_result(struct rb_root *root, struct perf_session *session,
static void print_summary(void)
{
printf("\nSUMMARY\n=======\n");
printf("Total bytes requested: %lu\n", total_requested);
printf("Total bytes allocated: %lu\n", total_allocated);
printf("Total bytes wasted on internal fragmentation: %lu\n",
printf("Total bytes requested: %'lu\n", total_requested);
printf("Total bytes allocated: %'lu\n", total_allocated);
printf("Total bytes wasted on internal fragmentation: %'lu\n",
total_allocated - total_requested);
printf("Internal fragmentation: %f%%\n",
fragmentation(total_requested, total_allocated));
printf("Cross CPU allocations: %lu/%lu\n", nr_cross_allocs, nr_allocs);
printf("Cross CPU allocations: %'lu/%'lu\n", nr_cross_allocs, nr_allocs);
}

static void print_result(struct perf_session *session)
Expand Down Expand Up @@ -706,6 +707,8 @@ int cmd_kmem(int argc, const char **argv, const char *prefix __maybe_unused)
symbol__init(&session->header.env);

if (!strcmp(argv[0], "stat")) {
setlocale(LC_ALL, "");

if (cpu__setup_cpunode_map())
goto out_delete;

Expand Down

0 comments on commit 77cfe38

Please sign in to comment.