From: Andrew Morton <akpm@osdl.org>
To: Jim Houston <jim.houston@ccur.com>
Cc: thockin@sun.com, torvalds@osdl.org,
viro@parcelfarce.linux.theplanet.co.uk,
linux-kernel@vger.kernel.org, george@mvista.com
Subject: Re: PATCH - raise max_anon limit
Date: Thu, 12 Feb 2004 14:03:56 -0800 [thread overview]
Message-ID: <20040212140356.70be613f.akpm@osdl.org> (raw)
In-Reply-To: <1076606773.990.165.camel@new.localdomain>
Jim Houston <jim.houston@ccur.com> wrote:
>
> On Wed, 2004-02-11 at 20:20, Andrew Morton wrote:
> > Tim Hockin <thockin@sun.com> wrote:
> > > No, it doesn't store the counter with the id. They expect you to do that.
> > > My best understanding is that thi sis to prevent re-use of the same key.
> > > I'm not sure I grok why it is useful. If you release a key, it should be
> > > safe to reuse. Period. I assume there was some use case that brought about
> > > this "feature" but if so, I don't know what it is. The big comment about it
> > > is just confusing me.
> >
> > Maybe Jim can tell us why it's there. Certainly, the idr interface would
> > be more useful if it just returned id's which start from zero.
>
> Hi Andrew, Everyone,
>
> If this new use of idr.c as a sparse bitmap catches on,
I think it should catch on - it is a fairly common kernel requirement. The
max_anon thing requires it, and I am also pressing it upon the scsi guys to
handle enormous numbers of disks (depends on how they end up doing that).
In neither case is the associated pointer needed.
> When I wrote the original code, I was thinking of allocating process
> id values where there is a tradition of allocating sequential values.
File descriptors are like that too.
> George Anzinger rewrote most of my code. The r in idr.c is for
> immediate reuse. His version picks the lowest available bit in the
> sparse bitmap. The RESERVED_BITS comments seem to be stale.
>
> The rational for avoiding immediate reuse of id values is to catch
> application errors. Consider:
>
> fd1 = open_like_call(...);
> read(fd1,...);
> close(fd1);
> fd2 = open_like_call(...);
> write(fd1...);
>
> If fd2 has a different value than the recently closed fd1, the
> error is detected immediately.
>
In this case the debug capability is getting in the way of real-world
requirements, which is not good.
idr_pre_get() is not very good IMO. For a start, it's racy:
idr_pre_get();
lock();
idr_get_new();
unlock();
how do we know that some other CPU didn't come in and steal our
preallocation? That's why I (buggily) converted unnamed_dev_lock from a
spinlock to a semaphore, so we could perform the preallocation under the
same locking.
It would be better, and more idiomatic if idr_get_new() were to take a gfp
mask and to perform its own allocation. That has its own problems and if
the code is under really heavy stress one might need to emulate
radix_tree_preload()/radix_tree_preload_end(), but for most things that's a
bit over the top.
next prev parent reply other threads:[~2004-02-12 22:02 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-02-06 22:15 PATCH - raise max_anon limit Tim Hockin
2004-02-07 8:55 ` Andrew Morton
2004-02-07 9:48 ` viro
2004-02-11 20:33 ` Tim Hockin
2004-02-11 20:38 ` Linus Torvalds
2004-02-11 21:09 ` Tim Hockin
2004-02-11 21:53 ` Andrew Morton
2004-02-11 22:28 ` Tim Hockin
2004-02-11 22:48 ` Andrew Morton
[not found] ` <20040211233852.GN9155@sun.com>
[not found] ` <20040211155754.5068332c.akpm@osdl.org>
[not found] ` <20040212003840.GO9155@sun.com>
[not found] ` <20040211164233.5f233595.akpm@osdl.org>
2004-02-12 1:08 ` Tim Hockin
2004-02-12 1:20 ` Andrew Morton
2004-02-12 2:22 ` Tim Hockin
2004-02-12 17:26 ` Jim Houston
2004-02-12 18:49 ` Tim Hockin
2004-02-13 2:01 ` Jamie Lokier
2004-02-12 22:03 ` Andrew Morton [this message]
2004-02-13 1:12 ` George Anzinger
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=20040212140356.70be613f.akpm@osdl.org \
--to=akpm@osdl.org \
--cc=george@mvista.com \
--cc=jim.houston@ccur.com \
--cc=linux-kernel@vger.kernel.org \
--cc=thockin@sun.com \
--cc=torvalds@osdl.org \
--cc=viro@parcelfarce.linux.theplanet.co.uk \
/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