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>

next in thread | raw e-mail | index | archive | help
  This message is in MIME format.  The first part should be readable text,
  while the remaining parts are likely unreadable without MIME-aware tools.
  Send mail to mime@docserver.cac.washington.edu for more info.

--0-329173002-987101212=:77198
Content-Type: TEXT/PLAIN; charset=US-ASCII

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


--0-329173002-987101212=:77198
Content-Type: APPLICATION/x-tar-gz; name="malloc.tgz"
Content-Transfer-Encoding: BASE64
Content-ID: <Pine.BSF.4.21.0104121146520.77198@mail.2cactus.com>
Content-Description: 
Content-Disposition: attachment; filename="malloc.tgz"

H4sIAG+V1ToAA+1Ye2+bSBDPv+FTTEmq4MR1AGP7FCeRHNvtWfGj8kOn07Wi
GJYYGYMF+JI0zXe/2QXjBzSprqnb0/GTkNnZmZ2Z3ZllxjPNtl1dnbnGwian
ez8EoIgVUYQ9AKlSYr+I5W80gIpcVoqKIioSssmyJO1B6ceYs4mFH2gewN4N
8fzJE3y3E0LsXRi0W8w2zn+mWU5Bf2kdkiiWFeWr518si/H5FytKCdmKiozn
L760IWn4n5//geXo9sIgcO7f+6dzzdNmhcklt0nGJ0ghT4nnEDtJD2Mqhc6C
LEkP7ufET5IXlpskzr20lfHBiYDxr6Z4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0qZ9X9iKcv/XeDAMh3MMVA7tVZX/Z1bJtxyvN1+vUyD
uKNGMPKFlR+slqPt1VZf9cDth+1HWDdUWRMWd0vsEy+sSonUCVo00NsqpVtS
gzxtY/JR+0NryQPiGJb5q9xNm/kf36kvquO5/McCYPX/T1lGNkUsF7P83wWS
H1hdLGqyKYu/SoRmyJAhQ4YMGTJkyJAhQ4YMGTJk+B78AzaYzwwAKAAA
--0-329173002-987101212=:77198--

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-hackers" in the body of the message




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