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>
This commit is contained in:
@@ -29,7 +29,14 @@ struct task_struct *__switch_to(struct task_struct *prev,
|
|||||||
*/
|
*/
|
||||||
#define switch_to(prev, next, last) \
|
#define switch_to(prev, next, last) \
|
||||||
do { \
|
do { \
|
||||||
unsigned long esi, edi; \
|
/* \
|
||||||
|
* Context-switching clobbers all registers, so we clobber \
|
||||||
|
* them explicitly, via unused output variables. \
|
||||||
|
* (EAX and EBP is not listed because EBP is saved/restored \
|
||||||
|
* explicitly for wchan access and EAX is the return value of \
|
||||||
|
* __switch_to()) \
|
||||||
|
*/ \
|
||||||
|
unsigned long ebx, ecx, edx, esi, edi; \
|
||||||
\
|
\
|
||||||
asm volatile( \
|
asm volatile( \
|
||||||
"pushfl \n\t" /* save flags */ \
|
"pushfl \n\t" /* save flags */ \
|
||||||
@@ -49,6 +56,7 @@ do { \
|
|||||||
"=a" (last), \
|
"=a" (last), \
|
||||||
\
|
\
|
||||||
/* clobbered output registers: */ \
|
/* clobbered output registers: */ \
|
||||||
|
"=b" (ebx), "=c" (ecx), "=d" (edx), \
|
||||||
"=S" (esi), "=D" (edi) \
|
"=S" (esi), "=D" (edi) \
|
||||||
\
|
\
|
||||||
/* input parameters: */ \
|
/* input parameters: */ \
|
||||||
|
Reference in New Issue
Block a user