kern/81301: problems with new "contigmalloc" routine

Hans Petter Selasky hselasky at c2i.net
Fri May 20 11:30:12 GMT 2005


>Number:         81301
>Category:       kern
>Synopsis:       problems with new "contigmalloc" routine
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    freebsd-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Fri May 20 11:30:11 GMT 2005
>Closed-Date:
>Last-Modified:
>Originator:     HPS
>Release:        FreeBSD 6.0-CURRENT i386
>Organization:
>Environment:
System: FreeBSD 6.0-CURRENT FreeBSD 6.0-CURRENT #149: Tue May 10 20:43:15 CEST 
2005 root@:/usr/obj/usr/src/sys/custom i386

>Description:

The new "contigmalloc" routine have got three problems. First it locks Giant, 
which will cause lock order reversal problems. Secondly it sleeps even if 
flag M_NOWAIT is passed. Thirdly flag M_ZERO does not have any effect. 

1st problem:

May 20 12:33:44  kernel: lock order reversal
May 20 12:33:44  kernel: 1st 0xc175a6c8 ugen lock (ugen lock) 
@ /usr/mnt3/src/sys/dev/usb2/_ugen.c:1452
May 20 12:33:44  kernel: 2nd 0xc09bdde0 Giant (Giant) 
@ /usr/mnt3/src/sys/vm/vm_contig.c:550
May 20 12:33:44  kernel: KDB: stack backtrace:
May 20 12:33:44  kernel: witness_checkorder(c09bdde0,9,c08e34af,226) at 
witness_checkorder+0x50c
May 20 12:33:44  kernel: _mtx_lock_flags(c09bdde0,0,c08e34af,226,8) at 
_mtx_lock_flags+0x40
May 20 12:33:44  kernel: contigmalloc(184ec,c0952c60,1,0,ffffffff) at 
contigmalloc+0x45
May 20 12:33:44  kernel: bus_dmamem_alloc(c1aacc00,d4cd7974,5,d4cd7978) at 
bus_dmamem_alloc+0x61
May 20 12:33:44  kernel: usb_alloc_mem(184e0,4,8,8,d4164ae4) at 
usb_alloc_mem+0x53

2nd problem:

May 20 12:33:44  kernel: malloc(M_WAITOK) of "g_bio", forcing M_NOWAIT with 
the following non-sleepable locks held:
May 20 12:33:44  kernel: exclusive sleep mutex ugen lock r = 0 (0xc175a6c8) 
locked @ /usr/mnt3/src/sys/dev/usb2/_ugen.c:1452
May 20 12:33:44  kernel: KDB: stack backtrace:
May 20 12:33:46  kernel: witness_warn(5,0,c08e3022,c08c3c87) at 
witness_warn+0x1a8
May 20 12:33:46  kernel: uma_zalloc_arg(c103dc60,0,102) at uma_zalloc_arg+0x4b
May 20 12:33:46  kernel: g_allotpages(c1af918c,d4cd783c,1,1,d4cd7800) at 
swap_pager_putpages+0x413
May 20 12:33:46  kernel: vm_pageout_flush(d4cd783c,1,1,c1460d88,c1461058) at 
vm_pageout_flush+0xf5
May 20 12:33:46  kernel: vm_contig_launder_page(e269,0,c0a0b8d0,ffffffff,f) at 
vm_contig_launder_page+0xa8
May 20 12:33:46  kernel: vm_page_alloc_contig(19,0,0,ffffffff,10) at 
vm_page_alloc_contig+0x204
May 20 12:33:46  kernel: contigmalloc(184ec,c0952c60,1,0,ffffffff) at 
contigmalloc+0x337
May 20 12:33:46  kernel: bus_dmamem_alloc(c1aacc00,d4cd7974,5,d4cd7978) at 
bus_dmamem_alloc+0x61
May 20 12:33:46  kernel: usb_alloc_mem(184e0,4,8,8,d4164ae4) at 
usb_alloc_mem+0x53

>How-To-Repeat:

>Fix:

The flags passed to "contigmalloc" must be passed on, and should not be 
ignored. If unused flags are passed to "contigmalloc", it should warn. 
"Giant" should not be locked during memory allocation.
>Release-Note:
>Audit-Trail:
>Unformatted:


More information about the freebsd-bugs mailing list