Re: Extend "struct malloc_type" for extended KMEMSTATS?

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Havard Eidnes
Date: Wednesday, March 31, 2010 - 6:12 am

Hi,

it's time to pick up an old issue I discussed here earlier.

As described earlier, I'd like to extend vmstat to show the
number of allocations done per type and size, like so:

Memory statistics by type                                Type  Kern
           Type InUse  MemUse HighUse   Limit   Requests Limit Limit Size(s)
   kernfs mount     1      1K      1K  78644K          1     0     0 16:1
    ptyfs mount     1      1K      1K  78644K          1     0     0 16:1
     prop array     1      1K      1K  78644K          1     0     0 64:1
prop dictionary   145     19K     19K  78644K        145     0     0 128:145
    prop string   143      3K      3K  78644K        143     0     0 16:143
           acpi    30      1K      1K  78644K         31     0     0 16:7,32:19,64:4
            USB    46      5K      5K  78644K         52     0     0 16:6,32:6,64:19,128:9,256:6,1024:0
     USB device    18     19K     19K  78644K         18     0     0 16:6,128:3,2048:9

These stats are only available under KMEMSTATS, but since struct
malloc_type is part of what vmstat uses, it would not be friendly
to require a new vmstat just because you turned on KMEMSTATS in
the kernel.  This means that this change will currently consume
around 5-6KB extra kernel memory.  All the counting in the kernel
is however done under KMEMSTATS ifdefs.

While it is apparently true that malloc(9) over time is being
replaced by kmem(9), there remains a large number of uses of
malloc(9) in the kernel, and they are unlikely to go away anytime
soon.

This change is the first stage of a two-stage set of changes
which would make it easier to spot and trace kernel memory leaks
in use of malloc(9), and was of much help finding the kernel
memory leak documented in PRs 39145 and 42661.

The new diff is attached below.  This time I've refrained from
the re-typing of the preexisting fields in "struct malloc_type",
to keep the change as small as possible.

It would appear that in addition to this change, a kernel
revision bump would be required.

Comments?

Regards,

- Håvard
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
Re: Extend "struct malloc_type" for extended KMEMSTATS?, Havard Eidnes, (Wed Mar 31, 6:12 am)