From owner-freebsd-arch Fri Feb 7 18:27:25 2003 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 8152F37B401 for ; Fri, 7 Feb 2003 18:27:24 -0800 (PST) Received: from elvis.mu.org (elvis.mu.org [192.203.228.196]) by mx1.FreeBSD.org (Postfix) with ESMTP id 5FD2D43FDF for ; Fri, 7 Feb 2003 18:27:23 -0800 (PST) (envelope-from bright@elvis.mu.org) Received: by elvis.mu.org (Postfix, from userid 1192) id F0B59AE22C; Fri, 7 Feb 2003 18:27:22 -0800 (PST) Date: Fri, 7 Feb 2003 18:27:22 -0800 From: Alfred Perlstein To: Jeff Roberson Cc: Gary Thorpe , Julian Elischer , Peter Wemm , Dag-Erling Smorgrav , arch@FreeBSD.ORG Subject: Re: New kernel allocation API Message-ID: <20030208022722.GB88781@elvis.mu.org> References: <20030206193815.71344.qmail@web41205.mail.yahoo.com> <20030207205529.K72073-100000@mail.chesapeake.net> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20030207205529.K72073-100000@mail.chesapeake.net> User-Agent: Mutt/1.4i Sender: owner-freebsd-arch@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG * Jeff Roberson [030207 18:10] wrote: > On Thu, 6 Feb 2003, Gary Thorpe wrote: > > > How will it make it faster? By jumping to the group of memory slabs > > that would match that size? > > Yes. Right now in malloc you have to look up the zone based on the > address. I have a hack that lets us do this in constant time. It > basically goes like this: *snip* It seems that you've missed reading the original allocator or something, there's a cheap way to do this that doesn't require too much overhead. Since you know the max size of the malloc arena you simply allocated "size of malloc arena" / granulatity to realize "number of pointers". You then allocate "number of pointers". Now as you allocate portions of the malloc arena for slabs you point the pointers corresponding to the granule at the slab. Now you can take any pointer and figure out which granule it is associated with in O(1) time. Yes there is a space tradeoff, but it avoids this pmap_kextract nonsense and multiple pointer dereferences. -Alfred To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-arch" in the body of the message