Skip to content

Commit 8063e41

Browse files
oleg-nesterovrostedt
authored andcommitted
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>
1 parent 4af4206 commit 8063e41

1 file changed

Lines changed: 11 additions & 13 deletions

File tree

‎kernel/tracepoint.c‎

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -492,33 +492,31 @@ static int sys_tracepoint_refcount;
492492

493493
void syscall_regfunc(void)
494494
{
495-
unsigned long flags;
496-
struct task_struct *g, *t;
495+
struct task_struct *p, *t;
497496

498497
if (!sys_tracepoint_refcount) {
499-
read_lock_irqsave(&tasklist_lock, flags);
500-
do_each_thread(g, t) {
498+
read_lock(&tasklist_lock);
499+
for_each_process_thread(p, t) {
501500
/* Skip kernel threads. */
502-
if (t->mm)
501+
if (!(t->flags & PF_KTHREAD))
503502
set_tsk_thread_flag(t, TIF_SYSCALL_TRACEPOINT);
504-
} while_each_thread(g, t);
505-
read_unlock_irqrestore(&tasklist_lock, flags);
503+
}
504+
read_unlock(&tasklist_lock);
506505
}
507506
sys_tracepoint_refcount++;
508507
}
509508

510509
void syscall_unregfunc(void)
511510
{
512-
unsigned long flags;
513-
struct task_struct *g, *t;
511+
struct task_struct *p, *t;
514512

515513
sys_tracepoint_refcount--;
516514
if (!sys_tracepoint_refcount) {
517-
read_lock_irqsave(&tasklist_lock, flags);
518-
do_each_thread(g, t) {
515+
read_lock(&tasklist_lock);
516+
for_each_process_thread(p, t) {
519517
clear_tsk_thread_flag(t, TIF_SYSCALL_TRACEPOINT);
520-
} while_each_thread(g, t);
521-
read_unlock_irqrestore(&tasklist_lock, flags);
518+
}
519+
read_unlock(&tasklist_lock);
522520
}
523521
}
524522
#endif

0 commit comments

Comments
 (0)