summaryrefslogtreecommitdiffstats
path: root/kernel/tracepoint.c
diff options
context:
space:
mode:
authorSteven Rostedt (Red Hat) <rostedt@goodmis.org>2016-11-28 13:03:21 -0500
committerSteven Rostedt <rostedt@goodmis.org>2016-12-09 09:13:30 -0500
commit8cf868affdc459beee1a941df0cfaba1673740e3 (patch)
tree64dd73ba504f458831177e091f90f0324962d226 /kernel/tracepoint.c
parent38e11df134297ea3860c7aad8263ece27db01308 (diff)
tracing: Have the reg function allow to fail
Some tracepoints have a registration function that gets enabled when the tracepoint is enabled. There may be cases that the registraction function must fail (for example, can't allocate enough memory). In this case, the tracepoint should also fail to register, otherwise the user would not know why the tracepoint is not working. Cc: David Howells <dhowells@redhat.com> Cc: Seiji Aguchi <seiji.aguchi@hds.com> Cc: Anton Blanchard <anton@samba.org> Cc: Mathieu Desnoyers <mathieu.desnoyers@efficios.com> Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
Diffstat (limited to 'kernel/tracepoint.c')
-rw-r--r--kernel/tracepoint.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/kernel/tracepoint.c b/kernel/tracepoint.c
index d0639d917899..1f9a31f934a4 100644
--- a/kernel/tracepoint.c
+++ b/kernel/tracepoint.c
@@ -194,9 +194,13 @@ static int tracepoint_add_func(struct tracepoint *tp,
194 struct tracepoint_func *func, int prio) 194 struct tracepoint_func *func, int prio)
195{ 195{
196 struct tracepoint_func *old, *tp_funcs; 196 struct tracepoint_func *old, *tp_funcs;
197 int ret;
197 198
198 if (tp->regfunc && !static_key_enabled(&tp->key)) 199 if (tp->regfunc && !static_key_enabled(&tp->key)) {
199 tp->regfunc(); 200 ret = tp->regfunc();
201 if (ret < 0)
202 return ret;
203 }
200 204
201 tp_funcs = rcu_dereference_protected(tp->funcs, 205 tp_funcs = rcu_dereference_protected(tp->funcs,
202 lockdep_is_held(&tracepoints_mutex)); 206 lockdep_is_held(&tracepoints_mutex));
@@ -529,7 +533,7 @@ EXPORT_SYMBOL_GPL(for_each_kernel_tracepoint);
529/* NB: reg/unreg are called while guarded with the tracepoints_mutex */ 533/* NB: reg/unreg are called while guarded with the tracepoints_mutex */
530static int sys_tracepoint_refcount; 534static int sys_tracepoint_refcount;
531 535
532void syscall_regfunc(void) 536int syscall_regfunc(void)
533{ 537{
534 struct task_struct *p, *t; 538 struct task_struct *p, *t;
535 539
@@ -541,6 +545,8 @@ void syscall_regfunc(void)
541 read_unlock(&tasklist_lock); 545 read_unlock(&tasklist_lock);
542 } 546 }
543 sys_tracepoint_refcount++; 547 sys_tracepoint_refcount++;
548
549 return 0;
544} 550}
545 551
546void syscall_unregfunc(void) 552void syscall_unregfunc(void)