From owner-freebsd-hackers@FreeBSD.ORG Thu Aug 9 05:24:29 2012 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 1C4BF106564A; Thu, 9 Aug 2012 05:24:29 +0000 (UTC) (envelope-from peter@rulingia.com) Received: from vps.rulingia.com (host-122-100-2-194.octopus.com.au [122.100.2.194]) by mx1.freebsd.org (Postfix) with ESMTP id BB9748FC08; Thu, 9 Aug 2012 05:24:28 +0000 (UTC) Received: from server.rulingia.com (c220-239-247-45.belrs5.nsw.optusnet.com.au [220.239.247.45]) by vps.rulingia.com (8.14.5/8.14.5) with ESMTP id q795OLQU055369 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Thu, 9 Aug 2012 15:24:22 +1000 (EST) (envelope-from peter@rulingia.com) X-Bogosity: Ham, spamicity=0.000000 Received: from server.rulingia.com (localhost.rulingia.com [127.0.0.1]) by server.rulingia.com (8.14.5/8.14.5) with ESMTP id q795OFZF017310 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Thu, 9 Aug 2012 15:24:15 +1000 (EST) (envelope-from peter@server.rulingia.com) Received: (from peter@localhost) by server.rulingia.com (8.14.5/8.14.5/Submit) id q795OFux017309; Thu, 9 Aug 2012 15:24:15 +1000 (EST) (envelope-from peter) Date: Thu, 9 Aug 2012 15:24:15 +1000 From: Peter Jeremy To: John Baldwin Message-ID: <20120809052415.GB13662@server.rulingia.com> References: <20120703111753.GB72292@server.rulingia.com> <20120708110516.GA38312@server.rulingia.com> <201207120826.05577.jhb@freebsd.org> <201208061016.13065.jhb@freebsd.org> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="PNTmBPCT7hxwcZjr" Content-Disposition: inline In-Reply-To: <201208061016.13065.jhb@freebsd.org> X-PGP-Key: http://www.rulingia.com/keys/peter.pgp User-Agent: Mutt/1.5.21 (2010-09-15) Cc: freebsd-hackers@freebsd.org Subject: Re: contigmalloc() breaking Xorg 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: Thu, 09 Aug 2012 05:24:29 -0000 --PNTmBPCT7hxwcZjr Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On 2012-Aug-06 10:16:13 -0400, John Baldwin wrote: >On Thursday, July 12, 2012 8:26:05 am John Baldwin wrote: >> However, rather add a wiredmalloc(), I think you should just have=20 >> bus_dmamem_alloc() call kmem_alloc_attr() directly in this case. One of= the=20 >> things I've been meaning to add to bus_dma is a way to allocate other me= mory=20 >> types (e.g. WC memory), and in that case it would be best to just call= =20 >> kmem_alloc_attr() directly instead. > >After my recent changes, I think this would do the above. What do >you think of this, and if it looks ok, can you test it? > >Index: busdma_machdep.c >=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D >--- busdma_machdep.c (revision 239020) >+++ busdma_machdep.c (working copy) >@@ -533,13 +533,14 @@ bus_dmamem_alloc(bus_dma_tag_t dmat, void** vaddr, > dmat->lowaddr >=3D ptoa((vm_paddr_t)Maxmem) && > attr =3D=3D VM_MEMATTR_DEFAULT) { > *vaddr =3D malloc(dmat->maxsize, M_DEVBUF, mflags); >+ } else if (dmat->nsegments >=3D btoc(dmat->maxsize) && >+ dmat->alignment <=3D PAGE_SIZE && >+ (dmat->boundary =3D=3D 0 || dmat->boundary >=3D dmat->lowaddr)) { >+ /* Page-based multi-segment allocations allowed */ >+ *vaddr =3D (void *)kmem_alloc_attr(kernel_map, dmat->maxsize, >+ mflags, 0ul, dmat->lowaddr, attr); >+ *mapp =3D &contig_dmamap; > } else { >- /* >- * XXX Use Contigmalloc until it is merged into this facility >- * and handles multi-seg allocations. Nobody is doing >- * multi-seg allocations yet though. >- * XXX Certain AGP hardware does. >- */ > *vaddr =3D (void *)kmem_alloc_contig(kernel_map, dmat->maxsize, > mflags, 0ul, dmat->lowaddr, dmat->alignment ? > dmat->alignment : 1ul, dmat->boundary, attr); I've tried this on a -current/amd64 box (r239130) that has 2GB RAM and ZFS. I looped tar(1)s of several bits of /usr/src whilst doing a "-j2 buildworld" and killing X every 30s for about 7 hours. (The Xserver grabs a 8192-page dmamem tag when it starts). It all seemed to work OK. I haven't tried it on the box where I originally saw the problem because that's running 8.x. I'll have a look at backporting your and alc@'s fixes when I get some spare time. --=20 Peter Jeremy --PNTmBPCT7hxwcZjr Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.19 (FreeBSD) iEYEARECAAYFAlAjSX8ACgkQ/opHv/APuId4XgCgk/87aZt8DKG3M4VAGzFiXV3p P64AoLgImj0PZK47zw6vJ6bH67lkjmgP =E/cO -----END PGP SIGNATURE----- --PNTmBPCT7hxwcZjr--