Re: [PATCH 1/11] Add generic helpers for arch IPI function calls

!MAILaRCHIVE_VOTE_RePLACE
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
To: James Bottomley <James.Bottomley@...>
Cc: <dhowells@...>, Andrew Morton <akpm@...>, Jens Axboe <jens.axboe@...>, <linux-arch@...>, <linux-kernel@...>, <npiggin@...>, <torvalds@...>, <peterz@...>, <sam@...>, Paul E. McKenney <paulmck@...>
Date: Monday, April 28, 2008 - 10:25 am

James Bottomley <James.Bottomley@HansenPartnership.com> wrote:


The problem with FRV has to do with global variables, not functions.

With FRV, we attempt to pack as many small variables into the "small data
section" (.sdata) as we can, and then retain a pointer to it in a register.
Thus for small variables, we can use a single instruction, such as:

	LDI	@(GR16,%gprel(my_variable)),GRx

to access it.  However, this limits the offset of my_variable to be +/-2048
from GR16 because all the instructions are the same size, and that's the size
of the offset field therein.

Alternatively, we can use:

	SETHI.P	%hi(my_variable),GRy
	SETLO	%lo(my_variable),GRy
	LD	@(GRy,GR0),GRx

which obviously takes two more instructions, although they can be executed
simultaneously, and 8 more bytes of RAM/icache.

However, the compiler will assume that it should access _all_ global variables
using GPREL-addressing unless it is told otherwise.  This means that if a
global variable should not be GPREL-addressed, its *declaration* should be
annotated, as this affects how it is addressed.  Furthermore, if the variable
is *defined* in C, that definition should be annotated the same as the
declaration, otherwise it'll eat storage from .sdata rather than the
appropriate section.


Global functions are another matter.  The FRV's PC+offset call and branch
instructions have 24-bit displacements, which is fine for leaping about within
the kernel core with a single instruction.

In modules, we instead (a) suppress GPREL addressing entirely because we can't
put module variables in .sdata, and (b) make all interfunction jumps that the
assembler can't resolve into:

	SETHI.P	%hi(that_function),GRy
	SETLO	%lo(that_function),GRy
	JMPL	@(GRy,GR0)

because a 24-bit offset can only span 16MB, which isn't far enough.


We could use a GOT, but I believe that would add an extra memory access to any
memory access or jump - which I'd prefer to avoid.

David
--
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[PATCH 0/11] Generic smp_call_function() #2, Jens Axboe, (Tue Apr 22, 2:50 pm)
Re: [PATCH 2/11] x86: convert to generic helpers for IPI fun..., Jeremy Fitzhardinge, (Sat Apr 26, 2:44 am)
Re: [PATCH 2/11] x86: convert to generic helpers for IPI fun..., Jeremy Fitzhardinge, (Sun Apr 27, 11:18 am)
Re: [PATCH 1/11] Add generic helpers for arch IPI function c..., David Howells, (Mon Apr 28, 10:25 am)
Re: [PATCH 1/11] Add generic helpers for arch IPI function c..., Jeremy Fitzhardinge, (Sat Apr 26, 2:28 am)
Re: [PATCH 11/11] s390: convert to generic helpers for IPI f..., Martin Schwidefsky, (Wed Apr 23, 8:42 am)