lkml.org 
[lkml]   [2008]   [Jun]   [4]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH 3/4] x86_64: Fold pda into per cpu area
Jeremy Fitzhardinge wrote:
> Mike Travis wrote:
>> * Declare the pda as a per cpu variable.
>>
>> * Make the x86_64 per cpu area start at zero.
>>
>> * Since the pda is now the first element of the per_cpu area, cpu_pda()
>> is no longer needed and per_cpu() can be used instead. This also
>> makes
>> the _cpu_pda[] table obsolete.
>>
>> * Since %gs is pointing to the pda, it will then also point to the
>> per cpu
>> variables and can be accessed thusly:
>>
>> %gs:[&per_cpu_xxxx - __per_cpu_start]
>>


The above is only a partial story (I folded the two patches but didn't
update the comments correctly.] The variables are already offset from
__per_cpu_start by virtue of the .data.percpu section being based at
zero. Therefore only the %gs register needs to be set to the base of
each cpu's percpu section to resolve the target address:

%gs:&per_cpu_xxxx

And the .data.percpu.first forces the pda percpu variable to the front.


>
> Unfortunately that doesn't actually work, because you can't have a reloc
> with two variables.
>
> In something like:
>
> mov %gs:per_cpu__foo - 12345, %rax
> mov %gs:per_cpu__foo, %rax
> mov %gs:per_cpu__foo - 12345(%rip), %rax
> mov %gs:per_cpu__foo(%rip), %rax
> mov %gs:per_cpu__foo - __per_cpu_start, %rax
> mov %gs:per_cpu__foo - __per_cpu_start(%rip), %rax
>
> the last two lines will not assemble:
>
> t.S:5: Error: can't resolve `per_cpu__foo' {*UND* section} -
> `__per_cpu_start' {*UND* section}
> t.S:6: Error: can't resolve `per_cpu__foo' {*UND* section} -
> `__per_cpu_start' {*UND* section}
>
> Unfortunately, the only way I can think of fixing this is to compute the
> offset into a temp register, then use that:
>
> lea per_cpu__foo(%rip), %rax
> mov %gs:__per_cpu_offset(%rax), %rax
>
> (where __per_cpu_offset is defined in the linker script as
> -__per_cpu_start).
>
> This seems to be a general problem with zero-offset per-cpu. And its
> unfortunate, because no-register access to per-cpu variables is nice to
> have.
>
> The other alternative - and I have no idea whether this is practical or
> possible - is to define a complete set of pre-offset per_cpu symbols.
>
> J



\
 
 \ /
  Last update: 2008-06-04 15:51    [W:0.327 / U:0.152 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site