From owner-p4-projects@FreeBSD.ORG Thu Oct 20 17:42:19 2005 Return-Path: X-Original-To: p4-projects@freebsd.org Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 7317016A422; Thu, 20 Oct 2005 17:42:19 +0000 (GMT) X-Original-To: perforce@freebsd.org Delivered-To: perforce@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 0E66E16A41F for ; Thu, 20 Oct 2005 17:42:19 +0000 (GMT) (envelope-from bb+lists.freebsd.perforce@cyrus.watson.org) Received: from repoman.freebsd.org (repoman.freebsd.org [216.136.204.115]) by mx1.FreeBSD.org (Postfix) with ESMTP id CA86143D5A for ; Thu, 20 Oct 2005 17:42:18 +0000 (GMT) (envelope-from bb+lists.freebsd.perforce@cyrus.watson.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.13.1/8.13.1) with ESMTP id j9KHgI6I016564 for ; Thu, 20 Oct 2005 17:42:18 GMT (envelope-from bb+lists.freebsd.perforce@cyrus.watson.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.13.1/8.13.1/Submit) id j9KHgIMu016561 for perforce@freebsd.org; Thu, 20 Oct 2005 17:42:18 GMT (envelope-from bb+lists.freebsd.perforce@cyrus.watson.org) Date: Thu, 20 Oct 2005 17:42:18 GMT Message-Id: <200510201742.j9KHgIMu016561@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to bb+lists.freebsd.perforce@cyrus.watson.org using -f From: Robert Watson To: Perforce Change Reviews Cc: Subject: PERFORCE change 85603 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 20 Oct 2005 17:42:20 -0000 http://perforce.freebsd.org/chv.cgi?CH=85603 Change 85603 by rwatson@rwatson_zoo on 2005/10/20 17:42:11 Add "show malloc" to DDB. Affected files ... .. //depot/projects/trustedbsd/audit3/sys/kern/kern_malloc.c#5 edit Differences ... ==== //depot/projects/trustedbsd/audit3/sys/kern/kern_malloc.c#5 (text+ko) ==== @@ -34,6 +34,7 @@ #include __FBSDID("$FreeBSD: src/sys/kern/kern_malloc.c,v 1.146 2005/08/02 20:03:23 ru Exp $"); +#include "opt_ddb.h" #include "opt_vm.h" #include @@ -69,6 +70,8 @@ #include #endif +#include + /* * When realloc() is called, if the new size is sufficiently smaller than * the old size, realloc() will allocate a new, smaller block to avoid @@ -813,6 +816,30 @@ SYSCTL_INT(_kern, OID_AUTO, malloc_count, CTLFLAG_RD, &kmemcount, 0, "Count of kernel malloc types"); +#ifdef DDB +DB_SHOW_COMMAND(malloc, db_show_malloc) +{ + struct malloc_type_internal *mtip; + struct malloc_type *mtp; + u_int64_t allocs, frees; + int i; + + db_printf("%18s %12s %12s %12s\n", "Type", "Allocs", "Frees", + "Used"); + for (mtp = kmemstatistics; mtp != NULL; mtp = mtp->ks_next) { + mtip = (struct malloc_type_internal *)mtp->ks_handle; + allocs = 0; + frees = 0; + for (i = 0; i < MAXCPU; i++) { + allocs += mtip->mti_stats[i].mts_numallocs; + frees += mtip->mti_stats[i].mts_numfrees; + } + db_printf("%18s %12llu %12llu %12llu\n", mtp->ks_shortdesc, + allocs, frees, allocs - frees); + } +} +#endif + #ifdef MALLOC_PROFILE static int