This is the mail archive of the
systemtap@sourceware.org
mailing list for the systemtap project.
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