From: Andi Kleen <ak@suse.de>
To: Alan Cox <alan@lxorguk.ukuu.org.uk>
Cc: linux-kernel@vger.kernel.org
Subject: [PATCH] Some assembly microoptimizations for 2.4
Date: Fri, 22 Dec 2000 18:59:48 +0100 [thread overview]
Message-ID: <20001222185948.A26703@gruyere.muc.suse.de> (raw)
The following patch does some "micro optimizations" for 2.4, that are
partly not so micro. It tries to avoid segment register reloads for
interrupts taken from kernel mode (e.g. the idle task), because they
require expensive locked cycles to read the GDT. It also changes
switch_to() not to misalign the call/ret stack during context switch,
which helps somewhat on the Athlon.
They have been running well for some time on my workstation.
-Andi
--- arch/i386/kernel/entry.S 2000/11/10 04:49:56 1.92
+++ arch/i386/kernel/entry.S 2000/12/22 18:16:38
@@ -106,10 +106,14 @@
popl %edi; \
popl %ebp; \
popl %eax; \
+ cmpl $__KERNEL_DS,(%esp); \
+ je 4f ; \
1: popl %ds; \
2: popl %es; \
addl $4,%esp; \
3: iret; \
+4: addl $12,%esp; \
+ iret; \
.section .fixup,"ax"; \
4: movl $0,(%esp); \
jmp 1b; \
@@ -271,13 +275,13 @@
jne handle_softirq
ENTRY(ret_from_intr)
- GET_CURRENT(%ebx)
- movl EFLAGS(%esp),%eax # mix EFLAGS and CS
- movb CS(%esp),%al
- testl $(VM_MASK | 3),%eax # return to VM86 mode or non-supervisor?
+ GET_CURRENT(%ebx)
+ movl EFLAGS(%esp),%eax # mix EFLAGS and CS
+ movb CS(%esp),%al
+ testl $(VM_MASK | 3),%eax # return to VM86 mode or non-supervisor?
jne ret_with_reschedule
jmp restore_all
-
+
ALIGN
handle_softirq:
call SYMBOL_NAME(do_softirq)
@@ -313,9 +317,11 @@
pushl %esi # push the error code
pushl %edx # push the pt_regs pointer
movl $(__KERNEL_DS),%edx
+ cmpl %edx,%ecx
+ jz 1f # should only happen for *_user or kernel bugs
movl %edx,%ds
movl %edx,%es
- GET_CURRENT(%ebx)
+1: GET_CURRENT(%ebx)
call *%edi
addl $8,%esp
jmp ret_from_exception
--- include/asm-i386/system.h 2000/09/26 05:25:56 1.44
+++ include/asm-i386/system.h 2000/12/22 18:17:26
@@ -20,7 +20,9 @@
"movl %3,%%esp\n\t" /* restore ESP */ \
"movl $1f,%1\n\t" /* save EIP */ \
"pushl %4\n\t" /* restore EIP */ \
- "jmp __switch_to\n" \
+ "call __switch_to\n\t" \
+ "popl %%esi\n\t" \
+ "jmp *%%esi\n\t" \
"1:\t" \
"popl %%ebp\n\t" \
"popl %%edi\n\t" \
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
Please read the FAQ at http://www.tux.org/lkml/
reply other threads:[~2000-12-22 18:30 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20001222185948.A26703@gruyere.muc.suse.de \
--to=ak@suse.de \
--cc=alan@lxorguk.ukuu.org.uk \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).