[PATCH] x86: SMP alternatives
authorGerd Hoffmann <kraxel@suse.de>
Thu, 23 Mar 2006 10:59:32 +0000 (02:59 -0800)
committerLinus Torvalds <torvalds@g5.osdl.org>
Thu, 23 Mar 2006 15:38:04 +0000 (07:38 -0800)
commit9a0b5817ad97bb718ab85322759d19a238712b47
tree39bd21eb69c4001b99096d96a76a2e5d37904108
parent4d7d8c82c181711d28c8336108330a9121f5ef07
[PATCH] x86: SMP alternatives

Implement SMP alternatives, i.e.  switching at runtime between different
code versions for UP and SMP.  The code can patch both SMP->UP and UP->SMP.
The UP->SMP case is useful for CPU hotplug.

With CONFIG_CPU_HOTPLUG enabled the code switches to UP at boot time and
when the number of CPUs goes down to 1, and switches to SMP when the number
of CPUs goes up to 2.

Without CONFIG_CPU_HOTPLUG or on non-SMP-capable systems the code is
patched once at boot time (if needed) and the tables are released
afterwards.

The changes in detail:

  * The current alternatives bits are moved to a separate file,
    the SMP alternatives code is added there.

  * The patch adds some new elf sections to the kernel:
    .smp_altinstructions
like .altinstructions, also contains a list
of alt_instr structs.
    .smp_altinstr_replacement
like .altinstr_replacement, but also has some space to
save original instruction before replaving it.
    .smp_locks
list of pointers to lock prefixes which can be nop'ed
out on UP.
    The first two are used to replace more complex instruction
    sequences such as spinlocks and semaphores.  It would be possible
    to deal with the lock prefixes with that as well, but by handling
    them as special case the table sizes become much smaller.

 * The sections are page-aligned and padded up to page size, so they
   can be free if they are not needed.

 * Splitted the code to release init pages to a separate function and
   use it to release the elf sections if they are unused.

Signed-off-by: Gerd Hoffmann <kraxel@suse.de>
Signed-off-by: Chuck Ebbert <76306.1226@compuserve.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
20 files changed:
arch/i386/kernel/Makefile
arch/i386/kernel/alternative.c [new file with mode: 0644]
arch/i386/kernel/cpu/proc.c
arch/i386/kernel/module.c
arch/i386/kernel/semaphore.c
arch/i386/kernel/setup.c
arch/i386/kernel/smpboot.c
arch/i386/kernel/vmlinux.lds.S
arch/i386/mm/init.c
arch/um/kernel/um_arch.c
include/asm-i386/alternative.h [new file with mode: 0644]
include/asm-i386/atomic.h
include/asm-i386/bitops.h
include/asm-i386/cpufeature.h
include/asm-i386/mutex.h
include/asm-i386/rwlock.h
include/asm-i386/semaphore.h
include/asm-i386/spinlock.h
include/asm-i386/system.h
include/asm-um/alternative.h [new file with mode: 0644]