android_kernel_xiaomi_sm8350/include/asm-mips
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
..
arc
cobalt Resurrect Cobalt support for 2.6. 2005-10-29 19:30:42 +01:00
ddb5xxx
dec Use physical addresses at the interface level, letting drivers remap 2005-10-29 19:31:35 +01:00
galileo-boards
gcc
ip32 [MIPS] IP32: Fix sparse warnings. 2005-11-17 16:23:48 +00:00
it8172
jmr3927 Use new txx9 serial driver. 2005-10-29 19:30:52 +01:00
lasat
mach-atlas
mach-au1x00 MIPS: Au1550: Fix OHCI memory map size 2006-01-10 13:39:07 +00:00
mach-db1x00 [MIPS] Add missing arch defines for the Alchemy MTD driver. 2005-11-17 16:23:42 +00:00
mach-ddb5074
mach-dec Use physical addresses at the interface level, letting drivers remap 2005-10-29 19:31:35 +01:00
mach-ev64120
mach-ev96100
mach-generic Redefine outs[wl] for ide_outs[wl]. 2005-11-07 18:05:40 +00:00
mach-ip22 MIPS: Introduce machinery for testing for MIPSxxR1/2. 2006-01-10 13:39:06 +00:00
mach-ip27 [PATCH] scheduler cache-hot-autodetect 2006-01-12 09:08:50 -08:00
mach-ip32 MIPS: Introduce machinery for testing for MIPSxxR1/2. 2006-01-10 13:39:06 +00:00
mach-ja MIPS: Introduce machinery for testing for MIPSxxR1/2. 2006-01-10 13:39:06 +00:00
mach-jazz
mach-jmr3927 [MIPS] JMR3927: Fix include wrapper symbol. 2005-11-17 16:23:54 +00:00
mach-lasat
mach-mips Fixup a few lose ends in explicit support for MIPS R1/R2. 2005-10-29 19:32:37 +01:00
mach-ocelot
mach-ocelot3 MIPS: Introduce machinery for testing for MIPSxxR1/2. 2006-01-10 13:39:06 +00:00
mach-pb1x00 [MIPS] Add missing arch defines for the Alchemy MTD driver. 2005-11-17 16:23:42 +00:00
mach-pnx8550 Philips PNX8550 support: MIPS32-like core with 2 Trimedias on it. 2005-10-29 19:31:54 +01:00
mach-qemu [MIPS] Qemu: Qemu is emulating a 1193.182kHz i8254 PIC. 2005-12-01 11:05:15 +00:00
mach-rm200 MIPS: Introduce machinery for testing for MIPSxxR1/2. 2006-01-10 13:39:06 +00:00
mach-sibyte Support the MIPS32 / MIPS64 DSP ASE. 2005-10-29 19:31:17 +01:00
mach-sim Cleanup the mess in cpu_cache_init. 2005-10-29 19:32:32 +01:00
mach-yosemite MIPS: Introduce machinery for testing for MIPSxxR1/2. 2006-01-10 13:39:06 +00:00
mips-boards [MIPS] SEAD: More build fixes. 2005-11-17 16:23:57 +00:00
pci
sgi
sibyte Support for BigSur board. 2005-10-29 19:32:47 +01:00
sn Delete the SABLE_RTL case. 2005-10-29 19:32:19 +01:00
tx4927
tx4938 Support for Toshiba's RBHMA4500 eval board for the TX4938. 2005-10-29 19:31:57 +01:00
vr41xx Update Yoichi Yuasa's email address. 2006-01-10 13:39:07 +00:00
xtalk
8253pit.h
a.out.h
abi.h Support the MIPS32 / MIPS64 DSP ASE. 2005-10-29 19:31:17 +01:00
addrspace.h Add support for SB1A CPU. 2005-10-29 19:32:46 +01:00
asm.h Fix build with CONFIG_PRINTK disabled. 2005-10-29 19:31:18 +01:00
asmmacro-32.h
asmmacro-64.h
asmmacro.h
atomic.h MIPS: Get rid of atomic_lock. 2006-01-10 13:39:06 +00:00
auxvec.h
bcache.h
bitops.h [FLS64]: generic version 2006-01-03 13:11:06 -08:00
bootinfo.h Support for Toshiba's RBHMA4500 eval board for the TX4938. 2005-10-29 19:31:57 +01:00
branch.h
break.h Allocate break code 513 to KDB. 2005-10-29 19:30:34 +01:00
bug.h Fix weirdness in <asm/bug.h> 2005-10-29 19:32:38 +01:00
bugs.h Build fix for certain configurations. 2005-10-29 19:31:05 +01:00
byteorder.h
cache.h [PATCH] Kill L1_CACHE_SHIFT_MAX 2006-01-08 20:13:39 -08:00
cachectl.h
cacheflush.h Better interface to run uncached cache setup code. 2005-10-29 19:31:11 +01:00
cacheops.h
checksum.h The type of sum in csum_tcpudp_nofold is "unsigned int", so when we assign 2005-10-29 19:32:25 +01:00
compat.h 2.6.14-rc1 updates for MIPS compat types. 2005-10-29 19:32:40 +01:00
compiler.h
cpu-features.h MIPS: Reorganize ISA constants strictly as bitmasks. 2006-01-10 13:39:07 +00:00
cpu-info.h Cleanup decoding of MIPSxx config registers. 2005-10-29 19:31:12 +01:00
cpu.h MIPS: Reorganize ISA constants strictly as bitmasks. 2006-01-10 13:39:07 +00:00
cputime.h
current.h
ddb5074.h
debug.h
delay.h MIPS: Fix mdelay(1) for 64bit kernel with HZ == 1000 2006-01-10 13:39:04 +00:00
div64.h
dma-mapping.h
dma.h
ds1286.h
dsp.h MIPS: DSP: Set all register masks to 0x3ff. 2006-01-10 13:39:04 +00:00
elf.h MIPS: Namespace pollution: dump_regs() -> elf_dump_regs() 2006-01-10 13:39:08 +00:00
emergency-restart.h
errno.h Delete duplicate definitions. 2005-11-07 18:05:40 +00:00
fcntl.h Complete the fcntl.h cleanup. 2005-10-29 19:32:40 +01:00
fixmap.h Delete duplicate copy of fixrange_init. 2005-10-29 19:30:28 +01:00
floppy.h
fpregdef.h
fpu_emulator.h Now that a struct is the only member left in struct 2005-10-29 19:31:14 +01:00
fpu.h __compute_return_epc() uses CFC1 instruction which might result in a 2005-10-29 19:31:13 +01:00
futex.h Futexes for MIPS, for the time being only the R10000_LLSC_WAR version. 2005-10-29 19:32:21 +01:00
gdb-stub.h
gfx.h
gt64120.h
gt64240.h
hardirq.h
hazards.h MIPS: R2: Try to bulletproof instruction_hazard against miss-compilation. 2006-01-10 13:39:08 +00:00
highmem.h Define kmap_atomic_pfn() for MIPS. 2005-10-29 19:31:42 +01:00
hw_irq.h
i8259.h
ide.h
inst.h Support the MIPS32 / MIPS64 DSP ASE. 2005-10-29 19:31:17 +01:00
interrupt.h MIPS: R2: Fix local_irq_save() 2006-01-10 13:39:08 +00:00
inventory.h Reformatting, remove debugging code. 2005-10-29 19:30:57 +01:00
io.h [MIPS] Add const qualifier to writes##bwlq. 2005-11-17 16:23:49 +00:00
ioctl.h
ioctls.h
ipc.h
ipcbuf.h
irq_cpu.h
irq.h Sparseify MIPS. 2005-10-29 19:30:50 +01:00
isadep.h
it8712.h
jazz.h
jazzdma.h
kmap_types.h
linkage.h
local.h
m48t35.h
m48t37.h
marvell.h
mc146818-time.h Use rtc_lock to protect RTC operations 2005-11-07 18:05:38 +00:00
mc146818rtc.h
mipsmtregs.h Virtual SMP support for the 34K. 2005-10-29 19:32:10 +01:00
mipsprom.h
mipsregs.h MIPS: DSP: Put mask field into the right place. 2006-01-10 13:39:05 +00:00
mman.h [PATCH] madvise(MADV_REMOVE): remove pages from tmpfs shm backing store 2006-01-06 08:33:22 -08:00
mmu_context.h Fix 64bit SMP TLB handler and stack frame handling, optimize 32bit SMP 2005-10-29 19:31:00 +01:00
mmu.h
mmzone.h More configcheck fixes. 2005-10-29 19:32:40 +01:00
module.h Add spaces to MODULE_PROC_FAMILY values. 2005-11-07 18:05:34 +00:00
msc01_ic.h
msgbuf.h
mutex.h [PATCH] mutex subsystem, add default include/asm-*/mutex.h files 2006-01-09 15:59:19 -08:00
namei.h
nile4.h
numnodes.h
paccess.h Gcc 4.0 fixes. 2005-10-29 19:30:53 +01:00
page.h Fixup a few lose ends in explicit support for MIPS R1/R2. 2005-10-29 19:32:37 +01:00
param.h
parport.h
pci.h BCM1480 HT support 2005-10-29 19:32:49 +01:00
percpu.h
pgalloc.h Update MIPS to use the 4-level pagetable code thereby getting rid of 2005-10-29 19:30:31 +01:00
pgtable-32.h On CONFIG_64BIT_PHYS_ADDR, pfn always fits in 'unsigned long', but 2005-10-29 19:32:09 +01:00
pgtable-64.h [PATCH] vm: remove unused/broken page_pte[_prot] macros 2005-10-30 17:37:22 -08:00
pgtable-bits.h Rename CONFIG_CPU_MIPS{32,64} to CONFIG_CPU_MIPS{32|64}_R1. 2005-10-29 19:31:37 +01:00
pgtable.h [PATCH] fix remaining missing includes 2005-11-07 07:53:41 -08:00
pmon.h
poll.h
posix_types.h
prctl.h
prefetch.h
processor.h MIPS: DSP: eleminate used_dsp. 2006-01-10 13:39:04 +00:00
ptrace.h Revise MIPS 64-bit ptrace interface 2005-10-29 19:32:29 +01:00
qemu.h
r4kcache.h More .set push/pop encapsulation, more eyefriendly code formatting. 2005-10-29 19:32:14 +01:00
reboot.h
reg.h
regdef.h
resource.h
rtc.h Remove mips_rtc_lock 2005-11-07 18:05:38 +00:00
rtlx.h Turn rtlx upside down. 2005-11-07 18:05:33 +00:00
scatterlist.h
sections.h
segment.h
semaphore.h [PATCH] semaphore: Remove __MUTEX_INITIALIZER() 2005-10-30 17:37:27 -08:00
sembuf.h
serial.h Use new txx9 serial driver. 2005-10-29 19:30:52 +01:00
setup.h
sgialib.h
sgiarcs.h
sgidefs.h
shmbuf.h
shmparam.h
sigcontext.h Support the MIPS32 / MIPS64 DSP ASE. 2005-10-29 19:31:17 +01:00
siginfo.h On MIPS the struct sigev preamble is only 8 bytes. 2005-10-29 19:31:15 +01:00
signal.h [MIPS] Delete duplicate definitions of break codes. 2005-11-17 16:23:38 +00:00
sim.h
smp.h
sni.h
socket.h Add SOCK_DCCP definition for MIPS also. 2005-10-29 19:32:26 +01:00
sockios.h
spinlock_types.h
spinlock.h More configcheck fixes. 2005-10-29 19:32:40 +01:00
stackframe.h Fix get_saved_sp for 64bit address space. Simplify set_save_sp. 2005-10-29 19:31:39 +01:00
stat.h
statfs.h
string.h
suspend.h
sysmips.h
system.h [PATCH] sched: add cacheflush() asm 2006-01-12 09:08:49 -08:00
termbits.h
termios.h
thread_info.h NPTL, round one. 2005-10-29 19:31:06 +01:00
time.h Use rtc_lock to protect RTC operations 2005-11-07 18:05:38 +00:00
timex.h
titan_dep.h
tlb.h
tlbdebug.h
tlbflush.h
topology.h
traps.h More AP / SP bits for the 34K, the Malta bits and things. Still wants 2005-10-29 19:31:53 +01:00
tx3912.h
types.h
uaccess.h Drop might_sleep() calls from get_user() & co. This should fix the issue 2005-10-29 19:32:10 +01:00
ucontext.h
unaligned.h
unistd.h [PATCH] unify sys_ptrace prototype 2005-10-30 17:37:20 -08:00
user.h
vga.h Fix endianess bugs. 2005-10-29 19:31:41 +01:00
war.h Redo RM9000 workaround which along with other DSP ASE changes was 2005-10-29 19:31:23 +01:00
watch.h
wbflush.h
xor.h
xxs1500.h