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
[-- Attachment #1 --]
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
>> bus_dmamem_alloc() call kmem_alloc_attr() directly in this case. One of the
>> things I've been meaning to add to bus_dma is a way to allocate other memory
>> types (e.g. WC memory), and in that case it would be best to just call
>> 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
>===================================================================
>--- 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 >= ptoa((vm_paddr_t)Maxmem) &&
> attr == VM_MEMATTR_DEFAULT) {
> *vaddr = malloc(dmat->maxsize, M_DEVBUF, mflags);
>+ } else if (dmat->nsegments >= btoc(dmat->maxsize) &&
>+ dmat->alignment <= PAGE_SIZE &&
>+ (dmat->boundary == 0 || dmat->boundary >= dmat->lowaddr)) {
>+ /* Page-based multi-segment allocations allowed */
>+ *vaddr = (void *)kmem_alloc_attr(kernel_map, dmat->maxsize,
>+ mflags, 0ul, dmat->lowaddr, attr);
>+ *mapp = &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 = (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.
--
Peter Jeremy
[-- Attachment #2 --]
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.19 (FreeBSD)
iEYEARECAAYFAlAjSX8ACgkQ/opHv/APuId4XgCgk/87aZt8DKG3M4VAGzFiXV3p
P64AoLgImj0PZK47zw6vJ6bH67lkjmgP
=E/cO
-----END PGP SIGNATURE-----
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20120809052415.GB13662>
