i386 individual CPU selection
PATCH 1/1 i386 individual CPU selection
User interface:
This patch changes the CPU selection mechanism so that each CPU is an independent y/n choice.
The advantage of this is that the user knows exactly and has full control over the range of CPUs supported by the kernel. Without this patch it's not clear, for example, how to build a kernel that will work on both K6s and WinChips.
In addition to the processor selection, a choice is added for the CPU that the kernel should be optimized, which is used for the -mcpu switch.
CPU description language and capabilities:
CPU capabilities are described in a simple description language in arch/i386/kernel/cpu/Config.in.in which is converted by scripts/gencpucfg to config language and a generated header. Example:
cpu PENTIUMIII
name "Intel Pentium III"
arch 686
align 4
has fpu good_apic mmx mmxext pae xmm tsc
mayhave smp
wants 686_checksum prefetch
end
For each of the capabilities listed in has/mayhave/wants/maywant two macros may be defined: CONFIG_X86_MAY_HAVE|WANT_feature and CONFIG_X86_MAY_NOT_HAVE|WANT_feature.
These flags are defined in arch/i386/kernel/cpu/Config.in: the definitions are done per-flag rather than per-cpu to avoid config options showing multiple times in .config.
The cpufeature_config.h header is generated and defines cpu_has|wants_feature either as 0, to 1 or __cpu_has|wants_feature depending on the flags.
Example:
#if defined(CONFIG_X86_MAY_HAVE_TSC) && defined(CONFIG_X86_MAY_NOT_HAVE_TSC)
#define cpu_has_tsc __cpu_has_tsc
#elif defined(CONFIG_X86_MAY_HAVE_TSC)
#define cpu_has_tsc 1
#else
#define cpu_has_tsc 0
#endif
The code alignment and L1 cache size are instead automatically set to the largest value among the selected processors.
This system, while a bit complex, allows to generate optimal code for a given set of processors.
Now the only missing feature is the actual use of these macros and the dynamic fixup code in the whole i386 kernel tree, which is a 57KB patch, coming soon if no one objects.
arch/i386/Config.help +89 -62
@@ -387,110 +387,137 @@ CONFIG_BINFMT_MISC don't know what to answer at this point, say Y. CONFIG_M386 - This is the processor type of your CPU. This information is used for - optimizing purposes. In order to compile a kernel that can run on - all x86 CPU types (albeit not optimally fast), you can specify - "386" here. - - The kernel will not necessarily run on earlier architectures than - the one you have chosen, e.g. a Pentium optimized kernel will run on - a PPro, but not necessarily on a i486. - - Here are the settings recommended for greatest speed: - - "386" for the AMD/Cyrix/Intel 386DX/DXL/SL/SLC/SX, Cyrix/TI - 486DLC/DLC2, UMC 486SX-S and NexGen Nx586. Only "386" kernels - will run on a 386 class machine. - - "486" for the AMD/Cyrix/IBM/Intel 486DX/DX2/DX4 or - SL/SLC/SLC2/SLC3/SX/SX2 and UMC U5D or U5S. - - "586" for generic Pentium CPUs lacking the TSC - (time stamp counter) register. - - "Pentium-Classic" for the Intel Pentium. - - "Pentium-MMX" for the Intel Pentium MMX. - - "Pentium-Pro" for the Intel Pentium Pro/Celeron/Pentium II. - - "Pentium-III" for the Intel Pentium III - and Celerons based on the Coppermine core. - - "Pentium-4" for the Intel Pentium 4. - - "K6" for the AMD K6, K6-II and K6-III (aka K6-3D). - - "Athlon" for the AMD K7 family (Athlon/Duron/Thunderbird). - - "Crusoe" for the Transmeta Crusoe series. - - "Winchip-C6" for original IDT Winchip. - - "Winchip-2" for IDT Winchip 2. - - "Winchip-2A" for IDT Winchips with 3dNow! capabilities. - - "CyrixIII" for VIA Cyrix III or VIA C3. - - If you don't know what to do, choose "386". + Say Y here for a x386 processor, ether Intel or one of the + compatible processors from AMD, Cyrix, IBM. + Only say Y if necessary, since the 386 lack of several cool features + will cause the kernel to emulate them with slower code. CONFIG_M486 - Select this for a x486 processor, ether Intel or one of the - compatible processors from AMD, Cyrix, IBM, or Intel. Includes DX, + Say Y here for a x486 processor, ether Intel or one of the + compatible processors from AMD, Cyrix, IBM. Includes DX, DX2, and DX4 variants; also SL/SLC/SLC2/SLC3/SX/SX2 and UMC U5D or U5S. +CONFIG_MELAN + Say Y here for an AMD Elan processor. Unfortunately this processor + is supported in such a way that the resulting kernel won't run on + any other processor. + CONFIG_M586 - Select this for an x586 or x686 processor such as the AMD K5, the + Say Y here for an x586 or x686 processor such as the AMD K5, the Intel 5x86 or 6x86, or the Intel 6x86MX. This choice does not assume the RDTSC (Read Time Stamp Counter) instruction. +CONFIG_M586MX + Say Y here for the NexGen 6x86MX and other Pentium-class processors + with the MMX graphics/multimedia extended instructions but without + the RDTSC (Read Time Stamp Counter) instruction. + CONFIG_M586TSC - Select this for a Pentium Classic processor with the RDTSC (Read + Say Y here for a Pentium Classic processor with the RDTSC (Read Time Stamp Counter) instruction for benchmarking. CONFIG_M586MMX - Select this for a Pentium with the MMX graphics/multimedia - extended instructions. + Say Y here for a Pentium with the MMX graphics/multimedia + extended instructions and with the RDTSC (Read Time Stamp Counter) + instruction for benchmarking. CONFIG_M686 - Select this for a Pro/Celeron/Pentium II. This enables the use of - Pentium Pro extended instructions, and disables the init-time guard - against the f00f bug found in earlier Pentiums. + Say Y here for a non-Intel/AMD 686 processor without MMX support + support. This enables the use of Pentium Pro extended instructions + and disables the init-time guard against the f00f bug found in + earlier Pentiums. + +CONFIG_MPENTIUMPRO + Say Y here for a Pentium Pro or Celeron. This enables the use of + Pentium Pro extended instructions, disables the init-time guard + against the f00f bug found in earlier Pentiums and enables the + workaround for the Pentium Pro store ordering bug. + +CONFIG_MPENTIUMII + Say Y here for a Pentium II or another 686 processor with MMX + support. This enables the use of Pentium Pro extended instructions, + disables the init-time guard against the f00f bug found in earlier + Pentiums and disables the workaround for the Pentium Pro store + ordering bug. CONFIG_MPENTIUMIII - Select this for Intel chips based on the Pentium-III and + Say Y here for Intel chips based on the Pentium-III and Celeron-Coppermine core. Enables use of some extended prefetch instructions, in addition to the Pentium II extensions. CONFIG_MPENTIUM4 - Select this for Intel Pentium 4 chips. Presently these are - treated almost like Pentium IIIs, but with a different cache - shift. + Say Y here for Intel Pentium 4 chips. They have a different cache + shift and if you are compiling with GCC 3.1 or later instructions + will be selected and ordered specifically for maximum performance on + the Intel Pentium 4. CONFIG_MCRUSOE - Select this for Transmeta Crusoe processor. Treats the processor + Say Y here for Transmeta Crusoe processor. Treats the processor like a 586 with TSC, and sets some GCC optimization flags (like a Pentium Pro with no alignment requirements). CONFIG_MK6 - Select this for an AMD K6-family processor. Enables use of - some extended instructions, and passes appropriate optimization - flags to GCC. + Say Y here for an AMD K6 processor. Enables use of some extended + instructions, and passes appropriate optimization flags to GCC. + +CONFIG_MK6II + Say Y here for an AMD K6-2/K6-3D or K6-3. Enables use of some + extended instructions, passes appropriate optimization flags to GCC + and enables 3DNow! CONFIG_MK7 - Select this for an AMD Athlon K7-family processor. Enables use of - some extended instructions, and passes appropriate optimization - flags to GCC. + Say Y here for an AMD Athlon K7-family processor. Enables use of + some extended instructions, passes appropriate optimization flags to + GCC and enables 3DNow! + +CONFIG_MK7SSE + Say Y here for an AMD Athlon K7-family processor with SSE support + such as the Athlon XP/MP. Enables use of some extended + instructions, passes appropriate optimization flags to GCC and + enables 3DNow! and SSE CONFIG_MCYRIXIII - Select this for a Cyrix III or C3 chip. Presently Linux and GCC + Say Y here for a Cyrix III or C3 chip. Presently Linux and GCC treat this chip as a generic 586. Whilst the CPU is 686 class, it lacks the cmov extension which gcc assumes is present when generating 686 code. CONFIG_MWINCHIPC6 - Select this for a IDT Winchip C6 chip. Linux and GCC - treat this chip as a 586TSC with some extended instructions - and alignment requirements. + Say Y here for a IDT Winchip C6 chip. Linux and GCC + treat this chip as a 586 with some extended instructions + and alignment requirements. Development kernels also enable + out of order memory stores for this CPU, which can increase + performance of some operations. CONFIG_MWINCHIP2 - Select this for a IDT Winchip-2. Linux and GCC + Say Y here for a IDT Winchip-2. Linux and GCC treat this chip as a 586TSC with some extended instructions - and alignment requirements. + and alignment requirements. Development kernels also enable + out of order memory stores for this CPU, which can increase + performance of some operations. CONFIG_MWINCHIP3D - Select this for a IDT Winchip-2A or 3. Linux and GCC + Say Y here for a IDT Winchip-2A or 3. Linux and GCC treat this chip as a 586TSC with some extended instructions - and alignment reqirements. Development kernels also enable - out of order memory stores for this CPU, which can increase - performance of some operations. + and alignment reqirements and with 3DNow! support. Development + kernels also enable out of order memory stores for this CPU, which + can increase performance of some operations. + +CONFIG_X86_MCPU_386 + This is the processor type the kernel will be optimized for. The + kernel will run on any processor you selected in the previous + questions, but it will run faster on the CPUs selected here and + slower on others. + + Currently this only affects instruction scheduling. Alignment and L1 + cacheline size are automatically set to the largest one from the + processors you select. + + If you don't know what to do, choose the processor where you want to + obtain the maximum performance. If you still don't know what to do, + choose the first element in the list that matches a processors that + you selected in the previous questions. CONFIG_VGA_CONSOLE Saying Y here will allow you to use Linux in text mode through a
arch/i386/config.in +63 -131
237 lines not on this page · raw message
arch/i386/defconfig +5 -2
@@ -36,16 +36,19 @@ CONFIG_KMOD=y # CONFIG_M586TSC is not set # CONFIG_M586MMX is not set # CONFIG_M686 is not set +CONFIG_MPENTIUMII=y CONFIG_MPENTIUMIII=y -# CONFIG_MPENTIUM4 is not set +CONFIG_MPENTIUM4=y # CONFIG_MK6 is not set -# CONFIG_MK7 is not set +CONFIG_MK7=y +CONFIG_MK7SSE=y # CONFIG_MELAN is not set # CONFIG_MCRUSOE is not set # CONFIG_MWINCHIPC6 is not set # CONFIG_MWINCHIP2 is not set # CONFIG_MWINCHIP3D is not set # CONFIG_MCYRIXIII is not set +CONFIG_MCPU_686=y CONFIG_X86_WP_WORKS_OK=y CONFIG_X86_INVLPG=y CONFIG_X86_CMPXCHG=y
arch/i386/kernel/cpu/Config.in.in +182 -0
182 lines not on this page · raw message
arch/i386/Makefile +75 -31
149 lines not on this page · raw message
Makefile +11 -11
@@ -565,36 +565,38 @@ ifeq ($(filter-out $(noconfig_targets),$ # Kernel configuration # --------------------------------------------------------------------------- +include arch/$(ARCH)/Makefile + .PHONY: oldconfig xconfig menuconfig config \ make_with_config -xconfig: +xconfig: arch/$(ARCH)/config.in @$(MAKE) -C scripts kconfig.tk wish -f scripts/kconfig.tk -menuconfig: +menuconfig: arch/$(ARCH)/config.in @$(MAKE) -C scripts lxdialog $(CONFIG_SHELL) $(src)/scripts/Menuconfig arch/$(ARCH)/config.in -config: +config: arch/$(ARCH)/config.in $(CONFIG_SHELL) $(src)/scripts/Configure arch/$(ARCH)/config.in -oldconfig: +oldconfig: arch/$(ARCH)/config.in $(CONFIG_SHELL) $(src)/scripts/Configure -d arch/$(ARCH)/config.in -randconfig: +randconfig: arch/$(ARCH)/config.in $(CONFIG_SHELL) $(src)/scripts/Configure -r arch/$(ARCH)/config.in -allyesconfig: +allyesconfig: arch/$(ARCH)/config.in $(CONFIG_SHELL) $(src)/scripts/Configure -y arch/$(ARCH)/config.in -allnoconfig: +allnoconfig: arch/$(ARCH)/config.in $(CONFIG_SHELL) $(src)/scripts/Configure -n arch/$(ARCH)/config.in -allmodconfig: +allmodconfig: arch/$(ARCH)/config.in $(CONFIG_SHELL) $(src)/scripts/Configure -m arch/$(ARCH)/config.in -defconfig: +defconfig: arch/$(ARCH)/config.in yes '' | $(CONFIG_SHELL) $(src)/scripts/Configure -d arch/$(ARCH)/config.in # Cleaning up
@@ -654,8 +656,6 @@ MRPROPER_DIRS += \ # That's our way to know about arch specific cleanup. -include arch/$(ARCH)/Makefile - clean: archclean @echo 'Cleaning up' @find . -name SCCS -prune -o -name BitKeeper -prune -o \
scripts/gencpucfg +140 -0
140 lines not on this page · raw message