Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1534358
| From | Arnaldo Carvalho de Melo <acme@kernel.org> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | [PATCH 10/19] perf kmem stat: Track memory freed |
| Date | 2016-12-01 19:10 +0100 |
| Message-ID | <sJDXY-7Z4-51@gated-at.bofh.it> (permalink) |
| References | <sJDXX-7Z4-5@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
From: David Ahern <dsa@cumulusnetworks.com>
Track freed memory as well as allocations and show the net in the
summary.
Committer notes:
Testing it:
# perf kmem record usleep 1
[ perf record: Woken up 0 times to write data ]
[ perf record: Captured and wrote 1.626 MB perf.data (4208 samples) ]
[root@jouet ~]# perf kmem stat --slab
SUMMARY (SLAB allocator)
========================
Total bytes requested: 234,011
Total bytes allocated: 234,504
Total bytes freed: 213,328 <------
Net total bytes allocated: 21,176
Total bytes wasted on internal fragmentation: 493
Internal fragmentation: 0.210231%
Cross CPU allocations: 4/1,963
#
Signed-off-by: David Ahern <dsahern@gmail.com>
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: http://lkml.kernel.org/r/1480110133-37039-1-git-send-email-dsahern@gmail.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
tools/perf/builtin-kmem.c | 12 +++++++++++-
1 file changed, 11 insertions(+), 1 deletion(-)
diff --git a/tools/perf/builtin-kmem.c b/tools/perf/builtin-kmem.c
index d426dcb18ce9..7fd6f1e1e293 100644
--- a/tools/perf/builtin-kmem.c
+++ b/tools/perf/builtin-kmem.c
@@ -49,6 +49,7 @@ struct alloc_stat {
u64 ptr;
u64 bytes_req;
u64 bytes_alloc;
+ u64 last_alloc;
u32 hit;
u32 pingpong;
@@ -62,7 +63,7 @@ static struct rb_root root_alloc_sorted;
static struct rb_root root_caller_stat;
static struct rb_root root_caller_sorted;
-static unsigned long total_requested, total_allocated;
+static unsigned long total_requested, total_allocated, total_freed;
static unsigned long nr_allocs, nr_cross_allocs;
static int insert_alloc_stat(unsigned long call_site, unsigned long ptr,
@@ -105,6 +106,8 @@ static int insert_alloc_stat(unsigned long call_site, unsigned long ptr,
}
data->call_site = call_site;
data->alloc_cpu = cpu;
+ data->last_alloc = bytes_alloc;
+
return 0;
}
@@ -223,6 +226,8 @@ static int perf_evsel__process_free_event(struct perf_evsel *evsel,
if (!s_alloc)
return 0;
+ total_freed += s_alloc->last_alloc;
+
if ((short)sample->cpu != s_alloc->alloc_cpu) {
s_alloc->pingpong++;
@@ -1128,6 +1133,11 @@ static void print_slab_summary(void)
printf("\n========================\n");
printf("Total bytes requested: %'lu\n", total_requested);
printf("Total bytes allocated: %'lu\n", total_allocated);
+ printf("Total bytes freed: %'lu\n", total_freed);
+ if (total_allocated > total_freed) {
+ printf("Net total bytes allocated: %'lu\n",
+ total_allocated - total_freed);
+ }
printf("Total bytes wasted on internal fragmentation: %'lu\n",
total_allocated - total_requested);
printf("Internal fragmentation: %f%%\n",
--
2.9.3
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
[GIT PULL 00/19] perf/core improvements and fixes Arnaldo Carvalho de Melo <acme@kernel.org> - 2016-12-01 19:10 +0100 [PATCH 12/19] perf tools: Add time-based utility functions Arnaldo Carvalho de Melo <acme@kernel.org> - 2016-12-01 19:10 +0100 [PATCH 18/19] perf annotate: Use arch->objdump.comment_char in dec__parse() Arnaldo Carvalho de Melo <acme@kernel.org> - 2016-12-01 19:10 +0100 [PATCH 02/19] perf annotate: Show invalid jump offset in error message Arnaldo Carvalho de Melo <acme@kernel.org> - 2016-12-01 19:10 +0100 [PATCH 16/19] perf kmem: Add option to specify time window of interest Arnaldo Carvalho de Melo <acme@kernel.org> - 2016-12-01 19:10 +0100 [PATCH 08/19] perf tools: Introduce perf hooks Arnaldo Carvalho de Melo <acme@kernel.org> - 2016-12-01 19:10 +0100 [PATCH 06/19] tools lib bpf: Add private field for bpf_object Arnaldo Carvalho de Melo <acme@kernel.org> - 2016-12-01 19:10 +0100 [PATCH 14/19] perf script: Add option to specify time window of interest Arnaldo Carvalho de Melo <acme@kernel.org> - 2016-12-01 19:10 +0100 [PATCH 19/19] perf annotate: AArch64 support Arnaldo Carvalho de Melo <acme@kernel.org> - 2016-12-01 19:10 +0100 [PATCH 10/19] perf kmem stat: Track memory freed Arnaldo Carvalho de Melo <acme@kernel.org> - 2016-12-01 19:10 +0100 [PATCH 03/19] perf sched timehist: Handle cpu migration events Arnaldo Carvalho de Melo <acme@kernel.org> - 2016-12-01 19:10 +0100 [PATCH 09/19] perf test: Remove "test" and similar strings from test descriptions Arnaldo Carvalho de Melo <acme@kernel.org> - 2016-12-01 19:10 +0100 [PATCH 13/19] perf tools: Move parse_nsec_time to time-utils.c Arnaldo Carvalho de Melo <acme@kernel.org> - 2016-12-01 19:10 +0100 [PATCH 04/19] perf trace: Update tid/pid filtering option to leverage symbol_conf Arnaldo Carvalho de Melo <acme@kernel.org> - 2016-12-01 19:10 +0100 [PATCH 01/19] perf ui helpline: Provide a printf variant Arnaldo Carvalho de Melo <acme@kernel.org> - 2016-12-01 19:10 +0100 Re: [GIT PULL 00/19] perf/core improvements and fixes Ingo Molnar <mingo@kernel.org> - 2016-12-02 10:20 +0100
csiph-web