Commit 747774d6 authored by Masami Hiramatsu's avatar Masami Hiramatsu Committed by Steven Rostedt (VMware)

tracing/probe: Add trace flag access APIs for trace_probe

Add trace_probe_test/set/clear_flag() functions for accessing
trace_probe.flag field.
This flags field should not be accessed directly.

Link: http://lkml.kernel.org/r/155931585683.28323.314290023236905988.stgit@devnote2Signed-off-by: default avatarMasami Hiramatsu <mhiramat@kernel.org>
Signed-off-by: default avatarSteven Rostedt (VMware) <rostedt@goodmis.org>
parent b5f935ee
...@@ -298,7 +298,7 @@ enable_trace_kprobe(struct trace_kprobe *tk, struct trace_event_file *file) ...@@ -298,7 +298,7 @@ enable_trace_kprobe(struct trace_kprobe *tk, struct trace_event_file *file)
if (ret) if (ret)
return ret; return ret;
} else } else
tk->tp.flags |= TP_FLAG_PROFILE; trace_probe_set_flag(&tk->tp, TP_FLAG_PROFILE);
if (enabled) if (enabled)
return 0; return 0;
...@@ -308,7 +308,7 @@ enable_trace_kprobe(struct trace_kprobe *tk, struct trace_event_file *file) ...@@ -308,7 +308,7 @@ enable_trace_kprobe(struct trace_kprobe *tk, struct trace_event_file *file)
if (file) if (file)
trace_probe_remove_file(&tk->tp, file); trace_probe_remove_file(&tk->tp, file);
else else
tk->tp.flags &= ~TP_FLAG_PROFILE; trace_probe_clear_flag(&tk->tp, TP_FLAG_PROFILE);
} }
return ret; return ret;
...@@ -329,9 +329,9 @@ disable_trace_kprobe(struct trace_kprobe *tk, struct trace_event_file *file) ...@@ -329,9 +329,9 @@ disable_trace_kprobe(struct trace_kprobe *tk, struct trace_event_file *file)
return -ENOENT; return -ENOENT;
if (!trace_probe_has_single_file(tp)) if (!trace_probe_has_single_file(tp))
goto out; goto out;
tp->flags &= ~TP_FLAG_TRACE; trace_probe_clear_flag(tp, TP_FLAG_TRACE);
} else } else
tp->flags &= ~TP_FLAG_PROFILE; trace_probe_clear_flag(tp, TP_FLAG_PROFILE);
if (!trace_probe_is_enabled(tp) && trace_probe_is_registered(tp)) { if (!trace_probe_is_enabled(tp) && trace_probe_is_registered(tp)) {
if (trace_kprobe_is_return(tk)) if (trace_kprobe_is_return(tk))
...@@ -408,7 +408,7 @@ static int __register_trace_kprobe(struct trace_kprobe *tk) ...@@ -408,7 +408,7 @@ static int __register_trace_kprobe(struct trace_kprobe *tk)
ret = register_kprobe(&tk->rp.kp); ret = register_kprobe(&tk->rp.kp);
if (ret == 0) if (ret == 0)
tk->tp.flags |= TP_FLAG_REGISTERED; trace_probe_set_flag(&tk->tp, TP_FLAG_REGISTERED);
return ret; return ret;
} }
...@@ -420,7 +420,7 @@ static void __unregister_trace_kprobe(struct trace_kprobe *tk) ...@@ -420,7 +420,7 @@ static void __unregister_trace_kprobe(struct trace_kprobe *tk)
unregister_kretprobe(&tk->rp); unregister_kretprobe(&tk->rp);
else else
unregister_kprobe(&tk->rp.kp); unregister_kprobe(&tk->rp.kp);
tk->tp.flags &= ~TP_FLAG_REGISTERED; trace_probe_clear_flag(&tk->tp, TP_FLAG_REGISTERED);
/* Cleanup kprobe for reuse */ /* Cleanup kprobe for reuse */
if (tk->rp.kp.symbol_name) if (tk->rp.kp.symbol_name)
tk->rp.kp.addr = NULL; tk->rp.kp.addr = NULL;
...@@ -1313,10 +1313,10 @@ static int kprobe_dispatcher(struct kprobe *kp, struct pt_regs *regs) ...@@ -1313,10 +1313,10 @@ static int kprobe_dispatcher(struct kprobe *kp, struct pt_regs *regs)
raw_cpu_inc(*tk->nhit); raw_cpu_inc(*tk->nhit);
if (tk->tp.flags & TP_FLAG_TRACE) if (trace_probe_test_flag(&tk->tp, TP_FLAG_TRACE))
kprobe_trace_func(tk, regs); kprobe_trace_func(tk, regs);
#ifdef CONFIG_PERF_EVENTS #ifdef CONFIG_PERF_EVENTS
if (tk->tp.flags & TP_FLAG_PROFILE) if (trace_probe_test_flag(&tk->tp, TP_FLAG_PROFILE))
ret = kprobe_perf_func(tk, regs); ret = kprobe_perf_func(tk, regs);
#endif #endif
return ret; return ret;
...@@ -1330,10 +1330,10 @@ kretprobe_dispatcher(struct kretprobe_instance *ri, struct pt_regs *regs) ...@@ -1330,10 +1330,10 @@ kretprobe_dispatcher(struct kretprobe_instance *ri, struct pt_regs *regs)
raw_cpu_inc(*tk->nhit); raw_cpu_inc(*tk->nhit);
if (tk->tp.flags & TP_FLAG_TRACE) if (trace_probe_test_flag(&tk->tp, TP_FLAG_TRACE))
kretprobe_trace_func(tk, ri, regs); kretprobe_trace_func(tk, ri, regs);
#ifdef CONFIG_PERF_EVENTS #ifdef CONFIG_PERF_EVENTS
if (tk->tp.flags & TP_FLAG_PROFILE) if (trace_probe_test_flag(&tk->tp, TP_FLAG_PROFILE))
kretprobe_perf_func(tk, ri, regs); kretprobe_perf_func(tk, ri, regs);
#endif #endif
return 0; /* We don't tweek kernel, so just return 0 */ return 0; /* We don't tweek kernel, so just return 0 */
......
...@@ -948,7 +948,7 @@ int trace_probe_add_file(struct trace_probe *tp, struct trace_event_file *file) ...@@ -948,7 +948,7 @@ int trace_probe_add_file(struct trace_probe *tp, struct trace_event_file *file)
link->file = file; link->file = file;
INIT_LIST_HEAD(&link->list); INIT_LIST_HEAD(&link->list);
list_add_tail_rcu(&link->list, &tp->files); list_add_tail_rcu(&link->list, &tp->files);
tp->flags |= TP_FLAG_TRACE; trace_probe_set_flag(tp, TP_FLAG_TRACE);
return 0; return 0;
} }
...@@ -979,7 +979,7 @@ int trace_probe_remove_file(struct trace_probe *tp, ...@@ -979,7 +979,7 @@ int trace_probe_remove_file(struct trace_probe *tp,
kfree(link); kfree(link);
if (list_empty(&tp->files)) if (list_empty(&tp->files))
tp->flags &= ~TP_FLAG_TRACE; trace_probe_clear_flag(tp, TP_FLAG_TRACE);
return 0; return 0;
} }
...@@ -238,14 +238,32 @@ struct event_file_link { ...@@ -238,14 +238,32 @@ struct event_file_link {
struct list_head list; struct list_head list;
}; };
static inline bool trace_probe_test_flag(struct trace_probe *tp,
unsigned int flag)
{
return !!(tp->flags & flag);
}
static inline void trace_probe_set_flag(struct trace_probe *tp,
unsigned int flag)
{
tp->flags |= flag;
}
static inline void trace_probe_clear_flag(struct trace_probe *tp,
unsigned int flag)
{
tp->flags &= ~flag;
}
static inline bool trace_probe_is_enabled(struct trace_probe *tp) static inline bool trace_probe_is_enabled(struct trace_probe *tp)
{ {
return !!(tp->flags & (TP_FLAG_TRACE | TP_FLAG_PROFILE)); return trace_probe_test_flag(tp, TP_FLAG_TRACE | TP_FLAG_PROFILE);
} }
static inline bool trace_probe_is_registered(struct trace_probe *tp) static inline bool trace_probe_is_registered(struct trace_probe *tp)
{ {
return !!(tp->flags & TP_FLAG_REGISTERED); return trace_probe_test_flag(tp, TP_FLAG_REGISTERED);
} }
static inline int trace_probe_unregister_event_call(struct trace_probe *tp) static inline int trace_probe_unregister_event_call(struct trace_probe *tp)
......
...@@ -927,17 +927,17 @@ probe_event_enable(struct trace_uprobe *tu, struct trace_event_file *file, ...@@ -927,17 +927,17 @@ probe_event_enable(struct trace_uprobe *tu, struct trace_event_file *file,
int ret; int ret;
if (file) { if (file) {
if (tu->tp.flags & TP_FLAG_PROFILE) if (trace_probe_test_flag(&tu->tp, TP_FLAG_PROFILE))
return -EINTR; return -EINTR;
ret = trace_probe_add_file(&tu->tp, file); ret = trace_probe_add_file(&tu->tp, file);
if (ret < 0) if (ret < 0)
return ret; return ret;
} else { } else {
if (tu->tp.flags & TP_FLAG_TRACE) if (trace_probe_test_flag(&tu->tp, TP_FLAG_TRACE))
return -EINTR; return -EINTR;
tu->tp.flags |= TP_FLAG_PROFILE; trace_probe_set_flag(&tu->tp, TP_FLAG_PROFILE);
} }
WARN_ON(!uprobe_filter_is_empty(&tu->filter)); WARN_ON(!uprobe_filter_is_empty(&tu->filter));
...@@ -970,7 +970,7 @@ probe_event_enable(struct trace_uprobe *tu, struct trace_event_file *file, ...@@ -970,7 +970,7 @@ probe_event_enable(struct trace_uprobe *tu, struct trace_event_file *file,
if (file) if (file)
trace_probe_remove_file(&tu->tp, file); trace_probe_remove_file(&tu->tp, file);
else else
tu->tp.flags &= ~TP_FLAG_PROFILE; trace_probe_clear_flag(&tu->tp, TP_FLAG_PROFILE);
return ret; return ret;
} }
...@@ -988,7 +988,7 @@ probe_event_disable(struct trace_uprobe *tu, struct trace_event_file *file) ...@@ -988,7 +988,7 @@ probe_event_disable(struct trace_uprobe *tu, struct trace_event_file *file)
if (trace_probe_is_enabled(&tu->tp)) if (trace_probe_is_enabled(&tu->tp))
return; return;
} else } else
tu->tp.flags &= ~TP_FLAG_PROFILE; trace_probe_clear_flag(&tu->tp, TP_FLAG_PROFILE);
WARN_ON(!uprobe_filter_is_empty(&tu->filter)); WARN_ON(!uprobe_filter_is_empty(&tu->filter));
...@@ -1266,11 +1266,11 @@ static int uprobe_dispatcher(struct uprobe_consumer *con, struct pt_regs *regs) ...@@ -1266,11 +1266,11 @@ static int uprobe_dispatcher(struct uprobe_consumer *con, struct pt_regs *regs)
ucb = uprobe_buffer_get(); ucb = uprobe_buffer_get();
store_trace_args(ucb->buf, &tu->tp, regs, esize, dsize); store_trace_args(ucb->buf, &tu->tp, regs, esize, dsize);
if (tu->tp.flags & TP_FLAG_TRACE) if (trace_probe_test_flag(&tu->tp, TP_FLAG_TRACE))
ret |= uprobe_trace_func(tu, regs, ucb, dsize); ret |= uprobe_trace_func(tu, regs, ucb, dsize);
#ifdef CONFIG_PERF_EVENTS #ifdef CONFIG_PERF_EVENTS
if (tu->tp.flags & TP_FLAG_PROFILE) if (trace_probe_test_flag(&tu->tp, TP_FLAG_PROFILE))
ret |= uprobe_perf_func(tu, regs, ucb, dsize); ret |= uprobe_perf_func(tu, regs, ucb, dsize);
#endif #endif
uprobe_buffer_put(ucb); uprobe_buffer_put(ucb);
...@@ -1301,11 +1301,11 @@ static int uretprobe_dispatcher(struct uprobe_consumer *con, ...@@ -1301,11 +1301,11 @@ static int uretprobe_dispatcher(struct uprobe_consumer *con,
ucb = uprobe_buffer_get(); ucb = uprobe_buffer_get();
store_trace_args(ucb->buf, &tu->tp, regs, esize, dsize); store_trace_args(ucb->buf, &tu->tp, regs, esize, dsize);
if (tu->tp.flags & TP_FLAG_TRACE) if (trace_probe_test_flag(&tu->tp, TP_FLAG_TRACE))
uretprobe_trace_func(tu, func, regs, ucb, dsize); uretprobe_trace_func(tu, func, regs, ucb, dsize);
#ifdef CONFIG_PERF_EVENTS #ifdef CONFIG_PERF_EVENTS
if (tu->tp.flags & TP_FLAG_PROFILE) if (trace_probe_test_flag(&tu->tp, TP_FLAG_PROFILE))
uretprobe_perf_func(tu, func, regs, ucb, dsize); uretprobe_perf_func(tu, func, regs, ucb, dsize);
#endif #endif
uprobe_buffer_put(ucb); uprobe_buffer_put(ucb);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment