From owner-freebsd-hackers Fri Mar 6 17:05:44 1998 Return-Path: Received: (from majordom@localhost) by hub.freebsd.org (8.8.8/8.8.8) id RAA23344 for freebsd-hackers-outgoing; Fri, 6 Mar 1998 17:05:44 -0800 (PST) (envelope-from owner-freebsd-hackers@FreeBSD.ORG) Received: from smtp02.primenet.com (smtp02.primenet.com [206.165.6.132]) by hub.freebsd.org (8.8.8/8.8.8) with ESMTP id RAA23335 for ; Fri, 6 Mar 1998 17:05:31 -0800 (PST) (envelope-from tlambert@usr09.primenet.com) Received: (from daemon@localhost) by smtp02.primenet.com (8.8.8/8.8.8) id SAA13562; Fri, 6 Mar 1998 18:05:28 -0700 (MST) Received: from usr09.primenet.com(206.165.6.209) via SMTP by smtp02.primenet.com, id smtpd013510; Fri Mar 6 18:05:20 1998 Received: (from tlambert@localhost) by usr09.primenet.com (8.8.5/8.8.5) id SAA25317; Fri, 6 Mar 1998 18:05:16 -0700 (MST) From: Terry Lambert Message-Id: <199803070105.SAA25317@usr09.primenet.com> Subject: Re: Are mbufs aligned or bounded on something? To: dg@root.com Date: Sat, 7 Mar 1998 01:05:15 +0000 (GMT) Cc: semen@iclub.nsu.ru, mike@smith.net.au, freebsd-hackers@FreeBSD.ORG In-Reply-To: <199803060654.WAA24313@implode.root.com> from "David Greenman" at Mar 5, 98 10:54:13 pm X-Mailer: ELM [version 2.4 PL25] MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG > >By the way: if i need aligned memory, should i use contigmalloc(), or > >better to use malloc, and align block by hands? > > All memory returned by malloc() is guaranteed to be power of two aligned > and won't span a page boundry if <= a page in size; there are many places in > the kernel that rely on this. > If you need a large chunk of memory that must be physically contiguous, > then use contigmalloc(). If you need to use contigmalloc(), then you should allocate at boot time. The current kernel does not support kernel page relocation as a means of defragmenting kernel memory to guarantee you the ability to do a contigmalloc() at some later date. Doing this is not terribly hard, but then leaves you with a contiguous region fragmentation problem (which would potentially leave you in the same boat, just less frequently than the current "always") if you alloc and dealloc frequently, and compete with other hardware for contig regions of different sizes. Terry Lambert terry@lambert.org --- Any opinions in this posting are my own and not those of my present or previous employers. To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message