[PATCH] Some assembly microoptimizations for 2.4

From: Andi Kleen (ak@suse.de)
Date: Fri Dec 22 2000 - 12:59:48 EST

  • Next message: Richard B. Johnson: "Re: Transmission errors for Xircom RealPort2 10/100 Cardbus NIC."

    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/



    This archive was generated by hypermail 2b29 : Fri Dec 22 2000 - 13:30:12 EST