Linux MIPS Architecture development
 help / color / mirror / Atom feed
From: Steven Rostedt <srostedt@redhat.com>
To: Sergei Shtylyov <sshtylyov@mvista.com>
Cc: Wu Zhangjin <wuzhangjin@gmail.com>,
	Ralf Baechle <ralf@linux-mips.org>,
	linux-mips@linux-mips.org
Subject: Re: [PATCH 5/5] tracing, MIPS: Fix set_graph_function of function graph tracer
Date: Thu, 20 Jan 2011 09:04:38 -0500	[thread overview]
Message-ID: <1295532278.19789.12.camel@fedora> (raw)
In-Reply-To: <4D381677.3000502@mvista.com>

On Thu, 2011-01-20 at 14:03 +0300, Sergei Shtylyov wrote:

> > diff --git a/arch/mips/kernel/ftrace.c b/arch/mips/kernel/ftrace.c
> > index bc91e4a..62775d7 100644
> > --- a/arch/mips/kernel/ftrace.c
> > +++ b/arch/mips/kernel/ftrace.c
> [...]
> > @@ -304,7 +304,14 @@ void prepare_ftrace_return(unsigned long *parent_ra_addr, unsigned long self_ra,
> >   		return;
> >   	}
> >
> > -	trace.func = self_ra;
> > +	/*
> > +	 * Get the recorded ip of the current mcount calling site in the
> > +	 * __mcount_loc section, which will be used to filter the function
> > +	 * entries configured through the tracing/set_graph_function interface.
> > +	 */
> > +
> > +	insns = (in_kernel_space(self_ra)) ? 2 : (MCOUNT_OFFSET_INSNS + 1);
> 
>     Unneeded parens.

agreed

> 
> > +	trace.func = self_ra - (MCOUNT_INSN_SIZE * insns);
> 
>     Here too.

I like the parens here. Yes, it is basic math precedence, but it stands
out to a reviewer who has their brain more focused on correct code than
thinking about which op has precedence.

Reviewing code that has:

	trace.func = self_ra - MCOUNT_INSN_SIZE * insns;

And as I my mother language reads left to right, my thought process
goes: subtract MCOUNT_INSN_SIZE from self_ra and then times insns... oh
wait, times goes first; stop reset, restart... subtract MCOUNT_INSN_SIZE
times insns from self_ra.  That stop reset and restart of the thought
process breaks the train of thought and could waste a lot more time than
just the moment it happened. All this is avoided by the parenthesis that
automatically trigger the brain to think those go first.

I say, leave these in.

-- Steve

  parent reply	other threads:[~2011-01-20 14:04 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-01-19 19:28 [PATCH 0/5] Misc updates for Ftrace of MIPS Wu Zhangjin
     [not found] ` <cover.1295464564.git.wuzhangjin@gmail.com>
2011-01-19 19:28   ` [PATCH 1/5] tracing, MIPS: reduce one instruction for function graph tracer Wu Zhangjin
2011-01-19 19:30     ` wu zhangjin
2011-01-19 19:28   ` [PATCH 2/5] tracing, MIPS: replace in_module() with a generic in_kernel_space() Wu Zhangjin
2011-01-19 19:30     ` wu zhangjin
2011-01-19 19:28 ` [PATCH 1/5] tracing, MIPS: Speed up function graph tracer Wu Zhangjin
2011-01-24 13:50   ` Ralf Baechle
2011-01-19 19:28 ` [PATCH 2/5] tracing, MIPS: Substitute in_kernel_space() for in_module() Wu Zhangjin
2011-01-24 13:57   ` Ralf Baechle
2011-01-26 12:36     ` wu zhangjin
2011-01-19 19:28 ` [PATCH 3/5] tracing, MIPS: Clean up prepare_ftrace_return() Wu Zhangjin
2011-01-24 14:21   ` Ralf Baechle
2011-01-19 19:28 ` [PATCH 4/5] tracing, MIPS: Clean up ftrace_make_nop() Wu Zhangjin
2011-01-19 19:28 ` [PATCH 5/5] tracing, MIPS: Fix set_graph_function of function graph tracer Wu Zhangjin
2011-01-20 11:03   ` Sergei Shtylyov
2011-01-20 12:46     ` wu zhangjin
2011-01-20 14:04     ` Steven Rostedt [this message]
2011-01-21  9:09       ` wu zhangjin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1295532278.19789.12.camel@fedora \
    --to=srostedt@redhat.com \
    --cc=linux-mips@linux-mips.org \
    --cc=ralf@linux-mips.org \
    --cc=sshtylyov@mvista.com \
    --cc=wuzhangjin@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox