linux-stable/arch/x86/kernel
Robert Richter bc1738f6ee perf, x86: Fix event scheduler for constraints with overlapping counters
The current x86 event scheduler fails to resolve scheduling problems
of certain combinations of events and constraints. This happens if the
counter mask of such an event is not a subset of any other counter
mask of a constraint with an equal or higher weight, e.g. constraints
of the AMD family 15h pmu:

                        counter mask    weight

 amd_f15_PMC30          0x09            2  <--- overlapping counters
 amd_f15_PMC20          0x07            3
 amd_f15_PMC53          0x38            3

The scheduler does not find then an existing solution. Here is an
example:

 event code     counter         failure         possible solution

 0x02E          PMC[3,0]        0               3
 0x043          PMC[2:0]        1               0
 0x045          PMC[2:0]        2               1
 0x046          PMC[2:0]        FAIL            2

The event scheduler may not select the correct counter in the first
cycle because it needs to know which subsequent events will be
scheduled. It may fail to schedule the events then.

To solve this, we now save the scheduler state of events with
overlapping counter counstraints.  If we fail to schedule the events
we rollback to those states and try to use another free counter.

Constraints with overlapping counters are marked with a new introduced
overlap flag. We set the overlap flag for such constraints to give the
scheduler a hint which events to select for counter rescheduling. The
EVENT_CONSTRAINT_OVERLAP() macro can be used for this.

Care must be taken as the rescheduling algorithm is O(n!) which will
increase scheduling cycles for an over-commited system dramatically.
The number of such EVENT_CONSTRAINT_OVERLAP() macros and its counter
masks must be kept at a minimum. Thus, the current stack is limited to
2 states to limit the number of loops the algorithm takes in the worst
case.

On systems with no overlapping-counter constraints, this
implementation does not increase the loop count compared to the
previous algorithm.

V2:
* Renamed redo -> overlap.
* Reimplementation using perf scheduling helper functions.

V3:
* Added WARN_ON_ONCE() if out of save states.
* Changed function interface of perf_sched_restore_state() to use bool
  as return value.

Signed-off-by: Robert Richter <robert.richter@amd.com>
Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Stephane Eranian <eranian@google.com>
Link: http://lkml.kernel.org/r/1321616122-1533-3-git-send-email-robert.richter@amd.com
Signed-off-by: Ingo Molnar <mingo@elte.hu>
2011-12-06 08:33:56 +01:00
..
acpi x86 idle: move mwait_idle_with_hints() to where it is used 2011-08-03 19:06:36 -04:00
apic Merge branch 'x86-uv-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip 2011-10-28 05:43:56 -07:00
cpu perf, x86: Fix event scheduler for constraints with overlapping counters 2011-12-06 08:33:56 +01:00
.gitignore
alternative.c x86-64: Move vread_tsc and vread_hpet into the vDSO 2011-07-14 17:57:05 -07:00
amd_gart_64.c doc: fix broken references 2011-09-27 18:08:04 +02:00
amd_nb.c x86, amd-nb: Rename CPU PCI id define for F4 2011-03-31 08:51:38 +02:00
apb_timer.c Merge branch 'timers-clocksource-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip 2011-07-23 10:34:47 -07:00
aperture_64.c x86, gart: Don't enforce GART aperture lower-bound by alignment 2011-04-18 10:31:38 -07:00
apm_32.c doc: fix broken references 2011-09-27 18:08:04 +02:00
asm-offsets.c x86, asm: Cleanup unnecssary macros in asm-offsets.c 2011-02-25 16:37:32 -08:00
asm-offsets_32.c lguest: use a special 1:1 linear pagetable mode until first switch. 2011-07-22 14:39:48 +09:30
asm-offsets_64.c x86: Partly unify asm-offsets_{32,64}.c 2011-02-10 13:31:37 +01:00
audit_64.c
bootflag.c
check.c x86: Don't check for BIOS corruption in first 64K when there's no need to 2011-03-09 16:36:41 +01:00
cpuid.c
crash.c x86, nmi: Wire up NMI handlers to new routines 2011-10-10 06:56:57 +02:00
crash_dump_32.c crash_dump: export is_kdump_kernel to modules, consolidate elfcorehdr_addr, setup_elfcorehdr and saved_max_pfn 2011-03-23 19:47:19 -07:00
crash_dump_64.c crash_dump: export is_kdump_kernel to modules, consolidate elfcorehdr_addr, setup_elfcorehdr and saved_max_pfn 2011-03-23 19:47:19 -07:00
devicetree.c x86: Fix files explicitly requiring export.h for EXPORT_SYMBOL/THIS_MODULE 2011-10-31 19:30:35 -04:00
doublefault_32.c
dumpstack.c Merge branch 'driver-core-next' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/driver-core-2.6 2011-05-19 18:24:11 -07:00
dumpstack_32.c x86, dumpstack: Correct stack dump info when frame pointer is available 2011-03-18 10:51:42 +01:00
dumpstack_64.c x86: Don't use frame pointer to save old stack on irq entry 2011-07-02 18:06:36 +02:00
e820.c x86: Fix files explicitly requiring export.h for EXPORT_SYMBOL/THIS_MODULE 2011-10-31 19:30:35 -04:00
early-quirks.c x86, quirk: Fix SB600 revision check 2011-03-16 14:03:32 +01:00
early_printk.c
entry_32.S x86-32: Fix boot with CONFIG_X86_INVD_BUG 2011-08-25 13:27:14 -07:00
entry_64.S x86-64: Fix CFI data for interrupt frames 2011-09-28 19:04:52 +02:00
ftrace.c x86/ftrace: Fix compiler warning in ftrace.c 2011-05-25 19:56:26 -04:00
head.c
head32.c Merge branch 'x86-platform-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip 2011-05-19 18:08:06 -07:00
head64.c x86: Cleanup highmap after brk is concluded 2011-03-19 11:58:19 -07:00
head_32.S Merge branch 'x86-platform-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip 2011-03-15 20:01:36 -07:00
head_64.S x86, trampoline: Common infrastructure for low memory trampolines 2011-02-17 21:02:43 -08:00
hpet.c x86: Fix files explicitly requiring export.h for EXPORT_SYMBOL/THIS_MODULE 2011-10-31 19:30:35 -04:00
hw_breakpoint.c x86: Use this_cpu_ops to optimize code 2010-12-30 12:20:28 +01:00
i386_ksyms_32.c
i387.c treewide: fix potentially dangerous trailing ';' in #defined values/expressions 2011-07-21 14:10:00 +02:00
i8237.c x86: Use syscore_ops instead of sysdev classes and sysdevs 2011-03-23 22:15:54 +01:00
i8253.c x86: Use common i8253 clockevent 2011-07-01 10:37:14 +02:00
i8259.c atomic: use <linux/atomic.h> 2011-07-26 16:49:47 -07:00
init_task.c
io_delay.c
ioport.c x86: Use bitmap library functions 2011-02-17 14:59:22 +01:00
irq.c x86: Fix files explicitly requiring export.h for EXPORT_SYMBOL/THIS_MODULE 2011-10-31 19:30:35 -04:00
irq_32.c x86: Fix common misspellings 2011-03-18 10:39:30 +01:00
irq_64.c
irq_work.c
irqinit.c atomic: use <linux/atomic.h> 2011-07-26 16:49:47 -07:00
jump_label.c x86/jump_label: add arch_jump_label_transform_static() 2011-10-25 11:54:42 -07:00
kdebugfs.c
kgdb.c x86, nmi: Wire up NMI handlers to new routines 2011-10-10 06:56:57 +02:00
kprobes.c Merge branch 'perf-core-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip 2011-10-26 17:03:38 +02:00
kvm.c KVM guest: KVM Steal time registration 2011-07-24 11:49:36 +03:00
kvmclock.c KVM guest: KVM Steal time registration 2011-07-24 11:49:36 +03:00
ldt.c
machine_kexec_32.c
machine_kexec_64.c
Makefile x86, nmi: Split out nmi from traps.c 2011-10-10 06:56:47 +02:00
mca_32.c x86: Fix common misspellings 2011-03-18 10:39:30 +01:00
microcode_amd.c x86, microcode, AMD: Add microcode revision to /proc/cpuinfo 2011-10-19 16:07:30 +02:00
microcode_core.c x86, microcode: Don't request microcode from userspace unnecessarily 2011-10-13 16:20:35 +02:00
microcode_intel.c x86, intel: Output microcode revision in /proc/cpuinfo 2011-10-14 13:16:35 +02:00
mmconf-fam10h_64.c
module.c modules: make arch's use default loader hooks 2011-07-24 22:06:04 +09:30
mpparse.c x86, ioapic: Consolidate mp_ioapics[] into 'struct ioapic' 2011-05-20 13:40:59 +02:00
msr.c
nmi.c x86: Fix files explicitly requiring export.h for EXPORT_SYMBOL/THIS_MODULE 2011-10-31 19:30:35 -04:00
paravirt-spinlocks.c
paravirt.c Merge branch 'x86-vdso-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-tip 2011-08-12 20:46:24 -07:00
paravirt_patch_32.c
paravirt_patch_64.c
pci-calgary_64.c treewide: Convert uses of struct resource to resource_size(ptr) 2011-06-10 14:55:36 +02:00
pci-dma.c x86: Fix files explicitly requiring export.h for EXPORT_SYMBOL/THIS_MODULE 2011-10-31 19:30:35 -04:00
pci-iommu_table.c arch/x86/kernel/pci-iommu_table.c: Convert sprintf_symbol to %pS 2011-05-10 10:21:35 +02:00
pci-nommu.c
pci-swiotlb.c
pcspeaker.c
probe_roms.c x86: Fix files explicitly requiring export.h for EXPORT_SYMBOL/THIS_MODULE 2011-10-31 19:30:35 -04:00
process.c x86, mm, trivial: Remove unnecessary get_order() in free_thread_info() 2011-08-23 21:49:35 +02:00
process_32.c Merge branch 'perf-core-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip 2011-10-26 17:03:38 +02:00
process_64.c x86, nmi: Add in logic to handle multiple events and unknown NMIs 2011-10-10 06:57:01 +02:00
ptrace.c perf: Add context field to perf_event 2011-07-01 11:06:38 +02:00
pvclock.c
quirks.c x86, quirks: Use pci_dev->revision 2011-07-21 10:26:00 +02:00
reboot.c x86, nmi: Wire up NMI handlers to new routines 2011-10-10 06:56:57 +02:00
reboot_32.S x86, reboot: Fix relocations in reboot_32.S 2011-05-02 14:44:46 -07:00
reboot_fixups_32.c
relocate_kernel_32.S kexec, x86: Fix incorrect jump back address if not preserving context 2011-07-21 11:19:28 +02:00
relocate_kernel_64.S kexec, x86: Fix incorrect jump back address if not preserving context 2011-07-21 11:19:28 +02:00
resource.c x86: avoid high BIOS area when allocating address space 2010-12-17 10:01:30 -08:00
rtc.c x86: Fix files explicitly requiring export.h for EXPORT_SYMBOL/THIS_MODULE 2011-10-31 19:30:35 -04:00
setup.c Merge branch 'linus' into x86/urgent 2011-05-26 13:51:35 +02:00
setup_percpu.c x86: Unify CPU -> NUMA node mapping between 32 and 64bit 2011-01-28 14:54:09 +01:00
signal.c x86: Kill handle_signal()->set_fs() 2011-07-14 21:46:20 -07:00
smp.c x86: Fix files explicitly requiring export.h for EXPORT_SYMBOL/THIS_MODULE 2011-10-31 19:30:35 -04:00
smpboot.c Merge branch 'x86-cleanups-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip 2011-07-22 17:02:38 -07:00
stacktrace.c x86: Swap save_stack_trace_regs parameters 2011-06-14 22:48:51 -04:00
step.c x86-64: Add user_64bit_mode paravirt op 2011-08-04 16:13:49 -07:00
sys_i386_32.c
sys_x86_64.c x86, amd: Include linux/elf.h since we use stuff from asm/elf.h 2011-09-28 10:34:31 +02:00
syscall_64.c
syscall_table_32.S Cross Memory Attach 2011-10-31 17:30:44 -07:00
tboot.c x86: Fix files explicitly requiring export.h for EXPORT_SYMBOL/THIS_MODULE 2011-10-31 19:30:35 -04:00
tce_64.c
test_nx.c x86: Eliminate various 'set but not used' warnings 2011-05-21 19:10:33 +02:00
test_rodata.c
time.c x86: Fix files explicitly requiring export.h for EXPORT_SYMBOL/THIS_MODULE 2011-10-31 19:30:35 -04:00
tls.c
tls.h
topology.c x86: Fix files explicitly requiring export.h for EXPORT_SYMBOL/THIS_MODULE 2011-10-31 19:30:35 -04:00
trampoline.c x86, trampoline: Common infrastructure for low memory trampolines 2011-02-17 21:02:43 -08:00
trampoline_32.S x86, trampoline: Common infrastructure for low memory trampolines 2011-02-17 21:02:43 -08:00
trampoline_64.S x86-64, trampoline: Remove unused variable 2011-02-18 15:50:36 -08:00
traps.c x86, nmi: Split out nmi from traps.c 2011-10-10 06:56:47 +02:00
tsc.c Merge branches 'x86-detect-hyper-for-linus', 'x86-fpu-for-linus', 'x86-kexec-for-linus', 'x86-platform-for-linus', 'x86-quirks-for-linus', 'x86-tsc-for-linus' and 'x86-smpboot-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip 2011-07-23 10:38:21 -07:00
tsc_sync.c
verify_cpu.S x86: Fix common misspellings 2011-03-18 10:39:30 +01:00
vm86_32.c thp: split_huge_page_mm/vma 2011-01-13 17:32:41 -08:00
vmlinux.lds.S x86-64: Rework vsyscall emulation and add vsyscall= parameter 2011-08-10 19:26:46 -05:00
vsmp_64.c
vsyscall_64.c x86: fix implicit include of <linux/topology.h> in vsyscall_64 2011-10-31 19:30:34 -04:00
vsyscall_emu_64.S x86-64: Rework vsyscall emulation and add vsyscall= parameter 2011-08-10 19:26:46 -05:00
vsyscall_trace.h x86-64: Add vsyscall:emulate_vsyscall trace event 2011-08-04 16:13:53 -07:00
x86_init.c Merge branch 'x86-platform-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip 2011-05-19 18:08:06 -07:00
x8664_ksyms_64.c x86-64, mem: Convert memmove() to assembly file and fix return value bug 2011-01-25 16:58:39 -08:00
xsave.c x86: Fix common misspellings 2011-03-18 10:39:30 +01:00