aboutsummaryrefslogtreecommitdiffstats
path: root/include/asm-x86/system.h
diff options
context:
space:
mode:
authorIngo Molnar <mingo@elte.hu>2008-03-05 04:46:38 -0500
committerIngo Molnar <mingo@elte.hu>2008-04-17 11:40:52 -0400
commit8b6451fe5cf78909f28d3762f77df060c8603cd0 (patch)
treea9e6a3a9f79877675a1855469ed98677db771797 /include/asm-x86/system.h
parent23b55bd9f33a1812a664e548803db34c9bec56e8 (diff)
x86: fix switch_to() clobbers
Liu Pingfan noticed that switch_to() clobbers more registers than its asm constraints specify. We get away with this due to luck mostly - schedule() by its nature only has 'local' state which gets reloaded automatically. Fix it nevertheless, we could hit this anytime. it turns out that with the extra constraints gcc manages to make schedule() even more compact: text data bss dec hex filename 28626 684 2640 31950 7cce sched.o.before 28613 684 2640 31937 7cc1 sched.o.after Reported-by: Liu Pingfan <kernelfans@gmail.com> Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'include/asm-x86/system.h')
-rw-r--r--include/asm-x86/system.h10
1 files changed, 9 insertions, 1 deletions
diff --git a/include/asm-x86/system.h b/include/asm-x86/system.h
index 299ae9605cb1..33b0017156a7 100644
--- a/include/asm-x86/system.h
+++ b/include/asm-x86/system.h
@@ -29,7 +29,14 @@ struct task_struct *__switch_to(struct task_struct *prev,
29 */ 29 */
30#define switch_to(prev, next, last) \ 30#define switch_to(prev, next, last) \
31do { \ 31do { \
32 unsigned long esi, edi; \ 32 /* \
33 * Context-switching clobbers all registers, so we clobber \
34 * them explicitly, via unused output variables. \
35 * (EAX and EBP is not listed because EBP is saved/restored \
36 * explicitly for wchan access and EAX is the return value of \
37 * __switch_to()) \
38 */ \
39 unsigned long ebx, ecx, edx, esi, edi; \
33 \ 40 \
34 asm volatile( \ 41 asm volatile( \
35 "pushfl \n\t" /* save flags */ \ 42 "pushfl \n\t" /* save flags */ \
@@ -49,6 +56,7 @@ do { \
49 "=a" (last), \ 56 "=a" (last), \
50 \ 57 \
51 /* clobbered output registers: */ \ 58 /* clobbered output registers: */ \
59 "=b" (ebx), "=c" (ecx), "=d" (edx), \
52 "=S" (esi), "=D" (edi) \ 60 "=S" (esi), "=D" (edi) \
53 \ 61 \
54 /* input parameters: */ \ 62 /* input parameters: */ \