Messages in this thread Patches in this message | | | Date | Sun, 20 Feb 2000 20:52:28 +0100 | From | Rainer Keller <> | Subject | [Patch] Optimize entry.S and hw_irq.h |
| |
Hi Yall, some time ago (in the times of 2.0) I was stumbling across some assembly lines, which didn't look too optimised, regarding, that they seem to be rather time-critical.
Well, I took a second look and quickly came up with some optimisation, which should at least make my P133 (w/o MMX) happier.
It runs stable and feels a LoT faster ,-]]] (*just joking*) Anyway, it might help, so feel free to comment or improve.
Now, on to the patch: The Macro in entry.S was calling cld, which cannot pair on P5, since most of the time, the macro was called after another value was pushed on to the stack, I chose to take cld out of the way after the pushes, in order to let those pair. Then, I'm not to happy with mov $(__KERNEL_DS), %edx; since %edx is pushed only 2 cycles above, as well as choosing %ebx for the kernel segment...
Well, but since in the most critical path (I believe) it was used in conjunction with the macro GET_CURRENT, I chose to come up with a new macro, SAVE_ALL_GET_CURRENT, which would do both, just interleaved to better fill the pipes of the Pentium. Then of course, the two macros where exchanged by the new one later on.
In hw_irq.h, only the cld was moved towards the end of the macro, for the very same reasons. This alone should save 2 cycles on Pplain.
If You have suggestions, I'd be more than happy to hear about them, but please CC, since I'm not subscribed to LKML.
Greetings, raY
-- ------------------------------------------------------------------------ Rainer Keller e-mail: Rainer.Keller@studmail.uni-stuttgart.de Universitaetsstr. 100 WWW: http://wg100.wh.uni-stuttgart.de/~ray 70569 Stuttgart Tel. 0711 / 6787536--- linux-2.3.46/arch/i386/kernel/entry.S Sun Feb 20 11:50:41 2000 +++ linux-2.3.46-mine/arch/i386/kernel/entry.S Sun Feb 20 20:31:51 2000 @@ -82,7 +82,6 @@ #define SAVE_ALL \ - cld; \ pushl %es; \ pushl %ds; \ pushl %eax; \ @@ -92,10 +91,28 @@ pushl %edx; \ pushl %ecx; \ pushl %ebx; \ + cld; \ movl $(__KERNEL_DS),%edx; \ movl %edx,%ds; \ movl %edx,%es; +#define SAVE_ALL_GET_CURRENT(reg) \ + pushl %es; \ + pushl %ds; \ + pushl %eax; \ + pushl %ebp; \ + pushl %edi; \ + pushl %esi; \ + pushl %edx; \ + pushl %ecx; \ + pushl %ebx; \ + cld; \ + movl $(__KERNEL_DS),%edx; \ + movl %esp, reg; \ + movl %edx,%ds; \ + movl %edx,%es; \ + andl $-8192, reg; \ + #define RESTORE_ALL \ popl %ebx; \ popl %ecx; \ @@ -192,8 +209,7 @@ ENTRY(system_call) pushl %eax # save orig_eax - SAVE_ALL - GET_CURRENT(%ebx) + SAVE_ALL_GET_CURRENT(%ebx) cmpl $(NR_syscalls),%eax jae badsys testb $0x20,flags(%ebx) # PF_TRACESYS @@ -327,8 +343,7 @@ ENTRY(device_not_available) pushl $-1 # mark this as an int - SAVE_ALL - GET_CURRENT(%ebx) + SAVE_ALL_GET_CURRENT(%ebx) pushl $ret_from_exception movl %cr0,%eax testl $0x4,%eax # EM (math emulation bit)--- linux-2.3.46/include/asm-i386/hw_irq.h Tue Feb 1 02:14:00 2000 +++ linux-2.3.46-mine/include/asm-i386/hw_irq.h Sun Feb 20 14:39:58 2000 @@ -95,7 +95,6 @@ #define STR(x) __STR(x) #define SAVE_ALL \ - "cld\n\t" \ "pushl %es\n\t" \ "pushl %ds\n\t" \ "pushl %eax\n\t" \ @@ -105,6 +104,7 @@ "pushl %edx\n\t" \ "pushl %ecx\n\t" \ "pushl %ebx\n\t" \ + "cld\n\t" \ "movl $" STR(__KERNEL_DS) ",%edx\n\t" \ "movl %edx,%ds\n\t" \ "movl %edx,%es\n\t" | |