Eduard - Gabriel Munteanu | b9ce08c | 2008-08-10 20:14:03 +0300 | [diff] [blame] | 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 | |
| 15 | enum 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 | |
| 23 | extern void kmemtrace_init(void); |
| 24 | |
Frederic Weisbecker | 36994e5 | 2008-12-29 13:42:23 -0800 | [diff] [blame] | 25 | extern void kmemtrace_mark_alloc_node(enum kmemtrace_type_id type_id, |
Eduard - Gabriel Munteanu | b9ce08c | 2008-08-10 20:14:03 +0300 | [diff] [blame] | 26 | unsigned long call_site, |
| 27 | const void *ptr, |
| 28 | size_t bytes_req, |
| 29 | size_t bytes_alloc, |
| 30 | gfp_t gfp_flags, |
Frederic Weisbecker | 36994e5 | 2008-12-29 13:42:23 -0800 | [diff] [blame] | 31 | int node); |
Eduard - Gabriel Munteanu | b9ce08c | 2008-08-10 20:14:03 +0300 | [diff] [blame] | 32 | |
Frederic Weisbecker | 36994e5 | 2008-12-29 13:42:23 -0800 | [diff] [blame] | 33 | extern void kmemtrace_mark_free(enum kmemtrace_type_id type_id, |
Eduard - Gabriel Munteanu | b9ce08c | 2008-08-10 20:14:03 +0300 | [diff] [blame] | 34 | unsigned long call_site, |
Frederic Weisbecker | 36994e5 | 2008-12-29 13:42:23 -0800 | [diff] [blame] | 35 | const void *ptr); |
Eduard - Gabriel Munteanu | b9ce08c | 2008-08-10 20:14:03 +0300 | [diff] [blame] | 36 | |
| 37 | #else /* CONFIG_KMEMTRACE */ |
| 38 | |
| 39 | static inline void kmemtrace_init(void) |
| 40 | { |
| 41 | } |
| 42 | |
| 43 | static inline void kmemtrace_mark_alloc_node(enum kmemtrace_type_id type_id, |
| 44 | unsigned long call_site, |
| 45 | const void *ptr, |
| 46 | size_t bytes_req, |
| 47 | size_t bytes_alloc, |
| 48 | gfp_t gfp_flags, |
| 49 | int node) |
| 50 | { |
| 51 | } |
| 52 | |
| 53 | static inline void kmemtrace_mark_free(enum kmemtrace_type_id type_id, |
| 54 | unsigned long call_site, |
| 55 | const void *ptr) |
| 56 | { |
| 57 | } |
| 58 | |
| 59 | #endif /* CONFIG_KMEMTRACE */ |
| 60 | |
| 61 | static inline void kmemtrace_mark_alloc(enum kmemtrace_type_id type_id, |
| 62 | unsigned long call_site, |
| 63 | const void *ptr, |
| 64 | size_t bytes_req, |
| 65 | size_t bytes_alloc, |
| 66 | gfp_t gfp_flags) |
| 67 | { |
| 68 | kmemtrace_mark_alloc_node(type_id, call_site, ptr, |
| 69 | bytes_req, bytes_alloc, gfp_flags, -1); |
| 70 | } |
| 71 | |
| 72 | #endif /* __KERNEL__ */ |
| 73 | |
| 74 | #endif /* _LINUX_KMEMTRACE_H */ |
| 75 | |