From owner-freebsd-stable@FreeBSD.ORG Thu Oct 26 10:20:06 2006 Return-Path: X-Original-To: freebsd-stable@freebsd.org Delivered-To: freebsd-stable@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 06DEB16A49E for ; Thu, 26 Oct 2006 10:20:05 +0000 (UTC) (envelope-from rwatson@FreeBSD.org) Received: from cyrus.watson.org (cyrus.watson.org [209.31.154.42]) by mx1.FreeBSD.org (Postfix) with ESMTP id 754F043D55 for ; Thu, 26 Oct 2006 10:20:05 +0000 (GMT) (envelope-from rwatson@FreeBSD.org) Received: from fledge.watson.org (fledge.watson.org [209.31.154.41]) by cyrus.watson.org (Postfix) with ESMTP id 2AD9046E74; Thu, 26 Oct 2006 06:20:05 -0400 (EDT) Date: Thu, 26 Oct 2006 11:20:05 +0100 (BST) From: Robert Watson X-X-Sender: robert@fledge.watson.org To: Scott Long In-Reply-To: <20061026091253.J69980@fledge.watson.org> Message-ID: <20061026111723.K33725@fledge.watson.org> References: <20061025183308.L33725@fledge.watson.org> <838FCA83-20F8-4A09-A025-E69956032F86@lassitu.de> <45400286.9020402@samsco.org> <20061026091253.J69980@fledge.watson.org> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed Cc: FreeBSD Stable , Andreas Sons , Stefan Bethke Subject: Re: panic: kmem_map too small X-BeenThere: freebsd-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Production branch of FreeBSD source code List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 26 Oct 2006 10:20:06 -0000 On Thu, 26 Oct 2006, Robert Watson wrote: > On Wed, 25 Oct 2006, Scott Long wrote: > >> There are no obvious culprits from what you posted. The kernel was only >> trying to allocate 60 bytes, and the 64-byte bucket didn't look to be >> overly used. None of the other zones look terribly over-used either. The >> 'show malloc' command doesn't really give enough stats to be terribly >> useful, IMHO. > > What would you add to the output to make it more useful? The main > difference between "show malloc" and "vmstat -m", other than any "use over > time" associated with multiple runs of vmstat -m, is the malloc size > bitmask. This is relatively easily added to kern_malloc.c. > >> And neither of the commands can effectively track things like contig memory >> allocator. Can you try the following two commands: > > Want to add "show contigmalloc"? > > I've found it significantly easier to debug memory leaks since adding these > DDB commands, but they are easily enhanced to carry more information than > they do now. After a bit of looking at the output, etc, I agree with your conclusion that what's there now is lacking. The attached patch, committed to -CURRENT but not yet to -STABLE, makes the "show malloc" DDB output a bit more like the "vmstat -m" output, in that it summarizes the allocation counts and adds the memory use information. Sample output: db> show malloc Type InUse MemUse Requests GEOM 111 14K 529 fw_xfer 0 0K 0 $PIR 0 0K 0 pfs_vncache 0 0K 0 pfs_nodes 20 3K 20 nexusdev 2 1K 2 This is much more useful for malloc types that see variable size allocation, rather than fixed-size allocation, and aligns better with what is offered by user space vmstat -m. I still don't implement interpretting the size mask, as occurs in user space. Robert N M Watson Computer Laboratory University of Cambridge Index: kern_malloc.c =================================================================== RCS file: /zoo/cvsup/FreeBSD-CVS/src/sys/kern/kern_malloc.c,v retrieving revision 1.155 diff -u -r1.155 kern_malloc.c --- kern_malloc.c 23 Jul 2006 19:55:41 -0000 1.155 +++ kern_malloc.c 26 Oct 2006 10:13:42 -0000 @@ -802,20 +802,26 @@ struct malloc_type_internal *mtip; struct malloc_type *mtp; u_int64_t allocs, frees; + u_int64_t alloced, freed; int i; - db_printf("%18s %12s %12s %12s\n", "Type", "Allocs", "Frees", - "Used"); + db_printf("%18s %12s %12s %12s\n", "Type", "InUse", "MemUse", + "Requests"); for (mtp = kmemstatistics; mtp != NULL; mtp = mtp->ks_next) { mtip = (struct malloc_type_internal *)mtp->ks_handle; allocs = 0; frees = 0; + alloced = 0; + freed = 0; for (i = 0; i < MAXCPU; i++) { allocs += mtip->mti_stats[i].mts_numallocs; frees += mtip->mti_stats[i].mts_numfrees; + alloced += mtip->mti_stats[i].mts_memalloced; + freed += mtip->mti_stats[i].mts_memfreed; } - db_printf("%18s %12ju %12ju %12ju\n", mtp->ks_shortdesc, - allocs, frees, allocs - frees); + db_printf("%18s %12ju %12juK %12ju\n", + mtp->ks_shortdesc, allocs - frees, + (alloced - freed + 1023) / 1024, allocs); } } #endif