| To: | Alan Cooper <alcooperx@gmail.com> |
|---|---|
| Subject: | Re: MIPS Function Tracer question |
| From: | David Daney <ddaney.cavm@gmail.com> |
| Date: | Fri, 30 Nov 2012 08:25:16 -0800 |
| Cc: | linux-mips <linux-mips@linux-mips.org> |
| Dkim-signature: | v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=message-id:date:from:user-agent:mime-version:to:cc:subject :references:in-reply-to:content-type:content-transfer-encoding; bh=lwUorNm7h3Ph3ZBWm6FeSX8xf2RhvljXKgZoOcruHAA=; b=XYWafHGYBc+9g51RziAEv5k4zo6uvnzQEgudY0x9V7JXyGTKHcMBDgrj4XQiYgw00L tUYerqaJiFU1TwL6HSyKlxYOmLjnICKxp3nJGiDAlG5jk3un3kpyFuZlRjLbcnhwY79N HIQLXm466LJNPgDotps96EZ3cyadqWhTaOG89aEykRl146zj6qkvMjYZdCFFCNK9w2jS nHJxT9HiAkNf4+JQhoaiw51BJ+bFLgzpC5VA9r0GQEVQG6SkBjZauPjgBxo8xoZsi/Tm ExHze1m99ZOjdn2rtPZ58A80Cuw4w1as7qj9H35r6kP9iSSBmVSf+zItu3CGHgNLLE6p eqAA== |
| In-reply-to: | <CAOGqxeU=BumDt6jnVc=sKk=q_v1eywGu=_Eo9xo3r9av3Ky6kw@mail.gmail.com> |
| List-archive: | <http://www.linux-mips.org/archives/linux-mips/> |
| List-help: | <mailto:ecartis@linux-mips.org?Subject=help> |
| List-id: | linux-mips <linux-mips.eddie.linux-mips.org> |
| List-owner: | <mailto:ralf@linux-mips.org> |
| List-post: | <mailto:linux-mips@linux-mips.org> |
| List-software: | Ecartis version 1.0.0 |
| List-subscribe: | <mailto:ecartis@linux-mips.org?subject=subscribe%20linux-mips> |
| List-unsubscribe: | <mailto:ecartis@linux-mips.org?subject=unsubscribe%20linux-mips> |
| References: | <CAOGqxeUOrVFoqsmUV19h5tXsD6pw5creXP9aN1C-V7K3WL2EXA@mail.gmail.com> <50B7E91C.6070403@gmail.com> <CAOGqxeU=BumDt6jnVc=sKk=q_v1eywGu=_Eo9xo3r9av3Ky6kw@mail.gmail.com> |
| Sender: | linux-mips-bounce@linux-mips.org |
| User-agent: | Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/17.0 Thunderbird/17.0 |
On 11/30/2012 06:53 AM, Alan Cooper wrote: I needed to be more specific. The issues I'm seeing are only on 32BIT platforms with dynamic tracing. Let me explain the issue. When the compiler flag "-pg" is specified for 32BIT platforms to enable tracing, the compiler adds "addiu sp,sp,-8" in the delay slot after every call to _mcount (some legacy thing where 2 arguments used to be pushed on the stack). The _mcount routine is expected to adjust the sp by 8 before returning. If the kernel's tracer infrastructure is broken for 32-bit kernels, then it should be fixed. I think it was only really tested on 64-bit kernels. It seems that the sp adjustment should be replaced by NOP as well if tracing is disabled. The problem is when tracing is disabled, all calls to _mcount are dynamically converted from "jal _mcount" to "nop" but the following "addiu sp,sp,-8" instruction is unchanged and when executed leaves the sp off by -8 for the remainder of the function. This bug is hidden when the compiler is told to use frame pointers because all offsets into the stack use the fp instead of the sp and the sp is restored from the frame pointer instead of just adding a constant to sp. When frame pointers are not enabled the code crashes. I don't think the toolchain version makes any difference because the _mcount assembly language routine adjusts the stack pointer by 8 if not CONFIG_64BIT regardless of the toolchain version. On Thu, Nov 29, 2012 at 6:00 PM, David Daney <ddaney.cavm@gmail.com> wrote:On 11/29/2012 01:04 PM, Alan Cooper wrote:I've been doing some testing of the MIPS Function Tracer functionality on the 3.3 kernel. I was surprised to find that the option to generate frame pointers was required for tracing.It is not really required for MIPS function tracing, but the Kconfigs for some reason set it.When I don't enable FRAME_POINTER along with FUNCTION_TRACER, the kernel hangs on boot. I also noticed that a checkin to the 3.4 kernel (b732d439cb43336cd6d7e804ecb2c81193ef63b0) no longer forces on FRAME_POINTER when FUNCTION_TRACER is selected. I was wondering how it works in 3.4 and beyond, so I built a Malta kernel from the latest MIPS tree with FUNCTION_TRACING enabled and tested it with QEMU. The kernel hung the same way. I can think of 2 reasons for this: 1. Function tracing is broken for MIPS in 3.4 and beyond. 2. The 4.5.3 GNU C compiler I'm using is generating different code for function tracing.Function tracing works best with recent versions of GCC (those that support -mmcount-ra-address).I was wondering if anyone has MIPS function tracing working in 3.4 or later? |
| <Prev in Thread] | Current Thread | [Next in Thread> |
|---|---|---|
| ||
| Previous by Date: | Re: [PATCH v3 0/8] bcma/ssb/BCM47XX: add GPIO driver to ssb/bcma, Hauke Mehrtens |
|---|---|
| Next by Date: | [ 50/56] MPI: Fix compilation on MIPS with GCC 4.4 and newer, Greg Kroah-Hartman |
| Previous by Thread: | Re: MIPS Function Tracer question, David Daney |
| Next by Thread: | Patch "MPI: Fix compilation on MIPS with GCC 4.4 and newer" has been added to the 3.4-stable tree, gregkh |
| Indexes: | [Date] [Thread] [Top] [All Lists] |