On Tue, 23 Jun 2015 16:06:39 -0700 Josef Bacik <jba...@fb.com> wrote:
> I needed to track down a very slow memory leak so I adapted the same approach > trace-cmd profile uses to track kernel memory allocations. You run this with > > trace-cmd kmemleak Note, I'm still playing with this. > > and then you can kill -SIGUSR2 <trace-cmd pid> to get current status updates, > or > just stop the process when you are ready. It will tell you how much was lost > and the size of the objects that were allocated, along with the tracebacks and > the counts of the allocators. Thanks, > > Signed-off-by: Josef Bacik <jba...@fb.com> > diff --git a/trace-kmemleak.c b/trace-kmemleak.c > new file mode 100644 > index 0000000..2e288fe > --- /dev/null > +++ b/trace-kmemleak.c Please add a copyright notice here. You can add your name as author but more importantly, please state what license this is under. See trace-record.c for details. > @@ -0,0 +1,552 @@ > +#define _LARGEFILE64_SOURCE > +#include <sys/types.h> > +#include <unistd.h> > +#include <stdio.h> > +#include <getopt.h> > +#include <signal.h> > + > +#include "trace-local.h" > +#include "trace-hash.h" > +#include "list.h" > + > +#define memory_from_item(item) container_of(item, struct memory, hash) > +#define memory_from_phash(item) container_of(item, struct memory, phash) > +#define leak_from_item(item) container_of(item, struct memory_leak, hash) > +#define edata_from_item(item) container_of(item, struct event_data, > hash) > +#define stack_from_item(item) container_of(item, struct stack_trace, > hash) > + > --- a/trace-record.c > +++ b/trace-record.c > @@ -3703,6 +3721,7 @@ static void add_hook(struct buffer_instance *instance, > const char *arg) > } > > enum { > + OPT_kmemleak = 249, > OPT_bycomm = 250, Ug, I realized I never applied your bycomm patch. I'll need to look at that now too. Egad, I've been putting off trace-cmd for to long. I need to start getting back to it! -- Steve > OPT_stderr = 251, > OPT_profile = 252, > @@ -3738,7 +3757,7 @@ void trace_record (int argc, char **argv) -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/