From owner-freebsd-arch@FreeBSD.ORG Thu Jul 22 17:38:45 2004 Return-Path: Delivered-To: freebsd-arch@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 7DB7016A4CE; Thu, 22 Jul 2004 17:38:45 +0000 (GMT) Received: from pimout1-ext.prodigy.net (pimout1-ext.prodigy.net [207.115.63.77]) by mx1.FreeBSD.org (Postfix) with ESMTP id 3E1EA43D1F; Thu, 22 Jul 2004 17:38:45 +0000 (GMT) (envelope-from julian@elischer.org) Received: from elischer.org (adsl-68-121-219-69.dsl.snfc21.pacbell.net [68.121.219.69])i6MHchKn260214; Thu, 22 Jul 2004 13:38:43 -0400 Message-ID: <40FFFBA3.1030204@elischer.org> Date: Thu, 22 Jul 2004 10:38:43 -0700 From: Julian Elischer User-Agent: Mozilla/5.0 (X11; U; FreeBSD i386; en-US; rv:1.4b) Gecko/20030524 X-Accept-Language: en, hu MIME-Version: 1.0 To: Poul-Henning Kamp References: <200407221502.i6MF2Yqg039032@freefall.freebsd.org> In-Reply-To: <200407221502.i6MF2Yqg039032@freefall.freebsd.org> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit cc: arch@freebsd.org Subject: Re: [REVIEW] unit number allocation API X-BeenThere: freebsd-arch@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Discussion related to FreeBSD architecture List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 22 Jul 2004 17:38:45 -0000 Poul-Henning Kamp wrote: >We need to allocate unit numbers for (pseudo)devices, and a few >places we need to allocate inode numbers for synthetic filesystems >(for instance DEVFS). > >For these applications the overhead of rman(9) can be totally >unacceptable (60 bytes per allocation ?) and something more memory >frugal is called for. > >This is a small API I just wrote, targeted specifically for allocating >unit numbers and similar spaces. > >Currently the allocation policy is "lowest free number", but it >would be possible to add support for allocating a specific number >as well. > >It uses a mixed run-length/bitmap strategy with fixed size memory >chunks (so it can use uma(9) in the kernel). > >Worst case memory usage is two bits per managed unit-number (worst >case is "allocate all units, free all the odd numbered ones"). > >For the typical case where we never free any unit numbers, it will >use 52 bytes in total on i386. > >Please review. (It can be run in userland) > >Poul-Henning > > > please also look at the Thread_id (lwpid) allocator marcel added to kern_thread.c