mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2024-11-17 01:04:19 +08:00
b4ecc12699
Xiaohui Xin and some other folks at Intel have been looking into what's
behind the performance hit of paravirt_ops when running native.
It appears that the hit is entirely due to the paravirtualized
spinlocks introduced by:
| commit 8efcbab674
| Date: Mon Jul 7 12:07:51 2008 -0700
|
| paravirt: introduce a "lock-byte" spinlock implementation
The extra call/return in the spinlock path is somehow
causing an increase in the cycles/instruction of somewhere around 2-7%
(seems to vary quite a lot from test to test). The working theory is
that the CPU's pipeline is getting upset about the
call->call->locked-op->return->return, and seems to be failing to
speculate (though I haven't seen anything definitive about the precise
reasons). This doesn't entirely make sense, because the performance
hit is also visible on unlock and other operations which don't involve
locked instructions. But spinlock operations clearly swamp all the
other pvops operations, even though I can't imagine that they're
nearly as common (there's only a .05% increase in instructions
executed).
If I disable just the pv-spinlock calls, my tests show that pvops is
identical to non-pvops performance on native (my measurements show that
it is actually about .1% faster, but Xiaohui shows a .05% slowdown).
Summary of results, averaging 10 runs of the "mmperf" test, using a
no-pvops build as baseline:
nopv Pv-nospin Pv-spin
CPU cycles 100.00% 99.89% 102.18%
instructions 100.00% 100.10% 100.15%
CPI 100.00% 99.79% 102.03%
cache ref 100.00% 100.84% 100.28%
cache miss 100.00% 90.47% 88.56%
cache miss rate 100.00% 89.72% 88.31%
branches 100.00% 99.93% 100.04%
branch miss 100.00% 103.66% 107.72%
branch miss rt 100.00% 103.73% 107.67%
wallclock 100.00% 99.90% 102.20%
The clear effect here is that the 2% increase in CPI is
directly reflected in the final wallclock time.
(The other interesting effect is that the more ops are
out of line calls via pvops, the lower the cache access
and miss rates. Not too surprising, but it suggests that
the non-pvops kernel is over-inlined. On the flipside,
the branch misses go up correspondingly...)
So, what's the fix?
Paravirt patching turns all the pvops calls into direct calls, so
_spin_lock etc do end up having direct calls. For example, the compiler
generated code for paravirtualized _spin_lock is:
<_spin_lock+0>: mov %gs:0xb4c8,%rax
<_spin_lock+9>: incl 0xffffffffffffe044(%rax)
<_spin_lock+15>: callq *0xffffffff805a5b30
<_spin_lock+22>: retq
The indirect call will get patched to:
<_spin_lock+0>: mov %gs:0xb4c8,%rax
<_spin_lock+9>: incl 0xffffffffffffe044(%rax)
<_spin_lock+15>: callq <__ticket_spin_lock>
<_spin_lock+20>: nop; nop /* or whatever 2-byte nop */
<_spin_lock+22>: retq
One possibility is to inline _spin_lock, etc, when building an
optimised kernel (ie, when there's no spinlock/preempt
instrumentation/debugging enabled). That will remove the outer
call/return pair, returning the instruction stream to a single
call/return, which will presumably execute the same as the non-pvops
case. The downsides arel 1) it will replicate the
preempt_disable/enable code at eack lock/unlock callsite; this code is
fairly small, but not nothing; and 2) the spinlock definitions are
already a very heavily tangled mass of #ifdefs and other preprocessor
magic, and making any changes will be non-trivial.
The other obvious answer is to disable pv-spinlocks. Making them a
separate config option is fairly easy, and it would be trivial to
enable them only when Xen is enabled (as the only non-default user).
But it doesn't really address the common case of a distro build which
is going to have Xen support enabled, and leaves the open question of
whether the native performance cost of pv-spinlocks is worth the
performance improvement on a loaded Xen system (10% saving of overall
system CPU when guests block rather than spin). Still it is a
reasonable short-term workaround.
[ Impact: fix pvops performance regression when running native ]
Analysed-by: "Xin Xiaohui" <xiaohui.xin@intel.com>
Analysed-by: "Li Xin" <xin.li@intel.com>
Analysed-by: "Nakajima Jun" <jun.nakajima@intel.com>
Signed-off-by: Jeremy Fitzhardinge <jeremy.fitzhardinge@citrix.com>
Acked-by: H. Peter Anvin <hpa@zytor.com>
Cc: Nick Piggin <npiggin@suse.de>
Cc: Xen-devel <xen-devel@lists.xensource.com>
LKML-Reference: <4A0B62F7.5030802@goop.org>
[ fixed the help text ]
Signed-off-by: Ingo Molnar <mingo@elte.hu>
126 lines
4.0 KiB
Makefile
126 lines
4.0 KiB
Makefile
#
|
|
# Makefile for the linux kernel.
|
|
#
|
|
|
|
extra-y := head_$(BITS).o head$(BITS).o head.o init_task.o vmlinux.lds
|
|
|
|
CPPFLAGS_vmlinux.lds += -U$(UTS_MACHINE)
|
|
|
|
ifdef CONFIG_FUNCTION_TRACER
|
|
# Do not profile debug and lowlevel utilities
|
|
CFLAGS_REMOVE_tsc.o = -pg
|
|
CFLAGS_REMOVE_rtc.o = -pg
|
|
CFLAGS_REMOVE_paravirt-spinlocks.o = -pg
|
|
CFLAGS_REMOVE_ftrace.o = -pg
|
|
CFLAGS_REMOVE_early_printk.o = -pg
|
|
endif
|
|
|
|
#
|
|
# vsyscalls (which work on the user stack) should have
|
|
# no stack-protector checks:
|
|
#
|
|
nostackp := $(call cc-option, -fno-stack-protector)
|
|
CFLAGS_vsyscall_64.o := $(PROFILING) -g0 $(nostackp)
|
|
CFLAGS_hpet.o := $(nostackp)
|
|
CFLAGS_tsc.o := $(nostackp)
|
|
CFLAGS_paravirt.o := $(nostackp)
|
|
|
|
obj-y := process_$(BITS).o signal.o entry_$(BITS).o
|
|
obj-y += traps.o irq.o irq_$(BITS).o dumpstack_$(BITS).o
|
|
obj-y += time_$(BITS).o ioport.o ldt.o dumpstack.o
|
|
obj-y += setup.o i8259.o irqinit_$(BITS).o
|
|
obj-$(CONFIG_X86_VISWS) += visws_quirks.o
|
|
obj-$(CONFIG_X86_32) += probe_roms_32.o
|
|
obj-$(CONFIG_X86_32) += sys_i386_32.o i386_ksyms_32.o
|
|
obj-$(CONFIG_X86_64) += sys_x86_64.o x8664_ksyms_64.o
|
|
obj-$(CONFIG_X86_64) += syscall_64.o vsyscall_64.o
|
|
obj-y += bootflag.o e820.o
|
|
obj-y += pci-dma.o quirks.o i8237.o topology.o kdebugfs.o
|
|
obj-y += alternative.o i8253.o pci-nommu.o
|
|
obj-y += tsc.o io_delay.o rtc.o
|
|
|
|
obj-$(CONFIG_X86_TRAMPOLINE) += trampoline.o
|
|
obj-y += process.o
|
|
obj-y += i387.o xsave.o
|
|
obj-y += ptrace.o
|
|
obj-$(CONFIG_X86_DS) += ds.o
|
|
obj-$(CONFIG_X86_32) += tls.o
|
|
obj-$(CONFIG_IA32_EMULATION) += tls.o
|
|
obj-y += step.o
|
|
obj-$(CONFIG_STACKTRACE) += stacktrace.o
|
|
obj-y += cpu/
|
|
obj-y += acpi/
|
|
obj-y += reboot.o
|
|
obj-$(CONFIG_MCA) += mca_32.o
|
|
obj-$(CONFIG_X86_MSR) += msr.o
|
|
obj-$(CONFIG_X86_CPUID) += cpuid.o
|
|
obj-$(CONFIG_PCI) += early-quirks.o
|
|
apm-y := apm_32.o
|
|
obj-$(CONFIG_APM) += apm.o
|
|
obj-$(CONFIG_SMP) += smp.o
|
|
obj-$(CONFIG_SMP) += smpboot.o tsc_sync.o
|
|
obj-$(CONFIG_SMP) += setup_percpu.o
|
|
obj-$(CONFIG_X86_64_SMP) += tsc_sync.o
|
|
obj-$(CONFIG_X86_TRAMPOLINE) += trampoline_$(BITS).o
|
|
obj-$(CONFIG_X86_MPPARSE) += mpparse.o
|
|
obj-y += apic/
|
|
obj-$(CONFIG_X86_REBOOTFIXUPS) += reboot_fixups_32.o
|
|
obj-$(CONFIG_DYNAMIC_FTRACE) += ftrace.o
|
|
obj-$(CONFIG_FUNCTION_GRAPH_TRACER) += ftrace.o
|
|
obj-$(CONFIG_FTRACE_SYSCALLS) += ftrace.o
|
|
obj-$(CONFIG_KEXEC) += machine_kexec_$(BITS).o
|
|
obj-$(CONFIG_KEXEC) += relocate_kernel_$(BITS).o crash.o
|
|
obj-$(CONFIG_CRASH_DUMP) += crash_dump_$(BITS).o
|
|
obj-$(CONFIG_KPROBES) += kprobes.o
|
|
obj-$(CONFIG_MODULES) += module_$(BITS).o
|
|
obj-$(CONFIG_EFI) += efi.o efi_$(BITS).o efi_stub_$(BITS).o
|
|
obj-$(CONFIG_DOUBLEFAULT) += doublefault_32.o
|
|
obj-$(CONFIG_KGDB) += kgdb.o
|
|
obj-$(CONFIG_VM86) += vm86_32.o
|
|
obj-$(CONFIG_EARLY_PRINTK) += early_printk.o
|
|
|
|
obj-$(CONFIG_HPET_TIMER) += hpet.o
|
|
|
|
obj-$(CONFIG_K8_NB) += k8.o
|
|
obj-$(CONFIG_MGEODE_LX) += geode_32.o mfgpt_32.o
|
|
obj-$(CONFIG_DEBUG_RODATA_TEST) += test_rodata.o
|
|
obj-$(CONFIG_DEBUG_NX_TEST) += test_nx.o
|
|
|
|
obj-$(CONFIG_VMI) += vmi_32.o vmiclock_32.o
|
|
obj-$(CONFIG_KVM_GUEST) += kvm.o
|
|
obj-$(CONFIG_KVM_CLOCK) += kvmclock.o
|
|
obj-$(CONFIG_PARAVIRT) += paravirt.o paravirt_patch_$(BITS).o
|
|
obj-$(CONFIG_PARAVIRT_SPINLOCKS)+= paravirt-spinlocks.o
|
|
obj-$(CONFIG_PARAVIRT_CLOCK) += pvclock.o
|
|
|
|
obj-$(CONFIG_PCSPKR_PLATFORM) += pcspeaker.o
|
|
|
|
obj-$(CONFIG_SCx200) += scx200.o
|
|
scx200-y += scx200_32.o
|
|
|
|
obj-$(CONFIG_OLPC) += olpc.o
|
|
|
|
microcode-y := microcode_core.o
|
|
microcode-$(CONFIG_MICROCODE_INTEL) += microcode_intel.o
|
|
microcode-$(CONFIG_MICROCODE_AMD) += microcode_amd.o
|
|
obj-$(CONFIG_MICROCODE) += microcode.o
|
|
|
|
obj-$(CONFIG_X86_CHECK_BIOS_CORRUPTION) += check.o
|
|
|
|
obj-$(CONFIG_SWIOTLB) += pci-swiotlb.o
|
|
|
|
###
|
|
# 64 bit specific files
|
|
ifeq ($(CONFIG_X86_64),y)
|
|
obj-$(CONFIG_X86_UV) += tlb_uv.o bios_uv.o uv_irq.o uv_sysfs.o uv_time.o
|
|
obj-$(CONFIG_X86_PM_TIMER) += pmtimer_64.o
|
|
obj-$(CONFIG_AUDIT) += audit_64.o
|
|
|
|
obj-$(CONFIG_GART_IOMMU) += pci-gart_64.o aperture_64.o
|
|
obj-$(CONFIG_CALGARY_IOMMU) += pci-calgary_64.o tce_64.o
|
|
obj-$(CONFIG_AMD_IOMMU) += amd_iommu_init.o amd_iommu.o
|
|
|
|
obj-$(CONFIG_PCI_MMCONFIG) += mmconf-fam10h_64.o
|
|
obj-y += vsmp_64.o
|
|
endif
|