From mboxrd@z Thu Jan 1 00:00:00 1970 From: Arnaldo Carvalho de Melo Subject: Re: Is it possible to trace events and its call stack? Date: Mon, 16 Jan 2017 16:32:59 -0300 Message-ID: <20170116193259.GB14872@kernel.org> References: <20170116115525.21e12d967e0acf8159c29165@kernel.org> <20170116212629.610b7575657f0ac9b1f563e1@kernel.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Return-path: Received: from mail.kernel.org ([198.145.29.136]:43972 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750855AbdAPTdk (ORCPT ); Mon, 16 Jan 2017 14:33:40 -0500 Content-Disposition: inline In-Reply-To: <20170116212629.610b7575657f0ac9b1f563e1@kernel.org> Sender: linux-perf-users-owner@vger.kernel.org List-ID: To: Masami Hiramatsu Cc: Qu Wenruo , linux-perf-users@vger.kernel.org, Namhyung Kim Em Mon, Jan 16, 2017 at 09:26:29PM +0900, Masami Hiramatsu escreveu: > On Mon, 16 Jan 2017 16:48:57 +0800 > Qu Wenruo wrote: > > > > > > > At 01/16/2017 10:55 AM, Masami Hiramatsu wrote: > > > On Thu, 12 Jan 2017 15:49:08 +0800 > > > Qu Wenruo wrote: > > > > > >> Hi, > > >> > > >> Is it possible to use perf/ftrace to trace events and its call stack? > > >> > > >> [Background] > > >> It's one structure in btrfs, btrfs_bio, I'm tracing for. > > >> That structure is allocated and free somewhat frequently, and its size > > >> is not fixed, so no SLAB/SLUB cache is used. > > >> > > >> I added trace events(or trace points, anyway, just in > > >> include/trace/events/btrfs.h) to trace the allocation and freeing. > > >> Which will output the pointer address of that structure, so I can pair > > >> them, alone with other info. > > >> > > >> Things went well until, I found some structures are allocated but not > > >> freed. (no corresponding trace point is triggered for given address). > > >> > > >> It's possible that btrfs just forget to free it, or btrfs is just > > >> holding it for some purpose. > > >> So kernel memleak detector won't catch the later one. > > >> > > >> That's to say along with the tracepoint data, I still need the call > > >> stack of each calling, to determine the code who leak or hold the pointer. > > >> > > >> Is it possible to do it using perf or ftrace? > > > > > > If you are using ftrace, yes, you can enable stacktrace for each > > > events by setting stacktrace event trigger as below; > > > > > > echo stacktrace > events/btrfs//trigger > > > > > > Then ftrace will show the stacktrace data. > > > See /sys/kernel/debug/tracing/README for more details. :) > > > > That's great! > > > > The most pure ftrace method! > > > > I also found perf makes life easier compared to pure ftrace one :) > > Should be :) > > > Although after some search, I didn't find any equivalent of > > "function_graph" tracer, which is quite handy to handle small amount of > > calling time data. > > > > Does it mean perf tool just doesn't support? > > Namhyung had made it. I'm not sure why it is not merged. > > https://lwn.net/Articles/570503/ /me trying to revive that patchset... - Arnaldo