From: "Paul (宝瑠) Menage" <menage@google.com>
To: "Dave Hansen" <haveblue@us.ibm.com>
Cc: balbir@linux.vnet.ibm.com, dhaval@linux.vnet.ibm.com,
"linux kernel mailing list" <linux-kernel@vger.kernel.org>,
"Pavel Emelianov" <xemul@sw.ru>, "Paul Jackson" <pj@sgi.com>,
"Linux Containers" <containers@lists.osdl.org>,
"Andrew Morton" <akpm@linux-foundation.org>
Subject: Re: Containers: css_put() dilemma
Date: Tue, 17 Jul 2007 09:15:58 -0700 [thread overview]
Message-ID: <6599ad830707170915p46794c61g3baba1ab0af5db7@mail.gmail.com> (raw)
In-Reply-To: <1184688131.6454.109.camel@localhost>
On 7/17/07, Dave Hansen <haveblue@us.ibm.com> wrote:
> On Tue, 2007-07-17 at 08:49 -0700, Paul (宝瑠) Menage wrote:
> > Because as soon as you do the atomic_dec_and_test() on css->refcnt and
> > the refcnt hits zero, then theoretically someone other thread (that
> > already holds container_mutex) could check that the refcount is zero
> > and free the container structure.
>
> Then that other task had a reference and itself should have bumped the
> count, and the other user would never have seen it hit zero.
Nope. The container could have been empty (of tasks) and hence had a zero count.
The liveness model used by containers is that when the refcount hits
zero, the container isn't immediately destroyed (since it can contain
useful historical usage data, etc) but simply becomes eligible for
destruction by userspace via an rmdir().
>
> Even if there are still pages attached to the container, why not just
> have those take a reference, and don't bother actually freeing the
> container until the last true reference is dropped?
Yes, we could potentially just use the main count variable rather than
having separate per-subsystem extra refcounts. The main reasons to do
it this way are:
- the root subsystem state for a subsystem can shift between different
"struct container" objects if it was previously inactive and gets
mounted as part of a hierarchy (or similarly, gets unmounted and goes
inactive). Possibly we could get around this by simply saying not
doing refcounting on the subsys states attached to root containers
since they can never be freed anyway.
- At some point I'd like to be able to support shifting subsystems
between active hierarchies, at least in limited cases such as where
the hierarchies are isomorphic, or binding/unbinding subsystems
to/from active hierarchies. At that point we definitely need to be
able to split out the different subsystem state refcounts from one
another in the same hierarchy.
- we'd still have the issue that Balbir wants to be able to drop a
reference in a non-sleeping context, and we want to avoid doing
excessive synchronization in the normal case when the css_put()
doesn't put the reference count to zero.
>
> Does it matter if the destruction callbacks don't happen until well
> after an attempt to destroy the container is made?
Well that's sort of the point of putting a synchronize_rcu() in
container_diput() - it ensures that the actual destruction of the
object doesn't occur until sufficiently after the destruction attempt
is initiated that no one is still using the reference.
The alternative would be something that polls to spot whether
refcounts have reached zero and if so runs the userspace helper. That
doesn't seem particularly palatable when you have large numbers of
containers, if we can avoid it easily.
Paul
next prev parent reply other threads:[~2007-07-17 16:16 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-07-16 18:50 Balbir Singh
2007-07-16 19:03 ` Paul (宝瑠) Menage
2007-07-17 2:21 ` Balbir Singh
2007-07-17 2:35 ` Paul (宝瑠) Menage
2007-07-17 7:00 ` Balbir Singh
2007-07-17 7:18 ` Paul (宝瑠) Menage
2007-07-17 10:28 ` Balbir Singh
2007-07-17 15:49 ` Paul (宝瑠) Menage
2007-07-17 16:02 ` Dave Hansen
2007-07-17 16:15 ` Paul (宝瑠) Menage [this message]
2007-07-17 17:23 ` Paul Jackson
2007-07-17 17:40 ` Balbir Singh
2007-07-17 17:44 ` Paul (宝瑠) Menage
2007-07-17 17:55 ` Paul Jackson
2007-07-17 17:57 ` Paul (宝瑠) Menage
2007-07-17 18:11 ` Balbir Singh
2007-07-17 18:26 ` Paul (宝瑠) Menage
2007-07-18 4:29 ` Balbir Singh
2007-07-18 5:30 ` Balbir Singh
2007-07-18 5:52 ` Srivatsa Vaddagiri
2007-07-18 23:15 ` Paul Menage
2007-07-19 3:44 ` Balbir Singh
2007-07-18 6:07 ` Paul (宝瑠) Menage
2007-07-17 17:53 ` Paul Jackson
2007-07-17 17:55 ` Paul (宝瑠) Menage
2007-07-17 17:58 ` Paul Jackson
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=6599ad830707170915p46794c61g3baba1ab0af5db7@mail.gmail.com \
--to=menage@google.com \
--cc=akpm@linux-foundation.org \
--cc=balbir@linux.vnet.ibm.com \
--cc=containers@lists.osdl.org \
--cc=dhaval@linux.vnet.ibm.com \
--cc=haveblue@us.ibm.com \
--cc=linux-kernel@vger.kernel.org \
--cc=pj@sgi.com \
--cc=xemul@sw.ru \
/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®