From: Dave Hansen <dave@linux.vnet.ibm.com>
To: Mike Waychison <mikew@google.com>
Cc: akpm@linux-foundation.org, containers@lists.linux-foundation.org,
bblum@google.com, linux-kernel@vger.kernel.org,
menage@google.com, vda.linux@googlemail.com
Subject: Re: [RFCv2][PATCH] flexible array implementation
Date: Wed, 22 Jul 2009 15:00:17 -0700 [thread overview]
Message-ID: <1248300017.24021.344.camel@nimitz> (raw)
In-Reply-To: <4A676ECC.1090400@google.com>
On Wed, 2009-07-22 at 15:55 -0400, Mike Waychison wrote:
> > +#define FLEX_ARRAY_INIT(size, total) {{{\
> > + .element_size = (size), \
> > + .nr_elements = 0, \
> > +}}}
> > +
>
> It's not clear how this guy is used. It will initialize a flex_array,
> but how is somebody expected to free the parts that get associated with it?
I tried to make that a bit more clear with the kerneldocs.
flex_array_free_parts() will free just the "parts" without touching the
"base" structure. Otherwise, this macro is used in the same way as
RADIX_TREE_INIT().
> Is there a fancy way to make declaring a flex_array on stack a
> compile-time error?
Not that I know of. One thing that I did which makes this a _bit_
easier to detect is that sizeof(struct flex_array)==PAGE_SIZE instead of
just leaving a "void members[0]" at the end of the struct. That means
that scripts/checkstack.pl should spot these.
I just double-checked:
$ objdump -d ../mhp-build/i386-qemu-smp/vmlinux | scripts/checkstack.pl i386
0xc02499d8 min_free_kbytes_sysctl_handler [vmlinux]: 4096
0xc0276619 do_sys_poll [vmlinux]: 896
0xc0276b49 do_select [vmlinux]: 704
...
That's after I added a 'struct flex_array f;' in
min_free_kbytes_sysctl_handler().
I'm happy to hear of anybody else's tricks, though. I guess I could do
a WARN_ONCE() in some of the flex_array*() functions if we detect an
address that looks to be on the stack. But, I can't think of any fancy
compile-time ones.
-- Dave
next prev parent reply other threads:[~2009-07-22 22:00 UTC|newest]
Thread overview: 36+ 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-21 22:35 ` Andrew Morton
2009-07-21 22:09 ` Dave Hansen
2009-07-22 3:25 ` Li Zefan
[not found] ` <4A66868F.4010001-BthXqXjhjHXQFUHtdCDX3A@public.gmane.org>
2009-07-22 4:34 ` Dave Hansen
2009-07-22 4:34 ` Dave Hansen
2009-07-22 6:14 ` Li Zefan
2009-07-22 6:14 ` Li Zefan
2009-07-22 3:25 ` Li Zefan
2009-07-22 7:09 ` Amerigo Wang
2009-07-22 15:02 ` Dave Hansen
[not found] ` <20090722070903.GG6281-+dguKlz9DXUf7BdofF/totBPR1lH4CV8@public.gmane.org>
2009-07-22 15:02 ` Dave Hansen
2009-07-22 7:09 ` Amerigo Wang
2009-07-22 18:30 ` Matt Helsley
[not found] ` <20090722183018.GE5878-52DBMbEzqgQ/wnmkkaCWp/UQ3DHhIser@public.gmane.org>
2009-07-22 22:03 ` Dave Hansen
2009-07-22 22:03 ` Dave Hansen
2009-07-22 18:30 ` Matt Helsley
2009-07-22 19:55 ` Mike Waychison
2009-07-22 19:55 ` Mike Waychison
2009-07-22 22:00 ` Dave Hansen [this message]
[not found] ` <4A676ECC.1090400-hpIqsD4AKlfQT0dZR+AlfA@public.gmane.org>
2009-07-22 22:00 ` Dave Hansen
2009-07-22 20:57 ` Benjamin Blum
2009-07-22 20:57 ` Benjamin Blum
[not found] ` <2f86c2480907221357j5a09fd9au890f815db3750187-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2009-07-22 21:51 ` Dave Hansen
2009-07-22 21:51 ` Dave Hansen
2009-07-22 23:20 ` Benjamin Blum
2009-07-22 23:20 ` Benjamin Blum
2009-07-23 5:41 ` Dave Hansen
[not found] ` <2f86c2480907221620u6da3a8e3h8273f6a9ee156f86-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2009-07-23 5:41 ` Dave Hansen
2009-07-23 2:45 ` H. Peter Anvin
[not found] ` <4A67CEB7.2080505-YMNOUZJC4hwAvxtiuMwx3w@public.gmane.org>
2009-07-23 14:30 ` Dave Hansen
2009-07-23 14:30 ` Dave Hansen
2009-07-23 2:45 ` H. Peter Anvin
-- strict thread matches above, loose matches on Subject: below --
2009-07-21 22:00 Dave Hansen
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=1248300017.24021.344.camel@nimitz \
--to=dave@linux.vnet.ibm.com \
--cc=akpm@linux-foundation.org \
--cc=bblum@google.com \
--cc=containers@lists.linux-foundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=menage@google.com \
--cc=mikew@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 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.