tech-kern archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: rfc: vmem(9) API/implementation changes



-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 07/27/11 19:28, David Young wrote:
> On Wed, Jul 27, 2011 at 04:58:23PM +0000, Eduardo Horvath wrote:
>> On Wed, 27 Jul 2011, David Young wrote:
>> 
>>> There are a couple of changes to the API that I would like to
>>> make. First, I don't think that vmem_addr_t 0 should be reserved
>>> for error indications (0 == VMEM_ADDR_NULL), but the API should
>>> change from this:
>> 
>> I'd recommend returning -1 on error.  0 is a valid address, but
>> while -1 is a valid address, when do you ever use this interface to
>> allocate something that starts at address -1?  And it gets around
>> all the noxious problems involved in returning data through
>> reference parameters.
> 
> I don't know.  Suppose sizeof(vmem_addr_t) == sizeof(uint32_t).
> Which of these cases should fail, and on which statement?
> 
> Case A:
> 
> 1     vm = vmem_create("test", 0xffffffff, 1, 0, NULL, NULL, NULL, 1, 2
> VM_SLEEP, IPL_NONE); 3        p = vmem_alloc(vm, 1, VM_SLEEP);
> 
> Case B:
> 
> 1     vm = vmem_create("test", 0xfffffffe, 2, 0, NULL, NULL, NULL, 1, 2
> VM_SLEEP, IPL_NONE); 3        p = vmem_alloc(vm, 2, VM_SLEEP);
> 
> Case C:
> 
> 1     vm = vmem_create("test", 0xfffffffe, 2, 0, NULL, NULL, NULL, 1, 2
> VM_SLEEP, IPL_NONE); 3        p = vmem_alloc(vm, 1, VM_SLEEP); 4      q =
> vmem_alloc(vm, 1, VM_SLEEP);
> 
> Dave
> 
Hi,

I think case A should fail on vmem_create B an vmem_alloc and C on the
second vmem_alloc...
having said that, yes I think the api of vmem is awful it is mixing up
return addresses with error conditions...
While we are pretty close to the Solaris API, except that we should have
an vmem_create, which takes an non-size-adjusting import function and a
vmem_xcreate with takes the import function as it currently is.
This allows vmem_alloc to be used as an import function, which gets
important to stack arenas, something I do within the effort to make
kmem/pool allocations backed by a vmem arena and making vmem self contained
I think out of bound error reporting is essential as there are a few bus
extents that span the entire range.

Lars


- -- 
- ------------------------------------

Mystische Erklärungen:
Die mystischen Erklärungen gelten für tief;
die Wahrheit ist, dass sie noch nicht einmal oberflächlich sind.

   -- Friedrich Nietzsche
   [ Die Fröhliche Wissenschaft Buch 3, 126 ]
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.17 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAk4wU4UACgkQcxuYqjT7GRY99wCfdmllk2bO/wXHa44Mj630Pkum
M8EAn3BsTHHusWN8qJzj9dMskR/GdTPm
=IvXq
-----END PGP SIGNATURE-----


Home | Main Index | Thread Index | Old Index