From owner-freebsd-hackers@freebsd.org Wed May 10 09:20:00 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 E5C37D65C9D for ; Wed, 10 May 2017 09:20:00 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from kib.kiev.ua (kib.kiev.ua [IPv6:2001:470:d5e7:1::1]) (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 646DEF6B for ; Wed, 10 May 2017 09:20:00 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from tom.home (kib@localhost [127.0.0.1]) by kib.kiev.ua (8.15.2/8.15.2) with ESMTPS id v4A9Jkwg078564 (version=TLSv1.2 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Wed, 10 May 2017 12:19:46 +0300 (EEST) (envelope-from kostikbel@gmail.com) DKIM-Filter: OpenDKIM Filter v2.10.3 kib.kiev.ua v4A9Jkwg078564 Received: (from kostik@localhost) by tom.home (8.15.2/8.15.2/Submit) id v4A9JkW1078563; Wed, 10 May 2017 12:19:46 +0300 (EEST) (envelope-from kostikbel@gmail.com) X-Authentication-Warning: tom.home: kostik set sender to kostikbel@gmail.com using -f Date: Wed, 10 May 2017 12:19:46 +0300 From: Konstantin Belousov To: Sebastian Huber Cc: FreeBSD Subject: Re: Linux gen_pool allocator replacement? Message-ID: <20170510091946.GT1622@kib.kiev.ua> References: <5912D448.5060201@embedded-brains.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <5912D448.5060201@embedded-brains.de> User-Agent: Mutt/1.8.2 (2017-04-18) X-Spam-Status: No, score=-2.0 required=5.0 tests=ALL_TRUSTED,BAYES_00, DKIM_ADSP_CUSTOM_MED,FREEMAIL_FROM,NML_ADSP_CUSTOM_MED autolearn=no autolearn_force=no version=3.4.1 X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on tom.home 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: Wed, 10 May 2017 09:20:01 -0000 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.