lkml.org 
[lkml]   [2008]   [Jul]   [9]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [RFC 00/15] x86_64: Optimize percpu accesses
Jeremy Fitzhardinge wrote:

> No, it makes no difference. %gs:X always has a 32-bit offset in the
> instruction, regardless of how big X is:
>
> mov %eax, %gs:0
> mov %eax, %gs:0x1234567
> ->
> 0: 65 89 04 25 00 00 00 00 mov %eax,%gs:0x0
> 8: 65 89 04 25 67 45 23 01 mov %eax,%gs:0x1234567

The processor itself supports smaller offsets.

Note also that the 32 bit offset size limits the offset that can be added to the segment register. You either need to place the per cpu area either in the last 2G of the address space or in the first 2G. The zero based approach removes that limitation.


>> It also is easier to handle since __per_cpu_start does not figure
>> in the calculation of the offsets.
>>
>
> No, you do it the same as i386. You set the segment base to be
> percpu_area-__per_cpu_start, and then just refer to %gs:per_cpu__foo
> directly. You can use rip-relative addressing to make it a smaller
> addressing mode too:
>
> 0: 65 89 05 00 00 00 00 mov %eax,%gs:0(%rip) # 0x7

RIP relative also implies a 32 bit offset meaning that the code cannot be more than 2G away from the per cpu area.


\
 
 \ /
  Last update: 2008-07-09 23:29    [W:0.187 / U:0.636 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site