diff options
author | Oleg Nesterov <oleg@redhat.com> | 2014-04-13 14:59:18 -0400 |
---|---|---|
committer | Steven Rostedt <rostedt@goodmis.org> | 2014-06-21 00:15:25 -0400 |
commit | 8063e41d2ffc0b0ce974ea802158be35902072f3 (patch) | |
tree | 27787dcbf46b42a1737c4668673eb249b9304038 | |
parent | 4af4206be2bd1933cae20c2b6fb2058dbc887f7c (diff) |
tracing: Change syscall_*regfunc() to check PF_KTHREAD and use for_each_process_thread()
1. Remove _irqsafe from syscall_regfunc/syscall_unregfunc,
read_lock(tasklist) doesn't need to disable irqs.
2. Change this code to avoid the deprecated do_each_thread()
and use for_each_process_thread() (stolen from the patch
from Frederic).
3. Change syscall_regfunc() to check PF_KTHREAD to skip
the kernel threads, ->mm != NULL is the common mistake.
Note: probably this check should be simply removed, needs
another patch.
[fweisbec@gmail.com: s/do_each_thread/for_each_process_thread/]
Link: http://lkml.kernel.org/p/20140413185918.GC20668@redhat.com
Signed-off-by: Oleg Nesterov <oleg@redhat.com>
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
-rw-r--r-- | kernel/tracepoint.c | 24 |
1 files changed, 11 insertions, 13 deletions
diff --git a/kernel/tracepoint.c b/kernel/tracepoint.c index 33cbd8c203f8..9cf12640de5a 100644 --- a/kernel/tracepoint.c +++ b/kernel/tracepoint.c | |||
@@ -492,33 +492,31 @@ static int sys_tracepoint_refcount; | |||
492 | 492 | ||
493 | void syscall_regfunc(void) | 493 | void syscall_regfunc(void) |
494 | { | 494 | { |
495 | unsigned long flags; | 495 | struct task_struct *p, *t; |
496 | struct task_struct *g, *t; | ||
497 | 496 | ||
498 | if (!sys_tracepoint_refcount) { | 497 | if (!sys_tracepoint_refcount) { |
499 | read_lock_irqsave(&tasklist_lock, flags); | 498 | read_lock(&tasklist_lock); |
500 | do_each_thread(g, t) { | 499 | for_each_process_thread(p, t) { |
501 | /* Skip kernel threads. */ | 500 | /* Skip kernel threads. */ |
502 | if (t->mm) | 501 | if (!(t->flags & PF_KTHREAD)) |
503 | set_tsk_thread_flag(t, TIF_SYSCALL_TRACEPOINT); | 502 | set_tsk_thread_flag(t, TIF_SYSCALL_TRACEPOINT); |
504 | } while_each_thread(g, t); | 503 | } |
505 | read_unlock_irqrestore(&tasklist_lock, flags); | 504 | read_unlock(&tasklist_lock); |
506 | } | 505 | } |
507 | sys_tracepoint_refcount++; | 506 | sys_tracepoint_refcount++; |
508 | } | 507 | } |
509 | 508 | ||
510 | void syscall_unregfunc(void) | 509 | void syscall_unregfunc(void) |
511 | { | 510 | { |
512 | unsigned long flags; | 511 | struct task_struct *p, *t; |
513 | struct task_struct *g, *t; | ||
514 | 512 | ||
515 | sys_tracepoint_refcount--; | 513 | sys_tracepoint_refcount--; |
516 | if (!sys_tracepoint_refcount) { | 514 | if (!sys_tracepoint_refcount) { |
517 | read_lock_irqsave(&tasklist_lock, flags); | 515 | read_lock(&tasklist_lock); |
518 | do_each_thread(g, t) { | 516 | for_each_process_thread(p, t) { |
519 | clear_tsk_thread_flag(t, TIF_SYSCALL_TRACEPOINT); | 517 | clear_tsk_thread_flag(t, TIF_SYSCALL_TRACEPOINT); |
520 | } while_each_thread(g, t); | 518 | } |
521 | read_unlock_irqrestore(&tasklist_lock, flags); | 519 | read_unlock(&tasklist_lock); |
522 | } | 520 | } |
523 | } | 521 | } |
524 | #endif | 522 | #endif |