Re: kmem API to allocate arrays

2017-07-30 Thread Martin Husemann
On Sun, Jul 30, 2017 at 03:30:59PM -, Michael van Elst wrote: > Reallocation is usually a reason for memory fragmentation. I would > rather try to avoid it instead of making it easier. Agreeed. Also for kernel drivers, resizing an array allocation is a very rare operation and no good reason

Re: kmem API to allocate arrays

2017-07-30 Thread Kamil Rytarowski
On 30.07.2017 16:51, Taylor R Campbell wrote: >> Date: Sun, 30 Jul 2017 16:24:07 +0200 >> From: Kamil Rytarowski >> >> I would allow size to be 0, like with the original reallocarr(3). It >> might be less pretty, but more compatible with the original model and >> less vulnerable to

Re: kmem API to allocate arrays

2017-07-30 Thread Michael van Elst
campbell+netbsd-tech-k...@mumble.net (Taylor R Campbell) writes: >Initially I was reluctant to do that because (a) we don't even have a >kmem_realloc, perhaps for some particular reason, and (b) it requires >an extra parameter for the old size. But I don't know any particular >reason in (a), and

Re: kmem API to allocate arrays

2017-07-30 Thread Taylor R Campbell
> Date: Sun, 30 Jul 2017 16:24:07 +0200 > From: Kamil Rytarowski > > I would allow size to be 0, like with the original reallocarr(3). It > might be less pretty, but more compatible with the original model and > less vulnerable to accidental panics for no good reason. Hard to

Re: kmem API to allocate arrays

2017-07-30 Thread Kamil Rytarowski
On 30.07.2017 15:45, Taylor R Campbell wrote: >> Date: Sun, 30 Jul 2017 10:22:11 +0200 >> From: Kamil Rytarowski >> >> I think we should go for kmem_reallocarr(). It has been designed for >> overflows like realocarray(3) with an option to be capable to resize a >> table fron 1 to N

Re: kmem API to allocate arrays

2017-07-30 Thread Taylor R Campbell
> Date: Sun, 30 Jul 2017 10:22:11 +0200 > From: Kamil Rytarowski > > I think we should go for kmem_reallocarr(). It has been designed for > overflows like realocarray(3) with an option to be capable to resize a > table fron 1 to N elements and back from N to 0 including freeing.

kmem API to allocate arrays

2017-07-29 Thread Taylor R Campbell
It's stupid that we have to litter drivers with if (SIZE_MAX/sizeof(struct xyz_cookie) < iocmd->ncookies) { error = EINVAL; goto out; } cookies = kmem_alloc(iocmd->ncookies*sizeof(struct xyz_cookie), KM_SLEEP); ... and