contigmalloc() breaking Xorg

Peter Jeremy peter at rulingia.com
Thu Aug 9 05:24:29 UTC 2012


On 2012-Aug-06 10:16:13 -0400, John Baldwin <jhb at 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
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 196 bytes
Desc: not available
Url : http://lists.freebsd.org/pipermail/freebsd-hackers/attachments/20120809/5e189367/attachment.pgp


More information about the freebsd-hackers mailing list