aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/kmemtrace.h
diff options
context:
space:
mode:
authorEduard - Gabriel Munteanu <eduard.munteanu@linux360.ro>2008-08-10 13:14:03 -0400
committerPekka Enberg <penberg@cs.helsinki.fi>2008-12-29 08:34:01 -0500
commitb9ce08c01020eb28bfbfa6faf1c740281c5f418e (patch)
treeb42bbda9a44a9e62d952816482b340bc4b70870b /include/linux/kmemtrace.h
parent35995a4d815586bc968a857f7235707940a2f755 (diff)
kmemtrace: Core implementation.
kmemtrace provides tracing for slab allocator functions, such as kmalloc, kfree, kmem_cache_alloc, kmem_cache_free etc.. Collected data is then fed to the userspace application in order to analyse allocation hotspots, internal fragmentation and so on, making it possible to see how well an allocator performs, as well as debug and profile kernel code. Signed-off-by: Eduard - Gabriel Munteanu <eduard.munteanu@linux360.ro> Signed-off-by: Pekka Enberg <penberg@cs.helsinki.fi>
Diffstat (limited to 'include/linux/kmemtrace.h')
-rw-r--r--include/linux/kmemtrace.h85
1 files changed, 85 insertions, 0 deletions
diff --git a/include/linux/kmemtrace.h b/include/linux/kmemtrace.h
new file mode 100644
index 000000000000..2c332010cb4e
--- /dev/null
+++ b/include/linux/kmemtrace.h
@@ -0,0 +1,85 @@
1/*
2 * Copyright (C) 2008 Eduard - Gabriel Munteanu
3 *
4 * This file is released under GPL version 2.
5 */
6
7#ifndef _LINUX_KMEMTRACE_H
8#define _LINUX_KMEMTRACE_H
9
10#ifdef __KERNEL__
11
12#include <linux/types.h>
13#include <linux/marker.h>
14
15enum kmemtrace_type_id {
16 KMEMTRACE_TYPE_KMALLOC = 0, /* kmalloc() or kfree(). */
17 KMEMTRACE_TYPE_CACHE, /* kmem_cache_*(). */
18 KMEMTRACE_TYPE_PAGES, /* __get_free_pages() and friends. */
19};
20
21#ifdef CONFIG_KMEMTRACE
22
23extern void kmemtrace_init(void);
24
25static inline void kmemtrace_mark_alloc_node(enum kmemtrace_type_id type_id,
26 unsigned long call_site,
27 const void *ptr,
28 size_t bytes_req,
29 size_t bytes_alloc,
30 gfp_t gfp_flags,
31 int node)
32{
33 trace_mark(kmemtrace_alloc, "type_id %d call_site %lu ptr %lu "
34 "bytes_req %lu bytes_alloc %lu gfp_flags %lu node %d",
35 type_id, call_site, (unsigned long) ptr,
36 bytes_req, bytes_alloc, (unsigned long) gfp_flags, node);
37}
38
39static inline void kmemtrace_mark_free(enum kmemtrace_type_id type_id,
40 unsigned long call_site,
41 const void *ptr)
42{
43 trace_mark(kmemtrace_free, "type_id %d call_site %lu ptr %lu",
44 type_id, call_site, (unsigned long) ptr);
45}
46
47#else /* CONFIG_KMEMTRACE */
48
49static inline void kmemtrace_init(void)
50{
51}
52
53static inline void kmemtrace_mark_alloc_node(enum kmemtrace_type_id type_id,
54 unsigned long call_site,
55 const void *ptr,
56 size_t bytes_req,
57 size_t bytes_alloc,
58 gfp_t gfp_flags,
59 int node)
60{
61}
62
63static inline void kmemtrace_mark_free(enum kmemtrace_type_id type_id,
64 unsigned long call_site,
65 const void *ptr)
66{
67}
68
69#endif /* CONFIG_KMEMTRACE */
70
71static inline void kmemtrace_mark_alloc(enum kmemtrace_type_id type_id,
72 unsigned long call_site,
73 const void *ptr,
74 size_t bytes_req,
75 size_t bytes_alloc,
76 gfp_t gfp_flags)
77{
78 kmemtrace_mark_alloc_node(type_id, call_site, ptr,
79 bytes_req, bytes_alloc, gfp_flags, -1);
80}
81
82#endif /* __KERNEL__ */
83
84#endif /* _LINUX_KMEMTRACE_H */
85