Skip to content

Commit

Permalink
tracing: Change syscall_*regfunc() to check PF_KTHREAD and use for_ea…
Browse files Browse the repository at this point in the history
…ch_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.

[[email protected]: s/do_each_thread/for_each_process_thread/]
Link: http://lkml.kernel.org/p/[email protected]

Signed-off-by: Oleg Nesterov <[email protected]>
Signed-off-by: Steven Rostedt <[email protected]>
  • Loading branch information
oleg-nesterov authored and rostedt committed Jun 21, 2014
1 parent 4af4206 commit 8063e41
Showing 1 changed file with 11 additions and 13 deletions.
24 changes: 11 additions & 13 deletions kernel/tracepoint.c
Original file line number Diff line number Diff line change
Expand Up @@ -492,33 +492,31 @@ static int sys_tracepoint_refcount;

void syscall_regfunc(void)
{
unsigned long flags;
struct task_struct *g, *t;
struct task_struct *p, *t;

if (!sys_tracepoint_refcount) {
read_lock_irqsave(&tasklist_lock, flags);
do_each_thread(g, t) {
read_lock(&tasklist_lock);
for_each_process_thread(p, t) {
/* Skip kernel threads. */
if (t->mm)
if (!(t->flags & PF_KTHREAD))
set_tsk_thread_flag(t, TIF_SYSCALL_TRACEPOINT);
} while_each_thread(g, t);
read_unlock_irqrestore(&tasklist_lock, flags);
}
read_unlock(&tasklist_lock);
}
sys_tracepoint_refcount++;
}

void syscall_unregfunc(void)
{
unsigned long flags;
struct task_struct *g, *t;
struct task_struct *p, *t;

sys_tracepoint_refcount--;
if (!sys_tracepoint_refcount) {
read_lock_irqsave(&tasklist_lock, flags);
do_each_thread(g, t) {
read_lock(&tasklist_lock);
for_each_process_thread(p, t) {
clear_tsk_thread_flag(t, TIF_SYSCALL_TRACEPOINT);
} while_each_thread(g, t);
read_unlock_irqrestore(&tasklist_lock, flags);
}
read_unlock(&tasklist_lock);
}
}
#endif

0 comments on commit 8063e41

Please sign in to comment.