linux/include/asm-i386
akpm@osdl.org 198e2f1811 [PATCH] scheduler cache-hot-autodetect
)

From: Ingo Molnar <mingo@elte.hu>

This is the latest version of the scheduler cache-hot-auto-tune patch.

The first problem was that detection time scaled with O(N^2), which is
unacceptable on larger SMP and NUMA systems. To solve this:

- I've added a 'domain distance' function, which is used to cache
  measurement results. Each distance is only measured once. This means
  that e.g. on NUMA distances of 0, 1 and 2 might be measured, on HT
  distances 0 and 1, and on SMP distance 0 is measured. The code walks
  the domain tree to determine the distance, so it automatically follows
  whatever hierarchy an architecture sets up. This cuts down on the boot
  time significantly and removes the O(N^2) limit. The only assumption
  is that migration costs can be expressed as a function of domain
  distance - this covers the overwhelming majority of existing systems,
  and is a good guess even for more assymetric systems.

  [ People hacking systems that have assymetries that break this
    assumption (e.g. different CPU speeds) should experiment a bit with
    the cpu_distance() function. Adding a ->migration_distance factor to
    the domain structure would be one possible solution - but lets first
    see the problem systems, if they exist at all. Lets not overdesign. ]

Another problem was that only a single cache-size was used for measuring
the cost of migration, and most architectures didnt set that variable
up. Furthermore, a single cache-size does not fit NUMA hierarchies with
L3 caches and does not fit HT setups, where different CPUs will often
have different 'effective cache sizes'. To solve this problem:

- Instead of relying on a single cache-size provided by the platform and
  sticking to it, the code now auto-detects the 'effective migration
  cost' between two measured CPUs, via iterating through a wide range of
  cachesizes. The code searches for the maximum migration cost, which
  occurs when the working set of the test-workload falls just below the
  'effective cache size'. I.e. real-life optimized search is done for
  the maximum migration cost, between two real CPUs.

  This, amongst other things, has the positive effect hat if e.g. two
  CPUs share a L2/L3 cache, a different (and accurate) migration cost
  will be found than between two CPUs on the same system that dont share
  any caches.

(The reliable measurement of migration costs is tricky - see the source
for details.)

Furthermore i've added various boot-time options to override/tune
migration behavior.

Firstly, there's a blanket override for autodetection:

	migration_cost=1000,2000,3000

will override the depth 0/1/2 values with 1msec/2msec/3msec values.

Secondly, there's a global factor that can be used to increase (or
decrease) the autodetected values:

	migration_factor=120

will increase the autodetected values by 20%. This option is useful to
tune things in a workload-dependent way - e.g. if a workload is
cache-insensitive then CPU utilization can be maximized by specifying
migration_factor=0.

I've tested the autodetection code quite extensively on x86, on 3
P3/Xeon/2MB, and the autodetected values look pretty good:

Dual Celeron (128K L2 cache):

 ---------------------
 migration cost matrix (max_cache_size: 131072, cpu: 467 MHz):
 ---------------------
           [00]    [01]
 [00]:     -     1.7(1)
 [01]:   1.7(1)    -
 ---------------------
 cacheflush times [2]: 0.0 (0) 1.7 (1784008)
 ---------------------

Here the slow memory subsystem dominates system performance, and even
though caches are small, the migration cost is 1.7 msecs.

Dual HT P4 (512K L2 cache):

 ---------------------
 migration cost matrix (max_cache_size: 524288, cpu: 2379 MHz):
 ---------------------
           [00]    [01]    [02]    [03]
 [00]:     -     0.4(1)  0.0(0)  0.4(1)
 [01]:   0.4(1)    -     0.4(1)  0.0(0)
 [02]:   0.0(0)  0.4(1)    -     0.4(1)
 [03]:   0.4(1)  0.0(0)  0.4(1)    -
 ---------------------
 cacheflush times [2]: 0.0 (33900) 0.4 (448514)
 ---------------------

Here it can be seen that there is no migration cost between two HT
siblings (CPU#0/2 and CPU#1/3 are separate physical CPUs). A fast memory
system makes inter-physical-CPU migration pretty cheap: 0.4 msecs.

8-way P3/Xeon [2MB L2 cache]:

 ---------------------
 migration cost matrix (max_cache_size: 2097152, cpu: 700 MHz):
 ---------------------
           [00]    [01]    [02]    [03]    [04]    [05]    [06]    [07]
 [00]:     -    19.2(1) 19.2(1) 19.2(1) 19.2(1) 19.2(1) 19.2(1) 19.2(1)
 [01]:  19.2(1)    -    19.2(1) 19.2(1) 19.2(1) 19.2(1) 19.2(1) 19.2(1)
 [02]:  19.2(1) 19.2(1)    -    19.2(1) 19.2(1) 19.2(1) 19.2(1) 19.2(1)
 [03]:  19.2(1) 19.2(1) 19.2(1)    -    19.2(1) 19.2(1) 19.2(1) 19.2(1)
 [04]:  19.2(1) 19.2(1) 19.2(1) 19.2(1)    -    19.2(1) 19.2(1) 19.2(1)
 [05]:  19.2(1) 19.2(1) 19.2(1) 19.2(1) 19.2(1)    -    19.2(1) 19.2(1)
 [06]:  19.2(1) 19.2(1) 19.2(1) 19.2(1) 19.2(1) 19.2(1)    -    19.2(1)
 [07]:  19.2(1) 19.2(1) 19.2(1) 19.2(1) 19.2(1) 19.2(1) 19.2(1)    -
 ---------------------
 cacheflush times [2]: 0.0 (0) 19.2 (19281756)
 ---------------------

This one has huge caches and a relatively slow memory subsystem - so the
migration cost is 19 msecs.

Signed-off-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Ashok Raj <ashok.raj@intel.com>
Signed-off-by: Ken Chen <kenneth.w.chen@intel.com>
Cc: <wilder@us.ibm.com>
Signed-off-by: John Hawkes <hawkes@sgi.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2006-01-12 09:08:50 -08:00
..
mach-bigsmp [PATCH] x86: convert bigsmp to use flat physical mode 2006-01-06 08:33:37 -08:00
mach-default [PATCH] x86_64/i386: Remove preempt disable calls in lowlevel IPI 2006-01-11 19:01:57 -08:00
mach-es7000 [PATCH] ES7000 platform update 2005-10-30 17:37:12 -08:00
mach-generic [PATCH] x86: sutomatically enable bigsmp when we have more than 8 CPUs 2005-09-05 00:06:10 -07:00
mach-numaq [PATCH] Do not enforce unique IO_APIC_ID check for xAPIC systems (i386) 2005-06-23 09:45:09 -07:00
mach-summit [PATCH] USB: Always do usb-handoff 2005-10-28 16:47:49 -07:00
mach-visws Revert "i386: move apic init in init_IRQs" 2005-10-31 19:16:17 -08:00
mach-voyager Linux-2.6.12-rc2 2005-04-16 15:20:36 -07:00
8253pit.h Linux-2.6.12-rc2 2005-04-16 15:20:36 -07:00
a.out.h Linux-2.6.12-rc2 2005-04-16 15:20:36 -07:00
acpi.h [ACPI] delete CONFIG_ACPI_PCI 2005-08-25 12:40:44 -04:00
agp.h [PATCH] i386: inline asm cleanup 2005-09-05 00:06:11 -07:00
apic.h [PATCH] i386: Handle missing local APIC timer interrupts on C3 state 2006-01-11 19:04:54 -08:00
apicdef.h [PATCH] x86: sutomatically enable bigsmp when we have more than 8 CPUs 2005-09-05 00:06:10 -07:00
arch_hooks.h Linux-2.6.12-rc2 2005-04-16 15:20:36 -07:00
atomic.h [PATCH] mutex subsystem, add atomic_xchg() to all arches 2006-01-09 15:59:17 -08:00
auxvec.h [PATCH] auxiliary vector cleanups 2005-09-07 16:57:21 -07:00
bitops.h [PATCH] i386/x86-64: Use input/output dependencies for bitops 2006-01-11 19:01:11 -08:00
boot.h Linux-2.6.12-rc2 2005-04-16 15:20:36 -07:00
bug.h [PATCH] remove all kernel BUGs 2005-05-01 08:59:01 -07:00
bugs.h [PATCH] i386: move SIMD initialization 2006-01-06 08:33:34 -08:00
byteorder.h Linux-2.6.12-rc2 2005-04-16 15:20:36 -07:00
cache.h [PATCH] Kill L1_CACHE_SHIFT_MAX 2006-01-08 20:13:39 -08:00
cacheflush.h [PATCH] x86/x86_64: mark rodata section read only: x86 parts 2006-01-06 08:33:36 -08:00
checksum.h [NET]: Fix ipl=>ihl typo in ip_fast_csum 2005-08-29 16:02:48 -07:00
cpu.h [PATCH] i386 CPU hotplug 2005-06-25 16:24:29 -07:00
cpufeature.h [PATCH] i386/x86-64: Generalize X86_FEATURE_CONSTANT_TSC flag 2006-01-11 19:01:12 -08:00
cputime.h Linux-2.6.12-rc2 2005-04-16 15:20:36 -07:00
current.h Linux-2.6.12-rc2 2005-04-16 15:20:36 -07:00
debugreg.h Linux-2.6.12-rc2 2005-04-16 15:20:36 -07:00
delay.h Linux-2.6.12-rc2 2005-04-16 15:20:36 -07:00
desc.h [PATCH] x86: GDT alignment fix 2006-01-06 08:33:33 -08:00
div64.h [PATCH] include/asm-i386/: "extern inline" -> "static inline" 2005-09-10 10:06:34 -07:00
dma-mapping.h [PATCH] i386: make pci_map_single/pci_map_sg warn for zero length. 2006-01-11 19:04:56 -08:00
dma.h Linux-2.6.12-rc2 2005-04-16 15:20:36 -07:00
e820.h [PATCH] Increase number of e820 entries hard limit from 32 to 128 2005-05-01 08:58:51 -07:00
elf.h [PATCH] fix remaining missing includes 2005-11-07 07:53:41 -08:00
emergency-restart.h [PATCH] i386: Implement machine_emergency_reboot 2005-07-26 14:35:42 -07:00
errno.h Linux-2.6.12-rc2 2005-04-16 15:20:36 -07:00
fcntl.h [PATCH] Clean up struct flock64 definitions 2005-09-07 16:57:38 -07:00
fixmap.h [ACPI] delete CONFIG_ACPI_BOOT 2005-08-24 12:08:54 -04:00
floppy.h [PATCH] make some things static 2005-05-05 16:36:47 -07:00
futex.h [PATCH] uml: adapt asm/futex.h to our arch 2005-09-21 16:16:29 -07:00
genapic.h [PATCH] Do not enforce unique IO_APIC_ID check for xAPIC systems (i386) 2005-06-23 09:45:09 -07:00
hardirq.h Linux-2.6.12-rc2 2005-04-16 15:20:36 -07:00
highmem.h [PATCH] kdump: Routines for copying dump pages 2005-06-25 16:24:53 -07:00
hpet.h [PATCH] i386: fix hpet for systems that don't support legacy replacement 2005-05-01 08:58:50 -07:00
hw_irq.h Revert "i386: move apic init in init_IRQs" 2005-10-31 19:16:17 -08:00
i387.h x86: use alternative instructions for fnsave/fxsave too 2005-07-22 18:19:20 -04:00
i8253.h [PATCH] x86: i8253/i8259A lock cleanup 2005-06-30 08:45:10 -07:00
i8259.h Linux-2.6.12-rc2 2005-04-16 15:20:36 -07:00
ide.h [PATCH] ide: explain the PCI bus test we do in <asm-i386/ide.h> 2005-11-10 00:10:37 +01:00
io.h [PATCH] x86_64: Generalize DMI and enable for x86-64 2006-01-11 19:04:51 -08:00
io_apic.h [ACPI] delete CONFIG_ACPI_BOOT 2005-08-24 12:08:54 -04:00
ioctl.h [PATCH] Generic ioctl.h 2006-01-10 08:01:34 -08:00
ioctls.h Linux-2.6.12-rc2 2005-04-16 15:20:36 -07:00
ipc.h Linux-2.6.12-rc2 2005-04-16 15:20:36 -07:00
ipcbuf.h Linux-2.6.12-rc2 2005-04-16 15:20:36 -07:00
irq.h [PATCH] Make vm86 support optional 2006-01-08 20:14:11 -08:00
ist.h Linux-2.6.12-rc2 2005-04-16 15:20:36 -07:00
kdebug.h [PATCH] x86 NMI: better support for debuggers 2005-09-05 00:06:13 -07:00
kexec.h [PATCH] Kdump: i386 compiler warning fix 2006-01-10 08:01:27 -08:00
kmap_types.h Linux-2.6.12-rc2 2005-04-16 15:20:36 -07:00
kprobes.h [PATCH] kprobes: fix build breakage 2006-01-10 08:01:40 -08:00
ldt.h Linux-2.6.12-rc2 2005-04-16 15:20:36 -07:00
linkage.h [PATCH] i386: fix prevent_tail_call 2005-05-26 16:16:16 -07:00
local.h Linux-2.6.12-rc2 2005-04-16 15:20:36 -07:00
math_emu.h Linux-2.6.12-rc2 2005-04-16 15:20:36 -07:00
mc146818rtc.h Linux-2.6.12-rc2 2005-04-16 15:20:36 -07:00
mca.h Linux-2.6.12-rc2 2005-04-16 15:20:36 -07:00
mca_dma.h Linux-2.6.12-rc2 2005-04-16 15:20:36 -07:00
mman.h [PATCH] madvise(MADV_REMOVE): remove pages from tmpfs shm backing store 2006-01-06 08:33:22 -08:00
mmu.h Linux-2.6.12-rc2 2005-04-16 15:20:36 -07:00
mmu_context.h Linux-2.6.12-rc2 2005-04-16 15:20:36 -07:00
mmx.h Linux-2.6.12-rc2 2005-04-16 15:20:36 -07:00
mmzone.h [PATCH] mm: kvaddr_to_nid not used in common code 2006-01-06 08:33:23 -08:00
module.h [PATCH] Base support for AMD Geode GX/LX processors 2006-01-06 08:33:38 -08:00
mpspec.h Merge linux-2.6 with linux-acpi-2.6 2005-09-08 01:45:47 -04:00
mpspec_def.h [PATCH] mpspec: remove unneeded packed attribute 2006-01-06 08:33:39 -08:00
msgbuf.h Linux-2.6.12-rc2 2005-04-16 15:20:36 -07:00
msi.h [PATCH] PCI: Change MSI to use physical delivery mode always 2005-11-10 16:09:18 -08:00
msr.h [PATCH] x86: more asm cleanups 2005-09-05 00:06:12 -07:00
mtrr.h Linux-2.6.12-rc2 2005-04-16 15:20:36 -07:00
mutex.h Fix mutex_trylock() copy-and-paste bug (x86, x86-64, generic mutex-dec.h) 2006-01-11 15:50:47 -08:00
namei.h Linux-2.6.12-rc2 2005-04-16 15:20:36 -07:00
nmi.h Linux-2.6.12-rc2 2005-04-16 15:20:36 -07:00
node.h Linux-2.6.12-rc2 2005-04-16 15:20:36 -07:00
numa.h [PATCH] x86-64: Use ACPI PXM to parse PCI<->node assignments 2005-09-12 10:49:57 -07:00
numaq.h Linux-2.6.12-rc2 2005-04-16 15:20:36 -07:00
numnodes.h Linux-2.6.12-rc2 2005-04-16 15:20:36 -07:00
page.h [PATCH] remove hugetlb_clean_stale_pgtable() and fix huge_pte_alloc() 2005-09-05 00:05:46 -07:00
param.h [PATCH] Avoid namespace pollution in <asm/param.h> 2006-01-02 08:38:38 -08:00
parport.h Linux-2.6.12-rc2 2005-04-16 15:20:36 -07:00
pci-direct.h Linux-2.6.12-rc2 2005-04-16 15:20:36 -07:00
pci.h Revert PCIBIOS_MIN_IO changes for 2.6.13 2005-08-14 18:21:30 -07:00
percpu.h Linux-2.6.12-rc2 2005-04-16 15:20:36 -07:00
pgalloc.h Linux-2.6.12-rc2 2005-04-16 15:20:36 -07:00
pgtable-2level-defs.h Linux-2.6.12-rc2 2005-04-16 15:20:36 -07:00
pgtable-2level.h [PATCH] i386: little pgtable.h consolidation vs 2/3level 2005-10-30 17:37:12 -08:00
pgtable-3level-defs.h Linux-2.6.12-rc2 2005-04-16 15:20:36 -07:00
pgtable-3level.h [PATCH] i386: little pgtable.h consolidation vs 2/3level 2005-10-30 17:37:12 -08:00
pgtable.h [PATCH] fix remaining missing includes 2005-11-07 07:53:41 -08:00
poll.h Linux-2.6.12-rc2 2005-04-16 15:20:36 -07:00
posix_types.h Linux-2.6.12-rc2 2005-04-16 15:20:36 -07:00
processor.h [PATCH] i386: Replace broken serialize_cpu in microcode driver with correct sync_core 2006-01-11 19:04:58 -08:00
ptrace.h [PATCH] PTRACE_SYSEMU is only for i386 and clashes with other ptrace codes of other archs 2006-01-08 20:14:04 -08:00
resource.h Linux-2.6.12-rc2 2005-04-16 15:20:36 -07:00
rtc.h Linux-2.6.12-rc2 2005-04-16 15:20:36 -07:00
rwlock.h Linux-2.6.12-rc2 2005-04-16 15:20:36 -07:00
rwsem.h [PATCH] add sem_is_read/write_locked() 2005-10-29 21:40:35 -07:00
scatterlist.h Linux-2.6.12-rc2 2005-04-16 15:20:36 -07:00
seccomp.h Linux-2.6.12-rc2 2005-04-16 15:20:36 -07:00
sections.h Linux-2.6.12-rc2 2005-04-16 15:20:36 -07:00
segment.h [PATCH] x86: Pnp segments in segment h 2006-01-06 08:33:34 -08:00
semaphore.h [PATCH] semaphore: Remove __MUTEX_INITIALIZER() 2005-10-30 17:37:27 -08:00
sembuf.h Linux-2.6.12-rc2 2005-04-16 15:20:36 -07:00
serial.h [PATCH] Serial: Split 8250 port table (part 2) 2005-06-29 18:45:19 +01:00
setup.h [PATCH] x86: fix EFI memory map parsing 2005-09-05 00:06:09 -07:00
shmbuf.h Linux-2.6.12-rc2 2005-04-16 15:20:36 -07:00
shmparam.h Linux-2.6.12-rc2 2005-04-16 15:20:36 -07:00
sigcontext.h Linux-2.6.12-rc2 2005-04-16 15:20:36 -07:00
siginfo.h Linux-2.6.12-rc2 2005-04-16 15:20:36 -07:00
signal.h x86: Fix silly typo in recent <asm/signal.h> fixes 2005-11-17 10:04:31 -08:00
smp.h [PATCH] PCI: Change MSI to use physical delivery mode always 2005-11-10 16:09:18 -08:00
socket.h [NET]: Introduce SO_{SND,RCV}BUFFORCE socket options 2005-08-29 15:31:35 -07:00
sockios.h Linux-2.6.12-rc2 2005-04-16 15:20:36 -07:00
sparsemem.h [PATCH] sparsemem memory model for i386 2005-06-23 09:45:05 -07:00
spinlock.h [PATCH] spinlock consolidation 2005-09-10 10:06:21 -07:00
spinlock_types.h [PATCH] spinlock consolidation 2005-09-10 10:06:21 -07:00
srat.h Linux-2.6.12-rc2 2005-04-16 15:20:36 -07:00
stat.h Linux-2.6.12-rc2 2005-04-16 15:20:36 -07:00
statfs.h Linux-2.6.12-rc2 2005-04-16 15:20:36 -07:00
string.h Add "memory" clobbers to the x86 inline asm of strncmp and friends 2005-06-24 10:39:17 -07:00
suspend.h [PATCH] i386: Use loaddebug macro consistently 2005-04-16 15:24:46 -07:00
system.h [PATCH] sched: add cacheflush() asm 2006-01-12 09:08:49 -08:00
termbits.h Linux-2.6.12-rc2 2005-04-16 15:20:36 -07:00
termios.h Linux-2.6.12-rc2 2005-04-16 15:20:36 -07:00
thread_info.h kbuild: full dependency check on asm-offsets.h 2005-09-09 19:28:28 +02:00
timer.h [PATCH] add suspend/resume for timer 2005-09-05 00:06:18 -07:00
timex.h [PATCH] x86: cpu_khz type fix 2005-06-23 09:45:11 -07:00
tlb.h Linux-2.6.12-rc2 2005-04-16 15:20:36 -07:00
tlbflush.h [PATCH] seccomp: tsc disable 2005-06-27 15:11:44 -07:00
topology.h [PATCH] scheduler cache-hot-autodetect 2006-01-12 09:08:50 -08:00
types.h [PATCH] sab: consolidate kmem_bufctl_t 2005-09-05 00:05:48 -07:00
uaccess.h [PATCH] remove verify_area(): remove verify_area() from various uaccess.h headers 2005-09-07 16:57:35 -07:00
ucontext.h Linux-2.6.12-rc2 2005-04-16 15:20:36 -07:00
unaligned.h Linux-2.6.12-rc2 2005-04-16 15:20:36 -07:00
unistd.h [PATCH] Swap Migration V5: sys_migrate_pages interface 2006-01-08 20:12:42 -08:00
user.h Linux-2.6.12-rc2 2005-04-16 15:20:36 -07:00
vga.h Linux-2.6.12-rc2 2005-04-16 15:20:36 -07:00
vic.h Linux-2.6.12-rc2 2005-04-16 15:20:36 -07:00
vm86.h [PATCH] Make vm86 support optional 2006-01-08 20:14:11 -08:00
voyager.h Linux-2.6.12-rc2 2005-04-16 15:20:36 -07:00
xor.h [PATCH] i386: inline asm cleanup 2005-09-05 00:06:11 -07:00