Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751908AbbFYCnb (ORCPT ); Wed, 24 Jun 2015 22:43:31 -0400 Received: from cdptpa-outbound-snat.email.rr.com ([107.14.166.225]:63841 "EHLO cdptpa-oedge-vip.email.rr.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1750942AbbFYCnY (ORCPT ); Wed, 24 Jun 2015 22:43:24 -0400 Date: Wed, 24 Jun 2015 22:43:54 -0400 From: Steven Rostedt To: Josef Bacik Cc: , Subject: Re: [PATCH] trace-cmd: add a kernel memory leak detector Message-ID: <20150624224354.4dafb594@grimm.local.home> In-Reply-To: <1435100799-32723-1-git-send-email-jbacik@fb.com> References: <1435100799-32723-1-git-send-email-jbacik@fb.com> X-Mailer: Claws Mail 3.11.1 (GTK+ 2.24.25; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-RR-Connecting-IP: 107.14.168.118:25 X-Cloudmark-Score: 0 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2326 Lines: 76 On Tue, 23 Jun 2015 16:06:39 -0700 Josef Bacik 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 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 > 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 > +#include > +#include > +#include > +#include > + > +#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 majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/