From: "KAMEZAWA Hiroyuki" <kamezawa.hiroyu@jp.fujitsu.com>
To: "Dave Hansen" <dave@linux.vnet.ibm.com>
Cc: "KAMEZAWA Hiroyuki" <kamezawa.hiroyu@jp.fujitsu.com>,
vda.linux@googlemail.com, containers@lists.linux-foundation.org,
linux-kernel@vger.kernel.org, menage@google.com,
akpm@linux-foundation.org
Subject: Re: [RFC][PATCH] flexible array implementation v3
Date: Thu, 23 Jul 2009 23:48:11 +0900 (JST) [thread overview]
Message-ID: <3b45d0f54f0f9c96727e4f9d07b97008.squirrel@webmail-b.css.fujitsu.com> (raw)
In-Reply-To: <1248357948.24021.692.camel@nimitz>
Dave Hansen wrote:
> On Thu, 2009-07-23 at 10:44 +0900, KAMEZAWA Hiroyuki wrote:
>> The caller can't know whether
>> - there are no entry or
>> - NULL(0) is stored at the array.
>>
>> Then, he has to check gotten value is valid or not by himself.
>
> I think you may be reading this bit wrong. Either that, or I badly
> miscoded it. :) The flex_array_get() code should returns NULL in cases
> of error or the *address* of the data element. It will actually return
> an address pointing into the second-level page.
>
> NULL's two meaning here are:
> 1. No element was ever put() here and thus there's no data page
> 2. Your index was out of bounds
>
> (1) is a little fuzzy here. It of course doesn't absolutely guarantee
> that no put() was done since we just use the data page's existence to
> tell. This is certainly no worse than a normal C array would be,
> though.
>
ok, maybe not necessary to handle.
>> Can't we return -ENOENT here(especially when prealloc() is called) ?
>> But ah, anyway, all-zero elements in allocated array exists ;(
>> and the user can get value from an entry never be put.
>>
>> If we can fill the first 4bytes of _unused_ index by some magic code
>> like this
>> #define FLEX_ARRAY_UNUSED_MAGIC (0xa5a5a5a5)
>> (if maintaining bitmap/status of usage is nonsense)
>> and flex_array_get() can return -ENOENT, the users will feel easy.
>>
>> Overprotection ;) ?
>
> I intentionally didn't use kzalloc() for the data pages. I figured that
> users will either initialize it themselves or pass in __GFP_ZERO. I've
> added a comment to clarify this.
>
sorry for noise.
I just felt that this code expects users know all they really do.
As said, seems nice :) thank you.
Reviewed-by: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
next prev parent reply other threads:[~2009-07-23 14:48 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-07-22 17:53 Dave Hansen
2009-07-23 1:44 ` KAMEZAWA Hiroyuki
2009-07-23 14:05 ` Dave Hansen
2009-07-23 14:48 ` KAMEZAWA Hiroyuki [this message]
2009-07-23 15:44 ` Oren Laadan
2009-07-23 16:02 ` 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=3b45d0f54f0f9c96727e4f9d07b97008.squirrel@webmail-b.css.fujitsu.com \
--to=kamezawa.hiroyu@jp.fujitsu.com \
--cc=akpm@linux-foundation.org \
--cc=containers@lists.linux-foundation.org \
--cc=dave@linux.vnet.ibm.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
all inboxes | Powered by JetHome®