*BSD News Article 13869


Return to BSD News archive

Newsgroups: comp.os.386bsd.bugs
Path: sserve!newshost.anu.edu.au!munnari.oz.au!news.Hawaii.Edu!ames!agate!doc.ic.ac.uk!marble.uknet.ac.uk!mcsun!fuug!kiae!relcom!maginf!amsteel!ivans
From: ivans@amsteel.chel.su (Mike Ivans)
Subject: Re: kmem_map overflow with 0.2.2 kernel
Organization: AMsteel Joint Venture
References: <C4Kw3q.C6M@sugar.neosoft.com>
Message-ID: <1993Mar31.075521.29358@amsteel.chel.su>
Date: Wed, 31 Mar 1993 07:55:21 GMT
Lines: 102

peter@NeoSoft.com (Peter da Silva) writes:

>distribution loaded on /var1 (temporarily mounted as /tmp) I have been
>getting reproducible kmem_map crashes using the /tmp/extract program. Using
>"cat bin* | compress -d | cpio -pcdumv" works, but I'd like to find out
>what the problem is.

>Any ideas? This is a pretty vanilla (if old) installation.

I  had  a similar problem while compiling X with sources on sparcstation,
connected to my 386bsd box through NFS. I solved  the  problem  with  the
help of the following patch for vm_kern.c:

  | Path: amsteel!maginf!kiae!demos!fuug!mcsun!uknet!doc.ic.ac.uk!pipex!uunet!ihz.compuserve.com!mdickson
  | From: mdickson@csi.compuserve.com (Michael Dickson)
  | Newsgroups: comp.unix.bsd
  | Subject: A fix for kern_malloc panics
  | Message-ID: <MDICKSON.93Jan18113820@mhaao.csi.compuserve.com>
  | Date: 18 Jan 93 16:40:52 GMT
  | Sender: news@csi.compuserve.com (Usenet News)
  | Reply-To: m.dickson@csi.CompuServe.com
  | Distribution: comp.unix.bsd
  | Organization: CompuServe, Inc.
  | Lines: 74
  |
  | All,
  |
  | Well, here's a patch that I believe should fix the problems
  | we've been seeing with panics (kmem_map too small).  Note that
  | this is only a partial fix.  There is some extra work to do
  | to complete the changes.
  |
  |   In short, the M_WAITOK and M_NOWAIT flags passed to the kernel
  | memory allocator routines are converted to boolean TRUE/FALSE
  | values when passed in parameter "canwait" to kern_malloc.  The logic
  | in kern_malloc is incorrectly coded so that a panic is generated
  | if canwait is TRUE and a null is returned on the FALSE condition.
  | This is obviously backwards (even the comments indicate the correct
  | behaviour).  Basically the M_NOWAIT case is designed for interrupt
  | time allocational where a request must be satisfied immediately.
  | The vast majority of the allocations happen using M_WAITOK.
  |
  |   I found this after doing some debugging.  In most cases when
  | the machine would panic it was during a bursty load condition
  | creating a temporary memory shortfall, hence the panic.  This change
  | allows callers to detect the shortfall and act accordingly.
  |
  |   Note that this is really only a partial fix.  There are a couple
  | of places where MALLOC is called where the return value is NOT
  | checked.  Ideally these also need to be fixed.
  |
  | Anyway, here's the patch.  Enjoy.
  |
  | Mike Dickson
  | Compuserve, Incorporated
  | m.dickson@csi.compuserve.com
  |
  |
  | *** vm_kern.c.save	Sun Jan 10 12:51:05 1993
  | --- vm_kern.c	Sun Jan 17 01:39:03 1993
  | ***************
  | *** 360,365 ****
  | --- 360,366 ----
  |   	vm_offset_t		addr;
  |   	vm_page_t		m;
  |   	extern vm_object_t	kmem_object;
  | + 	int			result;
  |
  |   	if (map != kmem_map && map != mb_map && map != buffer_map)
  |   		panic("kern_malloc_alloc: map != {kmem,mb,buffer}_map");
  | ***************
  | *** 367,377 ****
  |   	size = round_page(size);
  |   	addr = vm_map_min(map);
  |
  | ! 	if (vm_map_find(map, NULL, (vm_offset_t)0,
  | ! 			&addr, size, TRUE) != KERN_SUCCESS) {
  | ! 		if (canwait)
  |   			panic("kmem_malloc: kmem_map too small");
  | ! 		return(0);
  |   	}
  |
  |   	/*
  | --- 368,382 ----
  |   	size = round_page(size);
  |   	addr = vm_map_min(map);
  |
  | ! 	result = vm_map_find(map, NULL, (vm_offset_t)0, &addr, size, TRUE);
  | ! 	if (result != KERN_SUCCESS) {
  | ! 		if (canwait) {
  | ! 		        return(0);
  | ! 		}
  | ! 		else {
  | ! 		        printf("kmem_malloc: bad status return of %d.\n", result);
  |   			panic("kmem_malloc: kmem_map too small");
  | ! 		}
  |   	}
  |
  |   	/*
-- 
ιΧΑΞΟΧ νΙΘΑΙΜ (A Bear With a Little Brain), σπ AMsteel.
    Voice:  (35137) 3-0267, 7-3406. E-mail:  ivans@amsteel.chel.su