powerpc: Merge thread_info.h

David Howells dhowells at redhat.com
Fri Oct 21 19:36:11 EST 2005


David Gibson <david at gibson.dropbear.id.au> wrote:

> 	- Instead of inline asm to implement current_thread_info(),
> which needs to be different for ppc32 and ppc64, we use C with an
> asm("r1") register variable.  gcc turns it into the same asm as we
> used to have for both platforms.

Doesn't the compiler complain at that as R1 is the stack pointer?

There's another trick you may wish to consider. It's one I've used in the FRV
arch to great effect. That's similar to the PPC arch in that instructions are
fixed size, and so displacements are limited.

What I did is to use a general register to hold current whilst inside the
kernel:

	[include/asm-frv/current.h]
	register struct task_struct *current asm("gr29");

Whilst the FRV ABI specifies that GR28-GR31 are reserved for O/S use, I
suspect the standard PPC ABI doesn't do similar. What you can do is pass gcc a
flag to tell it not to use that register for its own purposes ("-ffixed-r29"
for example).

This means rather than calculating current each time from the stack pointer
and the thread_info struct, you can just refer to members of the current task
struct directly. You could also place the thread_info struct at a known
displacement (perhaps negative) from current and thus access that directly
too.

What you would need to do, though, is load the current register on entry to an
exception. It would be slightly more complicated for you because PPC can be
SMP.

I found that this improved performance and shrank code size in the kernel.

David



More information about the Linuxppc64-dev mailing list