From: Al Viro <viro@ZenIV.linux.org.uk>
To: Linus Torvalds <torvalds@linux-foundation.org>
Cc: "Eric W. Biederman" <ebiederm@xmission.com>,
linux-fsdevel@vger.kernel.org, netdev@vger.kernel.org,
Linux Containers <containers@lists.osdl.org>
Subject: Re: [RFC] breakage in sysfs_readdir() and s_instances abuse in sysfs
Date: Sun, 12 Jun 2011 19:17:10 +0100 [thread overview]
Message-ID: <20110612181709.GF11521@ZenIV.linux.org.uk> (raw)
In-Reply-To: <BANLkTi=AfYH1eg_O1N2M9BfcF=UmBFPy6w@mail.gmail.com>
On Sun, Jun 12, 2011 at 10:59:42AM -0700, Linus Torvalds wrote:
> On Sun, Jun 12, 2011 at 12:15 AM, Eric W. Biederman
> <ebiederm@xmission.com> wrote:
> >
> > I honestly hate the pattern that is being used here. ?Holding a
> > reference count because we can't be bothered to free things reliably
> > when we actually stop using them.
>
> WHAT?
>
> That's what a reference count *is*. It's all about "free things
> reliably when we actually stop using them".
>
> Your comment makes zero sense.
>
> EVERY SINGLE kernel data structure should be reference counted. Read
> Documentation/CodingStyle, or look at any of the good code in the
> kernel (ie core process or VFS code). A non-refcounted data structure
> that is used by more than one entity IS A BUG!
>
> Quite frankly, your objection sounds moronic. If there is more than
> one user, then a reference count is _always_ the right thing. Nothing
> else ever works, and trust me, people have tried. They've tried
> locking, they've tried luck, they've tried crazy things. Nothing but
> refcounts works.
No, what the current code is trying to do is to have two kinds of references -
contributing to refcount (they do have one, all right) and non-contributing.
*AND* it attempts to hunt non-contributing ones down and replace them with
NULL when refcount hits zero. And fscks up in dealing with the results.
What this patch does is pretty much the same thing we do for mm_struct and
superblocks - two refcounts, one controlling the shutdown of object and another
controlling the actual freeing of memory. The second kind of references
contributes to the "memory" refcount and so does having non-zero "active"
refcount. No games with replacing references with NULL, no races around those,
etc.
Eric's objection is that sysfs superblock would pin the memory occupied by
struct net down until it's unmounted. Frankly, I think it's a BS -
aforementioned 2.5K are trivial to pin down *anyway*. Just chdir deep
enough into that instance of sysfs tree and inodes/dentries you've pinned
down by that will easily eat this much.
next prev parent reply other threads:[~2011-06-12 18:17 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-06-04 0:15 [RFC] breakage in sysfs_readdir() and s_instances abuse in sysfs Al Viro
2011-06-04 21:22 ` Al Viro
2011-06-04 21:55 ` Linus Torvalds
2011-06-04 22:23 ` Al Viro
2011-06-06 19:03 ` Eric W. Biederman
2011-06-07 21:58 ` Al Viro
2011-06-07 22:59 ` Al Viro
2011-06-09 1:26 ` Al Viro
2011-06-12 7:15 ` Eric W. Biederman
2011-06-12 17:59 ` Linus Torvalds
2011-06-12 18:17 ` Al Viro [this message]
2011-06-12 18:35 ` Al Viro
-- strict thread matches above, loose matches on Subject: below --
2011-06-04 22:25 Al Viro
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=20110612181709.GF11521@ZenIV.linux.org.uk \
--to=viro@zeniv.linux.org.uk \
--cc=containers@lists.osdl.org \
--cc=ebiederm@xmission.com \
--cc=linux-fsdevel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=torvalds@linux-foundation.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).