Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752246AbbGOCvL (ORCPT ); Tue, 14 Jul 2015 22:51:11 -0400 Received: from smtprelay0099.hostedemail.com ([216.40.44.99]:48957 "EHLO smtprelay.hostedemail.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751018AbbGOCvJ (ORCPT ); Tue, 14 Jul 2015 22:51:09 -0400 X-Session-Marker: 726F737465647440676F6F646D69732E6F7267 X-Spam-Summary: 2,0,0,,d41d8cd98f00b204,rostedt@goodmis.org,:::::::::::::::::,RULES_HIT:41:69:355:379:541:599:800:960:973:981:988:989:1260:1277:1311:1313:1314:1345:1359:1437:1515:1516:1518:1534:1542:1593:1594:1711:1730:1747:1777:1792:1801:2393:2553:2559:2562:2693:2892:2904:3138:3139:3140:3141:3142:3354:3622:3865:3866:3867:3868:3870:3871:3872:3873:3874:4321:4605:5007:6119:6120:6261:7514:7875:7903:9000:10004:10400:10848:10967:11026:11232:11658:11914:12043:12295:12296:12517:12519:12683:12740:13095:14096:14097:21060:21080,0,RBL:none,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fn,MSBL:0,DNSBL:none,Custom_rules:0:0:0 X-HE-Tag: dust72_612a17b23d322 X-Filterd-Recvd-Size: 3555 Date: Tue, 14 Jul 2015 22:51:05 -0400 From: Steven Rostedt To: AKASHI Takahiro Cc: Jungseok Lee , catalin.marinas@arm.com, will.deacon@arm.com, olof@lixom.net, broonie@kernel.org, david.griego@linaro.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: Re: [RFC 2/3] arm64: refactor save_stack_trace() Message-ID: <20150714225105.6c1e4f15@gandalf.local.home> In-Reply-To: <55A5A75A.1060401@linaro.org> References: <1436765375-7119-1-git-send-email-takahiro.akashi@linaro.org> <1436765375-7119-3-git-send-email-takahiro.akashi@linaro.org> <20150714093154.4d73e551@gandalf.local.home> <55A5A75A.1060401@linaro.org> X-Mailer: Claws Mail 3.11.1 (GTK+ 2.24.28; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2558 Lines: 73 On Wed, 15 Jul 2015 09:20:42 +0900 AKASHI Takahiro wrote: > On 07/14/2015 10:31 PM, Steven Rostedt wrote: > > On Tue, 14 Jul 2015 21:47:10 +0900 > > Jungseok Lee wrote: > > > >> Is the below example an unexpected result? > >> Entry 17 and 18 are ftrace_call and ftrace_ops_no_ops, respectively. > > [snip] > > > Note, function tracing does not disable interrupts. This looks to be > > that an interrupt came in while __aloc_skb() was being traced. > > Yeah, I think so, too. But if my insight is correct, it's not __alloc_skb() > but one of functions that it calls. As I said in the commit log message > of patch[1/3], the exact traced function will not be listed by > save_stack_trace() because we don't create a stack frame at mcount(). > I think this is a flaw in the current implementation (on x86). > > what do you think, Steve? > mcount (well ftrace_call actually) does indeed create a stack frame for itself *and* for what called it. At least on x86_64. See mcount_64.S. With -pg -mfentry, it creates a stack frame. Without -mfentry, mcount is called after the current function's frame is made so we don't need to do much. Here's what the -mfentry version does: pushq %rbp pushq 8*2(%rsp) /* this is the parent pointer */ pushq %rbp movq %rsp, %rbp pushq 8*3(%rsp) /* Return address to ftrace_call */ pushq %rbp movq %rsp, %rbp Thus the stack looks like this: <---+ | | | +------------------------------+ | | return address for func | | | return address for func_call | | | original %rbp | | +------------------------------+ | | return address for func | | | ptr to parent frame (%rbp) | ----+ +------------------------------| <-----+ | return address for func_call | | | ptr to next frame (%rbp) | ------+ +------------------------------+ <---+ | | Current %rbp points to func_call frame -----+ The first box isn't used as a frame, but is used by ftrace_call to save information to restore everything properly. Thus, __alloc_skb() is what is currently being traced. -- Steve -- 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/