From owner-p4-projects Fri May 3 10: 5:17 2002 Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id D408237B404; Fri, 3 May 2002 10:05:06 -0700 (PDT) Delivered-To: perforce@freebsd.org Received: from mail.speakeasy.net (mail17.speakeasy.net [216.254.0.217]) by hub.freebsd.org (Postfix) with ESMTP id 102DF37B41E for ; Fri, 3 May 2002 10:05:03 -0700 (PDT) Received: (qmail 30092 invoked from network); 3 May 2002 17:05:01 -0000 Received: from unknown (HELO server.baldwin.cx) ([216.27.160.63]) (envelope-sender ) by mail17.speakeasy.net (qmail-ldap-1.03) with DES-CBC3-SHA encrypted SMTP for ; 3 May 2002 17:05:01 -0000 Received: from laptop.baldwin.cx (gw1.twc.weather.com [216.133.140.1]) by server.baldwin.cx (8.11.6/8.11.6) with ESMTP id g43H4wF12210; Fri, 3 May 2002 13:04:59 -0400 (EDT) (envelope-from jhb@FreeBSD.org) Message-ID: X-Mailer: XFMail 1.5.2 on FreeBSD X-Priority: 3 (Normal) Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 8bit MIME-Version: 1.0 In-Reply-To: Date: Fri, 03 May 2002 13:04:52 -0400 (EDT) From: John Baldwin To: John Baldwin Subject: Re: PERFORCE change 10740 for review Cc: Perforce Change Reviews Cc: Perforce Change Reviews , Jonathan Mini , Julian Elischer Sender: owner-p4-projects@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG On 03-May-2002 John Baldwin wrote: > > On 03-May-2002 Julian Elischer wrote: >> >> >> On Fri, 3 May 2002, John Baldwin wrote: >> >>> >>> We already have a slab allocator for that, no need to reinvent it. >> >> You do NOT have a slab allocator that allocates fulli linked up thread >> structures with preallocated vm ojects for the stack etc. > > Uh, only cause you haven't bothered to write proper constructor's > destructor's > for the uma zone then. We _do_ have a proper slab allocator and by trying > to manage it yourself you are simply preventing uma from being fully able > to manage the memory in the system. Correction. :) s/ctor/init/, s/dtor/fini/. In uma we have four functions associated with a zone: ctor() - called whenever a 'user' malloc, like uma_zalloc() is called dtor() - called whenever a 'user' free is called() init() - called when on objects when they are actually allocated into a slab from kmem fini() - called when on objects when the slab they are part of is released back to kmem Thus, you can perform type-stable initialization in init() and teardown in fini() and it won't get called on each malloc() or free(), but only when the memory is actually allocated from of free'd to KVM. By allowing uma to manage your "free" but still type-stable threads, you allow it to release those unused structures to kvm if there is a memory shortage. This lets the kernel adjust to temporary memory needs on the fly. For example, if we suddenly need a lot of mbuf's, uma can go find some unused slabs, fini() them, and then make them into mbuf slabs instead. Later when the need for mbuf's recedes to its normal level and more threads are needed, uma can grab some of the free mbuf slabs and convert them to thread slabs. This allows the kernel to better adjust to changing memory conditions in the kernel. If you insist on using your own free list to duplicate the work of init()/fini(), you reduce uma's ability to handle changing memory conditions. Does this make sense? -- John Baldwin <>< http://www.FreeBSD.org/~jhb/ "Power Users Use the Power to Serve!" - http://www.FreeBSD.org/ To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe p4-projects" in the body of the message