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
_______________________________________________
freebsd-stable@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-stable
To unsubscribe, send any mail to "[EMAIL PROTECTED]"

Reply via email to