percpu: add optimized generic percpu accessors
[safe/jmp/linux-2.6] / arch / x86 / include / asm / pda.h
1 #ifndef _ASM_X86_PDA_H
2 #define _ASM_X86_PDA_H
3
4 #ifndef __ASSEMBLY__
5 #include <linux/stddef.h>
6 #include <linux/types.h>
7 #include <linux/cache.h>
8 #include <linux/threads.h>
9 #include <asm/page.h>
10 #include <asm/percpu.h>
11
12 /* Per processor datastructure. %gs points to it while the kernel runs */
13 struct x8664_pda {
14         struct task_struct *pcurrent;   /* 0  Current process */
15         unsigned long dummy;
16         unsigned long kernelstack;      /* 16 top of kernel stack for current */
17         unsigned long oldrsp;           /* 24 user rsp for system call */
18         int irqcount;                   /* 32 Irq nesting counter. Starts -1 */
19         unsigned int cpunumber;         /* 36 Logical CPU number */
20 #ifdef CONFIG_CC_STACKPROTECTOR
21         unsigned long stack_canary;     /* 40 stack canary value */
22                                         /* gcc-ABI: this canary MUST be at
23                                            offset 40!!! */
24 #endif
25         char *irqstackptr;
26         short nodenumber;               /* number of current node (32k max) */
27         short in_bootmem;               /* pda lives in bootmem */
28         unsigned int __softirq_pending;
29         unsigned int __nmi_count;       /* number of NMI on this CPUs */
30         short mmu_state;
31         short isidle;
32         struct mm_struct *active_mm;
33         unsigned apic_timer_irqs;
34         unsigned irq0_irqs;
35         unsigned irq_resched_count;
36         unsigned irq_call_count;
37         unsigned irq_tlb_count;
38         unsigned irq_thermal_count;
39         unsigned irq_threshold_count;
40         unsigned irq_spurious_count;
41 } ____cacheline_aligned_in_smp;
42
43 DECLARE_PER_CPU(struct x8664_pda, __pda);
44 extern void pda_init(int);
45
46 #define cpu_pda(cpu)            (&per_cpu(__pda, cpu))
47
48 #define read_pda(field)         percpu_read(__pda.field)
49 #define write_pda(field, val)   percpu_write(__pda.field, val)
50 #define add_pda(field, val)     percpu_add(__pda.field, val)
51 #define sub_pda(field, val)     percpu_sub(__pda.field, val)
52 #define or_pda(field, val)      percpu_or(__pda.field, val)
53
54 /* This is not atomic against other CPUs -- CPU preemption needs to be off */
55 #define test_and_clear_bit_pda(bit, field)                              \
56         x86_test_and_clear_bit_percpu(bit, __pda.field)
57
58 #endif
59
60 #define PDA_STACKOFFSET (5*8)
61
62 #endif /* _ASM_X86_PDA_H */