lkml.org 
[lkml]   [1998]   [Dec]   [12]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
Subject[PATCH] 2.1.131: i386 tweak to switch_to()
Linus,

Please find enclosed a patch which reduces the number of instructions in
switch_to() on i386. It's similar to the patch someone posted which
simply removes some of the push/pop pairs, but this one has the correct
asm constraints so that it works properly ;-)

Tested on UP w/ egcs-1.0.2 (I'm running with it now). Should work
everywhere.

-- Jamie

--- linux/include/asm-i386/system.h.devel Sun Dec 6 21:30:16 1998
+++ linux/include/asm-i386/system.h Fri Dec 11 14:52:42 1998
@@ -12,27 +12,25 @@
/*
* We do most of the task switching in C, but we need
* to do the EIP/ESP switch in assembly..
+ * EBP must be last thing pushed on stack for get_wchan()
+ * [see fs/proc/array.c], and anyway EBP is ignored in the clobbers list.
*/
#define switch_to(prev,next) do { \
- unsigned long eax, edx, ecx; \
- asm volatile("pushl %%ebx\n\t" \
- "pushl %%esi\n\t" \
- "pushl %%edi\n\t" \
- "pushl %%ebp\n\t" \
+ unsigned long eax, edx; \
+ asm volatile("pushl %%ebp\n\t" \
"movl %%esp,%0\n\t" /* save ESP */ \
- "movl %5,%%esp\n\t" /* restore ESP */ \
+ "movl %4,%%esp\n\t" /* restore ESP */ \
"movl $1f,%1\n\t" /* save EIP */ \
- "pushl %6\n\t" /* restore EIP */ \
- "jmp __switch_to\n" \
+ "pushl %5\n\t" /* restore EIP */ \
+ "jmp __switch_to\n\t" \
+ ".balign 4\n" \
"1:\t" \
- "popl %%ebp\n\t" \
- "popl %%edi\n\t" \
- "popl %%esi\n\t" \
- "popl %%ebx" \
+ "popl %%ebp" \
:"=m" (prev->tss.esp),"=m" (prev->tss.eip), \
- "=a" (eax), "=d" (edx), "=c" (ecx) \
+ "=a" (eax), "=d" (edx) \
:"m" (next->tss.esp),"m" (next->tss.eip), \
- "a" (prev), "d" (next)); \
+ "a" (prev), "d" (next) \
+ :"ebx", "ecx", "esi", "edi", "cc", "memory"); \
} while (0)

#define _set_base(addr,base) \
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2005-03-22 13:46    [from the cache]
©2003-2011 Jasper Spaans