diff options
Diffstat (limited to 'arch/x86/include/asm/percpu.h')
-rw-r--r-- | arch/x86/include/asm/percpu.h | 104 |
1 files changed, 91 insertions, 13 deletions
diff --git a/arch/x86/include/asm/percpu.h b/arch/x86/include/asm/percpu.h index b65a36defeb7..0c44196b78ac 100644 --- a/arch/x86/include/asm/percpu.h +++ b/arch/x86/include/asm/percpu.h | |||
@@ -74,31 +74,31 @@ extern void __bad_percpu_size(void); | |||
74 | 74 | ||
75 | #define percpu_to_op(op, var, val) \ | 75 | #define percpu_to_op(op, var, val) \ |
76 | do { \ | 76 | do { \ |
77 | typedef typeof(var) T__; \ | 77 | typedef typeof(var) pto_T__; \ |
78 | if (0) { \ | 78 | if (0) { \ |
79 | T__ tmp__; \ | 79 | pto_T__ pto_tmp__; \ |
80 | tmp__ = (val); \ | 80 | pto_tmp__ = (val); \ |
81 | } \ | 81 | } \ |
82 | switch (sizeof(var)) { \ | 82 | switch (sizeof(var)) { \ |
83 | case 1: \ | 83 | case 1: \ |
84 | asm(op "b %1,"__percpu_arg(0) \ | 84 | asm(op "b %1,"__percpu_arg(0) \ |
85 | : "+m" (var) \ | 85 | : "+m" (var) \ |
86 | : "qi" ((T__)(val))); \ | 86 | : "qi" ((pto_T__)(val))); \ |
87 | break; \ | 87 | break; \ |
88 | case 2: \ | 88 | case 2: \ |
89 | asm(op "w %1,"__percpu_arg(0) \ | 89 | asm(op "w %1,"__percpu_arg(0) \ |
90 | : "+m" (var) \ | 90 | : "+m" (var) \ |
91 | : "ri" ((T__)(val))); \ | 91 | : "ri" ((pto_T__)(val))); \ |
92 | break; \ | 92 | break; \ |
93 | case 4: \ | 93 | case 4: \ |
94 | asm(op "l %1,"__percpu_arg(0) \ | 94 | asm(op "l %1,"__percpu_arg(0) \ |
95 | : "+m" (var) \ | 95 | : "+m" (var) \ |
96 | : "ri" ((T__)(val))); \ | 96 | : "ri" ((pto_T__)(val))); \ |
97 | break; \ | 97 | break; \ |
98 | case 8: \ | 98 | case 8: \ |
99 | asm(op "q %1,"__percpu_arg(0) \ | 99 | asm(op "q %1,"__percpu_arg(0) \ |
100 | : "+m" (var) \ | 100 | : "+m" (var) \ |
101 | : "re" ((T__)(val))); \ | 101 | : "re" ((pto_T__)(val))); \ |
102 | break; \ | 102 | break; \ |
103 | default: __bad_percpu_size(); \ | 103 | default: __bad_percpu_size(); \ |
104 | } \ | 104 | } \ |
@@ -106,31 +106,31 @@ do { \ | |||
106 | 106 | ||
107 | #define percpu_from_op(op, var, constraint) \ | 107 | #define percpu_from_op(op, var, constraint) \ |
108 | ({ \ | 108 | ({ \ |
109 | typeof(var) ret__; \ | 109 | typeof(var) pfo_ret__; \ |
110 | switch (sizeof(var)) { \ | 110 | switch (sizeof(var)) { \ |
111 | case 1: \ | 111 | case 1: \ |
112 | asm(op "b "__percpu_arg(1)",%0" \ | 112 | asm(op "b "__percpu_arg(1)",%0" \ |
113 | : "=q" (ret__) \ | 113 | : "=q" (pfo_ret__) \ |
114 | : constraint); \ | 114 | : constraint); \ |
115 | break; \ | 115 | break; \ |
116 | case 2: \ | 116 | case 2: \ |
117 | asm(op "w "__percpu_arg(1)",%0" \ | 117 | asm(op "w "__percpu_arg(1)",%0" \ |
118 | : "=r" (ret__) \ | 118 | : "=r" (pfo_ret__) \ |
119 | : constraint); \ | 119 | : constraint); \ |
120 | break; \ | 120 | break; \ |
121 | case 4: \ | 121 | case 4: \ |
122 | asm(op "l "__percpu_arg(1)",%0" \ | 122 | asm(op "l "__percpu_arg(1)",%0" \ |
123 | : "=r" (ret__) \ | 123 | : "=r" (pfo_ret__) \ |
124 | : constraint); \ | 124 | : constraint); \ |
125 | break; \ | 125 | break; \ |
126 | case 8: \ | 126 | case 8: \ |
127 | asm(op "q "__percpu_arg(1)",%0" \ | 127 | asm(op "q "__percpu_arg(1)",%0" \ |
128 | : "=r" (ret__) \ | 128 | : "=r" (pfo_ret__) \ |
129 | : constraint); \ | 129 | : constraint); \ |
130 | break; \ | 130 | break; \ |
131 | default: __bad_percpu_size(); \ | 131 | default: __bad_percpu_size(); \ |
132 | } \ | 132 | } \ |
133 | ret__; \ | 133 | pfo_ret__; \ |
134 | }) | 134 | }) |
135 | 135 | ||
136 | /* | 136 | /* |
@@ -153,6 +153,84 @@ do { \ | |||
153 | #define percpu_or(var, val) percpu_to_op("or", per_cpu__##var, val) | 153 | #define percpu_or(var, val) percpu_to_op("or", per_cpu__##var, val) |
154 | #define percpu_xor(var, val) percpu_to_op("xor", per_cpu__##var, val) | 154 | #define percpu_xor(var, val) percpu_to_op("xor", per_cpu__##var, val) |
155 | 155 | ||
156 | #define __this_cpu_read_1(pcp) percpu_from_op("mov", (pcp), "m"(pcp)) | ||
157 | #define __this_cpu_read_2(pcp) percpu_from_op("mov", (pcp), "m"(pcp)) | ||
158 | #define __this_cpu_read_4(pcp) percpu_from_op("mov", (pcp), "m"(pcp)) | ||
159 | |||
160 | #define __this_cpu_write_1(pcp, val) percpu_to_op("mov", (pcp), val) | ||
161 | #define __this_cpu_write_2(pcp, val) percpu_to_op("mov", (pcp), val) | ||
162 | #define __this_cpu_write_4(pcp, val) percpu_to_op("mov", (pcp), val) | ||
163 | #define __this_cpu_add_1(pcp, val) percpu_to_op("add", (pcp), val) | ||
164 | #define __this_cpu_add_2(pcp, val) percpu_to_op("add", (pcp), val) | ||
165 | #define __this_cpu_add_4(pcp, val) percpu_to_op("add", (pcp), val) | ||
166 | #define __this_cpu_and_1(pcp, val) percpu_to_op("and", (pcp), val) | ||
167 | #define __this_cpu_and_2(pcp, val) percpu_to_op("and", (pcp), val) | ||
168 | #define __this_cpu_and_4(pcp, val) percpu_to_op("and", (pcp), val) | ||
169 | #define __this_cpu_or_1(pcp, val) percpu_to_op("or", (pcp), val) | ||
170 | #define __this_cpu_or_2(pcp, val) percpu_to_op("or", (pcp), val) | ||
171 | #define __this_cpu_or_4(pcp, val) percpu_to_op("or", (pcp), val) | ||
172 | #define __this_cpu_xor_1(pcp, val) percpu_to_op("xor", (pcp), val) | ||
173 | #define __this_cpu_xor_2(pcp, val) percpu_to_op("xor", (pcp), val) | ||
174 | #define __this_cpu_xor_4(pcp, val) percpu_to_op("xor", (pcp), val) | ||
175 | |||
176 | #define this_cpu_read_1(pcp) percpu_from_op("mov", (pcp), "m"(pcp)) | ||
177 | #define this_cpu_read_2(pcp) percpu_from_op("mov", (pcp), "m"(pcp)) | ||
178 | #define this_cpu_read_4(pcp) percpu_from_op("mov", (pcp), "m"(pcp)) | ||
179 | #define this_cpu_write_1(pcp, val) percpu_to_op("mov", (pcp), val) | ||
180 | #define this_cpu_write_2(pcp, val) percpu_to_op("mov", (pcp), val) | ||
181 | #define this_cpu_write_4(pcp, val) percpu_to_op("mov", (pcp), val) | ||
182 | #define this_cpu_add_1(pcp, val) percpu_to_op("add", (pcp), val) | ||
183 | #define this_cpu_add_2(pcp, val) percpu_to_op("add", (pcp), val) | ||
184 | #define this_cpu_add_4(pcp, val) percpu_to_op("add", (pcp), val) | ||
185 | #define this_cpu_and_1(pcp, val) percpu_to_op("and", (pcp), val) | ||
186 | #define this_cpu_and_2(pcp, val) percpu_to_op("and", (pcp), val) | ||
187 | #define this_cpu_and_4(pcp, val) percpu_to_op("and", (pcp), val) | ||
188 | #define this_cpu_or_1(pcp, val) percpu_to_op("or", (pcp), val) | ||
189 | #define this_cpu_or_2(pcp, val) percpu_to_op("or", (pcp), val) | ||
190 | #define this_cpu_or_4(pcp, val) percpu_to_op("or", (pcp), val) | ||
191 | #define this_cpu_xor_1(pcp, val) percpu_to_op("xor", (pcp), val) | ||
192 | #define this_cpu_xor_2(pcp, val) percpu_to_op("xor", (pcp), val) | ||
193 | #define this_cpu_xor_4(pcp, val) percpu_to_op("xor", (pcp), val) | ||
194 | |||
195 | #define irqsafe_cpu_add_1(pcp, val) percpu_to_op("add", (pcp), val) | ||
196 | #define irqsafe_cpu_add_2(pcp, val) percpu_to_op("add", (pcp), val) | ||
197 | #define irqsafe_cpu_add_4(pcp, val) percpu_to_op("add", (pcp), val) | ||
198 | #define irqsafe_cpu_and_1(pcp, val) percpu_to_op("and", (pcp), val) | ||
199 | #define irqsafe_cpu_and_2(pcp, val) percpu_to_op("and", (pcp), val) | ||
200 | #define irqsafe_cpu_and_4(pcp, val) percpu_to_op("and", (pcp), val) | ||
201 | #define irqsafe_cpu_or_1(pcp, val) percpu_to_op("or", (pcp), val) | ||
202 | #define irqsafe_cpu_or_2(pcp, val) percpu_to_op("or", (pcp), val) | ||
203 | #define irqsafe_cpu_or_4(pcp, val) percpu_to_op("or", (pcp), val) | ||
204 | #define irqsafe_cpu_xor_1(pcp, val) percpu_to_op("xor", (pcp), val) | ||
205 | #define irqsafe_cpu_xor_2(pcp, val) percpu_to_op("xor", (pcp), val) | ||
206 | #define irqsafe_cpu_xor_4(pcp, val) percpu_to_op("xor", (pcp), val) | ||
207 | |||
208 | /* | ||
209 | * Per cpu atomic 64 bit operations are only available under 64 bit. | ||
210 | * 32 bit must fall back to generic operations. | ||
211 | */ | ||
212 | #ifdef CONFIG_X86_64 | ||
213 | #define __this_cpu_read_8(pcp) percpu_from_op("mov", (pcp), "m"(pcp)) | ||
214 | #define __this_cpu_write_8(pcp, val) percpu_to_op("mov", (pcp), val) | ||
215 | #define __this_cpu_add_8(pcp, val) percpu_to_op("add", (pcp), val) | ||
216 | #define __this_cpu_and_8(pcp, val) percpu_to_op("and", (pcp), val) | ||
217 | #define __this_cpu_or_8(pcp, val) percpu_to_op("or", (pcp), val) | ||
218 | #define __this_cpu_xor_8(pcp, val) percpu_to_op("xor", (pcp), val) | ||
219 | |||
220 | #define this_cpu_read_8(pcp) percpu_from_op("mov", (pcp), "m"(pcp)) | ||
221 | #define this_cpu_write_8(pcp, val) percpu_to_op("mov", (pcp), val) | ||
222 | #define this_cpu_add_8(pcp, val) percpu_to_op("add", (pcp), val) | ||
223 | #define this_cpu_and_8(pcp, val) percpu_to_op("and", (pcp), val) | ||
224 | #define this_cpu_or_8(pcp, val) percpu_to_op("or", (pcp), val) | ||
225 | #define this_cpu_xor_8(pcp, val) percpu_to_op("xor", (pcp), val) | ||
226 | |||
227 | #define irqsafe_cpu_add_8(pcp, val) percpu_to_op("add", (pcp), val) | ||
228 | #define irqsafe_cpu_and_8(pcp, val) percpu_to_op("and", (pcp), val) | ||
229 | #define irqsafe_cpu_or_8(pcp, val) percpu_to_op("or", (pcp), val) | ||
230 | #define irqsafe_cpu_xor_8(pcp, val) percpu_to_op("xor", (pcp), val) | ||
231 | |||
232 | #endif | ||
233 | |||
156 | /* This is not atomic against other CPUs -- CPU preemption needs to be off */ | 234 | /* This is not atomic against other CPUs -- CPU preemption needs to be off */ |
157 | #define x86_test_and_clear_bit_percpu(bit, var) \ | 235 | #define x86_test_and_clear_bit_percpu(bit, var) \ |
158 | ({ \ | 236 | ({ \ |