Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 12 Apr 2001 11:46:52 -0700 (MST)
From:      Logan Gabriel <logan@mail.2cactus.com>
To:        freebsd-hackers@FreeBSD.org
Subject:   Kernel malloc problems with M_NOWAIT.
Message-ID:  <Pine.BSF.4.21.0104121141470.77198-101000@mail.2cactus.com>

index | next in thread | raw e-mail

[-- Attachment #1 --]
There is a hard to duplicate race condition in freebsd's
kernel malloc.  Bassically it is possiables for the kernel    
to tsleep way down in vm_page_sleep_busy even when M_NOWAIT
is spefcied.  Under some conditions this can block the kernel
completly.

Attatched is a kernel module that demonstrates this rare condition,
The module has been tested on 4.2-RELEASE generic kernel configurations
as well as -STABLE.  The module only seems to work about one out of every 
10 or 15 tries which makes me think there is a race condition happening.

# ps -l -N ./kernel.31 -M ./vmcore.31
  UID   PID  PPID CPU PRI NI   VSZ  RSS WCHAN  STAT  TT       TIME COMMAND
    0   474   332   0 -18  0   176    0 vmopar D+   #C1    0:00.00  (kldload)
    0   477   333   0 -18  0  1372    0 thrd_s DV+  #C9    0:00.00  (csh)

(kgdb) proc 474
(kgdb) bt
#0  mi_switch () at ../../kern/kern_synch.c:858
#1  0xc016e0d9 in tsleep (ident=0xc05e0794, priority=4, wmesg=0xc02decd1 "vmopar", timo=0) at ../../kern/kern_synch.c:467
#2  0xc0245fbf in vm_object_page_remove (object=0xc0352cc0, start=6882, end=6907, clean_only=0) at ../../vm/vm_page.h:565
#3  0xc0242506 in vm_map_delete (map=0xc0352b60, start=3248361472, end=3248463872) at ../../vm/vm_map.c:1809
#4  0xc02406af in kmem_malloc (map=0xc0352b60, size=102400, flags=1) at ../../vm/vm_kern.c:365
#5  0xc0166bc7 in malloc (size=100000, type=0xc191d840, flags=1) at ../../kern/kern_malloc.c:188
#6  0xc191c6da in ?? ()
#7  0xc015b49b in module_register_init (arg=0xc191d824) at ../../kern/kern_module.c:109
#8  0xc015ba57 in linker_file_sysinit (lf=0xc190fa80) at ../../kern/kern_linker.c:151
#9  0xc015bbd8 in linker_load_file (filename=0xc18e1800 "./test_module_nowait_42_generic.ko", result=0xd3f28f28) at ../../kern/kern_linker.c:285
#10 0xc015c422 in kldload (p=0xd2b8e400, uap=0xd3f28f80) at ../../kern/kern_linker.c:678
#11 0xc02a6e09 in syscall2 (frame={tf_fs = 47, tf_es = 47, tf_ds = 47, tf_edi = 0, tf_esi = 1, tf_ebp = -1077937200, tf_isp = -739078188, 
      tf_ebx = -1077937112, tf_edx = 0, tf_ecx = 134559200, tf_eax = 304, tf_trapno = 12, tf_err = 2, tf_eip = 134513812, tf_cs = 31, 
      tf_eflags = 647, tf_esp = -1077937244, tf_ss = 47}) at ../../i386/i386/trap.c:1150
#12 0xc029b195 in Xint0x80_syscall ()
#13 0x8048135 in ?? ()

# vmstat -m -N ./kernel.31 -M ./vmcore.31 | tail -2
Memory Totals:  In Use    Free    Requests
                 2315K     50K      322928


[-- Attachment #2 --]
o:X{oHϿSLIuc'YCӵ4w4ٙݙe3Ͷ]]&{?Q=Rbo4\V"*ɲ$Aǘh
|B][6YNAi(_,+J	ي/!i psf%I'H!O;Ic*΂,IO$νx~G|9<tFf>%\65`P=3@S.QyF
*q>cu*&{ڜ5췚թ۽hmuBGk<u*7f窩Mg9n@+L,&*#7ZGRU.ܗY})xܼ^-[QZ{\Ty8i
w(mzi-jWkq1ܞX7!WݜL_*Ir]ZzhG3fƈ"ͿvVjTnrHF]O*dGIp~D\x%+N.µX璢IoF)C^0Nm\pxOg9ICLxa[@2tUۣEo<5W3N0ݘOf
3M}'[#$u4Y[W_7:!|¡(M8Yؗ#sh!Ѭk;1j7>	àFWAsahZOT_GCeu<SAX꿢,X)VovqŸ`Z,sڻ4|83J)/gܾ3OX
6,]7_@P~<́G_	>p*.C.!.8c(LlR_/Ue'Jb)]21P;VW[&r~LF0V_GX7TYwK/J	Z4*[R<mcQCkMߩ/`OYF6E,X],j)JfȐ!C2dȐ!C2d6(
help

Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?Pine.BSF.4.21.0104121141470.77198-101000>