From: Li Zefan <lizf@cn.fujitsu.com>
To: Dave Hansen <dave@linux.vnet.ibm.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, mikew@google.com
Subject: Re: [RFCv2][PATCH] flexible array implementation
Date: Wed, 22 Jul 2009 11:25:03 +0800 [thread overview]
Message-ID: <4A66868F.4010001@cn.fujitsu.com> (raw)
In-Reply-To: <20090721220017.60A219D3@kernel>
> +/**
> + * flex_array_put - copy data into the array at @element_nr
> + * @src: address of data to copy into the array
> + * @element_nr: index of the position in which to insert
> + * the new element.
@fa and @flags are not documented.
> + *
> + * Note that this *copies* the contents of @src into
> + * the array. If you are trying to store an array of
> + * pointers, make sure to pass in &ptr instead of ptr.
> + *
> + * Locking must be provided by the caller.
> + */
> +int flex_array_put(struct flex_array *fa, int element_nr, void *src, gfp_t flags)
> +{
> + int part_nr = fa_element_to_part_nr(fa, element_nr);
> + struct flex_array_part *part;
> + void *dst;
> +
> + part = __fa_get_part(fa, part_nr, flags);
> + if (!part)
> + return -ENOMEM;
So this may allocate memory, and has disavantages:
- If flex_array_put() is called in atomic context, flags has to be GFP_ATOMIC.
- and thus it may fail.
Since we pass the total_elem to flex_array_alloc(), how about add a flag,
and if the flag is set, the alloc() will also allocate all fa_parts?
And add __flex_array_put(), which assumes fa_parts has been allocated.
> + dst = &part->elements[offset_inside_part(fa, element_nr)];
> + memcpy(dst, src, fa->element_size);
> + return 0;
> +}
> +
next prev parent reply other threads:[~2009-07-22 3:26 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:09 ` Dave Hansen
2009-07-21 22:35 ` Andrew Morton
2009-07-21 22:35 ` Andrew Morton
2009-07-22 3:25 ` Li Zefan [this message]
[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
2009-07-22 18:30 ` Matt Helsley
2009-07-22 22:03 ` Dave Hansen
[not found] ` <20090722183018.GE5878-52DBMbEzqgQ/wnmkkaCWp/UQ3DHhIser@public.gmane.org>
2009-07-22 22:03 ` Dave Hansen
2009-07-22 19:55 ` Mike Waychison
2009-07-22 19:55 ` Mike Waychison
[not found] ` <4A676ECC.1090400-hpIqsD4AKlfQT0dZR+AlfA@public.gmane.org>
2009-07-22 22:00 ` Dave Hansen
2009-07-22 22:00 ` Dave Hansen
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
[not found] ` <2f86c2480907221620u6da3a8e3h8273f6a9ee156f86-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2009-07-23 5:41 ` Dave Hansen
2009-07-23 5:41 ` Dave Hansen
2009-07-22 20:57 ` Benjamin Blum
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=4A66868F.4010001@cn.fujitsu.com \
--to=lizf@cn.fujitsu.com \
--cc=akpm@linux-foundation.org \
--cc=bblum@google.com \
--cc=containers@lists.linux-foundation.org \
--cc=dave@linux.vnet.ibm.com \
--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.