From owner-freebsd-hackers@freebsd.org Thu May 11 06:34:16 2017 Return-Path: Delivered-To: freebsd-hackers@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id B36BAD68F3B for ; Thu, 11 May 2017 06:34:16 +0000 (UTC) (envelope-from sebastian.huber@embedded-brains.de) Received: from dedi548.your-server.de (dedi548.your-server.de [85.10.215.148]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 723B719CE for ; Thu, 11 May 2017 06:34:15 +0000 (UTC) (envelope-from sebastian.huber@embedded-brains.de) Received: from [78.47.166.52] (helo=sslproxy04.your-server.de) by dedi548.your-server.de with esmtpsa (TLSv1.2:DHE-RSA-AES256-GCM-SHA384:256) (Exim 4.85_2) (envelope-from ) id 1d8hfw-0000XL-KR; Thu, 11 May 2017 08:34:12 +0200 Received: from [82.135.62.35] (helo=mail.embedded-brains.de) by sslproxy04.your-server.de with esmtpsa (TLSv1.2:DHE-RSA-AES256-GCM-SHA384:256) (Exim 4.84_2) (envelope-from ) id 1d8hfw-0000dQ-Dm; Thu, 11 May 2017 08:34:12 +0200 Received: from localhost (localhost.localhost [127.0.0.1]) by mail.embedded-brains.de (Postfix) with ESMTP id 862092A003F; Thu, 11 May 2017 08:34:39 +0200 (CEST) Received: from mail.embedded-brains.de ([127.0.0.1]) by localhost (zimbra.eb.localhost [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id 5AN-2kijCbIt; Thu, 11 May 2017 08:34:37 +0200 (CEST) Received: from localhost (localhost.localhost [127.0.0.1]) by mail.embedded-brains.de (Postfix) with ESMTP id 2EB672A160A; Thu, 11 May 2017 08:34:37 +0200 (CEST) X-Virus-Scanned: amavisd-new at zimbra.eb.localhost Received: from mail.embedded-brains.de ([127.0.0.1]) by localhost (zimbra.eb.localhost [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id FMaPn8ftCq6P; Thu, 11 May 2017 08:34:37 +0200 (CEST) Received: from [192.168.96.129] (unknown [192.168.96.129]) by mail.embedded-brains.de (Postfix) with ESMTPSA id 158D52A003F; Thu, 11 May 2017 08:34:37 +0200 (CEST) Subject: Re: Linux gen_pool allocator replacement? To: Konstantin Belousov References: <5912D448.5060201@embedded-brains.de> <20170510091946.GT1622@kib.kiev.ua> Cc: FreeBSD From: Sebastian Huber Message-ID: <591405E1.1000204@embedded-brains.de> Date: Thu, 11 May 2017 08:34:09 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.5.0 MIME-Version: 1.0 In-Reply-To: <20170510091946.GT1622@kib.kiev.ua> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: quoted-printable X-Authenticated-Sender: smtp-embedded@poldinet.de X-Virus-Scanned: Clear (ClamAV 0.99.2/23375/Wed May 10 23:03:12 2017) X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 11 May 2017 06:34:16 -0000 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/gen= alloc.h >> >> for example here >> >> https://github.com/torvalds/linux/blob/master/drivers/soc/fsl/qbman/qm= an.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 woul= d >> be nice. > For an abstract resource allocator, look at vmem(9). It manages arbitr= ary > resources represented by ranges of integer values, you can use the rang= e > of size 1. > > There is no man page for vmem(9), but the interface is clearly explaine= d > 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=20 driver-specific support using blist for gen_pool: https://github.com/freebsd/freebsd/blob/master/sys/dev/cxgb/ulp/iw_cxgb/i= w_cxgb_hal.h#L190 --=20 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@embedded-brains.de PGP : Public key available on request. Diese Nachricht ist keine gesch=E4ftliche Mitteilung im Sinne des EHUG.