aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--kernel/trace/ftrace.c27
1 files changed, 27 insertions, 0 deletions
diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c
index 8c1c9c0f4775..7e9a20b69939 100644
--- a/kernel/trace/ftrace.c
+++ b/kernel/trace/ftrace.c
@@ -17,6 +17,7 @@
17#include <linux/clocksource.h> 17#include <linux/clocksource.h>
18#include <linux/kallsyms.h> 18#include <linux/kallsyms.h>
19#include <linux/seq_file.h> 19#include <linux/seq_file.h>
20#include <linux/suspend.h>
20#include <linux/debugfs.h> 21#include <linux/debugfs.h>
21#include <linux/hardirq.h> 22#include <linux/hardirq.h>
22#include <linux/kthread.h> 23#include <linux/kthread.h>
@@ -1957,6 +1958,7 @@ ftrace_enable_sysctl(struct ctl_table *table, int write,
1957#ifdef CONFIG_FUNCTION_GRAPH_TRACER 1958#ifdef CONFIG_FUNCTION_GRAPH_TRACER
1958 1959
1959static atomic_t ftrace_graph_active; 1960static atomic_t ftrace_graph_active;
1961static struct notifier_block ftrace_suspend_notifier;
1960 1962
1961int ftrace_graph_entry_stub(struct ftrace_graph_ent *trace) 1963int ftrace_graph_entry_stub(struct ftrace_graph_ent *trace)
1962{ 1964{
@@ -2035,6 +2037,27 @@ static int start_graph_tracing(void)
2035 return ret; 2037 return ret;
2036} 2038}
2037 2039
2040/*
2041 * Hibernation protection.
2042 * The state of the current task is too much unstable during
2043 * suspend/restore to disk. We want to protect against that.
2044 */
2045static int
2046ftrace_suspend_notifier_call(struct notifier_block *bl, unsigned long state,
2047 void *unused)
2048{
2049 switch (state) {
2050 case PM_HIBERNATION_PREPARE:
2051 pause_graph_tracing();
2052 break;
2053
2054 case PM_POST_HIBERNATION:
2055 unpause_graph_tracing();
2056 break;
2057 }
2058 return NOTIFY_DONE;
2059}
2060
2038int register_ftrace_graph(trace_func_graph_ret_t retfunc, 2061int register_ftrace_graph(trace_func_graph_ret_t retfunc,
2039 trace_func_graph_ent_t entryfunc) 2062 trace_func_graph_ent_t entryfunc)
2040{ 2063{
@@ -2042,6 +2065,9 @@ int register_ftrace_graph(trace_func_graph_ret_t retfunc,
2042 2065
2043 mutex_lock(&ftrace_sysctl_lock); 2066 mutex_lock(&ftrace_sysctl_lock);
2044 2067
2068 ftrace_suspend_notifier.notifier_call = ftrace_suspend_notifier_call;
2069 register_pm_notifier(&ftrace_suspend_notifier);
2070
2045 atomic_inc(&ftrace_graph_active); 2071 atomic_inc(&ftrace_graph_active);
2046 ret = start_graph_tracing(); 2072 ret = start_graph_tracing();
2047 if (ret) { 2073 if (ret) {
@@ -2067,6 +2093,7 @@ void unregister_ftrace_graph(void)
2067 ftrace_graph_return = (trace_func_graph_ret_t)ftrace_stub; 2093 ftrace_graph_return = (trace_func_graph_ret_t)ftrace_stub;
2068 ftrace_graph_entry = ftrace_graph_entry_stub; 2094 ftrace_graph_entry = ftrace_graph_entry_stub;
2069 ftrace_shutdown(FTRACE_STOP_FUNC_RET); 2095 ftrace_shutdown(FTRACE_STOP_FUNC_RET);
2096 unregister_pm_notifier(&ftrace_suspend_notifier);
2070 2097
2071 mutex_unlock(&ftrace_sysctl_lock); 2098 mutex_unlock(&ftrace_sysctl_lock);
2072} 2099}