All of lore.kernel.org
 help / color / mirror / Atom feed
From: Michael Ellerman <michael@ellerman.id.au>
To: Paul Mackerras <paulus@samba.org>
Cc: linux-kernel@vger.kernel.org, Milton Miller <miltonm@bga.com>,
	linuxppc-dev@ozlabs.org, Steven Rostedt <srostedt@redhat.com>,
	Thomas Gleixner <tglx@linutronix.de>,
	Steven Rostedt <rostedt@goodmis.org>,
	Andrew Morton <akpm@linux-foundation.org>,
	Ingo Molnar <mingo@elte.hu>
Subject: Re: [PATCH 2/5] powerpc: ftrace, convert to new dynamic ftrace arch API
Date: Mon, 24 Nov 2008 13:49:36 +1100	[thread overview]
Message-ID: <1227494976.21735.1.camel@localhost> (raw)
In-Reply-To: <18730.1723.708467.812600@drongo.ozlabs.ibm.com>

[-- Attachment #1: Type: text/plain, Size: 1662 bytes --]

On Mon, 2008-11-24 at 12:43 +1100, Paul Mackerras wrote:
> Steven Rostedt writes:
> 
> > Thanks to Paul Mackennas for pointing out the mistakes of my original
> 
> Mackerras
> 
> > +static int test_24bit_addr(unsigned long ip, unsigned long addr)
> > +{
> > +	long diff;
> > +
> > +	/*
> > +	 * Can we get to addr from ip in 24 bits?
> > +	 *  (26 really, since we mulitply by 4 for 4 byte alignment)
> > +	 */
> > +	diff = addr - ip;
> > +
> > +	/*
> > +	 * Return true if diff is less than 1 << 25
> > +	 *  and greater than -1 << 26.
> > +	 */
> > +	return (diff < (1 << 25)) && (diff > (-1 << 26));
> 
> I think this still isn't right, and the comment is one of those ones
> that is only useful to people who can't read C, as it's just a
> transliteration of the code.
> 
> The comment should say something like "Return true if diff can be
> represented as a 26-bit twos-complement binary number" and the second
> part of the test should be (diff >= (-1 << 25)).  However, since you
> define a test_offset() function in patch 4/5 that does the same test
> but using only one comparison instead of two, why don't you just say:
> 
> 	return !test_offset(diff);
> 
> (having first moved test_offset() before test_24bit_addr)?

Or better still, split out and use the code from create_branch() in
arch/powerpc/lib/code-patching.c .. which is hopefully correct :)

cheers

-- 
Michael Ellerman
OzLabs, IBM Australia Development Lab

wwweb: http://michael.ellerman.id.au
phone: +61 2 6212 1183 (tie line 70 21183)

We do not inherit the earth from our ancestors,
we borrow it from our children. - S.M.A.R.T Person

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 197 bytes --]

WARNING: multiple messages have this Message-ID (diff)
From: Michael Ellerman <michael@ellerman.id.au>
To: Paul Mackerras <paulus@samba.org>
Cc: Steven Rostedt <rostedt@goodmis.org>,
	Andrew Morton <akpm@linux-foundation.org>,
	linux-kernel@vger.kernel.org, Milton Miller <miltonm@bga.com>,
	linuxppc-dev@ozlabs.org, Steven Rostedt <srostedt@redhat.com>,
	Ingo Molnar <mingo@elte.hu>, Thomas Gleixner <tglx@linutronix.de>
Subject: Re: [PATCH 2/5] powerpc: ftrace, convert to new dynamic ftrace arch API
Date: Mon, 24 Nov 2008 13:49:36 +1100	[thread overview]
Message-ID: <1227494976.21735.1.camel@localhost> (raw)
In-Reply-To: <18730.1723.708467.812600@drongo.ozlabs.ibm.com>

[-- Attachment #1: Type: text/plain, Size: 1662 bytes --]

On Mon, 2008-11-24 at 12:43 +1100, Paul Mackerras wrote:
> Steven Rostedt writes:
> 
> > Thanks to Paul Mackennas for pointing out the mistakes of my original
> 
> Mackerras
> 
> > +static int test_24bit_addr(unsigned long ip, unsigned long addr)
> > +{
> > +	long diff;
> > +
> > +	/*
> > +	 * Can we get to addr from ip in 24 bits?
> > +	 *  (26 really, since we mulitply by 4 for 4 byte alignment)
> > +	 */
> > +	diff = addr - ip;
> > +
> > +	/*
> > +	 * Return true if diff is less than 1 << 25
> > +	 *  and greater than -1 << 26.
> > +	 */
> > +	return (diff < (1 << 25)) && (diff > (-1 << 26));
> 
> I think this still isn't right, and the comment is one of those ones
> that is only useful to people who can't read C, as it's just a
> transliteration of the code.
> 
> The comment should say something like "Return true if diff can be
> represented as a 26-bit twos-complement binary number" and the second
> part of the test should be (diff >= (-1 << 25)).  However, since you
> define a test_offset() function in patch 4/5 that does the same test
> but using only one comparison instead of two, why don't you just say:
> 
> 	return !test_offset(diff);
> 
> (having first moved test_offset() before test_24bit_addr)?

Or better still, split out and use the code from create_branch() in
arch/powerpc/lib/code-patching.c .. which is hopefully correct :)

cheers

-- 
Michael Ellerman
OzLabs, IBM Australia Development Lab

wwweb: http://michael.ellerman.id.au
phone: +61 2 6212 1183 (tie line 70 21183)

We do not inherit the earth from our ancestors,
we borrow it from our children. - S.M.A.R.T Person

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 197 bytes --]

  reply	other threads:[~2008-11-24  2:49 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-11-20 19:09 [PATCH 0/5] powerpc: dynamic ftrace port Steven Rostedt
2008-11-20 19:09 ` Steven Rostedt
2008-11-20 19:09 ` [PATCH 1/5] powerpc: ftrace, do not latency trace idle Steven Rostedt
2008-11-20 19:09   ` Steven Rostedt
2008-11-20 19:09 ` [PATCH 2/5] powerpc: ftrace, convert to new dynamic ftrace arch API Steven Rostedt
2008-11-20 19:09   ` Steven Rostedt
2008-11-24  1:43   ` Paul Mackerras
2008-11-24  1:43     ` Paul Mackerras
2008-11-24  2:49     ` Michael Ellerman [this message]
2008-11-24  2:49       ` Michael Ellerman
2008-11-24 18:00     ` Steven Rostedt
2008-11-24 18:00       ` Steven Rostedt
2008-11-20 19:09 ` [PATCH 3/5] powerpc: ftrace, use probe_kernel API to modify code Steven Rostedt
2008-11-20 19:09   ` Steven Rostedt
2008-11-20 19:09 ` [PATCH 4/5] powerpc/ppc64: ftrace, handle module trampolines for dyn ftrace Steven Rostedt
2008-11-20 19:09   ` Steven Rostedt
2008-11-24  2:26   ` Paul Mackerras
2008-11-24  2:26     ` Paul Mackerras
2008-11-24 17:56     ` Steven Rostedt
2008-11-24 17:56       ` Steven Rostedt
2008-11-24 20:59     ` Steven Rostedt
2008-11-24 20:59       ` Steven Rostedt
2008-11-20 19:09 ` [PATCH 5/5] powerpc/ppc32: ftrace, dynamic ftrace to handle modules Steven Rostedt
2008-11-20 19:09   ` Steven Rostedt
2008-11-24  2:35   ` Paul Mackerras
2008-11-24  2:35     ` Paul Mackerras
2008-11-20 19:15 ` [PATCH 0/5] powerpc: dynamic ftrace port Steven Rostedt
2008-11-20 19:15   ` Steven Rostedt
2008-11-20 19:20   ` Ingo Molnar
2008-11-20 19:20     ` Ingo Molnar
2008-11-20 19:16 ` Ingo Molnar
2008-11-20 19:16   ` Ingo Molnar
2008-11-20 19:24   ` Steven Rostedt
2008-11-20 19:24     ` Steven Rostedt

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=1227494976.21735.1.camel@localhost \
    --to=michael@ellerman.id.au \
    --cc=akpm@linux-foundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linuxppc-dev@ozlabs.org \
    --cc=miltonm@bga.com \
    --cc=mingo@elte.hu \
    --cc=paulus@samba.org \
    --cc=rostedt@goodmis.org \
    --cc=srostedt@redhat.com \
    --cc=tglx@linutronix.de \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.