From: Dave Hansen <haveblue@us.ibm.com>
To: Oliver Neukum <Oliver.Neukum@lrz.uni-muenchen.de>
Cc: Kasper Dupont <kasperd@daimi.au.dk>,
Linux-Kernel <linux-kernel@vger.kernel.org>
Subject: Re: [RFC] Race condition?
Date: Fri, 02 Aug 2002 12:09:41 -0700 [thread overview]
Message-ID: <3D4AD8F5.1090107@us.ibm.com> (raw)
In-Reply-To: 200208021858.g72Iwam03030@fachschaft.cup.uni-muenchen.de
Oliver Neukum wrote:
>>The root of the problem is that the reference count is being relied on
>>for the wrong thing. There is a race on p->user between the
>>dup_task_struct() and whenever the atomic_inc(&p->user->__count)
>>occcurs. The user reference count needs to be incremented in
>>dup_task_struct(), before the copy occurs.
>
> I don't get you. The user_struct can hardly go away while we are
> forking.
Good point. I was figuring that it could disappear when the task
clearly can't be exiting or setuid'ing while forking.
> IMHO you should add a spinlock to user_struct and take it.
> A clear solution that doesn't hurt the common case.
That _is_ a pretty clear solution. It looks like there are grand
plans for struct user, so it might come in handy in the future. But,
a spinlock _will_ hurt the common case. With the atomic incs, we have
2 of them in the common case and, at most, 4 in the failure case.
Adding a spinlock will require more lock instructions, which are the
most costly operations in either a spinlock or atomic op.
Either of these are _incredibly_ small prices to pay in any case.
Forks are slow anyway. A spinlock would be just fine with me.
--
Dave Hansen
haveblue@us.ibm.com
next prev parent reply other threads:[~2002-08-02 19:06 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2002-08-02 13:46 [RFC] Race condition? Kasper Dupont
2002-08-02 14:48 ` Oliver Neukum
2002-08-02 17:13 ` Kasper Dupont
2002-08-02 18:51 ` Oliver Neukum
2002-08-02 17:37 ` Dave Hansen
2002-08-02 18:45 ` Oliver Neukum
2002-08-02 19:09 ` Dave Hansen [this message]
2002-08-02 17:00 ` Dave Hansen
2002-08-02 17:41 ` Oliver Neukum
2002-08-02 18:48 ` Dave Hansen
2002-08-02 18:56 ` Dave Hansen
2002-08-03 0:36 ` Keith Owens
[not found] <17aw0S-0U7gB7C@fmrl00.sul.t-online.com>
2002-08-03 11:07 ` Keith Owens
2002-08-03 11:17 ` Keith Owens
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=3D4AD8F5.1090107@us.ibm.com \
--to=haveblue@us.ibm.com \
--cc=Oliver.Neukum@lrz.uni-muenchen.de \
--cc=kasperd@daimi.au.dk \
--cc=linux-kernel@vger.kernel.org \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.