lkml.org 
[lkml]   [2014]   [Apr]   [9]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
SubjectRe: [PATCH 2/5] tracepoint: Convert process iteration to use for_each_process_thread()
On Wed, Apr 09, 2014 at 04:28:35PM +0000, Mathieu Desnoyers wrote:
> ----- Original Message -----
> > From: "Frederic Weisbecker" <fweisbec@gmail.com>
> > To: "LKML" <linux-kernel@vger.kernel.org>
> > Cc: "Frederic Weisbecker" <fweisbec@gmail.com>, "Andrew Morton" <akpm@linux-foundation.org>, "Ingo Molnar"
> > <mingo@kernel.org>, "Mathieu Desnoyers" <mathieu.desnoyers@efficios.com>, "Oleg Nesterov" <oleg@redhat.com>, "Steven
> > Rostedt" <rostedt@goodmis.org>
> > Sent: Wednesday, April 9, 2014 12:11:19 PM
> > Subject: [PATCH 2/5] tracepoint: Convert process iteration to use for_each_process_thread()
> >
> > do_each_thread/while_each_thread iterators are deprecated by
> > for_each_thread/for_each_process_thread() APIs.
> >
> > Lets convert the callers in the tracepoint code. The ultimate
> > goal is to remove the struct task_struct::thread_group field and
> > the corresponding do_each_thread/while_each_thread iterators that are
> > RCU unsafe.
> >
> > Cc: Andrew Morton <akpm@linux-foundation.org>
> > Cc: Ingo Molnar <mingo@kernel.org>
> > Cc: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
> > Cc: Oleg Nesterov <oleg@redhat.com>
> > Cc: Steven Rostedt <rostedt@goodmis.org>
> > Signed-off-by: Frederic Weisbecker <fweisbec@gmail.com>
> > ---
> > kernel/tracepoint.c | 12 ++++++------
> > 1 file changed, 6 insertions(+), 6 deletions(-)
> >
> > diff --git a/kernel/tracepoint.c b/kernel/tracepoint.c
> > index fb0a38a..00a7e8b 100644
> > --- a/kernel/tracepoint.c
> > +++ b/kernel/tracepoint.c
> > @@ -561,15 +561,15 @@ 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) {
> > + for_each_process_thread(p, t) {
>
> What are the locking rules for for_each_process_thread() ?
>
> Is it required to hold RCU read-side lock ? (it's not the case here)
>
> Is tasklist_lock read-side lock sufficient ?

It's the same requirements than do_each_thread while_each_thread: tasklist_lock
or RCU. Except that it's really RCU-safe. while_each_thread isn't really
safe due to issues with concurrent exec/de_thread()

Then it depends on your requirement, if you can tolerate concurrent
adds and removals or not. Here tasklist_lock seems required or we may miss
some tasks' syscall traces.

>
> A quick glance at those for_each iterator defines in sched.h was not
> helpful in finding this information.

Agreed, I'm going to add comments to precise that.


\
 
 \ /
  Last update: 2014-04-11 01:21    [W:0.864 / U:0.596 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site