summaryrefslogtreecommitdiffstats
path: root/trace-function-profiler-band-aid.patch
blob: 56b492afbb42d10901d2f9d3fcc993f78bc71833 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
From cc5585a60d6c094bb15a1a748174d96699d296c4 Mon Sep 17 00:00:00 2001
From: Luis Claudio R. Goncalves <lclaudio@uudg.org>
Date: Fri, 3 Jul 2009 13:16:33 -0500
Subject: [PATCH] trace: function profiler band-aid

commit dea2d9a0550f1a8da36a380567b61de9d9a83208 in tip.

Kernel Panic when stressing ftrace function_profiler

https://bugzilla.redhat.com/show_bug.cgi?id=500156

This patch does not fix the whole issue but removes a few probable spots
where the panic could originate from.

	[root@void ~]#  while true
	>  do echo "starting new test..."
	> ./function_profiler.sh sleep 2 > /dev/null
	> dmesg -c
	> ./function_profiler.sh ls -la > /dev/null
	> dmesg -c;
	> done
	starting new test...
	starting new test...
	...
	Kernel panic - not syncing: Fatal exception

Signed-off-by: Luis Claudio R. Goncalves <lgoncalv@redhat.com>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com>
---
 kernel/trace/ftrace.c                |    3 ++-
 kernel/trace/trace_functions_graph.c |    2 +-
 2 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c
index 2404b59..a05e769 100644
--- a/kernel/trace/ftrace.c
+++ b/kernel/trace/ftrace.c
@@ -392,7 +392,8 @@ static int function_stat_show(struct seq_file *m, void *v)
 #ifdef CONFIG_FUNCTION_GRAPH_TRACER
 	seq_printf(m, "    ");
 	avg = rec->time;
-	do_div(avg, rec->counter);
+	if (rec->counter)
+		do_div(avg, rec->counter);
 
 	mutex_lock(&mutex);
 	trace_seq_init(&s);
diff --git a/kernel/trace/trace_functions_graph.c b/kernel/trace/trace_functions_graph.c
index 9aed1a5..974bc47 100644
--- a/kernel/trace/trace_functions_graph.c
+++ b/kernel/trace/trace_functions_graph.c
@@ -628,7 +628,7 @@ trace_print_graph_duration(unsigned long long duration, struct trace_seq *s)
 	int ret, len;
 	int i;
 
-	sprintf(msecs_str, "%lu", (unsigned long) duration);
+	snprintf(msecs_str, sizeof(msecs_str), "%lu", (unsigned long) duration);
 
 	/* Print msecs */
 	ret = trace_seq_printf(s, "%s", msecs_str);
-- 
1.7.0.4