aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/tracepoint.c
diff options
context:
space:
mode:
Diffstat (limited to 'kernel/tracepoint.c')
-rw-r--r--kernel/tracepoint.c38
1 files changed, 38 insertions, 0 deletions
diff --git a/kernel/tracepoint.c b/kernel/tracepoint.c
index 1ef5d3a601c7..070a42bb8920 100644
--- a/kernel/tracepoint.c
+++ b/kernel/tracepoint.c
@@ -24,6 +24,7 @@
24#include <linux/tracepoint.h> 24#include <linux/tracepoint.h>
25#include <linux/err.h> 25#include <linux/err.h>
26#include <linux/slab.h> 26#include <linux/slab.h>
27#include <linux/sched.h>
27 28
28extern struct tracepoint __start___tracepoints[]; 29extern struct tracepoint __start___tracepoints[];
29extern struct tracepoint __stop___tracepoints[]; 30extern struct tracepoint __stop___tracepoints[];
@@ -577,3 +578,40 @@ static int init_tracepoints(void)
577__initcall(init_tracepoints); 578__initcall(init_tracepoints);
578 579
579#endif /* CONFIG_MODULES */ 580#endif /* CONFIG_MODULES */
581
582static DEFINE_MUTEX(regfunc_mutex);
583static int sys_tracepoint_refcount;
584
585void syscall_regfunc(void)
586{
587 unsigned long flags;
588 struct task_struct *g, *t;
589
590 mutex_lock(&regfunc_mutex);
591 if (!sys_tracepoint_refcount) {
592 read_lock_irqsave(&tasklist_lock, flags);
593 do_each_thread(g, t) {
594 set_tsk_thread_flag(t, TIF_SYSCALL_FTRACE);
595 } while_each_thread(g, t);
596 read_unlock_irqrestore(&tasklist_lock, flags);
597 }
598 sys_tracepoint_refcount++;
599 mutex_unlock(&regfunc_mutex);
600}
601
602void syscall_unregfunc(void)
603{
604 unsigned long flags;
605 struct task_struct *g, *t;
606
607 mutex_lock(&regfunc_mutex);
608 sys_tracepoint_refcount--;
609 if (!sys_tracepoint_refcount) {
610 read_lock_irqsave(&tasklist_lock, flags);
611 do_each_thread(g, t) {
612 clear_tsk_thread_flag(t, TIF_SYSCALL_FTRACE);
613 } while_each_thread(g, t);
614 read_unlock_irqrestore(&tasklist_lock, flags);
615 }
616 mutex_unlock(&regfunc_mutex);
617}