diff options
Diffstat (limited to 'include/linux')
-rw-r--r-- | include/linux/blktrace_api.h | 5 | ||||
-rw-r--r-- | include/linux/ftrace.h | 25 | ||||
-rw-r--r-- | include/linux/sched.h | 2 | ||||
-rw-r--r-- | include/linux/slab_def.h | 68 | ||||
-rw-r--r-- | include/linux/slob_def.h | 9 | ||||
-rw-r--r-- | include/linux/slub_def.h | 53 |
6 files changed, 146 insertions, 16 deletions
diff --git a/include/linux/blktrace_api.h b/include/linux/blktrace_api.h index 25379cba2370..ed12e8fd8cf7 100644 --- a/include/linux/blktrace_api.h +++ b/include/linux/blktrace_api.h | |||
@@ -143,6 +143,9 @@ struct blk_user_trace_setup { | |||
143 | 143 | ||
144 | #ifdef __KERNEL__ | 144 | #ifdef __KERNEL__ |
145 | #if defined(CONFIG_BLK_DEV_IO_TRACE) | 145 | #if defined(CONFIG_BLK_DEV_IO_TRACE) |
146 | |||
147 | #include <linux/sysfs.h> | ||
148 | |||
146 | struct blk_trace { | 149 | struct blk_trace { |
147 | int trace_state; | 150 | int trace_state; |
148 | struct rchan *rchan; | 151 | struct rchan *rchan; |
@@ -193,6 +196,8 @@ extern int blk_trace_setup(struct request_queue *q, char *name, dev_t dev, | |||
193 | extern int blk_trace_startstop(struct request_queue *q, int start); | 196 | extern int blk_trace_startstop(struct request_queue *q, int start); |
194 | extern int blk_trace_remove(struct request_queue *q); | 197 | extern int blk_trace_remove(struct request_queue *q); |
195 | 198 | ||
199 | extern struct attribute_group blk_trace_attr_group; | ||
200 | |||
196 | #else /* !CONFIG_BLK_DEV_IO_TRACE */ | 201 | #else /* !CONFIG_BLK_DEV_IO_TRACE */ |
197 | #define blk_trace_ioctl(bdev, cmd, arg) (-ENOTTY) | 202 | #define blk_trace_ioctl(bdev, cmd, arg) (-ENOTTY) |
198 | #define blk_trace_shutdown(q) do { } while (0) | 203 | #define blk_trace_shutdown(q) do { } while (0) |
diff --git a/include/linux/ftrace.h b/include/linux/ftrace.h index 677432b9cb7e..7840e718c6c7 100644 --- a/include/linux/ftrace.h +++ b/include/linux/ftrace.h | |||
@@ -126,6 +126,10 @@ extern int ftrace_update_ftrace_func(ftrace_func_t func); | |||
126 | extern void ftrace_caller(void); | 126 | extern void ftrace_caller(void); |
127 | extern void ftrace_call(void); | 127 | extern void ftrace_call(void); |
128 | extern void mcount_call(void); | 128 | extern void mcount_call(void); |
129 | |||
130 | #ifndef FTRACE_ADDR | ||
131 | #define FTRACE_ADDR ((unsigned long)ftrace_caller) | ||
132 | #endif | ||
129 | #ifdef CONFIG_FUNCTION_GRAPH_TRACER | 133 | #ifdef CONFIG_FUNCTION_GRAPH_TRACER |
130 | extern void ftrace_graph_caller(void); | 134 | extern void ftrace_graph_caller(void); |
131 | extern int ftrace_enable_ftrace_graph_caller(void); | 135 | extern int ftrace_enable_ftrace_graph_caller(void); |
@@ -298,6 +302,9 @@ ftrace_special(unsigned long arg1, unsigned long arg2, unsigned long arg3); | |||
298 | extern int | 302 | extern int |
299 | __ftrace_printk(unsigned long ip, const char *fmt, ...) | 303 | __ftrace_printk(unsigned long ip, const char *fmt, ...) |
300 | __attribute__ ((format (printf, 2, 3))); | 304 | __attribute__ ((format (printf, 2, 3))); |
305 | # define ftrace_vprintk(fmt, ap) __ftrace_printk(_THIS_IP_, fmt, ap) | ||
306 | extern int | ||
307 | __ftrace_vprintk(unsigned long ip, const char *fmt, va_list ap); | ||
301 | extern void ftrace_dump(void); | 308 | extern void ftrace_dump(void); |
302 | #else | 309 | #else |
303 | static inline void | 310 | static inline void |
@@ -313,6 +320,11 @@ ftrace_printk(const char *fmt, ...) | |||
313 | { | 320 | { |
314 | return 0; | 321 | return 0; |
315 | } | 322 | } |
323 | static inline int | ||
324 | ftrace_vprintk(const char *fmt, va_list ap) | ||
325 | { | ||
326 | return 0; | ||
327 | } | ||
316 | static inline void ftrace_dump(void) { } | 328 | static inline void ftrace_dump(void) { } |
317 | #endif | 329 | #endif |
318 | 330 | ||
@@ -492,4 +504,17 @@ static inline int test_tsk_trace_graph(struct task_struct *tsk) | |||
492 | 504 | ||
493 | #endif /* CONFIG_TRACING */ | 505 | #endif /* CONFIG_TRACING */ |
494 | 506 | ||
507 | |||
508 | #ifdef CONFIG_HW_BRANCH_TRACER | ||
509 | |||
510 | void trace_hw_branch(u64 from, u64 to); | ||
511 | void trace_hw_branch_oops(void); | ||
512 | |||
513 | #else /* CONFIG_HW_BRANCH_TRACER */ | ||
514 | |||
515 | static inline void trace_hw_branch(u64 from, u64 to) {} | ||
516 | static inline void trace_hw_branch_oops(void) {} | ||
517 | |||
518 | #endif /* CONFIG_HW_BRANCH_TRACER */ | ||
519 | |||
495 | #endif /* _LINUX_FTRACE_H */ | 520 | #endif /* _LINUX_FTRACE_H */ |
diff --git a/include/linux/sched.h b/include/linux/sched.h index 5a7c76388731..f3c23cf11abc 100644 --- a/include/linux/sched.h +++ b/include/linux/sched.h | |||
@@ -137,6 +137,8 @@ extern unsigned long nr_uninterruptible(void); | |||
137 | extern unsigned long nr_active(void); | 137 | extern unsigned long nr_active(void); |
138 | extern unsigned long nr_iowait(void); | 138 | extern unsigned long nr_iowait(void); |
139 | 139 | ||
140 | extern unsigned long get_parent_ip(unsigned long addr); | ||
141 | |||
140 | struct seq_file; | 142 | struct seq_file; |
141 | struct cfs_rq; | 143 | struct cfs_rq; |
142 | struct task_group; | 144 | struct task_group; |
diff --git a/include/linux/slab_def.h b/include/linux/slab_def.h index 6ca6a7b66d75..f4523651fa42 100644 --- a/include/linux/slab_def.h +++ b/include/linux/slab_def.h | |||
@@ -14,6 +14,7 @@ | |||
14 | #include <asm/page.h> /* kmalloc_sizes.h needs PAGE_SIZE */ | 14 | #include <asm/page.h> /* kmalloc_sizes.h needs PAGE_SIZE */ |
15 | #include <asm/cache.h> /* kmalloc_sizes.h needs L1_CACHE_BYTES */ | 15 | #include <asm/cache.h> /* kmalloc_sizes.h needs L1_CACHE_BYTES */ |
16 | #include <linux/compiler.h> | 16 | #include <linux/compiler.h> |
17 | #include <trace/kmemtrace.h> | ||
17 | 18 | ||
18 | /* Size description struct for general caches. */ | 19 | /* Size description struct for general caches. */ |
19 | struct cache_sizes { | 20 | struct cache_sizes { |
@@ -28,8 +29,26 @@ extern struct cache_sizes malloc_sizes[]; | |||
28 | void *kmem_cache_alloc(struct kmem_cache *, gfp_t); | 29 | void *kmem_cache_alloc(struct kmem_cache *, gfp_t); |
29 | void *__kmalloc(size_t size, gfp_t flags); | 30 | void *__kmalloc(size_t size, gfp_t flags); |
30 | 31 | ||
31 | static inline void *kmalloc(size_t size, gfp_t flags) | 32 | #ifdef CONFIG_KMEMTRACE |
33 | extern void *kmem_cache_alloc_notrace(struct kmem_cache *cachep, gfp_t flags); | ||
34 | extern size_t slab_buffer_size(struct kmem_cache *cachep); | ||
35 | #else | ||
36 | static __always_inline void * | ||
37 | kmem_cache_alloc_notrace(struct kmem_cache *cachep, gfp_t flags) | ||
32 | { | 38 | { |
39 | return kmem_cache_alloc(cachep, flags); | ||
40 | } | ||
41 | static inline size_t slab_buffer_size(struct kmem_cache *cachep) | ||
42 | { | ||
43 | return 0; | ||
44 | } | ||
45 | #endif | ||
46 | |||
47 | static __always_inline void *kmalloc(size_t size, gfp_t flags) | ||
48 | { | ||
49 | struct kmem_cache *cachep; | ||
50 | void *ret; | ||
51 | |||
33 | if (__builtin_constant_p(size)) { | 52 | if (__builtin_constant_p(size)) { |
34 | int i = 0; | 53 | int i = 0; |
35 | 54 | ||
@@ -47,10 +66,17 @@ static inline void *kmalloc(size_t size, gfp_t flags) | |||
47 | found: | 66 | found: |
48 | #ifdef CONFIG_ZONE_DMA | 67 | #ifdef CONFIG_ZONE_DMA |
49 | if (flags & GFP_DMA) | 68 | if (flags & GFP_DMA) |
50 | return kmem_cache_alloc(malloc_sizes[i].cs_dmacachep, | 69 | cachep = malloc_sizes[i].cs_dmacachep; |
51 | flags); | 70 | else |
52 | #endif | 71 | #endif |
53 | return kmem_cache_alloc(malloc_sizes[i].cs_cachep, flags); | 72 | cachep = malloc_sizes[i].cs_cachep; |
73 | |||
74 | ret = kmem_cache_alloc_notrace(cachep, flags); | ||
75 | |||
76 | kmemtrace_mark_alloc(KMEMTRACE_TYPE_KMALLOC, _THIS_IP_, ret, | ||
77 | size, slab_buffer_size(cachep), flags); | ||
78 | |||
79 | return ret; | ||
54 | } | 80 | } |
55 | return __kmalloc(size, flags); | 81 | return __kmalloc(size, flags); |
56 | } | 82 | } |
@@ -59,8 +85,25 @@ found: | |||
59 | extern void *__kmalloc_node(size_t size, gfp_t flags, int node); | 85 | extern void *__kmalloc_node(size_t size, gfp_t flags, int node); |
60 | extern void *kmem_cache_alloc_node(struct kmem_cache *, gfp_t flags, int node); | 86 | extern void *kmem_cache_alloc_node(struct kmem_cache *, gfp_t flags, int node); |
61 | 87 | ||
62 | static inline void *kmalloc_node(size_t size, gfp_t flags, int node) | 88 | #ifdef CONFIG_KMEMTRACE |
89 | extern void *kmem_cache_alloc_node_notrace(struct kmem_cache *cachep, | ||
90 | gfp_t flags, | ||
91 | int nodeid); | ||
92 | #else | ||
93 | static __always_inline void * | ||
94 | kmem_cache_alloc_node_notrace(struct kmem_cache *cachep, | ||
95 | gfp_t flags, | ||
96 | int nodeid) | ||
97 | { | ||
98 | return kmem_cache_alloc_node(cachep, flags, nodeid); | ||
99 | } | ||
100 | #endif | ||
101 | |||
102 | static __always_inline void *kmalloc_node(size_t size, gfp_t flags, int node) | ||
63 | { | 103 | { |
104 | struct kmem_cache *cachep; | ||
105 | void *ret; | ||
106 | |||
64 | if (__builtin_constant_p(size)) { | 107 | if (__builtin_constant_p(size)) { |
65 | int i = 0; | 108 | int i = 0; |
66 | 109 | ||
@@ -78,11 +121,18 @@ static inline void *kmalloc_node(size_t size, gfp_t flags, int node) | |||
78 | found: | 121 | found: |
79 | #ifdef CONFIG_ZONE_DMA | 122 | #ifdef CONFIG_ZONE_DMA |
80 | if (flags & GFP_DMA) | 123 | if (flags & GFP_DMA) |
81 | return kmem_cache_alloc_node(malloc_sizes[i].cs_dmacachep, | 124 | cachep = malloc_sizes[i].cs_dmacachep; |
82 | flags, node); | 125 | else |
83 | #endif | 126 | #endif |
84 | return kmem_cache_alloc_node(malloc_sizes[i].cs_cachep, | 127 | cachep = malloc_sizes[i].cs_cachep; |
85 | flags, node); | 128 | |
129 | ret = kmem_cache_alloc_node_notrace(cachep, flags, node); | ||
130 | |||
131 | kmemtrace_mark_alloc_node(KMEMTRACE_TYPE_KMALLOC, _THIS_IP_, | ||
132 | ret, size, slab_buffer_size(cachep), | ||
133 | flags, node); | ||
134 | |||
135 | return ret; | ||
86 | } | 136 | } |
87 | return __kmalloc_node(size, flags, node); | 137 | return __kmalloc_node(size, flags, node); |
88 | } | 138 | } |
diff --git a/include/linux/slob_def.h b/include/linux/slob_def.h index 59a3fa476ab9..0ec00b39d006 100644 --- a/include/linux/slob_def.h +++ b/include/linux/slob_def.h | |||
@@ -3,14 +3,15 @@ | |||
3 | 3 | ||
4 | void *kmem_cache_alloc_node(struct kmem_cache *, gfp_t flags, int node); | 4 | void *kmem_cache_alloc_node(struct kmem_cache *, gfp_t flags, int node); |
5 | 5 | ||
6 | static inline void *kmem_cache_alloc(struct kmem_cache *cachep, gfp_t flags) | 6 | static __always_inline void *kmem_cache_alloc(struct kmem_cache *cachep, |
7 | gfp_t flags) | ||
7 | { | 8 | { |
8 | return kmem_cache_alloc_node(cachep, flags, -1); | 9 | return kmem_cache_alloc_node(cachep, flags, -1); |
9 | } | 10 | } |
10 | 11 | ||
11 | void *__kmalloc_node(size_t size, gfp_t flags, int node); | 12 | void *__kmalloc_node(size_t size, gfp_t flags, int node); |
12 | 13 | ||
13 | static inline void *kmalloc_node(size_t size, gfp_t flags, int node) | 14 | static __always_inline void *kmalloc_node(size_t size, gfp_t flags, int node) |
14 | { | 15 | { |
15 | return __kmalloc_node(size, flags, node); | 16 | return __kmalloc_node(size, flags, node); |
16 | } | 17 | } |
@@ -23,12 +24,12 @@ static inline void *kmalloc_node(size_t size, gfp_t flags, int node) | |||
23 | * kmalloc is the normal method of allocating memory | 24 | * kmalloc is the normal method of allocating memory |
24 | * in the kernel. | 25 | * in the kernel. |
25 | */ | 26 | */ |
26 | static inline void *kmalloc(size_t size, gfp_t flags) | 27 | static __always_inline void *kmalloc(size_t size, gfp_t flags) |
27 | { | 28 | { |
28 | return __kmalloc_node(size, flags, -1); | 29 | return __kmalloc_node(size, flags, -1); |
29 | } | 30 | } |
30 | 31 | ||
31 | static inline void *__kmalloc(size_t size, gfp_t flags) | 32 | static __always_inline void *__kmalloc(size_t size, gfp_t flags) |
32 | { | 33 | { |
33 | return kmalloc(size, flags); | 34 | return kmalloc(size, flags); |
34 | } | 35 | } |
diff --git a/include/linux/slub_def.h b/include/linux/slub_def.h index 2f5c16b1aacd..6b657f7dcb2b 100644 --- a/include/linux/slub_def.h +++ b/include/linux/slub_def.h | |||
@@ -10,6 +10,7 @@ | |||
10 | #include <linux/gfp.h> | 10 | #include <linux/gfp.h> |
11 | #include <linux/workqueue.h> | 11 | #include <linux/workqueue.h> |
12 | #include <linux/kobject.h> | 12 | #include <linux/kobject.h> |
13 | #include <trace/kmemtrace.h> | ||
13 | 14 | ||
14 | enum stat_item { | 15 | enum stat_item { |
15 | ALLOC_FASTPATH, /* Allocation from cpu slab */ | 16 | ALLOC_FASTPATH, /* Allocation from cpu slab */ |
@@ -204,13 +205,31 @@ static __always_inline struct kmem_cache *kmalloc_slab(size_t size) | |||
204 | void *kmem_cache_alloc(struct kmem_cache *, gfp_t); | 205 | void *kmem_cache_alloc(struct kmem_cache *, gfp_t); |
205 | void *__kmalloc(size_t size, gfp_t flags); | 206 | void *__kmalloc(size_t size, gfp_t flags); |
206 | 207 | ||
208 | #ifdef CONFIG_KMEMTRACE | ||
209 | extern void *kmem_cache_alloc_notrace(struct kmem_cache *s, gfp_t gfpflags); | ||
210 | #else | ||
211 | static __always_inline void * | ||
212 | kmem_cache_alloc_notrace(struct kmem_cache *s, gfp_t gfpflags) | ||
213 | { | ||
214 | return kmem_cache_alloc(s, gfpflags); | ||
215 | } | ||
216 | #endif | ||
217 | |||
207 | static __always_inline void *kmalloc_large(size_t size, gfp_t flags) | 218 | static __always_inline void *kmalloc_large(size_t size, gfp_t flags) |
208 | { | 219 | { |
209 | return (void *)__get_free_pages(flags | __GFP_COMP, get_order(size)); | 220 | unsigned int order = get_order(size); |
221 | void *ret = (void *) __get_free_pages(flags | __GFP_COMP, order); | ||
222 | |||
223 | kmemtrace_mark_alloc(KMEMTRACE_TYPE_KMALLOC, _THIS_IP_, ret, | ||
224 | size, PAGE_SIZE << order, flags); | ||
225 | |||
226 | return ret; | ||
210 | } | 227 | } |
211 | 228 | ||
212 | static __always_inline void *kmalloc(size_t size, gfp_t flags) | 229 | static __always_inline void *kmalloc(size_t size, gfp_t flags) |
213 | { | 230 | { |
231 | void *ret; | ||
232 | |||
214 | if (__builtin_constant_p(size)) { | 233 | if (__builtin_constant_p(size)) { |
215 | if (size > PAGE_SIZE) | 234 | if (size > PAGE_SIZE) |
216 | return kmalloc_large(size, flags); | 235 | return kmalloc_large(size, flags); |
@@ -221,7 +240,13 @@ static __always_inline void *kmalloc(size_t size, gfp_t flags) | |||
221 | if (!s) | 240 | if (!s) |
222 | return ZERO_SIZE_PTR; | 241 | return ZERO_SIZE_PTR; |
223 | 242 | ||
224 | return kmem_cache_alloc(s, flags); | 243 | ret = kmem_cache_alloc_notrace(s, flags); |
244 | |||
245 | kmemtrace_mark_alloc(KMEMTRACE_TYPE_KMALLOC, | ||
246 | _THIS_IP_, ret, | ||
247 | size, s->size, flags); | ||
248 | |||
249 | return ret; | ||
225 | } | 250 | } |
226 | } | 251 | } |
227 | return __kmalloc(size, flags); | 252 | return __kmalloc(size, flags); |
@@ -231,8 +256,24 @@ static __always_inline void *kmalloc(size_t size, gfp_t flags) | |||
231 | void *__kmalloc_node(size_t size, gfp_t flags, int node); | 256 | void *__kmalloc_node(size_t size, gfp_t flags, int node); |
232 | void *kmem_cache_alloc_node(struct kmem_cache *, gfp_t flags, int node); | 257 | void *kmem_cache_alloc_node(struct kmem_cache *, gfp_t flags, int node); |
233 | 258 | ||
259 | #ifdef CONFIG_KMEMTRACE | ||
260 | extern void *kmem_cache_alloc_node_notrace(struct kmem_cache *s, | ||
261 | gfp_t gfpflags, | ||
262 | int node); | ||
263 | #else | ||
264 | static __always_inline void * | ||
265 | kmem_cache_alloc_node_notrace(struct kmem_cache *s, | ||
266 | gfp_t gfpflags, | ||
267 | int node) | ||
268 | { | ||
269 | return kmem_cache_alloc_node(s, gfpflags, node); | ||
270 | } | ||
271 | #endif | ||
272 | |||
234 | static __always_inline void *kmalloc_node(size_t size, gfp_t flags, int node) | 273 | static __always_inline void *kmalloc_node(size_t size, gfp_t flags, int node) |
235 | { | 274 | { |
275 | void *ret; | ||
276 | |||
236 | if (__builtin_constant_p(size) && | 277 | if (__builtin_constant_p(size) && |
237 | size <= PAGE_SIZE && !(flags & SLUB_DMA)) { | 278 | size <= PAGE_SIZE && !(flags & SLUB_DMA)) { |
238 | struct kmem_cache *s = kmalloc_slab(size); | 279 | struct kmem_cache *s = kmalloc_slab(size); |
@@ -240,7 +281,13 @@ static __always_inline void *kmalloc_node(size_t size, gfp_t flags, int node) | |||
240 | if (!s) | 281 | if (!s) |
241 | return ZERO_SIZE_PTR; | 282 | return ZERO_SIZE_PTR; |
242 | 283 | ||
243 | return kmem_cache_alloc_node(s, flags, node); | 284 | ret = kmem_cache_alloc_node_notrace(s, flags, node); |
285 | |||
286 | kmemtrace_mark_alloc_node(KMEMTRACE_TYPE_KMALLOC, | ||
287 | _THIS_IP_, ret, | ||
288 | size, s->size, flags, node); | ||
289 | |||
290 | return ret; | ||
244 | } | 291 | } |
245 | return __kmalloc_node(size, flags, node); | 292 | return __kmalloc_node(size, flags, node); |
246 | } | 293 | } |