[RFC/PATCH] Make powerpc64 use __thread for per-cpu variables
Steven Rostedt
rostedt at goodmis.org
Thu May 11 04:04:18 EST 2006
On Wed, 10 May 2006, Richard Henderson wrote:
> On Wed, May 10, 2006 at 02:03:59PM +1000, Paul Mackerras wrote:
> > With this patch, 64-bit powerpc uses __thread for per-cpu variables.
>
> How do you plan to address the compiler optimizing
>
> __thread int foo;
> {
> use(foo);
> schedule();
> use(foo);
> }
>
> into
>
> {
> int *tmp = &foo; // tls arithmetic here
> use(*tmp);
> schedule();
> use(*tmp);
> }
>
> Across the schedule, we may have changed cpus, making the cached
> address invalid.
>
If you mean use(foo) is the same as per_cpu(foo), I can't see the compile
optimizing this:
+#define per_cpu(var, cpu) \
+ (*(__typeof__(&per_cpu__##var))({ \
+ void *__ptr; \
+ asm("addi %0,%1,per_cpu__"#var"@tprel" \
+ : "=b" (__ptr) \
+ : "b" (paca[(cpu)].thread_ptr)); \
+ __ptr; \
+ }))
Anyway, per_cpu variables are usually used with preemption turned off and
no need to schedule.
-- Steve
More information about the Linuxppc-dev
mailing list