From owner-freebsd-hackers@FreeBSD.ORG Sat Jul 1 09:07:08 2006 Return-Path: X-Original-To: freebsd-hackers@freebsd.org Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 61AEA16A55A for ; Sat, 1 Jul 2006 09:07:08 +0000 (UTC) (envelope-from hselasky@c2i.net) Received: from swip.net (mailfe03.swip.net [212.247.154.65]) by mx1.FreeBSD.org (Postfix) with ESMTP id 7AE1244087 for ; Sat, 1 Jul 2006 08:44:50 +0000 (GMT) (envelope-from hselasky@c2i.net) X-T2-Posting-ID: gvlK0tOCzrqh9CPROFOFPw== X-Cloudmark-Score: 0.000000 [] Received: from mp-217-38-131.daxnet.no ([193.217.38.131] verified) by mailfe03.swip.net (CommuniGate Pro SMTP 5.0.8) with ESMTP id 232122932; Sat, 01 Jul 2006 10:44:48 +0200 From: Hans Petter Selasky To: Peter Jeremy Date: Sat, 1 Jul 2006 10:44:54 +0200 User-Agent: KMail/1.7 References: <200605271102.19799.hselasky@c2i.net> <200606302029.28563.hselasky@c2i.net> <20060630203226.GG734@turion.vk2pj.dyndns.org> In-Reply-To: <20060630203226.GG734@turion.vk2pj.dyndns.org> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200607011044.54872.hselasky@c2i.net> Cc: freebsd-hackers@freebsd.org Subject: Re: contiguous memory allocation problem X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 01 Jul 2006 09:07:08 -0000 On Friday 30 June 2006 22:32, Peter Jeremy wrote: > On Fri, 2006-Jun-30 20:29:28 +0200, Hans Petter Selasky wrote: > >I sometimes see that the USB driver is unable to allocate contiguous > > memory for itself. For example I noticed that FreeBSD was unable to > > allocate 350kbytes of contiguous memory after that I had run "konqueror", > > the KDE web browser and various other memory consuming applications for a > > while. > > I reported this about 18 months ago and I'm fairly certain you even > contributed to the thread at the time. > > >Any comments? > > The latest concensus seems to be that the USB system should make use of > the scatter-gather facilities in the hardware to avoid the need to > allocate large contiguous memory chunks. iedowse@ had mostly finished > implementing this in mid May. Yes, but scatter and gather will add extra complexity to the driver, and maybe an extra memory copy in most cases. The idea is to allocate less than or equal to a page of memory, and then avoid the problem? The most important thing is to keep memory allocations of constant size. For example under my USB system, all memory is allocated at attach. There is no longer allocation and freeing of memory during usage, with a few exceptions. I was thinking I could pre-allocate 2-4MB for the USB system, then make a list of freed memory blocks, and then search this list first, before allocating new memory. Depending on how many different kinds of equipment one plugs, this should work fine. What do you think? --HPS