Linux gen_pool allocator replacement?

Sebastian Huber sebastian.huber at embedded-brains.de
Thu May 11 06:34:16 UTC 2017


On 10/05/17 11:19, Konstantin Belousov wrote:
> On Wed, May 10, 2017 at 10:50:16AM +0200, Sebastian Huber wrote:
>> Hello,
>>
>> I try currently to port a BSD licensed Linux network interface driver to
>> FreeBSD. This driver uses the gen_pool allocator
>>
>> http://elixir.free-electrons.com/linux/latest/source/include/linux/genalloc.h
>>
>> for example here
>>
>> https://github.com/torvalds/linux/blob/master/drivers/soc/fsl/qbman/qman.c#L2707
>>
>> Does someone know if something similar exits in the FreeBSD kernel? I
>> cannot use UMA since the pool management data must reside outside the
>> managed memory area. One use case in this driver seems just to manage a
> I think you would get more useful answers if you explain what the
> facility does.
>
>> range of integers, so no actual memory allocation. For this I could
>> probably use UNR(9), but a general gen_pool allocator replacement would
>> be nice.
> For an abstract resource allocator, look at vmem(9).  It manages arbitrary
> resources represented by ranges of integer values, you can use the range
> of size 1.
>
> There is no man page for vmem(9), but the interface is clearly explained
> in sys/vmem.h, and there is an article by Jeff Bonwick and Jonathan
> Adams about vmem, describing the original Solaris facility.

Thanks for the hint to vmem(9). There seems to be already a 
driver-specific support using blist for gen_pool:

https://github.com/freebsd/freebsd/blob/master/sys/dev/cxgb/ulp/iw_cxgb/iw_cxgb_hal.h#L190

-- 
Sebastian Huber, embedded brains GmbH

Address : Dornierstr. 4, D-82178 Puchheim, Germany
Phone   : +49 89 189 47 41-16
Fax     : +49 89 189 47 41-09
E-Mail  : sebastian.huber at embedded-brains.de
PGP     : Public key available on request.

Diese Nachricht ist keine geschäftliche Mitteilung im Sinne des EHUG.



More information about the freebsd-hackers mailing list