Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 9 Aug 2012 15:24:15 +1000
From:      Peter Jeremy <peter@rulingia.com>
To:        John Baldwin <jhb@freebsd.org>
Cc:        freebsd-hackers@freebsd.org
Subject:   Re: contigmalloc() breaking Xorg
Message-ID:  <20120809052415.GB13662@server.rulingia.com>
In-Reply-To: <201208061016.13065.jhb@freebsd.org>
References:  <20120703111753.GB72292@server.rulingia.com> <20120708110516.GA38312@server.rulingia.com> <201207120826.05577.jhb@freebsd.org> <201208061016.13065.jhb@freebsd.org>

next in thread | previous in thread | raw e-mail | index | archive | help

--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 <jhb@freebsd.org> 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--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20120809052415.GB13662>