[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20120830191523.GF6749@jtriplet-mobl1>
Date: Thu, 30 Aug 2012 12:15:23 -0700
From: Josh Triplett <josh@...htriplett.org>
To: "Paul E. McKenney" <paulmck@...ux.vnet.ibm.com>
Cc: linux-kernel@...r.kernel.org, mingo@...e.hu, laijs@...fujitsu.com,
dipankar@...ibm.com, akpm@...ux-foundation.org,
mathieu.desnoyers@...ymtl.ca, niv@...ibm.com, tglx@...utronix.de,
peterz@...radead.org, rostedt@...dmis.org, Valdis.Kletnieks@...edu,
dhowells@...hat.com, eric.dumazet@...il.com, darren@...art.com,
fweisbec@...il.com, sbw@....edu, patches@...aro.org
Subject: Re: [PATCH tip/core/rcu 5/5] rcu: Prevent initialization race in
rcutorture kthreads
On Thu, Aug 30, 2012 at 11:45:12AM -0700, Paul E. McKenney wrote:
> From: "Paul E. McKenney" <paulmck@...ux.vnet.ibm.com>
>
> When you do something like "t = kthread_run(...)", it is possible that
> the kthread will start running before the assignment to "t" happens.
> If the child kthread expects to find a pointer to its task_struct in "t",
> it will then be fatally disappointed. This commit therefore switches
> such cases to kthread_create() followed by wake_up_process(), guaranteeing
> that the assignment happens before the child kthread starts running.
>
> Reported-by: Fengguang Wu <fengguang.wu@...el.com>
> Signed-off-by: Paul E. McKenney <paulmck@...ux.vnet.ibm.com>
Seems like you should go ahead and make this change for all the threads,
not just two of them. A simple wrapper around kthread_run, taking a
struct task_struct ** to write to, would make this much simpler. Such a
wrapper could also return an error code directly (for use in firsterr),
write NULL to the pointer on error, and perhaps print an error message,
which would remove most of the boilerplate currently duplicated for
every thread creation.
Arguably, all of those except the error message printing would make
sense as changes to kthread_run itself, but that's another patch. :)
- Josh Triplett
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists