linux/include
Peter Zijlstra (Intel) 803e3757c4 perf: Avoid horrible stack usage
commit 86038c5ea8 upstream.

Both Linus (most recent) and Steve (a while ago) reported that perf
related callbacks have massive stack bloat.

The problem is that software events need a pt_regs in order to
properly report the event location and unwind stack. And because we
could not assume one was present we allocated one on stack and filled
it with minimal bits required for operation.

Now, pt_regs is quite large, so this is undesirable. Furthermore it
turns out that most sites actually have a pt_regs pointer available,
making this even more onerous, as the stack space is pointless waste.

This patch addresses the problem by observing that software events
have well defined nesting semantics, therefore we can use static
per-cpu storage instead of on-stack.

Linus made the further observation that all but the scheduler callers
of perf_sw_event() have a pt_regs available, so we change the regular
perf_sw_event() to require a valid pt_regs (where it used to be
optional) and add perf_sw_event_sched() for the scheduler.

We have a scheduler specific call instead of a more generic _noregs()
like construct because we can assume non-recursion from the scheduler
and thereby simplify the code further (_noregs would have to put the
recursion context call inline in order to assertain which __perf_regs
element to use).

One last note on the implementation of perf_trace_buf_prepare(); we
allow .regs = NULL for those cases where we already have a pt_regs
pointer available and do not need another.

Reported-by: Linus Torvalds <torvalds@linux-foundation.org>
Reported-by: Steven Rostedt <rostedt@goodmis.org>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Cc: Arnaldo Carvalho de Melo <acme@kernel.org>
Cc: Javi Merino <javi.merino@arm.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Cc: Oleg Nesterov <oleg@redhat.com>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Petr Mladek <pmladek@suse.cz>
Cc: Steven Rostedt <rostedt@goodmis.org>
Cc: Tom Zanussi <tom.zanussi@linux.intel.com>
Cc: Vaibhav Nagarnaik <vnagarnaik@google.com>
Link: http://lkml.kernel.org/r/20141216115041.GW3337@twins.programming.kicks-ass.net
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Cc: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
History 2017-04-30 05:49:15 +02:00
..
acpi ACPICA: Tables: Fix an issue that FACS initialization is performed twice 2015-08-04 14:33:56 -04:00
asm-generic asm-generic: make get_user() clear the destination on errors 2016-10-05 22:40:20 -04:00
clocksource ARM: pxa: Add non device-tree timer link to clocksource 2014-07-23 12:02:39 +02:00
crypto crypto: ahash - Fix EINPROGRESS notification callback 2017-04-22 07:15:01 +02:00
drm drm/ttm, drm/vmwgfx: Relax permission checking when opening surfaces 2017-04-22 07:14:59 +02:00
dt-bindings The fixes for the clock framework are all regressions in drivers, plus a 2014-11-25 17:52:56 -08:00
keys KEYS: Restore partial ID matching functionality for asymmetric keys 2014-10-06 15:21:05 +01:00
kvm arm/arm64: KVM: Keep elrsr/aisr in sync with software model 2015-05-11 07:07:37 -04:00
linux perf: Avoid horrible stack usage 2017-04-30 05:49:15 +02:00
math-emu math-emu: fix floating-point to integer overflow detection 2014-01-07 18:36:24 -06:00
media Merge branch 'patchwork' into v4l_for_linus 2014-10-09 14:00:54 -03:00
memory ddr: add LPDDR2 data from JESD209-2 2012-05-02 00:04:06 -07:00
misc cxl: Add new header for call backs and structs 2014-10-08 20:15:43 +11:00
net netlabel: out of bound access in cipso_v4_validate() 2017-04-18 07:55:44 +02:00
pcmcia pcmcia/ds.h: introduce helper for pcmcia_driver module boilerplate 2013-03-15 12:26:03 -07:00
ras PCI/AER: Rename PCI_ERR_UNC_TRAIN to PCI_ERR_UNC_UND 2014-09-25 09:42:40 -06:00
rdma IB/cma: Fix a race condition in iboe_addr_get_sgid() 2017-01-15 09:49:52 -05:00
rxrpc include/rxrpc/types.h: Remove unused header 2014-08-29 20:33:39 -07:00
scsi scsi: libiscsi: add lock around task lists to fix list corruption regression 2017-04-22 07:15:01 +02:00
soc/tegra ARM: tegra: Convert PMC to a driver 2014-07-17 14:58:43 +02:00
sound ALSA: pcm: More kerneldoc updates 2016-03-04 10:18:43 -05:00
target target: Fix remote-port TMR ABORT + se_cmd fabric stop 2016-03-05 22:13:44 -05:00
trace perf: Avoid horrible stack usage 2017-04-30 05:49:15 +02:00
uapi uapi: fix linux/packet_diag.h userspace compilation error 2017-04-18 07:55:54 +02:00
video fbdev changes for 3.18 2014-10-18 18:03:02 -07:00
xen x86/xen: Support kexec/kdump in HVM guests by doing a soft reset 2015-10-27 22:13:13 -04:00
Kbuild UAPI: remove empty Kbuild files 2013-04-30 17:04:09 -07:00