Thread (25 messages) flat view 25 messages, 9 authors, 2006-05-18

Re: [RFC/PATCH] Make powerpc64 use __thread for per-cpu variables

From: Steven Rostedt <rostedt@goodmis.org>
Date: 2006-05-10 18:04:26
Also in: linux-arch, lkml

On Wed, 10 May 2006, Richard Henderson wrote:
On Wed, May 10, 2006 at 02:03:59PM +1000, Paul Mackerras wrote:
quoted
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
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help