Subject: pool allocator diagnostic helpers
To: None <tech-kern@netbsd.org>
From: Jason Thorpe <thorpej@nas.nasa.gov>
List: tech-kern
Date: 05/10/1999 13:55:52
Hi folks...

I've made some changes to the pool allocator which will aid in tracking
down problems with memory allocation...

I've added a "show pool" command to DDB, which dumps fairly complete
information about a pool.  Two modifiers ara available: /p (show page
headers) and /l (show log).

Logging is now enabled on a per-pool basis, so if you only need to track
allocations and frees on the mclpool, you can do that by making a change to
the pool_init() call that passes PR_LOGGING.  You can enable logging on all
pools by using the kernel option POOL_DIAGNOSTIC.

Pool logging now also works on pools that are not pool_create()'d, but
rather just pool_init()'d.  If the pool_init() call is made too early to use
malloc(), logging is disabled automatically.

I've also changed the ABI somewhat; file and line indicators are now ALWAYS
passed to pool_get(), pool_put(), and pool_reclaim().  These are used to
perform reentrancy checking and logging.  Logging and reentrancy checking are
available if DIAGNOSTIC is defined.  The file and line info are always passed
for the benefit of LKMs, etc.

Anyhow, attached below is sample output from one of my Alphas.  Hopefully
this will be useful to people!   Heh, amusingly enough, I've noticed a
(harmless) little bug in the instrumentation, just by sending this mail
with the page list output! :-)

        -- Jason R. Thorpe <thorpej@nas.nasa.gov>

db> show pool/p mclpool
POOL mclpl: size 2048, align 8, ioff 0, roflags 0x00000000
        pagesz 8192, mtype 0
        alloc 0xfffffc00003781e0, release 0xfffffc0000378240
        minitems 8, minpages 2, maxpages 64, npages 43
        itemsperpage 4, nitems 12, nout 160, hardlimit 256

        nget 592, nfail 0, nput 432
        npagealloc 0, npagefree 0, hiwat 43, nidle 3

        page list:
                page 0xfffffc0002334000, nmissing 4, time 0,0
                page 0xfffffc0002366000, nmissing 4, time 0,0
                page 0xfffffc0002368000, nmissing 4, time 0,0
                page 0xfffffc000236a000, nmissing 4, time 0,0
                page 0xfffffc000236c000, nmissing 4, time 0,0
                page 0xfffffc0002370000, nmissing 4, time 0,0
                page 0xfffffc0002372000, nmissing 4, time 0,0
                page 0xfffffc0002374000, nmissing 4, time 0,0
                page 0xfffffc0002376000, nmissing 4, time 0,0
                page 0xfffffc0002378000, nmissing 4, time 0,0
                page 0xfffffc000237a000, nmissing 4, time 0,0
                page 0xfffffc000237c000, nmissing 4, time 0,0
                page 0xfffffc000237e000, nmissing 4, time 0,0
                page 0xfffffc0002382000, nmissing 4, time 0,0
                page 0xfffffc0002384000, nmissing 4, time 0,0
                page 0xfffffc0002386000, nmissing 4, time 0,0
                page 0xfffffc0002388000, nmissing 4, time 0,0
                page 0xfffffc00023b6000, nmissing 4, time 0,0
                page 0xfffffc00023b8000, nmissing 4, time 0,0
                page 0xfffffc00023ba000, nmissing 4, time 0,0
                page 0xfffffc00023be000, nmissing 4, time 0,0
                page 0xfffffc00023c0000, nmissing 4, time 0,0
                page 0xfffffc00023c2000, nmissing 4, time 0,0
                page 0xfffffc00023c4000, nmissing 4, time 0,0
                page 0xfffffc00023c6000, nmissing 4, time 0,0
                page 0xfffffc00023c8000, nmissing 4, time 0,0
                page 0xfffffc00023ca000, nmissing 4, time 0,0
                page 0xfffffc00023cc000, nmissing 4, time 0,0
                page 0xfffffc00023d0000, nmissing 4, time 0,0
                page 0xfffffc00023d2000, nmissing 4, time 0,0
                page 0xfffffc00023d4000, nmissing 4, time 0,0
                page 0xfffffc00023d6000, nmissing 4, time 0,0
                page 0xfffffc00023d8000, nmissing 4, time 0,0
                page 0xfffffc0002e94000, nmissing 4, time 0,0
                page 0xfffffc0002e96000, nmissing 4, time 0,0
                page 0xfffffc0002e98000, nmissing 4, time 0,0
                page 0xfffffc0002e9c000, nmissing 4, time 0,0
                page 0xfffffc0002e9e000, nmissing 4, time 0,0
                page 0xfffffc0002ea0000, nmissing 4, time 0,0
                page 0xfffffc0002ea2000, nmissing 4, time 0,0
                page 0xfffffc0002ea4000, nmissing 0, time 926368220,642942
                page 0xfffffc000381c000, nmissing 0, time 926368220,650435
                page 0xfffffc0002338000, nmissing 0, time 926368220,656054
        curpage 0xfffffc0002ea4000
db> c


NetBSD/alpha (bishop) (ttyC0)

login: