]>
Commit | Line | Data |
---|---|---|
0db1477e GKH |
1 | From ef99b88b16bee753fa51207abdc58ae660453ec6 Mon Sep 17 00:00:00 2001 |
2 | From: Rabin Vincent <rabin@rab.in> | |
3 | Date: Mon, 13 Apr 2015 22:30:12 +0200 | |
4 | Subject: tracing: Handle ftrace_dump() atomic context in graph_trace_open() | |
5 | ||
6 | From: Rabin Vincent <rabin@rab.in> | |
7 | ||
8 | commit ef99b88b16bee753fa51207abdc58ae660453ec6 upstream. | |
9 | ||
10 | graph_trace_open() can be called in atomic context from ftrace_dump(). | |
11 | Use GFP_ATOMIC for the memory allocations when that's the case, in order | |
12 | to avoid the following splat. | |
13 | ||
14 | BUG: sleeping function called from invalid context at mm/slab.c:2849 | |
15 | in_atomic(): 1, irqs_disabled(): 128, pid: 0, name: swapper/0 | |
16 | Backtrace: | |
17 | .. | |
18 | [<8004dc94>] (__might_sleep) from [<801371f4>] (kmem_cache_alloc_trace+0x160/0x238) | |
19 | r7:87800040 r6:000080d0 r5:810d16e8 r4:000080d0 | |
20 | [<80137094>] (kmem_cache_alloc_trace) from [<800cbd60>] (graph_trace_open+0x30/0xd0) | |
21 | r10:00000100 r9:809171a8 r8:00008e28 r7:810d16f0 r6:00000001 r5:810d16e8 | |
22 | r4:810d16f0 | |
23 | [<800cbd30>] (graph_trace_open) from [<800c79c4>] (trace_init_global_iter+0x50/0x9c) | |
24 | r8:00008e28 r7:808c853c r6:00000001 r5:810d16e8 r4:810d16f0 r3:800cbd30 | |
25 | [<800c7974>] (trace_init_global_iter) from [<800c7aa0>] (ftrace_dump+0x90/0x2ec) | |
26 | r4:810d2580 r3:00000000 | |
27 | [<800c7a10>] (ftrace_dump) from [<80414b2c>] (sysrq_ftrace_dump+0x1c/0x20) | |
28 | r10:00000100 r9:809171a8 r8:808f6e7c r7:00000001 r6:00000007 r5:0000007a | |
29 | r4:808d5394 | |
30 | [<80414b10>] (sysrq_ftrace_dump) from [<800169b8>] (return_to_handler+0x0/0x18) | |
31 | [<80415498>] (__handle_sysrq) from [<800169b8>] (return_to_handler+0x0/0x18) | |
32 | r8:808c8100 r7:808c8444 r6:00000101 r5:00000010 r4:84eb3210 | |
33 | [<80415668>] (handle_sysrq) from [<800169b8>] (return_to_handler+0x0/0x18) | |
34 | [<8042a760>] (pl011_int) from [<800169b8>] (return_to_handler+0x0/0x18) | |
35 | r10:809171bc r9:809171a8 r8:00000001 r7:00000026 r6:808c6000 r5:84f01e60 | |
36 | r4:8454fe00 | |
37 | [<8007782c>] (handle_irq_event_percpu) from [<80077b44>] (handle_irq_event+0x4c/0x6c) | |
38 | r10:808c7ef0 r9:87283e00 r8:00000001 r7:00000000 r6:8454fe00 r5:84f01e60 | |
39 | r4:84f01e00 | |
40 | [<80077af8>] (handle_irq_event) from [<8007aa28>] (handle_fasteoi_irq+0xf0/0x1ac) | |
41 | r6:808f52a4 r5:84f01e60 r4:84f01e00 r3:00000000 | |
42 | [<8007a938>] (handle_fasteoi_irq) from [<80076dc0>] (generic_handle_irq+0x3c/0x4c) | |
43 | r6:00000026 r5:00000000 r4:00000026 r3:8007a938 | |
44 | [<80076d84>] (generic_handle_irq) from [<80077128>] (__handle_domain_irq+0x8c/0xfc) | |
45 | r4:808c1e38 r3:0000002e | |
46 | [<8007709c>] (__handle_domain_irq) from [<800087b8>] (gic_handle_irq+0x34/0x6c) | |
47 | r10:80917748 r9:00000001 r8:88802100 r7:808c7ef0 r6:808c8fb0 r5:00000015 | |
48 | r4:8880210c r3:808c7ef0 | |
49 | [<80008784>] (gic_handle_irq) from [<80014044>] (__irq_svc+0x44/0x7c) | |
50 | ||
51 | Link: http://lkml.kernel.org/r/1428953721-31349-1-git-send-email-rabin@rab.in | |
52 | Link: http://lkml.kernel.org/r/1428957012-2319-1-git-send-email-rabin@rab.in | |
53 | ||
54 | Signed-off-by: Rabin Vincent <rabin@rab.in> | |
55 | Signed-off-by: Steven Rostedt <rostedt@goodmis.org> | |
56 | Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> | |
57 | ||
58 | --- | |
59 | kernel/trace/trace_functions_graph.c | 8 ++++++-- | |
60 | 1 file changed, 6 insertions(+), 2 deletions(-) | |
61 | ||
62 | --- a/kernel/trace/trace_functions_graph.c | |
63 | +++ b/kernel/trace/trace_functions_graph.c | |
64 | @@ -1309,15 +1309,19 @@ void graph_trace_open(struct trace_itera | |
65 | { | |
66 | /* pid and depth on the last trace processed */ | |
67 | struct fgraph_data *data; | |
68 | + gfp_t gfpflags; | |
69 | int cpu; | |
70 | ||
71 | iter->private = NULL; | |
72 | ||
73 | - data = kzalloc(sizeof(*data), GFP_KERNEL); | |
74 | + /* We can be called in atomic context via ftrace_dump() */ | |
75 | + gfpflags = (in_atomic() || irqs_disabled()) ? GFP_ATOMIC : GFP_KERNEL; | |
76 | + | |
77 | + data = kzalloc(sizeof(*data), gfpflags); | |
78 | if (!data) | |
79 | goto out_err; | |
80 | ||
81 | - data->cpu_data = alloc_percpu(struct fgraph_cpu_data); | |
82 | + data->cpu_data = alloc_percpu_gfp(struct fgraph_cpu_data, gfpflags); | |
83 | if (!data->cpu_data) | |
84 | goto out_err_free; | |
85 |