Date: Fri, 30 Jun 2000 00:16:22 -0400 (EDT) From: Bosko Milekic <bmilekic@dsuper.net> To: Joe McGuckin <joe@via.net> Cc: freebsd-hackers@FreeBSD.ORG Subject: Re: Re[2]: mbuf re-write(s), v 0.1 Message-ID: <Pine.BSF.4.21.0006300005240.6772-100000@jehovah.technokratis.com> In-Reply-To: <200006292222.PAA10225@monk.via.net>
next in thread | previous in thread | raw e-mail | index | archive | help
On Thu, 29 Jun 2000, Joe McGuckin wrote: > > What about a slab allocator > (e.g. http://www.cnds.jhu.edu/~jesus/418/SlabAllocator.pdf) > > Joe What's your motivation behind this recommendation? What you're essentially suggesting is a replacement for our kernel malloc(). This will not make mbuf allocations faster by any means. The mbuf allocator that I presented in code a week or so ago does something very simple, as there is no point in making same-sized object allocations complicated, really, especially when they are small objects; in other words, I did NOT suggest going back to using malloc() for mbufs. I wrote a new, simpler and faster customized allocator which does essentially this: * Check free list, which is a doubly-linked list of "mb_map page descriptor structures" (new structure, mbpl_pg_descr). This structure contains very basic and essential information, such as the address of the VM page, the number of mbufs that are "in use" on that page, etc. If there is a node present on that general free list, then there is a free mbuf, and allocation from the map is not necessary. Grab free mbuf. If node now no longer contains any free mbufs, detach it from this list and attach it to free list. * If nothing on free list, allocate from map, also allocate memory for mbpl_pg_descr node for the obtained page and break page down into n objects, attaching it to the free list. Future allocations can allocate from that page until we run out. Freeing is equally simple: * Compute index into global array of pointers to mbpl_pg_descr structures based on the address of the mbuf. Locate node and determine on which list its on. * Place mbuf back on that mbpl_pg_descr's free list and if the node was previously on the empty list, move it to the free list, as there is now at least one free mbuf available on it. * If the freed mbuf completes the page, the page can be freed back to the map, but ONLY free it back if min_on_avail is met (sysctl). So you see, it is possible in this way to control the free list, and have many objects cached on the free list, essentially going back to the behavior we presently have, if that's what the sysadmin wants, with only the little overhead of having to deal with the linked lists (which isn't much, as they are both doubly-linked, so insertion/removal is fast). That's it, roughly. I hope this clears up some things for those of you who didn't look at the actual code. Regards, Bosko. -- Bosko Milekic * Voice/Mobile: 514.865.7738 * Pager: 514.921.0237 bmilekic@technokratis.com * http://www.technokratis.com/ To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?Pine.BSF.4.21.0006300005240.6772-100000>