From: Josh Triplett <josh@joshtriplett.org>
To: "Paul E. McKenney" <paulmck@linux.vnet.ibm.com>
Cc: linux-kernel@vger.kernel.org, mingo@elte.hu,
laijs@cn.fujitsu.com, dipankar@in.ibm.com,
akpm@linux-foundation.org, mathieu.desnoyers@polymtl.ca,
niv@us.ibm.com, tglx@linutronix.de, peterz@infradead.org,
rostedt@goodmis.org, Valdis.Kletnieks@vt.edu,
dhowells@redhat.com, eric.dumazet@gmail.com, darren@dvhart.com,
fweisbec@gmail.com, sbw@mit.edu, patches@linaro.org
Subject: Re: [PATCH tip/core/rcu 5/5] rcu: Prevent initialization race in rcutorture kthreads
Date: Thu, 30 Aug 2012 12:15:23 -0700 [thread overview]
Message-ID: <20120830191523.GF6749@jtriplet-mobl1> (raw)
In-Reply-To: <1346352312-31987-5-git-send-email-paulmck@linux.vnet.ibm.com>
On Thu, Aug 30, 2012 at 11:45:12AM -0700, Paul E. McKenney wrote:
> From: "Paul E. McKenney" <paulmck@linux.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@intel.com>
> Signed-off-by: Paul E. McKenney <paulmck@linux.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
next prev parent reply other threads:[~2012-08-30 19:15 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-08-30 18:44 [PATCH tip/core/rcu 0/5] Documentation and rcutorture changes Paul E. McKenney
2012-08-30 18:45 ` [PATCH tip/core/rcu 1/5] rcu: Update rcutorture defaults Paul E. McKenney
2012-08-30 18:45 ` [PATCH tip/core/rcu 2/5] rcu: Track CPU-hotplug duration statistics Paul E. McKenney
2012-08-30 19:00 ` Josh Triplett
2012-08-30 20:38 ` Paul E. McKenney
2012-08-30 23:23 ` Josh Triplett
2012-08-30 18:45 ` [PATCH tip/core/rcu 3/5] rcu: Document SRCU dead-CPU capabilities, emphasize read-side limits Paul E. McKenney
2012-08-30 19:01 ` Josh Triplett
2012-09-18 9:12 ` Lai Jiangshan
2012-09-18 23:32 ` Paul E. McKenney
2012-08-30 18:45 ` [PATCH tip/core/rcu 4/5] rcu: Switch rcutorture to pr_alert() and friends Paul E. McKenney
2012-08-30 19:05 ` Josh Triplett
2012-08-30 18:45 ` [PATCH tip/core/rcu 5/5] rcu: Prevent initialization race in rcutorture kthreads Paul E. McKenney
2012-08-30 19:15 ` Josh Triplett [this message]
2012-08-30 18:57 ` [PATCH tip/core/rcu 1/5] rcu: Update rcutorture defaults Josh Triplett
2012-08-30 21:35 ` Paul E. McKenney
2012-08-30 23:24 ` Josh Triplett
2012-08-30 18:56 ` [PATCH tip/core/rcu 0/5] Documentation and rcutorture changes Josh Triplett
2012-08-30 21:46 ` Paul E. McKenney
2012-08-30 23:22 ` Josh Triplett
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20120830191523.GF6749@jtriplet-mobl1 \
--to=josh@joshtriplett.org \
--cc=Valdis.Kletnieks@vt.edu \
--cc=akpm@linux-foundation.org \
--cc=darren@dvhart.com \
--cc=dhowells@redhat.com \
--cc=dipankar@in.ibm.com \
--cc=eric.dumazet@gmail.com \
--cc=fweisbec@gmail.com \
--cc=laijs@cn.fujitsu.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mathieu.desnoyers@polymtl.ca \
--cc=mingo@elte.hu \
--cc=niv@us.ibm.com \
--cc=patches@linaro.org \
--cc=paulmck@linux.vnet.ibm.com \
--cc=peterz@infradead.org \
--cc=rostedt@goodmis.org \
--cc=sbw@mit.edu \
--cc=tglx@linutronix.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®