diff options
Diffstat (limited to 'kernel/tracepoint.c')
-rw-r--r-- | kernel/tracepoint.c | 38 |
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 | ||
28 | extern struct tracepoint __start___tracepoints[]; | 29 | extern struct tracepoint __start___tracepoints[]; |
29 | extern struct tracepoint __stop___tracepoints[]; | 30 | extern 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 | |||
582 | static DEFINE_MUTEX(regfunc_mutex); | ||
583 | static int sys_tracepoint_refcount; | ||
584 | |||
585 | void syscall_regfunc(void) | ||
586 | { | ||
587 | unsigned long flags; | ||
588 | struct task_struct *g, *t; | ||
589 | |||
590 | mutex_lock(®func_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(®func_mutex); | ||
600 | } | ||
601 | |||
602 | void syscall_unregfunc(void) | ||
603 | { | ||
604 | unsigned long flags; | ||
605 | struct task_struct *g, *t; | ||
606 | |||
607 | mutex_lock(®func_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(®func_mutex); | ||
617 | } | ||