Re: [rfc 00/45] [RFC] CPU ops and a rework of per cpu data handlingon x86_64

From: Christoph Lameter
Date: Mon Nov 19 2007 - 20:29:39 EST


Duh a patch did not make it due to XXX in the header.

I will put this also on git.kernel.org slab tree branch cpudata


x86_64: Strip down PDA operations through the use of CPU_XXX operations.

The *_pda operations behave in the same way as the CPU_XX ops. They both access data
that is relative to a segment register. So strip out as much as we can.

What is left after this patchset are some special pda ops for x86_64

or_pda()
test_and_clear_bit_pda()

Signed-off-by: Christoph Lameter <clameter@xxxxxxx>

---
include/asm-x86/current_64.h | 2 +-
include/asm-x86/pda.h | 34 ++++------------------------------
include/asm-x86/thread_info_64.h | 2 ++
3 files changed, 7 insertions(+), 31 deletions(-)

Index: linux-2.6/include/asm-x86/pda.h
===================================================================
--- linux-2.6.orig/include/asm-x86/pda.h 2007-11-19 16:17:22.325639807 -0800
+++ linux-2.6/include/asm-x86/pda.h 2007-11-19 16:24:13.569640223 -0800
@@ -81,36 +81,10 @@ extern struct x8664_pda _proxy_pda;
} \
} while (0)

-#define pda_from_op(op,field) ({ \
- typeof(_proxy_pda.field) ret__; \
- switch (sizeof(_proxy_pda.field)) { \
- case 2: \
- asm(op "w %%gs:%c1,%0" : \
- "=r" (ret__) : \
- "i" (pda_offset(field)), \
- "m" (_proxy_pda.field)); \
- break; \
- case 4: \
- asm(op "l %%gs:%c1,%0": \
- "=r" (ret__): \
- "i" (pda_offset(field)), \
- "m" (_proxy_pda.field)); \
- break; \
- case 8: \
- asm(op "q %%gs:%c1,%0": \
- "=r" (ret__) : \
- "i" (pda_offset(field)), \
- "m" (_proxy_pda.field)); \
- break; \
- default: \
- __bad_pda_field(); \
- } \
- ret__; })
-
-#define read_pda(field) pda_from_op("mov",field)
-#define write_pda(field,val) pda_to_op("mov",field,val)
-#define add_pda(field,val) pda_to_op("add",field,val)
-#define sub_pda(field,val) pda_to_op("sub",field,val)
+#define read_pda(field) CPU_READ(per_cpu_var(pda).field)
+#define write_pda(field,val) CPU_WRITE(per_cpu_var(pda).field, val)
+#define add_pda(field,val) CPU_ADD(per_cpu_var(pda).field, val)
+#define sub_pda(field,val) CPU_ADD(per_cpu_var(pda).field, val)
#define or_pda(field,val) pda_to_op("or",field,val)

/* This is not atomic against other CPUs -- CPU preemption needs to be off */
Index: linux-2.6/include/asm-x86/current_64.h
===================================================================
--- linux-2.6.orig/include/asm-x86/current_64.h 2007-11-19 15:45:03.470390243 -0800
+++ linux-2.6/include/asm-x86/current_64.h 2007-11-19 16:24:13.569640223 -0800
@@ -4,7 +4,7 @@
#if !defined(__ASSEMBLY__)
struct task_struct;

-#include <asm/pda.h>
+#include <asm/percpu.h>

static inline struct task_struct *get_current(void)
{
Index: linux-2.6/include/asm-x86/thread_info_64.h
===================================================================
--- linux-2.6.orig/include/asm-x86/thread_info_64.h 2007-11-19 15:45:03.482390495 -0800
+++ linux-2.6/include/asm-x86/thread_info_64.h 2007-11-19 16:24:13.569640223 -0800
@@ -41,6 +41,8 @@ struct thread_info {
* preempt_count needs to be 1 initially, until the scheduler is functional.
*/
#ifndef __ASSEMBLY__
+#include <asm/percpu_64.h>
+
#define INIT_THREAD_INFO(tsk) \
{ \
.task = &tsk, \

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/