[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <18720.60351.611649.125429@drongo.ozlabs.ibm.com>
Date: Mon, 17 Nov 2008 14:57:51 +1100
From: Paul Mackerras <paulus@...ba.org>
To: Steven Rostedt <rostedt@...dmis.org>
Cc: linux-kernel@...r.kernel.org, Ingo Molnar <mingo@...e.hu>,
Andrew Morton <akpm@...ux-foundation.org>,
Thomas Gleixner <tglx@...utronix.de>,
Peter Zijlstra <peterz@...radead.org>,
David Miller <davem@...emloft.net>,
Benjamin Herrenschmidt <benh@...nel.crashing.org>,
Frederic Weisbecker <fweisbec@...il.com>,
Pekka Paalanen <pq@....fi>, linuxppc-dev@...abs.org,
Rusty Russell <rusty@...tcorp.com.au>,
Paul Mundt <lethal@...ux-sh.org>,
Steven Rostedt <srostedt@...hat.com>
Subject: Re: [PATCH 2/7] ftrace, ppc: convert to new dynamic ftrace arch API
Steven Rostedt writes:
> +static int test_24bit_addr(unsigned long ip, unsigned long addr)
> +{
> + unsigned long diff;
> +
> + /* can we get to addr from ip in 24 bits? */
> + diff = ip > addr ? ip - addr : addr - ip;
> +
> + return !(diff & ((unsigned long)-1 << 24));
Since a branch instruction can reach +/- 32MB, the 24 needs to be 25.
It's 25 not 26 since you have effectively accounted for one bit by
taking the absolute value of the offset. Also, this will say that an
offset of -0x2000000 is out of range whereas it is just in range.
That probably doesn't matter unless you're relying on this to give
exactly the same answer in all cases as tests done elsewhere (e.g. in
module_64.c).
Note that the address difference being too large isn't the only reason
for a procedure call to go via a trampoline on ppc64. A trampoline is
also needed when the called function uses a different TOC from the
caller. The most obvious example of this is when the caller is in a
module and the callee is in the main kernel or another module.
Currently all functions in the main kernel use the same TOC, but the
linker is capable of dividing up a large executable into groups of
functions and assigning a different TOC to each group, in order to
avoid any of the TOCs getting too large (a TOC is limited to 64kB).
If the linker does that, it automatically inserts trampolines to
handle the TOC change.
Paul.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists