This is the mail archive of the systemtap@sourceware.org mailing list for the systemtap project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: How can I trace when the allocated memory is free after kmalloc ?


On Fri, 2011-09-16 at 17:19 +0900, ììíB wrote:
> Hi Mark.
> 
> If  "A thead" get a kernel memory by kmalloc, and "B thead" can free the memory, 
> how can I trace  when the allocated memory is returned after kmalloc ?

I suppose you can save the address that kmalloc returned and check for
that address while probing kfree. Maybe something like:

global addrs;

probe vm.kmalloc
{
  addrs[ptr] = get_cycles();
}

probe vm.kfree
{
  if (addrs[ptr] != 0)
    {
      printf("%x released after %d cycles\n",
             ptr, get_cycles() - addrs[ptr]);
    }
  delete(addrs[ptr]);
}

That will probably overflow MAXMAPENTRIES pretty quickly though.

Cheers,

Mark


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]