linux-mips
[Top] [All Lists]

Re: [PATCH 1/5] tracing, MIPS: reduce one instruction for function graph

To: Ralf Baechle <ralf@linux-mips.org>
Subject: Re: [PATCH 1/5] tracing, MIPS: reduce one instruction for function graph tracer
From: wu zhangjin <wuzhangjin@gmail.com>
Date: Thu, 20 Jan 2011 03:30:32 +0800
Cc: Wu Zhangjin <wuzhangjin@gmail.com>, Steven Rostedt <srostedt@redhat.com>, linux-mips@linux-mips.org
Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:in-reply-to:references:date :message-id:subject:from:to:cc:content-type :content-transfer-encoding; bh=ORf5/R8BzMeB9IAS/WnAnjO3MFwxFZ4ga59Q+BrLnCY=; b=FZwDwm5i7ckzgL+aYVkpYkQf5cvW7EG9kWkuuf5hgMD5YCucRIyesY1qISfpapGj8J H2TMUXhsVHFMD8RW01hKCAiihKLOBPerY19KAmokkzM6HIKnERVRwuJqjdN4Io/zSarZ mZUQySGAQZ1vywMur2cV21HN8zSwfVncLMngA=
Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type:content-transfer-encoding; b=lw1KWjYxmUftEC+uBRfPEMi4+DGUBlzvsRZfEbFY5iAEESimT0Q6pgVhtTfkeWn5Xq NE89PTXnca53ISeqxpvGWvTXhJxCKTVzTvyVTrFqO0RqUjrid+Dtef/ioUDyGOI+5NqV M7tTvjcGl2vZ4Z9B85VMzh5k18Do3MRJacN4U=
In-reply-to: <5fcf37ab006f1ccfe6844e7392a66c4cdd1aa84d.1295464564.git.wuzhangjin@gmail.com>
Original-recipient: rfc822;linux-mips@linux-mips.org
References: <cover.1295464564.git.wuzhangjin@gmail.com> <cover.1295464855.git.wuzhangjin@gmail.com> <5fcf37ab006f1ccfe6844e7392a66c4cdd1aa84d.1295464564.git.wuzhangjin@gmail.com>
Sender: linux-mips-bounce@linux-mips.org
Sorry, please ignore this one.

On Thu, Jan 20, 2011 at 3:28 AM, Wu Zhangjin <wuzhangjin@gmail.com> wrote:
> This simply moves the "ip-=4" statement down to the end of the do { ...
> } while (...); loop, which reduces one unneeded subtration and the
> subsequent memory loading and comparation. as a result, speed up the
> function a little.
>
> Signed-off-by: Wu Zhangjin <wuzhangjin@gmail.com>
> ---
>  arch/mips/kernel/ftrace.c |   14 +++++++-------
>  1 files changed, 7 insertions(+), 7 deletions(-)
>
> diff --git a/arch/mips/kernel/ftrace.c b/arch/mips/kernel/ftrace.c
> index 5a84a1f..635c1dc 100644
> --- a/arch/mips/kernel/ftrace.c
> +++ b/arch/mips/kernel/ftrace.c
> @@ -200,19 +200,17 @@ unsigned long ftrace_get_parent_addr(unsigned long 
> self_addr,
>        int faulted;
>
>        /*
> -        * For module, move the ip from calling site of mcount to the
> -        * instruction "lui v1, hi_16bit_of_mcount"(offset is 20), but for
> -        * kernel, move to the instruction "move ra, at"(offset is 12)
> +        * For module, move the ip from calling site of mcount after the
> +        * instruction "lui v1, hi_16bit_of_mcount"(offset is 24), but for
> +        * kernel, move after the instruction "move ra, at"(offset is 16)
>         */
> -       ip = self_addr - (in_module(self_addr) ? 20 : 12);
> +       ip = self_addr - (in_module(self_addr) ? 24 : 16);
>
>        /*
>         * search the text until finding the non-store instruction or "s{d,w}
>         * ra, offset(sp)" instruction
>         */
>        do {
> -               ip -= 4;
> -
>                /* get the code at "ip": code = *(unsigned int *)ip; */
>                safe_load_code(code, ip, faulted);
>
> @@ -226,7 +224,9 @@ unsigned long ftrace_get_parent_addr(unsigned long 
> self_addr,
>                if ((code & S_R_SP) != S_R_SP)
>                        return parent_addr;
>
> -       } while (((code & S_RA_SP) != S_RA_SP));
> +               /* Move to the next instruction */
> +               ip -= 4;
> +       } while ((code & S_RA_SP) != S_RA_SP);
>
>        sp = fp + (code & OFFSET_MASK);
>
> --
> 1.7.1
>
>

<Prev in Thread] Current Thread [Next in Thread>