From: Dave Hansen <dave@linux.vnet.ibm.com>
To: "H. Peter Anvin" <hpa@zytor.com>
Cc: vda.linux@googlemail.com, bblum@google.com,
linux-kernel@vger.kernel.org,
containers@lists.linux-foundation.org, menage@google.com,
akpm@linux-foundation.org
Subject: Re: [RFCv2][PATCH] flexible array implementation
Date: Thu, 23 Jul 2009 07:30:01 -0700 [thread overview]
Message-ID: <1248359401.24021.715.camel@nimitz> (raw)
In-Reply-To: <4A67CEB7.2080505@zytor.com>
On Wed, 2009-07-22 at 19:45 -0700, H. Peter Anvin wrote:
> > I call it a flexible array. It does all of its work in
> > PAGE_SIZE bits, so never does an order>0 allocation.
> > The base level has PAGE_SIZE-2*sizeof(int) bytes of
> > storage for pointers to the second level. So, with a
> > 32-bit arch, you get about 4MB (4183112 bytes) of total
> > storage when the objects pack nicely into a page. It
> > is half that on 64-bit because the pointers are twice
> > the size.
>
> I'm wondering if there is any use case which would require scaling below
> the PAGE_SIZE level... in which case it would be nice for it to
> gracefully decay to a single kmalloc allocation + some metadata.
For the pid_t case that actually spawned all this, I think it makes a
ton of sense. It should be pretty easy to just cannibalize the
base->part[] pointers to use for data if (total*element_size <=
bytes_allocated - sizeof(metadata)) in the base. We'd have to store the
requested allocation total, but that's not bad.
1. Do we use this mode *only* when using a small 'total'? Or, do we
use the mode only when accessing a small range of elements, like
indexes < 511.
2. Do we just use the mode when the indexes are large, but not sparse?
Say, when someone is only using indexes 1024->1535?
3. Do we ever allocate less than 1 page (i.e. kmalloc(2048)) for the
base given a small enough 'total' requested? If so, it gets much
harder to grow the array later on if we want to support resizing.
4. Do we ever promote under the covers from this mode up to the full
two-level one?
This also gives us more of a reason to store a flex_array->total and
enforce that the array is not allowed to grow past that.
-- Dave
prev parent reply other threads:[~2009-07-23 14:46 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-07-21 22:00 [RFCv2][PATCH] flexible array implementation Dave Hansen
2009-07-21 22:09 ` Dave Hansen
2009-07-21 22:35 ` Andrew Morton
2009-07-22 3:25 ` Li Zefan
2009-07-22 4:34 ` Dave Hansen
2009-07-22 6:14 ` Li Zefan
2009-07-22 7:09 ` Amerigo Wang
2009-07-22 15:02 ` Dave Hansen
2009-07-22 18:30 ` Matt Helsley
2009-07-22 22:03 ` Dave Hansen
2009-07-22 19:55 ` Mike Waychison
2009-07-22 22:00 ` Dave Hansen
2009-07-22 20:57 ` Benjamin Blum
2009-07-22 21:51 ` Dave Hansen
2009-07-22 23:20 ` Benjamin Blum
2009-07-23 5:41 ` Dave Hansen
2009-07-23 2:45 ` H. Peter Anvin
2009-07-23 14:30 ` Dave Hansen [this message]
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=1248359401.24021.715.camel@nimitz \
--to=dave@linux.vnet.ibm.com \
--cc=akpm@linux-foundation.org \
--cc=bblum@google.com \
--cc=containers@lists.linux-foundation.org \
--cc=hpa@zytor.com \
--cc=linux-kernel@vger.kernel.org \
--cc=menage@google.com \
--cc=vda.linux@googlemail.com \
/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