From owner-freebsd-hackers Thu Apr 12 13:18: 1 2001 Delivered-To: freebsd-hackers@freebsd.org Received: from fw.wintelcom.net (ns1.wintelcom.net [209.1.153.20]) by hub.freebsd.org (Postfix) with ESMTP id 12F4137B424 for ; Thu, 12 Apr 2001 13:17:58 -0700 (PDT) (envelope-from bright@fw.wintelcom.net) Received: (from bright@localhost) by fw.wintelcom.net (8.10.0/8.10.0) id f3CKHvG19152; Thu, 12 Apr 2001 13:17:57 -0700 (PDT) Date: Thu, 12 Apr 2001 13:17:57 -0700 From: Alfred Perlstein To: Logan Gabriel Cc: freebsd-hackers@FreeBSD.ORG Subject: Re: Kernel malloc problems with M_NOWAIT. Message-ID: <20010412131757.J24582@fw.wintelcom.net> References: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2.5i In-Reply-To: ; from logan@mail.2cactus.com on Thu, Apr 12, 2001 at 11:46:52AM -0700 X-all-your-base: are belong to us. Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG * Logan Gabriel [010412 11:50] wrote: > 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. > Please try the attached patch: Index: vm_kern.c =================================================================== RCS file: /home/ncvs/src/sys/vm/vm_kern.c,v retrieving revision 1.61.2.1 diff -u -r1.61.2.1 vm_kern.c --- vm_kern.c 2000/08/04 22:31:11 1.61.2.1 +++ vm_kern.c 2001/04/12 20:19:17 @@ -362,7 +362,7 @@ vm_map_lock(map); goto retry; } - vm_map_delete(map, addr, addr + size); + vm_map_delete(map, addr, addr + (i - PAGE_SIZE)); vm_map_unlock(map); if (flags & M_ASLEEP) { VM_AWAIT; if it bombs please try: Index: vm_kern.c =================================================================== RCS file: /home/ncvs/src/sys/vm/vm_kern.c,v retrieving revision 1.61.2.1 diff -u -r1.61.2.1 vm_kern.c --- vm_kern.c 2000/08/04 22:31:11 1.61.2.1 +++ vm_kern.c 2001/04/12 20:19:59 @@ -362,7 +362,7 @@ vm_map_lock(map); goto retry; } - vm_map_delete(map, addr, addr + size); + vm_map_delete(map, addr, addr + i); vm_map_unlock(map); if (flags & M_ASLEEP) { VM_AWAIT; -- -Alfred Perlstein - [bright@wintelcom.net|alfred@freebsd.org] Instead of asking why a piece of software is using "1970s technology," start asking why software is ignoring 30 years of accumulated wisdom. To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message