From owner-freebsd-questions Mon May 20 19:47:20 1996 Return-Path: owner-questions Received: (from root@localhost) by freefall.freebsd.org (8.7.3/8.7.3) id TAA14013 for questions-outgoing; Mon, 20 May 1996 19:47:20 -0700 (PDT) Received: from mail.barrnet.net (mail.barrnet.net [131.119.246.7]) by freefall.freebsd.org (8.7.3/8.7.3) with ESMTP id TAA13987; Mon, 20 May 1996 19:47:00 -0700 (PDT) Received: from Root.COM (implode.Root.COM [198.145.90.17]) by mail.barrnet.net (8.7.5/MAIL-RELAY-LEN) with ESMTP id TAA10422; Mon, 20 May 1996 19:46:58 -0700 (PDT) Received: from localhost (localhost [127.0.0.1]) by Root.COM (8.7.5/8.6.5) with SMTP id TAA11579; Mon, 20 May 1996 19:43:45 -0700 (PDT) Message-Id: <199605210243.TAA11579@Root.COM> X-Authentication-Warning: implode.Root.COM: Host localhost [127.0.0.1] didn't use HELO protocol To: Joe McGuckin cc: hackers@FreeBSD.org, questions@FreeBSD.org Subject: Re: Help - Panic Attacks! In-reply-to: Your message of "Mon, 20 May 1996 14:33:41 PDT." <199605202133.OAA21060@ns.via.net> From: David Greenman Reply-To: davidg@Root.COM Date: Mon, 20 May 1996 19:43:45 -0700 Sender: owner-questions@FreeBSD.org X-Loop: FreeBSD.org Precedence: bulk >Our web machine (FreeBSD 2.1, 128Meg) panicked today - twice in a row. > >Can anyone shed some light on this? >May 19 02:03:56 ovation /kernel: panic: kmem_malloc: kmem_map too small This is caused by a bug in the calculation of the size of the malloc area, causing the system to calculate it far too small when a large NMBCLUSTERS value is used. The attached patch fixes this problem. -DG David Greenman Core-team/Principal Architect, The FreeBSD Project Index: kern_malloc.c =================================================================== RCS file: /home/ncvs/src/sys/kern/kern_malloc.c,v retrieving revision 1.12 retrieving revision 1.12.4.1 diff -c -r1.12 -r1.12.4.1 *** kern_malloc.c 1995/05/30 08:05:33 1.12 --- kern_malloc.c 1996/01/29 11:20:25 1.12.4.1 *************** *** 31,37 **** * SUCH DAMAGE. * * @(#)kern_malloc.c 8.3 (Berkeley) 1/4/94 ! * $Id: kern_malloc.c,v 1.12 1995/05/30 08:05:33 rgrimes Exp $ */ #include --- 31,37 ---- * SUCH DAMAGE. * * @(#)kern_malloc.c 8.3 (Berkeley) 1/4/94 ! * $Id: kern_malloc.c,v 1.12.4.1 1996/01/29 11:20:25 davidg Exp $ */ #include *************** *** 39,44 **** --- 39,45 ---- #include #include #include + #include #include #include *************** *** 371,384 **** #if (MAXALLOCSAVE < CLBYTES) ERROR!_kmeminit:_MAXALLOCSAVE_too_small #endif ! npg = VM_KMEM_SIZE/ NBPG; ! if( npg > cnt.v_page_count) ! npg = cnt.v_page_count; kmemusage = (struct kmemusage *) kmem_alloc(kernel_map, (vm_size_t)(npg * sizeof(struct kmemusage))); kmem_map = kmem_suballoc(kernel_map, (vm_offset_t *)&kmembase, ! (vm_offset_t *)&kmemlimit, (vm_size_t)(npg * NBPG), FALSE); #ifdef KMEMSTATS for (indx = 0; indx < MINBUCKET + 16; indx++) { if (1 << indx >= CLBYTES) --- 372,384 ---- #if (MAXALLOCSAVE < CLBYTES) ERROR!_kmeminit:_MAXALLOCSAVE_too_small #endif ! npg = (nmbclusters * MCLBYTES + VM_KMEM_SIZE) / PAGE_SIZE; kmemusage = (struct kmemusage *) kmem_alloc(kernel_map, (vm_size_t)(npg * sizeof(struct kmemusage))); kmem_map = kmem_suballoc(kernel_map, (vm_offset_t *)&kmembase, ! (vm_offset_t *)&kmemlimit, (vm_size_t)(npg * PAGE_SIZE), ! FALSE); #ifdef KMEMSTATS for (indx = 0; indx < MINBUCKET + 16; indx++) { if (1 << indx >= CLBYTES) *************** *** 387,393 **** bucket[indx].kb_elmpercl = CLBYTES / (1 << indx); bucket[indx].kb_highwat = 5 * bucket[indx].kb_elmpercl; } ! for (indx = 0; indx < M_LAST; indx++) ! kmemstats[indx].ks_limit = npg * NBPG * 6 / 10; #endif } --- 387,399 ---- bucket[indx].kb_elmpercl = CLBYTES / (1 << indx); bucket[indx].kb_highwat = 5 * bucket[indx].kb_elmpercl; } ! /* ! * Limit maximum memory for each type to 60% of malloc area size or ! * 60% of physical memory, whichever is smaller. ! */ ! for (indx = 0; indx < M_LAST; indx++) { ! kmemstats[indx].ks_limit = min(cnt.v_page_count * PAGE_SIZE, ! (npg * PAGE_SIZE - nmbclusters * MCLBYTES)) * 6 / 10; ! } #endif }