linux-stable/samples
Alexei Starovoitov 9811e35359 samples/bpf: Add kmem_alloc()/free() tracker tool
One BPF program attaches to kmem_cache_alloc_node() and
remembers all allocated objects in the map.
Another program attaches to kmem_cache_free() and deletes
corresponding object from the map.

User space walks the map every second and prints any objects
which are older than 1 second.

Usage:

	$ sudo tracex4

Then start few long living processes. The 'tracex4' will print
something like this:

	obj 0xffff880465928000 is 13sec old was allocated at ip ffffffff8105dc32
	obj 0xffff88043181c280 is 13sec old was allocated at ip ffffffff8105dc32
	obj 0xffff880465848000 is  8sec old was allocated at ip ffffffff8105dc32
	obj 0xffff8804338bc280 is 15sec old was allocated at ip ffffffff8105dc32

	$ addr2line -fispe vmlinux ffffffff8105dc32
	do_fork at fork.c:1665

As soon as processes exit the memory is reclaimed and 'tracex4'
prints nothing.

Similar experiment can be done with the __kmalloc()/kfree() pair.

Signed-off-by: Alexei Starovoitov <ast@plumgrid.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Arnaldo Carvalho de Melo <acme@infradead.org>
Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Daniel Borkmann <daniel@iogearbox.net>
Cc: David S. Miller <davem@davemloft.net>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Steven Rostedt <rostedt@goodmis.org>
Link: http://lkml.kernel.org/r/1427312966-8434-10-git-send-email-ast@plumgrid.com
Signed-off-by: Ingo Molnar <mingo@kernel.org>
2015-04-02 13:25:51 +02:00
..
bpf samples/bpf: Add kmem_alloc()/free() tracker tool 2015-04-02 13:25:51 +02:00
hidraw HID: samples/hidraw: add .gitignore file 2013-08-20 12:48:58 +02:00
hw_breakpoint perf: Add context field to perf_event 2011-07-01 11:06:38 +02:00
kdb kdb: Add kdb kernel module sample 2010-10-29 13:14:39 -05:00
kfifo kfifo API type safety 2013-11-15 09:32:23 +09:00
kobject samples/kobject/: avoid world-writable sysfs files. 2014-05-14 10:53:57 +09:30
kprobes kprobes: update jprobe_example.c for do_fork() change 2014-09-26 11:11:12 +02:00
livepatch livepatch: rename config to CONFIG_LIVEPATCH 2015-02-04 11:25:51 +01:00
rpmsg misc: remove __dev* attributes. 2013-01-03 15:57:16 -08:00
seccomp samples/seccomp: improve label helper 2015-02-17 14:34:55 -08:00
trace_events tracing: Add samples of DECLARE_EVENT_CLASS() and DEFINE_EVENT() 2015-02-09 18:05:51 -05:00
uhid HID: uhid: improve uhid example client 2013-09-04 11:35:14 +02:00
Kconfig livepatch: rename config to CONFIG_LIVEPATCH 2015-02-04 11:25:51 +01:00
Makefile livepatch: samples: add sample live patching module 2014-12-22 15:40:49 +01:00