aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Documentation/ABI/testing/sysfs-bus-event_source-devices-format14
-rw-r--r--Documentation/RCU/RTFP.txt1784
-rw-r--r--Documentation/RCU/checklist.txt14
-rw-r--r--Documentation/RCU/stallwarn.txt87
-rw-r--r--Documentation/RCU/torture.txt33
-rw-r--r--Documentation/RCU/trace.txt36
-rw-r--r--Documentation/hwmon/w83627ehf9
-rw-r--r--Documentation/hwmon/zl610014
-rw-r--r--Documentation/lockup-watchdogs.txt63
-rw-r--r--Documentation/nmi_watchdog.txt83
-rw-r--r--Documentation/scheduler/sched-stats.txt3
-rw-r--r--Documentation/static-keys.txt286
-rw-r--r--Documentation/trace/ftrace.txt7
-rw-r--r--MAINTAINERS40
-rw-r--r--Makefile2
-rw-r--r--arch/Kconfig29
-rw-r--r--arch/alpha/kernel/perf_event.c4
-rw-r--r--arch/arm/include/asm/perf_event.h4
-rw-r--r--arch/arm/kernel/perf_event.c4
-rw-r--r--arch/arm/kernel/process.c4
-rw-r--r--arch/arm/kernel/smp.c7
-rw-r--r--arch/avr32/kernel/process.c4
-rw-r--r--arch/blackfin/kernel/process.c4
-rw-r--r--arch/c6x/kernel/entry.S27
-rw-r--r--arch/cris/kernel/process.c4
-rw-r--r--arch/frv/include/asm/perf_event.h2
-rw-r--r--arch/frv/kernel/process.c4
-rw-r--r--arch/h8300/kernel/process.c4
-rw-r--r--arch/hexagon/include/asm/perf_event.h2
-rw-r--r--arch/hexagon/kernel/smp.c2
-rw-r--r--arch/ia64/include/asm/paravirt.h6
-rw-r--r--arch/ia64/kernel/paravirt.c4
-rw-r--r--arch/ia64/kernel/process.c4
-rw-r--r--arch/m32r/kernel/process.c4
-rw-r--r--arch/m68k/kernel/process_mm.c4
-rw-r--r--arch/m68k/kernel/process_no.c4
-rw-r--r--arch/microblaze/kernel/process.c4
-rw-r--r--arch/mips/include/asm/jump_label.h2
-rw-r--r--arch/mips/kernel/perf_event_mipsxx.c4
-rw-r--r--arch/mips/kernel/process.c4
-rw-r--r--arch/mn10300/kernel/process.c4
-rw-r--r--arch/parisc/kernel/process.c4
-rw-r--r--arch/powerpc/include/asm/jump_label.h2
-rw-r--r--arch/powerpc/include/asm/perf_event_server.h2
-rw-r--r--arch/powerpc/kernel/idle.c8
-rw-r--r--arch/powerpc/kernel/perf_event.c10
-rw-r--r--arch/powerpc/platforms/iseries/setup.c8
-rw-r--r--arch/s390/include/asm/jump_label.h2
-rw-r--r--arch/s390/include/asm/perf_event.h1
-rw-r--r--arch/s390/kernel/irq.c9
-rw-r--r--arch/s390/kernel/process.c4
-rw-r--r--arch/s390/kernel/smp.c6
-rw-r--r--arch/score/kernel/process.c4
-rw-r--r--arch/sh/kernel/idle.c4
-rw-r--r--arch/sh/kernel/perf_event.c4
-rw-r--r--arch/sparc/include/asm/jump_label.h2
-rw-r--r--arch/sparc/kernel/perf_event.c4
-rw-r--r--arch/sparc/kernel/process_32.c8
-rw-r--r--arch/sparc/kernel/process_64.c10
-rw-r--r--arch/tile/configs/tilegx_defconfig1438
-rw-r--r--arch/tile/configs/tilepro_defconfig1317
-rw-r--r--arch/tile/kernel/process.c4
-rw-r--r--arch/x86/Kconfig1
-rw-r--r--arch/x86/include/asm/hardirq.h1
-rw-r--r--arch/x86/include/asm/inat.h5
-rw-r--r--arch/x86/include/asm/insn.h18
-rw-r--r--arch/x86/include/asm/jump_label.h6
-rw-r--r--arch/x86/include/asm/msr-index.h7
-rw-r--r--arch/x86/include/asm/paravirt.h6
-rw-r--r--arch/x86/include/asm/perf_event.h2
-rw-r--r--arch/x86/include/asm/timer.h8
-rw-r--r--arch/x86/kernel/Makefile1
-rw-r--r--arch/x86/kernel/cpu/amd.c3
-rw-r--r--arch/x86/kernel/cpu/perf_event.c182
-rw-r--r--arch/x86/kernel/cpu/perf_event.h51
-rw-r--r--arch/x86/kernel/cpu/perf_event_amd.c21
-rw-r--r--arch/x86/kernel/cpu/perf_event_intel.c177
-rw-r--r--arch/x86/kernel/cpu/perf_event_intel_ds.c22
-rw-r--r--arch/x86/kernel/cpu/perf_event_intel_lbr.c526
-rw-r--r--arch/x86/kernel/cpu/perf_event_p6.c19
-rw-r--r--arch/x86/kernel/irq_32.c11
-rw-r--r--arch/x86/kernel/kprobes-common.h102
-rw-r--r--arch/x86/kernel/kprobes-opt.c512
-rw-r--r--arch/x86/kernel/kprobes.c664
-rw-r--r--arch/x86/kernel/kvm.c4
-rw-r--r--arch/x86/kernel/paravirt.c4
-rw-r--r--arch/x86/kernel/process.c24
-rw-r--r--arch/x86/kernel/process_32.c4
-rw-r--r--arch/x86/kernel/process_64.c4
-rw-r--r--arch/x86/kernel/smpboot.c13
-rw-r--r--arch/x86/kernel/time.c3
-rw-r--r--arch/x86/kernel/tsc.c3
-rw-r--r--arch/x86/kernel/tsc_sync.c29
-rw-r--r--arch/x86/kvm/mmu_audit.c8
-rw-r--r--arch/x86/lib/inat.c36
-rw-r--r--arch/x86/lib/insn.c13
-rw-r--r--arch/xtensa/kernel/process.c4
-rw-r--r--block/blk-ioc.c135
-rw-r--r--block/blk-softirq.c16
-rw-r--r--block/blk.h16
-rw-r--r--block/cfq-iosched.c12
-rw-r--r--block/genhd.c42
-rw-r--r--block/partition-generic.c48
-rw-r--r--drivers/block/DAC960.c18
-rw-r--r--drivers/block/sx8.c2
-rw-r--r--drivers/clocksource/acpi_pm.c24
-rw-r--r--drivers/clocksource/clksrc-dbx500-prcmu.c5
-rw-r--r--drivers/clocksource/cs5535-clockevt.c3
-rw-r--r--drivers/clocksource/cyclone.c2
-rw-r--r--drivers/clocksource/scx200_hrt.c24
-rw-r--r--drivers/cpuidle/cpuidle.c8
-rw-r--r--drivers/gpu/drm/exynos/exynos_drm_connector.c16
-rw-r--r--drivers/gpu/drm/exynos/exynos_drm_drv.c2
-rw-r--r--drivers/gpu/drm/exynos/exynos_drm_fbdev.c28
-rw-r--r--drivers/gpu/drm/exynos/exynos_drm_fimd.c17
-rw-r--r--drivers/gpu/drm/i915/i915_reg.h2
-rw-r--r--drivers/gpu/drm/i915/intel_display.c1
-rw-r--r--drivers/gpu/drm/i915/intel_sprite.c6
-rw-r--r--drivers/hwmon/pmbus/zl6100.c12
-rw-r--r--drivers/hwmon/w83627ehf.c17
-rw-r--r--drivers/i2c/algos/i2c-algo-bit.c8
-rw-r--r--drivers/i2c/i2c-core.c12
-rw-r--r--drivers/iommu/intel-iommu.c59
-rw-r--r--drivers/media/dvb/siano/smsdvb.c127
-rw-r--r--drivers/media/video/davinci/isif.c1
-rw-r--r--drivers/media/video/uvc/uvc_video.c14
-rw-r--r--drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c51
-rw-r--r--drivers/net/hyperv/netvsc_drv.c4
-rw-r--r--drivers/net/usb/usbnet.c4
-rw-r--r--drivers/net/wimax/i2400m/netdev.c30
-rw-r--r--drivers/rapidio/devices/tsi721.h30
-rw-r--r--drivers/regulator/da9052-regulator.c12
-rw-r--r--drivers/regulator/tps6524x-regulator.c2
-rw-r--r--drivers/rtc/interface.c30
-rw-r--r--drivers/target/iscsi/iscsi_target.c2
-rw-r--r--drivers/target/target_core_pr.c34
-rw-r--r--drivers/target/target_core_transport.c1
-rw-r--r--drivers/target/tcm_fc/tfc_sess.c12
-rw-r--r--drivers/video/backlight/s6e63m0.c2
-rw-r--r--fs/Kconfig4
-rw-r--r--fs/afs/file.c2
-rw-r--r--fs/afs/internal.h2
-rw-r--r--fs/afs/rxrpc.c3
-rw-r--r--fs/block_dev.c16
-rw-r--r--fs/dcache.c29
-rw-r--r--fs/eventpoll.c4
-rw-r--r--fs/exec.c9
-rw-r--r--fs/namei.c122
-rw-r--r--fs/nilfs2/the_nilfs.c7
-rw-r--r--fs/proc/base.c3
-rw-r--r--include/linux/clocksource.h7
-rw-r--r--include/linux/ftrace.h77
-rw-r--r--include/linux/ftrace_event.h11
-rw-r--r--include/linux/genhd.h1
-rw-r--r--include/linux/init_task.h2
-rw-r--r--include/linux/interrupt.h7
-rw-r--r--include/linux/iocontext.h10
-rw-r--r--include/linux/jump_label.h162
-rw-r--r--include/linux/kernel.h28
-rw-r--r--include/linux/math64.h4
-rw-r--r--include/linux/netdevice.h4
-rw-r--r--include/linux/netfilter.h6
-rw-r--r--include/linux/perf_event.h201
-rw-r--r--include/linux/preempt.h5
-rw-r--r--include/linux/printk.h10
-rw-r--r--include/linux/rcupdate.h83
-rw-r--r--include/linux/rcutiny.h10
-rw-r--r--include/linux/rcutree.h19
-rw-r--r--include/linux/ring_buffer.h3
-rw-r--r--include/linux/sched.h54
-rw-r--r--include/linux/srcu.h15
-rw-r--r--include/linux/static_key.h1
-rw-r--r--include/linux/timex.h17
-rw-r--r--include/linux/tracepoint.h28
-rw-r--r--include/linux/wait.h5
-rw-r--r--include/linux/workqueue.h4
-rw-r--r--include/net/sock.h6
-rw-r--r--include/trace/events/power.h2
-rw-r--r--include/trace/events/printk.h41
-rw-r--r--include/trace/events/rcu.h63
-rw-r--r--include/trace/events/sched.h27
-rw-r--r--include/trace/events/signal.h85
-rw-r--r--init/Kconfig9
-rw-r--r--init/main.c5
-rw-r--r--kernel/events/core.c246
-rw-r--r--kernel/events/hw_breakpoint.c13
-rw-r--r--kernel/exit.c4
-rw-r--r--kernel/futex.c51
-rw-r--r--kernel/irq/chip.c5
-rw-r--r--kernel/irq/handle.c14
-rw-r--r--kernel/irq/internals.h2
-rw-r--r--kernel/irq/manage.c86
-rw-r--r--kernel/jump_label.c135
-rw-r--r--kernel/lockdep.c8
-rw-r--r--kernel/mutex.c4
-rw-r--r--kernel/printk.c45
-rw-r--r--kernel/rcu.h26
-rw-r--r--kernel/rcupdate.c5
-rw-r--r--kernel/rcutiny.c26
-rw-r--r--kernel/rcutiny_plugin.h77
-rw-r--r--kernel/rcutorture.c91
-rw-r--r--kernel/rcutree.c507
-rw-r--r--kernel/rcutree.h27
-rw-r--r--kernel/rcutree_plugin.h450
-rw-r--r--kernel/rcutree_trace.c12
-rw-r--r--kernel/sched/auto_group.c12
-rw-r--r--kernel/sched/core.c147
-rw-r--r--kernel/sched/debug.c1
-rw-r--r--kernel/sched/fair.c400
-rw-r--r--kernel/sched/rt.c43
-rw-r--r--kernel/sched/sched.h29
-rw-r--r--kernel/sched/stats.c4
-rw-r--r--kernel/signal.c28
-rw-r--r--kernel/softirq.c34
-rw-r--r--kernel/srcu.c33
-rw-r--r--kernel/sys.c2
-rw-r--r--kernel/time/ntp.c85
-rw-r--r--kernel/time/tick-broadcast.c4
-rw-r--r--kernel/time/tick-sched.c17
-rw-r--r--kernel/time/timekeeping.c338
-rw-r--r--kernel/trace/Kconfig2
-rw-r--r--kernel/trace/ftrace.c137
-rw-r--r--kernel/trace/ring_buffer.c157
-rw-r--r--kernel/trace/trace.c115
-rw-r--r--kernel/trace/trace.h37
-rw-r--r--kernel/trace/trace_entries.h54
-rw-r--r--kernel/trace/trace_event_perf.c208
-rw-r--r--kernel/trace/trace_events.c12
-rw-r--r--kernel/trace/trace_events_filter.c175
-rw-r--r--kernel/trace/trace_export.c64
-rw-r--r--kernel/trace/trace_kprobe.c8
-rw-r--r--kernel/trace/trace_output.c12
-rw-r--r--kernel/trace/trace_syscalls.c22
-rw-r--r--kernel/tracepoint.c20
-rw-r--r--kernel/watchdog.c24
-rw-r--r--kernel/workqueue.c7
-rw-r--r--lib/Kconfig.debug42
-rw-r--r--mm/memcontrol.c53
-rw-r--r--net/core/dev.c24
-rw-r--r--net/core/net-sysfs.c4
-rw-r--r--net/core/sock.c4
-rw-r--r--net/core/sysctl_net_core.c4
-rw-r--r--net/ipv4/cipso_ipv4.c11
-rw-r--r--net/ipv4/ip_sockglue.c7
-rw-r--r--net/ipv4/tcp_memcontrol.c6
-rw-r--r--net/ipv6/mcast.c1
-rw-r--r--net/ipv6/route.c2
-rw-r--r--net/mac80211/mesh_pathtbl.c8
-rw-r--r--net/netfilter/core.c6
-rw-r--r--net/netfilter/nf_conntrack_netlink.c23
-rw-r--r--net/sched/sch_sfq.c6
-rw-r--r--tools/perf/Documentation/Makefile86
-rw-r--r--tools/perf/Documentation/perf-lock.txt20
-rw-r--r--tools/perf/Documentation/perf-record.txt38
-rw-r--r--tools/perf/Documentation/perf-report.txt15
-rw-r--r--tools/perf/Documentation/perf-script.txt5
-rw-r--r--tools/perf/Documentation/perf-stat.txt4
-rw-r--r--tools/perf/Documentation/perf-top.txt8
-rw-r--r--tools/perf/MANIFEST1
-rw-r--r--tools/perf/Makefile75
-rw-r--r--tools/perf/bench/bench.h1
-rw-r--r--tools/perf/bench/mem-memcpy-x86-64-asm-def.h8
-rw-r--r--tools/perf/bench/mem-memcpy-x86-64-asm.S6
-rw-r--r--tools/perf/bench/mem-memcpy.c12
-rw-r--r--tools/perf/bench/mem-memset-arch.h12
-rw-r--r--tools/perf/bench/mem-memset-x86-64-asm-def.h12
-rw-r--r--tools/perf/bench/mem-memset-x86-64-asm.S13
-rw-r--r--tools/perf/bench/mem-memset.c297
-rw-r--r--tools/perf/builtin-bench.c3
-rw-r--r--tools/perf/builtin-diff.c60
-rw-r--r--tools/perf/builtin-lock.c4
-rw-r--r--tools/perf/builtin-probe.c12
-rw-r--r--tools/perf/builtin-record.c152
-rw-r--r--tools/perf/builtin-report.c218
-rw-r--r--tools/perf/builtin-script.c80
-rw-r--r--tools/perf/builtin-stat.c41
-rw-r--r--tools/perf/builtin-test.c362
-rw-r--r--tools/perf/builtin-top.c45
-rw-r--r--tools/perf/config/feature-tests.mak15
-rw-r--r--tools/perf/perf.h26
-rwxr-xr-xtools/perf/python/twatch.py2
-rw-r--r--tools/perf/util/annotate.c2
-rw-r--r--tools/perf/util/bitmap.c10
-rw-r--r--tools/perf/util/cache.h12
-rw-r--r--tools/perf/util/cpumap.c11
-rw-r--r--tools/perf/util/cpumap.h4
-rw-r--r--tools/perf/util/ctype.c2
-rw-r--r--tools/perf/util/debugfs.c141
-rw-r--r--tools/perf/util/debugfs.h6
-rw-r--r--tools/perf/util/event.h1
-rw-r--r--tools/perf/util/evlist.c23
-rw-r--r--tools/perf/util/evlist.h9
-rw-r--r--tools/perf/util/evsel.c28
-rw-r--r--tools/perf/util/evsel.h5
-rw-r--r--tools/perf/util/gtk/browser.c189
-rw-r--r--tools/perf/util/gtk/gtk.h8
-rw-r--r--tools/perf/util/header.c586
-rw-r--r--tools/perf/util/header.h3
-rw-r--r--tools/perf/util/hist.c165
-rw-r--r--tools/perf/util/hist.h32
-rw-r--r--tools/perf/util/include/asm/dwarf2.h4
-rw-r--r--tools/perf/util/include/linux/bitmap.h11
-rw-r--r--tools/perf/util/map.c15
-rw-r--r--tools/perf/util/map.h1
-rw-r--r--tools/perf/util/parse-events-bison.c1917
-rw-r--r--tools/perf/util/parse-events-bison.h81
-rw-r--r--tools/perf/util/parse-events-flex.c2272
-rw-r--r--tools/perf/util/parse-events-flex.h316
-rw-r--r--tools/perf/util/parse-events.c603
-rw-r--r--tools/perf/util/parse-events.h49
-rw-r--r--tools/perf/util/parse-events.l126
-rw-r--r--tools/perf/util/parse-events.y229
-rw-r--r--tools/perf/util/pmu-bison.c1663
-rw-r--r--tools/perf/util/pmu-bison.h73
-rw-r--r--tools/perf/util/pmu-flex.c1821
-rw-r--r--tools/perf/util/pmu-flex.h316
-rw-r--r--tools/perf/util/pmu.c469
-rw-r--r--tools/perf/util/pmu.h41
-rw-r--r--tools/perf/util/pmu.l43
-rw-r--r--tools/perf/util/pmu.y93
-rw-r--r--tools/perf/util/probe-event.c33
-rw-r--r--tools/perf/util/probe-finder.c1
-rw-r--r--tools/perf/util/python-ext-sources19
-rw-r--r--tools/perf/util/python.c10
-rw-r--r--tools/perf/util/scripting-engines/trace-event-python.c1
-rw-r--r--tools/perf/util/session.c127
-rw-r--r--tools/perf/util/session.h6
-rw-r--r--tools/perf/util/setup.py8
-rw-r--r--tools/perf/util/sort.c287
-rw-r--r--tools/perf/util/sort.h11
-rw-r--r--tools/perf/util/symbol.c24
-rw-r--r--tools/perf/util/symbol.h24
-rw-r--r--tools/perf/util/sysfs.c60
-rw-r--r--tools/perf/util/sysfs.h6
-rw-r--r--tools/perf/util/thread_map.c237
-rw-r--r--tools/perf/util/thread_map.h11
-rw-r--r--tools/perf/util/top.c13
-rw-r--r--tools/perf/util/top.h6
-rw-r--r--tools/perf/util/trace-event-parse.c23
-rw-r--r--tools/perf/util/trace-event-read.c1
-rw-r--r--tools/perf/util/trace-event-scripting.c1
-rw-r--r--tools/perf/util/ui/browser.h2
-rw-r--r--tools/perf/util/ui/browsers/annotate.c18
-rw-r--r--tools/perf/util/ui/browsers/hists.c119
-rw-r--r--tools/perf/util/ui/browsers/map.c2
-rw-r--r--tools/perf/util/ui/keysyms.h2
-rw-r--r--tools/perf/util/ui/util.c82
-rw-r--r--tools/perf/util/usage.c39
-rw-r--r--tools/perf/util/util.c2
-rw-r--r--tools/perf/util/util.h6
350 files changed, 21533 insertions, 7000 deletions
diff --git a/Documentation/ABI/testing/sysfs-bus-event_source-devices-format b/Documentation/ABI/testing/sysfs-bus-event_source-devices-format
new file mode 100644
index 000000000000..079afc71363d
--- /dev/null
+++ b/Documentation/ABI/testing/sysfs-bus-event_source-devices-format
@@ -0,0 +1,14 @@
1Where: /sys/bus/event_source/devices/<dev>/format
2Date: January 2012
3Kernel Version: 3.3
4Contact: Jiri Olsa <jolsa@redhat.com>
5Description:
6 Attribute group to describe the magic bits that go into
7 perf_event_attr::config[012] for a particular pmu.
8 Each attribute of this group defines the 'hardware' bitmask
9 we want to export, so that userspace can deal with sane
10 name/value pairs.
11
12 Example: 'config1:1,6-10,44'
13 Defines contents of attribute that occupies bits 1,6-10,44 of
14 perf_event_attr::config1.
diff --git a/Documentation/RCU/RTFP.txt b/Documentation/RCU/RTFP.txt
index c43460dade0f..7c1dfb19fc40 100644
--- a/Documentation/RCU/RTFP.txt
+++ b/Documentation/RCU/RTFP.txt
@@ -1,9 +1,10 @@
1Read the F-ing Papers! 1Read the Fscking Papers!
2 2
3 3
4This document describes RCU-related publications, and is followed by 4This document describes RCU-related publications, and is followed by
5the corresponding bibtex entries. A number of the publications may 5the corresponding bibtex entries. A number of the publications may
6be found at http://www.rdrop.com/users/paulmck/RCU/. 6be found at http://www.rdrop.com/users/paulmck/RCU/. For others, browsers
7and search engines will usually find what you are looking for.
7 8
8The first thing resembling RCU was published in 1980, when Kung and Lehman 9The first thing resembling RCU was published in 1980, when Kung and Lehman
9[Kung80] recommended use of a garbage collector to defer destruction 10[Kung80] recommended use of a garbage collector to defer destruction
@@ -160,7 +161,26 @@ which Mathieu Desnoyers is now maintaining [MathieuDesnoyers2009URCU]
160[MathieuDesnoyersPhD]. TINY_RCU [PaulEMcKenney2009BloatWatchRCU] made 161[MathieuDesnoyersPhD]. TINY_RCU [PaulEMcKenney2009BloatWatchRCU] made
161its appearance, as did expedited RCU [PaulEMcKenney2009expeditedRCU]. 162its appearance, as did expedited RCU [PaulEMcKenney2009expeditedRCU].
162The problem of resizeable RCU-protected hash tables may now be on a path 163The problem of resizeable RCU-protected hash tables may now be on a path
163to a solution [JoshTriplett2009RPHash]. 164to a solution [JoshTriplett2009RPHash]. A few academic researchers are now
165using RCU to solve their parallel problems [HariKannan2009DynamicAnalysisRCU].
166
1672010 produced a simpler preemptible-RCU implementation
168based on TREE_RCU [PaulEMcKenney2010SimpleOptRCU], lockdep-RCU
169[PaulEMcKenney2010LockdepRCU], another resizeable RCU-protected hash
170table [HerbertXu2010RCUResizeHash] (this one consuming more memory,
171but allowing arbitrary changes in hash function, as required for DoS
172avoidance in the networking code), realization of the 2009 RCU-protected
173hash table with atomic node move [JoshTriplett2010RPHash], an update on
174the RCU API [PaulEMcKenney2010RCUAPI].
175
1762011 marked the inclusion of Nick Piggin's fully lockless dentry search
177[LinusTorvalds2011Linux2:6:38:rc1:NPigginVFS], an RCU-protected red-black
178tree using software transactional memory to protect concurrent updates
179(strange, but true!) [PhilHoward2011RCUTMRBTree], yet another variant of
180RCU-protected resizeable hash tables [Triplett:2011:RPHash], the 3.0 RCU
181trainwreck [PaulEMcKenney2011RCU3.0trainwreck], and Neil Brown's "Meet the
182Lockers" LWN article [NeilBrown2011MeetTheLockers].
183
164 184
165Bibtex Entries 185Bibtex Entries
166 186
@@ -173,6 +193,14 @@ Bibtex Entries
173,volume="5" 193,volume="5"
174,number="3" 194,number="3"
175,pages="354-382" 195,pages="354-382"
196,note="Available:
197\url{http://portal.acm.org/citation.cfm?id=320619&dl=GUIDE,}
198[Viewed December 3, 2007]"
199,annotation={
200 Use garbage collector to clean up data after everyone is done with it.
201 .
202 Oldest use of something vaguely resembling RCU that I have found.
203}
176} 204}
177 205
178@techreport{Manber82 206@techreport{Manber82
@@ -184,6 +212,31 @@ Bibtex Entries
184,number="82-01-01" 212,number="82-01-01"
185,month="January" 213,month="January"
186,pages="28" 214,pages="28"
215,annotation={
216 .
217 Superseded by Manber84.
218 .
219 Describes concurrent AVL tree implementation. Uses a
220 garbage-collection mechanism to handle concurrent use and deletion
221 of nodes in the tree, but lacks the summary-of-execution-history
222 concept of read-copy locking.
223 .
224 Keeps full list of processes that were active when a given
225 node was to be deleted, and waits until all such processes have
226 -terminated- before allowing this node to be reused. This is
227 not described in great detail -- one could imagine using process
228 IDs for this if the ID space was large enough that overlapping
229 never occurred.
230 .
231 This restriction makes this algorithm unsuitable for use in
232 systems comprised of long-lived processes. It also produces
233 completely unacceptable overhead in systems with large numbers
234 of processes. Finally, it is specific to AVL trees.
235 .
236 Cites Kung80, so not an independent invention, but the first
237 RCU-like usage that does not rely on an automatic garbage
238 collector.
239}
187} 240}
188 241
189@article{Manber84 242@article{Manber84
@@ -195,6 +248,74 @@ Bibtex Entries
195,volume="9" 248,volume="9"
196,number="3" 249,number="3"
197,pages="439-455" 250,pages="439-455"
251,annotation={
252 Describes concurrent AVL tree implementation. Uses a
253 garbage-collection mechanism to handle concurrent use and deletion
254 of nodes in the tree, but lacks the summary-of-execution-history
255 concept of read-copy locking.
256 .
257 Keeps full list of processes that were active when a given
258 node was to be deleted, and waits until all such processes have
259 -terminated- before allowing this node to be reused. This is
260 not described in great detail -- one could imagine using process
261 IDs for this if the ID space was large enough that overlapping
262 never occurred.
263 .
264 This restriction makes this algorithm unsuitable for use in
265 systems comprised of long-lived processes. It also produces
266 completely unacceptable overhead in systems with large numbers
267 of processes. Finally, it is specific to AVL trees.
268}
269}
270
271@Conference{RichardRashid87a
272,Author="Richard Rashid and Avadis Tevanian and Michael Young and
273David Golub and Robert Baron and David Black and William Bolosky and
274Jonathan Chew"
275,Title="Machine-Independent Virtual Memory Management for Paged
276Uniprocessor and Multiprocessor Architectures"
277,Booktitle="{2\textsuperscript{nd} Symposium on Architectural Support
278for Programming Languages and Operating Systems}"
279,Publisher="Association for Computing Machinery"
280,Month="October"
281,Year="1987"
282,pages="31-39"
283,Address="Palo Alto, CA"
284,note="Available:
285\url{http://www.cse.ucsc.edu/~randal/221/rashid-machvm.pdf}
286[Viewed February 17, 2005]"
287,annotation={
288 Describes lazy TLB flush, where one waits for each CPU to pass
289 through a scheduling-clock interrupt before reusing a given range
290 of virtual address. Does not describe how one determines that
291 all CPUs have in fact taken such an interrupt, though there are
292 no shortage of straightforward methods for accomplishing this.
293 .
294 Note that it does not make sense to just wait a fixed amount of
295 time, since a given CPU might have interrupts disabled for an
296 extended amount of time.
297}
298}
299
300@article{BarbaraLiskov1988ArgusCACM
301,author = {Barbara Liskov}
302,title = {Distributed programming in {Argus}}
303,journal = {Commun. ACM}
304,volume = {31}
305,number = {3}
306,year = {1988}
307,issn = {0001-0782}
308,pages = {300--312}
309,doi = {http://doi.acm.org/10.1145/42392.42399}
310,publisher = {ACM}
311,address = {New York, NY, USA}
312,annotation= {
313 At the top of page 307: "Conflicts with deposits and withdrawals
314 are necessary if the reported total is to be up to date. They
315 could be avoided by having total return a sum that is slightly
316 out of date." Relies on semantics -- approximate numerical
317 values sometimes OK.
318}
198} 319}
199 320
200@techreport{Hennessy89 321@techreport{Hennessy89
@@ -216,6 +337,13 @@ Bibtex Entries
216,year="1990" 337,year="1990"
217,number="CS-TR-2222.1" 338,number="CS-TR-2222.1"
218,month="June" 339,month="June"
340,annotation={
341 Concurrent access to skip lists. Has both weak and strong search.
342 Uses concept of ``garbage queue'', but has no real way of cleaning
343 the garbage efficiently.
344 .
345 Appears to be an independent invention of an RCU-like mechanism.
346}
219} 347}
220 348
221@Book{Adams91 349@Book{Adams91
@@ -223,20 +351,15 @@ Bibtex Entries
223,title="Concurrent Programming, Principles, and Practices" 351,title="Concurrent Programming, Principles, and Practices"
224,Publisher="Benjamin Cummins" 352,Publisher="Benjamin Cummins"
225,Year="1991" 353,Year="1991"
354,annotation={
355 Has a few paragraphs describing ``chaotic relaxation'', a
356 numerical analysis technique that allows multiprocessors to
357 avoid synchronization overhead by using possibly-stale data.
358 .
359 Seems like this is descended from yet another independent
360 invention of RCU-like function -- but this is restricted
361 in that reclamation is not necessary.
226} 362}
227
228@phdthesis{HMassalinPhD
229,author="H. Massalin"
230,title="Synthesis: An Efficient Implementation of Fundamental Operating
231System Services"
232,school="Columbia University"
233,address="New York, NY"
234,year="1992"
235,annotation="
236 Mondo optimizing compiler.
237 Wait-free stuff.
238 Good advice: defer work to avoid synchronization.
239"
240} 363}
241 364
242@unpublished{Jacobson93 365@unpublished{Jacobson93
@@ -244,7 +367,13 @@ System Services"
244,title="Avoid Read-Side Locking Via Delayed Free" 367,title="Avoid Read-Side Locking Via Delayed Free"
245,year="1993" 368,year="1993"
246,month="September" 369,month="September"
247,note="Verbal discussion" 370,note="private communication"
371,annotation={
372 Use fixed time delay to approximate grace period. Very simple,
373 but subject to random memory corruption under heavy load.
374 .
375 Independent invention of RCU-like mechanism.
376}
248} 377}
249 378
250@Conference{AjuJohn95 379@Conference{AjuJohn95
@@ -256,6 +385,17 @@ System Services"
256,Year="1995" 385,Year="1995"
257,pages="11-23" 386,pages="11-23"
258,Address="New Orleans, LA" 387,Address="New Orleans, LA"
388,note="Available:
389\url{https://www.usenix.org/publications/library/proceedings/neworl/full_papers/john.a}
390[Viewed October 1, 2010]"
391,annotation={
392 Age vnodes out of the cache, and have a fixed time set by a kernel
393 parameter. Not clear that all races were in fact correctly handled.
394 Used a 20-minute time by default, which would most definitely not
395 be suitable during DoS attacks or virus scans.
396 .
397 Apparently independent invention of RCU-like mechanism.
398}
259} 399}
260 400
261@conference{Pu95a, 401@conference{Pu95a,
@@ -301,31 +441,47 @@ Utilizing Execution History and Thread Monitoring"
301,institution="US Patent and Trademark Office" 441,institution="US Patent and Trademark Office"
302,address="Washington, DC" 442,address="Washington, DC"
303,year="1995" 443,year="1995"
304,number="US Patent 5,442,758 (contributed under GPL)" 444,number="US Patent 5,442,758"
305,month="August" 445,month="August"
446,annotation={
447 Describes the parallel RCU infrastructure. Includes NUMA aspect
448 (structure of bitmap can reflect bus structure of computer system).
449 .
450 Another independent invention of an RCU-like mechanism, but the
451 "real" RCU this time!
452}
306} 453}
307 454
308@techreport{Slingwine97 455@techreport{Slingwine97
309,author="John D. Slingwine and Paul E. McKenney" 456,author="John D. Slingwine and Paul E. McKenney"
310,title="Method for maintaining data coherency using thread 457,title="Method for Maintaining Data Coherency Using Thread Activity
311activity summaries in a multicomputer system" 458Summaries in a Multicomputer System"
312,institution="US Patent and Trademark Office" 459,institution="US Patent and Trademark Office"
313,address="Washington, DC" 460,address="Washington, DC"
314,year="1997" 461,year="1997"
315,number="US Patent 5,608,893 (contributed under GPL)" 462,number="US Patent 5,608,893"
316,month="March" 463,month="March"
464,pages="19"
465,annotation={
466 Describes use of RCU to synchronize data between a pair of
467 SMP/NUMA computer systems.
468}
317} 469}
318 470
319@techreport{Slingwine98 471@techreport{Slingwine98
320,author="John D. Slingwine and Paul E. McKenney" 472,author="John D. Slingwine and Paul E. McKenney"
321,title="Apparatus and method for achieving reduced overhead 473,title="Apparatus and Method for Achieving Reduced Overhead Mutual
322mutual exclusion and maintaining coherency in a multiprocessor 474Exclusion and Maintaining Coherency in a Multiprocessor System
323system utilizing execution history and thread monitoring" 475Utilizing Execution History and Thread Monitoring"
324,institution="US Patent and Trademark Office" 476,institution="US Patent and Trademark Office"
325,address="Washington, DC" 477,address="Washington, DC"
326,year="1998" 478,year="1998"
327,number="US Patent 5,727,209 (contributed under GPL)" 479,number="US Patent 5,727,209"
328,month="March" 480,month="March"
481,annotation={
482 Describes doing an atomic update by copying the data item and
483 then substituting it into the data structure.
484}
329} 485}
330 486
331@Conference{McKenney98 487@Conference{McKenney98
@@ -337,6 +493,15 @@ Problems"
337,Year="1998" 493,Year="1998"
338,pages="509-518" 494,pages="509-518"
339,Address="Las Vegas, NV" 495,Address="Las Vegas, NV"
496,note="Available:
497\url{http://www.rdrop.com/users/paulmck/RCU/rclockpdcsproof.pdf}
498[Viewed December 3, 2007]"
499,annotation={
500 Describes and analyzes RCU mechanism in DYNIX/ptx. Describes
501 application to linked list update and log-buffer flushing.
502 Defines 'quiescent state'. Includes both measured and analytic
503 evaluation.
504}
340} 505}
341 506
342@Conference{Gamsa99 507@Conference{Gamsa99
@@ -349,18 +514,76 @@ Operating System Design and Implementation}"
349,Year="1999" 514,Year="1999"
350,pages="87-100" 515,pages="87-100"
351,Address="New Orleans, LA" 516,Address="New Orleans, LA"
517,note="Available:
518\url{http://www.usenix.org/events/osdi99/full_papers/gamsa/gamsa.pdf}
519[Viewed August 30, 2006]"
520,annotation={
521 Use of RCU-like facility in K42/Tornado. Another independent
522 invention of RCU.
523 See especially pages 7-9 (Section 5).
524}
525}
526
527@unpublished{RustyRussell2000a
528,Author="Rusty Russell"
529,Title="Re: modular net drivers"
530,month="June"
531,year="2000"
532,day="23"
533,note="Available:
534\url{http://oss.sgi.com/projects/netdev/archive/2000-06/msg00250.html}
535[Viewed April 10, 2006]"
536,annotation={
537 Proto-RCU proposal from Phil Rumpf and Rusty Russell.
538 Yet another independent invention of RCU.
539 Outline of algorithm to unload modules...
540 .
541 Appeared on net-dev mailing list.
542}
543}
544
545@unpublished{RustyRussell2000b
546,Author="Rusty Russell"
547,Title="Re: modular net drivers"
548,month="June"
549,year="2000"
550,day="24"
551,note="Available:
552\url{http://oss.sgi.com/projects/netdev/archive/2000-06/msg00254.html}
553[Viewed April 10, 2006]"
554,annotation={
555 Proto-RCU proposal from Phil Rumpf and Rusty Russell.
556 .
557 Appeared on net-dev mailing list.
558}
559}
560
561@unpublished{McKenney01b
562,Author="Paul E. McKenney and Dipankar Sarma"
563,Title="Read-Copy Update Mutual Exclusion in {Linux}"
564,month="February"
565,year="2001"
566,note="Available:
567\url{http://lse.sourceforge.net/locking/rcu/rcupdate_doc.html}
568[Viewed October 18, 2004]"
569,annotation={
570 Prototypical Linux documentation for RCU.
571}
352} 572}
353 573
354@techreport{Slingwine01 574@techreport{Slingwine01
355,author="John D. Slingwine and Paul E. McKenney" 575,author="John D. Slingwine and Paul E. McKenney"
356,title="Apparatus and method for achieving reduced overhead 576,title="Apparatus and Method for Achieving Reduced Overhead Mutual
357mutual exclusion and maintaining coherency in a multiprocessor 577Exclusion and Maintaining Coherency in a Multiprocessor System
358system utilizing execution history and thread monitoring" 578Utilizing Execution History and Thread Monitoring"
359,institution="US Patent and Trademark Office" 579,institution="US Patent and Trademark Office"
360,address="Washington, DC" 580,address="Washington, DC"
361,year="2001" 581,year="2001"
362,number="US Patent 5,219,690 (contributed under GPL)" 582,number="US Patent 6,219,690"
363,month="April" 583,month="April"
584,annotation={
585 'Change in mode' aspect of RCU. Can be thought of as a lazy barrier.
586}
364} 587}
365 588
366@Conference{McKenney01a 589@Conference{McKenney01a
@@ -372,14 +595,61 @@ Orran Krieger and Rusty Russell and Dipankar Sarma and Maneesh Soni"
372,Year="2001" 595,Year="2001"
373,note="Available: 596,note="Available:
374\url{http://www.linuxsymposium.org/2001/abstracts/readcopy.php} 597\url{http://www.linuxsymposium.org/2001/abstracts/readcopy.php}
375\url{http://www.rdrop.com/users/paulmck/rclock/rclock_OLS.2001.05.01c.pdf} 598\url{http://www.rdrop.com/users/paulmck/RCU/rclock_OLS.2001.05.01c.pdf}
376[Viewed June 23, 2004]" 599[Viewed June 23, 2004]"
377annotation=" 600,annotation={
378Described RCU, and presented some patches implementing and using it in 601 Described RCU, and presented some patches implementing and using
379the Linux kernel. 602 it in the Linux kernel.
603}
604}
605
606@unpublished{McKenney01f
607,Author="Paul E. McKenney"
608,Title="{RFC:} patch to allow lock-free traversal of lists with insertion"
609,month="October"
610,year="2001"
611,note="Available:
612\url{http://marc.theaimsgroup.com/?l=linux-kernel&m=100259266316456&w=2}
613[Viewed June 23, 2004]"
614,annotation="
615 Memory-barrier and Alpha thread. 100 messages, not too bad...
616"
617}
618
619@unpublished{Spraul01
620,Author="Manfred Spraul"
621,Title="Re: {RFC:} patch to allow lock-free traversal of lists with insertion"
622,month="October"
623,year="2001"
624,note="Available:
625\url{http://marc.theaimsgroup.com/?l=linux-kernel&m=100264675012867&w=2}
626[Viewed June 23, 2004]"
627,annotation="
628 Suggested burying memory barriers in Linux's list-manipulation
629 primitives.
380" 630"
381} 631}
382 632
633@unpublished{LinusTorvalds2001a
634,Author="Linus Torvalds"
635,Title="{Re:} {[Lse-tech]} {Re:} {RFC:} patch to allow lock-free traversal of lists with insertion"
636,month="October"
637,year="2001"
638,note="Available:
639\url{http://lkml.org/lkml/2001/10/13/105}
640[Viewed August 21, 2004]"
641}
642
643@unpublished{Blanchard02a
644,Author="Anton Blanchard"
645,Title="some RCU dcache and ratcache results"
646,month="March"
647,year="2002"
648,note="Available:
649\url{http://marc.theaimsgroup.com/?l=linux-kernel&m=101637107412972&w=2}
650[Viewed October 18, 2004]"
651}
652
383@Conference{Linder02a 653@Conference{Linder02a
384,Author="Hanna Linder and Dipankar Sarma and Maneesh Soni" 654,Author="Hanna Linder and Dipankar Sarma and Maneesh Soni"
385,Title="Scalability of the Directory Entry Cache" 655,Title="Scalability of the Directory Entry Cache"
@@ -387,6 +657,10 @@ the Linux kernel.
387,Month="June" 657,Month="June"
388,Year="2002" 658,Year="2002"
389,pages="289-300" 659,pages="289-300"
660,annotation="
661 Measured scalability of Linux 2.4 kernel's directory-entry cache
662 (dcache), and measured some scalability enhancements.
663"
390} 664}
391 665
392@Conference{McKenney02a 666@Conference{McKenney02a
@@ -400,49 +674,76 @@ Andrea Arcangeli and Andi Kleen and Orran Krieger and Rusty Russell"
400,note="Available: 674,note="Available:
401\url{http://www.linux.org.uk/~ajh/ols2002_proceedings.pdf.gz} 675\url{http://www.linux.org.uk/~ajh/ols2002_proceedings.pdf.gz}
402[Viewed June 23, 2004]" 676[Viewed June 23, 2004]"
677,annotation="
678 Presented and compared a number of RCU implementations for the
679 Linux kernel.
680"
403} 681}
404 682
405@conference{Michael02a 683@unpublished{Sarma02a
406,author="Maged M. Michael" 684,Author="Dipankar Sarma"
407,title="Safe Memory Reclamation for Dynamic Lock-Free Objects Using Atomic 685,Title="specweb99: dcache scalability results"
408Reads and Writes" 686,month="July"
409,Year="2002" 687,year="2002"
410,Month="August" 688,note="Available:
411,booktitle="{Proceedings of the 21\textsuperscript{st} Annual ACM 689\url{http://marc.theaimsgroup.com/?l=linux-kernel&m=102645767914212&w=2}
412Symposium on Principles of Distributed Computing}" 690[Viewed June 23, 2004]"
413,pages="21-30"
414,annotation=" 691,annotation="
415 Each thread keeps an array of pointers to items that it is 692 Compare fastwalk and RCU for dcache. RCU won.
416 currently referencing. Sort of an inside-out garbage collection
417 mechanism, but one that requires the accessing code to explicitly
418 state its needs. Also requires read-side memory barriers on
419 most architectures.
420" 693"
421} 694}
422 695
423@conference{Michael02b 696@unpublished{Barbieri02
424,author="Maged M. Michael" 697,Author="Luca Barbieri"
425,title="High Performance Dynamic Lock-Free Hash Tables and List-Based Sets" 698,Title="Re: {[PATCH]} Initial support for struct {vfs\_cred}"
426,Year="2002" 699,month="August"
427,Month="August" 700,year="2002"
428,booktitle="{Proceedings of the 14\textsuperscript{th} Annual ACM 701,note="Available:
429Symposium on Parallel 702\url{http://marc.theaimsgroup.com/?l=linux-kernel&m=103082050621241&w=2}
430Algorithms and Architecture}" 703[Viewed: June 23, 2004]"
431,pages="73-82"
432,annotation=" 704,annotation="
433 Like the title says... 705 Suggested RCU for vfs\_shared\_cred.
434" 706"
435} 707}
436 708
437@InProceedings{HerlihyLM02 709@unpublished{Dickins02a
438,author={Maurice Herlihy and Victor Luchangco and Mark Moir} 710,author="Hugh Dickins"
439,title="The Repeat Offender Problem: A Mechanism for Supporting Dynamic-Sized, 711,title="Use RCU for System-V IPC"
440Lock-Free Data Structures" 712,year="2002"
441,booktitle={Proceedings of 16\textsuperscript{th} International 713,month="October"
442Symposium on Distributed Computing} 714,note="private communication"
443,year=2002 715}
716
717@unpublished{Sarma02b
718,Author="Dipankar Sarma"
719,Title="Some dcache\_rcu benchmark numbers"
444,month="October" 720,month="October"
445,pages="339-353" 721,year="2002"
722,note="Available:
723\url{http://marc.theaimsgroup.com/?l=linux-kernel&m=103462075416638&w=2}
724[Viewed June 23, 2004]"
725,annotation="
726 Performance of dcache RCU on kernbench for 16x NUMA-Q and 1x,
727 2x, and 4x systems. RCU does no harm, and helps on 16x.
728"
729}
730
731@unpublished{LinusTorvalds2003a
732,Author="Linus Torvalds"
733,Title="Re: {[PATCH]} small fixes in brlock.h"
734,month="March"
735,year="2003"
736,note="Available:
737\url{http://lkml.org/lkml/2003/3/9/205}
738[Viewed March 13, 2006]"
739,annotation="
740 Linus suggests replacing brlock with RCU and/or seqlocks:
741 .
742 'It's entirely possible that the current user could be replaced
743 by RCU and/or seqlocks, and we could get rid of brlocks entirely.'
744 .
745 Steve Hemminger responds by replacing them with RCU.
746"
446} 747}
447 748
448@article{Appavoo03a 749@article{Appavoo03a
@@ -457,6 +758,20 @@ B. Rosenburg and M. Stumm and J. Xenidis"
457,volume="42" 758,volume="42"
458,number="1" 759,number="1"
459,pages="60-76" 760,pages="60-76"
761,annotation="
762 Use of RCU to enable hot-swapping for autonomic behavior in K42.
763"
764}
765
766@unpublished{Seigh03
767,author="Joseph W. {Seigh II}"
768,title="Read Copy Update"
769,Year="2003"
770,Month="March"
771,note="email correspondence"
772,annotation="
773 Described the relationship of the VM/XA passive serialization to RCU.
774"
460} 775}
461 776
462@Conference{Arcangeli03 777@Conference{Arcangeli03
@@ -470,6 +785,27 @@ Dipankar Sarma"
470,year="2003" 785,year="2003"
471,month="June" 786,month="June"
472,pages="297-310" 787,pages="297-310"
788,note="Available:
789\url{http://www.rdrop.com/users/paulmck/RCU/rcu.FREENIX.2003.06.14.pdf}
790[Viewed November 21, 2007]"
791,annotation="
792 Compared updated RCU implementations for the Linux kernel, and
793 described System V IPC use of RCU, including order-of-magnitude
794 performance improvements.
795"
796}
797
798@Conference{Soules03a
799,Author="Craig A. N. Soules and Jonathan Appavoo and Kevin Hui and
800Dilma {Da Silva} and Gregory R. Ganger and Orran Krieger and
801Michael Stumm and Robert W. Wisniewski and Marc Auslander and
802Michal Ostrowski and Bryan Rosenburg and Jimi Xenidis"
803,Title="System Support for Online Reconfiguration"
804,Booktitle="Proceedings of the 2003 USENIX Annual Technical Conference"
805,Publisher="USENIX Association"
806,year="2003"
807,month="June"
808,pages="141-154"
473} 809}
474 810
475@article{McKenney03a 811@article{McKenney03a
@@ -481,6 +817,22 @@ Dipankar Sarma"
481,volume="1" 817,volume="1"
482,number="114" 818,number="114"
483,pages="18-26" 819,pages="18-26"
820,note="Available:
821\url{http://www.linuxjournal.com/article/6993}
822[Viewed November 14, 2007]"
823,annotation="
824 Reader-friendly intro to RCU, with the infamous old-man-and-brat
825 cartoon.
826"
827}
828
829@unpublished{Sarma03a
830,Author="Dipankar Sarma"
831,Title="RCU low latency patches"
832,month="December"
833,year="2003"
834,note="Message ID: 20031222180114.GA2248@in.ibm.com"
835,annotation="dipankar/ct.2004.03.27/RCUll.2003.12.22.patch"
484} 836}
485 837
486@techreport{Friedberg03a 838@techreport{Friedberg03a
@@ -489,9 +841,14 @@ Dipankar Sarma"
489,institution="US Patent and Trademark Office" 841,institution="US Patent and Trademark Office"
490,address="Washington, DC" 842,address="Washington, DC"
491,year="2003" 843,year="2003"
492,number="US Patent 6,662,184 (contributed under GPL)" 844,number="US Patent 6,662,184"
493,month="December" 845,month="December"
494,pages="112" 846,pages="112"
847,annotation="
848 Applies RCU to a wildcard-search Patricia tree in order to permit
849 synchronization-free lookup. RCU is used to retain removed nodes
850 for a grace period before freeing them.
851"
495} 852}
496 853
497@article{McKenney04a 854@article{McKenney04a
@@ -503,6 +860,12 @@ Dipankar Sarma"
503,volume="1" 860,volume="1"
504,number="118" 861,number="118"
505,pages="38-46" 862,pages="38-46"
863,note="Available:
864\url{http://www.linuxjournal.com/node/7124}
865[Viewed December 26, 2010]"
866,annotation="
867 Reader friendly intro to dcache and RCU.
868"
506} 869}
507 870
508@Conference{McKenney04b 871@Conference{McKenney04b
@@ -514,8 +877,83 @@ Dipankar Sarma"
514,Address="Adelaide, Australia" 877,Address="Adelaide, Australia"
515,note="Available: 878,note="Available:
516\url{http://www.linux.org.au/conf/2004/abstracts.html#90} 879\url{http://www.linux.org.au/conf/2004/abstracts.html#90}
517\url{http://www.rdrop.com/users/paulmck/rclock/lockperf.2004.01.17a.pdf} 880\url{http://www.rdrop.com/users/paulmck/RCU/lockperf.2004.01.17a.pdf}
518[Viewed June 23, 2004]" 881[Viewed June 23, 2004]"
882,annotation="
883 Compares performance of RCU to that of other locking primitives
884 over a number of CPUs (x86, Opteron, Itanium, and PPC).
885"
886}
887
888@unpublished{Sarma04a
889,Author="Dipankar Sarma"
890,Title="{[PATCH]} {RCU} for low latency (experimental)"
891,month="March"
892,year="2004"
893,note="\url{http://marc.theaimsgroup.com/?l=linux-kernel&m=108003746402892&w=2}"
894,annotation="Head of thread: dipankar/2004.03.23/rcu-low-lat.1.patch"
895}
896
897@unpublished{Sarma04b
898,Author="Dipankar Sarma"
899,Title="Re: {[PATCH]} {RCU} for low latency (experimental)"
900,month="March"
901,year="2004"
902,note="\url{http://marc.theaimsgroup.com/?l=linux-kernel&m=108016474829546&w=2}"
903,annotation="dipankar/rcuth.2004.03.24/rcu-throttle.patch"
904}
905
906@unpublished{Spraul04a
907,Author="Manfred Spraul"
908,Title="[RFC] 0/5 rcu lock update"
909,month="May"
910,year="2004"
911,note="Available:
912\url{http://marc.theaimsgroup.com/?l=linux-kernel&m=108546407726602&w=2}
913[Viewed June 23, 2004]"
914,annotation="
915 Hierarchical-bitmap patch for RCU infrastructure.
916"
917}
918
919@unpublished{Steiner04a
920,Author="Jack Steiner"
921,Title="Re: [Lse-tech] [RFC, PATCH] 1/5 rcu lock update:
922Add per-cpu batch counter"
923,month="May"
924,year="2004"
925,note="Available:
926\url{http://marc.theaimsgroup.com/?l=linux-kernel&m=108551764515332&w=2}
927[Viewed June 23, 2004]"
928,annotation={
929 RCU runs reasonably on a 512-CPU SGI using Manfred Spraul's patches,
930 which may be found at:
931 https://lkml.org/lkml/2004/5/20/49 (split vars into cachelines)
932 https://lkml.org/lkml/2004/5/22/114 (cpu_quiet() patch)
933 https://lkml.org/lkml/2004/5/25/24 (0/5)
934 https://lkml.org/lkml/2004/5/25/23 (1/5)
935 https://lkml.org/lkml/2004/5/25/265 (works for Jack)
936 https://lkml.org/lkml/2004/5/25/20 (2/5)
937 https://lkml.org/lkml/2004/5/25/22 (3/5)
938 https://lkml.org/lkml/2004/5/25/19 (4/5)
939 https://lkml.org/lkml/2004/5/25/21 (5/5)
940}
941}
942
943@Conference{Sarma04c
944,Author="Dipankar Sarma and Paul E. McKenney"
945,Title="Making {RCU} Safe for Deep Sub-Millisecond Response
946Realtime Applications"
947,Booktitle="Proceedings of the 2004 USENIX Annual Technical Conference
948(FREENIX Track)"
949,Publisher="USENIX Association"
950,year="2004"
951,month="June"
952,pages="182-191"
953,annotation="
954 Describes and compares a number of modifications to the Linux RCU
955 implementation that make it friendly to realtime applications.
956"
519} 957}
520 958
521@phdthesis{PaulEdwardMcKenneyPhD 959@phdthesis{PaulEdwardMcKenneyPhD
@@ -529,17 +967,118 @@ Oregon Health and Sciences University"
529,note="Available: 967,note="Available:
530\url{http://www.rdrop.com/users/paulmck/RCU/RCUdissertation.2004.07.14e1.pdf} 968\url{http://www.rdrop.com/users/paulmck/RCU/RCUdissertation.2004.07.14e1.pdf}
531[Viewed October 15, 2004]" 969[Viewed October 15, 2004]"
970,annotation="
971 Describes RCU implementations and presents design patterns
972 corresponding to common uses of RCU in several operating-system
973 kernels.
974"
532} 975}
533 976
534@Conference{Sarma04c 977@unpublished{PaulEMcKenney2004rcu:dereference
535,Author="Dipankar Sarma and Paul E. McKenney" 978,Author="Dipankar Sarma"
536,Title="Making RCU Safe for Deep Sub-Millisecond Response Realtime Applications" 979,Title="{Re: RCU : Abstracted RCU dereferencing [5/5]}"
537,Booktitle="Proceedings of the 2004 USENIX Annual Technical Conference 980,month="August"
538(FREENIX Track)"
539,Publisher="USENIX Association"
540,year="2004" 981,year="2004"
541,month="June" 982,note="Available:
542,pages="182-191" 983\url{http://lkml.org/lkml/2004/8/6/237}
984[Viewed June 8, 2010]"
985,annotation="
986 Introduce rcu_dereference().
987"
988}
989
990@unpublished{JimHouston04a
991,Author="Jim Houston"
992,Title="{[RFC\&PATCH] Alternative {RCU} implementation}"
993,month="August"
994,year="2004"
995,note="Available:
996\url{http://lkml.org/lkml/2004/8/30/87}
997[Viewed February 17, 2005]"
998,annotation="
999 Uses active code in rcu_read_lock() and rcu_read_unlock() to
1000 make RCU happen, allowing RCU to function on CPUs that do not
1001 receive a scheduling-clock interrupt.
1002"
1003}
1004
1005@unpublished{TomHart04a
1006,Author="Thomas E. Hart"
1007,Title="Master's Thesis: Applying Lock-free Techniques to the {Linux} Kernel"
1008,month="October"
1009,year="2004"
1010,note="Available:
1011\url{http://www.cs.toronto.edu/~tomhart/masters_thesis.html}
1012[Viewed October 15, 2004]"
1013,annotation="
1014 Proposes comparing RCU to lock-free methods for the Linux kernel.
1015"
1016}
1017
1018@unpublished{Vaddagiri04a
1019,Author="Srivatsa Vaddagiri"
1020,Title="Subject: [RFC] Use RCU for tcp\_ehash lookup"
1021,month="October"
1022,year="2004"
1023,note="Available:
1024\url{http://marc.theaimsgroup.com/?t=109395731700004&r=1&w=2}
1025[Viewed October 18, 2004]"
1026,annotation="
1027 Srivatsa's RCU patch for tcp_ehash lookup.
1028"
1029}
1030
1031@unpublished{Thirumalai04a
1032,Author="Ravikiran Thirumalai"
1033,Title="Subject: [patchset] Lockfree fd lookup 0 of 5"
1034,month="October"
1035,year="2004"
1036,note="Available:
1037\url{http://marc.theaimsgroup.com/?t=109144217400003&r=1&w=2}
1038[Viewed October 18, 2004]"
1039,annotation="
1040 Ravikiran's lockfree FD patch.
1041"
1042}
1043
1044@unpublished{Thirumalai04b
1045,Author="Ravikiran Thirumalai"
1046,Title="Subject: Re: [patchset] Lockfree fd lookup 0 of 5"
1047,month="October"
1048,year="2004"
1049,note="Available:
1050\url{http://marc.theaimsgroup.com/?l=linux-kernel&m=109152521410459&w=2}
1051[Viewed October 18, 2004]"
1052,annotation="
1053 Ravikiran's lockfree FD patch.
1054"
1055}
1056
1057@unpublished{PaulEMcKenney2004rcu:assign:pointer
1058,Author="Paul E. McKenney"
1059,Title="{[PATCH 1/3] RCU: \url{rcu_assign_pointer()} removal of memory barriers}"
1060,month="October"
1061,year="2004"
1062,note="Available:
1063\url{http://lkml.org/lkml/2004/10/23/241}
1064[Viewed June 8, 2010]"
1065,annotation="
1066 Introduce rcu_assign_pointer().
1067"
1068}
1069
1070@unpublished{JamesMorris04a
1071,Author="James Morris"
1072,Title="{[PATCH 2/3] SELinux} scalability - convert {AVC} to {RCU}"
1073,day="15"
1074,month="November"
1075,year="2004"
1076,note="Available:
1077\url{http://marc.theaimsgroup.com/?l=linux-kernel&m=110054979416004&w=2}
1078[Viewed December 10, 2004]"
1079,annotation="
1080 James Morris posts Kaigai Kohei's patch to LKML.
1081"
543} 1082}
544 1083
545@unpublished{JamesMorris04b 1084@unpublished{JamesMorris04b
@@ -550,6 +1089,85 @@ Oregon Health and Sciences University"
550,note="Available: 1089,note="Available:
551\url{http://www.livejournal.com/users/james_morris/2153.html} 1090\url{http://www.livejournal.com/users/james_morris/2153.html}
552[Viewed December 10, 2004]" 1091[Viewed December 10, 2004]"
1092,annotation="
1093 RCU helps SELinux performance. ;-) Made LWN.
1094"
1095}
1096
1097@unpublished{PaulMcKenney2005RCUSemantics
1098,Author="Paul E. McKenney and Jonathan Walpole"
1099,Title="{RCU} Semantics: A First Attempt"
1100,month="January"
1101,year="2005"
1102,day="30"
1103,note="Available:
1104\url{http://www.rdrop.com/users/paulmck/RCU/rcu-semantics.2005.01.30a.pdf}
1105[Viewed December 6, 2009]"
1106,annotation="
1107 Early derivation of RCU semantics.
1108"
1109}
1110
1111@unpublished{PaulMcKenney2005e
1112,Author="Paul E. McKenney"
1113,Title="Real-Time Preemption and {RCU}"
1114,month="March"
1115,year="2005"
1116,day="17"
1117,note="Available:
1118\url{http://lkml.org/lkml/2005/3/17/199}
1119[Viewed September 5, 2005]"
1120,annotation="
1121 First posting showing how RCU can be safely adapted for
1122 preemptable RCU read side critical sections.
1123"
1124}
1125
1126@unpublished{EsbenNeilsen2005a
1127,Author="Esben Neilsen"
1128,Title="Re: Real-Time Preemption and {RCU}"
1129,month="March"
1130,year="2005"
1131,day="18"
1132,note="Available:
1133\url{http://lkml.org/lkml/2005/3/18/122}
1134[Viewed March 30, 2006]"
1135,annotation="
1136 Esben Neilsen suggests read-side suppression of grace-period
1137 processing for crude-but-workable realtime RCU. The downside
1138 is indefinite grace periods...But this is OK for experimentation
1139 and testing.
1140"
1141}
1142
1143@unpublished{TomHart05a
1144,Author="Thomas E. Hart and Paul E. McKenney and Angela Demke Brown"
1145,Title="Efficient Memory Reclamation is Necessary for Fast Lock-Free
1146Data Structures"
1147,month="March"
1148,year="2005"
1149,note="Available:
1150\url{ftp://ftp.cs.toronto.edu/csrg-technical-reports/515/}
1151[Viewed March 4, 2005]"
1152,annotation="
1153 Comparison of RCU, QBSR, and EBSR. RCU wins for read-mostly
1154 workloads. ;-)
1155"
1156}
1157
1158@unpublished{JonCorbet2005DeprecateSyncKernel
1159,Author="Jonathan Corbet"
1160,Title="API change: synchronize_kernel() deprecated"
1161,month="May"
1162,day="3"
1163,year="2005"
1164,note="Available:
1165\url{http://lwn.net/Articles/134484/}
1166[Viewed May 3, 2005]"
1167,annotation="
1168 Jon Corbet describes deprecation of synchronize_kernel()
1169 in favor of synchronize_rcu() and synchronize_sched().
1170"
553} 1171}
554 1172
555@unpublished{PaulMcKenney05a 1173@unpublished{PaulMcKenney05a
@@ -568,7 +1186,7 @@ Oregon Health and Sciences University"
568 1186
569@conference{PaulMcKenney05b 1187@conference{PaulMcKenney05b
570,Author="Paul E. McKenney and Dipankar Sarma" 1188,Author="Paul E. McKenney and Dipankar Sarma"
571,Title="Towards Hard Realtime Response from the Linux Kernel on SMP Hardware" 1189,Title="Towards Hard Realtime Response from the {Linux} Kernel on {SMP} Hardware"
572,Booktitle="linux.conf.au 2005" 1190,Booktitle="linux.conf.au 2005"
573,month="April" 1191,month="April"
574,year="2005" 1192,year="2005"
@@ -578,6 +1196,103 @@ Oregon Health and Sciences University"
578[Viewed May 13, 2005]" 1196[Viewed May 13, 2005]"
579,annotation=" 1197,annotation="
580 Realtime turns into making RCU yet more realtime friendly. 1198 Realtime turns into making RCU yet more realtime friendly.
1199 http://lca2005.linux.org.au/Papers/Paul%20McKenney/Towards%20Hard%20Realtime%20Response%20from%20the%20Linux%20Kernel/LKS.2005.04.22a.pdf
1200"
1201}
1202
1203@unpublished{PaulEMcKenneyHomePage
1204,Author="Paul E. McKenney"
1205,Title="{Paul} {E.} {McKenney}"
1206,month="May"
1207,year="2005"
1208,note="Available:
1209\url{http://www.rdrop.com/users/paulmck/}
1210[Viewed May 25, 2005]"
1211,annotation="
1212 Paul McKenney's home page.
1213"
1214}
1215
1216@unpublished{PaulEMcKenneyRCUPage
1217,Author="Paul E. McKenney"
1218,Title="Read-Copy Update {(RCU)}"
1219,month="May"
1220,year="2005"
1221,note="Available:
1222\url{http://www.rdrop.com/users/paulmck/RCU}
1223[Viewed May 25, 2005]"
1224,annotation="
1225 Paul McKenney's RCU page.
1226"
1227}
1228
1229@unpublished{JosephSeigh2005a
1230,Author="Joseph Seigh"
1231,Title="{RCU}+{SMR} (hazard pointers)"
1232,month="July"
1233,year="2005"
1234,note="Personal communication"
1235,annotation="
1236 Joe Seigh announcing his atomic-ptr-plus project.
1237 http://sourceforge.net/projects/atomic-ptr-plus/
1238"
1239}
1240
1241@unpublished{JosephSeigh2005b
1242,Author="Joseph Seigh"
1243,Title="Lock-free synchronization primitives"
1244,month="July"
1245,day="6"
1246,year="2005"
1247,note="Available:
1248\url{http://sourceforge.net/projects/atomic-ptr-plus/}
1249[Viewed August 8, 2005]"
1250,annotation="
1251 Joe Seigh's atomic-ptr-plus project.
1252"
1253}
1254
1255@unpublished{PaulMcKenney2005c
1256,Author="Paul E.McKenney"
1257,Title="{[RFC,PATCH] RCU} and {CONFIG\_PREEMPT\_RT} sane patch"
1258,month="August"
1259,day="1"
1260,year="2005"
1261,note="Available:
1262\url{http://lkml.org/lkml/2005/8/1/155}
1263[Viewed March 14, 2006]"
1264,annotation="
1265 First operating counter-based realtime RCU patch posted to LKML.
1266"
1267}
1268
1269@unpublished{PaulMcKenney2005d
1270,Author="Paul E. McKenney"
1271,Title="Re: [Fwd: Re: [patch] Real-Time Preemption, -RT-2.6.13-rc4-V0.7.52-01]"
1272,month="August"
1273,day="8"
1274,year="2005"
1275,note="Available:
1276\url{http://lkml.org/lkml/2005/8/8/108}
1277[Viewed March 14, 2006]"
1278,annotation="
1279 First operating counter-based realtime RCU patch posted to LKML,
1280 but fixed so that various unusual combinations of configuration
1281 parameters all function properly.
1282"
1283}
1284
1285@unpublished{PaulMcKenney2005rcutorture
1286,Author="Paul E. McKenney"
1287,Title="{[PATCH]} {RCU} torture testing"
1288,month="October"
1289,day="1"
1290,year="2005"
1291,note="Available:
1292\url{http://lkml.org/lkml/2005/10/1/70}
1293[Viewed March 14, 2006]"
1294,annotation="
1295 First rcutorture patch.
581" 1296"
582} 1297}
583 1298
@@ -591,22 +1306,39 @@ Distributed Processing Symposium"
591,year="2006" 1306,year="2006"
592,day="25-29" 1307,day="25-29"
593,address="Rhodes, Greece" 1308,address="Rhodes, Greece"
1309,note="Available:
1310\url{http://www.rdrop.com/users/paulmck/RCU/hart_ipdps06.pdf}
1311[Viewed April 28, 2008]"
1312,annotation="
1313 Compares QSBR, HPBR, EBR, and lock-free reference counting.
1314 http://www.cs.toronto.edu/~tomhart/perflab/ipdps06.tgz
1315"
1316}
1317
1318@unpublished{NickPiggin2006radixtree
1319,Author="Nick Piggin"
1320,Title="[patch 3/3] radix-tree: {RCU} lockless readside"
1321,month="June"
1322,day="20"
1323,year="2006"
1324,note="Available:
1325\url{http://lkml.org/lkml/2006/6/20/238}
1326[Viewed March 25, 2008]"
594,annotation=" 1327,annotation="
595 Compares QSBR (AKA "classic RCU"), HPBR, EBR, and lock-free 1328 RCU-protected radix tree.
596 reference counting.
597" 1329"
598} 1330}
599 1331
600@Conference{PaulEMcKenney2006b 1332@Conference{PaulEMcKenney2006b
601,Author="Paul E. McKenney and Dipankar Sarma and Ingo Molnar and 1333,Author="Paul E. McKenney and Dipankar Sarma and Ingo Molnar and
602Suparna Bhattacharya" 1334Suparna Bhattacharya"
603,Title="Extending RCU for Realtime and Embedded Workloads" 1335,Title="Extending {RCU} for Realtime and Embedded Workloads"
604,Booktitle="{Ottawa Linux Symposium}" 1336,Booktitle="{Ottawa Linux Symposium}"
605,Month="July" 1337,Month="July"
606,Year="2006" 1338,Year="2006"
607,pages="v2 123-138" 1339,pages="v2 123-138"
608,note="Available: 1340,note="Available:
609\url{http://www.linuxsymposium.org/2006/index_2006.php} 1341\url{http://www.linuxsymposium.org/2006/view_abstract.php?content_key=184}
610\url{http://www.rdrop.com/users/paulmck/RCU/OLSrtRCU.2006.08.11a.pdf} 1342\url{http://www.rdrop.com/users/paulmck/RCU/OLSrtRCU.2006.08.11a.pdf}
611[Viewed January 1, 2007]" 1343[Viewed January 1, 2007]"
612,annotation=" 1344,annotation="
@@ -614,6 +1346,37 @@ Suparna Bhattacharya"
614" 1346"
615} 1347}
616 1348
1349@unpublished{WikipediaRCU
1350,Author="Paul E. McKenney and Chris Purcell and Algae and Ben Schumin and
1351Gaius Cornelius and Qwertyus and Neil Conway and Sbw and Blainster and
1352Canis Rufus and Zoicon5 and Anome and Hal Eisen"
1353,Title="Read-Copy Update"
1354,month="July"
1355,day="8"
1356,year="2006"
1357,note="Available:
1358\url{http://en.wikipedia.org/wiki/Read-copy-update}
1359[Viewed August 21, 2006]"
1360,annotation="
1361 Wikipedia RCU page as of July 8 2006.
1362"
1363}
1364
1365@Conference{NickPiggin2006LocklessPageCache
1366,Author="Nick Piggin"
1367,Title="A Lockless Pagecache in Linux---Introduction, Progress, Performance"
1368,Booktitle="{Ottawa Linux Symposium}"
1369,Month="July"
1370,Year="2006"
1371,pages="v2 249-254"
1372,note="Available:
1373\url{http://www.linuxsymposium.org/2006/view_abstract.php?content_key=184}
1374[Viewed January 11, 2009]"
1375,annotation="
1376 Uses RCU-protected radix tree for a lockless page cache.
1377"
1378}
1379
617@unpublished{PaulEMcKenney2006c 1380@unpublished{PaulEMcKenney2006c
618,Author="Paul E. McKenney" 1381,Author="Paul E. McKenney"
619,Title="Sleepable {RCU}" 1382,Title="Sleepable {RCU}"
@@ -637,29 +1400,301 @@ Revised:
637,day="18" 1400,day="18"
638,year="2006" 1401,year="2006"
639,note="Available: 1402,note="Available:
640\url{http://www.nada.kth.se/~snilsson/public/papers/trash/trash.pdf} 1403\url{http://www.nada.kth.se/~snilsson/publications/TRASH/trash.pdf}
641[Viewed February 24, 2007]" 1404[Viewed March 4, 2011]"
642,annotation=" 1405,annotation="
643 RCU-protected dynamic trie-hash combination. 1406 RCU-protected dynamic trie-hash combination.
644" 1407"
645} 1408}
646 1409
647@unpublished{ThomasEHart2007a 1410@unpublished{ChristophHellwig2006RCU2SRCU
648,Author="Thomas E. Hart and Paul E. McKenney and Angela Demke Brown and Jonathan Walpole" 1411,Author="Christoph Hellwig"
649,Title="Performance of memory reclamation for lockless synchronization" 1412,Title="Re: {[-mm PATCH 1/4]} {RCU}: split classic rcu"
650,journal="J. Parallel Distrib. Comput." 1413,month="September"
1414,day="28"
1415,year="2006"
1416,note="Available:
1417\url{http://lkml.org/lkml/2006/9/28/160}
1418[Viewed March 27, 2008]"
1419}
1420
1421@unpublished{PaulEMcKenneyRCUusagePage
1422,Author="Paul E. McKenney"
1423,Title="{RCU} {Linux} Usage"
1424,month="October"
1425,year="2006"
1426,note="Available:
1427\url{http://www.rdrop.com/users/paulmck/RCU/linuxusage.html}
1428[Viewed January 14, 2007]"
1429,annotation="
1430 Paul McKenney's RCU page showing graphs plotting Linux-kernel
1431 usage of RCU.
1432"
1433}
1434
1435@unpublished{PaulEMcKenneyRCUusageRawDataPage
1436,Author="Paul E. McKenney"
1437,Title="Read-Copy Update {(RCU)} Usage in {Linux} Kernel"
1438,month="October"
1439,year="2006"
1440,note="Available:
1441\url{http://www.rdrop.com/users/paulmck/RCU/linuxusage/rculocktab.html}
1442[Viewed January 14, 2007]"
1443,annotation="
1444 Paul McKenney's RCU page showing Linux usage of RCU in tabular
1445 form, with links to corresponding cscope databases.
1446"
1447}
1448
1449@unpublished{GauthamShenoy2006RCUrwlock
1450,Author="Gautham R. Shenoy"
1451,Title="[PATCH 4/5] lock\_cpu\_hotplug: Redesign - Lightweight implementation of lock\_cpu\_hotplug"
1452,month="October"
1453,year="2006"
1454,day=26
1455,note="Available:
1456\url{http://lkml.org/lkml/2006/10/26/73}
1457[Viewed January 26, 2009]"
1458,annotation="
1459 RCU-based reader-writer lock that allows readers to proceed with
1460 no memory barriers or atomic instruction in absence of writers.
1461 If writer do show up, readers must of course wait as required by
1462 the semantics of reader-writer locking. This is a recursive
1463 lock.
1464"
1465}
1466
1467@unpublished{JensAxboe2006SlowSRCU
1468,Author="Jens Axboe"
1469,Title="Re: [patch] cpufreq: mark \url{cpufreq_tsc()} as
1470\url{core_initcall_sync}"
1471,month="November"
1472,year="2006"
1473,day=17
1474,note="Available:
1475\url{http://lkml.org/lkml/2006/11/17/56}
1476[Viewed May 28, 2007]"
1477,annotation="
1478 SRCU's grace periods are too slow for Jens, even after a
1479 factor-of-three speedup.
1480 Sped-up version of SRCU at http://lkml.org/lkml/2006/11/17/359.
1481"
1482}
1483
1484@unpublished{OlegNesterov2006QRCU
1485,Author="Oleg Nesterov"
1486,Title="Re: [patch] cpufreq: mark {\tt cpufreq\_tsc()} as
1487{\tt core\_initcall\_sync}"
1488,month="November"
1489,year="2006"
1490,day=19
1491,note="Available:
1492\url{http://lkml.org/lkml/2006/11/19/69}
1493[Viewed May 28, 2007]"
1494,annotation="
1495 First cut of QRCU. Expanded/corrected versions followed.
1496 Used to be OlegNesterov2007QRCU, now time-corrected.
1497"
1498}
1499
1500@unpublished{OlegNesterov2006aQRCU
1501,Author="Oleg Nesterov"
1502,Title="Re: [RFC, PATCH 1/2] qrcu: {"quick"} srcu implementation"
1503,month="November"
1504,year="2006"
1505,day=30
1506,note="Available:
1507\url{http://lkml.org/lkml/2006/11/29/330}
1508[Viewed November 26, 2008]"
1509,annotation="
1510 Expanded/corrected version of QRCU.
1511 Used to be OlegNesterov2007aQRCU, now time-corrected.
1512"
1513}
1514
1515@unpublished{EvgeniyPolyakov2006RCUslowdown
1516,Author="Evgeniy Polyakov"
1517,Title="Badness in postponing work"
1518,month="December"
1519,year="2006"
1520,day=05
1521,note="Available:
1522\url{http://www.ioremap.net/node/41}
1523[Viewed October 28, 2008]"
1524,annotation="
1525 Using RCU as a pure delay leads to a 2.5x slowdown in skbs in
1526 the Linux kernel.
1527"
1528}
1529
1530@inproceedings{ChrisMatthews2006ClusteredObjectsRCU
1531,author = {Matthews, Chris and Coady, Yvonne and Appavoo, Jonathan}
1532,title = {Portability events: a programming model for scalable system infrastructures}
1533,booktitle = {PLOS '06: Proceedings of the 3rd workshop on Programming languages and operating systems}
1534,year = {2006}
1535,isbn = {1-59593-577-0}
1536,pages = {11}
1537,location = {San Jose, California}
1538,doi = {http://doi.acm.org/10.1145/1215995.1216006}
1539,publisher = {ACM}
1540,address = {New York, NY, USA}
1541,annotation={
1542 Uses K42's RCU-like functionality to manage clustered-object
1543 lifetimes.
1544}}
1545
1546@article{DilmaDaSilva2006K42
1547,author = {Silva, Dilma Da and Krieger, Orran and Wisniewski, Robert W. and Waterland, Amos and Tam, David and Baumann, Andrew}
1548,title = {K42: an infrastructure for operating system research}
1549,journal = {SIGOPS Oper. Syst. Rev.}
1550,volume = {40}
1551,number = {2}
1552,year = {2006}
1553,issn = {0163-5980}
1554,pages = {34--42}
1555,doi = {http://doi.acm.org/10.1145/1131322.1131333}
1556,publisher = {ACM}
1557,address = {New York, NY, USA}
1558,annotation={
1559 Describes relationship of K42 generations to RCU.
1560}}
1561
1562# CoreyMinyard2007list_splice_rcu
1563@unpublished{CoreyMinyard2007list:splice:rcu
1564,Author="Corey Minyard and Paul E. McKenney"
1565,Title="{[PATCH]} add an {RCU} version of list splicing"
1566,month="January"
1567,year="2007"
1568,day=3
1569,note="Available:
1570\url{http://lkml.org/lkml/2007/1/3/112}
1571[Viewed May 28, 2007]"
1572,annotation="
1573 Patch for list_splice_rcu().
1574"
1575}
1576
1577@unpublished{PaulEMcKenney2007rcubarrier
1578,Author="Paul E. McKenney"
1579,Title="{RCU} and Unloadable Modules"
1580,month="January"
1581,day="14"
1582,year="2007"
1583,note="Available:
1584\url{http://lwn.net/Articles/217484/}
1585[Viewed November 22, 2007]"
1586,annotation="
1587 LWN article introducing the rcu_barrier() primitive.
1588"
1589}
1590
1591@unpublished{PeterZijlstra2007SyncBarrier
1592,Author="Peter Zijlstra and Ingo Molnar"
1593,Title="{[PATCH 3/7]} barrier: a scalable synchonisation barrier"
1594,month="January"
1595,year="2007"
1596,day=28
1597,note="Available:
1598\url{http://lkml.org/lkml/2007/1/28/34}
1599[Viewed March 27, 2008]"
1600,annotation="
1601 RCU-like implementation for frequent updaters and rare readers(!).
1602 Subsumed into QRCU. Maybe...
1603"
1604}
1605
1606@unpublished{PaulEMcKenney2007BoostRCU
1607,Author="Paul E. McKenney"
1608,Title="Priority-Boosting {RCU} Read-Side Critical Sections"
1609,month="February"
1610,day="5"
1611,year="2007"
1612,note="Available:
1613\url{http://lwn.net/Articles/220677/}
1614Revised:
1615\url{http://www.rdrop.com/users/paulmck/RCU/RCUbooststate.2007.04.16a.pdf}
1616[Viewed September 7, 2007]"
1617,annotation="
1618 LWN article introducing RCU priority boosting.
1619"
1620}
1621
1622@unpublished{PaulMcKenney2007QRCUpatch
1623,Author="Paul E. McKenney"
1624,Title="{[PATCH]} {QRCU} with lockless fastpath"
1625,month="February"
1626,year="2007"
1627,day=24
1628,note="Available:
1629\url{http://lkml.org/lkml/2007/2/25/18}
1630[Viewed March 27, 2008]"
1631,annotation="
1632 Patch for QRCU supplying lock-free fast path.
1633"
1634}
1635
1636@article{JonathanAppavoo2007K42RCU
1637,author = {Appavoo, Jonathan and Silva, Dilma Da and Krieger, Orran and Auslander, Marc and Ostrowski, Michal and Rosenburg, Bryan and Waterland, Amos and Wisniewski, Robert W. and Xenidis, Jimi and Stumm, Michael and Soares, Livio}
1638,title = {Experience distributing objects in an SMMP OS}
1639,journal = {ACM Trans. Comput. Syst.}
1640,volume = {25}
1641,number = {3}
1642,year = {2007}
1643,issn = {0734-2071}
1644,pages = {6/1--6/52}
1645,doi = {http://doi.acm.org/10.1145/1275517.1275518}
1646,publisher = {ACM}
1647,address = {New York, NY, USA}
1648,annotation={
1649 Role of RCU in K42.
1650}}
1651
1652@conference{RobertOlsson2007Trash
1653,Author="Robert Olsson and Stefan Nilsson"
1654,Title="{TRASH}: A dynamic {LC}-trie and hash data structure"
1655,booktitle="Workshop on High Performance Switching and Routing (HPSR'07)"
1656,month="May"
1657,year="2007"
1658,note="Available:
1659\url{http://ieeexplore.ieee.org/xpl/freeabs_all.jsp?arnumber=4281239}
1660[Viewed October 1, 2010]"
1661,annotation="
1662 RCU-protected dynamic trie-hash combination.
1663"
1664}
1665
1666@conference{PeterZijlstra2007ConcurrentPagecacheRCU
1667,Author="Peter Zijlstra"
1668,Title="Concurrent Pagecache"
1669,Booktitle="Linux Symposium"
1670,month="June"
651,year="2007" 1671,year="2007"
652,note="To appear in J. Parallel Distrib. Comput. 1672,address="Ottawa, Canada"
653 \url{doi=10.1016/j.jpdc.2007.04.010}" 1673,note="Available:
1674\url{http://ols.108.redhat.com/2007/Reprints/zijlstra-Reprint.pdf}
1675[Viewed April 14, 2008]"
1676,annotation="
1677 Page-cache modifications permitting RCU readers and concurrent
1678 updates.
1679"
1680}
1681
1682@unpublished{PaulEMcKenney2007whatisRCU
1683,Author="Paul E. McKenney"
1684,Title="What is {RCU}?"
1685,year="2007"
1686,month="07"
1687,note="Available:
1688\url{http://www.rdrop.com/users/paulmck/RCU/whatisRCU.html}
1689[Viewed July 6, 2007]"
654,annotation={ 1690,annotation={
655 Compares QSBR (AKA "classic RCU"), HPBR, EBR, and lock-free 1691 Describes RCU in Linux kernel.
656 reference counting. Journal version of ThomasEHart2006a.
657} 1692}
658} 1693}
659 1694
660@unpublished{PaulEMcKenney2007QRCUspin 1695@unpublished{PaulEMcKenney2007QRCUspin
661,Author="Paul E. McKenney" 1696,Author="Paul E. McKenney"
662,Title="Using Promela and Spin to verify parallel algorithms" 1697,Title="Using {Promela} and {Spin} to verify parallel algorithms"
663,month="August" 1698,month="August"
664,day="1" 1699,day="1"
665,year="2007" 1700,year="2007"
@@ -669,6 +1704,50 @@ Revised:
669,annotation=" 1704,annotation="
670 LWN article describing Promela and spin, and also using Oleg 1705 LWN article describing Promela and spin, and also using Oleg
671 Nesterov's QRCU as an example (with Paul McKenney's fastpath). 1706 Nesterov's QRCU as an example (with Paul McKenney's fastpath).
1707 Merged patch at: http://lkml.org/lkml/2007/2/25/18
1708"
1709}
1710
1711@unpublished{PaulEMcKenney2007WG21DDOatomics
1712,Author="Paul E. McKenney and Hans-J. Boehm and Lawrence Crowl"
1713,Title="C++ Data-Dependency Ordering: Atomics and Memory Model"
1714,month="August"
1715,day="3"
1716,year="2007"
1717,note="Preprint:
1718\url{http://open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2664.htm}
1719[Viewed December 7, 2009]"
1720,annotation="
1721 RCU for C++, parts 1 and 2.
1722"
1723}
1724
1725@unpublished{PaulEMcKenney2007WG21DDOannotation
1726,Author="Paul E. McKenney and Lawrence Crowl"
1727,Title="C++ Data-Dependency Ordering: Function Annotation"
1728,month="September"
1729,day="18"
1730,year="2008"
1731,note="Preprint:
1732\url{http://open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2782.htm}
1733[Viewed December 7, 2009]"
1734,annotation="
1735 RCU for C++, part 2, updated many times.
1736"
1737}
1738
1739@unpublished{PaulEMcKenney2007PreemptibleRCUPatch
1740,Author="Paul E. McKenney"
1741,Title="[PATCH RFC 0/9] {RCU}: Preemptible {RCU}"
1742,month="September"
1743,day="10"
1744,year="2007"
1745,note="Available:
1746\url{http://lkml.org/lkml/2007/9/10/213}
1747[Viewed October 25, 2007]"
1748,annotation="
1749 Final patch for preemptable RCU to -rt. (Later patches were
1750 to mainline, eventually incorporated.)
672" 1751"
673} 1752}
674 1753
@@ -686,10 +1765,46 @@ Revised:
686" 1765"
687} 1766}
688 1767
1768@article{ThomasEHart2007a
1769,Author="Thomas E. Hart and Paul E. McKenney and Angela Demke Brown and Jonathan Walpole"
1770,Title="Performance of memory reclamation for lockless synchronization"
1771,journal="J. Parallel Distrib. Comput."
1772,volume={67}
1773,number="12"
1774,year="2007"
1775,issn="0743-7315"
1776,pages="1270--1285"
1777,doi="http://dx.doi.org/10.1016/j.jpdc.2007.04.010"
1778,publisher="Academic Press, Inc."
1779,address="Orlando, FL, USA"
1780,annotation={
1781 Compares QSBR, HPBR, EBR, and lock-free reference counting.
1782 Journal version of ThomasEHart2006a.
1783}
1784}
1785
1786@unpublished{MathieuDesnoyers2007call:rcu:schedNeeded
1787,Author="Mathieu Desnoyers"
1788,Title="Re: [patch 1/2] {Linux} Kernel Markers - Support Multiple Probes"
1789,month="December"
1790,day="20"
1791,year="2007"
1792,note="Available:
1793\url{http://lkml.org/lkml/2007/12/20/244}
1794[Viewed March 27, 2008]"
1795,annotation="
1796 Request for call_rcu_sched() and rcu_barrier_sched().
1797"
1798}
1799
1800
689######################################################################## 1801########################################################################
690# 1802#
691# "What is RCU?" LWN series. 1803# "What is RCU?" LWN series.
692# 1804#
1805# http://lwn.net/Articles/262464/ (What is RCU, Fundamentally?)
1806# http://lwn.net/Articles/263130/ (What is RCU's Usage?)
1807# http://lwn.net/Articles/264090/ (What is RCU's API?)
693 1808
694@unpublished{PaulEMcKenney2007WhatIsRCUFundamentally 1809@unpublished{PaulEMcKenney2007WhatIsRCUFundamentally
695,Author="Paul E. McKenney and Jonathan Walpole" 1810,Author="Paul E. McKenney and Jonathan Walpole"
@@ -723,7 +1838,7 @@ Revised:
723 3. RCU is a Bulk Reference-Counting Mechanism 1838 3. RCU is a Bulk Reference-Counting Mechanism
724 4. RCU is a Poor Man's Garbage Collector 1839 4. RCU is a Poor Man's Garbage Collector
725 5. RCU is a Way of Providing Existence Guarantees 1840 5. RCU is a Way of Providing Existence Guarantees
726 6. RCU is a Way of Waiting for Things to Finish 1841 6. RCU is a Way of Waiting for Things to Finish
727" 1842"
728} 1843}
729 1844
@@ -747,20 +1862,96 @@ Revised:
747# 1862#
748######################################################################## 1863########################################################################
749 1864
1865
1866@unpublished{SteveRostedt2008dyntickRCUpatch
1867,Author="Steven Rostedt and Paul E. McKenney"
1868,Title="{[PATCH]} add support for dynamic ticks and preempt rcu"
1869,month="January"
1870,day="29"
1871,year="2008"
1872,note="Available:
1873\url{http://lkml.org/lkml/2008/1/29/208}
1874[Viewed March 27, 2008]"
1875,annotation="
1876 Patch that prevents preemptible RCU from unnecessarily waking
1877 up dynticks-idle CPUs.
1878"
1879}
1880
1881@unpublished{PaulEMcKenney2008LKMLDependencyOrdering
1882,Author="Paul E. McKenney"
1883,Title="Re: [PATCH 02/22 -v7] Add basic support for gcc profiler instrumentation"
1884,month="February"
1885,day="1"
1886,year="2008"
1887,note="Available:
1888\url{http://lkml.org/lkml/2008/2/2/255}
1889[Viewed October 18, 2008]"
1890,annotation="
1891 Explanation of compilers violating dependency ordering.
1892"
1893}
1894
1895@Conference{PaulEMcKenney2008Beijing
1896,Author="Paul E. McKenney"
1897,Title="Introducing Technology Into {Linux} Or:
1898Introducing your technology Into {Linux} will require introducing a
1899lot of {Linux} into your technology!!!"
1900,Booktitle="2008 Linux Developer Symposium - China"
1901,Publisher="OSS China"
1902,Month="February"
1903,Year="2008"
1904,Address="Beijing, China"
1905,note="Available:
1906\url{http://www.rdrop.com/users/paulmck/RCU/TechIntroLinux.2008.02.19a.pdf}
1907[Viewed August 12, 2008]"
1908}
1909
1910@unpublished{PaulEMcKenney2008dynticksRCU
1911,Author="Paul E. McKenney and Steven Rostedt"
1912,Title="Integrating and Validating dynticks and Preemptable RCU"
1913,month="April"
1914,day="24"
1915,year="2008"
1916,note="Available:
1917\url{http://lwn.net/Articles/279077/}
1918[Viewed April 24, 2008]"
1919,annotation="
1920 Describes use of Promela and Spin to validate (and fix!) the
1921 dynticks/RCU interface.
1922"
1923}
1924
750@article{DinakarGuniguntala2008IBMSysJ 1925@article{DinakarGuniguntala2008IBMSysJ
751,author="D. Guniguntala and P. E. McKenney and J. Triplett and J. Walpole" 1926,author="D. Guniguntala and P. E. McKenney and J. Triplett and J. Walpole"
752,title="The read-copy-update mechanism for supporting real-time applications on shared-memory multiprocessor systems with {Linux}" 1927,title="The read-copy-update mechanism for supporting real-time applications on shared-memory multiprocessor systems with {Linux}"
753,Year="2008" 1928,Year="2008"
754,Month="April" 1929,Month="April-June"
755,journal="IBM Systems Journal" 1930,journal="IBM Systems Journal"
756,volume="47" 1931,volume="47"
757,number="2" 1932,number="2"
758,pages="@@-@@" 1933,pages="221-236"
759,annotation=" 1934,annotation="
760 RCU, realtime RCU, sleepable RCU, performance. 1935 RCU, realtime RCU, sleepable RCU, performance.
761" 1936"
762} 1937}
763 1938
1939@unpublished{LaiJiangshan2008NewClassicAlgorithm
1940,Author="Lai Jiangshan"
1941,Title="[{RFC}][{PATCH}] rcu classic: new algorithm for callbacks-processing"
1942,month="June"
1943,day="3"
1944,year="2008"
1945,note="Available:
1946\url{http://lkml.org/lkml/2008/6/2/539}
1947[Viewed December 10, 2008]"
1948,annotation="
1949 Updated RCU classic algorithm. Introduced multi-tailed list
1950 for RCU callbacks and also pulling common code into
1951 __call_rcu().
1952"
1953}
1954
764@article{PaulEMcKenney2008RCUOSR 1955@article{PaulEMcKenney2008RCUOSR
765,author="Paul E. McKenney and Jonathan Walpole" 1956,author="Paul E. McKenney and Jonathan Walpole"
766,title="Introducing technology into the {Linux} kernel: a case study" 1957,title="Introducing technology into the {Linux} kernel: a case study"
@@ -778,6 +1969,52 @@ Revised:
778} 1969}
779} 1970}
780 1971
1972@unpublished{ManfredSpraul2008StateMachineRCU
1973,Author="Manfred Spraul"
1974,Title="[{RFC}, {PATCH}] state machine based rcu"
1975,month="August"
1976,day="21"
1977,year="2008"
1978,note="Available:
1979\url{http://lkml.org/lkml/2008/8/21/336}
1980[Viewed December 8, 2008]"
1981,annotation="
1982 State-based RCU. One key thing that this patch does is to
1983 separate the dynticks handling of NMIs and IRQs.
1984"
1985}
1986
1987@unpublished{ManfredSpraul2008dyntickIRQNMI
1988,Author="Manfred Spraul"
1989,Title="Re: [{RFC}, {PATCH}] v4 scalable classic {RCU} implementation"
1990,month="September"
1991,day="6"
1992,year="2008"
1993,note="Available:
1994\url{http://lkml.org/lkml/2008/9/6/86}
1995[Viewed December 8, 2008]"
1996,annotation="
1997 Manfred notes a fix required to my attempt to separate irq
1998 and NMI processing for hierarchical RCU's dynticks interface.
1999"
2000}
2001
2002@techreport{PaulEMcKenney2008cyclicRCU
2003,author="Paul E. McKenney"
2004,title="Efficient Support of Consistent Cyclic Search With Read-Copy Update"
2005,institution="US Patent and Trademark Office"
2006,address="Washington, DC"
2007,year="2008"
2008,number="US Patent 7,426,511"
2009,month="September"
2010,pages="23"
2011,annotation="
2012 Maintains an additional level of indirection to allow
2013 readers to confine themselves to the desired snapshot of the
2014 data structure. Only permits one update at a time.
2015"
2016}
2017
781@unpublished{PaulEMcKenney2008HierarchicalRCU 2018@unpublished{PaulEMcKenney2008HierarchicalRCU
782,Author="Paul E. McKenney" 2019,Author="Paul E. McKenney"
783,Title="Hierarchical {RCU}" 2020,Title="Hierarchical {RCU}"
@@ -793,6 +2030,21 @@ Revised:
793" 2030"
794} 2031}
795 2032
2033@unpublished{PaulEMcKenney2009BloatwatchRCU
2034,Author="Paul E. McKenney"
2035,Title="Re: [PATCH fyi] RCU: the bloatwatch edition"
2036,month="January"
2037,day="14"
2038,year="2009"
2039,note="Available:
2040\url{http://lkml.org/lkml/2009/1/14/449}
2041[Viewed January 15, 2009]"
2042,annotation="
2043 Small-footprint implementation of RCU for uniprocessor
2044 embedded applications -- and also for exposition purposes.
2045"
2046}
2047
796@conference{PaulEMcKenney2009MaliciousURCU 2048@conference{PaulEMcKenney2009MaliciousURCU
797,Author="Paul E. McKenney" 2049,Author="Paul E. McKenney"
798,Title="Using a Malicious User-Level {RCU} to Torture {RCU}-Based Algorithms" 2050,Title="Using a Malicious User-Level {RCU} to Torture {RCU}-Based Algorithms"
@@ -816,15 +2068,17 @@ Revised:
816,year="2009" 2068,year="2009"
817,note="Available: 2069,note="Available:
818\url{http://lkml.org/lkml/2009/2/5/572} 2070\url{http://lkml.org/lkml/2009/2/5/572}
819\url{git://lttng.org/userspace-rcu.git} 2071\url{http://lttng.org/urcu}
820[Viewed February 20, 2009]" 2072[Viewed February 20, 2009]"
821,annotation=" 2073,annotation="
822 Mathieu Desnoyers's user-space RCU implementation. 2074 Mathieu Desnoyers's user-space RCU implementation.
823 git://lttng.org/userspace-rcu.git 2075 git://lttng.org/userspace-rcu.git
2076 http://lttng.org/cgi-bin/gitweb.cgi?p=userspace-rcu.git
2077 http://lttng.org/urcu
824" 2078"
825} 2079}
826 2080
827@unpublished{PaulEMcKenney2009BloatWatchRCU 2081@unpublished{PaulEMcKenney2009LWNBloatWatchRCU
828,Author="Paul E. McKenney" 2082,Author="Paul E. McKenney"
829,Title="{RCU}: The {Bloatwatch} Edition" 2083,Title="{RCU}: The {Bloatwatch} Edition"
830,month="March" 2084,month="March"
@@ -852,14 +2106,29 @@ Revised:
852" 2106"
853} 2107}
854 2108
855@unpublished{JoshTriplett2009RPHash 2109@unpublished{PaulEMcKenney2009fastRTRCU
2110,Author="Paul E. McKenney"
2111,Title="[{PATCH} {RFC} -tip 0/4] {RCU} cleanups and simplified preemptable {RCU}"
2112,month="July"
2113,day="23"
2114,year="2009"
2115,note="Available:
2116\url{http://lkml.org/lkml/2009/7/23/294}
2117[Viewed August 15, 2009]"
2118,annotation="
2119 First posting of simple and fast preemptable RCU.
2120"
2121}
2122
2123@InProceedings{JoshTriplett2009RPHash
856,Author="Josh Triplett" 2124,Author="Josh Triplett"
857,Title="Scalable concurrent hash tables via relativistic programming" 2125,Title="Scalable concurrent hash tables via relativistic programming"
858,month="September" 2126,month="September"
859,year="2009" 2127,year="2009"
860,note="Linux Plumbers Conference presentation" 2128,booktitle="Linux Plumbers Conference 2009"
861,annotation=" 2129,annotation="
862 RP fun with hash tables. 2130 RP fun with hash tables.
2131 See also JoshTriplett2010RPHash
863" 2132"
864} 2133}
865 2134
@@ -872,4 +2141,323 @@ Revised:
872,note="Available: 2141,note="Available:
873\url{http://www.lttng.org/pub/thesis/desnoyers-dissertation-2009-12.pdf} 2142\url{http://www.lttng.org/pub/thesis/desnoyers-dissertation-2009-12.pdf}
874[Viewed December 9, 2009]" 2143[Viewed December 9, 2009]"
2144,annotation={
2145 Chapter 6 (page 97) covers user-level RCU.
2146}
2147}
2148
2149@unpublished{RelativisticProgrammingWiki
2150,Author="Josh Triplett and Paul E. McKenney and Jonathan Walpole"
2151,Title="Relativistic Programming"
2152,month="September"
2153,year="2009"
2154,note="Available:
2155\url{http://wiki.cs.pdx.edu/rp/}
2156[Viewed December 9, 2009]"
2157,annotation="
2158 Main Relativistic Programming Wiki.
2159"
2160}
2161
2162@conference{PaulEMcKenney2009DeterministicRCU
2163,Author="Paul E. McKenney"
2164,Title="Deterministic Synchronization in Multicore Systems: the Role of {RCU}"
2165,Booktitle="Eleventh Real Time Linux Workshop"
2166,month="September"
2167,year="2009"
2168,address="Dresden, Germany"
2169,note="Available:
2170\url{http://www.rdrop.com/users/paulmck/realtime/paper/DetSyncRCU.2009.08.18a.pdf}
2171[Viewed January 14, 2009]"
2172}
2173
2174@unpublished{PaulEMcKenney2009HuntingHeisenbugs
2175,Author="Paul E. McKenney"
2176,Title="Hunting Heisenbugs"
2177,month="November"
2178,year="2009"
2179,day="1"
2180,note="Available:
2181\url{http://paulmck.livejournal.com/14639.html}
2182[Viewed June 4, 2010]"
2183,annotation="
2184 Day-one bug in Tree RCU that took forever to track down.
2185"
2186}
2187
2188@unpublished{MathieuDesnoyers2009defer:rcu
2189,Author="Mathieu Desnoyers"
2190,Title="Kernel RCU: shrink the size of the struct rcu\_head"
2191,month="December"
2192,year="2009"
2193,note="Available:
2194\url{http://lkml.org/lkml/2009/10/18/129}
2195[Viewed December 29, 2009]"
2196,annotation="
2197 Mathieu proposed defer_rcu() with fixed-size per-thread pool
2198 of RCU callbacks.
2199"
2200}
2201
2202@unpublished{MathieuDesnoyers2009VerifPrePub
2203,Author="Mathieu Desnoyers and Paul E. McKenney and Michel R. Dagenais"
2204,Title="Multi-Core Systems Modeling for Formal Verification of Parallel Algorithms"
2205,month="December"
2206,year="2009"
2207,note="Submitted to IEEE TPDS"
2208,annotation="
2209 OOMem model for Mathieu's user-level RCU mechanical proof of
2210 correctness.
2211"
2212}
2213
2214@unpublished{MathieuDesnoyers2009URCUPrePub
2215,Author="Mathieu Desnoyers and Paul E. McKenney and Alan Stern and Michel R. Dagenais and Jonathan Walpole"
2216,Title="User-Level Implementations of Read-Copy Update"
2217,month="December"
2218,year="2010"
2219,url=\url{http://www.computer.org/csdl/trans/td/2012/02/ttd2012020375-abs.html}
2220,annotation="
2221 RCU overview, desiderata, semi-formal semantics, user-level RCU
2222 usage scenarios, three classes of RCU implementation, wait-free
2223 RCU updates, RCU grace-period batching, update overhead,
2224 http://www.rdrop.com/users/paulmck/RCU/urcu-main-accepted.2011.08.30a.pdf
2225 http://www.rdrop.com/users/paulmck/RCU/urcu-supp-accepted.2011.08.30a.pdf
2226 Superseded by MathieuDesnoyers2012URCU.
2227"
2228}
2229
2230@inproceedings{HariKannan2009DynamicAnalysisRCU
2231,author = {Kannan, Hari}
2232,title = {Ordering decoupled metadata accesses in multiprocessors}
2233,booktitle = {MICRO 42: Proceedings of the 42nd Annual IEEE/ACM International Symposium on Microarchitecture}
2234,year = {2009}
2235,isbn = {978-1-60558-798-1}
2236,pages = {381--390}
2237,location = {New York, New York}
2238,doi = {http://doi.acm.org/10.1145/1669112.1669161}
2239,publisher = {ACM}
2240,address = {New York, NY, USA}
2241,annotation={
2242 Uses RCU to protect metadata used in dynamic analysis.
2243}}
2244
2245@conference{PaulEMcKenney2010SimpleOptRCU
2246,Author="Paul E. McKenney"
2247,Title="Simplicity Through Optimization"
2248,Booktitle="linux.conf.au 2010"
2249,month="January"
2250,year="2010"
2251,address="Wellington, New Zealand"
2252,note="Available:
2253\url{http://www.rdrop.com/users/paulmck/RCU/SimplicityThruOptimization.2010.01.21f.pdf}
2254[Viewed October 10, 2010]"
2255,annotation="
2256 TREE_PREEMPT_RCU optimizations greatly simplified the old
2257 PREEMPT_RCU implementation.
2258"
2259}
2260
2261@unpublished{PaulEMcKenney2010LockdepRCU
2262,Author="Paul E. McKenney"
2263,Title="Lockdep-{RCU}"
2264,month="February"
2265,year="2010"
2266,day="1"
2267,note="Available:
2268\url{https://lwn.net/Articles/371986/}
2269[Viewed June 4, 2010]"
2270,annotation="
2271 CONFIG_PROVE_RCU, or at least an early version.
2272"
2273}
2274
2275@unpublished{AviKivity2010KVM2RCU
2276,Author="Avi Kivity"
2277,Title="[{PATCH} 37/40] {KVM}: Bump maximum vcpu count to 64"
2278,month="February"
2279,year="2010"
2280,note="Available:
2281\url{http://www.mail-archive.com/kvm@vger.kernel.org/msg28640.html}
2282[Viewed March 20, 2010]"
2283,annotation="
2284 Use of RCU permits KVM to increase the size of guest OSes from
2285 16 CPUs to 64 CPUs.
2286"
2287}
2288
2289@unpublished{HerbertXu2010RCUResizeHash
2290,Author="Herbert Xu"
2291,Title="bridge: Add core IGMP snooping support"
2292,month="February"
2293,year="2010"
2294,note="Available:
2295\url{http://kerneltrap.com/mailarchive/linux-netdev/2010/2/26/6270589}
2296[Viewed March 20, 2011]"
2297,annotation={
2298 Use a pair of list_head structures to support RCU-protected
2299 resizable hash tables.
2300}}
2301
2302@article{JoshTriplett2010RPHash
2303,author="Josh Triplett and Paul E. McKenney and Jonathan Walpole"
2304,title="Scalable Concurrent Hash Tables via Relativistic Programming"
2305,journal="ACM Operating Systems Review"
2306,year=2010
2307,volume=44
2308,number=3
2309,month="July"
2310,annotation={
2311 RP fun with hash tables.
2312 http://portal.acm.org/citation.cfm?id=1842733.1842750
2313}}
2314
2315@unpublished{PaulEMcKenney2010RCUAPI
2316,Author="Paul E. McKenney"
2317,Title="The {RCU} {API}, 2010 Edition"
2318,month="December"
2319,day="8"
2320,year="2010"
2321,note="Available:
2322\url{http://lwn.net/Articles/418853/}
2323[Viewed December 8, 2010]"
2324,annotation="
2325 Includes updated software-engineering features.
2326"
2327}
2328
2329@mastersthesis{AndrejPodzimek2010masters
2330,author="Andrej Podzimek"
2331,title="Read-Copy-Update for OpenSolaris"
2332,school="Charles University in Prague"
2333,year="2010"
2334,note="Available:
2335\url{https://andrej.podzimek.org/thesis.pdf}
2336[Viewed January 31, 2011]"
2337,annotation={
2338 Reviews RCU implementations and creates a few for OpenSolaris.
2339 Drives quiescent-state detection from RCU read-side primitives,
2340 in a manner roughly similar to that of Jim Houston.
2341}}
2342
2343@unpublished{LinusTorvalds2011Linux2:6:38:rc1:NPigginVFS
2344,Author="Linus Torvalds"
2345,Title="Linux 2.6.38-rc1"
2346,month="January"
2347,year="2011"
2348,note="Available:
2349\url{https://lkml.org/lkml/2011/1/18/322}
2350[Viewed March 4, 2011]"
2351,annotation={
2352 "The RCU-based name lookup is at the other end of the spectrum - the
2353 absolute anti-gimmick. It's some seriously good stuff, and gets rid of
2354 the last main global lock that really tends to hurt some kernel loads.
2355 The dentry lock is no longer a big serializing issue. What's really
2356 nice about it is that it actually improves performance a lot even for
2357 single-threaded loads (on an SMP kernel), because it gets rid of some
2358 of the most expensive parts of path component lookup, which was the
2359 d_lock on every component lookup. So I'm seeing improvements of 30-50%
2360 on some seriously pathname-lookup intensive loads."
2361}}
2362
2363@techreport{JoshTriplett2011RPScalableCorrectOrdering
2364,author = {Josh Triplett and Philip W. Howard and Paul E. McKenney and Jonathan Walpole}
2365,title = {Scalable Correct Memory Ordering via Relativistic Programming}
2366,year = {2011}
2367,number = {11-03}
2368,institution = {Portland State University}
2369,note = {\url{http://www.cs.pdx.edu/pdfs/tr1103.pdf}}
2370}
2371
2372@inproceedings{PhilHoward2011RCUTMRBTree
2373,author = {Philip W. Howard and Jonathan Walpole}
2374,title = {A Relativistic Enhancement to Software Transactional Memory}
2375,booktitle = {Proceedings of the 3rd USENIX conference on Hot topics in parallelism}
2376,series = {HotPar'11}
2377,year = {2011}
2378,location = {Berkeley, CA}
2379,pages = {1--6}
2380,numpages = {6}
2381,url = {http://www.usenix.org/event/hotpar11/tech/final_files/Howard.pdf}
2382,publisher = {USENIX Association}
2383,address = {Berkeley, CA, USA}
2384}
2385
2386@techreport{PaulEMcKenney2011cyclicparallelRCU
2387,author="Paul E. McKenney and Jonathan Walpole"
2388,title="Efficient Support of Consistent Cyclic Search With Read-Copy Update and Parallel Updates"
2389,institution="US Patent and Trademark Office"
2390,address="Washington, DC"
2391,year="2011"
2392,number="US Patent 7,953,778"
2393,month="May"
2394,pages="34"
2395,annotation="
2396 Maintains an array of generation numbers to track in-flight
2397 updates and keeps an additional level of indirection to allow
2398 readers to confine themselves to the desired snapshot of the
2399 data structure.
2400"
2401}
2402
2403@inproceedings{Triplett:2011:RPHash
2404,author = {Triplett, Josh and McKenney, Paul E. and Walpole, Jonathan}
2405,title = {Resizable, Scalable, Concurrent Hash Tables via Relativistic Programming}
2406,booktitle = {Proceedings of the 2011 USENIX Annual Technical Conference}
2407,month = {June}
2408,year = {2011}
2409,pages = {145--158}
2410,numpages = {14}
2411,url={http://www.usenix.org/event/atc11/tech/final_files/atc11_proceedings.pdf}
2412,publisher = {The USENIX Association}
2413,address = {Portland, OR USA}
2414}
2415
2416@unpublished{PaulEMcKenney2011RCU3.0trainwreck
2417,Author="Paul E. McKenney"
2418,Title="3.0 and {RCU:} what went wrong"
2419,month="July"
2420,day="27"
2421,year="2011"
2422,note="Available:
2423\url{http://lwn.net/Articles/453002/}
2424[Viewed July 27, 2011]"
2425,annotation="
2426 Analysis of the RCU trainwreck in Linux kernel 3.0.
2427"
2428}
2429
2430@unpublished{NeilBrown2011MeetTheLockers
2431,Author="Neil Brown"
2432,Title="Meet the Lockers"
2433,month="August"
2434,day="3"
2435,year="2011"
2436,note="Available:
2437\url{http://lwn.net/Articles/453685/}
2438[Viewed September 2, 2011]"
2439,annotation="
2440 The Locker family as an analogy for locking, reference counting,
2441 RCU, and seqlock.
2442"
2443}
2444
2445@article{MathieuDesnoyers2012URCU
2446,Author="Mathieu Desnoyers and Paul E. McKenney and Alan Stern and Michel R. Dagenais and Jonathan Walpole"
2447,Title="User-Level Implementations of Read-Copy Update"
2448,journal="IEEE Transactions on Parallel and Distributed Systems"
2449,volume={23}
2450,year="2012"
2451,issn="1045-9219"
2452,pages="375-382"
2453,doi="http://doi.ieeecomputersociety.org/10.1109/TPDS.2011.159"
2454,publisher="IEEE Computer Society"
2455,address="Los Alamitos, CA, USA"
2456,annotation={
2457 RCU overview, desiderata, semi-formal semantics, user-level RCU
2458 usage scenarios, three classes of RCU implementation, wait-free
2459 RCU updates, RCU grace-period batching, update overhead,
2460 http://www.rdrop.com/users/paulmck/RCU/urcu-main-accepted.2011.08.30a.pdf
2461 http://www.rdrop.com/users/paulmck/RCU/urcu-supp-accepted.2011.08.30a.pdf
2462}
875} 2463}
diff --git a/Documentation/RCU/checklist.txt b/Documentation/RCU/checklist.txt
index bff2d8be1e18..5c8d74968090 100644
--- a/Documentation/RCU/checklist.txt
+++ b/Documentation/RCU/checklist.txt
@@ -180,6 +180,20 @@ over a rather long period of time, but improvements are always welcome!
180 operations that would not normally be undertaken while a real-time 180 operations that would not normally be undertaken while a real-time
181 workload is running. 181 workload is running.
182 182
183 In particular, if you find yourself invoking one of the expedited
184 primitives repeatedly in a loop, please do everyone a favor:
185 Restructure your code so that it batches the updates, allowing
186 a single non-expedited primitive to cover the entire batch.
187 This will very likely be faster than the loop containing the
188 expedited primitive, and will be much much easier on the rest
189 of the system, especially to real-time workloads running on
190 the rest of the system.
191
192 In addition, it is illegal to call the expedited forms from
193 a CPU-hotplug notifier, or while holding a lock that is acquired
194 by a CPU-hotplug notifier. Failing to observe this restriction
195 will result in deadlock.
196
1837. If the updater uses call_rcu() or synchronize_rcu(), then the 1977. If the updater uses call_rcu() or synchronize_rcu(), then the
184 corresponding readers must use rcu_read_lock() and 198 corresponding readers must use rcu_read_lock() and
185 rcu_read_unlock(). If the updater uses call_rcu_bh() or 199 rcu_read_unlock(). If the updater uses call_rcu_bh() or
diff --git a/Documentation/RCU/stallwarn.txt b/Documentation/RCU/stallwarn.txt
index 083d88cbc089..523364e4e1f1 100644
--- a/Documentation/RCU/stallwarn.txt
+++ b/Documentation/RCU/stallwarn.txt
@@ -12,14 +12,38 @@ CONFIG_RCU_CPU_STALL_TIMEOUT
12 This kernel configuration parameter defines the period of time 12 This kernel configuration parameter defines the period of time
13 that RCU will wait from the beginning of a grace period until it 13 that RCU will wait from the beginning of a grace period until it
14 issues an RCU CPU stall warning. This time period is normally 14 issues an RCU CPU stall warning. This time period is normally
15 ten seconds. 15 sixty seconds.
16 16
17RCU_SECONDS_TILL_STALL_RECHECK 17 This configuration parameter may be changed at runtime via the
18 /sys/module/rcutree/parameters/rcu_cpu_stall_timeout, however
19 this parameter is checked only at the beginning of a cycle.
20 So if you are 30 seconds into a 70-second stall, setting this
21 sysfs parameter to (say) five will shorten the timeout for the
22 -next- stall, or the following warning for the current stall
23 (assuming the stall lasts long enough). It will not affect the
24 timing of the next warning for the current stall.
18 25
19 This macro defines the period of time that RCU will wait after 26 Stall-warning messages may be enabled and disabled completely via
20 issuing a stall warning until it issues another stall warning 27 /sys/module/rcutree/parameters/rcu_cpu_stall_suppress.
21 for the same stall. This time period is normally set to three 28
22 times the check interval plus thirty seconds. 29CONFIG_RCU_CPU_STALL_VERBOSE
30
31 This kernel configuration parameter causes the stall warning to
32 also dump the stacks of any tasks that are blocking the current
33 RCU-preempt grace period.
34
35RCU_CPU_STALL_INFO
36
37 This kernel configuration parameter causes the stall warning to
38 print out additional per-CPU diagnostic information, including
39 information on scheduling-clock ticks and RCU's idle-CPU tracking.
40
41RCU_STALL_DELAY_DELTA
42
43 Although the lockdep facility is extremely useful, it does add
44 some overhead. Therefore, under CONFIG_PROVE_RCU, the
45 RCU_STALL_DELAY_DELTA macro allows five extra seconds before
46 giving an RCU CPU stall warning message.
23 47
24RCU_STALL_RAT_DELAY 48RCU_STALL_RAT_DELAY
25 49
@@ -64,6 +88,54 @@ INFO: rcu_bh_state detected stalls on CPUs/tasks: { } (detected by 4, 2502 jiffi
64 88
65This is rare, but does happen from time to time in real life. 89This is rare, but does happen from time to time in real life.
66 90
91If the CONFIG_RCU_CPU_STALL_INFO kernel configuration parameter is set,
92more information is printed with the stall-warning message, for example:
93
94 INFO: rcu_preempt detected stall on CPU
95 0: (63959 ticks this GP) idle=241/3fffffffffffffff/0
96 (t=65000 jiffies)
97
98In kernels with CONFIG_RCU_FAST_NO_HZ, even more information is
99printed:
100
101 INFO: rcu_preempt detected stall on CPU
102 0: (64628 ticks this GP) idle=dd5/3fffffffffffffff/0 drain=0 . timer=-1
103 (t=65000 jiffies)
104
105The "(64628 ticks this GP)" indicates that this CPU has taken more
106than 64,000 scheduling-clock interrupts during the current stalled
107grace period. If the CPU was not yet aware of the current grace
108period (for example, if it was offline), then this part of the message
109indicates how many grace periods behind the CPU is.
110
111The "idle=" portion of the message prints the dyntick-idle state.
112The hex number before the first "/" is the low-order 12 bits of the
113dynticks counter, which will have an even-numbered value if the CPU is
114in dyntick-idle mode and an odd-numbered value otherwise. The hex
115number between the two "/"s is the value of the nesting, which will
116be a small positive number if in the idle loop and a very large positive
117number (as shown above) otherwise.
118
119For CONFIG_RCU_FAST_NO_HZ kernels, the "drain=0" indicates that the
120CPU is not in the process of trying to force itself into dyntick-idle
121state, the "." indicates that the CPU has not given up forcing RCU
122into dyntick-idle mode (it would be "H" otherwise), and the "timer=-1"
123indicates that the CPU has not recented forced RCU into dyntick-idle
124mode (it would otherwise indicate the number of microseconds remaining
125in this forced state).
126
127
128Multiple Warnings From One Stall
129
130If a stall lasts long enough, multiple stall-warning messages will be
131printed for it. The second and subsequent messages are printed at
132longer intervals, so that the time between (say) the first and second
133message will be about three times the interval between the beginning
134of the stall and the first message.
135
136
137What Causes RCU CPU Stall Warnings?
138
67So your kernel printed an RCU CPU stall warning. The next question is 139So your kernel printed an RCU CPU stall warning. The next question is
68"What caused it?" The following problems can result in RCU CPU stall 140"What caused it?" The following problems can result in RCU CPU stall
69warnings: 141warnings:
@@ -128,4 +200,5 @@ is occurring, which will usually be in the function nearest the top of
128that portion of the stack which remains the same from trace to trace. 200that portion of the stack which remains the same from trace to trace.
129If you can reliably trigger the stall, ftrace can be quite helpful. 201If you can reliably trigger the stall, ftrace can be quite helpful.
130 202
131RCU bugs can often be debugged with the help of CONFIG_RCU_TRACE. 203RCU bugs can often be debugged with the help of CONFIG_RCU_TRACE
204and with RCU's event tracing.
diff --git a/Documentation/RCU/torture.txt b/Documentation/RCU/torture.txt
index d67068d0d2b9..375d3fb71437 100644
--- a/Documentation/RCU/torture.txt
+++ b/Documentation/RCU/torture.txt
@@ -69,6 +69,13 @@ onoff_interval
69 CPU-hotplug operations regardless of what value is 69 CPU-hotplug operations regardless of what value is
70 specified for onoff_interval. 70 specified for onoff_interval.
71 71
72onoff_holdoff The number of seconds to wait until starting CPU-hotplug
73 operations. This would normally only be used when
74 rcutorture was built into the kernel and started
75 automatically at boot time, in which case it is useful
76 in order to avoid confusing boot-time code with CPUs
77 coming and going.
78
72shuffle_interval 79shuffle_interval
73 The number of seconds to keep the test threads affinitied 80 The number of seconds to keep the test threads affinitied
74 to a particular subset of the CPUs, defaults to 3 seconds. 81 to a particular subset of the CPUs, defaults to 3 seconds.
@@ -79,6 +86,24 @@ shutdown_secs The number of seconds to run the test before terminating
79 zero, which disables test termination and system shutdown. 86 zero, which disables test termination and system shutdown.
80 This capability is useful for automated testing. 87 This capability is useful for automated testing.
81 88
89stall_cpu The number of seconds that a CPU should be stalled while
90 within both an rcu_read_lock() and a preempt_disable().
91 This stall happens only once per rcutorture run.
92 If you need multiple stalls, use modprobe and rmmod to
93 repeatedly run rcutorture. The default for stall_cpu
94 is zero, which prevents rcutorture from stalling a CPU.
95
96 Note that attempts to rmmod rcutorture while the stall
97 is ongoing will hang, so be careful what value you
98 choose for this module parameter! In addition, too-large
99 values for stall_cpu might well induce failures and
100 warnings in other parts of the kernel. You have been
101 warned!
102
103stall_cpu_holdoff
104 The number of seconds to wait after rcutorture starts
105 before stalling a CPU. Defaults to 10 seconds.
106
82stat_interval The number of seconds between output of torture 107stat_interval The number of seconds between output of torture
83 statistics (via printk()). Regardless of the interval, 108 statistics (via printk()). Regardless of the interval,
84 statistics are printed when the module is unloaded. 109 statistics are printed when the module is unloaded.
@@ -271,11 +296,13 @@ The following script may be used to torture RCU:
271 #!/bin/sh 296 #!/bin/sh
272 297
273 modprobe rcutorture 298 modprobe rcutorture
274 sleep 100 299 sleep 3600
275 rmmod rcutorture 300 rmmod rcutorture
276 dmesg | grep torture: 301 dmesg | grep torture:
277 302
278The output can be manually inspected for the error flag of "!!!". 303The output can be manually inspected for the error flag of "!!!".
279One could of course create a more elaborate script that automatically 304One could of course create a more elaborate script that automatically
280checked for such errors. The "rmmod" command forces a "SUCCESS" or 305checked for such errors. The "rmmod" command forces a "SUCCESS",
281"FAILURE" indication to be printk()ed. 306"FAILURE", or "RCU_HOTPLUG" indication to be printk()ed. The first
307two are self-explanatory, while the last indicates that while there
308were no RCU failures, CPU-hotplug problems were detected.
diff --git a/Documentation/RCU/trace.txt b/Documentation/RCU/trace.txt
index 49587abfc2f7..f6f15ce39903 100644
--- a/Documentation/RCU/trace.txt
+++ b/Documentation/RCU/trace.txt
@@ -33,23 +33,23 @@ rcu/rcuboost:
33The output of "cat rcu/rcudata" looks as follows: 33The output of "cat rcu/rcudata" looks as follows:
34 34
35rcu_sched: 35rcu_sched:
36 0 c=20972 g=20973 pq=1 pgp=20973 qp=0 dt=545/1/0 df=50 of=0 ri=0 ql=163 qs=NRW. kt=0/W/0 ktl=ebc3 b=10 ci=153737 co=0 ca=0 36 0 c=20972 g=20973 pq=1 pgp=20973 qp=0 dt=545/1/0 df=50 of=0 ql=163 qs=NRW. kt=0/W/0 ktl=ebc3 b=10 ci=153737 co=0 ca=0
37 1 c=20972 g=20973 pq=1 pgp=20973 qp=0 dt=967/1/0 df=58 of=0 ri=0 ql=634 qs=NRW. kt=0/W/1 ktl=58c b=10 ci=191037 co=0 ca=0 37 1 c=20972 g=20973 pq=1 pgp=20973 qp=0 dt=967/1/0 df=58 of=0 ql=634 qs=NRW. kt=0/W/1 ktl=58c b=10 ci=191037 co=0 ca=0
38 2 c=20972 g=20973 pq=1 pgp=20973 qp=0 dt=1081/1/0 df=175 of=0 ri=0 ql=74 qs=N.W. kt=0/W/2 ktl=da94 b=10 ci=75991 co=0 ca=0 38 2 c=20972 g=20973 pq=1 pgp=20973 qp=0 dt=1081/1/0 df=175 of=0 ql=74 qs=N.W. kt=0/W/2 ktl=da94 b=10 ci=75991 co=0 ca=0
39 3 c=20942 g=20943 pq=1 pgp=20942 qp=1 dt=1846/0/0 df=404 of=0 ri=0 ql=0 qs=.... kt=0/W/3 ktl=d1cd b=10 ci=72261 co=0 ca=0 39 3 c=20942 g=20943 pq=1 pgp=20942 qp=1 dt=1846/0/0 df=404 of=0 ql=0 qs=.... kt=0/W/3 ktl=d1cd b=10 ci=72261 co=0 ca=0
40 4 c=20972 g=20973 pq=1 pgp=20973 qp=0 dt=369/1/0 df=83 of=0 ri=0 ql=48 qs=N.W. kt=0/W/4 ktl=e0e7 b=10 ci=128365 co=0 ca=0 40 4 c=20972 g=20973 pq=1 pgp=20973 qp=0 dt=369/1/0 df=83 of=0 ql=48 qs=N.W. kt=0/W/4 ktl=e0e7 b=10 ci=128365 co=0 ca=0
41 5 c=20972 g=20973 pq=1 pgp=20973 qp=0 dt=381/1/0 df=64 of=0 ri=0 ql=169 qs=NRW. kt=0/W/5 ktl=fb2f b=10 ci=164360 co=0 ca=0 41 5 c=20972 g=20973 pq=1 pgp=20973 qp=0 dt=381/1/0 df=64 of=0 ql=169 qs=NRW. kt=0/W/5 ktl=fb2f b=10 ci=164360 co=0 ca=0
42 6 c=20972 g=20973 pq=1 pgp=20973 qp=0 dt=1037/1/0 df=183 of=0 ri=0 ql=62 qs=N.W. kt=0/W/6 ktl=d2ad b=10 ci=65663 co=0 ca=0 42 6 c=20972 g=20973 pq=1 pgp=20973 qp=0 dt=1037/1/0 df=183 of=0 ql=62 qs=N.W. kt=0/W/6 ktl=d2ad b=10 ci=65663 co=0 ca=0
43 7 c=20897 g=20897 pq=1 pgp=20896 qp=0 dt=1572/0/0 df=382 of=0 ri=0 ql=0 qs=.... kt=0/W/7 ktl=cf15 b=10 ci=75006 co=0 ca=0 43 7 c=20897 g=20897 pq=1 pgp=20896 qp=0 dt=1572/0/0 df=382 of=0 ql=0 qs=.... kt=0/W/7 ktl=cf15 b=10 ci=75006 co=0 ca=0
44rcu_bh: 44rcu_bh:
45 0 c=1480 g=1480 pq=1 pgp=1480 qp=0 dt=545/1/0 df=6 of=0 ri=1 ql=0 qs=.... kt=0/W/0 ktl=ebc3 b=10 ci=0 co=0 ca=0 45 0 c=1480 g=1480 pq=1 pgp=1480 qp=0 dt=545/1/0 df=6 of=0 ql=0 qs=.... kt=0/W/0 ktl=ebc3 b=10 ci=0 co=0 ca=0
46 1 c=1480 g=1480 pq=1 pgp=1480 qp=0 dt=967/1/0 df=3 of=0 ri=1 ql=0 qs=.... kt=0/W/1 ktl=58c b=10 ci=151 co=0 ca=0 46 1 c=1480 g=1480 pq=1 pgp=1480 qp=0 dt=967/1/0 df=3 of=0 ql=0 qs=.... kt=0/W/1 ktl=58c b=10 ci=151 co=0 ca=0
47 2 c=1480 g=1480 pq=1 pgp=1480 qp=0 dt=1081/1/0 df=6 of=0 ri=1 ql=0 qs=.... kt=0/W/2 ktl=da94 b=10 ci=0 co=0 ca=0 47 2 c=1480 g=1480 pq=1 pgp=1480 qp=0 dt=1081/1/0 df=6 of=0 ql=0 qs=.... kt=0/W/2 ktl=da94 b=10 ci=0 co=0 ca=0
48 3 c=1480 g=1480 pq=1 pgp=1480 qp=0 dt=1846/0/0 df=8 of=0 ri=1 ql=0 qs=.... kt=0/W/3 ktl=d1cd b=10 ci=0 co=0 ca=0 48 3 c=1480 g=1480 pq=1 pgp=1480 qp=0 dt=1846/0/0 df=8 of=0 ql=0 qs=.... kt=0/W/3 ktl=d1cd b=10 ci=0 co=0 ca=0
49 4 c=1480 g=1480 pq=1 pgp=1480 qp=0 dt=369/1/0 df=6 of=0 ri=1 ql=0 qs=.... kt=0/W/4 ktl=e0e7 b=10 ci=0 co=0 ca=0 49 4 c=1480 g=1480 pq=1 pgp=1480 qp=0 dt=369/1/0 df=6 of=0 ql=0 qs=.... kt=0/W/4 ktl=e0e7 b=10 ci=0 co=0 ca=0
50 5 c=1480 g=1480 pq=1 pgp=1480 qp=0 dt=381/1/0 df=4 of=0 ri=1 ql=0 qs=.... kt=0/W/5 ktl=fb2f b=10 ci=0 co=0 ca=0 50 5 c=1480 g=1480 pq=1 pgp=1480 qp=0 dt=381/1/0 df=4 of=0 ql=0 qs=.... kt=0/W/5 ktl=fb2f b=10 ci=0 co=0 ca=0
51 6 c=1480 g=1480 pq=1 pgp=1480 qp=0 dt=1037/1/0 df=6 of=0 ri=1 ql=0 qs=.... kt=0/W/6 ktl=d2ad b=10 ci=0 co=0 ca=0 51 6 c=1480 g=1480 pq=1 pgp=1480 qp=0 dt=1037/1/0 df=6 of=0 ql=0 qs=.... kt=0/W/6 ktl=d2ad b=10 ci=0 co=0 ca=0
52 7 c=1474 g=1474 pq=1 pgp=1473 qp=0 dt=1572/0/0 df=8 of=0 ri=1 ql=0 qs=.... kt=0/W/7 ktl=cf15 b=10 ci=0 co=0 ca=0 52 7 c=1474 g=1474 pq=1 pgp=1473 qp=0 dt=1572/0/0 df=8 of=0 ql=0 qs=.... kt=0/W/7 ktl=cf15 b=10 ci=0 co=0 ca=0
53 53
54The first section lists the rcu_data structures for rcu_sched, the second 54The first section lists the rcu_data structures for rcu_sched, the second
55for rcu_bh. Note that CONFIG_TREE_PREEMPT_RCU kernels will have an 55for rcu_bh. Note that CONFIG_TREE_PREEMPT_RCU kernels will have an
@@ -119,10 +119,6 @@ o "of" is the number of times that some other CPU has forced a
119 CPU is offline when it is really alive and kicking) is a fatal 119 CPU is offline when it is really alive and kicking) is a fatal
120 error, so it makes sense to err conservatively. 120 error, so it makes sense to err conservatively.
121 121
122o "ri" is the number of times that RCU has seen fit to send a
123 reschedule IPI to this CPU in order to get it to report a
124 quiescent state.
125
126o "ql" is the number of RCU callbacks currently residing on 122o "ql" is the number of RCU callbacks currently residing on
127 this CPU. This is the total number of callbacks, regardless 123 this CPU. This is the total number of callbacks, regardless
128 of what state they are in (new, waiting for grace period to 124 of what state they are in (new, waiting for grace period to
diff --git a/Documentation/hwmon/w83627ehf b/Documentation/hwmon/w83627ehf
index 3f44dbdfda70..ceaf6f652b00 100644
--- a/Documentation/hwmon/w83627ehf
+++ b/Documentation/hwmon/w83627ehf
@@ -50,7 +50,7 @@ W83627DHG, W83627DHG-P, W83627UHG, W83667HG, W83667HG-B, W83667HG-I
50(NCT6775F), and NCT6776F super I/O chips. We will refer to them collectively 50(NCT6775F), and NCT6776F super I/O chips. We will refer to them collectively
51as Winbond chips. 51as Winbond chips.
52 52
53The chips implement 2 to 4 temperature sensors (9 for NCT6775F and NCT6776F), 53The chips implement 3 to 4 temperature sensors (9 for NCT6775F and NCT6776F),
542 to 5 fan rotation speed sensors, 8 to 10 analog voltage sensors, one VID 542 to 5 fan rotation speed sensors, 8 to 10 analog voltage sensors, one VID
55(except for 627UHG), alarms with beep warnings (control unimplemented), 55(except for 627UHG), alarms with beep warnings (control unimplemented),
56and some automatic fan regulation strategies (plus manual fan control mode). 56and some automatic fan regulation strategies (plus manual fan control mode).
@@ -143,8 +143,13 @@ pwm[1-4]_min_output - minimum fan speed (range 1 - 255), when the temperature
143pwm[1-4]_stop_time - how many milliseconds [ms] must elapse to switch 143pwm[1-4]_stop_time - how many milliseconds [ms] must elapse to switch
144 corresponding fan off. (when the temperature was below 144 corresponding fan off. (when the temperature was below
145 defined range). 145 defined range).
146pwm[1-4]_start_output-minimum fan speed (range 1 - 255) when spinning up
147pwm[1-4]_step_output- rate of fan speed change (1 - 255)
148pwm[1-4]_stop_output- minimum fan speed (range 1 - 255) when spinning down
149pwm[1-4]_max_output - maximum fan speed (range 1 - 255), when the temperature
150 is above defined range.
146 151
147Note: last two functions are influenced by other control bits, not yet exported 152Note: last six functions are influenced by other control bits, not yet exported
148 by the driver, so a change might not have any effect. 153 by the driver, so a change might not have any effect.
149 154
150Implementation Details 155Implementation Details
diff --git a/Documentation/hwmon/zl6100 b/Documentation/hwmon/zl6100
index 51f76a189fee..a4e8d90f59f6 100644
--- a/Documentation/hwmon/zl6100
+++ b/Documentation/hwmon/zl6100
@@ -88,14 +88,12 @@ Module parameters
88delay 88delay
89----- 89-----
90 90
91Some Intersil/Zilker Labs DC-DC controllers require a minimum interval between 91Intersil/Zilker Labs DC-DC controllers require a minimum interval between I2C
92I2C bus accesses. According to Intersil, the minimum interval is 2 ms, though 92bus accesses. According to Intersil, the minimum interval is 2 ms, though 1 ms
931 ms appears to be sufficient and has not caused any problems in testing. 93appears to be sufficient and has not caused any problems in testing. The problem
94The problem is known to affect ZL6100, ZL2105, and ZL2008. It is known not to 94is known to affect all currently supported chips. For manual override, the
95affect ZL2004 and ZL6105. The driver automatically sets the interval to 1 ms 95driver provides a writeable module parameter, 'delay', which can be used to set
96except for ZL2004 and ZL6105. To enable manual override, the driver provides a 96the interval to a value between 0 and 65,535 microseconds.
97writeable module parameter, 'delay', which can be used to set the interval to
98a value between 0 and 65,535 microseconds.
99 97
100 98
101Sysfs entries 99Sysfs entries
diff --git a/Documentation/lockup-watchdogs.txt b/Documentation/lockup-watchdogs.txt
new file mode 100644
index 000000000000..d2a36602ca8d
--- /dev/null
+++ b/Documentation/lockup-watchdogs.txt
@@ -0,0 +1,63 @@
1===============================================================
2Softlockup detector and hardlockup detector (aka nmi_watchdog)
3===============================================================
4
5The Linux kernel can act as a watchdog to detect both soft and hard
6lockups.
7
8A 'softlockup' is defined as a bug that causes the kernel to loop in
9kernel mode for more than 20 seconds (see "Implementation" below for
10details), without giving other tasks a chance to run. The current
11stack trace is displayed upon detection and, by default, the system
12will stay locked up. Alternatively, the kernel can be configured to
13panic; a sysctl, "kernel.softlockup_panic", a kernel parameter,
14"softlockup_panic" (see "Documentation/kernel-parameters.txt" for
15details), and a compile option, "BOOTPARAM_HARDLOCKUP_PANIC", are
16provided for this.
17
18A 'hardlockup' is defined as a bug that causes the CPU to loop in
19kernel mode for more than 10 seconds (see "Implementation" below for
20details), without letting other interrupts have a chance to run.
21Similarly to the softlockup case, the current stack trace is displayed
22upon detection and the system will stay locked up unless the default
23behavior is changed, which can be done through a compile time knob,
24"BOOTPARAM_HARDLOCKUP_PANIC", and a kernel parameter, "nmi_watchdog"
25(see "Documentation/kernel-parameters.txt" for details).
26
27The panic option can be used in combination with panic_timeout (this
28timeout is set through the confusingly named "kernel.panic" sysctl),
29to cause the system to reboot automatically after a specified amount
30of time.
31
32=== Implementation ===
33
34The soft and hard lockup detectors are built on top of the hrtimer and
35perf subsystems, respectively. A direct consequence of this is that,
36in principle, they should work in any architecture where these
37subsystems are present.
38
39A periodic hrtimer runs to generate interrupts and kick the watchdog
40task. An NMI perf event is generated every "watchdog_thresh"
41(compile-time initialized to 10 and configurable through sysctl of the
42same name) seconds to check for hardlockups. If any CPU in the system
43does not receive any hrtimer interrupt during that time the
44'hardlockup detector' (the handler for the NMI perf event) will
45generate a kernel warning or call panic, depending on the
46configuration.
47
48The watchdog task is a high priority kernel thread that updates a
49timestamp every time it is scheduled. If that timestamp is not updated
50for 2*watchdog_thresh seconds (the softlockup threshold) the
51'softlockup detector' (coded inside the hrtimer callback function)
52will dump useful debug information to the system log, after which it
53will call panic if it was instructed to do so or resume execution of
54other kernel code.
55
56The period of the hrtimer is 2*watchdog_thresh/5, which means it has
57two or three chances to generate an interrupt before the hardlockup
58detector kicks in.
59
60As explained above, a kernel knob is provided that allows
61administrators to configure the period of the hrtimer and the perf
62event. The right value for a particular environment is a trade-off
63between fast response to lockups and detection overhead.
diff --git a/Documentation/nmi_watchdog.txt b/Documentation/nmi_watchdog.txt
deleted file mode 100644
index bf9f80a98282..000000000000
--- a/Documentation/nmi_watchdog.txt
+++ /dev/null
@@ -1,83 +0,0 @@
1
2[NMI watchdog is available for x86 and x86-64 architectures]
3
4Is your system locking up unpredictably? No keyboard activity, just
5a frustrating complete hard lockup? Do you want to help us debugging
6such lockups? If all yes then this document is definitely for you.
7
8On many x86/x86-64 type hardware there is a feature that enables
9us to generate 'watchdog NMI interrupts'. (NMI: Non Maskable Interrupt
10which get executed even if the system is otherwise locked up hard).
11This can be used to debug hard kernel lockups. By executing periodic
12NMI interrupts, the kernel can monitor whether any CPU has locked up,
13and print out debugging messages if so.
14
15In order to use the NMI watchdog, you need to have APIC support in your
16kernel. For SMP kernels, APIC support gets compiled in automatically. For
17UP, enable either CONFIG_X86_UP_APIC (Processor type and features -> Local
18APIC support on uniprocessors) or CONFIG_X86_UP_IOAPIC (Processor type and
19features -> IO-APIC support on uniprocessors) in your kernel config.
20CONFIG_X86_UP_APIC is for uniprocessor machines without an IO-APIC.
21CONFIG_X86_UP_IOAPIC is for uniprocessor with an IO-APIC. [Note: certain
22kernel debugging options, such as Kernel Stack Meter or Kernel Tracer,
23may implicitly disable the NMI watchdog.]
24
25For x86-64, the needed APIC is always compiled in.
26
27Using local APIC (nmi_watchdog=2) needs the first performance register, so
28you can't use it for other purposes (such as high precision performance
29profiling.) However, at least oprofile and the perfctr driver disable the
30local APIC NMI watchdog automatically.
31
32To actually enable the NMI watchdog, use the 'nmi_watchdog=N' boot
33parameter. Eg. the relevant lilo.conf entry:
34
35 append="nmi_watchdog=1"
36
37For SMP machines and UP machines with an IO-APIC use nmi_watchdog=1.
38For UP machines without an IO-APIC use nmi_watchdog=2, this only works
39for some processor types. If in doubt, boot with nmi_watchdog=1 and
40check the NMI count in /proc/interrupts; if the count is zero then
41reboot with nmi_watchdog=2 and check the NMI count. If it is still
42zero then log a problem, you probably have a processor that needs to be
43added to the nmi code.
44
45A 'lockup' is the following scenario: if any CPU in the system does not
46execute the period local timer interrupt for more than 5 seconds, then
47the NMI handler generates an oops and kills the process. This
48'controlled crash' (and the resulting kernel messages) can be used to
49debug the lockup. Thus whenever the lockup happens, wait 5 seconds and
50the oops will show up automatically. If the kernel produces no messages
51then the system has crashed so hard (eg. hardware-wise) that either it
52cannot even accept NMI interrupts, or the crash has made the kernel
53unable to print messages.
54
55Be aware that when using local APIC, the frequency of NMI interrupts
56it generates, depends on the system load. The local APIC NMI watchdog,
57lacking a better source, uses the "cycles unhalted" event. As you may
58guess it doesn't tick when the CPU is in the halted state (which happens
59when the system is idle), but if your system locks up on anything but the
60"hlt" processor instruction, the watchdog will trigger very soon as the
61"cycles unhalted" event will happen every clock tick. If it locks up on
62"hlt", then you are out of luck -- the event will not happen at all and the
63watchdog won't trigger. This is a shortcoming of the local APIC watchdog
64-- unfortunately there is no "clock ticks" event that would work all the
65time. The I/O APIC watchdog is driven externally and has no such shortcoming.
66But its NMI frequency is much higher, resulting in a more significant hit
67to the overall system performance.
68
69On x86 nmi_watchdog is disabled by default so you have to enable it with
70a boot time parameter.
71
72It's possible to disable the NMI watchdog in run-time by writing "0" to
73/proc/sys/kernel/nmi_watchdog. Writing "1" to the same file will re-enable
74the NMI watchdog. Notice that you still need to use "nmi_watchdog=" parameter
75at boot time.
76
77NOTE: In kernels prior to 2.4.2-ac18 the NMI-oopser is enabled unconditionally
78on x86 SMP boxes.
79
80[ feel free to send bug reports, suggestions and patches to
81 Ingo Molnar <mingo@redhat.com> or the Linux SMP mailing
82 list at <linux-smp@vger.kernel.org> ]
83
diff --git a/Documentation/scheduler/sched-stats.txt b/Documentation/scheduler/sched-stats.txt
index 1cd5d51bc761..8259b34a66ae 100644
--- a/Documentation/scheduler/sched-stats.txt
+++ b/Documentation/scheduler/sched-stats.txt
@@ -38,7 +38,8 @@ First field is a sched_yield() statistic:
38 1) # of times sched_yield() was called 38 1) # of times sched_yield() was called
39 39
40Next three are schedule() statistics: 40Next three are schedule() statistics:
41 2) # of times we switched to the expired queue and reused it 41 2) This field is a legacy array expiration count field used in the O(1)
42 scheduler. We kept it for ABI compatibility, but it is always set to zero.
42 3) # of times schedule() was called 43 3) # of times schedule() was called
43 4) # of times schedule() left the processor idle 44 4) # of times schedule() left the processor idle
44 45
diff --git a/Documentation/static-keys.txt b/Documentation/static-keys.txt
new file mode 100644
index 000000000000..d93f3c00f245
--- /dev/null
+++ b/Documentation/static-keys.txt
@@ -0,0 +1,286 @@
1 Static Keys
2 -----------
3
4By: Jason Baron <jbaron@redhat.com>
5
60) Abstract
7
8Static keys allows the inclusion of seldom used features in
9performance-sensitive fast-path kernel code, via a GCC feature and a code
10patching technique. A quick example:
11
12 struct static_key key = STATIC_KEY_INIT_FALSE;
13
14 ...
15
16 if (static_key_false(&key))
17 do unlikely code
18 else
19 do likely code
20
21 ...
22 static_key_slow_inc();
23 ...
24 static_key_slow_inc();
25 ...
26
27The static_key_false() branch will be generated into the code with as little
28impact to the likely code path as possible.
29
30
311) Motivation
32
33
34Currently, tracepoints are implemented using a conditional branch. The
35conditional check requires checking a global variable for each tracepoint.
36Although the overhead of this check is small, it increases when the memory
37cache comes under pressure (memory cache lines for these global variables may
38be shared with other memory accesses). As we increase the number of tracepoints
39in the kernel this overhead may become more of an issue. In addition,
40tracepoints are often dormant (disabled) and provide no direct kernel
41functionality. Thus, it is highly desirable to reduce their impact as much as
42possible. Although tracepoints are the original motivation for this work, other
43kernel code paths should be able to make use of the static keys facility.
44
45
462) Solution
47
48
49gcc (v4.5) adds a new 'asm goto' statement that allows branching to a label:
50
51http://gcc.gnu.org/ml/gcc-patches/2009-07/msg01556.html
52
53Using the 'asm goto', we can create branches that are either taken or not taken
54by default, without the need to check memory. Then, at run-time, we can patch
55the branch site to change the branch direction.
56
57For example, if we have a simple branch that is disabled by default:
58
59 if (static_key_false(&key))
60 printk("I am the true branch\n");
61
62Thus, by default the 'printk' will not be emitted. And the code generated will
63consist of a single atomic 'no-op' instruction (5 bytes on x86), in the
64straight-line code path. When the branch is 'flipped', we will patch the
65'no-op' in the straight-line codepath with a 'jump' instruction to the
66out-of-line true branch. Thus, changing branch direction is expensive but
67branch selection is basically 'free'. That is the basic tradeoff of this
68optimization.
69
70This lowlevel patching mechanism is called 'jump label patching', and it gives
71the basis for the static keys facility.
72
733) Static key label API, usage and examples:
74
75
76In order to make use of this optimization you must first define a key:
77
78 struct static_key key;
79
80Which is initialized as:
81
82 struct static_key key = STATIC_KEY_INIT_TRUE;
83
84or:
85
86 struct static_key key = STATIC_KEY_INIT_FALSE;
87
88If the key is not initialized, it is default false. The 'struct static_key',
89must be a 'global'. That is, it can't be allocated on the stack or dynamically
90allocated at run-time.
91
92The key is then used in code as:
93
94 if (static_key_false(&key))
95 do unlikely code
96 else
97 do likely code
98
99Or:
100
101 if (static_key_true(&key))
102 do likely code
103 else
104 do unlikely code
105
106A key that is initialized via 'STATIC_KEY_INIT_FALSE', must be used in a
107'static_key_false()' construct. Likewise, a key initialized via
108'STATIC_KEY_INIT_TRUE' must be used in a 'static_key_true()' construct. A
109single key can be used in many branches, but all the branches must match the
110way that the key has been initialized.
111
112The branch(es) can then be switched via:
113
114 static_key_slow_inc(&key);
115 ...
116 static_key_slow_dec(&key);
117
118Thus, 'static_key_slow_inc()' means 'make the branch true', and
119'static_key_slow_dec()' means 'make the the branch false' with appropriate
120reference counting. For example, if the key is initialized true, a
121static_key_slow_dec(), will switch the branch to false. And a subsequent
122static_key_slow_inc(), will change the branch back to true. Likewise, if the
123key is initialized false, a 'static_key_slow_inc()', will change the branch to
124true. And then a 'static_key_slow_dec()', will again make the branch false.
125
126An example usage in the kernel is the implementation of tracepoints:
127
128 static inline void trace_##name(proto) \
129 { \
130 if (static_key_false(&__tracepoint_##name.key)) \
131 __DO_TRACE(&__tracepoint_##name, \
132 TP_PROTO(data_proto), \
133 TP_ARGS(data_args), \
134 TP_CONDITION(cond)); \
135 }
136
137Tracepoints are disabled by default, and can be placed in performance critical
138pieces of the kernel. Thus, by using a static key, the tracepoints can have
139absolutely minimal impact when not in use.
140
141
1424) Architecture level code patching interface, 'jump labels'
143
144
145There are a few functions and macros that architectures must implement in order
146to take advantage of this optimization. If there is no architecture support, we
147simply fall back to a traditional, load, test, and jump sequence.
148
149* select HAVE_ARCH_JUMP_LABEL, see: arch/x86/Kconfig
150
151* #define JUMP_LABEL_NOP_SIZE, see: arch/x86/include/asm/jump_label.h
152
153* __always_inline bool arch_static_branch(struct static_key *key), see:
154 arch/x86/include/asm/jump_label.h
155
156* void arch_jump_label_transform(struct jump_entry *entry, enum jump_label_type type),
157 see: arch/x86/kernel/jump_label.c
158
159* __init_or_module void arch_jump_label_transform_static(struct jump_entry *entry, enum jump_label_type type),
160 see: arch/x86/kernel/jump_label.c
161
162
163* struct jump_entry, see: arch/x86/include/asm/jump_label.h
164
165
1665) Static keys / jump label analysis, results (x86_64):
167
168
169As an example, let's add the following branch to 'getppid()', such that the
170system call now looks like:
171
172SYSCALL_DEFINE0(getppid)
173{
174 int pid;
175
176+ if (static_key_false(&key))
177+ printk("I am the true branch\n");
178
179 rcu_read_lock();
180 pid = task_tgid_vnr(rcu_dereference(current->real_parent));
181 rcu_read_unlock();
182
183 return pid;
184}
185
186The resulting instructions with jump labels generated by GCC is:
187
188ffffffff81044290 <sys_getppid>:
189ffffffff81044290: 55 push %rbp
190ffffffff81044291: 48 89 e5 mov %rsp,%rbp
191ffffffff81044294: e9 00 00 00 00 jmpq ffffffff81044299 <sys_getppid+0x9>
192ffffffff81044299: 65 48 8b 04 25 c0 b6 mov %gs:0xb6c0,%rax
193ffffffff810442a0: 00 00
194ffffffff810442a2: 48 8b 80 80 02 00 00 mov 0x280(%rax),%rax
195ffffffff810442a9: 48 8b 80 b0 02 00 00 mov 0x2b0(%rax),%rax
196ffffffff810442b0: 48 8b b8 e8 02 00 00 mov 0x2e8(%rax),%rdi
197ffffffff810442b7: e8 f4 d9 00 00 callq ffffffff81051cb0 <pid_vnr>
198ffffffff810442bc: 5d pop %rbp
199ffffffff810442bd: 48 98 cltq
200ffffffff810442bf: c3 retq
201ffffffff810442c0: 48 c7 c7 e3 54 98 81 mov $0xffffffff819854e3,%rdi
202ffffffff810442c7: 31 c0 xor %eax,%eax
203ffffffff810442c9: e8 71 13 6d 00 callq ffffffff8171563f <printk>
204ffffffff810442ce: eb c9 jmp ffffffff81044299 <sys_getppid+0x9>
205
206Without the jump label optimization it looks like:
207
208ffffffff810441f0 <sys_getppid>:
209ffffffff810441f0: 8b 05 8a 52 d8 00 mov 0xd8528a(%rip),%eax # ffffffff81dc9480 <key>
210ffffffff810441f6: 55 push %rbp
211ffffffff810441f7: 48 89 e5 mov %rsp,%rbp
212ffffffff810441fa: 85 c0 test %eax,%eax
213ffffffff810441fc: 75 27 jne ffffffff81044225 <sys_getppid+0x35>
214ffffffff810441fe: 65 48 8b 04 25 c0 b6 mov %gs:0xb6c0,%rax
215ffffffff81044205: 00 00
216ffffffff81044207: 48 8b 80 80 02 00 00 mov 0x280(%rax),%rax
217ffffffff8104420e: 48 8b 80 b0 02 00 00 mov 0x2b0(%rax),%rax
218ffffffff81044215: 48 8b b8 e8 02 00 00 mov 0x2e8(%rax),%rdi
219ffffffff8104421c: e8 2f da 00 00 callq ffffffff81051c50 <pid_vnr>
220ffffffff81044221: 5d pop %rbp
221ffffffff81044222: 48 98 cltq
222ffffffff81044224: c3 retq
223ffffffff81044225: 48 c7 c7 13 53 98 81 mov $0xffffffff81985313,%rdi
224ffffffff8104422c: 31 c0 xor %eax,%eax
225ffffffff8104422e: e8 60 0f 6d 00 callq ffffffff81715193 <printk>
226ffffffff81044233: eb c9 jmp ffffffff810441fe <sys_getppid+0xe>
227ffffffff81044235: 66 66 2e 0f 1f 84 00 data32 nopw %cs:0x0(%rax,%rax,1)
228ffffffff8104423c: 00 00 00 00
229
230Thus, the disable jump label case adds a 'mov', 'test' and 'jne' instruction
231vs. the jump label case just has a 'no-op' or 'jmp 0'. (The jmp 0, is patched
232to a 5 byte atomic no-op instruction at boot-time.) Thus, the disabled jump
233label case adds:
234
2356 (mov) + 2 (test) + 2 (jne) = 10 - 5 (5 byte jump 0) = 5 addition bytes.
236
237If we then include the padding bytes, the jump label code saves, 16 total bytes
238of instruction memory for this small fucntion. In this case the non-jump label
239function is 80 bytes long. Thus, we have have saved 20% of the instruction
240footprint. We can in fact improve this even further, since the 5-byte no-op
241really can be a 2-byte no-op since we can reach the branch with a 2-byte jmp.
242However, we have not yet implemented optimal no-op sizes (they are currently
243hard-coded).
244
245Since there are a number of static key API uses in the scheduler paths,
246'pipe-test' (also known as 'perf bench sched pipe') can be used to show the
247performance improvement. Testing done on 3.3.0-rc2:
248
249jump label disabled:
250
251 Performance counter stats for 'bash -c /tmp/pipe-test' (50 runs):
252
253 855.700314 task-clock # 0.534 CPUs utilized ( +- 0.11% )
254 200,003 context-switches # 0.234 M/sec ( +- 0.00% )
255 0 CPU-migrations # 0.000 M/sec ( +- 39.58% )
256 487 page-faults # 0.001 M/sec ( +- 0.02% )
257 1,474,374,262 cycles # 1.723 GHz ( +- 0.17% )
258 <not supported> stalled-cycles-frontend
259 <not supported> stalled-cycles-backend
260 1,178,049,567 instructions # 0.80 insns per cycle ( +- 0.06% )
261 208,368,926 branches # 243.507 M/sec ( +- 0.06% )
262 5,569,188 branch-misses # 2.67% of all branches ( +- 0.54% )
263
264 1.601607384 seconds time elapsed ( +- 0.07% )
265
266jump label enabled:
267
268 Performance counter stats for 'bash -c /tmp/pipe-test' (50 runs):
269
270 841.043185 task-clock # 0.533 CPUs utilized ( +- 0.12% )
271 200,004 context-switches # 0.238 M/sec ( +- 0.00% )
272 0 CPU-migrations # 0.000 M/sec ( +- 40.87% )
273 487 page-faults # 0.001 M/sec ( +- 0.05% )
274 1,432,559,428 cycles # 1.703 GHz ( +- 0.18% )
275 <not supported> stalled-cycles-frontend
276 <not supported> stalled-cycles-backend
277 1,175,363,994 instructions # 0.82 insns per cycle ( +- 0.04% )
278 206,859,359 branches # 245.956 M/sec ( +- 0.04% )
279 4,884,119 branch-misses # 2.36% of all branches ( +- 0.85% )
280
281 1.579384366 seconds time elapsed
282
283The percentage of saved branches is .7%, and we've saved 12% on
284'branch-misses'. This is where we would expect to get the most savings, since
285this optimization is about reducing the number of branches. In addition, we've
286saved .2% on instructions, and 2.8% on cycles and 1.4% on elapsed time.
diff --git a/Documentation/trace/ftrace.txt b/Documentation/trace/ftrace.txt
index 1ebc24cf9a55..6f51fed45f2d 100644
--- a/Documentation/trace/ftrace.txt
+++ b/Documentation/trace/ftrace.txt
@@ -226,6 +226,13 @@ Here is the list of current tracers that may be configured.
226 Traces and records the max latency that it takes for 226 Traces and records the max latency that it takes for
227 the highest priority task to get scheduled after 227 the highest priority task to get scheduled after
228 it has been woken up. 228 it has been woken up.
229 Traces all tasks as an average developer would expect.
230
231 "wakeup_rt"
232
233 Traces and records the max latency that it takes for just
234 RT tasks (as the current "wakeup" does). This is useful
235 for those interested in wake up timings of RT tasks.
229 236
230 "hw-branch-tracer" 237 "hw-branch-tracer"
231 238
diff --git a/MAINTAINERS b/MAINTAINERS
index 95e4e43a12b4..9c63a43ab63a 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -1513,19 +1513,23 @@ F: drivers/mtd/devices/block2mtd.c
1513 1513
1514BLUETOOTH DRIVERS 1514BLUETOOTH DRIVERS
1515M: Marcel Holtmann <marcel@holtmann.org> 1515M: Marcel Holtmann <marcel@holtmann.org>
1516M: "Gustavo F. Padovan" <padovan@profusion.mobi> 1516M: Gustavo Padovan <gustavo@padovan.org>
1517M: Johan Hedberg <johan.hedberg@gmail.com>
1517L: linux-bluetooth@vger.kernel.org 1518L: linux-bluetooth@vger.kernel.org
1518W: http://www.bluez.org/ 1519W: http://www.bluez.org/
1519T: git git://git.kernel.org/pub/scm/linux/kernel/git/padovan/bluetooth-2.6.git 1520T: git git://git.kernel.org/pub/scm/linux/kernel/git/padovan/bluetooth.git
1521T: git git://git.kernel.org/pub/scm/linux/kernel/git/jh/bluetooth.git
1520S: Maintained 1522S: Maintained
1521F: drivers/bluetooth/ 1523F: drivers/bluetooth/
1522 1524
1523BLUETOOTH SUBSYSTEM 1525BLUETOOTH SUBSYSTEM
1524M: Marcel Holtmann <marcel@holtmann.org> 1526M: Marcel Holtmann <marcel@holtmann.org>
1525M: "Gustavo F. Padovan" <padovan@profusion.mobi> 1527M: Gustavo Padovan <gustavo@padovan.org>
1528M: Johan Hedberg <johan.hedberg@gmail.com>
1526L: linux-bluetooth@vger.kernel.org 1529L: linux-bluetooth@vger.kernel.org
1527W: http://www.bluez.org/ 1530W: http://www.bluez.org/
1528T: git git://git.kernel.org/pub/scm/linux/kernel/git/padovan/bluetooth-2.6.git 1531T: git git://git.kernel.org/pub/scm/linux/kernel/git/padovan/bluetooth.git
1532T: git git://git.kernel.org/pub/scm/linux/kernel/git/jh/bluetooth.git
1529S: Maintained 1533S: Maintained
1530F: net/bluetooth/ 1534F: net/bluetooth/
1531F: include/net/bluetooth/ 1535F: include/net/bluetooth/
@@ -1717,6 +1721,14 @@ F: include/linux/can/error.h
1717F: include/linux/can/netlink.h 1721F: include/linux/can/netlink.h
1718F: include/linux/can/platform/ 1722F: include/linux/can/platform/
1719 1723
1724CAPABILITIES
1725M: Serge Hallyn <serge.hallyn@canonical.com>
1726L: linux-security-module@vger.kernel.org
1727S: Supported
1728F: include/linux/capability.h
1729F: security/capability.c
1730F: security/commoncap.c
1731
1720CELL BROADBAND ENGINE ARCHITECTURE 1732CELL BROADBAND ENGINE ARCHITECTURE
1721M: Arnd Bergmann <arnd@arndb.de> 1733M: Arnd Bergmann <arnd@arndb.de>
1722L: linuxppc-dev@lists.ozlabs.org 1734L: linuxppc-dev@lists.ozlabs.org
@@ -2351,6 +2363,15 @@ S: Supported
2351F: drivers/gpu/drm/exynos 2363F: drivers/gpu/drm/exynos
2352F: include/drm/exynos* 2364F: include/drm/exynos*
2353 2365
2366EXYNOS MIPI DISPLAY DRIVERS
2367M: Inki Dae <inki.dae@samsung.com>
2368M: Donghwa Lee <dh09.lee@samsung.com>
2369M: Kyungmin Park <kyungmin.park@samsung.com>
2370L: linux-fbdev@vger.kernel.org
2371S: Maintained
2372F: drivers/video/exynos/exynos_mipi*
2373F: include/video/exynos_mipi*
2374
2354DSCC4 DRIVER 2375DSCC4 DRIVER
2355M: Francois Romieu <romieu@fr.zoreil.com> 2376M: Francois Romieu <romieu@fr.zoreil.com>
2356L: netdev@vger.kernel.org 2377L: netdev@vger.kernel.org
@@ -5859,6 +5880,7 @@ F: drivers/mmc/host/sdhci-s3c.c
5859 5880
5860SECURE DIGITAL HOST CONTROLLER INTERFACE (SDHCI) ST SPEAR DRIVER 5881SECURE DIGITAL HOST CONTROLLER INTERFACE (SDHCI) ST SPEAR DRIVER
5861M: Viresh Kumar <viresh.kumar@st.com> 5882M: Viresh Kumar <viresh.kumar@st.com>
5883L: spear-devel@list.st.com
5862L: linux-mmc@vger.kernel.org 5884L: linux-mmc@vger.kernel.org
5863S: Maintained 5885S: Maintained
5864F: drivers/mmc/host/sdhci-spear.c 5886F: drivers/mmc/host/sdhci-spear.c
@@ -6201,24 +6223,32 @@ F: drivers/tty/serial/sunzilog.h
6201 6223
6202SPEAR PLATFORM SUPPORT 6224SPEAR PLATFORM SUPPORT
6203M: Viresh Kumar <viresh.kumar@st.com> 6225M: Viresh Kumar <viresh.kumar@st.com>
6226L: spear-devel@list.st.com
6227L: linux-arm-kernel@lists.infradead.org (moderated for non-subscribers)
6204W: http://www.st.com/spear 6228W: http://www.st.com/spear
6205S: Maintained 6229S: Maintained
6206F: arch/arm/plat-spear/ 6230F: arch/arm/plat-spear/
6207 6231
6208SPEAR3XX MACHINE SUPPORT 6232SPEAR3XX MACHINE SUPPORT
6209M: Viresh Kumar <viresh.kumar@st.com> 6233M: Viresh Kumar <viresh.kumar@st.com>
6234L: spear-devel@list.st.com
6235L: linux-arm-kernel@lists.infradead.org (moderated for non-subscribers)
6210W: http://www.st.com/spear 6236W: http://www.st.com/spear
6211S: Maintained 6237S: Maintained
6212F: arch/arm/mach-spear3xx/ 6238F: arch/arm/mach-spear3xx/
6213 6239
6214SPEAR6XX MACHINE SUPPORT 6240SPEAR6XX MACHINE SUPPORT
6215M: Rajeev Kumar <rajeev-dlh.kumar@st.com> 6241M: Rajeev Kumar <rajeev-dlh.kumar@st.com>
6242L: spear-devel@list.st.com
6243L: linux-arm-kernel@lists.infradead.org (moderated for non-subscribers)
6216W: http://www.st.com/spear 6244W: http://www.st.com/spear
6217S: Maintained 6245S: Maintained
6218F: arch/arm/mach-spear6xx/ 6246F: arch/arm/mach-spear6xx/
6219 6247
6220SPEAR CLOCK FRAMEWORK SUPPORT 6248SPEAR CLOCK FRAMEWORK SUPPORT
6221M: Viresh Kumar <viresh.kumar@st.com> 6249M: Viresh Kumar <viresh.kumar@st.com>
6250L: spear-devel@list.st.com
6251L: linux-arm-kernel@lists.infradead.org (moderated for non-subscribers)
6222W: http://www.st.com/spear 6252W: http://www.st.com/spear
6223S: Maintained 6253S: Maintained
6224F: arch/arm/mach-spear*/clock.c 6254F: arch/arm/mach-spear*/clock.c
@@ -6227,6 +6257,8 @@ F: arch/arm/plat-spear/include/plat/clock.h
6227 6257
6228SPEAR PAD MULTIPLEXING SUPPORT 6258SPEAR PAD MULTIPLEXING SUPPORT
6229M: Viresh Kumar <viresh.kumar@st.com> 6259M: Viresh Kumar <viresh.kumar@st.com>
6260L: spear-devel@list.st.com
6261L: linux-arm-kernel@lists.infradead.org (moderated for non-subscribers)
6230W: http://www.st.com/spear 6262W: http://www.st.com/spear
6231S: Maintained 6263S: Maintained
6232F: arch/arm/plat-spear/include/plat/padmux.h 6264F: arch/arm/plat-spear/include/plat/padmux.h
diff --git a/Makefile b/Makefile
index 56d481727c30..1932984478c1 100644
--- a/Makefile
+++ b/Makefile
@@ -1,7 +1,7 @@
1VERSION = 3 1VERSION = 3
2PATCHLEVEL = 3 2PATCHLEVEL = 3
3SUBLEVEL = 0 3SUBLEVEL = 0
4EXTRAVERSION = -rc7 4EXTRAVERSION =
5NAME = Saber-toothed Squirrel 5NAME = Saber-toothed Squirrel
6 6
7# *DOCUMENTATION* 7# *DOCUMENTATION*
diff --git a/arch/Kconfig b/arch/Kconfig
index 4f55c736be11..5b448a74d0f7 100644
--- a/arch/Kconfig
+++ b/arch/Kconfig
@@ -47,18 +47,29 @@ config KPROBES
47 If in doubt, say "N". 47 If in doubt, say "N".
48 48
49config JUMP_LABEL 49config JUMP_LABEL
50 bool "Optimize trace point call sites" 50 bool "Optimize very unlikely/likely branches"
51 depends on HAVE_ARCH_JUMP_LABEL 51 depends on HAVE_ARCH_JUMP_LABEL
52 help 52 help
53 This option enables a transparent branch optimization that
54 makes certain almost-always-true or almost-always-false branch
55 conditions even cheaper to execute within the kernel.
56
57 Certain performance-sensitive kernel code, such as trace points,
58 scheduler functionality, networking code and KVM have such
59 branches and include support for this optimization technique.
60
53 If it is detected that the compiler has support for "asm goto", 61 If it is detected that the compiler has support for "asm goto",
54 the kernel will compile trace point locations with just a 62 the kernel will compile such branches with just a nop
55 nop instruction. When trace points are enabled, the nop will 63 instruction. When the condition flag is toggled to true, the
56 be converted to a jump to the trace function. This technique 64 nop will be converted to a jump instruction to execute the
57 lowers overhead and stress on the branch prediction of the 65 conditional block of instructions.
58 processor. 66
59 67 This technique lowers overhead and stress on the branch prediction
60 On i386, options added to the compiler flags may increase 68 of the processor and generally makes the kernel faster. The update
61 the size of the kernel slightly. 69 of the condition is slower, but those are always very rare.
70
71 ( On 32-bit x86, the necessary options added to the compiler
72 flags may increase the size of the kernel slightly. )
62 73
63config OPTPROBES 74config OPTPROBES
64 def_bool y 75 def_bool y
diff --git a/arch/alpha/kernel/perf_event.c b/arch/alpha/kernel/perf_event.c
index 8143cd7cdbfb..0dae252f7a33 100644
--- a/arch/alpha/kernel/perf_event.c
+++ b/arch/alpha/kernel/perf_event.c
@@ -685,6 +685,10 @@ static int alpha_pmu_event_init(struct perf_event *event)
685{ 685{
686 int err; 686 int err;
687 687
688 /* does not support taken branch sampling */
689 if (has_branch_stack(event))
690 return -EOPNOTSUPP;
691
688 switch (event->attr.type) { 692 switch (event->attr.type) {
689 case PERF_TYPE_RAW: 693 case PERF_TYPE_RAW:
690 case PERF_TYPE_HARDWARE: 694 case PERF_TYPE_HARDWARE:
diff --git a/arch/arm/include/asm/perf_event.h b/arch/arm/include/asm/perf_event.h
index 99cfe3607989..7523340afb8a 100644
--- a/arch/arm/include/asm/perf_event.h
+++ b/arch/arm/include/asm/perf_event.h
@@ -12,10 +12,6 @@
12#ifndef __ARM_PERF_EVENT_H__ 12#ifndef __ARM_PERF_EVENT_H__
13#define __ARM_PERF_EVENT_H__ 13#define __ARM_PERF_EVENT_H__
14 14
15/* ARM performance counters start from 1 (in the cp15 accesses) so use the
16 * same indexes here for consistency. */
17#define PERF_EVENT_INDEX_OFFSET 1
18
19/* ARM perf PMU IDs for use by internal perf clients. */ 15/* ARM perf PMU IDs for use by internal perf clients. */
20enum arm_perf_pmu_ids { 16enum arm_perf_pmu_ids {
21 ARM_PERF_PMU_ID_XSCALE1 = 0, 17 ARM_PERF_PMU_ID_XSCALE1 = 0,
diff --git a/arch/arm/kernel/perf_event.c b/arch/arm/kernel/perf_event.c
index b2abfa18f137..8a89d3b7626b 100644
--- a/arch/arm/kernel/perf_event.c
+++ b/arch/arm/kernel/perf_event.c
@@ -539,6 +539,10 @@ static int armpmu_event_init(struct perf_event *event)
539 int err = 0; 539 int err = 0;
540 atomic_t *active_events = &armpmu->active_events; 540 atomic_t *active_events = &armpmu->active_events;
541 541
542 /* does not support taken branch sampling */
543 if (has_branch_stack(event))
544 return -EOPNOTSUPP;
545
542 if (armpmu->map_event(event) == -ENOENT) 546 if (armpmu->map_event(event) == -ENOENT)
543 return -ENOENT; 547 return -ENOENT;
544 548
diff --git a/arch/arm/kernel/process.c b/arch/arm/kernel/process.c
index 971d65c253a9..c2ae3cd331fe 100644
--- a/arch/arm/kernel/process.c
+++ b/arch/arm/kernel/process.c
@@ -239,9 +239,7 @@ void cpu_idle(void)
239 leds_event(led_idle_end); 239 leds_event(led_idle_end);
240 rcu_idle_exit(); 240 rcu_idle_exit();
241 tick_nohz_idle_exit(); 241 tick_nohz_idle_exit();
242 preempt_enable_no_resched(); 242 schedule_preempt_disabled();
243 schedule();
244 preempt_disable();
245 } 243 }
246} 244}
247 245
diff --git a/arch/arm/kernel/smp.c b/arch/arm/kernel/smp.c
index cdeb727527d3..d616ed51e7a7 100644
--- a/arch/arm/kernel/smp.c
+++ b/arch/arm/kernel/smp.c
@@ -295,13 +295,6 @@ asmlinkage void __cpuinit secondary_start_kernel(void)
295 */ 295 */
296 percpu_timer_setup(); 296 percpu_timer_setup();
297 297
298 while (!cpu_active(cpu))
299 cpu_relax();
300
301 /*
302 * cpu_active bit is set, so it's safe to enalbe interrupts
303 * now.
304 */
305 local_irq_enable(); 298 local_irq_enable();
306 local_fiq_enable(); 299 local_fiq_enable();
307 300
diff --git a/arch/avr32/kernel/process.c b/arch/avr32/kernel/process.c
index ea3395750324..92c5af98a6f7 100644
--- a/arch/avr32/kernel/process.c
+++ b/arch/avr32/kernel/process.c
@@ -40,9 +40,7 @@ void cpu_idle(void)
40 cpu_idle_sleep(); 40 cpu_idle_sleep();
41 rcu_idle_exit(); 41 rcu_idle_exit();
42 tick_nohz_idle_exit(); 42 tick_nohz_idle_exit();
43 preempt_enable_no_resched(); 43 schedule_preempt_disabled();
44 schedule();
45 preempt_disable();
46 } 44 }
47} 45}
48 46
diff --git a/arch/blackfin/kernel/process.c b/arch/blackfin/kernel/process.c
index 8dd0416673cb..a80a643f3691 100644
--- a/arch/blackfin/kernel/process.c
+++ b/arch/blackfin/kernel/process.c
@@ -94,9 +94,7 @@ void cpu_idle(void)
94 idle(); 94 idle();
95 rcu_idle_exit(); 95 rcu_idle_exit();
96 tick_nohz_idle_exit(); 96 tick_nohz_idle_exit();
97 preempt_enable_no_resched(); 97 schedule_preempt_disabled();
98 schedule();
99 preempt_disable();
100 } 98 }
101} 99}
102 100
diff --git a/arch/c6x/kernel/entry.S b/arch/c6x/kernel/entry.S
index 3e977ccda827..30b37e5f4a61 100644
--- a/arch/c6x/kernel/entry.S
+++ b/arch/c6x/kernel/entry.S
@@ -717,33 +717,6 @@ ENTRY(sys_ftruncate64_c6x)
717#endif 717#endif
718ENDPROC(sys_ftruncate64_c6x) 718ENDPROC(sys_ftruncate64_c6x)
719 719
720#ifdef __ARCH_WANT_SYSCALL_OFF_T
721;; On Entry
722;; A4 - fd
723;; B4 - offset_lo (LE), offset_hi (BE)
724;; A6 - offset_lo (BE), offset_hi (LE)
725;; B6 - len
726;; A8 - advice
727ENTRY(sys_fadvise64_c6x)
728#ifdef CONFIG_C6X_BIG_KERNEL
729 MVKL .S1 sys_fadvise64,A0
730 MVKH .S1 sys_fadvise64,A0
731 BNOP .S2X A0,2
732#else
733 B .S2 sys_fadvise64
734 NOP 2
735#endif
736#ifdef CONFIG_CPU_BIG_ENDIAN
737 MV .L2 B4,B5
738 || MV .D2X A6,B4
739#else
740 MV .D2X A6,B5
741#endif
742 MV .D1X B6,A6
743 MV .D2X A8,B6
744#endif
745ENDPROC(sys_fadvise64_c6x)
746
747;; On Entry 720;; On Entry
748;; A4 - fd 721;; A4 - fd
749;; B4 - offset_lo (LE), offset_hi (BE) 722;; B4 - offset_lo (LE), offset_hi (BE)
diff --git a/arch/cris/kernel/process.c b/arch/cris/kernel/process.c
index aa585e4e979e..d8f50ff6fadd 100644
--- a/arch/cris/kernel/process.c
+++ b/arch/cris/kernel/process.c
@@ -115,9 +115,7 @@ void cpu_idle (void)
115 idle = default_idle; 115 idle = default_idle;
116 idle(); 116 idle();
117 } 117 }
118 preempt_enable_no_resched(); 118 schedule_preempt_disabled();
119 schedule();
120 preempt_disable();
121 } 119 }
122} 120}
123 121
diff --git a/arch/frv/include/asm/perf_event.h b/arch/frv/include/asm/perf_event.h
index a69e0155d146..c52ea5546b5b 100644
--- a/arch/frv/include/asm/perf_event.h
+++ b/arch/frv/include/asm/perf_event.h
@@ -12,6 +12,4 @@
12#ifndef _ASM_PERF_EVENT_H 12#ifndef _ASM_PERF_EVENT_H
13#define _ASM_PERF_EVENT_H 13#define _ASM_PERF_EVENT_H
14 14
15#define PERF_EVENT_INDEX_OFFSET 0
16
17#endif /* _ASM_PERF_EVENT_H */ 15#endif /* _ASM_PERF_EVENT_H */
diff --git a/arch/frv/kernel/process.c b/arch/frv/kernel/process.c
index 3901df1213c0..29cc49783787 100644
--- a/arch/frv/kernel/process.c
+++ b/arch/frv/kernel/process.c
@@ -92,9 +92,7 @@ void cpu_idle(void)
92 idle(); 92 idle();
93 } 93 }
94 94
95 preempt_enable_no_resched(); 95 schedule_preempt_disabled();
96 schedule();
97 preempt_disable();
98 } 96 }
99} 97}
100 98
diff --git a/arch/h8300/kernel/process.c b/arch/h8300/kernel/process.c
index 933bd388efb2..1a173b35f475 100644
--- a/arch/h8300/kernel/process.c
+++ b/arch/h8300/kernel/process.c
@@ -81,9 +81,7 @@ void cpu_idle(void)
81 while (1) { 81 while (1) {
82 while (!need_resched()) 82 while (!need_resched())
83 idle(); 83 idle();
84 preempt_enable_no_resched(); 84 schedule_preempt_disabled();
85 schedule();
86 preempt_disable();
87 } 85 }
88} 86}
89 87
diff --git a/arch/hexagon/include/asm/perf_event.h b/arch/hexagon/include/asm/perf_event.h
index 6c2910f91180..8b8526b491c7 100644
--- a/arch/hexagon/include/asm/perf_event.h
+++ b/arch/hexagon/include/asm/perf_event.h
@@ -19,6 +19,4 @@
19#ifndef _ASM_PERF_EVENT_H 19#ifndef _ASM_PERF_EVENT_H
20#define _ASM_PERF_EVENT_H 20#define _ASM_PERF_EVENT_H
21 21
22#define PERF_EVENT_INDEX_OFFSET 0
23
24#endif /* _ASM_PERF_EVENT_H */ 22#endif /* _ASM_PERF_EVENT_H */
diff --git a/arch/hexagon/kernel/smp.c b/arch/hexagon/kernel/smp.c
index c871a2cffaef..0123c63e9a3a 100644
--- a/arch/hexagon/kernel/smp.c
+++ b/arch/hexagon/kernel/smp.c
@@ -179,8 +179,6 @@ void __cpuinit start_secondary(void)
179 printk(KERN_INFO "%s cpu %d\n", __func__, current_thread_info()->cpu); 179 printk(KERN_INFO "%s cpu %d\n", __func__, current_thread_info()->cpu);
180 180
181 set_cpu_online(cpu, true); 181 set_cpu_online(cpu, true);
182 while (!cpumask_test_cpu(cpu, cpu_active_mask))
183 cpu_relax();
184 local_irq_enable(); 182 local_irq_enable();
185 183
186 cpu_idle(); 184 cpu_idle();
diff --git a/arch/ia64/include/asm/paravirt.h b/arch/ia64/include/asm/paravirt.h
index 32551d304cd7..b149b88ea795 100644
--- a/arch/ia64/include/asm/paravirt.h
+++ b/arch/ia64/include/asm/paravirt.h
@@ -281,9 +281,9 @@ paravirt_init_missing_ticks_accounting(int cpu)
281 pv_time_ops.init_missing_ticks_accounting(cpu); 281 pv_time_ops.init_missing_ticks_accounting(cpu);
282} 282}
283 283
284struct jump_label_key; 284struct static_key;
285extern struct jump_label_key paravirt_steal_enabled; 285extern struct static_key paravirt_steal_enabled;
286extern struct jump_label_key paravirt_steal_rq_enabled; 286extern struct static_key paravirt_steal_rq_enabled;
287 287
288static inline int 288static inline int
289paravirt_do_steal_accounting(unsigned long *new_itm) 289paravirt_do_steal_accounting(unsigned long *new_itm)
diff --git a/arch/ia64/kernel/paravirt.c b/arch/ia64/kernel/paravirt.c
index 100868216c55..1b22f6de2932 100644
--- a/arch/ia64/kernel/paravirt.c
+++ b/arch/ia64/kernel/paravirt.c
@@ -634,8 +634,8 @@ struct pv_irq_ops pv_irq_ops = {
634 * pv_time_ops 634 * pv_time_ops
635 * time operations 635 * time operations
636 */ 636 */
637struct jump_label_key paravirt_steal_enabled; 637struct static_key paravirt_steal_enabled;
638struct jump_label_key paravirt_steal_rq_enabled; 638struct static_key paravirt_steal_rq_enabled;
639 639
640static int 640static int
641ia64_native_do_steal_accounting(unsigned long *new_itm) 641ia64_native_do_steal_accounting(unsigned long *new_itm)
diff --git a/arch/ia64/kernel/process.c b/arch/ia64/kernel/process.c
index 6d33c5cc94f0..9dc52b63fc87 100644
--- a/arch/ia64/kernel/process.c
+++ b/arch/ia64/kernel/process.c
@@ -330,9 +330,7 @@ cpu_idle (void)
330 normal_xtp(); 330 normal_xtp();
331#endif 331#endif
332 } 332 }
333 preempt_enable_no_resched(); 333 schedule_preempt_disabled();
334 schedule();
335 preempt_disable();
336 check_pgt_cache(); 334 check_pgt_cache();
337 if (cpu_is_offline(cpu)) 335 if (cpu_is_offline(cpu))
338 play_dead(); 336 play_dead();
diff --git a/arch/m32r/kernel/process.c b/arch/m32r/kernel/process.c
index 422bea9f1dbc..3a4a32b27208 100644
--- a/arch/m32r/kernel/process.c
+++ b/arch/m32r/kernel/process.c
@@ -90,9 +90,7 @@ void cpu_idle (void)
90 90
91 idle(); 91 idle();
92 } 92 }
93 preempt_enable_no_resched(); 93 schedule_preempt_disabled();
94 schedule();
95 preempt_disable();
96 } 94 }
97} 95}
98 96
diff --git a/arch/m68k/kernel/process_mm.c b/arch/m68k/kernel/process_mm.c
index 099283ee1a8f..fe4186b5fc32 100644
--- a/arch/m68k/kernel/process_mm.c
+++ b/arch/m68k/kernel/process_mm.c
@@ -78,9 +78,7 @@ void cpu_idle(void)
78 while (1) { 78 while (1) {
79 while (!need_resched()) 79 while (!need_resched())
80 idle(); 80 idle();
81 preempt_enable_no_resched(); 81 schedule_preempt_disabled();
82 schedule();
83 preempt_disable();
84 } 82 }
85} 83}
86 84
diff --git a/arch/m68k/kernel/process_no.c b/arch/m68k/kernel/process_no.c
index 5e1078cabe0e..f7fe6c348595 100644
--- a/arch/m68k/kernel/process_no.c
+++ b/arch/m68k/kernel/process_no.c
@@ -73,9 +73,7 @@ void cpu_idle(void)
73 /* endless idle loop with no priority at all */ 73 /* endless idle loop with no priority at all */
74 while (1) { 74 while (1) {
75 idle(); 75 idle();
76 preempt_enable_no_resched(); 76 schedule_preempt_disabled();
77 schedule();
78 preempt_disable();
79 } 77 }
80} 78}
81 79
diff --git a/arch/microblaze/kernel/process.c b/arch/microblaze/kernel/process.c
index 7dcb5bfffb75..9155f7d92669 100644
--- a/arch/microblaze/kernel/process.c
+++ b/arch/microblaze/kernel/process.c
@@ -110,9 +110,7 @@ void cpu_idle(void)
110 rcu_idle_exit(); 110 rcu_idle_exit();
111 tick_nohz_idle_exit(); 111 tick_nohz_idle_exit();
112 112
113 preempt_enable_no_resched(); 113 schedule_preempt_disabled();
114 schedule();
115 preempt_disable();
116 check_pgt_cache(); 114 check_pgt_cache();
117 } 115 }
118} 116}
diff --git a/arch/mips/include/asm/jump_label.h b/arch/mips/include/asm/jump_label.h
index 1881b316ca45..4d6d77ed9b9d 100644
--- a/arch/mips/include/asm/jump_label.h
+++ b/arch/mips/include/asm/jump_label.h
@@ -20,7 +20,7 @@
20#define WORD_INSN ".word" 20#define WORD_INSN ".word"
21#endif 21#endif
22 22
23static __always_inline bool arch_static_branch(struct jump_label_key *key) 23static __always_inline bool arch_static_branch(struct static_key *key)
24{ 24{
25 asm goto("1:\tnop\n\t" 25 asm goto("1:\tnop\n\t"
26 "nop\n\t" 26 "nop\n\t"
diff --git a/arch/mips/kernel/perf_event_mipsxx.c b/arch/mips/kernel/perf_event_mipsxx.c
index e3b897acfbc0..811084f4e422 100644
--- a/arch/mips/kernel/perf_event_mipsxx.c
+++ b/arch/mips/kernel/perf_event_mipsxx.c
@@ -606,6 +606,10 @@ static int mipspmu_event_init(struct perf_event *event)
606{ 606{
607 int err = 0; 607 int err = 0;
608 608
609 /* does not support taken branch sampling */
610 if (has_branch_stack(event))
611 return -EOPNOTSUPP;
612
609 switch (event->attr.type) { 613 switch (event->attr.type) {
610 case PERF_TYPE_RAW: 614 case PERF_TYPE_RAW:
611 case PERF_TYPE_HARDWARE: 615 case PERF_TYPE_HARDWARE:
diff --git a/arch/mips/kernel/process.c b/arch/mips/kernel/process.c
index 7955409051c4..61f1cb45a1d5 100644
--- a/arch/mips/kernel/process.c
+++ b/arch/mips/kernel/process.c
@@ -80,9 +80,7 @@ void __noreturn cpu_idle(void)
80#endif 80#endif
81 rcu_idle_exit(); 81 rcu_idle_exit();
82 tick_nohz_idle_exit(); 82 tick_nohz_idle_exit();
83 preempt_enable_no_resched(); 83 schedule_preempt_disabled();
84 schedule();
85 preempt_disable();
86 } 84 }
87} 85}
88 86
diff --git a/arch/mn10300/kernel/process.c b/arch/mn10300/kernel/process.c
index 28eec3102535..cac401d37f75 100644
--- a/arch/mn10300/kernel/process.c
+++ b/arch/mn10300/kernel/process.c
@@ -123,9 +123,7 @@ void cpu_idle(void)
123 idle(); 123 idle();
124 } 124 }
125 125
126 preempt_enable_no_resched(); 126 schedule_preempt_disabled();
127 schedule();
128 preempt_disable();
129 } 127 }
130} 128}
131 129
diff --git a/arch/parisc/kernel/process.c b/arch/parisc/kernel/process.c
index 62c60b87d039..d4b94b395c16 100644
--- a/arch/parisc/kernel/process.c
+++ b/arch/parisc/kernel/process.c
@@ -71,9 +71,7 @@ void cpu_idle(void)
71 while (1) { 71 while (1) {
72 while (!need_resched()) 72 while (!need_resched())
73 barrier(); 73 barrier();
74 preempt_enable_no_resched(); 74 schedule_preempt_disabled();
75 schedule();
76 preempt_disable();
77 check_pgt_cache(); 75 check_pgt_cache();
78 } 76 }
79} 77}
diff --git a/arch/powerpc/include/asm/jump_label.h b/arch/powerpc/include/asm/jump_label.h
index 938986e412f1..ae098c438f00 100644
--- a/arch/powerpc/include/asm/jump_label.h
+++ b/arch/powerpc/include/asm/jump_label.h
@@ -17,7 +17,7 @@
17#define JUMP_ENTRY_TYPE stringify_in_c(FTR_ENTRY_LONG) 17#define JUMP_ENTRY_TYPE stringify_in_c(FTR_ENTRY_LONG)
18#define JUMP_LABEL_NOP_SIZE 4 18#define JUMP_LABEL_NOP_SIZE 4
19 19
20static __always_inline bool arch_static_branch(struct jump_label_key *key) 20static __always_inline bool arch_static_branch(struct static_key *key)
21{ 21{
22 asm goto("1:\n\t" 22 asm goto("1:\n\t"
23 "nop\n\t" 23 "nop\n\t"
diff --git a/arch/powerpc/include/asm/perf_event_server.h b/arch/powerpc/include/asm/perf_event_server.h
index 8f1df1208d23..1a8093fa8f71 100644
--- a/arch/powerpc/include/asm/perf_event_server.h
+++ b/arch/powerpc/include/asm/perf_event_server.h
@@ -61,8 +61,6 @@ struct pt_regs;
61extern unsigned long perf_misc_flags(struct pt_regs *regs); 61extern unsigned long perf_misc_flags(struct pt_regs *regs);
62extern unsigned long perf_instruction_pointer(struct pt_regs *regs); 62extern unsigned long perf_instruction_pointer(struct pt_regs *regs);
63 63
64#define PERF_EVENT_INDEX_OFFSET 1
65
66/* 64/*
67 * Only override the default definitions in include/linux/perf_event.h 65 * Only override the default definitions in include/linux/perf_event.h
68 * if we have hardware PMU support. 66 * if we have hardware PMU support.
diff --git a/arch/powerpc/kernel/idle.c b/arch/powerpc/kernel/idle.c
index 0a48bf5db6c8..c97fc60c790c 100644
--- a/arch/powerpc/kernel/idle.c
+++ b/arch/powerpc/kernel/idle.c
@@ -101,11 +101,11 @@ void cpu_idle(void)
101 ppc64_runlatch_on(); 101 ppc64_runlatch_on();
102 rcu_idle_exit(); 102 rcu_idle_exit();
103 tick_nohz_idle_exit(); 103 tick_nohz_idle_exit();
104 preempt_enable_no_resched(); 104 if (cpu_should_die()) {
105 if (cpu_should_die()) 105 sched_preempt_enable_no_resched();
106 cpu_die(); 106 cpu_die();
107 schedule(); 107 }
108 preempt_disable(); 108 schedule_preempt_disabled();
109 } 109 }
110} 110}
111 111
diff --git a/arch/powerpc/kernel/perf_event.c b/arch/powerpc/kernel/perf_event.c
index 64483fde95c6..c2e27ede07ec 100644
--- a/arch/powerpc/kernel/perf_event.c
+++ b/arch/powerpc/kernel/perf_event.c
@@ -1084,6 +1084,10 @@ static int power_pmu_event_init(struct perf_event *event)
1084 if (!ppmu) 1084 if (!ppmu)
1085 return -ENOENT; 1085 return -ENOENT;
1086 1086
1087 /* does not support taken branch sampling */
1088 if (has_branch_stack(event))
1089 return -EOPNOTSUPP;
1090
1087 switch (event->attr.type) { 1091 switch (event->attr.type) {
1088 case PERF_TYPE_HARDWARE: 1092 case PERF_TYPE_HARDWARE:
1089 ev = event->attr.config; 1093 ev = event->attr.config;
@@ -1193,6 +1197,11 @@ static int power_pmu_event_init(struct perf_event *event)
1193 return err; 1197 return err;
1194} 1198}
1195 1199
1200static int power_pmu_event_idx(struct perf_event *event)
1201{
1202 return event->hw.idx;
1203}
1204
1196struct pmu power_pmu = { 1205struct pmu power_pmu = {
1197 .pmu_enable = power_pmu_enable, 1206 .pmu_enable = power_pmu_enable,
1198 .pmu_disable = power_pmu_disable, 1207 .pmu_disable = power_pmu_disable,
@@ -1205,6 +1214,7 @@ struct pmu power_pmu = {
1205 .start_txn = power_pmu_start_txn, 1214 .start_txn = power_pmu_start_txn,
1206 .cancel_txn = power_pmu_cancel_txn, 1215 .cancel_txn = power_pmu_cancel_txn,
1207 .commit_txn = power_pmu_commit_txn, 1216 .commit_txn = power_pmu_commit_txn,
1217 .event_idx = power_pmu_event_idx,
1208}; 1218};
1209 1219
1210/* 1220/*
diff --git a/arch/powerpc/platforms/iseries/setup.c b/arch/powerpc/platforms/iseries/setup.c
index 8fc62586a973..a5fbf4cb6329 100644
--- a/arch/powerpc/platforms/iseries/setup.c
+++ b/arch/powerpc/platforms/iseries/setup.c
@@ -584,9 +584,7 @@ static void iseries_shared_idle(void)
584 if (hvlpevent_is_pending()) 584 if (hvlpevent_is_pending())
585 process_iSeries_events(); 585 process_iSeries_events();
586 586
587 preempt_enable_no_resched(); 587 schedule_preempt_disabled();
588 schedule();
589 preempt_disable();
590 } 588 }
591} 589}
592 590
@@ -615,9 +613,7 @@ static void iseries_dedicated_idle(void)
615 ppc64_runlatch_on(); 613 ppc64_runlatch_on();
616 rcu_idle_exit(); 614 rcu_idle_exit();
617 tick_nohz_idle_exit(); 615 tick_nohz_idle_exit();
618 preempt_enable_no_resched(); 616 schedule_preempt_disabled();
619 schedule();
620 preempt_disable();
621 } 617 }
622} 618}
623 619
diff --git a/arch/s390/include/asm/jump_label.h b/arch/s390/include/asm/jump_label.h
index 95a6cf2b5b67..6c32190dc73e 100644
--- a/arch/s390/include/asm/jump_label.h
+++ b/arch/s390/include/asm/jump_label.h
@@ -13,7 +13,7 @@
13#define ASM_ALIGN ".balign 4" 13#define ASM_ALIGN ".balign 4"
14#endif 14#endif
15 15
16static __always_inline bool arch_static_branch(struct jump_label_key *key) 16static __always_inline bool arch_static_branch(struct static_key *key)
17{ 17{
18 asm goto("0: brcl 0,0\n" 18 asm goto("0: brcl 0,0\n"
19 ".pushsection __jump_table, \"aw\"\n" 19 ".pushsection __jump_table, \"aw\"\n"
diff --git a/arch/s390/include/asm/perf_event.h b/arch/s390/include/asm/perf_event.h
index a75f168d2718..4eb444edbe49 100644
--- a/arch/s390/include/asm/perf_event.h
+++ b/arch/s390/include/asm/perf_event.h
@@ -6,4 +6,3 @@
6 6
7/* Empty, just to avoid compiling error */ 7/* Empty, just to avoid compiling error */
8 8
9#define PERF_EVENT_INDEX_OFFSET 0
diff --git a/arch/s390/kernel/irq.c b/arch/s390/kernel/irq.c
index b9a7fdd9c814..e30b2dfa8ba0 100644
--- a/arch/s390/kernel/irq.c
+++ b/arch/s390/kernel/irq.c
@@ -165,13 +165,6 @@ static inline int ext_hash(u16 code)
165 return (code + (code >> 9)) & 0xff; 165 return (code + (code >> 9)) & 0xff;
166} 166}
167 167
168static void ext_int_hash_update(struct rcu_head *head)
169{
170 struct ext_int_info *p = container_of(head, struct ext_int_info, rcu);
171
172 kfree(p);
173}
174
175int register_external_interrupt(u16 code, ext_int_handler_t handler) 168int register_external_interrupt(u16 code, ext_int_handler_t handler)
176{ 169{
177 struct ext_int_info *p; 170 struct ext_int_info *p;
@@ -202,7 +195,7 @@ int unregister_external_interrupt(u16 code, ext_int_handler_t handler)
202 list_for_each_entry_rcu(p, &ext_int_hash[index], entry) 195 list_for_each_entry_rcu(p, &ext_int_hash[index], entry)
203 if (p->code == code && p->handler == handler) { 196 if (p->code == code && p->handler == handler) {
204 list_del_rcu(&p->entry); 197 list_del_rcu(&p->entry);
205 call_rcu(&p->rcu, ext_int_hash_update); 198 kfree_rcu(p, rcu);
206 } 199 }
207 spin_unlock_irqrestore(&ext_int_hash_lock, flags); 200 spin_unlock_irqrestore(&ext_int_hash_lock, flags);
208 return 0; 201 return 0;
diff --git a/arch/s390/kernel/process.c b/arch/s390/kernel/process.c
index e795933eb2cb..7618085b4164 100644
--- a/arch/s390/kernel/process.c
+++ b/arch/s390/kernel/process.c
@@ -97,9 +97,7 @@ void cpu_idle(void)
97 tick_nohz_idle_exit(); 97 tick_nohz_idle_exit();
98 if (test_thread_flag(TIF_MCCK_PENDING)) 98 if (test_thread_flag(TIF_MCCK_PENDING))
99 s390_handle_mcck(); 99 s390_handle_mcck();
100 preempt_enable_no_resched(); 100 schedule_preempt_disabled();
101 schedule();
102 preempt_disable();
103 } 101 }
104} 102}
105 103
diff --git a/arch/s390/kernel/smp.c b/arch/s390/kernel/smp.c
index 2398ce6b15ae..b0e28c47ab83 100644
--- a/arch/s390/kernel/smp.c
+++ b/arch/s390/kernel/smp.c
@@ -550,12 +550,6 @@ int __cpuinit start_secondary(void *cpuvoid)
550 S390_lowcore.restart_psw.addr = 550 S390_lowcore.restart_psw.addr =
551 PSW_ADDR_AMODE | (unsigned long) psw_restart_int_handler; 551 PSW_ADDR_AMODE | (unsigned long) psw_restart_int_handler;
552 __ctl_set_bit(0, 28); /* Enable lowcore protection */ 552 __ctl_set_bit(0, 28); /* Enable lowcore protection */
553 /*
554 * Wait until the cpu which brought this one up marked it
555 * active before enabling interrupts.
556 */
557 while (!cpumask_test_cpu(smp_processor_id(), cpu_active_mask))
558 cpu_relax();
559 local_irq_enable(); 553 local_irq_enable();
560 /* cpu_idle will call schedule for us */ 554 /* cpu_idle will call schedule for us */
561 cpu_idle(); 555 cpu_idle();
diff --git a/arch/score/kernel/process.c b/arch/score/kernel/process.c
index 25d08030a883..2707023c7563 100644
--- a/arch/score/kernel/process.c
+++ b/arch/score/kernel/process.c
@@ -53,9 +53,7 @@ void __noreturn cpu_idle(void)
53 while (!need_resched()) 53 while (!need_resched())
54 barrier(); 54 barrier();
55 55
56 preempt_enable_no_resched(); 56 schedule_preempt_disabled();
57 schedule();
58 preempt_disable();
59 } 57 }
60} 58}
61 59
diff --git a/arch/sh/kernel/idle.c b/arch/sh/kernel/idle.c
index 406508d4ce74..7e4892826563 100644
--- a/arch/sh/kernel/idle.c
+++ b/arch/sh/kernel/idle.c
@@ -114,9 +114,7 @@ void cpu_idle(void)
114 114
115 rcu_idle_exit(); 115 rcu_idle_exit();
116 tick_nohz_idle_exit(); 116 tick_nohz_idle_exit();
117 preempt_enable_no_resched(); 117 schedule_preempt_disabled();
118 schedule();
119 preempt_disable();
120 } 118 }
121} 119}
122 120
diff --git a/arch/sh/kernel/perf_event.c b/arch/sh/kernel/perf_event.c
index 10b14e3a7eb8..068b8a2759b5 100644
--- a/arch/sh/kernel/perf_event.c
+++ b/arch/sh/kernel/perf_event.c
@@ -310,6 +310,10 @@ static int sh_pmu_event_init(struct perf_event *event)
310{ 310{
311 int err; 311 int err;
312 312
313 /* does not support taken branch sampling */
314 if (has_branch_stack(event))
315 return -EOPNOTSUPP;
316
313 switch (event->attr.type) { 317 switch (event->attr.type) {
314 case PERF_TYPE_RAW: 318 case PERF_TYPE_RAW:
315 case PERF_TYPE_HW_CACHE: 319 case PERF_TYPE_HW_CACHE:
diff --git a/arch/sparc/include/asm/jump_label.h b/arch/sparc/include/asm/jump_label.h
index fc73a82366f8..5080d16a832f 100644
--- a/arch/sparc/include/asm/jump_label.h
+++ b/arch/sparc/include/asm/jump_label.h
@@ -7,7 +7,7 @@
7 7
8#define JUMP_LABEL_NOP_SIZE 4 8#define JUMP_LABEL_NOP_SIZE 4
9 9
10static __always_inline bool arch_static_branch(struct jump_label_key *key) 10static __always_inline bool arch_static_branch(struct static_key *key)
11{ 11{
12 asm goto("1:\n\t" 12 asm goto("1:\n\t"
13 "nop\n\t" 13 "nop\n\t"
diff --git a/arch/sparc/kernel/perf_event.c b/arch/sparc/kernel/perf_event.c
index 614da624330c..8e16a4a21582 100644
--- a/arch/sparc/kernel/perf_event.c
+++ b/arch/sparc/kernel/perf_event.c
@@ -1105,6 +1105,10 @@ static int sparc_pmu_event_init(struct perf_event *event)
1105 if (atomic_read(&nmi_active) < 0) 1105 if (atomic_read(&nmi_active) < 0)
1106 return -ENODEV; 1106 return -ENODEV;
1107 1107
1108 /* does not support taken branch sampling */
1109 if (has_branch_stack(event))
1110 return -EOPNOTSUPP;
1111
1108 switch (attr->type) { 1112 switch (attr->type) {
1109 case PERF_TYPE_HARDWARE: 1113 case PERF_TYPE_HARDWARE:
1110 if (attr->config >= sparc_pmu->max_events) 1114 if (attr->config >= sparc_pmu->max_events)
diff --git a/arch/sparc/kernel/process_32.c b/arch/sparc/kernel/process_32.c
index f793742eec2b..935fdbcd88c2 100644
--- a/arch/sparc/kernel/process_32.c
+++ b/arch/sparc/kernel/process_32.c
@@ -113,9 +113,7 @@ void cpu_idle(void)
113 while (!need_resched()) 113 while (!need_resched())
114 cpu_relax(); 114 cpu_relax();
115 } 115 }
116 preempt_enable_no_resched(); 116 schedule_preempt_disabled();
117 schedule();
118 preempt_disable();
119 check_pgt_cache(); 117 check_pgt_cache();
120 } 118 }
121} 119}
@@ -138,9 +136,7 @@ void cpu_idle(void)
138 while (!need_resched()) 136 while (!need_resched())
139 cpu_relax(); 137 cpu_relax();
140 } 138 }
141 preempt_enable_no_resched(); 139 schedule_preempt_disabled();
142 schedule();
143 preempt_disable();
144 check_pgt_cache(); 140 check_pgt_cache();
145 } 141 }
146} 142}
diff --git a/arch/sparc/kernel/process_64.c b/arch/sparc/kernel/process_64.c
index 39d8b05201a2..06b5b5fc20c7 100644
--- a/arch/sparc/kernel/process_64.c
+++ b/arch/sparc/kernel/process_64.c
@@ -104,15 +104,13 @@ void cpu_idle(void)
104 rcu_idle_exit(); 104 rcu_idle_exit();
105 tick_nohz_idle_exit(); 105 tick_nohz_idle_exit();
106 106
107 preempt_enable_no_resched();
108
109#ifdef CONFIG_HOTPLUG_CPU 107#ifdef CONFIG_HOTPLUG_CPU
110 if (cpu_is_offline(cpu)) 108 if (cpu_is_offline(cpu)) {
109 sched_preempt_enable_no_resched();
111 cpu_play_dead(); 110 cpu_play_dead();
111 }
112#endif 112#endif
113 113 schedule_preempt_disabled();
114 schedule();
115 preempt_disable();
116 } 114 }
117} 115}
118 116
diff --git a/arch/tile/configs/tilegx_defconfig b/arch/tile/configs/tilegx_defconfig
index 7960d5896504..b8d99aca5431 100644
--- a/arch/tile/configs/tilegx_defconfig
+++ b/arch/tile/configs/tilegx_defconfig
@@ -1,363 +1,93 @@
1#
2# Automatically generated file; DO NOT EDIT.
3# Linux/tilegx 3.3.0-rc7 Kernel Configuration
4#
5CONFIG_TILE=y
6CONFIG_MMU=y
7CONFIG_GENERIC_CSUM=y
8CONFIG_SEMAPHORE_SLEEPERS=y
9CONFIG_HAVE_ARCH_ALLOC_REMAP=y
10CONFIG_HAVE_SETUP_PER_CPU_AREA=y
11CONFIG_NEED_PER_CPU_PAGE_FIRST_CHUNK=y
12CONFIG_SYS_SUPPORTS_HUGETLBFS=y
13CONFIG_GENERIC_CLOCKEVENTS=y
14CONFIG_RWSEM_GENERIC_SPINLOCK=y
15CONFIG_DEFAULT_MIGRATION_COST=10000000
16CONFIG_ARCH_SUPPORTS_OPTIMIZED_INLINING=y
17CONFIG_ARCH_PHYS_ADDR_T_64BIT=y
18CONFIG_ARCH_DMA_ADDR_T_64BIT=y
19CONFIG_LOCKDEP_SUPPORT=y
20CONFIG_STACKTRACE_SUPPORT=y
21CONFIG_ARCH_DISCONTIGMEM_ENABLE=y
22CONFIG_ARCH_DISCONTIGMEM_DEFAULT=y
23CONFIG_TRACE_IRQFLAGS_SUPPORT=y
24CONFIG_STRICT_DEVMEM=y
25CONFIG_SMP=y
26# CONFIG_DEBUG_COPY_FROM_USER is not set
27CONFIG_HVC_TILE=y
28CONFIG_TILEGX=y 1CONFIG_TILEGX=y
29CONFIG_64BIT=y
30CONFIG_ARCH_DEFCONFIG="arch/tile/configs/tilegx_defconfig"
31CONFIG_DEFCONFIG_LIST="/lib/modules/$UNAME_RELEASE/.config"
32
33#
34# General setup
35#
36CONFIG_EXPERIMENTAL=y 2CONFIG_EXPERIMENTAL=y
37CONFIG_INIT_ENV_ARG_LIMIT=32
38CONFIG_CROSS_COMPILE=""
39CONFIG_LOCALVERSION=""
40# CONFIG_LOCALVERSION_AUTO is not set 3# CONFIG_LOCALVERSION_AUTO is not set
41CONFIG_DEFAULT_HOSTNAME="(none)"
42CONFIG_SWAP=y
43CONFIG_SYSVIPC=y 4CONFIG_SYSVIPC=y
44CONFIG_SYSVIPC_SYSCTL=y
45CONFIG_POSIX_MQUEUE=y 5CONFIG_POSIX_MQUEUE=y
46CONFIG_POSIX_MQUEUE_SYSCTL=y
47CONFIG_BSD_PROCESS_ACCT=y 6CONFIG_BSD_PROCESS_ACCT=y
48CONFIG_BSD_PROCESS_ACCT_V3=y 7CONFIG_BSD_PROCESS_ACCT_V3=y
49# CONFIG_FHANDLE is not set 8CONFIG_FHANDLE=y
50CONFIG_TASKSTATS=y 9CONFIG_TASKSTATS=y
51CONFIG_TASK_DELAY_ACCT=y 10CONFIG_TASK_DELAY_ACCT=y
52CONFIG_TASK_XACCT=y 11CONFIG_TASK_XACCT=y
53CONFIG_TASK_IO_ACCOUNTING=y 12CONFIG_TASK_IO_ACCOUNTING=y
54CONFIG_AUDIT=y 13CONFIG_AUDIT=y
55# CONFIG_AUDIT_LOGINUID_IMMUTABLE is not set
56CONFIG_HAVE_GENERIC_HARDIRQS=y
57
58#
59# IRQ subsystem
60#
61CONFIG_GENERIC_HARDIRQS=y
62CONFIG_GENERIC_IRQ_PROBE=y
63CONFIG_GENERIC_IRQ_SHOW=y
64CONFIG_GENERIC_PENDING_IRQ=y
65
66#
67# RCU Subsystem
68#
69CONFIG_TREE_RCU=y
70# CONFIG_PREEMPT_RCU is not set
71# CONFIG_RCU_TRACE is not set
72CONFIG_RCU_FANOUT=64
73# CONFIG_RCU_FANOUT_EXACT is not set
74# CONFIG_RCU_FAST_NO_HZ is not set
75# CONFIG_TREE_RCU_TRACE is not set
76# CONFIG_IKCONFIG is not set
77CONFIG_LOG_BUF_SHIFT=19 14CONFIG_LOG_BUF_SHIFT=19
78CONFIG_CGROUPS=y 15CONFIG_CGROUPS=y
79CONFIG_CGROUP_DEBUG=y 16CONFIG_CGROUP_DEBUG=y
80# CONFIG_CGROUP_FREEZER is not set
81CONFIG_CGROUP_DEVICE=y 17CONFIG_CGROUP_DEVICE=y
82CONFIG_CPUSETS=y 18CONFIG_CPUSETS=y
83CONFIG_PROC_PID_CPUSET=y
84CONFIG_CGROUP_CPUACCT=y 19CONFIG_CGROUP_CPUACCT=y
85CONFIG_RESOURCE_COUNTERS=y 20CONFIG_RESOURCE_COUNTERS=y
86CONFIG_CGROUP_MEM_RES_CTLR=y 21CONFIG_CGROUP_MEM_RES_CTLR=y
87CONFIG_CGROUP_MEM_RES_CTLR_SWAP=y 22CONFIG_CGROUP_MEM_RES_CTLR_SWAP=y
88CONFIG_CGROUP_MEM_RES_CTLR_SWAP_ENABLED=y
89# CONFIG_CGROUP_MEM_RES_CTLR_KMEM is not set
90CONFIG_CGROUP_SCHED=y 23CONFIG_CGROUP_SCHED=y
91CONFIG_FAIR_GROUP_SCHED=y
92# CONFIG_CFS_BANDWIDTH is not set
93CONFIG_RT_GROUP_SCHED=y 24CONFIG_RT_GROUP_SCHED=y
94CONFIG_BLK_CGROUP=y 25CONFIG_BLK_CGROUP=y
95# CONFIG_DEBUG_BLK_CGROUP is not set
96# CONFIG_CHECKPOINT_RESTORE is not set
97CONFIG_NAMESPACES=y 26CONFIG_NAMESPACES=y
98CONFIG_UTS_NS=y
99CONFIG_IPC_NS=y
100CONFIG_USER_NS=y
101CONFIG_PID_NS=y
102CONFIG_NET_NS=y
103# CONFIG_SCHED_AUTOGROUP is not set
104CONFIG_MM_OWNER=y
105# CONFIG_SYSFS_DEPRECATED is not set
106CONFIG_RELAY=y 27CONFIG_RELAY=y
107CONFIG_BLK_DEV_INITRD=y 28CONFIG_BLK_DEV_INITRD=y
108CONFIG_INITRAMFS_SOURCE=""
109CONFIG_RD_GZIP=y
110# CONFIG_RD_BZIP2 is not set
111# CONFIG_RD_LZMA is not set
112# CONFIG_RD_XZ is not set
113# CONFIG_RD_LZO is not set
114CONFIG_CC_OPTIMIZE_FOR_SIZE=y
115CONFIG_SYSCTL=y
116CONFIG_ANON_INODES=y
117CONFIG_EXPERT=y
118CONFIG_SYSCTL_SYSCALL=y 29CONFIG_SYSCTL_SYSCALL=y
119CONFIG_KALLSYMS=y
120# CONFIG_KALLSYMS_ALL is not set
121CONFIG_HOTPLUG=y
122CONFIG_PRINTK=y
123CONFIG_BUG=y
124CONFIG_ELF_CORE=y
125CONFIG_BASE_FULL=y
126CONFIG_FUTEX=y
127CONFIG_EPOLL=y
128CONFIG_SIGNALFD=y
129CONFIG_TIMERFD=y
130CONFIG_EVENTFD=y
131CONFIG_SHMEM=y
132CONFIG_AIO=y
133CONFIG_EMBEDDED=y 30CONFIG_EMBEDDED=y
134
135#
136# Kernel Performance Events And Counters
137#
138CONFIG_VM_EVENT_COUNTERS=y
139CONFIG_PCI_QUIRKS=y
140CONFIG_SLUB_DEBUG=y
141# CONFIG_COMPAT_BRK is not set 31# CONFIG_COMPAT_BRK is not set
142# CONFIG_SLAB is not set
143CONFIG_SLUB=y
144# CONFIG_SLOB is not set
145CONFIG_PROFILING=y 32CONFIG_PROFILING=y
146CONFIG_USE_GENERIC_SMP_HELPERS=y
147CONFIG_ARCH_HAVE_NMI_SAFE_CMPXCHG=y
148
149#
150# GCOV-based kernel profiling
151#
152# CONFIG_GCOV_KERNEL is not set
153# CONFIG_HAVE_GENERIC_DMA_COHERENT is not set
154CONFIG_SLABINFO=y
155CONFIG_RT_MUTEXES=y
156CONFIG_BASE_SMALL=0
157CONFIG_MODULES=y 33CONFIG_MODULES=y
158CONFIG_MODULE_FORCE_LOAD=y 34CONFIG_MODULE_FORCE_LOAD=y
159CONFIG_MODULE_UNLOAD=y 35CONFIG_MODULE_UNLOAD=y
160# CONFIG_MODULE_FORCE_UNLOAD is not set
161# CONFIG_MODVERSIONS is not set
162# CONFIG_MODULE_SRCVERSION_ALL is not set
163CONFIG_STOP_MACHINE=y
164CONFIG_BLOCK=y
165CONFIG_BLK_DEV_BSG=y
166# CONFIG_BLK_DEV_BSGLIB is not set
167CONFIG_BLK_DEV_INTEGRITY=y 36CONFIG_BLK_DEV_INTEGRITY=y
168# CONFIG_BLK_DEV_THROTTLING is not set
169
170#
171# Partition Types
172#
173CONFIG_PARTITION_ADVANCED=y 37CONFIG_PARTITION_ADVANCED=y
174# CONFIG_ACORN_PARTITION is not set
175CONFIG_OSF_PARTITION=y 38CONFIG_OSF_PARTITION=y
176CONFIG_AMIGA_PARTITION=y 39CONFIG_AMIGA_PARTITION=y
177# CONFIG_ATARI_PARTITION is not set
178CONFIG_MAC_PARTITION=y 40CONFIG_MAC_PARTITION=y
179CONFIG_MSDOS_PARTITION=y
180CONFIG_BSD_DISKLABEL=y 41CONFIG_BSD_DISKLABEL=y
181CONFIG_MINIX_SUBPARTITION=y 42CONFIG_MINIX_SUBPARTITION=y
182CONFIG_SOLARIS_X86_PARTITION=y 43CONFIG_SOLARIS_X86_PARTITION=y
183CONFIG_UNIXWARE_DISKLABEL=y 44CONFIG_UNIXWARE_DISKLABEL=y
184# CONFIG_LDM_PARTITION is not set
185CONFIG_SGI_PARTITION=y 45CONFIG_SGI_PARTITION=y
186# CONFIG_ULTRIX_PARTITION is not set
187CONFIG_SUN_PARTITION=y 46CONFIG_SUN_PARTITION=y
188CONFIG_KARMA_PARTITION=y 47CONFIG_KARMA_PARTITION=y
189CONFIG_EFI_PARTITION=y 48CONFIG_EFI_PARTITION=y
190# CONFIG_SYSV68_PARTITION is not set
191CONFIG_BLOCK_COMPAT=y
192
193#
194# IO Schedulers
195#
196CONFIG_IOSCHED_NOOP=y
197CONFIG_IOSCHED_DEADLINE=y
198CONFIG_IOSCHED_CFQ=y
199CONFIG_CFQ_GROUP_IOSCHED=y 49CONFIG_CFQ_GROUP_IOSCHED=y
200# CONFIG_DEFAULT_DEADLINE is not set
201CONFIG_DEFAULT_CFQ=y
202# CONFIG_DEFAULT_NOOP is not set
203CONFIG_DEFAULT_IOSCHED="cfq"
204CONFIG_PADATA=y
205# CONFIG_INLINE_SPIN_TRYLOCK is not set
206# CONFIG_INLINE_SPIN_TRYLOCK_BH is not set
207# CONFIG_INLINE_SPIN_LOCK is not set
208# CONFIG_INLINE_SPIN_LOCK_BH is not set
209# CONFIG_INLINE_SPIN_LOCK_IRQ is not set
210# CONFIG_INLINE_SPIN_LOCK_IRQSAVE is not set
211CONFIG_INLINE_SPIN_UNLOCK=y
212# CONFIG_INLINE_SPIN_UNLOCK_BH is not set
213CONFIG_INLINE_SPIN_UNLOCK_IRQ=y
214# CONFIG_INLINE_SPIN_UNLOCK_IRQRESTORE is not set
215# CONFIG_INLINE_READ_TRYLOCK is not set
216# CONFIG_INLINE_READ_LOCK is not set
217# CONFIG_INLINE_READ_LOCK_BH is not set
218# CONFIG_INLINE_READ_LOCK_IRQ is not set
219# CONFIG_INLINE_READ_LOCK_IRQSAVE is not set
220CONFIG_INLINE_READ_UNLOCK=y
221# CONFIG_INLINE_READ_UNLOCK_BH is not set
222CONFIG_INLINE_READ_UNLOCK_IRQ=y
223# CONFIG_INLINE_READ_UNLOCK_IRQRESTORE is not set
224# CONFIG_INLINE_WRITE_TRYLOCK is not set
225# CONFIG_INLINE_WRITE_LOCK is not set
226# CONFIG_INLINE_WRITE_LOCK_BH is not set
227# CONFIG_INLINE_WRITE_LOCK_IRQ is not set
228# CONFIG_INLINE_WRITE_LOCK_IRQSAVE is not set
229CONFIG_INLINE_WRITE_UNLOCK=y
230# CONFIG_INLINE_WRITE_UNLOCK_BH is not set
231CONFIG_INLINE_WRITE_UNLOCK_IRQ=y
232# CONFIG_INLINE_WRITE_UNLOCK_IRQRESTORE is not set
233CONFIG_MUTEX_SPIN_ON_OWNER=y
234
235#
236# Tilera-specific configuration
237#
238CONFIG_NR_CPUS=100 50CONFIG_NR_CPUS=100
239CONFIG_TICK_ONESHOT=y
240CONFIG_NO_HZ=y 51CONFIG_NO_HZ=y
241CONFIG_HIGH_RES_TIMERS=y 52CONFIG_HIGH_RES_TIMERS=y
242CONFIG_GENERIC_CLOCKEVENTS_BUILD=y
243CONFIG_HZ_100=y 53CONFIG_HZ_100=y
244# CONFIG_HZ_250 is not set
245# CONFIG_HZ_300 is not set
246# CONFIG_HZ_1000 is not set
247CONFIG_HZ=100
248CONFIG_SCHED_HRTICK=y
249# CONFIG_KEXEC is not set
250CONFIG_COMPAT=y
251CONFIG_SYSVIPC_COMPAT=y
252# CONFIG_HIGHMEM is not set
253CONFIG_NUMA=y
254CONFIG_NODES_SHIFT=2
255CONFIG_PAGE_OFFSET=0xC0000000
256CONFIG_SELECT_MEMORY_MODEL=y
257CONFIG_DISCONTIGMEM_MANUAL=y
258CONFIG_DISCONTIGMEM=y
259CONFIG_FLAT_NODE_MEM_MAP=y
260CONFIG_NEED_MULTIPLE_NODES=y
261CONFIG_PAGEFLAGS_EXTENDED=y
262CONFIG_SPLIT_PTLOCK_CPUS=4
263# CONFIG_COMPACTION is not set
264CONFIG_MIGRATION=y
265CONFIG_PHYS_ADDR_T_64BIT=y
266CONFIG_ZONE_DMA_FLAG=0
267CONFIG_VIRT_TO_BUS=y
268# CONFIG_KSM is not set
269CONFIG_DEFAULT_MMAP_MIN_ADDR=4096
270# CONFIG_CLEANCACHE is not set
271# CONFIG_CMDLINE_BOOL is not set
272CONFIG_VMALLOC_RESERVE=0x1000000
273CONFIG_HARDWALL=y
274CONFIG_KERNEL_PL=1
275
276#
277# Bus options
278#
279CONFIG_PCI=y
280CONFIG_PCI_DOMAINS=y
281# CONFIG_NO_IOMEM is not set
282# CONFIG_NO_IOPORT is not set
283# CONFIG_ARCH_SUPPORTS_MSI is not set
284CONFIG_PCI_DEBUG=y 54CONFIG_PCI_DEBUG=y
285# CONFIG_PCI_STUB is not set
286# CONFIG_PCI_IOV is not set
287# CONFIG_PCI_PRI is not set
288# CONFIG_PCI_PASID is not set
289# CONFIG_HOTPLUG_PCI is not set
290
291#
292# Executable file formats
293#
294CONFIG_KCORE_ELF=y
295CONFIG_BINFMT_ELF=y
296CONFIG_COMPAT_BINFMT_ELF=y
297# CONFIG_CORE_DUMP_DEFAULT_ELF_HEADERS is not set 55# CONFIG_CORE_DUMP_DEFAULT_ELF_HEADERS is not set
298# CONFIG_HAVE_AOUT is not set
299CONFIG_BINFMT_MISC=y 56CONFIG_BINFMT_MISC=y
300CONFIG_NET=y 57CONFIG_NET=y
301
302#
303# Networking options
304#
305CONFIG_PACKET=y 58CONFIG_PACKET=y
306CONFIG_UNIX=y 59CONFIG_UNIX=y
307# CONFIG_UNIX_DIAG is not set
308CONFIG_XFRM=y
309CONFIG_XFRM_USER=y 60CONFIG_XFRM_USER=y
310CONFIG_XFRM_SUB_POLICY=y 61CONFIG_XFRM_SUB_POLICY=y
311CONFIG_XFRM_MIGRATE=y
312CONFIG_XFRM_STATISTICS=y 62CONFIG_XFRM_STATISTICS=y
313CONFIG_XFRM_IPCOMP=m
314CONFIG_NET_KEY=m 63CONFIG_NET_KEY=m
315CONFIG_NET_KEY_MIGRATE=y 64CONFIG_NET_KEY_MIGRATE=y
316CONFIG_INET=y 65CONFIG_INET=y
317CONFIG_IP_MULTICAST=y 66CONFIG_IP_MULTICAST=y
318CONFIG_IP_ADVANCED_ROUTER=y 67CONFIG_IP_ADVANCED_ROUTER=y
319# CONFIG_IP_FIB_TRIE_STATS is not set
320CONFIG_IP_MULTIPLE_TABLES=y 68CONFIG_IP_MULTIPLE_TABLES=y
321CONFIG_IP_ROUTE_MULTIPATH=y 69CONFIG_IP_ROUTE_MULTIPATH=y
322CONFIG_IP_ROUTE_VERBOSE=y 70CONFIG_IP_ROUTE_VERBOSE=y
323CONFIG_IP_ROUTE_CLASSID=y
324# CONFIG_IP_PNP is not set
325CONFIG_NET_IPIP=m 71CONFIG_NET_IPIP=m
326# CONFIG_NET_IPGRE_DEMUX is not set
327CONFIG_IP_MROUTE=y 72CONFIG_IP_MROUTE=y
328# CONFIG_IP_MROUTE_MULTIPLE_TABLES is not set
329CONFIG_IP_PIMSM_V1=y 73CONFIG_IP_PIMSM_V1=y
330CONFIG_IP_PIMSM_V2=y 74CONFIG_IP_PIMSM_V2=y
331# CONFIG_ARPD is not set
332CONFIG_SYN_COOKIES=y 75CONFIG_SYN_COOKIES=y
333CONFIG_INET_AH=m 76CONFIG_INET_AH=m
334CONFIG_INET_ESP=m 77CONFIG_INET_ESP=m
335CONFIG_INET_IPCOMP=m 78CONFIG_INET_IPCOMP=m
336CONFIG_INET_XFRM_TUNNEL=m
337CONFIG_INET_TUNNEL=m
338CONFIG_INET_XFRM_MODE_TRANSPORT=m 79CONFIG_INET_XFRM_MODE_TRANSPORT=m
339CONFIG_INET_XFRM_MODE_TUNNEL=m 80CONFIG_INET_XFRM_MODE_TUNNEL=m
340CONFIG_INET_XFRM_MODE_BEET=m 81CONFIG_INET_XFRM_MODE_BEET=m
341CONFIG_INET_LRO=y
342CONFIG_INET_DIAG=m 82CONFIG_INET_DIAG=m
343CONFIG_INET_TCP_DIAG=m
344# CONFIG_INET_UDP_DIAG is not set
345CONFIG_TCP_CONG_ADVANCED=y 83CONFIG_TCP_CONG_ADVANCED=y
346CONFIG_TCP_CONG_BIC=m
347CONFIG_TCP_CONG_CUBIC=y
348CONFIG_TCP_CONG_WESTWOOD=m
349CONFIG_TCP_CONG_HTCP=m
350CONFIG_TCP_CONG_HSTCP=m 84CONFIG_TCP_CONG_HSTCP=m
351CONFIG_TCP_CONG_HYBLA=m 85CONFIG_TCP_CONG_HYBLA=m
352CONFIG_TCP_CONG_VEGAS=m
353CONFIG_TCP_CONG_SCALABLE=m 86CONFIG_TCP_CONG_SCALABLE=m
354CONFIG_TCP_CONG_LP=m 87CONFIG_TCP_CONG_LP=m
355CONFIG_TCP_CONG_VENO=m 88CONFIG_TCP_CONG_VENO=m
356CONFIG_TCP_CONG_YEAH=m 89CONFIG_TCP_CONG_YEAH=m
357CONFIG_TCP_CONG_ILLINOIS=m 90CONFIG_TCP_CONG_ILLINOIS=m
358CONFIG_DEFAULT_CUBIC=y
359# CONFIG_DEFAULT_RENO is not set
360CONFIG_DEFAULT_TCP_CONG="cubic"
361CONFIG_TCP_MD5SIG=y 91CONFIG_TCP_MD5SIG=y
362CONFIG_IPV6=y 92CONFIG_IPV6=y
363CONFIG_IPV6_PRIVACY=y 93CONFIG_IPV6_PRIVACY=y
@@ -368,111 +98,60 @@ CONFIG_INET6_AH=m
368CONFIG_INET6_ESP=m 98CONFIG_INET6_ESP=m
369CONFIG_INET6_IPCOMP=m 99CONFIG_INET6_IPCOMP=m
370CONFIG_IPV6_MIP6=m 100CONFIG_IPV6_MIP6=m
371CONFIG_INET6_XFRM_TUNNEL=m
372CONFIG_INET6_TUNNEL=m
373CONFIG_INET6_XFRM_MODE_TRANSPORT=m 101CONFIG_INET6_XFRM_MODE_TRANSPORT=m
374CONFIG_INET6_XFRM_MODE_TUNNEL=m 102CONFIG_INET6_XFRM_MODE_TUNNEL=m
375CONFIG_INET6_XFRM_MODE_BEET=m 103CONFIG_INET6_XFRM_MODE_BEET=m
376CONFIG_INET6_XFRM_MODE_ROUTEOPTIMIZATION=m 104CONFIG_INET6_XFRM_MODE_ROUTEOPTIMIZATION=m
377CONFIG_IPV6_SIT=m 105CONFIG_IPV6_SIT=m
378# CONFIG_IPV6_SIT_6RD is not set
379CONFIG_IPV6_NDISC_NODETYPE=y
380CONFIG_IPV6_TUNNEL=m 106CONFIG_IPV6_TUNNEL=m
381CONFIG_IPV6_MULTIPLE_TABLES=y 107CONFIG_IPV6_MULTIPLE_TABLES=y
382# CONFIG_IPV6_SUBTREES is not set
383CONFIG_IPV6_MROUTE=y 108CONFIG_IPV6_MROUTE=y
384# CONFIG_IPV6_MROUTE_MULTIPLE_TABLES is not set
385CONFIG_IPV6_PIMSM_V2=y 109CONFIG_IPV6_PIMSM_V2=y
386CONFIG_NETLABEL=y 110CONFIG_NETLABEL=y
387CONFIG_NETWORK_SECMARK=y
388# CONFIG_NETWORK_PHY_TIMESTAMPING is not set
389CONFIG_NETFILTER=y 111CONFIG_NETFILTER=y
390# CONFIG_NETFILTER_DEBUG is not set
391CONFIG_NETFILTER_ADVANCED=y
392CONFIG_BRIDGE_NETFILTER=y
393
394#
395# Core Netfilter Configuration
396#
397CONFIG_NETFILTER_NETLINK=m
398# CONFIG_NETFILTER_NETLINK_ACCT is not set
399CONFIG_NETFILTER_NETLINK_QUEUE=m
400CONFIG_NETFILTER_NETLINK_LOG=m
401CONFIG_NF_CONNTRACK=m 112CONFIG_NF_CONNTRACK=m
402CONFIG_NF_CONNTRACK_MARK=y
403CONFIG_NF_CONNTRACK_SECMARK=y 113CONFIG_NF_CONNTRACK_SECMARK=y
404CONFIG_NF_CONNTRACK_ZONES=y 114CONFIG_NF_CONNTRACK_ZONES=y
405CONFIG_NF_CONNTRACK_PROCFS=y
406CONFIG_NF_CONNTRACK_EVENTS=y 115CONFIG_NF_CONNTRACK_EVENTS=y
407# CONFIG_NF_CONNTRACK_TIMESTAMP is not set
408CONFIG_NF_CT_PROTO_DCCP=m 116CONFIG_NF_CT_PROTO_DCCP=m
409CONFIG_NF_CT_PROTO_GRE=m
410CONFIG_NF_CT_PROTO_SCTP=m
411CONFIG_NF_CT_PROTO_UDPLITE=m 117CONFIG_NF_CT_PROTO_UDPLITE=m
412CONFIG_NF_CONNTRACK_AMANDA=m 118CONFIG_NF_CONNTRACK_AMANDA=m
413CONFIG_NF_CONNTRACK_FTP=m 119CONFIG_NF_CONNTRACK_FTP=m
414CONFIG_NF_CONNTRACK_H323=m 120CONFIG_NF_CONNTRACK_H323=m
415CONFIG_NF_CONNTRACK_IRC=m 121CONFIG_NF_CONNTRACK_IRC=m
416CONFIG_NF_CONNTRACK_BROADCAST=m
417CONFIG_NF_CONNTRACK_NETBIOS_NS=m 122CONFIG_NF_CONNTRACK_NETBIOS_NS=m
418# CONFIG_NF_CONNTRACK_SNMP is not set
419CONFIG_NF_CONNTRACK_PPTP=m 123CONFIG_NF_CONNTRACK_PPTP=m
420CONFIG_NF_CONNTRACK_SANE=m 124CONFIG_NF_CONNTRACK_SANE=m
421CONFIG_NF_CONNTRACK_SIP=m 125CONFIG_NF_CONNTRACK_SIP=m
422CONFIG_NF_CONNTRACK_TFTP=m 126CONFIG_NF_CONNTRACK_TFTP=m
423# CONFIG_NF_CT_NETLINK is not set
424CONFIG_NETFILTER_TPROXY=m 127CONFIG_NETFILTER_TPROXY=m
425CONFIG_NETFILTER_XTABLES=y
426
427#
428# Xtables combined modules
429#
430CONFIG_NETFILTER_XT_MARK=m
431CONFIG_NETFILTER_XT_CONNMARK=m
432
433#
434# Xtables targets
435#
436# CONFIG_NETFILTER_XT_TARGET_AUDIT is not set
437# CONFIG_NETFILTER_XT_TARGET_CHECKSUM is not set
438CONFIG_NETFILTER_XT_TARGET_CLASSIFY=m 128CONFIG_NETFILTER_XT_TARGET_CLASSIFY=m
439CONFIG_NETFILTER_XT_TARGET_CONNMARK=m 129CONFIG_NETFILTER_XT_TARGET_CONNMARK=m
440CONFIG_NETFILTER_XT_TARGET_CONNSECMARK=m 130CONFIG_NETFILTER_XT_TARGET_CONNSECMARK=m
441CONFIG_NETFILTER_XT_TARGET_CT=m 131CONFIG_NETFILTER_XT_TARGET_CT=m
442CONFIG_NETFILTER_XT_TARGET_DSCP=m 132CONFIG_NETFILTER_XT_TARGET_DSCP=m
443CONFIG_NETFILTER_XT_TARGET_HL=m
444CONFIG_NETFILTER_XT_TARGET_IDLETIMER=m 133CONFIG_NETFILTER_XT_TARGET_IDLETIMER=m
445CONFIG_NETFILTER_XT_TARGET_MARK=m 134CONFIG_NETFILTER_XT_TARGET_MARK=m
446CONFIG_NETFILTER_XT_TARGET_NFLOG=m 135CONFIG_NETFILTER_XT_TARGET_NFLOG=m
447CONFIG_NETFILTER_XT_TARGET_NFQUEUE=m 136CONFIG_NETFILTER_XT_TARGET_NFQUEUE=m
448CONFIG_NETFILTER_XT_TARGET_NOTRACK=m 137CONFIG_NETFILTER_XT_TARGET_NOTRACK=m
449CONFIG_NETFILTER_XT_TARGET_RATEEST=m
450CONFIG_NETFILTER_XT_TARGET_TEE=m 138CONFIG_NETFILTER_XT_TARGET_TEE=m
451CONFIG_NETFILTER_XT_TARGET_TPROXY=m 139CONFIG_NETFILTER_XT_TARGET_TPROXY=m
452CONFIG_NETFILTER_XT_TARGET_TRACE=m 140CONFIG_NETFILTER_XT_TARGET_TRACE=m
453CONFIG_NETFILTER_XT_TARGET_SECMARK=m 141CONFIG_NETFILTER_XT_TARGET_SECMARK=m
454CONFIG_NETFILTER_XT_TARGET_TCPMSS=m 142CONFIG_NETFILTER_XT_TARGET_TCPMSS=m
455CONFIG_NETFILTER_XT_TARGET_TCPOPTSTRIP=m 143CONFIG_NETFILTER_XT_TARGET_TCPOPTSTRIP=m
456
457#
458# Xtables matches
459#
460# CONFIG_NETFILTER_XT_MATCH_ADDRTYPE is not set
461CONFIG_NETFILTER_XT_MATCH_CLUSTER=m 144CONFIG_NETFILTER_XT_MATCH_CLUSTER=m
462CONFIG_NETFILTER_XT_MATCH_COMMENT=m 145CONFIG_NETFILTER_XT_MATCH_COMMENT=m
463CONFIG_NETFILTER_XT_MATCH_CONNBYTES=m 146CONFIG_NETFILTER_XT_MATCH_CONNBYTES=m
464CONFIG_NETFILTER_XT_MATCH_CONNLIMIT=m 147CONFIG_NETFILTER_XT_MATCH_CONNLIMIT=m
465CONFIG_NETFILTER_XT_MATCH_CONNMARK=m 148CONFIG_NETFILTER_XT_MATCH_CONNMARK=m
466CONFIG_NETFILTER_XT_MATCH_CONNTRACK=m 149CONFIG_NETFILTER_XT_MATCH_CONNTRACK=m
467# CONFIG_NETFILTER_XT_MATCH_CPU is not set
468CONFIG_NETFILTER_XT_MATCH_DCCP=m 150CONFIG_NETFILTER_XT_MATCH_DCCP=m
469# CONFIG_NETFILTER_XT_MATCH_DEVGROUP is not set
470CONFIG_NETFILTER_XT_MATCH_DSCP=m 151CONFIG_NETFILTER_XT_MATCH_DSCP=m
471CONFIG_NETFILTER_XT_MATCH_ECN=m
472CONFIG_NETFILTER_XT_MATCH_ESP=m 152CONFIG_NETFILTER_XT_MATCH_ESP=m
473CONFIG_NETFILTER_XT_MATCH_HASHLIMIT=m 153CONFIG_NETFILTER_XT_MATCH_HASHLIMIT=m
474CONFIG_NETFILTER_XT_MATCH_HELPER=m 154CONFIG_NETFILTER_XT_MATCH_HELPER=m
475CONFIG_NETFILTER_XT_MATCH_HL=m
476CONFIG_NETFILTER_XT_MATCH_IPRANGE=m 155CONFIG_NETFILTER_XT_MATCH_IPRANGE=m
477CONFIG_NETFILTER_XT_MATCH_IPVS=m 156CONFIG_NETFILTER_XT_MATCH_IPVS=m
478CONFIG_NETFILTER_XT_MATCH_LENGTH=m 157CONFIG_NETFILTER_XT_MATCH_LENGTH=m
@@ -480,7 +159,6 @@ CONFIG_NETFILTER_XT_MATCH_LIMIT=m
480CONFIG_NETFILTER_XT_MATCH_MAC=m 159CONFIG_NETFILTER_XT_MATCH_MAC=m
481CONFIG_NETFILTER_XT_MATCH_MARK=m 160CONFIG_NETFILTER_XT_MATCH_MARK=m
482CONFIG_NETFILTER_XT_MATCH_MULTIPORT=m 161CONFIG_NETFILTER_XT_MATCH_MULTIPORT=m
483# CONFIG_NETFILTER_XT_MATCH_NFACCT is not set
484CONFIG_NETFILTER_XT_MATCH_OSF=m 162CONFIG_NETFILTER_XT_MATCH_OSF=m
485CONFIG_NETFILTER_XT_MATCH_OWNER=m 163CONFIG_NETFILTER_XT_MATCH_OWNER=m
486CONFIG_NETFILTER_XT_MATCH_POLICY=m 164CONFIG_NETFILTER_XT_MATCH_POLICY=m
@@ -490,7 +168,6 @@ CONFIG_NETFILTER_XT_MATCH_QUOTA=m
490CONFIG_NETFILTER_XT_MATCH_RATEEST=m 168CONFIG_NETFILTER_XT_MATCH_RATEEST=m
491CONFIG_NETFILTER_XT_MATCH_REALM=m 169CONFIG_NETFILTER_XT_MATCH_REALM=m
492CONFIG_NETFILTER_XT_MATCH_RECENT=m 170CONFIG_NETFILTER_XT_MATCH_RECENT=m
493CONFIG_NETFILTER_XT_MATCH_SCTP=m
494CONFIG_NETFILTER_XT_MATCH_SOCKET=m 171CONFIG_NETFILTER_XT_MATCH_SOCKET=m
495CONFIG_NETFILTER_XT_MATCH_STATE=m 172CONFIG_NETFILTER_XT_MATCH_STATE=m
496CONFIG_NETFILTER_XT_MATCH_STATISTIC=m 173CONFIG_NETFILTER_XT_MATCH_STATISTIC=m
@@ -498,66 +175,33 @@ CONFIG_NETFILTER_XT_MATCH_STRING=m
498CONFIG_NETFILTER_XT_MATCH_TCPMSS=m 175CONFIG_NETFILTER_XT_MATCH_TCPMSS=m
499CONFIG_NETFILTER_XT_MATCH_TIME=m 176CONFIG_NETFILTER_XT_MATCH_TIME=m
500CONFIG_NETFILTER_XT_MATCH_U32=m 177CONFIG_NETFILTER_XT_MATCH_U32=m
501# CONFIG_IP_SET is not set
502CONFIG_IP_VS=m 178CONFIG_IP_VS=m
503CONFIG_IP_VS_IPV6=y 179CONFIG_IP_VS_IPV6=y
504# CONFIG_IP_VS_DEBUG is not set
505CONFIG_IP_VS_TAB_BITS=12
506
507#
508# IPVS transport protocol load balancing support
509#
510CONFIG_IP_VS_PROTO_TCP=y 180CONFIG_IP_VS_PROTO_TCP=y
511CONFIG_IP_VS_PROTO_UDP=y 181CONFIG_IP_VS_PROTO_UDP=y
512CONFIG_IP_VS_PROTO_AH_ESP=y
513CONFIG_IP_VS_PROTO_ESP=y 182CONFIG_IP_VS_PROTO_ESP=y
514CONFIG_IP_VS_PROTO_AH=y 183CONFIG_IP_VS_PROTO_AH=y
515CONFIG_IP_VS_PROTO_SCTP=y 184CONFIG_IP_VS_PROTO_SCTP=y
516
517#
518# IPVS scheduler
519#
520CONFIG_IP_VS_RR=m 185CONFIG_IP_VS_RR=m
521CONFIG_IP_VS_WRR=m 186CONFIG_IP_VS_WRR=m
522CONFIG_IP_VS_LC=m 187CONFIG_IP_VS_LC=m
523CONFIG_IP_VS_WLC=m 188CONFIG_IP_VS_WLC=m
524CONFIG_IP_VS_LBLC=m 189CONFIG_IP_VS_LBLC=m
525CONFIG_IP_VS_LBLCR=m 190CONFIG_IP_VS_LBLCR=m
526# CONFIG_IP_VS_DH is not set
527# CONFIG_IP_VS_SH is not set
528CONFIG_IP_VS_SED=m 191CONFIG_IP_VS_SED=m
529CONFIG_IP_VS_NQ=m 192CONFIG_IP_VS_NQ=m
530
531#
532# IPVS SH scheduler
533#
534CONFIG_IP_VS_SH_TAB_BITS=8
535
536#
537# IPVS application helper
538#
539# CONFIG_IP_VS_NFCT is not set
540# CONFIG_IP_VS_PE_SIP is not set
541
542#
543# IP: Netfilter Configuration
544#
545CONFIG_NF_DEFRAG_IPV4=m
546CONFIG_NF_CONNTRACK_IPV4=m 193CONFIG_NF_CONNTRACK_IPV4=m
547# CONFIG_NF_CONNTRACK_PROC_COMPAT is not set 194# CONFIG_NF_CONNTRACK_PROC_COMPAT is not set
548CONFIG_IP_NF_QUEUE=m 195CONFIG_IP_NF_QUEUE=m
549CONFIG_IP_NF_IPTABLES=y 196CONFIG_IP_NF_IPTABLES=y
550CONFIG_IP_NF_MATCH_AH=m 197CONFIG_IP_NF_MATCH_AH=m
551CONFIG_IP_NF_MATCH_ECN=m 198CONFIG_IP_NF_MATCH_ECN=m
552# CONFIG_IP_NF_MATCH_RPFILTER is not set
553CONFIG_IP_NF_MATCH_TTL=m 199CONFIG_IP_NF_MATCH_TTL=m
554CONFIG_IP_NF_FILTER=y 200CONFIG_IP_NF_FILTER=y
555CONFIG_IP_NF_TARGET_REJECT=y 201CONFIG_IP_NF_TARGET_REJECT=y
556CONFIG_IP_NF_TARGET_LOG=m 202CONFIG_IP_NF_TARGET_LOG=m
557CONFIG_IP_NF_TARGET_ULOG=m 203CONFIG_IP_NF_TARGET_ULOG=m
558# CONFIG_NF_NAT is not set
559CONFIG_IP_NF_MANGLE=m 204CONFIG_IP_NF_MANGLE=m
560# CONFIG_IP_NF_TARGET_CLUSTERIP is not set
561CONFIG_IP_NF_TARGET_ECN=m 205CONFIG_IP_NF_TARGET_ECN=m
562CONFIG_IP_NF_TARGET_TTL=m 206CONFIG_IP_NF_TARGET_TTL=m
563CONFIG_IP_NF_RAW=m 207CONFIG_IP_NF_RAW=m
@@ -565,11 +209,6 @@ CONFIG_IP_NF_SECURITY=m
565CONFIG_IP_NF_ARPTABLES=m 209CONFIG_IP_NF_ARPTABLES=m
566CONFIG_IP_NF_ARPFILTER=m 210CONFIG_IP_NF_ARPFILTER=m
567CONFIG_IP_NF_ARP_MANGLE=m 211CONFIG_IP_NF_ARP_MANGLE=m
568
569#
570# IPv6: Netfilter Configuration
571#
572CONFIG_NF_DEFRAG_IPV6=m
573CONFIG_NF_CONNTRACK_IPV6=m 212CONFIG_NF_CONNTRACK_IPV6=m
574CONFIG_IP6_NF_QUEUE=m 213CONFIG_IP6_NF_QUEUE=m
575CONFIG_IP6_NF_IPTABLES=m 214CONFIG_IP6_NF_IPTABLES=m
@@ -580,7 +219,6 @@ CONFIG_IP6_NF_MATCH_OPTS=m
580CONFIG_IP6_NF_MATCH_HL=m 219CONFIG_IP6_NF_MATCH_HL=m
581CONFIG_IP6_NF_MATCH_IPV6HEADER=m 220CONFIG_IP6_NF_MATCH_IPV6HEADER=m
582CONFIG_IP6_NF_MATCH_MH=m 221CONFIG_IP6_NF_MATCH_MH=m
583# CONFIG_IP6_NF_MATCH_RPFILTER is not set
584CONFIG_IP6_NF_MATCH_RT=m 222CONFIG_IP6_NF_MATCH_RT=m
585CONFIG_IP6_NF_TARGET_HL=m 223CONFIG_IP6_NF_TARGET_HL=m
586CONFIG_IP6_NF_TARGET_LOG=m 224CONFIG_IP6_NF_TARGET_LOG=m
@@ -611,52 +249,20 @@ CONFIG_BRIDGE_EBT_SNAT=m
611CONFIG_BRIDGE_EBT_LOG=m 249CONFIG_BRIDGE_EBT_LOG=m
612CONFIG_BRIDGE_EBT_ULOG=m 250CONFIG_BRIDGE_EBT_ULOG=m
613CONFIG_BRIDGE_EBT_NFLOG=m 251CONFIG_BRIDGE_EBT_NFLOG=m
614# CONFIG_IP_DCCP is not set
615CONFIG_IP_SCTP=m
616# CONFIG_SCTP_DBG_MSG is not set
617# CONFIG_SCTP_DBG_OBJCNT is not set
618# CONFIG_SCTP_HMAC_NONE is not set
619# CONFIG_SCTP_HMAC_SHA1 is not set
620CONFIG_SCTP_HMAC_MD5=y
621CONFIG_RDS=m 252CONFIG_RDS=m
622CONFIG_RDS_TCP=m 253CONFIG_RDS_TCP=m
623# CONFIG_RDS_DEBUG is not set
624# CONFIG_TIPC is not set
625# CONFIG_ATM is not set
626# CONFIG_L2TP is not set
627CONFIG_STP=m
628CONFIG_GARP=m
629CONFIG_BRIDGE=m 254CONFIG_BRIDGE=m
630CONFIG_BRIDGE_IGMP_SNOOPING=y
631CONFIG_NET_DSA=y 255CONFIG_NET_DSA=y
632CONFIG_NET_DSA_TAG_DSA=y
633CONFIG_NET_DSA_TAG_EDSA=y
634CONFIG_NET_DSA_TAG_TRAILER=y
635CONFIG_VLAN_8021Q=m 256CONFIG_VLAN_8021Q=m
636CONFIG_VLAN_8021Q_GVRP=y 257CONFIG_VLAN_8021Q_GVRP=y
637# CONFIG_DECNET is not set
638CONFIG_LLC=m
639# CONFIG_LLC2 is not set
640# CONFIG_IPX is not set
641# CONFIG_ATALK is not set
642# CONFIG_X25 is not set
643# CONFIG_LAPB is not set
644# CONFIG_ECONET is not set
645# CONFIG_WAN_ROUTER is not set
646CONFIG_PHONET=m 258CONFIG_PHONET=m
647# CONFIG_IEEE802154 is not set
648CONFIG_NET_SCHED=y 259CONFIG_NET_SCHED=y
649
650#
651# Queueing/Scheduling
652#
653CONFIG_NET_SCH_CBQ=m 260CONFIG_NET_SCH_CBQ=m
654CONFIG_NET_SCH_HTB=m 261CONFIG_NET_SCH_HTB=m
655CONFIG_NET_SCH_HFSC=m 262CONFIG_NET_SCH_HFSC=m
656CONFIG_NET_SCH_PRIO=m 263CONFIG_NET_SCH_PRIO=m
657CONFIG_NET_SCH_MULTIQ=m 264CONFIG_NET_SCH_MULTIQ=m
658CONFIG_NET_SCH_RED=m 265CONFIG_NET_SCH_RED=m
659# CONFIG_NET_SCH_SFB is not set
660CONFIG_NET_SCH_SFQ=m 266CONFIG_NET_SCH_SFQ=m
661CONFIG_NET_SCH_TEQL=m 267CONFIG_NET_SCH_TEQL=m
662CONFIG_NET_SCH_TBF=m 268CONFIG_NET_SCH_TBF=m
@@ -664,15 +270,7 @@ CONFIG_NET_SCH_GRED=m
664CONFIG_NET_SCH_DSMARK=m 270CONFIG_NET_SCH_DSMARK=m
665CONFIG_NET_SCH_NETEM=m 271CONFIG_NET_SCH_NETEM=m
666CONFIG_NET_SCH_DRR=m 272CONFIG_NET_SCH_DRR=m
667# CONFIG_NET_SCH_MQPRIO is not set
668# CONFIG_NET_SCH_CHOKE is not set
669# CONFIG_NET_SCH_QFQ is not set
670CONFIG_NET_SCH_INGRESS=m 273CONFIG_NET_SCH_INGRESS=m
671
672#
673# Classification
674#
675CONFIG_NET_CLS=y
676CONFIG_NET_CLS_BASIC=m 274CONFIG_NET_CLS_BASIC=m
677CONFIG_NET_CLS_TCINDEX=m 275CONFIG_NET_CLS_TCINDEX=m
678CONFIG_NET_CLS_ROUTE4=m 276CONFIG_NET_CLS_ROUTE4=m
@@ -685,7 +283,6 @@ CONFIG_NET_CLS_RSVP6=m
685CONFIG_NET_CLS_FLOW=m 283CONFIG_NET_CLS_FLOW=m
686CONFIG_NET_CLS_CGROUP=y 284CONFIG_NET_CLS_CGROUP=y
687CONFIG_NET_EMATCH=y 285CONFIG_NET_EMATCH=y
688CONFIG_NET_EMATCH_STACK=32
689CONFIG_NET_EMATCH_CMP=m 286CONFIG_NET_EMATCH_CMP=m
690CONFIG_NET_EMATCH_NBYTE=m 287CONFIG_NET_EMATCH_NBYTE=m
691CONFIG_NET_EMATCH_U32=m 288CONFIG_NET_EMATCH_U32=m
@@ -701,252 +298,46 @@ CONFIG_NET_ACT_NAT=m
701CONFIG_NET_ACT_PEDIT=m 298CONFIG_NET_ACT_PEDIT=m
702CONFIG_NET_ACT_SIMP=m 299CONFIG_NET_ACT_SIMP=m
703CONFIG_NET_ACT_SKBEDIT=m 300CONFIG_NET_ACT_SKBEDIT=m
704# CONFIG_NET_ACT_CSUM is not set
705CONFIG_NET_CLS_IND=y 301CONFIG_NET_CLS_IND=y
706CONFIG_NET_SCH_FIFO=y
707CONFIG_DCB=y 302CONFIG_DCB=y
708CONFIG_DNS_RESOLVER=y
709# CONFIG_BATMAN_ADV is not set
710# CONFIG_OPENVSWITCH is not set
711CONFIG_RPS=y
712CONFIG_RFS_ACCEL=y
713CONFIG_XPS=y
714# CONFIG_NETPRIO_CGROUP is not set
715CONFIG_BQL=y
716
717#
718# Network testing
719#
720# CONFIG_NET_PKTGEN is not set
721# CONFIG_HAMRADIO is not set
722# CONFIG_CAN is not set
723# CONFIG_IRDA is not set
724# CONFIG_BT is not set
725# CONFIG_AF_RXRPC is not set
726CONFIG_FIB_RULES=y
727# CONFIG_WIRELESS is not set 303# CONFIG_WIRELESS is not set
728# CONFIG_WIMAX is not set
729# CONFIG_RFKILL is not set
730# CONFIG_NET_9P is not set
731# CONFIG_CAIF is not set
732# CONFIG_CEPH_LIB is not set
733# CONFIG_NFC is not set
734
735#
736# Device Drivers
737#
738
739#
740# Generic Driver Options
741#
742CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug" 304CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug"
743CONFIG_DEVTMPFS=y 305CONFIG_DEVTMPFS=y
744CONFIG_DEVTMPFS_MOUNT=y 306CONFIG_DEVTMPFS_MOUNT=y
745CONFIG_STANDALONE=y
746CONFIG_PREVENT_FIRMWARE_BUILD=y
747CONFIG_FW_LOADER=y
748# CONFIG_FIRMWARE_IN_KERNEL is not set 307# CONFIG_FIRMWARE_IN_KERNEL is not set
749CONFIG_EXTRA_FIRMWARE=""
750# CONFIG_DEBUG_DRIVER is not set
751# CONFIG_DEBUG_DEVRES is not set
752CONFIG_SYS_HYPERVISOR=y
753# CONFIG_GENERIC_CPU_DEVICES is not set
754# CONFIG_DMA_SHARED_BUFFER is not set
755CONFIG_CONNECTOR=y 308CONFIG_CONNECTOR=y
756CONFIG_PROC_EVENTS=y
757# CONFIG_MTD is not set
758# CONFIG_PARPORT is not set
759CONFIG_BLK_DEV=y
760# CONFIG_BLK_CPQ_DA is not set
761# CONFIG_BLK_CPQ_CISS_DA is not set
762# CONFIG_BLK_DEV_DAC960 is not set
763# CONFIG_BLK_DEV_UMEM is not set
764# CONFIG_BLK_DEV_COW_COMMON is not set
765CONFIG_BLK_DEV_LOOP=y 309CONFIG_BLK_DEV_LOOP=y
766CONFIG_BLK_DEV_LOOP_MIN_COUNT=8
767CONFIG_BLK_DEV_CRYPTOLOOP=m 310CONFIG_BLK_DEV_CRYPTOLOOP=m
768# CONFIG_BLK_DEV_DRBD is not set
769# CONFIG_BLK_DEV_NBD is not set
770# CONFIG_BLK_DEV_NVME is not set
771CONFIG_BLK_DEV_SX8=m 311CONFIG_BLK_DEV_SX8=m
772# CONFIG_BLK_DEV_UB is not set
773CONFIG_BLK_DEV_RAM=y 312CONFIG_BLK_DEV_RAM=y
774CONFIG_BLK_DEV_RAM_COUNT=16
775CONFIG_BLK_DEV_RAM_SIZE=16384 313CONFIG_BLK_DEV_RAM_SIZE=16384
776# CONFIG_BLK_DEV_XIP is not set
777# CONFIG_CDROM_PKTCDVD is not set
778CONFIG_ATA_OVER_ETH=m 314CONFIG_ATA_OVER_ETH=m
779# CONFIG_BLK_DEV_RBD is not set
780
781#
782# Misc devices
783#
784# CONFIG_SENSORS_LIS3LV02D is not set
785# CONFIG_AD525X_DPOT is not set
786# CONFIG_PHANTOM is not set
787# CONFIG_INTEL_MID_PTI is not set
788# CONFIG_SGI_IOC4 is not set
789# CONFIG_TIFM_CORE is not set
790# CONFIG_ICS932S401 is not set
791# CONFIG_ENCLOSURE_SERVICES is not set
792# CONFIG_HP_ILO is not set
793# CONFIG_APDS9802ALS is not set
794# CONFIG_ISL29003 is not set
795# CONFIG_ISL29020 is not set
796# CONFIG_SENSORS_TSL2550 is not set
797# CONFIG_SENSORS_BH1780 is not set
798# CONFIG_SENSORS_BH1770 is not set
799# CONFIG_SENSORS_APDS990X is not set
800# CONFIG_HMC6352 is not set
801# CONFIG_DS1682 is not set
802# CONFIG_BMP085 is not set
803# CONFIG_PCH_PHUB is not set
804# CONFIG_USB_SWITCH_FSA9480 is not set
805# CONFIG_C2PORT is not set
806
807#
808# EEPROM support
809#
810# CONFIG_EEPROM_AT24 is not set
811# CONFIG_EEPROM_LEGACY is not set
812# CONFIG_EEPROM_MAX6875 is not set
813# CONFIG_EEPROM_93CX6 is not set
814# CONFIG_CB710_CORE is not set
815
816#
817# Texas Instruments shared transport line discipline
818#
819# CONFIG_SENSORS_LIS3_I2C is not set
820
821#
822# Altera FPGA firmware download module
823#
824# CONFIG_ALTERA_STAPL is not set
825
826#
827# SCSI device support
828#
829CONFIG_SCSI_MOD=y
830CONFIG_RAID_ATTRS=m 315CONFIG_RAID_ATTRS=m
831CONFIG_SCSI=y
832CONFIG_SCSI_DMA=y
833CONFIG_SCSI_TGT=m 316CONFIG_SCSI_TGT=m
834# CONFIG_SCSI_NETLINK is not set
835CONFIG_SCSI_PROC_FS=y
836
837#
838# SCSI support type (disk, tape, CD-ROM)
839#
840CONFIG_BLK_DEV_SD=y 317CONFIG_BLK_DEV_SD=y
841# CONFIG_CHR_DEV_ST is not set
842# CONFIG_CHR_DEV_OSST is not set
843# CONFIG_BLK_DEV_SR is not set
844# CONFIG_CHR_DEV_SG is not set
845# CONFIG_CHR_DEV_SCH is not set
846# CONFIG_SCSI_MULTI_LUN is not set
847CONFIG_SCSI_CONSTANTS=y 318CONFIG_SCSI_CONSTANTS=y
848CONFIG_SCSI_LOGGING=y 319CONFIG_SCSI_LOGGING=y
849# CONFIG_SCSI_SCAN_ASYNC is not set
850CONFIG_SCSI_WAIT_SCAN=m
851
852#
853# SCSI Transports
854#
855# CONFIG_SCSI_SPI_ATTRS is not set
856# CONFIG_SCSI_FC_ATTRS is not set
857# CONFIG_SCSI_ISCSI_ATTRS is not set
858CONFIG_SCSI_SAS_ATTRS=y
859CONFIG_SCSI_SAS_LIBSAS=y
860CONFIG_SCSI_SAS_ATA=y 320CONFIG_SCSI_SAS_ATA=y
861CONFIG_SCSI_SAS_HOST_SMP=y
862# CONFIG_SCSI_SRP_ATTRS is not set
863CONFIG_SCSI_LOWLEVEL=y
864# CONFIG_ISCSI_TCP is not set
865# CONFIG_ISCSI_BOOT_SYSFS is not set
866# CONFIG_SCSI_CXGB3_ISCSI is not set
867# CONFIG_SCSI_CXGB4_ISCSI is not set
868# CONFIG_SCSI_BNX2_ISCSI is not set
869# CONFIG_SCSI_BNX2X_FCOE is not set
870# CONFIG_BE2ISCSI is not set
871# CONFIG_BLK_DEV_3W_XXXX_RAID is not set
872# CONFIG_SCSI_HPSA is not set
873# CONFIG_SCSI_3W_9XXX is not set
874# CONFIG_SCSI_3W_SAS is not set
875# CONFIG_SCSI_ACARD is not set
876# CONFIG_SCSI_AACRAID is not set
877# CONFIG_SCSI_AIC7XXX is not set
878# CONFIG_SCSI_AIC7XXX_OLD is not set
879# CONFIG_SCSI_AIC79XX is not set
880# CONFIG_SCSI_AIC94XX is not set
881CONFIG_SCSI_MVSAS=y 321CONFIG_SCSI_MVSAS=y
882# CONFIG_SCSI_MVSAS_DEBUG is not set 322# CONFIG_SCSI_MVSAS_DEBUG is not set
883CONFIG_SCSI_MVSAS_TASKLET=y 323CONFIG_SCSI_MVSAS_TASKLET=y
884# CONFIG_SCSI_MVUMI is not set
885# CONFIG_SCSI_DPT_I2O is not set
886# CONFIG_SCSI_ADVANSYS is not set
887# CONFIG_SCSI_ARCMSR is not set
888# CONFIG_MEGARAID_NEWGEN is not set
889# CONFIG_MEGARAID_LEGACY is not set
890# CONFIG_MEGARAID_SAS is not set
891# CONFIG_SCSI_MPT2SAS is not set
892# CONFIG_SCSI_HPTIOP is not set
893# CONFIG_LIBFC is not set
894# CONFIG_LIBFCOE is not set
895# CONFIG_FCOE is not set
896# CONFIG_SCSI_DMX3191D is not set
897# CONFIG_SCSI_FUTURE_DOMAIN is not set
898# CONFIG_SCSI_IPS is not set
899# CONFIG_SCSI_INITIO is not set
900# CONFIG_SCSI_INIA100 is not set
901# CONFIG_SCSI_STEX is not set
902# CONFIG_SCSI_SYM53C8XX_2 is not set
903# CONFIG_SCSI_IPR is not set
904# CONFIG_SCSI_QLOGIC_1280 is not set
905# CONFIG_SCSI_QLA_FC is not set
906# CONFIG_SCSI_QLA_ISCSI is not set
907# CONFIG_SCSI_LPFC is not set
908# CONFIG_SCSI_DC395x is not set
909# CONFIG_SCSI_DC390T is not set
910# CONFIG_SCSI_DEBUG is not set
911# CONFIG_SCSI_PMCRAID is not set
912# CONFIG_SCSI_PM8001 is not set
913# CONFIG_SCSI_SRP is not set
914# CONFIG_SCSI_BFA_FC is not set
915# CONFIG_SCSI_LOWLEVEL_PCMCIA is not set
916# CONFIG_SCSI_DH is not set
917# CONFIG_SCSI_OSD_INITIATOR is not set
918CONFIG_ATA=y 324CONFIG_ATA=y
919# CONFIG_ATA_NONSTANDARD is not set
920CONFIG_ATA_VERBOSE_ERROR=y
921CONFIG_SATA_PMP=y
922
923#
924# Controllers with non-SFF native interface
925#
926# CONFIG_SATA_AHCI is not set
927# CONFIG_SATA_AHCI_PLATFORM is not set
928# CONFIG_SATA_INIC162X is not set
929# CONFIG_SATA_ACARD_AHCI is not set
930CONFIG_SATA_SIL24=y 325CONFIG_SATA_SIL24=y
931# CONFIG_ATA_SFF is not set 326# CONFIG_ATA_SFF is not set
932CONFIG_MD=y 327CONFIG_MD=y
933CONFIG_BLK_DEV_MD=y 328CONFIG_BLK_DEV_MD=y
934CONFIG_MD_AUTODETECT=y
935CONFIG_MD_LINEAR=m 329CONFIG_MD_LINEAR=m
936CONFIG_MD_RAID0=m 330CONFIG_MD_RAID0=m
937CONFIG_MD_RAID1=m 331CONFIG_MD_RAID1=m
938CONFIG_MD_RAID10=m 332CONFIG_MD_RAID10=m
939CONFIG_MD_RAID456=m 333CONFIG_MD_RAID456=m
940CONFIG_MULTICORE_RAID456=y 334CONFIG_MULTICORE_RAID456=y
941# CONFIG_MD_MULTIPATH is not set
942CONFIG_MD_FAULTY=m 335CONFIG_MD_FAULTY=m
943CONFIG_BLK_DEV_DM=m 336CONFIG_BLK_DEV_DM=m
944CONFIG_DM_DEBUG=y 337CONFIG_DM_DEBUG=y
945CONFIG_DM_CRYPT=m 338CONFIG_DM_CRYPT=m
946CONFIG_DM_SNAPSHOT=m 339CONFIG_DM_SNAPSHOT=m
947# CONFIG_DM_THIN_PROVISIONING is not set
948CONFIG_DM_MIRROR=m 340CONFIG_DM_MIRROR=m
949# CONFIG_DM_RAID is not set
950CONFIG_DM_LOG_USERSPACE=m 341CONFIG_DM_LOG_USERSPACE=m
951CONFIG_DM_ZERO=m 342CONFIG_DM_ZERO=m
952CONFIG_DM_MULTIPATH=m 343CONFIG_DM_MULTIPATH=m
@@ -954,55 +345,22 @@ CONFIG_DM_MULTIPATH_QL=m
954CONFIG_DM_MULTIPATH_ST=m 345CONFIG_DM_MULTIPATH_ST=m
955CONFIG_DM_DELAY=m 346CONFIG_DM_DELAY=m
956CONFIG_DM_UEVENT=y 347CONFIG_DM_UEVENT=y
957# CONFIG_DM_FLAKEY is not set
958# CONFIG_TARGET_CORE is not set
959CONFIG_FUSION=y 348CONFIG_FUSION=y
960# CONFIG_FUSION_SPI is not set
961# CONFIG_FUSION_FC is not set
962CONFIG_FUSION_SAS=y 349CONFIG_FUSION_SAS=y
963CONFIG_FUSION_MAX_SGE=128
964# CONFIG_FUSION_CTL is not set
965# CONFIG_FUSION_LOGGING is not set
966
967#
968# IEEE 1394 (FireWire) support
969#
970# CONFIG_FIREWIRE is not set
971# CONFIG_FIREWIRE_NOSY is not set
972# CONFIG_I2O is not set
973CONFIG_NETDEVICES=y 350CONFIG_NETDEVICES=y
974CONFIG_NET_CORE=y
975CONFIG_BONDING=m 351CONFIG_BONDING=m
976CONFIG_DUMMY=m 352CONFIG_DUMMY=m
977# CONFIG_EQUALIZER is not set
978# CONFIG_NET_FC is not set
979# CONFIG_MII is not set
980CONFIG_IFB=m 353CONFIG_IFB=m
981# CONFIG_NET_TEAM is not set
982CONFIG_MACVLAN=m 354CONFIG_MACVLAN=m
983CONFIG_MACVTAP=m 355CONFIG_MACVTAP=m
984CONFIG_NETCONSOLE=m 356CONFIG_NETCONSOLE=m
985CONFIG_NETCONSOLE_DYNAMIC=y 357CONFIG_NETCONSOLE_DYNAMIC=y
986CONFIG_NETPOLL=y
987CONFIG_NETPOLL_TRAP=y 358CONFIG_NETPOLL_TRAP=y
988CONFIG_NET_POLL_CONTROLLER=y
989CONFIG_TUN=y 359CONFIG_TUN=y
990CONFIG_VETH=m 360CONFIG_VETH=m
991# CONFIG_ARCNET is not set
992
993#
994# CAIF transport drivers
995#
996
997#
998# Distributed Switch Architecture drivers
999#
1000CONFIG_NET_DSA_MV88E6XXX=y
1001CONFIG_NET_DSA_MV88E6060=y 361CONFIG_NET_DSA_MV88E6060=y
1002CONFIG_NET_DSA_MV88E6XXX_NEED_PPU=y
1003CONFIG_NET_DSA_MV88E6131=y 362CONFIG_NET_DSA_MV88E6131=y
1004CONFIG_NET_DSA_MV88E6123_61_65=y 363CONFIG_NET_DSA_MV88E6123_61_65=y
1005CONFIG_ETHERNET=y
1006# CONFIG_NET_VENDOR_3COM is not set 364# CONFIG_NET_VENDOR_3COM is not set
1007# CONFIG_NET_VENDOR_ADAPTEC is not set 365# CONFIG_NET_VENDOR_ADAPTEC is not set
1008# CONFIG_NET_VENDOR_ALTEON is not set 366# CONFIG_NET_VENDOR_ALTEON is not set
@@ -1010,27 +368,21 @@ CONFIG_ETHERNET=y
1010# CONFIG_NET_VENDOR_ATHEROS is not set 368# CONFIG_NET_VENDOR_ATHEROS is not set
1011# CONFIG_NET_VENDOR_BROADCOM is not set 369# CONFIG_NET_VENDOR_BROADCOM is not set
1012# CONFIG_NET_VENDOR_BROCADE is not set 370# CONFIG_NET_VENDOR_BROCADE is not set
1013# CONFIG_NET_CALXEDA_XGMAC is not set
1014# CONFIG_NET_VENDOR_CHELSIO is not set 371# CONFIG_NET_VENDOR_CHELSIO is not set
1015# CONFIG_NET_VENDOR_CISCO is not set 372# CONFIG_NET_VENDOR_CISCO is not set
1016# CONFIG_DNET is not set
1017# CONFIG_NET_VENDOR_DEC is not set 373# CONFIG_NET_VENDOR_DEC is not set
1018# CONFIG_NET_VENDOR_DLINK is not set 374# CONFIG_NET_VENDOR_DLINK is not set
1019# CONFIG_NET_VENDOR_EMULEX is not set 375# CONFIG_NET_VENDOR_EMULEX is not set
1020# CONFIG_NET_VENDOR_EXAR is not set 376# CONFIG_NET_VENDOR_EXAR is not set
1021# CONFIG_NET_VENDOR_HP is not set 377# CONFIG_NET_VENDOR_HP is not set
1022# CONFIG_NET_VENDOR_INTEL is not set 378# CONFIG_NET_VENDOR_INTEL is not set
1023# CONFIG_IP1000 is not set
1024# CONFIG_JME is not set
1025# CONFIG_NET_VENDOR_MARVELL is not set 379# CONFIG_NET_VENDOR_MARVELL is not set
1026# CONFIG_NET_VENDOR_MELLANOX is not set 380# CONFIG_NET_VENDOR_MELLANOX is not set
1027# CONFIG_NET_VENDOR_MICREL is not set 381# CONFIG_NET_VENDOR_MICREL is not set
1028# CONFIG_NET_VENDOR_MYRI is not set 382# CONFIG_NET_VENDOR_MYRI is not set
1029# CONFIG_FEALNX is not set
1030# CONFIG_NET_VENDOR_NATSEMI is not set 383# CONFIG_NET_VENDOR_NATSEMI is not set
1031# CONFIG_NET_VENDOR_NVIDIA is not set 384# CONFIG_NET_VENDOR_NVIDIA is not set
1032# CONFIG_NET_VENDOR_OKI is not set 385# CONFIG_NET_VENDOR_OKI is not set
1033# CONFIG_ETHOC is not set
1034# CONFIG_NET_PACKET_ENGINE is not set 386# CONFIG_NET_PACKET_ENGINE is not set
1035# CONFIG_NET_VENDOR_QLOGIC is not set 387# CONFIG_NET_VENDOR_QLOGIC is not set
1036# CONFIG_NET_VENDOR_REALTEK is not set 388# CONFIG_NET_VENDOR_REALTEK is not set
@@ -1038,7 +390,6 @@ CONFIG_ETHERNET=y
1038# CONFIG_NET_VENDOR_SEEQ is not set 390# CONFIG_NET_VENDOR_SEEQ is not set
1039# CONFIG_NET_VENDOR_SILAN is not set 391# CONFIG_NET_VENDOR_SILAN is not set
1040# CONFIG_NET_VENDOR_SIS is not set 392# CONFIG_NET_VENDOR_SIS is not set
1041# CONFIG_SFC is not set
1042# CONFIG_NET_VENDOR_SMSC is not set 393# CONFIG_NET_VENDOR_SMSC is not set
1043# CONFIG_NET_VENDOR_STMICRO is not set 394# CONFIG_NET_VENDOR_STMICRO is not set
1044# CONFIG_NET_VENDOR_SUN is not set 395# CONFIG_NET_VENDOR_SUN is not set
@@ -1046,673 +397,91 @@ CONFIG_ETHERNET=y
1046# CONFIG_NET_VENDOR_TI is not set 397# CONFIG_NET_VENDOR_TI is not set
1047# CONFIG_TILE_NET is not set 398# CONFIG_TILE_NET is not set
1048# CONFIG_NET_VENDOR_VIA is not set 399# CONFIG_NET_VENDOR_VIA is not set
1049# CONFIG_FDDI is not set
1050# CONFIG_HIPPI is not set
1051CONFIG_PHYLIB=y
1052
1053#
1054# MII PHY device drivers
1055#
1056# CONFIG_MARVELL_PHY is not set
1057# CONFIG_DAVICOM_PHY is not set
1058# CONFIG_QSEMI_PHY is not set
1059# CONFIG_LXT_PHY is not set
1060# CONFIG_CICADA_PHY is not set
1061# CONFIG_VITESSE_PHY is not set
1062# CONFIG_SMSC_PHY is not set
1063# CONFIG_BROADCOM_PHY is not set
1064# CONFIG_ICPLUS_PHY is not set
1065# CONFIG_REALTEK_PHY is not set
1066# CONFIG_NATIONAL_PHY is not set
1067# CONFIG_STE10XP is not set
1068# CONFIG_LSI_ET1011C_PHY is not set
1069# CONFIG_MICREL_PHY is not set
1070# CONFIG_FIXED_PHY is not set
1071# CONFIG_MDIO_BITBANG is not set
1072# CONFIG_PPP is not set
1073# CONFIG_SLIP is not set
1074# CONFIG_TR is not set
1075
1076#
1077# USB Network Adapters
1078#
1079# CONFIG_USB_CATC is not set
1080# CONFIG_USB_KAWETH is not set
1081# CONFIG_USB_PEGASUS is not set
1082# CONFIG_USB_RTL8150 is not set
1083# CONFIG_USB_USBNET is not set
1084# CONFIG_USB_CDC_PHONET is not set
1085# CONFIG_USB_IPHETH is not set
1086# CONFIG_WLAN is not set 400# CONFIG_WLAN is not set
1087
1088#
1089# Enable WiMAX (Networking options) to see the WiMAX drivers
1090#
1091# CONFIG_WAN is not set
1092# CONFIG_VMXNET3 is not set
1093# CONFIG_ISDN is not set
1094# CONFIG_PHONE is not set
1095
1096#
1097# Input device support
1098#
1099CONFIG_INPUT=y
1100# CONFIG_INPUT_FF_MEMLESS is not set
1101# CONFIG_INPUT_POLLDEV is not set
1102# CONFIG_INPUT_SPARSEKMAP is not set
1103
1104#
1105# Userland interfaces
1106#
1107# CONFIG_INPUT_MOUSEDEV is not set 401# CONFIG_INPUT_MOUSEDEV is not set
1108# CONFIG_INPUT_JOYDEV is not set
1109# CONFIG_INPUT_EVDEV is not set
1110# CONFIG_INPUT_EVBUG is not set
1111
1112#
1113# Input Device Drivers
1114#
1115# CONFIG_INPUT_KEYBOARD is not set 402# CONFIG_INPUT_KEYBOARD is not set
1116# CONFIG_INPUT_MOUSE is not set 403# CONFIG_INPUT_MOUSE is not set
1117# CONFIG_INPUT_JOYSTICK is not set
1118# CONFIG_INPUT_TABLET is not set
1119# CONFIG_INPUT_TOUCHSCREEN is not set
1120# CONFIG_INPUT_MISC is not set
1121
1122#
1123# Hardware I/O ports
1124#
1125# CONFIG_SERIO is not set 404# CONFIG_SERIO is not set
1126# CONFIG_GAMEPORT is not set
1127
1128#
1129# Character devices
1130#
1131# CONFIG_VT is not set 405# CONFIG_VT is not set
1132CONFIG_UNIX98_PTYS=y
1133# CONFIG_DEVPTS_MULTIPLE_INSTANCES is not set
1134# CONFIG_LEGACY_PTYS is not set 406# CONFIG_LEGACY_PTYS is not set
1135# CONFIG_SERIAL_NONSTANDARD is not set
1136# CONFIG_NOZOMI is not set
1137# CONFIG_N_GSM is not set
1138# CONFIG_TRACE_SINK is not set
1139CONFIG_DEVKMEM=y
1140
1141#
1142# Serial drivers
1143#
1144# CONFIG_SERIAL_8250 is not set
1145
1146#
1147# Non-8250 serial port support
1148#
1149# CONFIG_SERIAL_MFD_HSU is not set
1150# CONFIG_SERIAL_JSM is not set
1151# CONFIG_SERIAL_TIMBERDALE is not set
1152# CONFIG_SERIAL_ALTERA_JTAGUART is not set
1153# CONFIG_SERIAL_ALTERA_UART is not set
1154# CONFIG_SERIAL_PCH_UART is not set
1155# CONFIG_SERIAL_XILINX_PS_UART is not set
1156# CONFIG_TTY_PRINTK is not set
1157CONFIG_HVC_DRIVER=y
1158# CONFIG_IPMI_HANDLER is not set
1159CONFIG_HW_RANDOM=y 407CONFIG_HW_RANDOM=y
1160CONFIG_HW_RANDOM_TIMERIOMEM=m 408CONFIG_HW_RANDOM_TIMERIOMEM=m
1161# CONFIG_R3964 is not set
1162# CONFIG_APPLICOM is not set
1163
1164#
1165# PCMCIA character devices
1166#
1167# CONFIG_RAW_DRIVER is not set
1168# CONFIG_TCG_TPM is not set
1169CONFIG_DEVPORT=y
1170# CONFIG_RAMOOPS is not set
1171CONFIG_TILE_SROM=y
1172CONFIG_I2C=y 409CONFIG_I2C=y
1173CONFIG_I2C_BOARDINFO=y
1174CONFIG_I2C_COMPAT=y
1175CONFIG_I2C_CHARDEV=y 410CONFIG_I2C_CHARDEV=y
1176# CONFIG_I2C_MUX is not set
1177CONFIG_I2C_HELPER_AUTO=y
1178
1179#
1180# I2C Hardware Bus support
1181#
1182
1183#
1184# PC SMBus host controller drivers
1185#
1186# CONFIG_I2C_ALI1535 is not set
1187# CONFIG_I2C_ALI1563 is not set
1188# CONFIG_I2C_ALI15X3 is not set
1189# CONFIG_I2C_AMD756 is not set
1190# CONFIG_I2C_AMD8111 is not set
1191# CONFIG_I2C_I801 is not set
1192# CONFIG_I2C_ISCH is not set
1193# CONFIG_I2C_PIIX4 is not set
1194# CONFIG_I2C_NFORCE2 is not set
1195# CONFIG_I2C_SIS5595 is not set
1196# CONFIG_I2C_SIS630 is not set
1197# CONFIG_I2C_SIS96X is not set
1198# CONFIG_I2C_VIA is not set
1199# CONFIG_I2C_VIAPRO is not set
1200
1201#
1202# I2C system bus drivers (mostly embedded / system-on-chip)
1203#
1204# CONFIG_I2C_DESIGNWARE_PCI is not set
1205# CONFIG_I2C_INTEL_MID is not set
1206# CONFIG_I2C_OCORES is not set
1207# CONFIG_I2C_PCA_PLATFORM is not set
1208# CONFIG_I2C_PXA_PCI is not set
1209# CONFIG_I2C_SIMTEC is not set
1210# CONFIG_I2C_XILINX is not set
1211# CONFIG_I2C_EG20T is not set
1212
1213#
1214# External I2C/SMBus adapter drivers
1215#
1216# CONFIG_I2C_DIOLAN_U2C is not set
1217# CONFIG_I2C_PARPORT_LIGHT is not set
1218# CONFIG_I2C_TAOS_EVM is not set
1219# CONFIG_I2C_TINY_USB is not set
1220
1221#
1222# Other I2C/SMBus bus drivers
1223#
1224# CONFIG_I2C_STUB is not set
1225# CONFIG_I2C_DEBUG_CORE is not set
1226# CONFIG_I2C_DEBUG_ALGO is not set
1227# CONFIG_I2C_DEBUG_BUS is not set
1228# CONFIG_SPI is not set
1229
1230#
1231# PPS support
1232#
1233# CONFIG_PPS is not set
1234
1235#
1236# PPS generators support
1237#
1238
1239#
1240# PTP clock support
1241#
1242
1243#
1244# Enable Device Drivers -> PPS to see the PTP clock options.
1245#
1246# CONFIG_W1 is not set
1247# CONFIG_POWER_SUPPLY is not set
1248# CONFIG_HWMON is not set 411# CONFIG_HWMON is not set
1249# CONFIG_THERMAL is not set
1250CONFIG_WATCHDOG=y 412CONFIG_WATCHDOG=y
1251# CONFIG_WATCHDOG_CORE is not set
1252CONFIG_WATCHDOG_NOWAYOUT=y 413CONFIG_WATCHDOG_NOWAYOUT=y
1253
1254#
1255# Watchdog Device Drivers
1256#
1257# CONFIG_SOFT_WATCHDOG is not set
1258# CONFIG_ALIM7101_WDT is not set
1259
1260#
1261# PCI-based Watchdog Cards
1262#
1263# CONFIG_PCIPCWATCHDOG is not set
1264# CONFIG_WDTPCI is not set
1265
1266#
1267# USB-based Watchdog Cards
1268#
1269# CONFIG_USBPCWATCHDOG is not set
1270CONFIG_SSB_POSSIBLE=y
1271
1272#
1273# Sonics Silicon Backplane
1274#
1275# CONFIG_SSB is not set
1276CONFIG_BCMA_POSSIBLE=y
1277
1278#
1279# Broadcom specific AMBA
1280#
1281# CONFIG_BCMA is not set
1282
1283#
1284# Multifunction device drivers
1285#
1286# CONFIG_MFD_CORE is not set
1287# CONFIG_MFD_88PM860X is not set
1288# CONFIG_MFD_SM501 is not set
1289# CONFIG_HTC_PASIC3 is not set
1290# CONFIG_TPS6105X is not set
1291# CONFIG_TPS6507X is not set
1292# CONFIG_TWL4030_CORE is not set
1293# CONFIG_MFD_STMPE is not set
1294# CONFIG_MFD_TC3589X is not set
1295# CONFIG_MFD_TMIO is not set
1296# CONFIG_PMIC_DA903X is not set
1297# CONFIG_MFD_DA9052_I2C is not set
1298# CONFIG_PMIC_ADP5520 is not set
1299# CONFIG_MFD_MAX8925 is not set
1300# CONFIG_MFD_MAX8997 is not set
1301# CONFIG_MFD_MAX8998 is not set
1302# CONFIG_MFD_S5M_CORE is not set
1303# CONFIG_MFD_WM8400 is not set
1304# CONFIG_MFD_WM831X_I2C is not set
1305# CONFIG_MFD_WM8350_I2C is not set
1306# CONFIG_MFD_WM8994 is not set
1307# CONFIG_MFD_PCF50633 is not set
1308# CONFIG_ABX500_CORE is not set
1309# CONFIG_LPC_SCH is not set
1310# CONFIG_MFD_RDC321X is not set
1311# CONFIG_MFD_JANZ_CMODIO is not set
1312# CONFIG_MFD_VX855 is not set
1313# CONFIG_MFD_WL1273_CORE is not set
1314# CONFIG_REGULATOR is not set
1315# CONFIG_MEDIA_SUPPORT is not set
1316
1317#
1318# Graphics support
1319#
1320# CONFIG_VGA_ARB is not set 414# CONFIG_VGA_ARB is not set
1321# CONFIG_DRM is not set
1322# CONFIG_STUB_POULSBO is not set
1323# CONFIG_VGASTATE is not set
1324# CONFIG_VIDEO_OUTPUT_CONTROL is not set
1325# CONFIG_FB is not set
1326# CONFIG_BACKLIGHT_LCD_SUPPORT is not set
1327# CONFIG_SOUND is not set
1328# CONFIG_HID_SUPPORT is not set 415# CONFIG_HID_SUPPORT is not set
1329CONFIG_USB_SUPPORT=y
1330CONFIG_USB_COMMON=y
1331CONFIG_USB_ARCH_HAS_HCD=y
1332CONFIG_USB_ARCH_HAS_OHCI=y
1333CONFIG_USB_ARCH_HAS_EHCI=y
1334CONFIG_USB_ARCH_HAS_XHCI=y
1335CONFIG_USB=y 416CONFIG_USB=y
1336# CONFIG_USB_DEBUG is not set
1337# CONFIG_USB_ANNOUNCE_NEW_DEVICES is not set
1338
1339#
1340# Miscellaneous USB options
1341#
1342# CONFIG_USB_DEVICEFS is not set
1343# CONFIG_USB_DEVICE_CLASS is not set 417# CONFIG_USB_DEVICE_CLASS is not set
1344# CONFIG_USB_DYNAMIC_MINORS is not set
1345# CONFIG_USB_OTG_WHITELIST is not set
1346# CONFIG_USB_OTG_BLACKLIST_HUB is not set
1347# CONFIG_USB_MON is not set
1348# CONFIG_USB_WUSB_CBAF is not set
1349
1350#
1351# USB Host Controller Drivers
1352#
1353# CONFIG_USB_C67X00_HCD is not set
1354# CONFIG_USB_XHCI_HCD is not set
1355CONFIG_USB_EHCI_HCD=y 418CONFIG_USB_EHCI_HCD=y
1356# CONFIG_USB_EHCI_ROOT_HUB_TT is not set
1357CONFIG_USB_EHCI_TT_NEWSCHED=y
1358# CONFIG_USB_EHCI_MV is not set
1359# CONFIG_USB_OXU210HP_HCD is not set
1360# CONFIG_USB_ISP116X_HCD is not set
1361# CONFIG_USB_ISP1760_HCD is not set
1362# CONFIG_USB_ISP1362_HCD is not set
1363CONFIG_USB_OHCI_HCD=y 419CONFIG_USB_OHCI_HCD=y
1364# CONFIG_USB_OHCI_BIG_ENDIAN_DESC is not set
1365# CONFIG_USB_OHCI_BIG_ENDIAN_MMIO is not set
1366CONFIG_USB_OHCI_LITTLE_ENDIAN=y
1367# CONFIG_USB_UHCI_HCD is not set
1368# CONFIG_USB_SL811_HCD is not set
1369# CONFIG_USB_R8A66597_HCD is not set
1370
1371#
1372# USB Device Class drivers
1373#
1374# CONFIG_USB_ACM is not set
1375# CONFIG_USB_PRINTER is not set
1376# CONFIG_USB_WDM is not set
1377# CONFIG_USB_TMC is not set
1378
1379#
1380# NOTE: USB_STORAGE depends on SCSI but BLK_DEV_SD may
1381#
1382
1383#
1384# also be needed; see USB_STORAGE Help for more info
1385#
1386CONFIG_USB_STORAGE=y 420CONFIG_USB_STORAGE=y
1387# CONFIG_USB_STORAGE_DEBUG is not set
1388# CONFIG_USB_STORAGE_REALTEK is not set
1389# CONFIG_USB_STORAGE_DATAFAB is not set
1390# CONFIG_USB_STORAGE_FREECOM is not set
1391# CONFIG_USB_STORAGE_ISD200 is not set
1392# CONFIG_USB_STORAGE_USBAT is not set
1393# CONFIG_USB_STORAGE_SDDR09 is not set
1394# CONFIG_USB_STORAGE_SDDR55 is not set
1395# CONFIG_USB_STORAGE_JUMPSHOT is not set
1396# CONFIG_USB_STORAGE_ALAUDA is not set
1397# CONFIG_USB_STORAGE_ONETOUCH is not set
1398# CONFIG_USB_STORAGE_KARMA is not set
1399# CONFIG_USB_STORAGE_CYPRESS_ATACB is not set
1400# CONFIG_USB_STORAGE_ENE_UB6250 is not set
1401# CONFIG_USB_UAS is not set
1402CONFIG_USB_LIBUSUAL=y 421CONFIG_USB_LIBUSUAL=y
1403
1404#
1405# USB Imaging devices
1406#
1407# CONFIG_USB_MDC800 is not set
1408# CONFIG_USB_MICROTEK is not set
1409
1410#
1411# USB port drivers
1412#
1413# CONFIG_USB_SERIAL is not set
1414
1415#
1416# USB Miscellaneous drivers
1417#
1418# CONFIG_USB_EMI62 is not set
1419# CONFIG_USB_EMI26 is not set
1420# CONFIG_USB_ADUTUX is not set
1421# CONFIG_USB_SEVSEG is not set
1422# CONFIG_USB_RIO500 is not set
1423# CONFIG_USB_LEGOTOWER is not set
1424# CONFIG_USB_LCD is not set
1425# CONFIG_USB_LED is not set
1426# CONFIG_USB_CYPRESS_CY7C63 is not set
1427# CONFIG_USB_CYTHERM is not set
1428# CONFIG_USB_IDMOUSE is not set
1429# CONFIG_USB_FTDI_ELAN is not set
1430# CONFIG_USB_APPLEDISPLAY is not set
1431# CONFIG_USB_SISUSBVGA is not set
1432# CONFIG_USB_LD is not set
1433# CONFIG_USB_TRANCEVIBRATOR is not set
1434# CONFIG_USB_IOWARRIOR is not set
1435# CONFIG_USB_TEST is not set
1436# CONFIG_USB_ISIGHTFW is not set
1437# CONFIG_USB_YUREX is not set
1438# CONFIG_USB_GADGET is not set
1439
1440#
1441# OTG and related infrastructure
1442#
1443# CONFIG_NOP_USB_XCEIV is not set
1444# CONFIG_UWB is not set
1445# CONFIG_MMC is not set
1446# CONFIG_MEMSTICK is not set
1447# CONFIG_NEW_LEDS is not set
1448# CONFIG_ACCESSIBILITY is not set
1449# CONFIG_INFINIBAND is not set
1450CONFIG_EDAC=y 422CONFIG_EDAC=y
1451
1452#
1453# Reporting subsystems
1454#
1455# CONFIG_EDAC_DEBUG is not set
1456CONFIG_EDAC_MM_EDAC=y 423CONFIG_EDAC_MM_EDAC=y
1457CONFIG_EDAC_TILE=y
1458CONFIG_RTC_LIB=y
1459CONFIG_RTC_CLASS=y 424CONFIG_RTC_CLASS=y
1460CONFIG_RTC_HCTOSYS=y
1461CONFIG_RTC_HCTOSYS_DEVICE="rtc0"
1462# CONFIG_RTC_DEBUG is not set
1463
1464#
1465# RTC interfaces
1466#
1467CONFIG_RTC_INTF_SYSFS=y
1468CONFIG_RTC_INTF_PROC=y
1469CONFIG_RTC_INTF_DEV=y
1470# CONFIG_RTC_INTF_DEV_UIE_EMUL is not set
1471# CONFIG_RTC_DRV_TEST is not set
1472
1473#
1474# I2C RTC drivers
1475#
1476# CONFIG_RTC_DRV_DS1307 is not set
1477# CONFIG_RTC_DRV_DS1374 is not set
1478# CONFIG_RTC_DRV_DS1672 is not set
1479# CONFIG_RTC_DRV_DS3232 is not set
1480# CONFIG_RTC_DRV_MAX6900 is not set
1481# CONFIG_RTC_DRV_RS5C372 is not set
1482# CONFIG_RTC_DRV_ISL1208 is not set
1483# CONFIG_RTC_DRV_ISL12022 is not set
1484# CONFIG_RTC_DRV_X1205 is not set
1485# CONFIG_RTC_DRV_PCF8563 is not set
1486# CONFIG_RTC_DRV_PCF8583 is not set
1487# CONFIG_RTC_DRV_M41T80 is not set
1488# CONFIG_RTC_DRV_BQ32K is not set
1489# CONFIG_RTC_DRV_S35390A is not set
1490# CONFIG_RTC_DRV_FM3130 is not set
1491# CONFIG_RTC_DRV_RX8581 is not set
1492# CONFIG_RTC_DRV_RX8025 is not set
1493# CONFIG_RTC_DRV_EM3027 is not set
1494# CONFIG_RTC_DRV_RV3029C2 is not set
1495
1496#
1497# SPI RTC drivers
1498#
1499
1500#
1501# Platform RTC drivers
1502#
1503# CONFIG_RTC_DRV_DS1286 is not set
1504# CONFIG_RTC_DRV_DS1511 is not set
1505# CONFIG_RTC_DRV_DS1553 is not set
1506# CONFIG_RTC_DRV_DS1742 is not set
1507# CONFIG_RTC_DRV_STK17TA8 is not set
1508# CONFIG_RTC_DRV_M48T86 is not set
1509# CONFIG_RTC_DRV_M48T35 is not set
1510# CONFIG_RTC_DRV_M48T59 is not set
1511# CONFIG_RTC_DRV_MSM6242 is not set
1512# CONFIG_RTC_DRV_BQ4802 is not set
1513# CONFIG_RTC_DRV_RP5C01 is not set
1514# CONFIG_RTC_DRV_V3020 is not set
1515
1516#
1517# on-CPU RTC drivers
1518#
1519CONFIG_RTC_DRV_TILE=y 425CONFIG_RTC_DRV_TILE=y
1520# CONFIG_DMADEVICES is not set
1521# CONFIG_AUXDISPLAY is not set
1522# CONFIG_UIO is not set
1523
1524#
1525# Virtio drivers
1526#
1527# CONFIG_VIRTIO_PCI is not set
1528# CONFIG_VIRTIO_BALLOON is not set
1529# CONFIG_VIRTIO_MMIO is not set
1530
1531#
1532# Microsoft Hyper-V guest support
1533#
1534# CONFIG_STAGING is not set
1535
1536#
1537# Hardware Spinlock drivers
1538#
1539CONFIG_IOMMU_SUPPORT=y
1540# CONFIG_VIRT_DRIVERS is not set
1541# CONFIG_PM_DEVFREQ is not set
1542
1543#
1544# File systems
1545#
1546CONFIG_EXT2_FS=y 426CONFIG_EXT2_FS=y
1547CONFIG_EXT2_FS_XATTR=y 427CONFIG_EXT2_FS_XATTR=y
1548CONFIG_EXT2_FS_POSIX_ACL=y 428CONFIG_EXT2_FS_POSIX_ACL=y
1549CONFIG_EXT2_FS_SECURITY=y 429CONFIG_EXT2_FS_SECURITY=y
1550CONFIG_EXT2_FS_XIP=y 430CONFIG_EXT2_FS_XIP=y
1551CONFIG_EXT3_FS=y 431CONFIG_EXT3_FS=y
1552CONFIG_EXT3_DEFAULTS_TO_ORDERED=y
1553CONFIG_EXT3_FS_XATTR=y
1554CONFIG_EXT3_FS_POSIX_ACL=y 432CONFIG_EXT3_FS_POSIX_ACL=y
1555CONFIG_EXT3_FS_SECURITY=y 433CONFIG_EXT3_FS_SECURITY=y
1556CONFIG_EXT4_FS=y 434CONFIG_EXT4_FS=y
1557CONFIG_EXT4_FS_XATTR=y
1558CONFIG_EXT4_FS_POSIX_ACL=y 435CONFIG_EXT4_FS_POSIX_ACL=y
1559CONFIG_EXT4_FS_SECURITY=y 436CONFIG_EXT4_FS_SECURITY=y
1560# CONFIG_EXT4_DEBUG is not set
1561CONFIG_FS_XIP=y
1562CONFIG_JBD=y
1563# CONFIG_JBD_DEBUG is not set
1564CONFIG_JBD2=y
1565# CONFIG_JBD2_DEBUG is not set
1566CONFIG_FS_MBCACHE=y
1567# CONFIG_REISERFS_FS is not set
1568# CONFIG_JFS_FS is not set
1569CONFIG_XFS_FS=y 437CONFIG_XFS_FS=y
1570CONFIG_XFS_QUOTA=y 438CONFIG_XFS_QUOTA=y
1571CONFIG_XFS_POSIX_ACL=y 439CONFIG_XFS_POSIX_ACL=y
1572# CONFIG_XFS_RT is not set
1573# CONFIG_XFS_DEBUG is not set
1574CONFIG_GFS2_FS=m 440CONFIG_GFS2_FS=m
1575CONFIG_GFS2_FS_LOCKING_DLM=y 441CONFIG_GFS2_FS_LOCKING_DLM=y
1576# CONFIG_OCFS2_FS is not set
1577CONFIG_BTRFS_FS=m 442CONFIG_BTRFS_FS=m
1578CONFIG_BTRFS_FS_POSIX_ACL=y 443CONFIG_BTRFS_FS_POSIX_ACL=y
1579# CONFIG_BTRFS_FS_CHECK_INTEGRITY is not set
1580# CONFIG_NILFS2_FS is not set
1581CONFIG_FS_POSIX_ACL=y
1582CONFIG_EXPORTFS=y
1583CONFIG_FILE_LOCKING=y
1584CONFIG_FSNOTIFY=y
1585CONFIG_DNOTIFY=y
1586CONFIG_INOTIFY_USER=y
1587# CONFIG_FANOTIFY is not set
1588CONFIG_QUOTA=y 444CONFIG_QUOTA=y
1589CONFIG_QUOTA_NETLINK_INTERFACE=y 445CONFIG_QUOTA_NETLINK_INTERFACE=y
1590# CONFIG_PRINT_QUOTA_WARNING is not set 446# CONFIG_PRINT_QUOTA_WARNING is not set
1591# CONFIG_QUOTA_DEBUG is not set
1592CONFIG_QUOTA_TREE=y
1593# CONFIG_QFMT_V1 is not set
1594CONFIG_QFMT_V2=y 447CONFIG_QFMT_V2=y
1595CONFIG_QUOTACTL=y
1596CONFIG_AUTOFS4_FS=m 448CONFIG_AUTOFS4_FS=m
1597CONFIG_FUSE_FS=y 449CONFIG_FUSE_FS=y
1598CONFIG_CUSE=m 450CONFIG_CUSE=m
1599CONFIG_GENERIC_ACL=y
1600
1601#
1602# Caches
1603#
1604CONFIG_FSCACHE=m 451CONFIG_FSCACHE=m
1605CONFIG_FSCACHE_STATS=y 452CONFIG_FSCACHE_STATS=y
1606# CONFIG_FSCACHE_HISTOGRAM is not set
1607# CONFIG_FSCACHE_DEBUG is not set
1608# CONFIG_FSCACHE_OBJECT_LIST is not set
1609CONFIG_CACHEFILES=m 453CONFIG_CACHEFILES=m
1610# CONFIG_CACHEFILES_DEBUG is not set
1611# CONFIG_CACHEFILES_HISTOGRAM is not set
1612
1613#
1614# CD-ROM/DVD Filesystems
1615#
1616CONFIG_ISO9660_FS=m 454CONFIG_ISO9660_FS=m
1617CONFIG_JOLIET=y 455CONFIG_JOLIET=y
1618CONFIG_ZISOFS=y 456CONFIG_ZISOFS=y
1619CONFIG_UDF_FS=m 457CONFIG_UDF_FS=m
1620CONFIG_UDF_NLS=y
1621
1622#
1623# DOS/FAT/NT Filesystems
1624#
1625CONFIG_FAT_FS=m
1626CONFIG_MSDOS_FS=m 458CONFIG_MSDOS_FS=m
1627CONFIG_VFAT_FS=m 459CONFIG_VFAT_FS=m
1628CONFIG_FAT_DEFAULT_CODEPAGE=437
1629CONFIG_FAT_DEFAULT_IOCHARSET="ascii" 460CONFIG_FAT_DEFAULT_IOCHARSET="ascii"
1630# CONFIG_NTFS_FS is not set
1631
1632#
1633# Pseudo filesystems
1634#
1635CONFIG_PROC_FS=y
1636CONFIG_PROC_KCORE=y 461CONFIG_PROC_KCORE=y
1637CONFIG_PROC_SYSCTL=y
1638CONFIG_PROC_PAGE_MONITOR=y
1639CONFIG_SYSFS=y
1640CONFIG_TMPFS=y 462CONFIG_TMPFS=y
1641CONFIG_TMPFS_POSIX_ACL=y 463CONFIG_TMPFS_POSIX_ACL=y
1642CONFIG_TMPFS_XATTR=y
1643CONFIG_HUGETLBFS=y 464CONFIG_HUGETLBFS=y
1644CONFIG_HUGETLB_PAGE=y
1645CONFIG_CONFIGFS_FS=m
1646CONFIG_MISC_FILESYSTEMS=y
1647# CONFIG_ADFS_FS is not set
1648# CONFIG_AFFS_FS is not set
1649CONFIG_ECRYPT_FS=m 465CONFIG_ECRYPT_FS=m
1650# CONFIG_HFS_FS is not set
1651# CONFIG_HFSPLUS_FS is not set
1652# CONFIG_BEFS_FS is not set
1653# CONFIG_BFS_FS is not set
1654# CONFIG_EFS_FS is not set
1655# CONFIG_LOGFS is not set
1656CONFIG_CRAMFS=m 466CONFIG_CRAMFS=m
1657CONFIG_SQUASHFS=m 467CONFIG_SQUASHFS=m
1658# CONFIG_SQUASHFS_XATTR is not set
1659CONFIG_SQUASHFS_ZLIB=y
1660# CONFIG_SQUASHFS_LZO is not set
1661# CONFIG_SQUASHFS_XZ is not set
1662# CONFIG_SQUASHFS_4K_DEVBLK_SIZE is not set
1663# CONFIG_SQUASHFS_EMBEDDED is not set
1664CONFIG_SQUASHFS_FRAGMENT_CACHE_SIZE=3
1665# CONFIG_VXFS_FS is not set
1666# CONFIG_MINIX_FS is not set
1667# CONFIG_OMFS_FS is not set
1668# CONFIG_HPFS_FS is not set
1669# CONFIG_QNX4FS_FS is not set
1670# CONFIG_ROMFS_FS is not set
1671# CONFIG_PSTORE is not set
1672# CONFIG_SYSV_FS is not set
1673# CONFIG_UFS_FS is not set
1674CONFIG_NETWORK_FILESYSTEMS=y
1675CONFIG_NFS_FS=m 468CONFIG_NFS_FS=m
1676CONFIG_NFS_V3=y 469CONFIG_NFS_V3=y
1677CONFIG_NFS_V3_ACL=y 470CONFIG_NFS_V3_ACL=y
1678CONFIG_NFS_V4=y 471CONFIG_NFS_V4=y
1679CONFIG_NFS_V4_1=y 472CONFIG_NFS_V4_1=y
1680CONFIG_PNFS_FILE_LAYOUT=m
1681CONFIG_PNFS_BLOCK=m
1682CONFIG_NFS_FSCACHE=y 473CONFIG_NFS_FSCACHE=y
1683# CONFIG_NFS_USE_LEGACY_DNS is not set
1684CONFIG_NFS_USE_KERNEL_DNS=y
1685# CONFIG_NFS_USE_NEW_IDMAPPER is not set
1686CONFIG_NFSD=m 474CONFIG_NFSD=m
1687CONFIG_NFSD_V2_ACL=y
1688CONFIG_NFSD_V3=y
1689CONFIG_NFSD_V3_ACL=y 475CONFIG_NFSD_V3_ACL=y
1690CONFIG_NFSD_V4=y 476CONFIG_NFSD_V4=y
1691# CONFIG_NFSD_FAULT_INJECTION is not set
1692CONFIG_LOCKD=m
1693CONFIG_LOCKD_V4=y
1694CONFIG_NFS_ACL_SUPPORT=m
1695CONFIG_NFS_COMMON=y
1696CONFIG_SUNRPC=m
1697CONFIG_SUNRPC_GSS=m
1698CONFIG_SUNRPC_BACKCHANNEL=y
1699CONFIG_RPCSEC_GSS_KRB5=m
1700# CONFIG_CEPH_FS is not set
1701CONFIG_CIFS=m 477CONFIG_CIFS=m
1702CONFIG_CIFS_STATS=y 478CONFIG_CIFS_STATS=y
1703# CONFIG_CIFS_STATS2 is not set
1704CONFIG_CIFS_WEAK_PW_HASH=y 479CONFIG_CIFS_WEAK_PW_HASH=y
1705CONFIG_CIFS_UPCALL=y 480CONFIG_CIFS_UPCALL=y
1706CONFIG_CIFS_XATTR=y 481CONFIG_CIFS_XATTR=y
1707CONFIG_CIFS_POSIX=y 482CONFIG_CIFS_POSIX=y
1708# CONFIG_CIFS_DEBUG2 is not set
1709CONFIG_CIFS_DFS_UPCALL=y 483CONFIG_CIFS_DFS_UPCALL=y
1710CONFIG_CIFS_FSCACHE=y 484CONFIG_CIFS_FSCACHE=y
1711# CONFIG_CIFS_ACL is not set
1712# CONFIG_NCP_FS is not set
1713# CONFIG_CODA_FS is not set
1714# CONFIG_AFS_FS is not set
1715CONFIG_NLS=y
1716CONFIG_NLS_DEFAULT="utf8" 485CONFIG_NLS_DEFAULT="utf8"
1717CONFIG_NLS_CODEPAGE_437=y 486CONFIG_NLS_CODEPAGE_437=y
1718CONFIG_NLS_CODEPAGE_737=m 487CONFIG_NLS_CODEPAGE_737=m
@@ -1752,191 +521,47 @@ CONFIG_NLS_ISO8859_15=m
1752CONFIG_NLS_KOI8_R=m 521CONFIG_NLS_KOI8_R=m
1753CONFIG_NLS_KOI8_U=m 522CONFIG_NLS_KOI8_U=m
1754CONFIG_NLS_UTF8=m 523CONFIG_NLS_UTF8=m
1755CONFIG_DLM=m
1756CONFIG_DLM_DEBUG=y 524CONFIG_DLM_DEBUG=y
1757
1758#
1759# Kernel hacking
1760#
1761# CONFIG_PRINTK_TIME is not set
1762CONFIG_DEFAULT_MESSAGE_LOGLEVEL=4
1763# CONFIG_ENABLE_WARN_DEPRECATED is not set 525# CONFIG_ENABLE_WARN_DEPRECATED is not set
1764CONFIG_ENABLE_MUST_CHECK=y
1765CONFIG_FRAME_WARN=2048
1766CONFIG_MAGIC_SYSRQ=y 526CONFIG_MAGIC_SYSRQ=y
1767CONFIG_STRIP_ASM_SYMS=y 527CONFIG_STRIP_ASM_SYMS=y
1768# CONFIG_UNUSED_SYMBOLS is not set
1769CONFIG_DEBUG_FS=y 528CONFIG_DEBUG_FS=y
1770CONFIG_HEADERS_CHECK=y 529CONFIG_HEADERS_CHECK=y
1771# CONFIG_DEBUG_SECTION_MISMATCH is not set
1772CONFIG_DEBUG_KERNEL=y
1773# CONFIG_DEBUG_SHIRQ is not set
1774CONFIG_LOCKUP_DETECTOR=y 530CONFIG_LOCKUP_DETECTOR=y
1775# CONFIG_HARDLOCKUP_DETECTOR is not set
1776# CONFIG_BOOTPARAM_HARDLOCKUP_PANIC is not set
1777CONFIG_BOOTPARAM_HARDLOCKUP_PANIC_VALUE=0
1778# CONFIG_BOOTPARAM_SOFTLOCKUP_PANIC is not set
1779CONFIG_BOOTPARAM_SOFTLOCKUP_PANIC_VALUE=0
1780CONFIG_DETECT_HUNG_TASK=y
1781CONFIG_DEFAULT_HUNG_TASK_TIMEOUT=120
1782# CONFIG_BOOTPARAM_HUNG_TASK_PANIC is not set
1783CONFIG_BOOTPARAM_HUNG_TASK_PANIC_VALUE=0
1784CONFIG_SCHED_DEBUG=y
1785CONFIG_SCHEDSTATS=y 531CONFIG_SCHEDSTATS=y
1786CONFIG_TIMER_STATS=y 532CONFIG_TIMER_STATS=y
1787# CONFIG_DEBUG_OBJECTS is not set
1788# CONFIG_SLUB_DEBUG_ON is not set
1789# CONFIG_SLUB_STATS is not set
1790# CONFIG_DEBUG_KMEMLEAK is not set
1791# CONFIG_DEBUG_RT_MUTEXES is not set
1792# CONFIG_RT_MUTEX_TESTER is not set
1793# CONFIG_DEBUG_SPINLOCK is not set
1794# CONFIG_DEBUG_MUTEXES is not set
1795# CONFIG_DEBUG_LOCK_ALLOC is not set
1796# CONFIG_PROVE_LOCKING is not set
1797# CONFIG_SPARSE_RCU_POINTER is not set
1798# CONFIG_LOCK_STAT is not set
1799# CONFIG_DEBUG_ATOMIC_SLEEP is not set
1800# CONFIG_DEBUG_LOCKING_API_SELFTESTS is not set
1801CONFIG_STACKTRACE=y
1802# CONFIG_DEBUG_STACK_USAGE is not set
1803# CONFIG_DEBUG_KOBJECT is not set
1804CONFIG_DEBUG_BUGVERBOSE=y
1805CONFIG_DEBUG_INFO=y 533CONFIG_DEBUG_INFO=y
1806CONFIG_DEBUG_INFO_REDUCED=y 534CONFIG_DEBUG_INFO_REDUCED=y
1807CONFIG_DEBUG_VM=y 535CONFIG_DEBUG_VM=y
1808# CONFIG_DEBUG_WRITECOUNT is not set
1809CONFIG_DEBUG_MEMORY_INIT=y 536CONFIG_DEBUG_MEMORY_INIT=y
1810CONFIG_DEBUG_LIST=y 537CONFIG_DEBUG_LIST=y
1811# CONFIG_TEST_LIST_SORT is not set
1812# CONFIG_DEBUG_SG is not set
1813# CONFIG_DEBUG_NOTIFIERS is not set
1814CONFIG_DEBUG_CREDENTIALS=y 538CONFIG_DEBUG_CREDENTIALS=y
1815# CONFIG_RCU_TORTURE_TEST is not set
1816CONFIG_RCU_CPU_STALL_TIMEOUT=60
1817# CONFIG_BACKTRACE_SELF_TEST is not set
1818# CONFIG_DEBUG_BLOCK_EXT_DEVT is not set
1819CONFIG_DEBUG_FORCE_WEAK_PER_CPU=y 539CONFIG_DEBUG_FORCE_WEAK_PER_CPU=y
1820# CONFIG_DEBUG_PER_CPU_MAPS is not set
1821# CONFIG_LKDTM is not set
1822# CONFIG_FAULT_INJECTION is not set
1823# CONFIG_SYSCTL_SYSCALL_CHECK is not set
1824# CONFIG_DEBUG_PAGEALLOC is not set
1825CONFIG_TRACING_SUPPORT=y
1826CONFIG_FTRACE=y
1827# CONFIG_IRQSOFF_TRACER is not set
1828# CONFIG_SCHED_TRACER is not set
1829# CONFIG_ENABLE_DEFAULT_TRACERS is not set
1830CONFIG_BRANCH_PROFILE_NONE=y
1831# CONFIG_PROFILE_ANNOTATED_BRANCHES is not set
1832# CONFIG_PROFILE_ALL_BRANCHES is not set
1833# CONFIG_BLK_DEV_IO_TRACE is not set
1834# CONFIG_BUILD_DOCSRC is not set
1835CONFIG_DYNAMIC_DEBUG=y 540CONFIG_DYNAMIC_DEBUG=y
1836# CONFIG_ATOMIC64_SELFTEST is not set
1837CONFIG_ASYNC_RAID6_TEST=m 541CONFIG_ASYNC_RAID6_TEST=m
1838# CONFIG_SAMPLES is not set
1839# CONFIG_TEST_KSTRTOX is not set
1840CONFIG_EARLY_PRINTK=y
1841CONFIG_DEBUG_STACKOVERFLOW=y 542CONFIG_DEBUG_STACKOVERFLOW=y
1842CONFIG_DEBUG_EXTRA_FLAGS=""
1843
1844#
1845# Security options
1846#
1847CONFIG_KEYS=y
1848# CONFIG_ENCRYPTED_KEYS is not set
1849CONFIG_KEYS_DEBUG_PROC_KEYS=y 543CONFIG_KEYS_DEBUG_PROC_KEYS=y
1850# CONFIG_SECURITY_DMESG_RESTRICT is not set
1851CONFIG_SECURITY=y 544CONFIG_SECURITY=y
1852CONFIG_SECURITYFS=y 545CONFIG_SECURITYFS=y
1853CONFIG_SECURITY_NETWORK=y 546CONFIG_SECURITY_NETWORK=y
1854CONFIG_SECURITY_NETWORK_XFRM=y 547CONFIG_SECURITY_NETWORK_XFRM=y
1855# CONFIG_SECURITY_PATH is not set
1856CONFIG_LSM_MMAP_MIN_ADDR=65536
1857CONFIG_SECURITY_SELINUX=y 548CONFIG_SECURITY_SELINUX=y
1858CONFIG_SECURITY_SELINUX_BOOTPARAM=y 549CONFIG_SECURITY_SELINUX_BOOTPARAM=y
1859CONFIG_SECURITY_SELINUX_BOOTPARAM_VALUE=1
1860CONFIG_SECURITY_SELINUX_DISABLE=y 550CONFIG_SECURITY_SELINUX_DISABLE=y
1861CONFIG_SECURITY_SELINUX_DEVELOP=y
1862CONFIG_SECURITY_SELINUX_AVC_STATS=y
1863CONFIG_SECURITY_SELINUX_CHECKREQPROT_VALUE=1
1864# CONFIG_SECURITY_SELINUX_POLICYDB_VERSION_MAX is not set
1865# CONFIG_SECURITY_SMACK is not set
1866# CONFIG_SECURITY_TOMOYO is not set
1867# CONFIG_SECURITY_APPARMOR is not set
1868# CONFIG_IMA is not set
1869# CONFIG_EVM is not set
1870CONFIG_DEFAULT_SECURITY_SELINUX=y
1871# CONFIG_DEFAULT_SECURITY_DAC is not set
1872CONFIG_DEFAULT_SECURITY="selinux"
1873CONFIG_XOR_BLOCKS=m
1874CONFIG_ASYNC_CORE=m
1875CONFIG_ASYNC_MEMCPY=m
1876CONFIG_ASYNC_XOR=m
1877CONFIG_ASYNC_PQ=m
1878CONFIG_ASYNC_RAID6_RECOV=m
1879CONFIG_CRYPTO=y
1880
1881#
1882# Crypto core or helper
1883#
1884CONFIG_CRYPTO_ALGAPI=y
1885CONFIG_CRYPTO_ALGAPI2=y
1886CONFIG_CRYPTO_AEAD=m
1887CONFIG_CRYPTO_AEAD2=y
1888CONFIG_CRYPTO_BLKCIPHER=m
1889CONFIG_CRYPTO_BLKCIPHER2=y
1890CONFIG_CRYPTO_HASH=y
1891CONFIG_CRYPTO_HASH2=y
1892CONFIG_CRYPTO_RNG=m
1893CONFIG_CRYPTO_RNG2=y
1894CONFIG_CRYPTO_PCOMP=m
1895CONFIG_CRYPTO_PCOMP2=y
1896CONFIG_CRYPTO_MANAGER=y
1897CONFIG_CRYPTO_MANAGER2=y
1898# CONFIG_CRYPTO_USER is not set
1899CONFIG_CRYPTO_MANAGER_DISABLE_TESTS=y
1900CONFIG_CRYPTO_GF128MUL=m
1901CONFIG_CRYPTO_NULL=m 551CONFIG_CRYPTO_NULL=m
1902CONFIG_CRYPTO_PCRYPT=m 552CONFIG_CRYPTO_PCRYPT=m
1903CONFIG_CRYPTO_WORKQUEUE=y
1904CONFIG_CRYPTO_CRYPTD=m 553CONFIG_CRYPTO_CRYPTD=m
1905CONFIG_CRYPTO_AUTHENC=m
1906CONFIG_CRYPTO_TEST=m 554CONFIG_CRYPTO_TEST=m
1907
1908#
1909# Authenticated Encryption with Associated Data
1910#
1911CONFIG_CRYPTO_CCM=m 555CONFIG_CRYPTO_CCM=m
1912CONFIG_CRYPTO_GCM=m 556CONFIG_CRYPTO_GCM=m
1913CONFIG_CRYPTO_SEQIV=m
1914
1915#
1916# Block modes
1917#
1918CONFIG_CRYPTO_CBC=m
1919CONFIG_CRYPTO_CTR=m
1920CONFIG_CRYPTO_CTS=m 557CONFIG_CRYPTO_CTS=m
1921CONFIG_CRYPTO_ECB=m
1922CONFIG_CRYPTO_LRW=m 558CONFIG_CRYPTO_LRW=m
1923CONFIG_CRYPTO_PCBC=m 559CONFIG_CRYPTO_PCBC=m
1924CONFIG_CRYPTO_XTS=m 560CONFIG_CRYPTO_XTS=m
1925
1926#
1927# Hash modes
1928#
1929CONFIG_CRYPTO_HMAC=y 561CONFIG_CRYPTO_HMAC=y
1930CONFIG_CRYPTO_XCBC=m 562CONFIG_CRYPTO_XCBC=m
1931CONFIG_CRYPTO_VMAC=m 563CONFIG_CRYPTO_VMAC=m
1932
1933#
1934# Digest
1935#
1936CONFIG_CRYPTO_CRC32C=y 564CONFIG_CRYPTO_CRC32C=y
1937CONFIG_CRYPTO_GHASH=m
1938CONFIG_CRYPTO_MD4=m
1939CONFIG_CRYPTO_MD5=y
1940CONFIG_CRYPTO_MICHAEL_MIC=m 565CONFIG_CRYPTO_MICHAEL_MIC=m
1941CONFIG_CRYPTO_RMD128=m 566CONFIG_CRYPTO_RMD128=m
1942CONFIG_CRYPTO_RMD160=m 567CONFIG_CRYPTO_RMD160=m
@@ -1947,77 +572,16 @@ CONFIG_CRYPTO_SHA256=m
1947CONFIG_CRYPTO_SHA512=m 572CONFIG_CRYPTO_SHA512=m
1948CONFIG_CRYPTO_TGR192=m 573CONFIG_CRYPTO_TGR192=m
1949CONFIG_CRYPTO_WP512=m 574CONFIG_CRYPTO_WP512=m
1950
1951#
1952# Ciphers
1953#
1954CONFIG_CRYPTO_AES=m
1955CONFIG_CRYPTO_ANUBIS=m 575CONFIG_CRYPTO_ANUBIS=m
1956CONFIG_CRYPTO_ARC4=m
1957CONFIG_CRYPTO_BLOWFISH=m 576CONFIG_CRYPTO_BLOWFISH=m
1958CONFIG_CRYPTO_BLOWFISH_COMMON=m
1959CONFIG_CRYPTO_CAMELLIA=m 577CONFIG_CRYPTO_CAMELLIA=m
1960CONFIG_CRYPTO_CAST5=m 578CONFIG_CRYPTO_CAST5=m
1961CONFIG_CRYPTO_CAST6=m 579CONFIG_CRYPTO_CAST6=m
1962CONFIG_CRYPTO_DES=m
1963CONFIG_CRYPTO_FCRYPT=m 580CONFIG_CRYPTO_FCRYPT=m
1964CONFIG_CRYPTO_KHAZAD=m 581CONFIG_CRYPTO_KHAZAD=m
1965# CONFIG_CRYPTO_SALSA20 is not set
1966CONFIG_CRYPTO_SEED=m 582CONFIG_CRYPTO_SEED=m
1967CONFIG_CRYPTO_SERPENT=m 583CONFIG_CRYPTO_SERPENT=m
1968CONFIG_CRYPTO_TEA=m 584CONFIG_CRYPTO_TEA=m
1969CONFIG_CRYPTO_TWOFISH=m 585CONFIG_CRYPTO_TWOFISH=m
1970CONFIG_CRYPTO_TWOFISH_COMMON=m
1971
1972#
1973# Compression
1974#
1975CONFIG_CRYPTO_DEFLATE=m
1976CONFIG_CRYPTO_ZLIB=m 586CONFIG_CRYPTO_ZLIB=m
1977CONFIG_CRYPTO_LZO=m 587CONFIG_CRYPTO_LZO=m
1978
1979#
1980# Random Number Generation
1981#
1982CONFIG_CRYPTO_ANSI_CPRNG=m
1983# CONFIG_CRYPTO_USER_API_HASH is not set
1984# CONFIG_CRYPTO_USER_API_SKCIPHER is not set
1985CONFIG_CRYPTO_HW=y
1986# CONFIG_BINARY_PRINTF is not set
1987
1988#
1989# Library routines
1990#
1991CONFIG_RAID6_PQ=m
1992CONFIG_BITREVERSE=y
1993CONFIG_GENERIC_FIND_FIRST_BIT=y
1994CONFIG_GENERIC_PCI_IOMAP=y
1995# CONFIG_CRC_CCITT is not set
1996CONFIG_CRC16=y
1997CONFIG_CRC_T10DIF=y
1998CONFIG_CRC_ITU_T=m
1999CONFIG_CRC32=y
2000# CONFIG_CRC7 is not set
2001CONFIG_LIBCRC32C=m
2002# CONFIG_CRC8 is not set
2003CONFIG_AUDIT_GENERIC=y
2004CONFIG_ZLIB_INFLATE=y
2005CONFIG_ZLIB_DEFLATE=m
2006CONFIG_LZO_COMPRESS=m
2007CONFIG_LZO_DECOMPRESS=m
2008# CONFIG_XZ_DEC is not set
2009# CONFIG_XZ_DEC_BCJ is not set
2010CONFIG_DECOMPRESS_GZIP=y
2011CONFIG_TEXTSEARCH=y
2012CONFIG_TEXTSEARCH_KMP=m
2013CONFIG_TEXTSEARCH_BM=m
2014CONFIG_TEXTSEARCH_FSM=m
2015CONFIG_HAS_IOMEM=y
2016CONFIG_HAS_IOPORT=y
2017CONFIG_HAS_DMA=y
2018CONFIG_CPU_RMAP=y
2019CONFIG_DQL=y
2020CONFIG_NLATTR=y
2021# CONFIG_AVERAGE is not set
2022# CONFIG_CORDIC is not set
2023# CONFIG_VIRTUALIZATION is not set
diff --git a/arch/tile/configs/tilepro_defconfig b/arch/tile/configs/tilepro_defconfig
index 87829912c045..2b1fd31894f1 100644
--- a/arch/tile/configs/tilepro_defconfig
+++ b/arch/tile/configs/tilepro_defconfig
@@ -1,368 +1,91 @@
1#
2# Automatically generated file; DO NOT EDIT.
3# Linux/tilepro 3.3.0-rc7 Kernel Configuration
4#
5CONFIG_TILE=y
6CONFIG_MMU=y
7CONFIG_GENERIC_CSUM=y
8CONFIG_SEMAPHORE_SLEEPERS=y
9CONFIG_HAVE_ARCH_ALLOC_REMAP=y
10CONFIG_HAVE_SETUP_PER_CPU_AREA=y
11CONFIG_NEED_PER_CPU_PAGE_FIRST_CHUNK=y
12CONFIG_SYS_SUPPORTS_HUGETLBFS=y
13CONFIG_GENERIC_CLOCKEVENTS=y
14CONFIG_RWSEM_GENERIC_SPINLOCK=y
15CONFIG_DEFAULT_MIGRATION_COST=10000000
16CONFIG_ARCH_SUPPORTS_OPTIMIZED_INLINING=y
17CONFIG_ARCH_PHYS_ADDR_T_64BIT=y
18CONFIG_ARCH_DMA_ADDR_T_64BIT=y
19CONFIG_LOCKDEP_SUPPORT=y
20CONFIG_STACKTRACE_SUPPORT=y
21CONFIG_ARCH_DISCONTIGMEM_ENABLE=y
22CONFIG_ARCH_DISCONTIGMEM_DEFAULT=y
23CONFIG_TRACE_IRQFLAGS_SUPPORT=y
24CONFIG_STRICT_DEVMEM=y
25CONFIG_SMP=y
26# CONFIG_DEBUG_COPY_FROM_USER is not set
27CONFIG_HVC_TILE=y
28# CONFIG_TILEGX is not set
29CONFIG_ARCH_DEFCONFIG="arch/tile/configs/tile_defconfig"
30CONFIG_DEFCONFIG_LIST="/lib/modules/$UNAME_RELEASE/.config"
31
32#
33# General setup
34#
35CONFIG_EXPERIMENTAL=y 1CONFIG_EXPERIMENTAL=y
36CONFIG_INIT_ENV_ARG_LIMIT=32
37CONFIG_CROSS_COMPILE=""
38CONFIG_LOCALVERSION=""
39# CONFIG_LOCALVERSION_AUTO is not set 2# CONFIG_LOCALVERSION_AUTO is not set
40CONFIG_DEFAULT_HOSTNAME="(none)"
41CONFIG_SWAP=y
42CONFIG_SYSVIPC=y 3CONFIG_SYSVIPC=y
43CONFIG_SYSVIPC_SYSCTL=y
44CONFIG_POSIX_MQUEUE=y 4CONFIG_POSIX_MQUEUE=y
45CONFIG_POSIX_MQUEUE_SYSCTL=y
46CONFIG_BSD_PROCESS_ACCT=y 5CONFIG_BSD_PROCESS_ACCT=y
47CONFIG_BSD_PROCESS_ACCT_V3=y 6CONFIG_BSD_PROCESS_ACCT_V3=y
48# CONFIG_FHANDLE is not set 7CONFIG_FHANDLE=y
49CONFIG_TASKSTATS=y 8CONFIG_TASKSTATS=y
50CONFIG_TASK_DELAY_ACCT=y 9CONFIG_TASK_DELAY_ACCT=y
51CONFIG_TASK_XACCT=y 10CONFIG_TASK_XACCT=y
52CONFIG_TASK_IO_ACCOUNTING=y 11CONFIG_TASK_IO_ACCOUNTING=y
53CONFIG_AUDIT=y 12CONFIG_AUDIT=y
54# CONFIG_AUDIT_LOGINUID_IMMUTABLE is not set
55CONFIG_HAVE_GENERIC_HARDIRQS=y
56
57#
58# IRQ subsystem
59#
60CONFIG_GENERIC_HARDIRQS=y
61CONFIG_GENERIC_IRQ_PROBE=y
62CONFIG_GENERIC_IRQ_SHOW=y
63CONFIG_GENERIC_PENDING_IRQ=y
64
65#
66# RCU Subsystem
67#
68CONFIG_TREE_RCU=y
69# CONFIG_PREEMPT_RCU is not set
70# CONFIG_RCU_TRACE is not set
71CONFIG_RCU_FANOUT=32
72# CONFIG_RCU_FANOUT_EXACT is not set
73# CONFIG_RCU_FAST_NO_HZ is not set
74# CONFIG_TREE_RCU_TRACE is not set
75# CONFIG_IKCONFIG is not set
76CONFIG_LOG_BUF_SHIFT=19 13CONFIG_LOG_BUF_SHIFT=19
77CONFIG_CGROUPS=y 14CONFIG_CGROUPS=y
78CONFIG_CGROUP_DEBUG=y 15CONFIG_CGROUP_DEBUG=y
79# CONFIG_CGROUP_FREEZER is not set
80CONFIG_CGROUP_DEVICE=y 16CONFIG_CGROUP_DEVICE=y
81CONFIG_CPUSETS=y 17CONFIG_CPUSETS=y
82CONFIG_PROC_PID_CPUSET=y
83CONFIG_CGROUP_CPUACCT=y 18CONFIG_CGROUP_CPUACCT=y
84CONFIG_RESOURCE_COUNTERS=y 19CONFIG_RESOURCE_COUNTERS=y
85CONFIG_CGROUP_MEM_RES_CTLR=y 20CONFIG_CGROUP_MEM_RES_CTLR=y
86CONFIG_CGROUP_MEM_RES_CTLR_SWAP=y 21CONFIG_CGROUP_MEM_RES_CTLR_SWAP=y
87CONFIG_CGROUP_MEM_RES_CTLR_SWAP_ENABLED=y
88# CONFIG_CGROUP_MEM_RES_CTLR_KMEM is not set
89CONFIG_CGROUP_SCHED=y 22CONFIG_CGROUP_SCHED=y
90CONFIG_FAIR_GROUP_SCHED=y
91# CONFIG_CFS_BANDWIDTH is not set
92CONFIG_RT_GROUP_SCHED=y 23CONFIG_RT_GROUP_SCHED=y
93CONFIG_BLK_CGROUP=y 24CONFIG_BLK_CGROUP=y
94# CONFIG_DEBUG_BLK_CGROUP is not set
95# CONFIG_CHECKPOINT_RESTORE is not set
96CONFIG_NAMESPACES=y 25CONFIG_NAMESPACES=y
97CONFIG_UTS_NS=y
98CONFIG_IPC_NS=y
99CONFIG_USER_NS=y
100CONFIG_PID_NS=y
101CONFIG_NET_NS=y
102# CONFIG_SCHED_AUTOGROUP is not set
103CONFIG_MM_OWNER=y
104# CONFIG_SYSFS_DEPRECATED is not set
105CONFIG_RELAY=y 26CONFIG_RELAY=y
106CONFIG_BLK_DEV_INITRD=y 27CONFIG_BLK_DEV_INITRD=y
107CONFIG_INITRAMFS_SOURCE=""
108CONFIG_RD_GZIP=y
109# CONFIG_RD_BZIP2 is not set
110# CONFIG_RD_LZMA is not set
111# CONFIG_RD_XZ is not set
112# CONFIG_RD_LZO is not set
113CONFIG_CC_OPTIMIZE_FOR_SIZE=y
114CONFIG_SYSCTL=y
115CONFIG_ANON_INODES=y
116CONFIG_EXPERT=y
117CONFIG_SYSCTL_SYSCALL=y 28CONFIG_SYSCTL_SYSCALL=y
118CONFIG_KALLSYMS=y
119# CONFIG_KALLSYMS_ALL is not set
120CONFIG_HOTPLUG=y
121CONFIG_PRINTK=y
122CONFIG_BUG=y
123CONFIG_ELF_CORE=y
124CONFIG_BASE_FULL=y
125CONFIG_FUTEX=y
126CONFIG_EPOLL=y
127CONFIG_SIGNALFD=y
128CONFIG_TIMERFD=y
129CONFIG_EVENTFD=y
130CONFIG_SHMEM=y
131CONFIG_AIO=y
132CONFIG_EMBEDDED=y 29CONFIG_EMBEDDED=y
133
134#
135# Kernel Performance Events And Counters
136#
137CONFIG_VM_EVENT_COUNTERS=y
138CONFIG_PCI_QUIRKS=y
139CONFIG_SLUB_DEBUG=y
140# CONFIG_COMPAT_BRK is not set 30# CONFIG_COMPAT_BRK is not set
141# CONFIG_SLAB is not set
142CONFIG_SLUB=y
143# CONFIG_SLOB is not set
144CONFIG_PROFILING=y 31CONFIG_PROFILING=y
145CONFIG_USE_GENERIC_SMP_HELPERS=y
146CONFIG_ARCH_HAVE_NMI_SAFE_CMPXCHG=y
147
148#
149# GCOV-based kernel profiling
150#
151# CONFIG_GCOV_KERNEL is not set
152# CONFIG_HAVE_GENERIC_DMA_COHERENT is not set
153CONFIG_SLABINFO=y
154CONFIG_RT_MUTEXES=y
155CONFIG_BASE_SMALL=0
156CONFIG_MODULES=y 32CONFIG_MODULES=y
157CONFIG_MODULE_FORCE_LOAD=y 33CONFIG_MODULE_FORCE_LOAD=y
158CONFIG_MODULE_UNLOAD=y 34CONFIG_MODULE_UNLOAD=y
159# CONFIG_MODULE_FORCE_UNLOAD is not set
160# CONFIG_MODVERSIONS is not set
161# CONFIG_MODULE_SRCVERSION_ALL is not set
162CONFIG_STOP_MACHINE=y
163CONFIG_BLOCK=y
164CONFIG_LBDAF=y
165CONFIG_BLK_DEV_BSG=y
166# CONFIG_BLK_DEV_BSGLIB is not set
167CONFIG_BLK_DEV_INTEGRITY=y 35CONFIG_BLK_DEV_INTEGRITY=y
168# CONFIG_BLK_DEV_THROTTLING is not set
169
170#
171# Partition Types
172#
173CONFIG_PARTITION_ADVANCED=y 36CONFIG_PARTITION_ADVANCED=y
174# CONFIG_ACORN_PARTITION is not set
175CONFIG_OSF_PARTITION=y 37CONFIG_OSF_PARTITION=y
176CONFIG_AMIGA_PARTITION=y 38CONFIG_AMIGA_PARTITION=y
177# CONFIG_ATARI_PARTITION is not set
178CONFIG_MAC_PARTITION=y 39CONFIG_MAC_PARTITION=y
179CONFIG_MSDOS_PARTITION=y
180CONFIG_BSD_DISKLABEL=y 40CONFIG_BSD_DISKLABEL=y
181CONFIG_MINIX_SUBPARTITION=y 41CONFIG_MINIX_SUBPARTITION=y
182CONFIG_SOLARIS_X86_PARTITION=y 42CONFIG_SOLARIS_X86_PARTITION=y
183CONFIG_UNIXWARE_DISKLABEL=y 43CONFIG_UNIXWARE_DISKLABEL=y
184# CONFIG_LDM_PARTITION is not set
185CONFIG_SGI_PARTITION=y 44CONFIG_SGI_PARTITION=y
186# CONFIG_ULTRIX_PARTITION is not set
187CONFIG_SUN_PARTITION=y 45CONFIG_SUN_PARTITION=y
188CONFIG_KARMA_PARTITION=y 46CONFIG_KARMA_PARTITION=y
189CONFIG_EFI_PARTITION=y 47CONFIG_EFI_PARTITION=y
190# CONFIG_SYSV68_PARTITION is not set
191
192#
193# IO Schedulers
194#
195CONFIG_IOSCHED_NOOP=y
196CONFIG_IOSCHED_DEADLINE=y
197CONFIG_IOSCHED_CFQ=y
198CONFIG_CFQ_GROUP_IOSCHED=y 48CONFIG_CFQ_GROUP_IOSCHED=y
199# CONFIG_DEFAULT_DEADLINE is not set
200CONFIG_DEFAULT_CFQ=y
201# CONFIG_DEFAULT_NOOP is not set
202CONFIG_DEFAULT_IOSCHED="cfq"
203CONFIG_PADATA=y
204# CONFIG_INLINE_SPIN_TRYLOCK is not set
205# CONFIG_INLINE_SPIN_TRYLOCK_BH is not set
206# CONFIG_INLINE_SPIN_LOCK is not set
207# CONFIG_INLINE_SPIN_LOCK_BH is not set
208# CONFIG_INLINE_SPIN_LOCK_IRQ is not set
209# CONFIG_INLINE_SPIN_LOCK_IRQSAVE is not set
210CONFIG_INLINE_SPIN_UNLOCK=y
211# CONFIG_INLINE_SPIN_UNLOCK_BH is not set
212CONFIG_INLINE_SPIN_UNLOCK_IRQ=y
213# CONFIG_INLINE_SPIN_UNLOCK_IRQRESTORE is not set
214# CONFIG_INLINE_READ_TRYLOCK is not set
215# CONFIG_INLINE_READ_LOCK is not set
216# CONFIG_INLINE_READ_LOCK_BH is not set
217# CONFIG_INLINE_READ_LOCK_IRQ is not set
218# CONFIG_INLINE_READ_LOCK_IRQSAVE is not set
219CONFIG_INLINE_READ_UNLOCK=y
220# CONFIG_INLINE_READ_UNLOCK_BH is not set
221CONFIG_INLINE_READ_UNLOCK_IRQ=y
222# CONFIG_INLINE_READ_UNLOCK_IRQRESTORE is not set
223# CONFIG_INLINE_WRITE_TRYLOCK is not set
224# CONFIG_INLINE_WRITE_LOCK is not set
225# CONFIG_INLINE_WRITE_LOCK_BH is not set
226# CONFIG_INLINE_WRITE_LOCK_IRQ is not set
227# CONFIG_INLINE_WRITE_LOCK_IRQSAVE is not set
228CONFIG_INLINE_WRITE_UNLOCK=y
229# CONFIG_INLINE_WRITE_UNLOCK_BH is not set
230CONFIG_INLINE_WRITE_UNLOCK_IRQ=y
231# CONFIG_INLINE_WRITE_UNLOCK_IRQRESTORE is not set
232CONFIG_MUTEX_SPIN_ON_OWNER=y
233
234#
235# Tilera-specific configuration
236#
237CONFIG_NR_CPUS=64
238CONFIG_TICK_ONESHOT=y
239CONFIG_NO_HZ=y 49CONFIG_NO_HZ=y
240CONFIG_HIGH_RES_TIMERS=y 50CONFIG_HIGH_RES_TIMERS=y
241CONFIG_GENERIC_CLOCKEVENTS_BUILD=y
242CONFIG_HZ_100=y 51CONFIG_HZ_100=y
243# CONFIG_HZ_250 is not set
244# CONFIG_HZ_300 is not set
245# CONFIG_HZ_1000 is not set
246CONFIG_HZ=100
247CONFIG_SCHED_HRTICK=y
248# CONFIG_KEXEC is not set
249CONFIG_HIGHMEM=y
250CONFIG_NUMA=y
251CONFIG_NODES_SHIFT=2
252# CONFIG_VMSPLIT_3_75G is not set
253# CONFIG_VMSPLIT_3_5G is not set
254CONFIG_VMSPLIT_3G=y
255# CONFIG_VMSPLIT_2_75G is not set
256# CONFIG_VMSPLIT_2_5G is not set
257# CONFIG_VMSPLIT_2_25G is not set
258# CONFIG_VMSPLIT_2G is not set
259# CONFIG_VMSPLIT_1G is not set
260CONFIG_PAGE_OFFSET=0xC0000000
261CONFIG_SELECT_MEMORY_MODEL=y
262CONFIG_DISCONTIGMEM_MANUAL=y
263CONFIG_DISCONTIGMEM=y
264CONFIG_FLAT_NODE_MEM_MAP=y
265CONFIG_NEED_MULTIPLE_NODES=y
266CONFIG_PAGEFLAGS_EXTENDED=y
267CONFIG_SPLIT_PTLOCK_CPUS=4
268# CONFIG_COMPACTION is not set
269CONFIG_MIGRATION=y
270CONFIG_PHYS_ADDR_T_64BIT=y
271CONFIG_ZONE_DMA_FLAG=0
272CONFIG_BOUNCE=y
273CONFIG_VIRT_TO_BUS=y
274# CONFIG_KSM is not set
275CONFIG_DEFAULT_MMAP_MIN_ADDR=4096
276# CONFIG_CLEANCACHE is not set
277# CONFIG_CMDLINE_BOOL is not set
278CONFIG_VMALLOC_RESERVE=0x1000000
279CONFIG_HARDWALL=y
280CONFIG_KERNEL_PL=1
281
282#
283# Bus options
284#
285CONFIG_PCI=y
286CONFIG_PCI_DOMAINS=y
287# CONFIG_NO_IOMEM is not set
288# CONFIG_NO_IOPORT is not set
289# CONFIG_ARCH_SUPPORTS_MSI is not set
290CONFIG_PCI_DEBUG=y 52CONFIG_PCI_DEBUG=y
291# CONFIG_PCI_STUB is not set
292# CONFIG_PCI_IOV is not set
293# CONFIG_PCI_PRI is not set
294# CONFIG_PCI_PASID is not set
295# CONFIG_HOTPLUG_PCI is not set
296
297#
298# Executable file formats
299#
300CONFIG_KCORE_ELF=y
301CONFIG_BINFMT_ELF=y
302# CONFIG_CORE_DUMP_DEFAULT_ELF_HEADERS is not set 53# CONFIG_CORE_DUMP_DEFAULT_ELF_HEADERS is not set
303# CONFIG_HAVE_AOUT is not set
304CONFIG_BINFMT_MISC=y 54CONFIG_BINFMT_MISC=y
305CONFIG_NET=y 55CONFIG_NET=y
306
307#
308# Networking options
309#
310CONFIG_PACKET=y 56CONFIG_PACKET=y
311CONFIG_UNIX=y 57CONFIG_UNIX=y
312# CONFIG_UNIX_DIAG is not set
313CONFIG_XFRM=y
314CONFIG_XFRM_USER=y 58CONFIG_XFRM_USER=y
315CONFIG_XFRM_SUB_POLICY=y 59CONFIG_XFRM_SUB_POLICY=y
316CONFIG_XFRM_MIGRATE=y
317CONFIG_XFRM_STATISTICS=y 60CONFIG_XFRM_STATISTICS=y
318CONFIG_XFRM_IPCOMP=m
319CONFIG_NET_KEY=m 61CONFIG_NET_KEY=m
320CONFIG_NET_KEY_MIGRATE=y 62CONFIG_NET_KEY_MIGRATE=y
321CONFIG_INET=y 63CONFIG_INET=y
322CONFIG_IP_MULTICAST=y 64CONFIG_IP_MULTICAST=y
323CONFIG_IP_ADVANCED_ROUTER=y 65CONFIG_IP_ADVANCED_ROUTER=y
324# CONFIG_IP_FIB_TRIE_STATS is not set
325CONFIG_IP_MULTIPLE_TABLES=y 66CONFIG_IP_MULTIPLE_TABLES=y
326CONFIG_IP_ROUTE_MULTIPATH=y 67CONFIG_IP_ROUTE_MULTIPATH=y
327CONFIG_IP_ROUTE_VERBOSE=y 68CONFIG_IP_ROUTE_VERBOSE=y
328CONFIG_IP_ROUTE_CLASSID=y
329# CONFIG_IP_PNP is not set
330CONFIG_NET_IPIP=m 69CONFIG_NET_IPIP=m
331# CONFIG_NET_IPGRE_DEMUX is not set
332CONFIG_IP_MROUTE=y 70CONFIG_IP_MROUTE=y
333# CONFIG_IP_MROUTE_MULTIPLE_TABLES is not set
334CONFIG_IP_PIMSM_V1=y 71CONFIG_IP_PIMSM_V1=y
335CONFIG_IP_PIMSM_V2=y 72CONFIG_IP_PIMSM_V2=y
336# CONFIG_ARPD is not set
337CONFIG_SYN_COOKIES=y 73CONFIG_SYN_COOKIES=y
338CONFIG_INET_AH=m 74CONFIG_INET_AH=m
339CONFIG_INET_ESP=m 75CONFIG_INET_ESP=m
340CONFIG_INET_IPCOMP=m 76CONFIG_INET_IPCOMP=m
341CONFIG_INET_XFRM_TUNNEL=m
342CONFIG_INET_TUNNEL=m
343CONFIG_INET_XFRM_MODE_TRANSPORT=m 77CONFIG_INET_XFRM_MODE_TRANSPORT=m
344CONFIG_INET_XFRM_MODE_TUNNEL=m 78CONFIG_INET_XFRM_MODE_TUNNEL=m
345CONFIG_INET_XFRM_MODE_BEET=m 79CONFIG_INET_XFRM_MODE_BEET=m
346CONFIG_INET_LRO=y
347CONFIG_INET_DIAG=m 80CONFIG_INET_DIAG=m
348CONFIG_INET_TCP_DIAG=m
349# CONFIG_INET_UDP_DIAG is not set
350CONFIG_TCP_CONG_ADVANCED=y 81CONFIG_TCP_CONG_ADVANCED=y
351CONFIG_TCP_CONG_BIC=m
352CONFIG_TCP_CONG_CUBIC=y
353CONFIG_TCP_CONG_WESTWOOD=m
354CONFIG_TCP_CONG_HTCP=m
355CONFIG_TCP_CONG_HSTCP=m 82CONFIG_TCP_CONG_HSTCP=m
356CONFIG_TCP_CONG_HYBLA=m 83CONFIG_TCP_CONG_HYBLA=m
357CONFIG_TCP_CONG_VEGAS=m
358CONFIG_TCP_CONG_SCALABLE=m 84CONFIG_TCP_CONG_SCALABLE=m
359CONFIG_TCP_CONG_LP=m 85CONFIG_TCP_CONG_LP=m
360CONFIG_TCP_CONG_VENO=m 86CONFIG_TCP_CONG_VENO=m
361CONFIG_TCP_CONG_YEAH=m 87CONFIG_TCP_CONG_YEAH=m
362CONFIG_TCP_CONG_ILLINOIS=m 88CONFIG_TCP_CONG_ILLINOIS=m
363CONFIG_DEFAULT_CUBIC=y
364# CONFIG_DEFAULT_RENO is not set
365CONFIG_DEFAULT_TCP_CONG="cubic"
366CONFIG_TCP_MD5SIG=y 89CONFIG_TCP_MD5SIG=y
367CONFIG_IPV6=y 90CONFIG_IPV6=y
368CONFIG_IPV6_PRIVACY=y 91CONFIG_IPV6_PRIVACY=y
@@ -373,111 +96,60 @@ CONFIG_INET6_AH=m
373CONFIG_INET6_ESP=m 96CONFIG_INET6_ESP=m
374CONFIG_INET6_IPCOMP=m 97CONFIG_INET6_IPCOMP=m
375CONFIG_IPV6_MIP6=m 98CONFIG_IPV6_MIP6=m
376CONFIG_INET6_XFRM_TUNNEL=m
377CONFIG_INET6_TUNNEL=m
378CONFIG_INET6_XFRM_MODE_TRANSPORT=m 99CONFIG_INET6_XFRM_MODE_TRANSPORT=m
379CONFIG_INET6_XFRM_MODE_TUNNEL=m 100CONFIG_INET6_XFRM_MODE_TUNNEL=m
380CONFIG_INET6_XFRM_MODE_BEET=m 101CONFIG_INET6_XFRM_MODE_BEET=m
381CONFIG_INET6_XFRM_MODE_ROUTEOPTIMIZATION=m 102CONFIG_INET6_XFRM_MODE_ROUTEOPTIMIZATION=m
382CONFIG_IPV6_SIT=m 103CONFIG_IPV6_SIT=m
383# CONFIG_IPV6_SIT_6RD is not set
384CONFIG_IPV6_NDISC_NODETYPE=y
385CONFIG_IPV6_TUNNEL=m 104CONFIG_IPV6_TUNNEL=m
386CONFIG_IPV6_MULTIPLE_TABLES=y 105CONFIG_IPV6_MULTIPLE_TABLES=y
387# CONFIG_IPV6_SUBTREES is not set
388CONFIG_IPV6_MROUTE=y 106CONFIG_IPV6_MROUTE=y
389# CONFIG_IPV6_MROUTE_MULTIPLE_TABLES is not set
390CONFIG_IPV6_PIMSM_V2=y 107CONFIG_IPV6_PIMSM_V2=y
391CONFIG_NETLABEL=y 108CONFIG_NETLABEL=y
392CONFIG_NETWORK_SECMARK=y
393# CONFIG_NETWORK_PHY_TIMESTAMPING is not set
394CONFIG_NETFILTER=y 109CONFIG_NETFILTER=y
395# CONFIG_NETFILTER_DEBUG is not set
396CONFIG_NETFILTER_ADVANCED=y
397CONFIG_BRIDGE_NETFILTER=y
398
399#
400# Core Netfilter Configuration
401#
402CONFIG_NETFILTER_NETLINK=m
403# CONFIG_NETFILTER_NETLINK_ACCT is not set
404CONFIG_NETFILTER_NETLINK_QUEUE=m
405CONFIG_NETFILTER_NETLINK_LOG=m
406CONFIG_NF_CONNTRACK=m 110CONFIG_NF_CONNTRACK=m
407CONFIG_NF_CONNTRACK_MARK=y
408CONFIG_NF_CONNTRACK_SECMARK=y 111CONFIG_NF_CONNTRACK_SECMARK=y
409CONFIG_NF_CONNTRACK_ZONES=y 112CONFIG_NF_CONNTRACK_ZONES=y
410CONFIG_NF_CONNTRACK_PROCFS=y
411CONFIG_NF_CONNTRACK_EVENTS=y 113CONFIG_NF_CONNTRACK_EVENTS=y
412# CONFIG_NF_CONNTRACK_TIMESTAMP is not set
413CONFIG_NF_CT_PROTO_DCCP=m 114CONFIG_NF_CT_PROTO_DCCP=m
414CONFIG_NF_CT_PROTO_GRE=m
415CONFIG_NF_CT_PROTO_SCTP=m
416CONFIG_NF_CT_PROTO_UDPLITE=m 115CONFIG_NF_CT_PROTO_UDPLITE=m
417CONFIG_NF_CONNTRACK_AMANDA=m 116CONFIG_NF_CONNTRACK_AMANDA=m
418CONFIG_NF_CONNTRACK_FTP=m 117CONFIG_NF_CONNTRACK_FTP=m
419CONFIG_NF_CONNTRACK_H323=m 118CONFIG_NF_CONNTRACK_H323=m
420CONFIG_NF_CONNTRACK_IRC=m 119CONFIG_NF_CONNTRACK_IRC=m
421CONFIG_NF_CONNTRACK_BROADCAST=m
422CONFIG_NF_CONNTRACK_NETBIOS_NS=m 120CONFIG_NF_CONNTRACK_NETBIOS_NS=m
423# CONFIG_NF_CONNTRACK_SNMP is not set
424CONFIG_NF_CONNTRACK_PPTP=m 121CONFIG_NF_CONNTRACK_PPTP=m
425CONFIG_NF_CONNTRACK_SANE=m 122CONFIG_NF_CONNTRACK_SANE=m
426CONFIG_NF_CONNTRACK_SIP=m 123CONFIG_NF_CONNTRACK_SIP=m
427CONFIG_NF_CONNTRACK_TFTP=m 124CONFIG_NF_CONNTRACK_TFTP=m
428# CONFIG_NF_CT_NETLINK is not set
429CONFIG_NETFILTER_TPROXY=m 125CONFIG_NETFILTER_TPROXY=m
430CONFIG_NETFILTER_XTABLES=y
431
432#
433# Xtables combined modules
434#
435CONFIG_NETFILTER_XT_MARK=m
436CONFIG_NETFILTER_XT_CONNMARK=m
437
438#
439# Xtables targets
440#
441# CONFIG_NETFILTER_XT_TARGET_AUDIT is not set
442# CONFIG_NETFILTER_XT_TARGET_CHECKSUM is not set
443CONFIG_NETFILTER_XT_TARGET_CLASSIFY=m 126CONFIG_NETFILTER_XT_TARGET_CLASSIFY=m
444CONFIG_NETFILTER_XT_TARGET_CONNMARK=m 127CONFIG_NETFILTER_XT_TARGET_CONNMARK=m
445CONFIG_NETFILTER_XT_TARGET_CONNSECMARK=m 128CONFIG_NETFILTER_XT_TARGET_CONNSECMARK=m
446CONFIG_NETFILTER_XT_TARGET_CT=m 129CONFIG_NETFILTER_XT_TARGET_CT=m
447CONFIG_NETFILTER_XT_TARGET_DSCP=m 130CONFIG_NETFILTER_XT_TARGET_DSCP=m
448CONFIG_NETFILTER_XT_TARGET_HL=m
449CONFIG_NETFILTER_XT_TARGET_IDLETIMER=m 131CONFIG_NETFILTER_XT_TARGET_IDLETIMER=m
450CONFIG_NETFILTER_XT_TARGET_MARK=m 132CONFIG_NETFILTER_XT_TARGET_MARK=m
451CONFIG_NETFILTER_XT_TARGET_NFLOG=m 133CONFIG_NETFILTER_XT_TARGET_NFLOG=m
452CONFIG_NETFILTER_XT_TARGET_NFQUEUE=m 134CONFIG_NETFILTER_XT_TARGET_NFQUEUE=m
453CONFIG_NETFILTER_XT_TARGET_NOTRACK=m 135CONFIG_NETFILTER_XT_TARGET_NOTRACK=m
454CONFIG_NETFILTER_XT_TARGET_RATEEST=m
455CONFIG_NETFILTER_XT_TARGET_TEE=m 136CONFIG_NETFILTER_XT_TARGET_TEE=m
456CONFIG_NETFILTER_XT_TARGET_TPROXY=m 137CONFIG_NETFILTER_XT_TARGET_TPROXY=m
457CONFIG_NETFILTER_XT_TARGET_TRACE=m 138CONFIG_NETFILTER_XT_TARGET_TRACE=m
458CONFIG_NETFILTER_XT_TARGET_SECMARK=m 139CONFIG_NETFILTER_XT_TARGET_SECMARK=m
459CONFIG_NETFILTER_XT_TARGET_TCPMSS=m 140CONFIG_NETFILTER_XT_TARGET_TCPMSS=m
460CONFIG_NETFILTER_XT_TARGET_TCPOPTSTRIP=m 141CONFIG_NETFILTER_XT_TARGET_TCPOPTSTRIP=m
461
462#
463# Xtables matches
464#
465# CONFIG_NETFILTER_XT_MATCH_ADDRTYPE is not set
466CONFIG_NETFILTER_XT_MATCH_CLUSTER=m 142CONFIG_NETFILTER_XT_MATCH_CLUSTER=m
467CONFIG_NETFILTER_XT_MATCH_COMMENT=m 143CONFIG_NETFILTER_XT_MATCH_COMMENT=m
468CONFIG_NETFILTER_XT_MATCH_CONNBYTES=m 144CONFIG_NETFILTER_XT_MATCH_CONNBYTES=m
469CONFIG_NETFILTER_XT_MATCH_CONNLIMIT=m 145CONFIG_NETFILTER_XT_MATCH_CONNLIMIT=m
470CONFIG_NETFILTER_XT_MATCH_CONNMARK=m 146CONFIG_NETFILTER_XT_MATCH_CONNMARK=m
471CONFIG_NETFILTER_XT_MATCH_CONNTRACK=m 147CONFIG_NETFILTER_XT_MATCH_CONNTRACK=m
472# CONFIG_NETFILTER_XT_MATCH_CPU is not set
473CONFIG_NETFILTER_XT_MATCH_DCCP=m 148CONFIG_NETFILTER_XT_MATCH_DCCP=m
474# CONFIG_NETFILTER_XT_MATCH_DEVGROUP is not set
475CONFIG_NETFILTER_XT_MATCH_DSCP=m 149CONFIG_NETFILTER_XT_MATCH_DSCP=m
476CONFIG_NETFILTER_XT_MATCH_ECN=m
477CONFIG_NETFILTER_XT_MATCH_ESP=m 150CONFIG_NETFILTER_XT_MATCH_ESP=m
478CONFIG_NETFILTER_XT_MATCH_HASHLIMIT=m 151CONFIG_NETFILTER_XT_MATCH_HASHLIMIT=m
479CONFIG_NETFILTER_XT_MATCH_HELPER=m 152CONFIG_NETFILTER_XT_MATCH_HELPER=m
480CONFIG_NETFILTER_XT_MATCH_HL=m
481CONFIG_NETFILTER_XT_MATCH_IPRANGE=m 153CONFIG_NETFILTER_XT_MATCH_IPRANGE=m
482CONFIG_NETFILTER_XT_MATCH_IPVS=m 154CONFIG_NETFILTER_XT_MATCH_IPVS=m
483CONFIG_NETFILTER_XT_MATCH_LENGTH=m 155CONFIG_NETFILTER_XT_MATCH_LENGTH=m
@@ -485,7 +157,6 @@ CONFIG_NETFILTER_XT_MATCH_LIMIT=m
485CONFIG_NETFILTER_XT_MATCH_MAC=m 157CONFIG_NETFILTER_XT_MATCH_MAC=m
486CONFIG_NETFILTER_XT_MATCH_MARK=m 158CONFIG_NETFILTER_XT_MATCH_MARK=m
487CONFIG_NETFILTER_XT_MATCH_MULTIPORT=m 159CONFIG_NETFILTER_XT_MATCH_MULTIPORT=m
488# CONFIG_NETFILTER_XT_MATCH_NFACCT is not set
489CONFIG_NETFILTER_XT_MATCH_OSF=m 160CONFIG_NETFILTER_XT_MATCH_OSF=m
490CONFIG_NETFILTER_XT_MATCH_OWNER=m 161CONFIG_NETFILTER_XT_MATCH_OWNER=m
491CONFIG_NETFILTER_XT_MATCH_POLICY=m 162CONFIG_NETFILTER_XT_MATCH_POLICY=m
@@ -495,7 +166,6 @@ CONFIG_NETFILTER_XT_MATCH_QUOTA=m
495CONFIG_NETFILTER_XT_MATCH_RATEEST=m 166CONFIG_NETFILTER_XT_MATCH_RATEEST=m
496CONFIG_NETFILTER_XT_MATCH_REALM=m 167CONFIG_NETFILTER_XT_MATCH_REALM=m
497CONFIG_NETFILTER_XT_MATCH_RECENT=m 168CONFIG_NETFILTER_XT_MATCH_RECENT=m
498CONFIG_NETFILTER_XT_MATCH_SCTP=m
499CONFIG_NETFILTER_XT_MATCH_SOCKET=m 169CONFIG_NETFILTER_XT_MATCH_SOCKET=m
500CONFIG_NETFILTER_XT_MATCH_STATE=m 170CONFIG_NETFILTER_XT_MATCH_STATE=m
501CONFIG_NETFILTER_XT_MATCH_STATISTIC=m 171CONFIG_NETFILTER_XT_MATCH_STATISTIC=m
@@ -503,66 +173,33 @@ CONFIG_NETFILTER_XT_MATCH_STRING=m
503CONFIG_NETFILTER_XT_MATCH_TCPMSS=m 173CONFIG_NETFILTER_XT_MATCH_TCPMSS=m
504CONFIG_NETFILTER_XT_MATCH_TIME=m 174CONFIG_NETFILTER_XT_MATCH_TIME=m
505CONFIG_NETFILTER_XT_MATCH_U32=m 175CONFIG_NETFILTER_XT_MATCH_U32=m
506# CONFIG_IP_SET is not set
507CONFIG_IP_VS=m 176CONFIG_IP_VS=m
508CONFIG_IP_VS_IPV6=y 177CONFIG_IP_VS_IPV6=y
509# CONFIG_IP_VS_DEBUG is not set
510CONFIG_IP_VS_TAB_BITS=12
511
512#
513# IPVS transport protocol load balancing support
514#
515CONFIG_IP_VS_PROTO_TCP=y 178CONFIG_IP_VS_PROTO_TCP=y
516CONFIG_IP_VS_PROTO_UDP=y 179CONFIG_IP_VS_PROTO_UDP=y
517CONFIG_IP_VS_PROTO_AH_ESP=y
518CONFIG_IP_VS_PROTO_ESP=y 180CONFIG_IP_VS_PROTO_ESP=y
519CONFIG_IP_VS_PROTO_AH=y 181CONFIG_IP_VS_PROTO_AH=y
520CONFIG_IP_VS_PROTO_SCTP=y 182CONFIG_IP_VS_PROTO_SCTP=y
521
522#
523# IPVS scheduler
524#
525CONFIG_IP_VS_RR=m 183CONFIG_IP_VS_RR=m
526CONFIG_IP_VS_WRR=m 184CONFIG_IP_VS_WRR=m
527CONFIG_IP_VS_LC=m 185CONFIG_IP_VS_LC=m
528CONFIG_IP_VS_WLC=m 186CONFIG_IP_VS_WLC=m
529CONFIG_IP_VS_LBLC=m 187CONFIG_IP_VS_LBLC=m
530CONFIG_IP_VS_LBLCR=m 188CONFIG_IP_VS_LBLCR=m
531# CONFIG_IP_VS_DH is not set
532# CONFIG_IP_VS_SH is not set
533CONFIG_IP_VS_SED=m 189CONFIG_IP_VS_SED=m
534CONFIG_IP_VS_NQ=m 190CONFIG_IP_VS_NQ=m
535
536#
537# IPVS SH scheduler
538#
539CONFIG_IP_VS_SH_TAB_BITS=8
540
541#
542# IPVS application helper
543#
544# CONFIG_IP_VS_NFCT is not set
545# CONFIG_IP_VS_PE_SIP is not set
546
547#
548# IP: Netfilter Configuration
549#
550CONFIG_NF_DEFRAG_IPV4=m
551CONFIG_NF_CONNTRACK_IPV4=m 191CONFIG_NF_CONNTRACK_IPV4=m
552# CONFIG_NF_CONNTRACK_PROC_COMPAT is not set 192# CONFIG_NF_CONNTRACK_PROC_COMPAT is not set
553CONFIG_IP_NF_QUEUE=m 193CONFIG_IP_NF_QUEUE=m
554CONFIG_IP_NF_IPTABLES=y 194CONFIG_IP_NF_IPTABLES=y
555CONFIG_IP_NF_MATCH_AH=m 195CONFIG_IP_NF_MATCH_AH=m
556CONFIG_IP_NF_MATCH_ECN=m 196CONFIG_IP_NF_MATCH_ECN=m
557# CONFIG_IP_NF_MATCH_RPFILTER is not set
558CONFIG_IP_NF_MATCH_TTL=m 197CONFIG_IP_NF_MATCH_TTL=m
559CONFIG_IP_NF_FILTER=y 198CONFIG_IP_NF_FILTER=y
560CONFIG_IP_NF_TARGET_REJECT=y 199CONFIG_IP_NF_TARGET_REJECT=y
561CONFIG_IP_NF_TARGET_LOG=m 200CONFIG_IP_NF_TARGET_LOG=m
562CONFIG_IP_NF_TARGET_ULOG=m 201CONFIG_IP_NF_TARGET_ULOG=m
563# CONFIG_NF_NAT is not set
564CONFIG_IP_NF_MANGLE=m 202CONFIG_IP_NF_MANGLE=m
565# CONFIG_IP_NF_TARGET_CLUSTERIP is not set
566CONFIG_IP_NF_TARGET_ECN=m 203CONFIG_IP_NF_TARGET_ECN=m
567CONFIG_IP_NF_TARGET_TTL=m 204CONFIG_IP_NF_TARGET_TTL=m
568CONFIG_IP_NF_RAW=m 205CONFIG_IP_NF_RAW=m
@@ -570,11 +207,6 @@ CONFIG_IP_NF_SECURITY=m
570CONFIG_IP_NF_ARPTABLES=m 207CONFIG_IP_NF_ARPTABLES=m
571CONFIG_IP_NF_ARPFILTER=m 208CONFIG_IP_NF_ARPFILTER=m
572CONFIG_IP_NF_ARP_MANGLE=m 209CONFIG_IP_NF_ARP_MANGLE=m
573
574#
575# IPv6: Netfilter Configuration
576#
577CONFIG_NF_DEFRAG_IPV6=m
578CONFIG_NF_CONNTRACK_IPV6=m 210CONFIG_NF_CONNTRACK_IPV6=m
579CONFIG_IP6_NF_QUEUE=m 211CONFIG_IP6_NF_QUEUE=m
580CONFIG_IP6_NF_IPTABLES=m 212CONFIG_IP6_NF_IPTABLES=m
@@ -585,7 +217,6 @@ CONFIG_IP6_NF_MATCH_OPTS=m
585CONFIG_IP6_NF_MATCH_HL=m 217CONFIG_IP6_NF_MATCH_HL=m
586CONFIG_IP6_NF_MATCH_IPV6HEADER=m 218CONFIG_IP6_NF_MATCH_IPV6HEADER=m
587CONFIG_IP6_NF_MATCH_MH=m 219CONFIG_IP6_NF_MATCH_MH=m
588# CONFIG_IP6_NF_MATCH_RPFILTER is not set
589CONFIG_IP6_NF_MATCH_RT=m 220CONFIG_IP6_NF_MATCH_RT=m
590CONFIG_IP6_NF_TARGET_HL=m 221CONFIG_IP6_NF_TARGET_HL=m
591CONFIG_IP6_NF_TARGET_LOG=m 222CONFIG_IP6_NF_TARGET_LOG=m
@@ -616,52 +247,20 @@ CONFIG_BRIDGE_EBT_SNAT=m
616CONFIG_BRIDGE_EBT_LOG=m 247CONFIG_BRIDGE_EBT_LOG=m
617CONFIG_BRIDGE_EBT_ULOG=m 248CONFIG_BRIDGE_EBT_ULOG=m
618CONFIG_BRIDGE_EBT_NFLOG=m 249CONFIG_BRIDGE_EBT_NFLOG=m
619# CONFIG_IP_DCCP is not set
620CONFIG_IP_SCTP=m
621# CONFIG_SCTP_DBG_MSG is not set
622# CONFIG_SCTP_DBG_OBJCNT is not set
623# CONFIG_SCTP_HMAC_NONE is not set
624# CONFIG_SCTP_HMAC_SHA1 is not set
625CONFIG_SCTP_HMAC_MD5=y
626CONFIG_RDS=m 250CONFIG_RDS=m
627CONFIG_RDS_TCP=m 251CONFIG_RDS_TCP=m
628# CONFIG_RDS_DEBUG is not set
629# CONFIG_TIPC is not set
630# CONFIG_ATM is not set
631# CONFIG_L2TP is not set
632CONFIG_STP=m
633CONFIG_GARP=m
634CONFIG_BRIDGE=m 252CONFIG_BRIDGE=m
635CONFIG_BRIDGE_IGMP_SNOOPING=y
636CONFIG_NET_DSA=y 253CONFIG_NET_DSA=y
637CONFIG_NET_DSA_TAG_DSA=y
638CONFIG_NET_DSA_TAG_EDSA=y
639CONFIG_NET_DSA_TAG_TRAILER=y
640CONFIG_VLAN_8021Q=m 254CONFIG_VLAN_8021Q=m
641CONFIG_VLAN_8021Q_GVRP=y 255CONFIG_VLAN_8021Q_GVRP=y
642# CONFIG_DECNET is not set
643CONFIG_LLC=m
644# CONFIG_LLC2 is not set
645# CONFIG_IPX is not set
646# CONFIG_ATALK is not set
647# CONFIG_X25 is not set
648# CONFIG_LAPB is not set
649# CONFIG_ECONET is not set
650# CONFIG_WAN_ROUTER is not set
651CONFIG_PHONET=m 256CONFIG_PHONET=m
652# CONFIG_IEEE802154 is not set
653CONFIG_NET_SCHED=y 257CONFIG_NET_SCHED=y
654
655#
656# Queueing/Scheduling
657#
658CONFIG_NET_SCH_CBQ=m 258CONFIG_NET_SCH_CBQ=m
659CONFIG_NET_SCH_HTB=m 259CONFIG_NET_SCH_HTB=m
660CONFIG_NET_SCH_HFSC=m 260CONFIG_NET_SCH_HFSC=m
661CONFIG_NET_SCH_PRIO=m 261CONFIG_NET_SCH_PRIO=m
662CONFIG_NET_SCH_MULTIQ=m 262CONFIG_NET_SCH_MULTIQ=m
663CONFIG_NET_SCH_RED=m 263CONFIG_NET_SCH_RED=m
664# CONFIG_NET_SCH_SFB is not set
665CONFIG_NET_SCH_SFQ=m 264CONFIG_NET_SCH_SFQ=m
666CONFIG_NET_SCH_TEQL=m 265CONFIG_NET_SCH_TEQL=m
667CONFIG_NET_SCH_TBF=m 266CONFIG_NET_SCH_TBF=m
@@ -669,15 +268,7 @@ CONFIG_NET_SCH_GRED=m
669CONFIG_NET_SCH_DSMARK=m 268CONFIG_NET_SCH_DSMARK=m
670CONFIG_NET_SCH_NETEM=m 269CONFIG_NET_SCH_NETEM=m
671CONFIG_NET_SCH_DRR=m 270CONFIG_NET_SCH_DRR=m
672# CONFIG_NET_SCH_MQPRIO is not set
673# CONFIG_NET_SCH_CHOKE is not set
674# CONFIG_NET_SCH_QFQ is not set
675CONFIG_NET_SCH_INGRESS=m 271CONFIG_NET_SCH_INGRESS=m
676
677#
678# Classification
679#
680CONFIG_NET_CLS=y
681CONFIG_NET_CLS_BASIC=m 272CONFIG_NET_CLS_BASIC=m
682CONFIG_NET_CLS_TCINDEX=m 273CONFIG_NET_CLS_TCINDEX=m
683CONFIG_NET_CLS_ROUTE4=m 274CONFIG_NET_CLS_ROUTE4=m
@@ -690,7 +281,6 @@ CONFIG_NET_CLS_RSVP6=m
690CONFIG_NET_CLS_FLOW=m 281CONFIG_NET_CLS_FLOW=m
691CONFIG_NET_CLS_CGROUP=y 282CONFIG_NET_CLS_CGROUP=y
692CONFIG_NET_EMATCH=y 283CONFIG_NET_EMATCH=y
693CONFIG_NET_EMATCH_STACK=32
694CONFIG_NET_EMATCH_CMP=m 284CONFIG_NET_EMATCH_CMP=m
695CONFIG_NET_EMATCH_NBYTE=m 285CONFIG_NET_EMATCH_NBYTE=m
696CONFIG_NET_EMATCH_U32=m 286CONFIG_NET_EMATCH_U32=m
@@ -706,248 +296,42 @@ CONFIG_NET_ACT_NAT=m
706CONFIG_NET_ACT_PEDIT=m 296CONFIG_NET_ACT_PEDIT=m
707CONFIG_NET_ACT_SIMP=m 297CONFIG_NET_ACT_SIMP=m
708CONFIG_NET_ACT_SKBEDIT=m 298CONFIG_NET_ACT_SKBEDIT=m
709# CONFIG_NET_ACT_CSUM is not set
710CONFIG_NET_CLS_IND=y 299CONFIG_NET_CLS_IND=y
711CONFIG_NET_SCH_FIFO=y
712CONFIG_DCB=y 300CONFIG_DCB=y
713CONFIG_DNS_RESOLVER=y
714# CONFIG_BATMAN_ADV is not set
715# CONFIG_OPENVSWITCH is not set
716CONFIG_RPS=y
717CONFIG_RFS_ACCEL=y
718CONFIG_XPS=y
719# CONFIG_NETPRIO_CGROUP is not set
720CONFIG_BQL=y
721
722#
723# Network testing
724#
725# CONFIG_NET_PKTGEN is not set
726# CONFIG_HAMRADIO is not set
727# CONFIG_CAN is not set
728# CONFIG_IRDA is not set
729# CONFIG_BT is not set
730# CONFIG_AF_RXRPC is not set
731CONFIG_FIB_RULES=y
732# CONFIG_WIRELESS is not set 301# CONFIG_WIRELESS is not set
733# CONFIG_WIMAX is not set
734# CONFIG_RFKILL is not set
735# CONFIG_NET_9P is not set
736# CONFIG_CAIF is not set
737# CONFIG_CEPH_LIB is not set
738# CONFIG_NFC is not set
739
740#
741# Device Drivers
742#
743
744#
745# Generic Driver Options
746#
747CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug" 302CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug"
748CONFIG_DEVTMPFS=y 303CONFIG_DEVTMPFS=y
749CONFIG_DEVTMPFS_MOUNT=y 304CONFIG_DEVTMPFS_MOUNT=y
750CONFIG_STANDALONE=y
751CONFIG_PREVENT_FIRMWARE_BUILD=y
752CONFIG_FW_LOADER=y
753# CONFIG_FIRMWARE_IN_KERNEL is not set 305# CONFIG_FIRMWARE_IN_KERNEL is not set
754CONFIG_EXTRA_FIRMWARE=""
755# CONFIG_DEBUG_DRIVER is not set
756# CONFIG_DEBUG_DEVRES is not set
757CONFIG_SYS_HYPERVISOR=y
758# CONFIG_GENERIC_CPU_DEVICES is not set
759# CONFIG_DMA_SHARED_BUFFER is not set
760CONFIG_CONNECTOR=y 306CONFIG_CONNECTOR=y
761CONFIG_PROC_EVENTS=y
762# CONFIG_MTD is not set
763# CONFIG_PARPORT is not set
764CONFIG_BLK_DEV=y
765# CONFIG_BLK_CPQ_DA is not set
766# CONFIG_BLK_CPQ_CISS_DA is not set
767# CONFIG_BLK_DEV_DAC960 is not set
768# CONFIG_BLK_DEV_UMEM is not set
769# CONFIG_BLK_DEV_COW_COMMON is not set
770CONFIG_BLK_DEV_LOOP=y 307CONFIG_BLK_DEV_LOOP=y
771CONFIG_BLK_DEV_LOOP_MIN_COUNT=8
772CONFIG_BLK_DEV_CRYPTOLOOP=m 308CONFIG_BLK_DEV_CRYPTOLOOP=m
773# CONFIG_BLK_DEV_DRBD is not set
774# CONFIG_BLK_DEV_NBD is not set
775# CONFIG_BLK_DEV_NVME is not set
776CONFIG_BLK_DEV_SX8=m 309CONFIG_BLK_DEV_SX8=m
777CONFIG_BLK_DEV_RAM=y 310CONFIG_BLK_DEV_RAM=y
778CONFIG_BLK_DEV_RAM_COUNT=16
779CONFIG_BLK_DEV_RAM_SIZE=16384 311CONFIG_BLK_DEV_RAM_SIZE=16384
780# CONFIG_BLK_DEV_XIP is not set
781# CONFIG_CDROM_PKTCDVD is not set
782CONFIG_ATA_OVER_ETH=m 312CONFIG_ATA_OVER_ETH=m
783# CONFIG_BLK_DEV_RBD is not set
784
785#
786# Misc devices
787#
788# CONFIG_SENSORS_LIS3LV02D is not set
789# CONFIG_AD525X_DPOT is not set
790# CONFIG_PHANTOM is not set
791# CONFIG_INTEL_MID_PTI is not set
792# CONFIG_SGI_IOC4 is not set
793# CONFIG_TIFM_CORE is not set
794# CONFIG_ICS932S401 is not set
795# CONFIG_ENCLOSURE_SERVICES is not set
796# CONFIG_HP_ILO is not set
797# CONFIG_APDS9802ALS is not set
798# CONFIG_ISL29003 is not set
799# CONFIG_ISL29020 is not set
800# CONFIG_SENSORS_TSL2550 is not set
801# CONFIG_SENSORS_BH1780 is not set
802# CONFIG_SENSORS_BH1770 is not set
803# CONFIG_SENSORS_APDS990X is not set
804# CONFIG_HMC6352 is not set
805# CONFIG_DS1682 is not set
806# CONFIG_BMP085 is not set
807# CONFIG_PCH_PHUB is not set
808# CONFIG_USB_SWITCH_FSA9480 is not set
809# CONFIG_C2PORT is not set
810
811#
812# EEPROM support
813#
814# CONFIG_EEPROM_AT24 is not set
815# CONFIG_EEPROM_LEGACY is not set
816# CONFIG_EEPROM_MAX6875 is not set
817# CONFIG_EEPROM_93CX6 is not set
818# CONFIG_CB710_CORE is not set
819
820#
821# Texas Instruments shared transport line discipline
822#
823# CONFIG_SENSORS_LIS3_I2C is not set
824
825#
826# Altera FPGA firmware download module
827#
828# CONFIG_ALTERA_STAPL is not set
829
830#
831# SCSI device support
832#
833CONFIG_SCSI_MOD=y
834CONFIG_RAID_ATTRS=m 313CONFIG_RAID_ATTRS=m
835CONFIG_SCSI=y
836CONFIG_SCSI_DMA=y
837CONFIG_SCSI_TGT=m 314CONFIG_SCSI_TGT=m
838# CONFIG_SCSI_NETLINK is not set
839CONFIG_SCSI_PROC_FS=y
840
841#
842# SCSI support type (disk, tape, CD-ROM)
843#
844CONFIG_BLK_DEV_SD=y 315CONFIG_BLK_DEV_SD=y
845# CONFIG_CHR_DEV_ST is not set
846# CONFIG_CHR_DEV_OSST is not set
847# CONFIG_BLK_DEV_SR is not set
848# CONFIG_CHR_DEV_SG is not set
849# CONFIG_CHR_DEV_SCH is not set
850# CONFIG_SCSI_MULTI_LUN is not set
851CONFIG_SCSI_CONSTANTS=y 316CONFIG_SCSI_CONSTANTS=y
852CONFIG_SCSI_LOGGING=y 317CONFIG_SCSI_LOGGING=y
853# CONFIG_SCSI_SCAN_ASYNC is not set
854CONFIG_SCSI_WAIT_SCAN=m
855
856#
857# SCSI Transports
858#
859# CONFIG_SCSI_SPI_ATTRS is not set
860# CONFIG_SCSI_FC_ATTRS is not set
861# CONFIG_SCSI_ISCSI_ATTRS is not set
862CONFIG_SCSI_SAS_ATTRS=y
863# CONFIG_SCSI_SAS_LIBSAS is not set
864# CONFIG_SCSI_SRP_ATTRS is not set
865CONFIG_SCSI_LOWLEVEL=y
866# CONFIG_ISCSI_TCP is not set
867# CONFIG_ISCSI_BOOT_SYSFS is not set
868# CONFIG_SCSI_CXGB3_ISCSI is not set
869# CONFIG_SCSI_CXGB4_ISCSI is not set
870# CONFIG_SCSI_BNX2_ISCSI is not set
871# CONFIG_SCSI_BNX2X_FCOE is not set
872# CONFIG_BE2ISCSI is not set
873# CONFIG_BLK_DEV_3W_XXXX_RAID is not set
874# CONFIG_SCSI_HPSA is not set
875# CONFIG_SCSI_3W_9XXX is not set
876# CONFIG_SCSI_3W_SAS is not set
877# CONFIG_SCSI_ACARD is not set
878# CONFIG_SCSI_AACRAID is not set
879# CONFIG_SCSI_AIC7XXX is not set
880# CONFIG_SCSI_AIC7XXX_OLD is not set
881# CONFIG_SCSI_AIC79XX is not set
882# CONFIG_SCSI_AIC94XX is not set
883# CONFIG_SCSI_MVSAS is not set
884# CONFIG_SCSI_MVUMI is not set
885# CONFIG_SCSI_DPT_I2O is not set
886# CONFIG_SCSI_ADVANSYS is not set
887# CONFIG_SCSI_ARCMSR is not set
888# CONFIG_MEGARAID_NEWGEN is not set
889# CONFIG_MEGARAID_LEGACY is not set
890# CONFIG_MEGARAID_SAS is not set
891# CONFIG_SCSI_MPT2SAS is not set
892# CONFIG_SCSI_HPTIOP is not set
893# CONFIG_LIBFC is not set
894# CONFIG_LIBFCOE is not set
895# CONFIG_FCOE is not set
896# CONFIG_SCSI_DMX3191D is not set
897# CONFIG_SCSI_FUTURE_DOMAIN is not set
898# CONFIG_SCSI_IPS is not set
899# CONFIG_SCSI_INITIO is not set
900# CONFIG_SCSI_INIA100 is not set
901# CONFIG_SCSI_STEX is not set
902# CONFIG_SCSI_SYM53C8XX_2 is not set
903# CONFIG_SCSI_IPR is not set
904# CONFIG_SCSI_QLOGIC_1280 is not set
905# CONFIG_SCSI_QLA_FC is not set
906# CONFIG_SCSI_QLA_ISCSI is not set
907# CONFIG_SCSI_LPFC is not set
908# CONFIG_SCSI_DC395x is not set
909# CONFIG_SCSI_DC390T is not set
910# CONFIG_SCSI_NSP32 is not set
911# CONFIG_SCSI_DEBUG is not set
912# CONFIG_SCSI_PMCRAID is not set
913# CONFIG_SCSI_PM8001 is not set
914# CONFIG_SCSI_SRP is not set
915# CONFIG_SCSI_BFA_FC is not set
916# CONFIG_SCSI_LOWLEVEL_PCMCIA is not set
917# CONFIG_SCSI_DH is not set
918# CONFIG_SCSI_OSD_INITIATOR is not set
919CONFIG_ATA=y 318CONFIG_ATA=y
920# CONFIG_ATA_NONSTANDARD is not set
921CONFIG_ATA_VERBOSE_ERROR=y
922CONFIG_SATA_PMP=y
923
924#
925# Controllers with non-SFF native interface
926#
927# CONFIG_SATA_AHCI is not set
928# CONFIG_SATA_AHCI_PLATFORM is not set
929# CONFIG_SATA_INIC162X is not set
930# CONFIG_SATA_ACARD_AHCI is not set
931CONFIG_SATA_SIL24=y 319CONFIG_SATA_SIL24=y
932# CONFIG_ATA_SFF is not set 320# CONFIG_ATA_SFF is not set
933CONFIG_MD=y 321CONFIG_MD=y
934CONFIG_BLK_DEV_MD=y 322CONFIG_BLK_DEV_MD=y
935CONFIG_MD_AUTODETECT=y
936CONFIG_MD_LINEAR=m 323CONFIG_MD_LINEAR=m
937CONFIG_MD_RAID0=m 324CONFIG_MD_RAID0=m
938CONFIG_MD_RAID1=m 325CONFIG_MD_RAID1=m
939CONFIG_MD_RAID10=m 326CONFIG_MD_RAID10=m
940CONFIG_MD_RAID456=m 327CONFIG_MD_RAID456=m
941CONFIG_MULTICORE_RAID456=y 328CONFIG_MULTICORE_RAID456=y
942# CONFIG_MD_MULTIPATH is not set
943CONFIG_MD_FAULTY=m 329CONFIG_MD_FAULTY=m
944CONFIG_BLK_DEV_DM=m 330CONFIG_BLK_DEV_DM=m
945CONFIG_DM_DEBUG=y 331CONFIG_DM_DEBUG=y
946CONFIG_DM_CRYPT=m 332CONFIG_DM_CRYPT=m
947CONFIG_DM_SNAPSHOT=m 333CONFIG_DM_SNAPSHOT=m
948# CONFIG_DM_THIN_PROVISIONING is not set
949CONFIG_DM_MIRROR=m 334CONFIG_DM_MIRROR=m
950# CONFIG_DM_RAID is not set
951CONFIG_DM_LOG_USERSPACE=m 335CONFIG_DM_LOG_USERSPACE=m
952CONFIG_DM_ZERO=m 336CONFIG_DM_ZERO=m
953CONFIG_DM_MULTIPATH=m 337CONFIG_DM_MULTIPATH=m
@@ -955,55 +339,22 @@ CONFIG_DM_MULTIPATH_QL=m
955CONFIG_DM_MULTIPATH_ST=m 339CONFIG_DM_MULTIPATH_ST=m
956CONFIG_DM_DELAY=m 340CONFIG_DM_DELAY=m
957CONFIG_DM_UEVENT=y 341CONFIG_DM_UEVENT=y
958# CONFIG_DM_FLAKEY is not set
959# CONFIG_TARGET_CORE is not set
960CONFIG_FUSION=y 342CONFIG_FUSION=y
961# CONFIG_FUSION_SPI is not set
962# CONFIG_FUSION_FC is not set
963CONFIG_FUSION_SAS=y 343CONFIG_FUSION_SAS=y
964CONFIG_FUSION_MAX_SGE=128
965# CONFIG_FUSION_CTL is not set
966# CONFIG_FUSION_LOGGING is not set
967
968#
969# IEEE 1394 (FireWire) support
970#
971# CONFIG_FIREWIRE is not set
972# CONFIG_FIREWIRE_NOSY is not set
973# CONFIG_I2O is not set
974CONFIG_NETDEVICES=y 344CONFIG_NETDEVICES=y
975CONFIG_NET_CORE=y
976CONFIG_BONDING=m 345CONFIG_BONDING=m
977CONFIG_DUMMY=m 346CONFIG_DUMMY=m
978# CONFIG_EQUALIZER is not set
979# CONFIG_NET_FC is not set
980# CONFIG_MII is not set
981CONFIG_IFB=m 347CONFIG_IFB=m
982# CONFIG_NET_TEAM is not set
983CONFIG_MACVLAN=m 348CONFIG_MACVLAN=m
984CONFIG_MACVTAP=m 349CONFIG_MACVTAP=m
985CONFIG_NETCONSOLE=m 350CONFIG_NETCONSOLE=m
986CONFIG_NETCONSOLE_DYNAMIC=y 351CONFIG_NETCONSOLE_DYNAMIC=y
987CONFIG_NETPOLL=y
988CONFIG_NETPOLL_TRAP=y 352CONFIG_NETPOLL_TRAP=y
989CONFIG_NET_POLL_CONTROLLER=y
990CONFIG_TUN=y 353CONFIG_TUN=y
991CONFIG_VETH=m 354CONFIG_VETH=m
992# CONFIG_ARCNET is not set
993
994#
995# CAIF transport drivers
996#
997
998#
999# Distributed Switch Architecture drivers
1000#
1001CONFIG_NET_DSA_MV88E6XXX=y
1002CONFIG_NET_DSA_MV88E6060=y 355CONFIG_NET_DSA_MV88E6060=y
1003CONFIG_NET_DSA_MV88E6XXX_NEED_PPU=y
1004CONFIG_NET_DSA_MV88E6131=y 356CONFIG_NET_DSA_MV88E6131=y
1005CONFIG_NET_DSA_MV88E6123_61_65=y 357CONFIG_NET_DSA_MV88E6123_61_65=y
1006CONFIG_ETHERNET=y
1007# CONFIG_NET_VENDOR_3COM is not set 358# CONFIG_NET_VENDOR_3COM is not set
1008# CONFIG_NET_VENDOR_ADAPTEC is not set 359# CONFIG_NET_VENDOR_ADAPTEC is not set
1009# CONFIG_NET_VENDOR_ALTEON is not set 360# CONFIG_NET_VENDOR_ALTEON is not set
@@ -1011,27 +362,21 @@ CONFIG_ETHERNET=y
1011# CONFIG_NET_VENDOR_ATHEROS is not set 362# CONFIG_NET_VENDOR_ATHEROS is not set
1012# CONFIG_NET_VENDOR_BROADCOM is not set 363# CONFIG_NET_VENDOR_BROADCOM is not set
1013# CONFIG_NET_VENDOR_BROCADE is not set 364# CONFIG_NET_VENDOR_BROCADE is not set
1014# CONFIG_NET_CALXEDA_XGMAC is not set
1015# CONFIG_NET_VENDOR_CHELSIO is not set 365# CONFIG_NET_VENDOR_CHELSIO is not set
1016# CONFIG_NET_VENDOR_CISCO is not set 366# CONFIG_NET_VENDOR_CISCO is not set
1017# CONFIG_DNET is not set
1018# CONFIG_NET_VENDOR_DEC is not set 367# CONFIG_NET_VENDOR_DEC is not set
1019# CONFIG_NET_VENDOR_DLINK is not set 368# CONFIG_NET_VENDOR_DLINK is not set
1020# CONFIG_NET_VENDOR_EMULEX is not set 369# CONFIG_NET_VENDOR_EMULEX is not set
1021# CONFIG_NET_VENDOR_EXAR is not set 370# CONFIG_NET_VENDOR_EXAR is not set
1022# CONFIG_NET_VENDOR_HP is not set 371# CONFIG_NET_VENDOR_HP is not set
1023# CONFIG_NET_VENDOR_INTEL is not set 372# CONFIG_NET_VENDOR_INTEL is not set
1024# CONFIG_IP1000 is not set
1025# CONFIG_JME is not set
1026# CONFIG_NET_VENDOR_MARVELL is not set 373# CONFIG_NET_VENDOR_MARVELL is not set
1027# CONFIG_NET_VENDOR_MELLANOX is not set 374# CONFIG_NET_VENDOR_MELLANOX is not set
1028# CONFIG_NET_VENDOR_MICREL is not set 375# CONFIG_NET_VENDOR_MICREL is not set
1029# CONFIG_NET_VENDOR_MYRI is not set 376# CONFIG_NET_VENDOR_MYRI is not set
1030# CONFIG_FEALNX is not set
1031# CONFIG_NET_VENDOR_NATSEMI is not set 377# CONFIG_NET_VENDOR_NATSEMI is not set
1032# CONFIG_NET_VENDOR_NVIDIA is not set 378# CONFIG_NET_VENDOR_NVIDIA is not set
1033# CONFIG_NET_VENDOR_OKI is not set 379# CONFIG_NET_VENDOR_OKI is not set
1034# CONFIG_ETHOC is not set
1035# CONFIG_NET_PACKET_ENGINE is not set 380# CONFIG_NET_PACKET_ENGINE is not set
1036# CONFIG_NET_VENDOR_QLOGIC is not set 381# CONFIG_NET_VENDOR_QLOGIC is not set
1037# CONFIG_NET_VENDOR_REALTEK is not set 382# CONFIG_NET_VENDOR_REALTEK is not set
@@ -1039,548 +384,92 @@ CONFIG_ETHERNET=y
1039# CONFIG_NET_VENDOR_SEEQ is not set 384# CONFIG_NET_VENDOR_SEEQ is not set
1040# CONFIG_NET_VENDOR_SILAN is not set 385# CONFIG_NET_VENDOR_SILAN is not set
1041# CONFIG_NET_VENDOR_SIS is not set 386# CONFIG_NET_VENDOR_SIS is not set
1042# CONFIG_SFC is not set
1043# CONFIG_NET_VENDOR_SMSC is not set 387# CONFIG_NET_VENDOR_SMSC is not set
1044# CONFIG_NET_VENDOR_STMICRO is not set 388# CONFIG_NET_VENDOR_STMICRO is not set
1045# CONFIG_NET_VENDOR_SUN is not set 389# CONFIG_NET_VENDOR_SUN is not set
1046# CONFIG_NET_VENDOR_TEHUTI is not set 390# CONFIG_NET_VENDOR_TEHUTI is not set
1047# CONFIG_NET_VENDOR_TI is not set 391# CONFIG_NET_VENDOR_TI is not set
1048CONFIG_TILE_NET=y
1049# CONFIG_NET_VENDOR_VIA is not set 392# CONFIG_NET_VENDOR_VIA is not set
1050# CONFIG_FDDI is not set
1051# CONFIG_HIPPI is not set
1052CONFIG_PHYLIB=y
1053
1054#
1055# MII PHY device drivers
1056#
1057# CONFIG_MARVELL_PHY is not set
1058# CONFIG_DAVICOM_PHY is not set
1059# CONFIG_QSEMI_PHY is not set
1060# CONFIG_LXT_PHY is not set
1061# CONFIG_CICADA_PHY is not set
1062# CONFIG_VITESSE_PHY is not set
1063# CONFIG_SMSC_PHY is not set
1064# CONFIG_BROADCOM_PHY is not set
1065# CONFIG_ICPLUS_PHY is not set
1066# CONFIG_REALTEK_PHY is not set
1067# CONFIG_NATIONAL_PHY is not set
1068# CONFIG_STE10XP is not set
1069# CONFIG_LSI_ET1011C_PHY is not set
1070# CONFIG_MICREL_PHY is not set
1071# CONFIG_FIXED_PHY is not set
1072# CONFIG_MDIO_BITBANG is not set
1073# CONFIG_PPP is not set
1074# CONFIG_SLIP is not set
1075# CONFIG_TR is not set
1076# CONFIG_WLAN is not set 393# CONFIG_WLAN is not set
1077
1078#
1079# Enable WiMAX (Networking options) to see the WiMAX drivers
1080#
1081# CONFIG_WAN is not set
1082# CONFIG_VMXNET3 is not set
1083# CONFIG_ISDN is not set
1084# CONFIG_PHONE is not set
1085
1086#
1087# Input device support
1088#
1089CONFIG_INPUT=y
1090# CONFIG_INPUT_FF_MEMLESS is not set
1091# CONFIG_INPUT_POLLDEV is not set
1092# CONFIG_INPUT_SPARSEKMAP is not set
1093
1094#
1095# Userland interfaces
1096#
1097# CONFIG_INPUT_MOUSEDEV is not set 394# CONFIG_INPUT_MOUSEDEV is not set
1098# CONFIG_INPUT_JOYDEV is not set
1099# CONFIG_INPUT_EVDEV is not set
1100# CONFIG_INPUT_EVBUG is not set
1101
1102#
1103# Input Device Drivers
1104#
1105# CONFIG_INPUT_KEYBOARD is not set 395# CONFIG_INPUT_KEYBOARD is not set
1106# CONFIG_INPUT_MOUSE is not set 396# CONFIG_INPUT_MOUSE is not set
1107# CONFIG_INPUT_JOYSTICK is not set
1108# CONFIG_INPUT_TABLET is not set
1109# CONFIG_INPUT_TOUCHSCREEN is not set
1110# CONFIG_INPUT_MISC is not set
1111
1112#
1113# Hardware I/O ports
1114#
1115# CONFIG_SERIO is not set 397# CONFIG_SERIO is not set
1116# CONFIG_GAMEPORT is not set
1117
1118#
1119# Character devices
1120#
1121# CONFIG_VT is not set 398# CONFIG_VT is not set
1122CONFIG_UNIX98_PTYS=y
1123# CONFIG_DEVPTS_MULTIPLE_INSTANCES is not set
1124# CONFIG_LEGACY_PTYS is not set 399# CONFIG_LEGACY_PTYS is not set
1125# CONFIG_SERIAL_NONSTANDARD is not set
1126# CONFIG_NOZOMI is not set
1127# CONFIG_N_GSM is not set
1128# CONFIG_TRACE_SINK is not set
1129CONFIG_DEVKMEM=y
1130
1131#
1132# Serial drivers
1133#
1134# CONFIG_SERIAL_8250 is not set
1135
1136#
1137# Non-8250 serial port support
1138#
1139# CONFIG_SERIAL_MFD_HSU is not set
1140# CONFIG_SERIAL_JSM is not set
1141# CONFIG_SERIAL_TIMBERDALE is not set
1142# CONFIG_SERIAL_ALTERA_JTAGUART is not set
1143# CONFIG_SERIAL_ALTERA_UART is not set
1144# CONFIG_SERIAL_PCH_UART is not set
1145# CONFIG_SERIAL_XILINX_PS_UART is not set
1146# CONFIG_TTY_PRINTK is not set
1147CONFIG_HVC_DRIVER=y
1148# CONFIG_IPMI_HANDLER is not set
1149CONFIG_HW_RANDOM=y 400CONFIG_HW_RANDOM=y
1150CONFIG_HW_RANDOM_TIMERIOMEM=m 401CONFIG_HW_RANDOM_TIMERIOMEM=m
1151# CONFIG_R3964 is not set
1152# CONFIG_APPLICOM is not set
1153
1154#
1155# PCMCIA character devices
1156#
1157# CONFIG_RAW_DRIVER is not set
1158# CONFIG_TCG_TPM is not set
1159CONFIG_DEVPORT=y
1160# CONFIG_RAMOOPS is not set
1161CONFIG_TILE_SROM=y
1162CONFIG_I2C=y 402CONFIG_I2C=y
1163CONFIG_I2C_BOARDINFO=y
1164CONFIG_I2C_COMPAT=y
1165CONFIG_I2C_CHARDEV=y 403CONFIG_I2C_CHARDEV=y
1166# CONFIG_I2C_MUX is not set
1167CONFIG_I2C_HELPER_AUTO=y
1168
1169#
1170# I2C Hardware Bus support
1171#
1172
1173#
1174# PC SMBus host controller drivers
1175#
1176# CONFIG_I2C_ALI1535 is not set
1177# CONFIG_I2C_ALI1563 is not set
1178# CONFIG_I2C_ALI15X3 is not set
1179# CONFIG_I2C_AMD756 is not set
1180# CONFIG_I2C_AMD8111 is not set
1181# CONFIG_I2C_I801 is not set
1182# CONFIG_I2C_ISCH is not set
1183# CONFIG_I2C_PIIX4 is not set
1184# CONFIG_I2C_NFORCE2 is not set
1185# CONFIG_I2C_SIS5595 is not set
1186# CONFIG_I2C_SIS630 is not set
1187# CONFIG_I2C_SIS96X is not set
1188# CONFIG_I2C_VIA is not set
1189# CONFIG_I2C_VIAPRO is not set
1190
1191#
1192# I2C system bus drivers (mostly embedded / system-on-chip)
1193#
1194# CONFIG_I2C_DESIGNWARE_PCI is not set
1195# CONFIG_I2C_INTEL_MID is not set
1196# CONFIG_I2C_OCORES is not set
1197# CONFIG_I2C_PCA_PLATFORM is not set
1198# CONFIG_I2C_PXA_PCI is not set
1199# CONFIG_I2C_SIMTEC is not set
1200# CONFIG_I2C_XILINX is not set
1201# CONFIG_I2C_EG20T is not set
1202
1203#
1204# External I2C/SMBus adapter drivers
1205#
1206# CONFIG_I2C_PARPORT_LIGHT is not set
1207# CONFIG_I2C_TAOS_EVM is not set
1208
1209#
1210# Other I2C/SMBus bus drivers
1211#
1212# CONFIG_I2C_STUB is not set
1213# CONFIG_I2C_DEBUG_CORE is not set
1214# CONFIG_I2C_DEBUG_ALGO is not set
1215# CONFIG_I2C_DEBUG_BUS is not set
1216# CONFIG_SPI is not set
1217
1218#
1219# PPS support
1220#
1221# CONFIG_PPS is not set
1222
1223#
1224# PPS generators support
1225#
1226
1227#
1228# PTP clock support
1229#
1230
1231#
1232# Enable Device Drivers -> PPS to see the PTP clock options.
1233#
1234# CONFIG_W1 is not set
1235# CONFIG_POWER_SUPPLY is not set
1236# CONFIG_HWMON is not set 404# CONFIG_HWMON is not set
1237# CONFIG_THERMAL is not set
1238CONFIG_WATCHDOG=y 405CONFIG_WATCHDOG=y
1239# CONFIG_WATCHDOG_CORE is not set
1240CONFIG_WATCHDOG_NOWAYOUT=y 406CONFIG_WATCHDOG_NOWAYOUT=y
1241
1242#
1243# Watchdog Device Drivers
1244#
1245# CONFIG_SOFT_WATCHDOG is not set
1246# CONFIG_ALIM7101_WDT is not set
1247
1248#
1249# PCI-based Watchdog Cards
1250#
1251# CONFIG_PCIPCWATCHDOG is not set
1252# CONFIG_WDTPCI is not set
1253CONFIG_SSB_POSSIBLE=y
1254
1255#
1256# Sonics Silicon Backplane
1257#
1258# CONFIG_SSB is not set
1259CONFIG_BCMA_POSSIBLE=y
1260
1261#
1262# Broadcom specific AMBA
1263#
1264# CONFIG_BCMA is not set
1265
1266#
1267# Multifunction device drivers
1268#
1269# CONFIG_MFD_CORE is not set
1270# CONFIG_MFD_88PM860X is not set
1271# CONFIG_MFD_SM501 is not set
1272# CONFIG_HTC_PASIC3 is not set
1273# CONFIG_TPS6105X is not set
1274# CONFIG_TPS6507X is not set
1275# CONFIG_TWL4030_CORE is not set
1276# CONFIG_MFD_STMPE is not set
1277# CONFIG_MFD_TC3589X is not set
1278# CONFIG_MFD_TMIO is not set
1279# CONFIG_PMIC_DA903X is not set
1280# CONFIG_MFD_DA9052_I2C is not set
1281# CONFIG_PMIC_ADP5520 is not set
1282# CONFIG_MFD_MAX8925 is not set
1283# CONFIG_MFD_MAX8997 is not set
1284# CONFIG_MFD_MAX8998 is not set
1285# CONFIG_MFD_S5M_CORE is not set
1286# CONFIG_MFD_WM8400 is not set
1287# CONFIG_MFD_WM831X_I2C is not set
1288# CONFIG_MFD_WM8350_I2C is not set
1289# CONFIG_MFD_WM8994 is not set
1290# CONFIG_MFD_PCF50633 is not set
1291# CONFIG_ABX500_CORE is not set
1292# CONFIG_LPC_SCH is not set
1293# CONFIG_MFD_RDC321X is not set
1294# CONFIG_MFD_JANZ_CMODIO is not set
1295# CONFIG_MFD_VX855 is not set
1296# CONFIG_MFD_WL1273_CORE is not set
1297# CONFIG_REGULATOR is not set
1298# CONFIG_MEDIA_SUPPORT is not set
1299
1300#
1301# Graphics support
1302#
1303# CONFIG_VGA_ARB is not set 407# CONFIG_VGA_ARB is not set
1304# CONFIG_DRM is not set
1305# CONFIG_STUB_POULSBO is not set
1306# CONFIG_VGASTATE is not set
1307# CONFIG_VIDEO_OUTPUT_CONTROL is not set
1308# CONFIG_FB is not set
1309# CONFIG_BACKLIGHT_LCD_SUPPORT is not set
1310# CONFIG_SOUND is not set
1311# CONFIG_HID_SUPPORT is not set 408# CONFIG_HID_SUPPORT is not set
1312# CONFIG_USB_SUPPORT is not set 409# CONFIG_USB_SUPPORT is not set
1313# CONFIG_UWB is not set
1314# CONFIG_MMC is not set
1315# CONFIG_MEMSTICK is not set
1316# CONFIG_NEW_LEDS is not set
1317# CONFIG_ACCESSIBILITY is not set
1318# CONFIG_INFINIBAND is not set
1319CONFIG_EDAC=y 410CONFIG_EDAC=y
1320
1321#
1322# Reporting subsystems
1323#
1324# CONFIG_EDAC_DEBUG is not set
1325CONFIG_EDAC_MM_EDAC=y 411CONFIG_EDAC_MM_EDAC=y
1326CONFIG_EDAC_TILE=y
1327CONFIG_RTC_LIB=y
1328CONFIG_RTC_CLASS=y 412CONFIG_RTC_CLASS=y
1329CONFIG_RTC_HCTOSYS=y
1330CONFIG_RTC_HCTOSYS_DEVICE="rtc0"
1331# CONFIG_RTC_DEBUG is not set
1332
1333#
1334# RTC interfaces
1335#
1336CONFIG_RTC_INTF_SYSFS=y
1337CONFIG_RTC_INTF_PROC=y
1338CONFIG_RTC_INTF_DEV=y
1339# CONFIG_RTC_INTF_DEV_UIE_EMUL is not set
1340# CONFIG_RTC_DRV_TEST is not set
1341
1342#
1343# I2C RTC drivers
1344#
1345# CONFIG_RTC_DRV_DS1307 is not set
1346# CONFIG_RTC_DRV_DS1374 is not set
1347# CONFIG_RTC_DRV_DS1672 is not set
1348# CONFIG_RTC_DRV_DS3232 is not set
1349# CONFIG_RTC_DRV_MAX6900 is not set
1350# CONFIG_RTC_DRV_RS5C372 is not set
1351# CONFIG_RTC_DRV_ISL1208 is not set
1352# CONFIG_RTC_DRV_ISL12022 is not set
1353# CONFIG_RTC_DRV_X1205 is not set
1354# CONFIG_RTC_DRV_PCF8563 is not set
1355# CONFIG_RTC_DRV_PCF8583 is not set
1356# CONFIG_RTC_DRV_M41T80 is not set
1357# CONFIG_RTC_DRV_BQ32K is not set
1358# CONFIG_RTC_DRV_S35390A is not set
1359# CONFIG_RTC_DRV_FM3130 is not set
1360# CONFIG_RTC_DRV_RX8581 is not set
1361# CONFIG_RTC_DRV_RX8025 is not set
1362# CONFIG_RTC_DRV_EM3027 is not set
1363# CONFIG_RTC_DRV_RV3029C2 is not set
1364
1365#
1366# SPI RTC drivers
1367#
1368
1369#
1370# Platform RTC drivers
1371#
1372# CONFIG_RTC_DRV_DS1286 is not set
1373# CONFIG_RTC_DRV_DS1511 is not set
1374# CONFIG_RTC_DRV_DS1553 is not set
1375# CONFIG_RTC_DRV_DS1742 is not set
1376# CONFIG_RTC_DRV_STK17TA8 is not set
1377# CONFIG_RTC_DRV_M48T86 is not set
1378# CONFIG_RTC_DRV_M48T35 is not set
1379# CONFIG_RTC_DRV_M48T59 is not set
1380# CONFIG_RTC_DRV_MSM6242 is not set
1381# CONFIG_RTC_DRV_BQ4802 is not set
1382# CONFIG_RTC_DRV_RP5C01 is not set
1383# CONFIG_RTC_DRV_V3020 is not set
1384
1385#
1386# on-CPU RTC drivers
1387#
1388CONFIG_RTC_DRV_TILE=y 413CONFIG_RTC_DRV_TILE=y
1389# CONFIG_DMADEVICES is not set
1390# CONFIG_AUXDISPLAY is not set
1391# CONFIG_UIO is not set
1392
1393#
1394# Virtio drivers
1395#
1396# CONFIG_VIRTIO_PCI is not set
1397# CONFIG_VIRTIO_BALLOON is not set
1398# CONFIG_VIRTIO_MMIO is not set
1399
1400#
1401# Microsoft Hyper-V guest support
1402#
1403# CONFIG_STAGING is not set
1404
1405#
1406# Hardware Spinlock drivers
1407#
1408CONFIG_IOMMU_SUPPORT=y
1409# CONFIG_VIRT_DRIVERS is not set
1410# CONFIG_PM_DEVFREQ is not set
1411
1412#
1413# File systems
1414#
1415CONFIG_EXT2_FS=y 414CONFIG_EXT2_FS=y
1416CONFIG_EXT2_FS_XATTR=y 415CONFIG_EXT2_FS_XATTR=y
1417CONFIG_EXT2_FS_POSIX_ACL=y 416CONFIG_EXT2_FS_POSIX_ACL=y
1418CONFIG_EXT2_FS_SECURITY=y 417CONFIG_EXT2_FS_SECURITY=y
1419CONFIG_EXT2_FS_XIP=y 418CONFIG_EXT2_FS_XIP=y
1420CONFIG_EXT3_FS=y 419CONFIG_EXT3_FS=y
1421CONFIG_EXT3_DEFAULTS_TO_ORDERED=y
1422CONFIG_EXT3_FS_XATTR=y
1423CONFIG_EXT3_FS_POSIX_ACL=y 420CONFIG_EXT3_FS_POSIX_ACL=y
1424CONFIG_EXT3_FS_SECURITY=y 421CONFIG_EXT3_FS_SECURITY=y
1425CONFIG_EXT4_FS=y 422CONFIG_EXT4_FS=y
1426CONFIG_EXT4_FS_XATTR=y
1427CONFIG_EXT4_FS_POSIX_ACL=y 423CONFIG_EXT4_FS_POSIX_ACL=y
1428CONFIG_EXT4_FS_SECURITY=y 424CONFIG_EXT4_FS_SECURITY=y
1429# CONFIG_EXT4_DEBUG is not set
1430CONFIG_FS_XIP=y
1431CONFIG_JBD=y
1432# CONFIG_JBD_DEBUG is not set
1433CONFIG_JBD2=y
1434# CONFIG_JBD2_DEBUG is not set
1435CONFIG_FS_MBCACHE=y
1436# CONFIG_REISERFS_FS is not set
1437# CONFIG_JFS_FS is not set
1438CONFIG_XFS_FS=y 425CONFIG_XFS_FS=y
1439CONFIG_XFS_QUOTA=y 426CONFIG_XFS_QUOTA=y
1440CONFIG_XFS_POSIX_ACL=y 427CONFIG_XFS_POSIX_ACL=y
1441# CONFIG_XFS_RT is not set
1442# CONFIG_XFS_DEBUG is not set
1443CONFIG_GFS2_FS=m 428CONFIG_GFS2_FS=m
1444CONFIG_GFS2_FS_LOCKING_DLM=y 429CONFIG_GFS2_FS_LOCKING_DLM=y
1445# CONFIG_OCFS2_FS is not set
1446CONFIG_BTRFS_FS=m 430CONFIG_BTRFS_FS=m
1447CONFIG_BTRFS_FS_POSIX_ACL=y 431CONFIG_BTRFS_FS_POSIX_ACL=y
1448# CONFIG_BTRFS_FS_CHECK_INTEGRITY is not set
1449# CONFIG_NILFS2_FS is not set
1450CONFIG_FS_POSIX_ACL=y
1451CONFIG_EXPORTFS=y
1452CONFIG_FILE_LOCKING=y
1453CONFIG_FSNOTIFY=y
1454CONFIG_DNOTIFY=y
1455CONFIG_INOTIFY_USER=y
1456# CONFIG_FANOTIFY is not set
1457CONFIG_QUOTA=y 432CONFIG_QUOTA=y
1458CONFIG_QUOTA_NETLINK_INTERFACE=y 433CONFIG_QUOTA_NETLINK_INTERFACE=y
1459# CONFIG_PRINT_QUOTA_WARNING is not set 434# CONFIG_PRINT_QUOTA_WARNING is not set
1460# CONFIG_QUOTA_DEBUG is not set
1461CONFIG_QUOTA_TREE=y
1462# CONFIG_QFMT_V1 is not set
1463CONFIG_QFMT_V2=y 435CONFIG_QFMT_V2=y
1464CONFIG_QUOTACTL=y
1465CONFIG_AUTOFS4_FS=m 436CONFIG_AUTOFS4_FS=m
1466CONFIG_FUSE_FS=y 437CONFIG_FUSE_FS=y
1467CONFIG_CUSE=m 438CONFIG_CUSE=m
1468CONFIG_GENERIC_ACL=y
1469
1470#
1471# Caches
1472#
1473CONFIG_FSCACHE=m 439CONFIG_FSCACHE=m
1474CONFIG_FSCACHE_STATS=y 440CONFIG_FSCACHE_STATS=y
1475# CONFIG_FSCACHE_HISTOGRAM is not set
1476# CONFIG_FSCACHE_DEBUG is not set
1477# CONFIG_FSCACHE_OBJECT_LIST is not set
1478CONFIG_CACHEFILES=m 441CONFIG_CACHEFILES=m
1479# CONFIG_CACHEFILES_DEBUG is not set
1480# CONFIG_CACHEFILES_HISTOGRAM is not set
1481
1482#
1483# CD-ROM/DVD Filesystems
1484#
1485CONFIG_ISO9660_FS=m 442CONFIG_ISO9660_FS=m
1486CONFIG_JOLIET=y 443CONFIG_JOLIET=y
1487CONFIG_ZISOFS=y 444CONFIG_ZISOFS=y
1488CONFIG_UDF_FS=m 445CONFIG_UDF_FS=m
1489CONFIG_UDF_NLS=y
1490
1491#
1492# DOS/FAT/NT Filesystems
1493#
1494CONFIG_FAT_FS=m
1495CONFIG_MSDOS_FS=m 446CONFIG_MSDOS_FS=m
1496CONFIG_VFAT_FS=m 447CONFIG_VFAT_FS=m
1497CONFIG_FAT_DEFAULT_CODEPAGE=437
1498CONFIG_FAT_DEFAULT_IOCHARSET="ascii" 448CONFIG_FAT_DEFAULT_IOCHARSET="ascii"
1499# CONFIG_NTFS_FS is not set
1500
1501#
1502# Pseudo filesystems
1503#
1504CONFIG_PROC_FS=y
1505CONFIG_PROC_KCORE=y 449CONFIG_PROC_KCORE=y
1506CONFIG_PROC_SYSCTL=y
1507CONFIG_PROC_PAGE_MONITOR=y
1508CONFIG_SYSFS=y
1509CONFIG_TMPFS=y 450CONFIG_TMPFS=y
1510CONFIG_TMPFS_POSIX_ACL=y 451CONFIG_TMPFS_POSIX_ACL=y
1511CONFIG_TMPFS_XATTR=y
1512CONFIG_HUGETLBFS=y 452CONFIG_HUGETLBFS=y
1513CONFIG_HUGETLB_PAGE=y
1514CONFIG_CONFIGFS_FS=m
1515CONFIG_MISC_FILESYSTEMS=y
1516# CONFIG_ADFS_FS is not set
1517# CONFIG_AFFS_FS is not set
1518CONFIG_ECRYPT_FS=m 453CONFIG_ECRYPT_FS=m
1519# CONFIG_HFS_FS is not set
1520# CONFIG_HFSPLUS_FS is not set
1521# CONFIG_BEFS_FS is not set
1522# CONFIG_BFS_FS is not set
1523# CONFIG_EFS_FS is not set
1524# CONFIG_LOGFS is not set
1525CONFIG_CRAMFS=m 454CONFIG_CRAMFS=m
1526CONFIG_SQUASHFS=m 455CONFIG_SQUASHFS=m
1527# CONFIG_SQUASHFS_XATTR is not set
1528CONFIG_SQUASHFS_ZLIB=y
1529# CONFIG_SQUASHFS_LZO is not set
1530# CONFIG_SQUASHFS_XZ is not set
1531# CONFIG_SQUASHFS_4K_DEVBLK_SIZE is not set
1532# CONFIG_SQUASHFS_EMBEDDED is not set
1533CONFIG_SQUASHFS_FRAGMENT_CACHE_SIZE=3
1534# CONFIG_VXFS_FS is not set
1535# CONFIG_MINIX_FS is not set
1536# CONFIG_OMFS_FS is not set
1537# CONFIG_HPFS_FS is not set
1538# CONFIG_QNX4FS_FS is not set
1539# CONFIG_ROMFS_FS is not set
1540# CONFIG_PSTORE is not set
1541# CONFIG_SYSV_FS is not set
1542# CONFIG_UFS_FS is not set
1543CONFIG_NETWORK_FILESYSTEMS=y
1544CONFIG_NFS_FS=m 456CONFIG_NFS_FS=m
1545CONFIG_NFS_V3=y 457CONFIG_NFS_V3=y
1546CONFIG_NFS_V3_ACL=y 458CONFIG_NFS_V3_ACL=y
1547CONFIG_NFS_V4=y 459CONFIG_NFS_V4=y
1548CONFIG_NFS_V4_1=y 460CONFIG_NFS_V4_1=y
1549CONFIG_PNFS_FILE_LAYOUT=m
1550CONFIG_PNFS_BLOCK=m
1551CONFIG_NFS_FSCACHE=y 461CONFIG_NFS_FSCACHE=y
1552# CONFIG_NFS_USE_LEGACY_DNS is not set
1553CONFIG_NFS_USE_KERNEL_DNS=y
1554# CONFIG_NFS_USE_NEW_IDMAPPER is not set
1555CONFIG_NFSD=m 462CONFIG_NFSD=m
1556CONFIG_NFSD_V2_ACL=y
1557CONFIG_NFSD_V3=y
1558CONFIG_NFSD_V3_ACL=y 463CONFIG_NFSD_V3_ACL=y
1559CONFIG_NFSD_V4=y 464CONFIG_NFSD_V4=y
1560# CONFIG_NFSD_FAULT_INJECTION is not set
1561CONFIG_LOCKD=m
1562CONFIG_LOCKD_V4=y
1563CONFIG_NFS_ACL_SUPPORT=m
1564CONFIG_NFS_COMMON=y
1565CONFIG_SUNRPC=m
1566CONFIG_SUNRPC_GSS=m
1567CONFIG_SUNRPC_BACKCHANNEL=y
1568CONFIG_RPCSEC_GSS_KRB5=m
1569# CONFIG_CEPH_FS is not set
1570CONFIG_CIFS=m 465CONFIG_CIFS=m
1571CONFIG_CIFS_STATS=y 466CONFIG_CIFS_STATS=y
1572# CONFIG_CIFS_STATS2 is not set
1573CONFIG_CIFS_WEAK_PW_HASH=y 467CONFIG_CIFS_WEAK_PW_HASH=y
1574CONFIG_CIFS_UPCALL=y 468CONFIG_CIFS_UPCALL=y
1575CONFIG_CIFS_XATTR=y 469CONFIG_CIFS_XATTR=y
1576CONFIG_CIFS_POSIX=y 470CONFIG_CIFS_POSIX=y
1577# CONFIG_CIFS_DEBUG2 is not set
1578CONFIG_CIFS_DFS_UPCALL=y 471CONFIG_CIFS_DFS_UPCALL=y
1579CONFIG_CIFS_FSCACHE=y 472CONFIG_CIFS_FSCACHE=y
1580# CONFIG_CIFS_ACL is not set
1581# CONFIG_NCP_FS is not set
1582# CONFIG_CODA_FS is not set
1583# CONFIG_AFS_FS is not set
1584CONFIG_NLS=y 473CONFIG_NLS=y
1585CONFIG_NLS_DEFAULT="utf8" 474CONFIG_NLS_DEFAULT="utf8"
1586CONFIG_NLS_CODEPAGE_437=y 475CONFIG_NLS_CODEPAGE_437=y
@@ -1621,192 +510,48 @@ CONFIG_NLS_ISO8859_15=m
1621CONFIG_NLS_KOI8_R=m 510CONFIG_NLS_KOI8_R=m
1622CONFIG_NLS_KOI8_U=m 511CONFIG_NLS_KOI8_U=m
1623CONFIG_NLS_UTF8=m 512CONFIG_NLS_UTF8=m
1624CONFIG_DLM=m
1625CONFIG_DLM_DEBUG=y 513CONFIG_DLM_DEBUG=y
1626
1627#
1628# Kernel hacking
1629#
1630# CONFIG_PRINTK_TIME is not set
1631CONFIG_DEFAULT_MESSAGE_LOGLEVEL=4
1632# CONFIG_ENABLE_WARN_DEPRECATED is not set 514# CONFIG_ENABLE_WARN_DEPRECATED is not set
1633CONFIG_ENABLE_MUST_CHECK=y
1634CONFIG_FRAME_WARN=2048 515CONFIG_FRAME_WARN=2048
1635CONFIG_MAGIC_SYSRQ=y 516CONFIG_MAGIC_SYSRQ=y
1636CONFIG_STRIP_ASM_SYMS=y 517CONFIG_STRIP_ASM_SYMS=y
1637# CONFIG_UNUSED_SYMBOLS is not set
1638CONFIG_DEBUG_FS=y 518CONFIG_DEBUG_FS=y
1639CONFIG_HEADERS_CHECK=y 519CONFIG_HEADERS_CHECK=y
1640# CONFIG_DEBUG_SECTION_MISMATCH is not set
1641CONFIG_DEBUG_KERNEL=y
1642# CONFIG_DEBUG_SHIRQ is not set
1643CONFIG_LOCKUP_DETECTOR=y 520CONFIG_LOCKUP_DETECTOR=y
1644# CONFIG_HARDLOCKUP_DETECTOR is not set
1645# CONFIG_BOOTPARAM_HARDLOCKUP_PANIC is not set
1646CONFIG_BOOTPARAM_HARDLOCKUP_PANIC_VALUE=0
1647# CONFIG_BOOTPARAM_SOFTLOCKUP_PANIC is not set
1648CONFIG_BOOTPARAM_SOFTLOCKUP_PANIC_VALUE=0
1649CONFIG_DETECT_HUNG_TASK=y
1650CONFIG_DEFAULT_HUNG_TASK_TIMEOUT=120
1651# CONFIG_BOOTPARAM_HUNG_TASK_PANIC is not set
1652CONFIG_BOOTPARAM_HUNG_TASK_PANIC_VALUE=0
1653CONFIG_SCHED_DEBUG=y
1654CONFIG_SCHEDSTATS=y 521CONFIG_SCHEDSTATS=y
1655CONFIG_TIMER_STATS=y 522CONFIG_TIMER_STATS=y
1656# CONFIG_DEBUG_OBJECTS is not set
1657# CONFIG_SLUB_DEBUG_ON is not set
1658# CONFIG_SLUB_STATS is not set
1659# CONFIG_DEBUG_KMEMLEAK is not set
1660# CONFIG_DEBUG_RT_MUTEXES is not set
1661# CONFIG_RT_MUTEX_TESTER is not set
1662# CONFIG_DEBUG_SPINLOCK is not set
1663# CONFIG_DEBUG_MUTEXES is not set
1664# CONFIG_DEBUG_LOCK_ALLOC is not set
1665# CONFIG_PROVE_LOCKING is not set
1666# CONFIG_SPARSE_RCU_POINTER is not set
1667# CONFIG_LOCK_STAT is not set
1668# CONFIG_DEBUG_ATOMIC_SLEEP is not set
1669# CONFIG_DEBUG_LOCKING_API_SELFTESTS is not set
1670CONFIG_STACKTRACE=y
1671# CONFIG_DEBUG_STACK_USAGE is not set
1672# CONFIG_DEBUG_KOBJECT is not set
1673# CONFIG_DEBUG_HIGHMEM is not set
1674CONFIG_DEBUG_BUGVERBOSE=y
1675CONFIG_DEBUG_INFO=y 523CONFIG_DEBUG_INFO=y
1676CONFIG_DEBUG_INFO_REDUCED=y 524CONFIG_DEBUG_INFO_REDUCED=y
1677CONFIG_DEBUG_VM=y 525CONFIG_DEBUG_VM=y
1678# CONFIG_DEBUG_WRITECOUNT is not set
1679CONFIG_DEBUG_MEMORY_INIT=y 526CONFIG_DEBUG_MEMORY_INIT=y
1680CONFIG_DEBUG_LIST=y 527CONFIG_DEBUG_LIST=y
1681# CONFIG_TEST_LIST_SORT is not set
1682# CONFIG_DEBUG_SG is not set
1683# CONFIG_DEBUG_NOTIFIERS is not set
1684CONFIG_DEBUG_CREDENTIALS=y 528CONFIG_DEBUG_CREDENTIALS=y
1685# CONFIG_RCU_TORTURE_TEST is not set
1686CONFIG_RCU_CPU_STALL_TIMEOUT=60
1687# CONFIG_BACKTRACE_SELF_TEST is not set
1688# CONFIG_DEBUG_BLOCK_EXT_DEVT is not set
1689CONFIG_DEBUG_FORCE_WEAK_PER_CPU=y 529CONFIG_DEBUG_FORCE_WEAK_PER_CPU=y
1690# CONFIG_DEBUG_PER_CPU_MAPS is not set
1691# CONFIG_LKDTM is not set
1692# CONFIG_FAULT_INJECTION is not set
1693# CONFIG_SYSCTL_SYSCALL_CHECK is not set
1694# CONFIG_DEBUG_PAGEALLOC is not set
1695CONFIG_TRACING_SUPPORT=y
1696CONFIG_FTRACE=y
1697# CONFIG_IRQSOFF_TRACER is not set
1698# CONFIG_SCHED_TRACER is not set
1699# CONFIG_ENABLE_DEFAULT_TRACERS is not set
1700CONFIG_BRANCH_PROFILE_NONE=y
1701# CONFIG_PROFILE_ANNOTATED_BRANCHES is not set
1702# CONFIG_PROFILE_ALL_BRANCHES is not set
1703# CONFIG_BLK_DEV_IO_TRACE is not set
1704# CONFIG_BUILD_DOCSRC is not set
1705CONFIG_DYNAMIC_DEBUG=y 530CONFIG_DYNAMIC_DEBUG=y
1706# CONFIG_ATOMIC64_SELFTEST is not set
1707CONFIG_ASYNC_RAID6_TEST=m 531CONFIG_ASYNC_RAID6_TEST=m
1708# CONFIG_SAMPLES is not set
1709# CONFIG_TEST_KSTRTOX is not set
1710CONFIG_EARLY_PRINTK=y
1711CONFIG_DEBUG_STACKOVERFLOW=y 532CONFIG_DEBUG_STACKOVERFLOW=y
1712CONFIG_DEBUG_EXTRA_FLAGS=""
1713
1714#
1715# Security options
1716#
1717CONFIG_KEYS=y
1718# CONFIG_ENCRYPTED_KEYS is not set
1719CONFIG_KEYS_DEBUG_PROC_KEYS=y 533CONFIG_KEYS_DEBUG_PROC_KEYS=y
1720# CONFIG_SECURITY_DMESG_RESTRICT is not set
1721CONFIG_SECURITY=y 534CONFIG_SECURITY=y
1722CONFIG_SECURITYFS=y 535CONFIG_SECURITYFS=y
1723CONFIG_SECURITY_NETWORK=y 536CONFIG_SECURITY_NETWORK=y
1724CONFIG_SECURITY_NETWORK_XFRM=y 537CONFIG_SECURITY_NETWORK_XFRM=y
1725# CONFIG_SECURITY_PATH is not set
1726CONFIG_LSM_MMAP_MIN_ADDR=65536
1727CONFIG_SECURITY_SELINUX=y 538CONFIG_SECURITY_SELINUX=y
1728CONFIG_SECURITY_SELINUX_BOOTPARAM=y 539CONFIG_SECURITY_SELINUX_BOOTPARAM=y
1729CONFIG_SECURITY_SELINUX_BOOTPARAM_VALUE=1
1730CONFIG_SECURITY_SELINUX_DISABLE=y 540CONFIG_SECURITY_SELINUX_DISABLE=y
1731CONFIG_SECURITY_SELINUX_DEVELOP=y
1732CONFIG_SECURITY_SELINUX_AVC_STATS=y
1733CONFIG_SECURITY_SELINUX_CHECKREQPROT_VALUE=1
1734# CONFIG_SECURITY_SELINUX_POLICYDB_VERSION_MAX is not set
1735# CONFIG_SECURITY_SMACK is not set
1736# CONFIG_SECURITY_TOMOYO is not set
1737# CONFIG_SECURITY_APPARMOR is not set
1738# CONFIG_IMA is not set
1739# CONFIG_EVM is not set
1740CONFIG_DEFAULT_SECURITY_SELINUX=y
1741# CONFIG_DEFAULT_SECURITY_DAC is not set
1742CONFIG_DEFAULT_SECURITY="selinux"
1743CONFIG_XOR_BLOCKS=m
1744CONFIG_ASYNC_CORE=m
1745CONFIG_ASYNC_MEMCPY=m
1746CONFIG_ASYNC_XOR=m
1747CONFIG_ASYNC_PQ=m
1748CONFIG_ASYNC_RAID6_RECOV=m
1749CONFIG_CRYPTO=y
1750
1751#
1752# Crypto core or helper
1753#
1754CONFIG_CRYPTO_ALGAPI=y
1755CONFIG_CRYPTO_ALGAPI2=y
1756CONFIG_CRYPTO_AEAD=m
1757CONFIG_CRYPTO_AEAD2=y
1758CONFIG_CRYPTO_BLKCIPHER=m
1759CONFIG_CRYPTO_BLKCIPHER2=y
1760CONFIG_CRYPTO_HASH=y
1761CONFIG_CRYPTO_HASH2=y
1762CONFIG_CRYPTO_RNG=m
1763CONFIG_CRYPTO_RNG2=y
1764CONFIG_CRYPTO_PCOMP=m
1765CONFIG_CRYPTO_PCOMP2=y
1766CONFIG_CRYPTO_MANAGER=y
1767CONFIG_CRYPTO_MANAGER2=y
1768# CONFIG_CRYPTO_USER is not set
1769CONFIG_CRYPTO_MANAGER_DISABLE_TESTS=y
1770CONFIG_CRYPTO_GF128MUL=m
1771CONFIG_CRYPTO_NULL=m 541CONFIG_CRYPTO_NULL=m
1772CONFIG_CRYPTO_PCRYPT=m 542CONFIG_CRYPTO_PCRYPT=m
1773CONFIG_CRYPTO_WORKQUEUE=y
1774CONFIG_CRYPTO_CRYPTD=m 543CONFIG_CRYPTO_CRYPTD=m
1775CONFIG_CRYPTO_AUTHENC=m
1776CONFIG_CRYPTO_TEST=m 544CONFIG_CRYPTO_TEST=m
1777
1778#
1779# Authenticated Encryption with Associated Data
1780#
1781CONFIG_CRYPTO_CCM=m 545CONFIG_CRYPTO_CCM=m
1782CONFIG_CRYPTO_GCM=m 546CONFIG_CRYPTO_GCM=m
1783CONFIG_CRYPTO_SEQIV=m
1784
1785#
1786# Block modes
1787#
1788CONFIG_CRYPTO_CBC=m
1789CONFIG_CRYPTO_CTR=m
1790CONFIG_CRYPTO_CTS=m 547CONFIG_CRYPTO_CTS=m
1791CONFIG_CRYPTO_ECB=m
1792CONFIG_CRYPTO_LRW=m 548CONFIG_CRYPTO_LRW=m
1793CONFIG_CRYPTO_PCBC=m 549CONFIG_CRYPTO_PCBC=m
1794CONFIG_CRYPTO_XTS=m 550CONFIG_CRYPTO_XTS=m
1795
1796#
1797# Hash modes
1798#
1799CONFIG_CRYPTO_HMAC=y 551CONFIG_CRYPTO_HMAC=y
1800CONFIG_CRYPTO_XCBC=m 552CONFIG_CRYPTO_XCBC=m
1801CONFIG_CRYPTO_VMAC=m 553CONFIG_CRYPTO_VMAC=m
1802
1803#
1804# Digest
1805#
1806CONFIG_CRYPTO_CRC32C=y 554CONFIG_CRYPTO_CRC32C=y
1807CONFIG_CRYPTO_GHASH=m
1808CONFIG_CRYPTO_MD4=m
1809CONFIG_CRYPTO_MD5=y
1810CONFIG_CRYPTO_MICHAEL_MIC=m 555CONFIG_CRYPTO_MICHAEL_MIC=m
1811CONFIG_CRYPTO_RMD128=m 556CONFIG_CRYPTO_RMD128=m
1812CONFIG_CRYPTO_RMD160=m 557CONFIG_CRYPTO_RMD160=m
@@ -1817,78 +562,18 @@ CONFIG_CRYPTO_SHA256=m
1817CONFIG_CRYPTO_SHA512=m 562CONFIG_CRYPTO_SHA512=m
1818CONFIG_CRYPTO_TGR192=m 563CONFIG_CRYPTO_TGR192=m
1819CONFIG_CRYPTO_WP512=m 564CONFIG_CRYPTO_WP512=m
1820
1821#
1822# Ciphers
1823#
1824CONFIG_CRYPTO_AES=m
1825CONFIG_CRYPTO_ANUBIS=m 565CONFIG_CRYPTO_ANUBIS=m
1826CONFIG_CRYPTO_ARC4=m
1827CONFIG_CRYPTO_BLOWFISH=m 566CONFIG_CRYPTO_BLOWFISH=m
1828CONFIG_CRYPTO_BLOWFISH_COMMON=m
1829CONFIG_CRYPTO_CAMELLIA=m 567CONFIG_CRYPTO_CAMELLIA=m
1830CONFIG_CRYPTO_CAST5=m 568CONFIG_CRYPTO_CAST5=m
1831CONFIG_CRYPTO_CAST6=m 569CONFIG_CRYPTO_CAST6=m
1832CONFIG_CRYPTO_DES=m
1833CONFIG_CRYPTO_FCRYPT=m 570CONFIG_CRYPTO_FCRYPT=m
1834CONFIG_CRYPTO_KHAZAD=m 571CONFIG_CRYPTO_KHAZAD=m
1835# CONFIG_CRYPTO_SALSA20 is not set
1836CONFIG_CRYPTO_SEED=m 572CONFIG_CRYPTO_SEED=m
1837CONFIG_CRYPTO_SERPENT=m 573CONFIG_CRYPTO_SERPENT=m
1838CONFIG_CRYPTO_TEA=m 574CONFIG_CRYPTO_TEA=m
1839CONFIG_CRYPTO_TWOFISH=m 575CONFIG_CRYPTO_TWOFISH=m
1840CONFIG_CRYPTO_TWOFISH_COMMON=m
1841
1842#
1843# Compression
1844#
1845CONFIG_CRYPTO_DEFLATE=m
1846CONFIG_CRYPTO_ZLIB=m 576CONFIG_CRYPTO_ZLIB=m
1847CONFIG_CRYPTO_LZO=m 577CONFIG_CRYPTO_LZO=m
1848
1849#
1850# Random Number Generation
1851#
1852CONFIG_CRYPTO_ANSI_CPRNG=m
1853# CONFIG_CRYPTO_USER_API_HASH is not set
1854# CONFIG_CRYPTO_USER_API_SKCIPHER is not set
1855CONFIG_CRYPTO_HW=y
1856# CONFIG_BINARY_PRINTF is not set
1857
1858#
1859# Library routines
1860#
1861CONFIG_RAID6_PQ=m
1862CONFIG_BITREVERSE=y
1863CONFIG_GENERIC_FIND_FIRST_BIT=y
1864CONFIG_GENERIC_PCI_IOMAP=y
1865CONFIG_CRC_CCITT=m 578CONFIG_CRC_CCITT=m
1866CONFIG_CRC16=y
1867CONFIG_CRC_T10DIF=y
1868CONFIG_CRC_ITU_T=m
1869CONFIG_CRC32=y
1870CONFIG_CRC7=m 579CONFIG_CRC7=m
1871CONFIG_LIBCRC32C=m
1872# CONFIG_CRC8 is not set
1873CONFIG_AUDIT_GENERIC=y
1874CONFIG_ZLIB_INFLATE=y
1875CONFIG_ZLIB_DEFLATE=m
1876CONFIG_LZO_COMPRESS=m
1877CONFIG_LZO_DECOMPRESS=m
1878# CONFIG_XZ_DEC is not set
1879# CONFIG_XZ_DEC_BCJ is not set
1880CONFIG_DECOMPRESS_GZIP=y
1881CONFIG_TEXTSEARCH=y
1882CONFIG_TEXTSEARCH_KMP=m
1883CONFIG_TEXTSEARCH_BM=m
1884CONFIG_TEXTSEARCH_FSM=m
1885CONFIG_HAS_IOMEM=y
1886CONFIG_HAS_IOPORT=y
1887CONFIG_HAS_DMA=y
1888CONFIG_CPU_RMAP=y
1889CONFIG_DQL=y
1890CONFIG_NLATTR=y
1891# CONFIG_AVERAGE is not set
1892# CONFIG_CORDIC is not set
1893CONFIG_HAVE_KVM=y
1894# CONFIG_VIRTUALIZATION is not set
diff --git a/arch/tile/kernel/process.c b/arch/tile/kernel/process.c
index 4c1ac6e5347a..6ae495ef2b99 100644
--- a/arch/tile/kernel/process.c
+++ b/arch/tile/kernel/process.c
@@ -108,9 +108,7 @@ void cpu_idle(void)
108 } 108 }
109 rcu_idle_exit(); 109 rcu_idle_exit();
110 tick_nohz_idle_exit(); 110 tick_nohz_idle_exit();
111 preempt_enable_no_resched(); 111 schedule_preempt_disabled();
112 schedule();
113 preempt_disable();
114 } 112 }
115} 113}
116 114
diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
index 5bed94e189fa..09675d3e0ac3 100644
--- a/arch/x86/Kconfig
+++ b/arch/x86/Kconfig
@@ -82,6 +82,7 @@ config X86
82 select CLKEVT_I8253 82 select CLKEVT_I8253
83 select ARCH_HAVE_NMI_SAFE_CMPXCHG 83 select ARCH_HAVE_NMI_SAFE_CMPXCHG
84 select GENERIC_IOMAP 84 select GENERIC_IOMAP
85 select DCACHE_WORD_ACCESS if !DEBUG_PAGEALLOC
85 86
86config INSTRUCTION_DECODER 87config INSTRUCTION_DECODER
87 def_bool (KPROBES || PERF_EVENTS) 88 def_bool (KPROBES || PERF_EVENTS)
diff --git a/arch/x86/include/asm/hardirq.h b/arch/x86/include/asm/hardirq.h
index da0b3ca815b7..382f75d735f3 100644
--- a/arch/x86/include/asm/hardirq.h
+++ b/arch/x86/include/asm/hardirq.h
@@ -7,7 +7,6 @@
7typedef struct { 7typedef struct {
8 unsigned int __softirq_pending; 8 unsigned int __softirq_pending;
9 unsigned int __nmi_count; /* arch dependent */ 9 unsigned int __nmi_count; /* arch dependent */
10 unsigned int irq0_irqs;
11#ifdef CONFIG_X86_LOCAL_APIC 10#ifdef CONFIG_X86_LOCAL_APIC
12 unsigned int apic_timer_irqs; /* arch dependent */ 11 unsigned int apic_timer_irqs; /* arch dependent */
13 unsigned int irq_spurious_count; 12 unsigned int irq_spurious_count;
diff --git a/arch/x86/include/asm/inat.h b/arch/x86/include/asm/inat.h
index 205b063e3e32..74a2e312e8a2 100644
--- a/arch/x86/include/asm/inat.h
+++ b/arch/x86/include/asm/inat.h
@@ -97,11 +97,12 @@
97 97
98/* Attribute search APIs */ 98/* Attribute search APIs */
99extern insn_attr_t inat_get_opcode_attribute(insn_byte_t opcode); 99extern insn_attr_t inat_get_opcode_attribute(insn_byte_t opcode);
100extern int inat_get_last_prefix_id(insn_byte_t last_pfx);
100extern insn_attr_t inat_get_escape_attribute(insn_byte_t opcode, 101extern insn_attr_t inat_get_escape_attribute(insn_byte_t opcode,
101 insn_byte_t last_pfx, 102 int lpfx_id,
102 insn_attr_t esc_attr); 103 insn_attr_t esc_attr);
103extern insn_attr_t inat_get_group_attribute(insn_byte_t modrm, 104extern insn_attr_t inat_get_group_attribute(insn_byte_t modrm,
104 insn_byte_t last_pfx, 105 int lpfx_id,
105 insn_attr_t esc_attr); 106 insn_attr_t esc_attr);
106extern insn_attr_t inat_get_avx_attribute(insn_byte_t opcode, 107extern insn_attr_t inat_get_avx_attribute(insn_byte_t opcode,
107 insn_byte_t vex_m, 108 insn_byte_t vex_m,
diff --git a/arch/x86/include/asm/insn.h b/arch/x86/include/asm/insn.h
index 74df3f1eddfd..48eb30a86062 100644
--- a/arch/x86/include/asm/insn.h
+++ b/arch/x86/include/asm/insn.h
@@ -96,12 +96,6 @@ struct insn {
96#define X86_VEX_P(vex) ((vex) & 0x03) /* VEX3 Byte2, VEX2 Byte1 */ 96#define X86_VEX_P(vex) ((vex) & 0x03) /* VEX3 Byte2, VEX2 Byte1 */
97#define X86_VEX_M_MAX 0x1f /* VEX3.M Maximum value */ 97#define X86_VEX_M_MAX 0x1f /* VEX3.M Maximum value */
98 98
99/* The last prefix is needed for two-byte and three-byte opcodes */
100static inline insn_byte_t insn_last_prefix(struct insn *insn)
101{
102 return insn->prefixes.bytes[3];
103}
104
105extern void insn_init(struct insn *insn, const void *kaddr, int x86_64); 99extern void insn_init(struct insn *insn, const void *kaddr, int x86_64);
106extern void insn_get_prefixes(struct insn *insn); 100extern void insn_get_prefixes(struct insn *insn);
107extern void insn_get_opcode(struct insn *insn); 101extern void insn_get_opcode(struct insn *insn);
@@ -160,6 +154,18 @@ static inline insn_byte_t insn_vex_p_bits(struct insn *insn)
160 return X86_VEX_P(insn->vex_prefix.bytes[2]); 154 return X86_VEX_P(insn->vex_prefix.bytes[2]);
161} 155}
162 156
157/* Get the last prefix id from last prefix or VEX prefix */
158static inline int insn_last_prefix_id(struct insn *insn)
159{
160 if (insn_is_avx(insn))
161 return insn_vex_p_bits(insn); /* VEX_p is a SIMD prefix id */
162
163 if (insn->prefixes.bytes[3])
164 return inat_get_last_prefix_id(insn->prefixes.bytes[3]);
165
166 return 0;
167}
168
163/* Offset of each field from kaddr */ 169/* Offset of each field from kaddr */
164static inline int insn_offset_rex_prefix(struct insn *insn) 170static inline int insn_offset_rex_prefix(struct insn *insn)
165{ 171{
diff --git a/arch/x86/include/asm/jump_label.h b/arch/x86/include/asm/jump_label.h
index a32b18ce6ead..3a16c1483b45 100644
--- a/arch/x86/include/asm/jump_label.h
+++ b/arch/x86/include/asm/jump_label.h
@@ -9,12 +9,12 @@
9 9
10#define JUMP_LABEL_NOP_SIZE 5 10#define JUMP_LABEL_NOP_SIZE 5
11 11
12#define JUMP_LABEL_INITIAL_NOP ".byte 0xe9 \n\t .long 0\n\t" 12#define STATIC_KEY_INITIAL_NOP ".byte 0xe9 \n\t .long 0\n\t"
13 13
14static __always_inline bool arch_static_branch(struct jump_label_key *key) 14static __always_inline bool arch_static_branch(struct static_key *key)
15{ 15{
16 asm goto("1:" 16 asm goto("1:"
17 JUMP_LABEL_INITIAL_NOP 17 STATIC_KEY_INITIAL_NOP
18 ".pushsection __jump_table, \"aw\" \n\t" 18 ".pushsection __jump_table, \"aw\" \n\t"
19 _ASM_ALIGN "\n\t" 19 _ASM_ALIGN "\n\t"
20 _ASM_PTR "1b, %l[l_yes], %c0 \n\t" 20 _ASM_PTR "1b, %l[l_yes], %c0 \n\t"
diff --git a/arch/x86/include/asm/msr-index.h b/arch/x86/include/asm/msr-index.h
index a6962d9161a0..ccb805966f68 100644
--- a/arch/x86/include/asm/msr-index.h
+++ b/arch/x86/include/asm/msr-index.h
@@ -56,6 +56,13 @@
56#define MSR_OFFCORE_RSP_0 0x000001a6 56#define MSR_OFFCORE_RSP_0 0x000001a6
57#define MSR_OFFCORE_RSP_1 0x000001a7 57#define MSR_OFFCORE_RSP_1 0x000001a7
58 58
59#define MSR_LBR_SELECT 0x000001c8
60#define MSR_LBR_TOS 0x000001c9
61#define MSR_LBR_NHM_FROM 0x00000680
62#define MSR_LBR_NHM_TO 0x000006c0
63#define MSR_LBR_CORE_FROM 0x00000040
64#define MSR_LBR_CORE_TO 0x00000060
65
59#define MSR_IA32_PEBS_ENABLE 0x000003f1 66#define MSR_IA32_PEBS_ENABLE 0x000003f1
60#define MSR_IA32_DS_AREA 0x00000600 67#define MSR_IA32_DS_AREA 0x00000600
61#define MSR_IA32_PERF_CAPABILITIES 0x00000345 68#define MSR_IA32_PERF_CAPABILITIES 0x00000345
diff --git a/arch/x86/include/asm/paravirt.h b/arch/x86/include/asm/paravirt.h
index a7d2db9a74fb..c0180fd372d2 100644
--- a/arch/x86/include/asm/paravirt.h
+++ b/arch/x86/include/asm/paravirt.h
@@ -230,9 +230,9 @@ static inline unsigned long long paravirt_sched_clock(void)
230 return PVOP_CALL0(unsigned long long, pv_time_ops.sched_clock); 230 return PVOP_CALL0(unsigned long long, pv_time_ops.sched_clock);
231} 231}
232 232
233struct jump_label_key; 233struct static_key;
234extern struct jump_label_key paravirt_steal_enabled; 234extern struct static_key paravirt_steal_enabled;
235extern struct jump_label_key paravirt_steal_rq_enabled; 235extern struct static_key paravirt_steal_rq_enabled;
236 236
237static inline u64 paravirt_steal_clock(int cpu) 237static inline u64 paravirt_steal_clock(int cpu)
238{ 238{
diff --git a/arch/x86/include/asm/perf_event.h b/arch/x86/include/asm/perf_event.h
index 461ce432b1c2..e8fb2c7a5f4f 100644
--- a/arch/x86/include/asm/perf_event.h
+++ b/arch/x86/include/asm/perf_event.h
@@ -188,8 +188,6 @@ extern u32 get_ibs_caps(void);
188#ifdef CONFIG_PERF_EVENTS 188#ifdef CONFIG_PERF_EVENTS
189extern void perf_events_lapic_init(void); 189extern void perf_events_lapic_init(void);
190 190
191#define PERF_EVENT_INDEX_OFFSET 0
192
193/* 191/*
194 * Abuse bit 3 of the cpu eflags register to indicate proper PEBS IP fixups. 192 * Abuse bit 3 of the cpu eflags register to indicate proper PEBS IP fixups.
195 * This flag is otherwise unused and ABI specified to be 0, so nobody should 193 * This flag is otherwise unused and ABI specified to be 0, so nobody should
diff --git a/arch/x86/include/asm/timer.h b/arch/x86/include/asm/timer.h
index 431793e5d484..34baa0eb5d0c 100644
--- a/arch/x86/include/asm/timer.h
+++ b/arch/x86/include/asm/timer.h
@@ -57,14 +57,10 @@ DECLARE_PER_CPU(unsigned long long, cyc2ns_offset);
57 57
58static inline unsigned long long __cycles_2_ns(unsigned long long cyc) 58static inline unsigned long long __cycles_2_ns(unsigned long long cyc)
59{ 59{
60 unsigned long long quot;
61 unsigned long long rem;
62 int cpu = smp_processor_id(); 60 int cpu = smp_processor_id();
63 unsigned long long ns = per_cpu(cyc2ns_offset, cpu); 61 unsigned long long ns = per_cpu(cyc2ns_offset, cpu);
64 quot = (cyc >> CYC2NS_SCALE_FACTOR); 62 ns += mult_frac(cyc, per_cpu(cyc2ns, cpu),
65 rem = cyc & ((1ULL << CYC2NS_SCALE_FACTOR) - 1); 63 (1UL << CYC2NS_SCALE_FACTOR));
66 ns += quot * per_cpu(cyc2ns, cpu) +
67 ((rem * per_cpu(cyc2ns, cpu)) >> CYC2NS_SCALE_FACTOR);
68 return ns; 64 return ns;
69} 65}
70 66
diff --git a/arch/x86/kernel/Makefile b/arch/x86/kernel/Makefile
index 5369059c07a9..532d2e090e6f 100644
--- a/arch/x86/kernel/Makefile
+++ b/arch/x86/kernel/Makefile
@@ -69,6 +69,7 @@ obj-$(CONFIG_KEXEC) += machine_kexec_$(BITS).o
69obj-$(CONFIG_KEXEC) += relocate_kernel_$(BITS).o crash.o 69obj-$(CONFIG_KEXEC) += relocate_kernel_$(BITS).o crash.o
70obj-$(CONFIG_CRASH_DUMP) += crash_dump_$(BITS).o 70obj-$(CONFIG_CRASH_DUMP) += crash_dump_$(BITS).o
71obj-$(CONFIG_KPROBES) += kprobes.o 71obj-$(CONFIG_KPROBES) += kprobes.o
72obj-$(CONFIG_OPTPROBES) += kprobes-opt.o
72obj-$(CONFIG_MODULES) += module.o 73obj-$(CONFIG_MODULES) += module.o
73obj-$(CONFIG_DOUBLEFAULT) += doublefault_32.o 74obj-$(CONFIG_DOUBLEFAULT) += doublefault_32.o
74obj-$(CONFIG_KGDB) += kgdb.o 75obj-$(CONFIG_KGDB) += kgdb.o
diff --git a/arch/x86/kernel/cpu/amd.c b/arch/x86/kernel/cpu/amd.c
index f4773f4aae35..0a44b90602b0 100644
--- a/arch/x86/kernel/cpu/amd.c
+++ b/arch/x86/kernel/cpu/amd.c
@@ -5,6 +5,7 @@
5#include <linux/mm.h> 5#include <linux/mm.h>
6 6
7#include <linux/io.h> 7#include <linux/io.h>
8#include <linux/sched.h>
8#include <asm/processor.h> 9#include <asm/processor.h>
9#include <asm/apic.h> 10#include <asm/apic.h>
10#include <asm/cpu.h> 11#include <asm/cpu.h>
@@ -456,6 +457,8 @@ static void __cpuinit early_init_amd(struct cpuinfo_x86 *c)
456 if (c->x86_power & (1 << 8)) { 457 if (c->x86_power & (1 << 8)) {
457 set_cpu_cap(c, X86_FEATURE_CONSTANT_TSC); 458 set_cpu_cap(c, X86_FEATURE_CONSTANT_TSC);
458 set_cpu_cap(c, X86_FEATURE_NONSTOP_TSC); 459 set_cpu_cap(c, X86_FEATURE_NONSTOP_TSC);
460 if (!check_tsc_unstable())
461 sched_clock_stable = 1;
459 } 462 }
460 463
461#ifdef CONFIG_X86_64 464#ifdef CONFIG_X86_64
diff --git a/arch/x86/kernel/cpu/perf_event.c b/arch/x86/kernel/cpu/perf_event.c
index 5adce1040b11..4ef8104958ee 100644
--- a/arch/x86/kernel/cpu/perf_event.c
+++ b/arch/x86/kernel/cpu/perf_event.c
@@ -24,6 +24,7 @@
24#include <linux/slab.h> 24#include <linux/slab.h>
25#include <linux/cpu.h> 25#include <linux/cpu.h>
26#include <linux/bitops.h> 26#include <linux/bitops.h>
27#include <linux/device.h>
27 28
28#include <asm/apic.h> 29#include <asm/apic.h>
29#include <asm/stacktrace.h> 30#include <asm/stacktrace.h>
@@ -31,6 +32,7 @@
31#include <asm/compat.h> 32#include <asm/compat.h>
32#include <asm/smp.h> 33#include <asm/smp.h>
33#include <asm/alternative.h> 34#include <asm/alternative.h>
35#include <asm/timer.h>
34 36
35#include "perf_event.h" 37#include "perf_event.h"
36 38
@@ -351,6 +353,36 @@ int x86_setup_perfctr(struct perf_event *event)
351 return 0; 353 return 0;
352} 354}
353 355
356/*
357 * check that branch_sample_type is compatible with
358 * settings needed for precise_ip > 1 which implies
359 * using the LBR to capture ALL taken branches at the
360 * priv levels of the measurement
361 */
362static inline int precise_br_compat(struct perf_event *event)
363{
364 u64 m = event->attr.branch_sample_type;
365 u64 b = 0;
366
367 /* must capture all branches */
368 if (!(m & PERF_SAMPLE_BRANCH_ANY))
369 return 0;
370
371 m &= PERF_SAMPLE_BRANCH_KERNEL | PERF_SAMPLE_BRANCH_USER;
372
373 if (!event->attr.exclude_user)
374 b |= PERF_SAMPLE_BRANCH_USER;
375
376 if (!event->attr.exclude_kernel)
377 b |= PERF_SAMPLE_BRANCH_KERNEL;
378
379 /*
380 * ignore PERF_SAMPLE_BRANCH_HV, not supported on x86
381 */
382
383 return m == b;
384}
385
354int x86_pmu_hw_config(struct perf_event *event) 386int x86_pmu_hw_config(struct perf_event *event)
355{ 387{
356 if (event->attr.precise_ip) { 388 if (event->attr.precise_ip) {
@@ -367,6 +399,36 @@ int x86_pmu_hw_config(struct perf_event *event)
367 399
368 if (event->attr.precise_ip > precise) 400 if (event->attr.precise_ip > precise)
369 return -EOPNOTSUPP; 401 return -EOPNOTSUPP;
402 /*
403 * check that PEBS LBR correction does not conflict with
404 * whatever the user is asking with attr->branch_sample_type
405 */
406 if (event->attr.precise_ip > 1) {
407 u64 *br_type = &event->attr.branch_sample_type;
408
409 if (has_branch_stack(event)) {
410 if (!precise_br_compat(event))
411 return -EOPNOTSUPP;
412
413 /* branch_sample_type is compatible */
414
415 } else {
416 /*
417 * user did not specify branch_sample_type
418 *
419 * For PEBS fixups, we capture all
420 * the branches at the priv level of the
421 * event.
422 */
423 *br_type = PERF_SAMPLE_BRANCH_ANY;
424
425 if (!event->attr.exclude_user)
426 *br_type |= PERF_SAMPLE_BRANCH_USER;
427
428 if (!event->attr.exclude_kernel)
429 *br_type |= PERF_SAMPLE_BRANCH_KERNEL;
430 }
431 }
370 } 432 }
371 433
372 /* 434 /*
@@ -424,6 +486,10 @@ static int __x86_pmu_event_init(struct perf_event *event)
424 /* mark unused */ 486 /* mark unused */
425 event->hw.extra_reg.idx = EXTRA_REG_NONE; 487 event->hw.extra_reg.idx = EXTRA_REG_NONE;
426 488
489 /* mark not used */
490 event->hw.extra_reg.idx = EXTRA_REG_NONE;
491 event->hw.branch_reg.idx = EXTRA_REG_NONE;
492
427 return x86_pmu.hw_config(event); 493 return x86_pmu.hw_config(event);
428} 494}
429 495
@@ -1210,6 +1276,8 @@ x86_pmu_notifier(struct notifier_block *self, unsigned long action, void *hcpu)
1210 break; 1276 break;
1211 1277
1212 case CPU_STARTING: 1278 case CPU_STARTING:
1279 if (x86_pmu.attr_rdpmc)
1280 set_in_cr4(X86_CR4_PCE);
1213 if (x86_pmu.cpu_starting) 1281 if (x86_pmu.cpu_starting)
1214 x86_pmu.cpu_starting(cpu); 1282 x86_pmu.cpu_starting(cpu);
1215 break; 1283 break;
@@ -1246,6 +1314,11 @@ static void __init pmu_check_apic(void)
1246 pr_info("no hardware sampling interrupt available.\n"); 1314 pr_info("no hardware sampling interrupt available.\n");
1247} 1315}
1248 1316
1317static struct attribute_group x86_pmu_format_group = {
1318 .name = "format",
1319 .attrs = NULL,
1320};
1321
1249static int __init init_hw_perf_events(void) 1322static int __init init_hw_perf_events(void)
1250{ 1323{
1251 struct x86_pmu_quirk *quirk; 1324 struct x86_pmu_quirk *quirk;
@@ -1319,6 +1392,9 @@ static int __init init_hw_perf_events(void)
1319 } 1392 }
1320 } 1393 }
1321 1394
1395 x86_pmu.attr_rdpmc = 1; /* enable userspace RDPMC usage by default */
1396 x86_pmu_format_group.attrs = x86_pmu.format_attrs;
1397
1322 pr_info("... version: %d\n", x86_pmu.version); 1398 pr_info("... version: %d\n", x86_pmu.version);
1323 pr_info("... bit width: %d\n", x86_pmu.cntval_bits); 1399 pr_info("... bit width: %d\n", x86_pmu.cntval_bits);
1324 pr_info("... generic registers: %d\n", x86_pmu.num_counters); 1400 pr_info("... generic registers: %d\n", x86_pmu.num_counters);
@@ -1542,23 +1618,115 @@ static int x86_pmu_event_init(struct perf_event *event)
1542 return err; 1618 return err;
1543} 1619}
1544 1620
1621static int x86_pmu_event_idx(struct perf_event *event)
1622{
1623 int idx = event->hw.idx;
1624
1625 if (!x86_pmu.attr_rdpmc)
1626 return 0;
1627
1628 if (x86_pmu.num_counters_fixed && idx >= X86_PMC_IDX_FIXED) {
1629 idx -= X86_PMC_IDX_FIXED;
1630 idx |= 1 << 30;
1631 }
1632
1633 return idx + 1;
1634}
1635
1636static ssize_t get_attr_rdpmc(struct device *cdev,
1637 struct device_attribute *attr,
1638 char *buf)
1639{
1640 return snprintf(buf, 40, "%d\n", x86_pmu.attr_rdpmc);
1641}
1642
1643static void change_rdpmc(void *info)
1644{
1645 bool enable = !!(unsigned long)info;
1646
1647 if (enable)
1648 set_in_cr4(X86_CR4_PCE);
1649 else
1650 clear_in_cr4(X86_CR4_PCE);
1651}
1652
1653static ssize_t set_attr_rdpmc(struct device *cdev,
1654 struct device_attribute *attr,
1655 const char *buf, size_t count)
1656{
1657 unsigned long val = simple_strtoul(buf, NULL, 0);
1658
1659 if (!!val != !!x86_pmu.attr_rdpmc) {
1660 x86_pmu.attr_rdpmc = !!val;
1661 smp_call_function(change_rdpmc, (void *)val, 1);
1662 }
1663
1664 return count;
1665}
1666
1667static DEVICE_ATTR(rdpmc, S_IRUSR | S_IWUSR, get_attr_rdpmc, set_attr_rdpmc);
1668
1669static struct attribute *x86_pmu_attrs[] = {
1670 &dev_attr_rdpmc.attr,
1671 NULL,
1672};
1673
1674static struct attribute_group x86_pmu_attr_group = {
1675 .attrs = x86_pmu_attrs,
1676};
1677
1678static const struct attribute_group *x86_pmu_attr_groups[] = {
1679 &x86_pmu_attr_group,
1680 &x86_pmu_format_group,
1681 NULL,
1682};
1683
1684static void x86_pmu_flush_branch_stack(void)
1685{
1686 if (x86_pmu.flush_branch_stack)
1687 x86_pmu.flush_branch_stack();
1688}
1689
1545static struct pmu pmu = { 1690static struct pmu pmu = {
1546 .pmu_enable = x86_pmu_enable, 1691 .pmu_enable = x86_pmu_enable,
1547 .pmu_disable = x86_pmu_disable, 1692 .pmu_disable = x86_pmu_disable,
1693
1694 .attr_groups = x86_pmu_attr_groups,
1548 1695
1549 .event_init = x86_pmu_event_init, 1696 .event_init = x86_pmu_event_init,
1550 1697
1551 .add = x86_pmu_add, 1698 .add = x86_pmu_add,
1552 .del = x86_pmu_del, 1699 .del = x86_pmu_del,
1553 .start = x86_pmu_start, 1700 .start = x86_pmu_start,
1554 .stop = x86_pmu_stop, 1701 .stop = x86_pmu_stop,
1555 .read = x86_pmu_read, 1702 .read = x86_pmu_read,
1556 1703
1557 .start_txn = x86_pmu_start_txn, 1704 .start_txn = x86_pmu_start_txn,
1558 .cancel_txn = x86_pmu_cancel_txn, 1705 .cancel_txn = x86_pmu_cancel_txn,
1559 .commit_txn = x86_pmu_commit_txn, 1706 .commit_txn = x86_pmu_commit_txn,
1707
1708 .event_idx = x86_pmu_event_idx,
1709 .flush_branch_stack = x86_pmu_flush_branch_stack,
1560}; 1710};
1561 1711
1712void arch_perf_update_userpage(struct perf_event_mmap_page *userpg, u64 now)
1713{
1714 userpg->cap_usr_time = 0;
1715 userpg->cap_usr_rdpmc = x86_pmu.attr_rdpmc;
1716 userpg->pmc_width = x86_pmu.cntval_bits;
1717
1718 if (!boot_cpu_has(X86_FEATURE_CONSTANT_TSC))
1719 return;
1720
1721 if (!boot_cpu_has(X86_FEATURE_NONSTOP_TSC))
1722 return;
1723
1724 userpg->cap_usr_time = 1;
1725 userpg->time_mult = this_cpu_read(cyc2ns);
1726 userpg->time_shift = CYC2NS_SCALE_FACTOR;
1727 userpg->time_offset = this_cpu_read(cyc2ns_offset) - now;
1728}
1729
1562/* 1730/*
1563 * callchain support 1731 * callchain support
1564 */ 1732 */
diff --git a/arch/x86/kernel/cpu/perf_event.h b/arch/x86/kernel/cpu/perf_event.h
index c30c807ddc72..6638aaf54493 100644
--- a/arch/x86/kernel/cpu/perf_event.h
+++ b/arch/x86/kernel/cpu/perf_event.h
@@ -33,6 +33,7 @@ enum extra_reg_type {
33 33
34 EXTRA_REG_RSP_0 = 0, /* offcore_response_0 */ 34 EXTRA_REG_RSP_0 = 0, /* offcore_response_0 */
35 EXTRA_REG_RSP_1 = 1, /* offcore_response_1 */ 35 EXTRA_REG_RSP_1 = 1, /* offcore_response_1 */
36 EXTRA_REG_LBR = 2, /* lbr_select */
36 37
37 EXTRA_REG_MAX /* number of entries needed */ 38 EXTRA_REG_MAX /* number of entries needed */
38}; 39};
@@ -130,6 +131,8 @@ struct cpu_hw_events {
130 void *lbr_context; 131 void *lbr_context;
131 struct perf_branch_stack lbr_stack; 132 struct perf_branch_stack lbr_stack;
132 struct perf_branch_entry lbr_entries[MAX_LBR_ENTRIES]; 133 struct perf_branch_entry lbr_entries[MAX_LBR_ENTRIES];
134 struct er_account *lbr_sel;
135 u64 br_sel;
133 136
134 /* 137 /*
135 * Intel host/guest exclude bits 138 * Intel host/guest exclude bits
@@ -268,6 +271,29 @@ struct x86_pmu_quirk {
268 void (*func)(void); 271 void (*func)(void);
269}; 272};
270 273
274union x86_pmu_config {
275 struct {
276 u64 event:8,
277 umask:8,
278 usr:1,
279 os:1,
280 edge:1,
281 pc:1,
282 interrupt:1,
283 __reserved1:1,
284 en:1,
285 inv:1,
286 cmask:8,
287 event2:4,
288 __reserved2:4,
289 go:1,
290 ho:1;
291 } bits;
292 u64 value;
293};
294
295#define X86_CONFIG(args...) ((union x86_pmu_config){.bits = {args}}).value
296
271/* 297/*
272 * struct x86_pmu - generic x86 pmu 298 * struct x86_pmu - generic x86 pmu
273 */ 299 */
@@ -309,10 +335,20 @@ struct x86_pmu {
309 struct x86_pmu_quirk *quirks; 335 struct x86_pmu_quirk *quirks;
310 int perfctr_second_write; 336 int perfctr_second_write;
311 337
338 /*
339 * sysfs attrs
340 */
341 int attr_rdpmc;
342 struct attribute **format_attrs;
343
344 /*
345 * CPU Hotplug hooks
346 */
312 int (*cpu_prepare)(int cpu); 347 int (*cpu_prepare)(int cpu);
313 void (*cpu_starting)(int cpu); 348 void (*cpu_starting)(int cpu);
314 void (*cpu_dying)(int cpu); 349 void (*cpu_dying)(int cpu);
315 void (*cpu_dead)(int cpu); 350 void (*cpu_dead)(int cpu);
351 void (*flush_branch_stack)(void);
316 352
317 /* 353 /*
318 * Intel Arch Perfmon v2+ 354 * Intel Arch Perfmon v2+
@@ -334,6 +370,8 @@ struct x86_pmu {
334 */ 370 */
335 unsigned long lbr_tos, lbr_from, lbr_to; /* MSR base regs */ 371 unsigned long lbr_tos, lbr_from, lbr_to; /* MSR base regs */
336 int lbr_nr; /* hardware stack size */ 372 int lbr_nr; /* hardware stack size */
373 u64 lbr_sel_mask; /* LBR_SELECT valid bits */
374 const int *lbr_sel_map; /* lbr_select mappings */
337 375
338 /* 376 /*
339 * Extra registers for events 377 * Extra registers for events
@@ -447,6 +485,15 @@ extern struct event_constraint emptyconstraint;
447 485
448extern struct event_constraint unconstrained; 486extern struct event_constraint unconstrained;
449 487
488static inline bool kernel_ip(unsigned long ip)
489{
490#ifdef CONFIG_X86_32
491 return ip > PAGE_OFFSET;
492#else
493 return (long)ip < 0;
494#endif
495}
496
450#ifdef CONFIG_CPU_SUP_AMD 497#ifdef CONFIG_CPU_SUP_AMD
451 498
452int amd_pmu_init(void); 499int amd_pmu_init(void);
@@ -527,6 +574,10 @@ void intel_pmu_lbr_init_nhm(void);
527 574
528void intel_pmu_lbr_init_atom(void); 575void intel_pmu_lbr_init_atom(void);
529 576
577void intel_pmu_lbr_init_snb(void);
578
579int intel_pmu_setup_lbr_filter(struct perf_event *event);
580
530int p4_pmu_init(void); 581int p4_pmu_init(void);
531 582
532int p6_pmu_init(void); 583int p6_pmu_init(void);
diff --git a/arch/x86/kernel/cpu/perf_event_amd.c b/arch/x86/kernel/cpu/perf_event_amd.c
index 67250a52430b..95e7fe1c5f0b 100644
--- a/arch/x86/kernel/cpu/perf_event_amd.c
+++ b/arch/x86/kernel/cpu/perf_event_amd.c
@@ -139,6 +139,9 @@ static int amd_pmu_hw_config(struct perf_event *event)
139 if (ret) 139 if (ret)
140 return ret; 140 return ret;
141 141
142 if (has_branch_stack(event))
143 return -EOPNOTSUPP;
144
142 if (event->attr.exclude_host && event->attr.exclude_guest) 145 if (event->attr.exclude_host && event->attr.exclude_guest)
143 /* 146 /*
144 * When HO == GO == 1 the hardware treats that as GO == HO == 0 147 * When HO == GO == 1 the hardware treats that as GO == HO == 0
@@ -401,6 +404,21 @@ static void amd_pmu_cpu_dead(int cpu)
401 } 404 }
402} 405}
403 406
407PMU_FORMAT_ATTR(event, "config:0-7,32-35");
408PMU_FORMAT_ATTR(umask, "config:8-15" );
409PMU_FORMAT_ATTR(edge, "config:18" );
410PMU_FORMAT_ATTR(inv, "config:23" );
411PMU_FORMAT_ATTR(cmask, "config:24-31" );
412
413static struct attribute *amd_format_attr[] = {
414 &format_attr_event.attr,
415 &format_attr_umask.attr,
416 &format_attr_edge.attr,
417 &format_attr_inv.attr,
418 &format_attr_cmask.attr,
419 NULL,
420};
421
404static __initconst const struct x86_pmu amd_pmu = { 422static __initconst const struct x86_pmu amd_pmu = {
405 .name = "AMD", 423 .name = "AMD",
406 .handle_irq = x86_pmu_handle_irq, 424 .handle_irq = x86_pmu_handle_irq,
@@ -423,6 +441,8 @@ static __initconst const struct x86_pmu amd_pmu = {
423 .get_event_constraints = amd_get_event_constraints, 441 .get_event_constraints = amd_get_event_constraints,
424 .put_event_constraints = amd_put_event_constraints, 442 .put_event_constraints = amd_put_event_constraints,
425 443
444 .format_attrs = amd_format_attr,
445
426 .cpu_prepare = amd_pmu_cpu_prepare, 446 .cpu_prepare = amd_pmu_cpu_prepare,
427 .cpu_starting = amd_pmu_cpu_starting, 447 .cpu_starting = amd_pmu_cpu_starting,
428 .cpu_dead = amd_pmu_cpu_dead, 448 .cpu_dead = amd_pmu_cpu_dead,
@@ -593,6 +613,7 @@ static __initconst const struct x86_pmu amd_pmu_f15h = {
593 .cpu_dead = amd_pmu_cpu_dead, 613 .cpu_dead = amd_pmu_cpu_dead,
594#endif 614#endif
595 .cpu_starting = amd_pmu_cpu_starting, 615 .cpu_starting = amd_pmu_cpu_starting,
616 .format_attrs = amd_format_attr,
596}; 617};
597 618
598__init int amd_pmu_init(void) 619__init int amd_pmu_init(void)
diff --git a/arch/x86/kernel/cpu/perf_event_intel.c b/arch/x86/kernel/cpu/perf_event_intel.c
index 61d4f79a550e..26b3e2fef104 100644
--- a/arch/x86/kernel/cpu/perf_event_intel.c
+++ b/arch/x86/kernel/cpu/perf_event_intel.c
@@ -728,6 +728,19 @@ static __initconst const u64 atom_hw_cache_event_ids
728 }, 728 },
729}; 729};
730 730
731static inline bool intel_pmu_needs_lbr_smpl(struct perf_event *event)
732{
733 /* user explicitly requested branch sampling */
734 if (has_branch_stack(event))
735 return true;
736
737 /* implicit branch sampling to correct PEBS skid */
738 if (x86_pmu.intel_cap.pebs_trap && event->attr.precise_ip > 1)
739 return true;
740
741 return false;
742}
743
731static void intel_pmu_disable_all(void) 744static void intel_pmu_disable_all(void)
732{ 745{
733 struct cpu_hw_events *cpuc = &__get_cpu_var(cpu_hw_events); 746 struct cpu_hw_events *cpuc = &__get_cpu_var(cpu_hw_events);
@@ -882,6 +895,13 @@ static void intel_pmu_disable_event(struct perf_event *event)
882 cpuc->intel_ctrl_guest_mask &= ~(1ull << hwc->idx); 895 cpuc->intel_ctrl_guest_mask &= ~(1ull << hwc->idx);
883 cpuc->intel_ctrl_host_mask &= ~(1ull << hwc->idx); 896 cpuc->intel_ctrl_host_mask &= ~(1ull << hwc->idx);
884 897
898 /*
899 * must disable before any actual event
900 * because any event may be combined with LBR
901 */
902 if (intel_pmu_needs_lbr_smpl(event))
903 intel_pmu_lbr_disable(event);
904
885 if (unlikely(hwc->config_base == MSR_ARCH_PERFMON_FIXED_CTR_CTRL)) { 905 if (unlikely(hwc->config_base == MSR_ARCH_PERFMON_FIXED_CTR_CTRL)) {
886 intel_pmu_disable_fixed(hwc); 906 intel_pmu_disable_fixed(hwc);
887 return; 907 return;
@@ -936,6 +956,12 @@ static void intel_pmu_enable_event(struct perf_event *event)
936 intel_pmu_enable_bts(hwc->config); 956 intel_pmu_enable_bts(hwc->config);
937 return; 957 return;
938 } 958 }
959 /*
960 * must enabled before any actual event
961 * because any event may be combined with LBR
962 */
963 if (intel_pmu_needs_lbr_smpl(event))
964 intel_pmu_lbr_enable(event);
939 965
940 if (event->attr.exclude_host) 966 if (event->attr.exclude_host)
941 cpuc->intel_ctrl_guest_mask |= (1ull << hwc->idx); 967 cpuc->intel_ctrl_guest_mask |= (1ull << hwc->idx);
@@ -1058,6 +1084,9 @@ again:
1058 1084
1059 data.period = event->hw.last_period; 1085 data.period = event->hw.last_period;
1060 1086
1087 if (has_branch_stack(event))
1088 data.br_stack = &cpuc->lbr_stack;
1089
1061 if (perf_event_overflow(event, &data, regs)) 1090 if (perf_event_overflow(event, &data, regs))
1062 x86_pmu_stop(event, 0); 1091 x86_pmu_stop(event, 0);
1063 } 1092 }
@@ -1124,17 +1153,17 @@ static bool intel_try_alt_er(struct perf_event *event, int orig_idx)
1124 */ 1153 */
1125static struct event_constraint * 1154static struct event_constraint *
1126__intel_shared_reg_get_constraints(struct cpu_hw_events *cpuc, 1155__intel_shared_reg_get_constraints(struct cpu_hw_events *cpuc,
1127 struct perf_event *event) 1156 struct perf_event *event,
1157 struct hw_perf_event_extra *reg)
1128{ 1158{
1129 struct event_constraint *c = &emptyconstraint; 1159 struct event_constraint *c = &emptyconstraint;
1130 struct hw_perf_event_extra *reg = &event->hw.extra_reg;
1131 struct er_account *era; 1160 struct er_account *era;
1132 unsigned long flags; 1161 unsigned long flags;
1133 int orig_idx = reg->idx; 1162 int orig_idx = reg->idx;
1134 1163
1135 /* already allocated shared msr */ 1164 /* already allocated shared msr */
1136 if (reg->alloc) 1165 if (reg->alloc)
1137 return &unconstrained; 1166 return NULL; /* call x86_get_event_constraint() */
1138 1167
1139again: 1168again:
1140 era = &cpuc->shared_regs->regs[reg->idx]; 1169 era = &cpuc->shared_regs->regs[reg->idx];
@@ -1157,14 +1186,10 @@ again:
1157 reg->alloc = 1; 1186 reg->alloc = 1;
1158 1187
1159 /* 1188 /*
1160 * All events using extra_reg are unconstrained. 1189 * need to call x86_get_event_constraint()
1161 * Avoids calling x86_get_event_constraints() 1190 * to check if associated event has constraints
1162 *
1163 * Must revisit if extra_reg controlling events
1164 * ever have constraints. Worst case we go through
1165 * the regular event constraint table.
1166 */ 1191 */
1167 c = &unconstrained; 1192 c = NULL;
1168 } else if (intel_try_alt_er(event, orig_idx)) { 1193 } else if (intel_try_alt_er(event, orig_idx)) {
1169 raw_spin_unlock_irqrestore(&era->lock, flags); 1194 raw_spin_unlock_irqrestore(&era->lock, flags);
1170 goto again; 1195 goto again;
@@ -1201,11 +1226,23 @@ static struct event_constraint *
1201intel_shared_regs_constraints(struct cpu_hw_events *cpuc, 1226intel_shared_regs_constraints(struct cpu_hw_events *cpuc,
1202 struct perf_event *event) 1227 struct perf_event *event)
1203{ 1228{
1204 struct event_constraint *c = NULL; 1229 struct event_constraint *c = NULL, *d;
1205 1230 struct hw_perf_event_extra *xreg, *breg;
1206 if (event->hw.extra_reg.idx != EXTRA_REG_NONE) 1231
1207 c = __intel_shared_reg_get_constraints(cpuc, event); 1232 xreg = &event->hw.extra_reg;
1208 1233 if (xreg->idx != EXTRA_REG_NONE) {
1234 c = __intel_shared_reg_get_constraints(cpuc, event, xreg);
1235 if (c == &emptyconstraint)
1236 return c;
1237 }
1238 breg = &event->hw.branch_reg;
1239 if (breg->idx != EXTRA_REG_NONE) {
1240 d = __intel_shared_reg_get_constraints(cpuc, event, breg);
1241 if (d == &emptyconstraint) {
1242 __intel_shared_reg_put_constraints(cpuc, xreg);
1243 c = d;
1244 }
1245 }
1209 return c; 1246 return c;
1210} 1247}
1211 1248
@@ -1253,6 +1290,10 @@ intel_put_shared_regs_event_constraints(struct cpu_hw_events *cpuc,
1253 reg = &event->hw.extra_reg; 1290 reg = &event->hw.extra_reg;
1254 if (reg->idx != EXTRA_REG_NONE) 1291 if (reg->idx != EXTRA_REG_NONE)
1255 __intel_shared_reg_put_constraints(cpuc, reg); 1292 __intel_shared_reg_put_constraints(cpuc, reg);
1293
1294 reg = &event->hw.branch_reg;
1295 if (reg->idx != EXTRA_REG_NONE)
1296 __intel_shared_reg_put_constraints(cpuc, reg);
1256} 1297}
1257 1298
1258static void intel_put_event_constraints(struct cpu_hw_events *cpuc, 1299static void intel_put_event_constraints(struct cpu_hw_events *cpuc,
@@ -1288,12 +1329,19 @@ static int intel_pmu_hw_config(struct perf_event *event)
1288 * 1329 *
1289 * Thereby we gain a PEBS capable cycle counter. 1330 * Thereby we gain a PEBS capable cycle counter.
1290 */ 1331 */
1291 u64 alt_config = 0x108000c0; /* INST_RETIRED.TOTAL_CYCLES */ 1332 u64 alt_config = X86_CONFIG(.event=0xc0, .inv=1, .cmask=16);
1333
1292 1334
1293 alt_config |= (event->hw.config & ~X86_RAW_EVENT_MASK); 1335 alt_config |= (event->hw.config & ~X86_RAW_EVENT_MASK);
1294 event->hw.config = alt_config; 1336 event->hw.config = alt_config;
1295 } 1337 }
1296 1338
1339 if (intel_pmu_needs_lbr_smpl(event)) {
1340 ret = intel_pmu_setup_lbr_filter(event);
1341 if (ret)
1342 return ret;
1343 }
1344
1297 if (event->attr.type != PERF_TYPE_RAW) 1345 if (event->attr.type != PERF_TYPE_RAW)
1298 return 0; 1346 return 0;
1299 1347
@@ -1383,6 +1431,24 @@ static void core_pmu_enable_all(int added)
1383 } 1431 }
1384} 1432}
1385 1433
1434PMU_FORMAT_ATTR(event, "config:0-7" );
1435PMU_FORMAT_ATTR(umask, "config:8-15" );
1436PMU_FORMAT_ATTR(edge, "config:18" );
1437PMU_FORMAT_ATTR(pc, "config:19" );
1438PMU_FORMAT_ATTR(any, "config:21" ); /* v3 + */
1439PMU_FORMAT_ATTR(inv, "config:23" );
1440PMU_FORMAT_ATTR(cmask, "config:24-31" );
1441
1442static struct attribute *intel_arch_formats_attr[] = {
1443 &format_attr_event.attr,
1444 &format_attr_umask.attr,
1445 &format_attr_edge.attr,
1446 &format_attr_pc.attr,
1447 &format_attr_inv.attr,
1448 &format_attr_cmask.attr,
1449 NULL,
1450};
1451
1386static __initconst const struct x86_pmu core_pmu = { 1452static __initconst const struct x86_pmu core_pmu = {
1387 .name = "core", 1453 .name = "core",
1388 .handle_irq = x86_pmu_handle_irq, 1454 .handle_irq = x86_pmu_handle_irq,
@@ -1407,6 +1473,7 @@ static __initconst const struct x86_pmu core_pmu = {
1407 .put_event_constraints = intel_put_event_constraints, 1473 .put_event_constraints = intel_put_event_constraints,
1408 .event_constraints = intel_core_event_constraints, 1474 .event_constraints = intel_core_event_constraints,
1409 .guest_get_msrs = core_guest_get_msrs, 1475 .guest_get_msrs = core_guest_get_msrs,
1476 .format_attrs = intel_arch_formats_attr,
1410}; 1477};
1411 1478
1412struct intel_shared_regs *allocate_shared_regs(int cpu) 1479struct intel_shared_regs *allocate_shared_regs(int cpu)
@@ -1432,7 +1499,7 @@ static int intel_pmu_cpu_prepare(int cpu)
1432{ 1499{
1433 struct cpu_hw_events *cpuc = &per_cpu(cpu_hw_events, cpu); 1500 struct cpu_hw_events *cpuc = &per_cpu(cpu_hw_events, cpu);
1434 1501
1435 if (!x86_pmu.extra_regs) 1502 if (!(x86_pmu.extra_regs || x86_pmu.lbr_sel_map))
1436 return NOTIFY_OK; 1503 return NOTIFY_OK;
1437 1504
1438 cpuc->shared_regs = allocate_shared_regs(cpu); 1505 cpuc->shared_regs = allocate_shared_regs(cpu);
@@ -1454,22 +1521,28 @@ static void intel_pmu_cpu_starting(int cpu)
1454 */ 1521 */
1455 intel_pmu_lbr_reset(); 1522 intel_pmu_lbr_reset();
1456 1523
1457 if (!cpuc->shared_regs || (x86_pmu.er_flags & ERF_NO_HT_SHARING)) 1524 cpuc->lbr_sel = NULL;
1525
1526 if (!cpuc->shared_regs)
1458 return; 1527 return;
1459 1528
1460 for_each_cpu(i, topology_thread_cpumask(cpu)) { 1529 if (!(x86_pmu.er_flags & ERF_NO_HT_SHARING)) {
1461 struct intel_shared_regs *pc; 1530 for_each_cpu(i, topology_thread_cpumask(cpu)) {
1531 struct intel_shared_regs *pc;
1462 1532
1463 pc = per_cpu(cpu_hw_events, i).shared_regs; 1533 pc = per_cpu(cpu_hw_events, i).shared_regs;
1464 if (pc && pc->core_id == core_id) { 1534 if (pc && pc->core_id == core_id) {
1465 cpuc->kfree_on_online = cpuc->shared_regs; 1535 cpuc->kfree_on_online = cpuc->shared_regs;
1466 cpuc->shared_regs = pc; 1536 cpuc->shared_regs = pc;
1467 break; 1537 break;
1538 }
1468 } 1539 }
1540 cpuc->shared_regs->core_id = core_id;
1541 cpuc->shared_regs->refcnt++;
1469 } 1542 }
1470 1543
1471 cpuc->shared_regs->core_id = core_id; 1544 if (x86_pmu.lbr_sel_map)
1472 cpuc->shared_regs->refcnt++; 1545 cpuc->lbr_sel = &cpuc->shared_regs->regs[EXTRA_REG_LBR];
1473} 1546}
1474 1547
1475static void intel_pmu_cpu_dying(int cpu) 1548static void intel_pmu_cpu_dying(int cpu)
@@ -1487,6 +1560,33 @@ static void intel_pmu_cpu_dying(int cpu)
1487 fini_debug_store_on_cpu(cpu); 1560 fini_debug_store_on_cpu(cpu);
1488} 1561}
1489 1562
1563static void intel_pmu_flush_branch_stack(void)
1564{
1565 /*
1566 * Intel LBR does not tag entries with the
1567 * PID of the current task, then we need to
1568 * flush it on ctxsw
1569 * For now, we simply reset it
1570 */
1571 if (x86_pmu.lbr_nr)
1572 intel_pmu_lbr_reset();
1573}
1574
1575PMU_FORMAT_ATTR(offcore_rsp, "config1:0-63");
1576
1577static struct attribute *intel_arch3_formats_attr[] = {
1578 &format_attr_event.attr,
1579 &format_attr_umask.attr,
1580 &format_attr_edge.attr,
1581 &format_attr_pc.attr,
1582 &format_attr_any.attr,
1583 &format_attr_inv.attr,
1584 &format_attr_cmask.attr,
1585
1586 &format_attr_offcore_rsp.attr, /* XXX do NHM/WSM + SNB breakout */
1587 NULL,
1588};
1589
1490static __initconst const struct x86_pmu intel_pmu = { 1590static __initconst const struct x86_pmu intel_pmu = {
1491 .name = "Intel", 1591 .name = "Intel",
1492 .handle_irq = intel_pmu_handle_irq, 1592 .handle_irq = intel_pmu_handle_irq,
@@ -1510,10 +1610,13 @@ static __initconst const struct x86_pmu intel_pmu = {
1510 .get_event_constraints = intel_get_event_constraints, 1610 .get_event_constraints = intel_get_event_constraints,
1511 .put_event_constraints = intel_put_event_constraints, 1611 .put_event_constraints = intel_put_event_constraints,
1512 1612
1613 .format_attrs = intel_arch3_formats_attr,
1614
1513 .cpu_prepare = intel_pmu_cpu_prepare, 1615 .cpu_prepare = intel_pmu_cpu_prepare,
1514 .cpu_starting = intel_pmu_cpu_starting, 1616 .cpu_starting = intel_pmu_cpu_starting,
1515 .cpu_dying = intel_pmu_cpu_dying, 1617 .cpu_dying = intel_pmu_cpu_dying,
1516 .guest_get_msrs = intel_guest_get_msrs, 1618 .guest_get_msrs = intel_guest_get_msrs,
1619 .flush_branch_stack = intel_pmu_flush_branch_stack,
1517}; 1620};
1518 1621
1519static __init void intel_clovertown_quirk(void) 1622static __init void intel_clovertown_quirk(void)
@@ -1690,9 +1793,11 @@ __init int intel_pmu_init(void)
1690 x86_pmu.extra_regs = intel_nehalem_extra_regs; 1793 x86_pmu.extra_regs = intel_nehalem_extra_regs;
1691 1794
1692 /* UOPS_ISSUED.STALLED_CYCLES */ 1795 /* UOPS_ISSUED.STALLED_CYCLES */
1693 intel_perfmon_event_map[PERF_COUNT_HW_STALLED_CYCLES_FRONTEND] = 0x180010e; 1796 intel_perfmon_event_map[PERF_COUNT_HW_STALLED_CYCLES_FRONTEND] =
1797 X86_CONFIG(.event=0x0e, .umask=0x01, .inv=1, .cmask=1);
1694 /* UOPS_EXECUTED.CORE_ACTIVE_CYCLES,c=1,i=1 */ 1798 /* UOPS_EXECUTED.CORE_ACTIVE_CYCLES,c=1,i=1 */
1695 intel_perfmon_event_map[PERF_COUNT_HW_STALLED_CYCLES_BACKEND] = 0x1803fb1; 1799 intel_perfmon_event_map[PERF_COUNT_HW_STALLED_CYCLES_BACKEND] =
1800 X86_CONFIG(.event=0xb1, .umask=0x3f, .inv=1, .cmask=1);
1696 1801
1697 x86_add_quirk(intel_nehalem_quirk); 1802 x86_add_quirk(intel_nehalem_quirk);
1698 1803
@@ -1727,9 +1832,11 @@ __init int intel_pmu_init(void)
1727 x86_pmu.er_flags |= ERF_HAS_RSP_1; 1832 x86_pmu.er_flags |= ERF_HAS_RSP_1;
1728 1833
1729 /* UOPS_ISSUED.STALLED_CYCLES */ 1834 /* UOPS_ISSUED.STALLED_CYCLES */
1730 intel_perfmon_event_map[PERF_COUNT_HW_STALLED_CYCLES_FRONTEND] = 0x180010e; 1835 intel_perfmon_event_map[PERF_COUNT_HW_STALLED_CYCLES_FRONTEND] =
1836 X86_CONFIG(.event=0x0e, .umask=0x01, .inv=1, .cmask=1);
1731 /* UOPS_EXECUTED.CORE_ACTIVE_CYCLES,c=1,i=1 */ 1837 /* UOPS_EXECUTED.CORE_ACTIVE_CYCLES,c=1,i=1 */
1732 intel_perfmon_event_map[PERF_COUNT_HW_STALLED_CYCLES_BACKEND] = 0x1803fb1; 1838 intel_perfmon_event_map[PERF_COUNT_HW_STALLED_CYCLES_BACKEND] =
1839 X86_CONFIG(.event=0xb1, .umask=0x3f, .inv=1, .cmask=1);
1733 1840
1734 pr_cont("Westmere events, "); 1841 pr_cont("Westmere events, ");
1735 break; 1842 break;
@@ -1740,7 +1847,7 @@ __init int intel_pmu_init(void)
1740 memcpy(hw_cache_event_ids, snb_hw_cache_event_ids, 1847 memcpy(hw_cache_event_ids, snb_hw_cache_event_ids,
1741 sizeof(hw_cache_event_ids)); 1848 sizeof(hw_cache_event_ids));
1742 1849
1743 intel_pmu_lbr_init_nhm(); 1850 intel_pmu_lbr_init_snb();
1744 1851
1745 x86_pmu.event_constraints = intel_snb_event_constraints; 1852 x86_pmu.event_constraints = intel_snb_event_constraints;
1746 x86_pmu.pebs_constraints = intel_snb_pebs_event_constraints; 1853 x86_pmu.pebs_constraints = intel_snb_pebs_event_constraints;
@@ -1750,9 +1857,11 @@ __init int intel_pmu_init(void)
1750 x86_pmu.er_flags |= ERF_NO_HT_SHARING; 1857 x86_pmu.er_flags |= ERF_NO_HT_SHARING;
1751 1858
1752 /* UOPS_ISSUED.ANY,c=1,i=1 to count stall cycles */ 1859 /* UOPS_ISSUED.ANY,c=1,i=1 to count stall cycles */
1753 intel_perfmon_event_map[PERF_COUNT_HW_STALLED_CYCLES_FRONTEND] = 0x180010e; 1860 intel_perfmon_event_map[PERF_COUNT_HW_STALLED_CYCLES_FRONTEND] =
1861 X86_CONFIG(.event=0x0e, .umask=0x01, .inv=1, .cmask=1);
1754 /* UOPS_DISPATCHED.THREAD,c=1,i=1 to count stall cycles*/ 1862 /* UOPS_DISPATCHED.THREAD,c=1,i=1 to count stall cycles*/
1755 intel_perfmon_event_map[PERF_COUNT_HW_STALLED_CYCLES_BACKEND] = 0x18001b1; 1863 intel_perfmon_event_map[PERF_COUNT_HW_STALLED_CYCLES_BACKEND] =
1864 X86_CONFIG(.event=0xb1, .umask=0x01, .inv=1, .cmask=1);
1756 1865
1757 pr_cont("SandyBridge events, "); 1866 pr_cont("SandyBridge events, ");
1758 break; 1867 break;
diff --git a/arch/x86/kernel/cpu/perf_event_intel_ds.c b/arch/x86/kernel/cpu/perf_event_intel_ds.c
index d6bd49faa40c..7f64df19e7dd 100644
--- a/arch/x86/kernel/cpu/perf_event_intel_ds.c
+++ b/arch/x86/kernel/cpu/perf_event_intel_ds.c
@@ -3,6 +3,7 @@
3#include <linux/slab.h> 3#include <linux/slab.h>
4 4
5#include <asm/perf_event.h> 5#include <asm/perf_event.h>
6#include <asm/insn.h>
6 7
7#include "perf_event.h" 8#include "perf_event.h"
8 9
@@ -439,9 +440,6 @@ void intel_pmu_pebs_enable(struct perf_event *event)
439 hwc->config &= ~ARCH_PERFMON_EVENTSEL_INT; 440 hwc->config &= ~ARCH_PERFMON_EVENTSEL_INT;
440 441
441 cpuc->pebs_enabled |= 1ULL << hwc->idx; 442 cpuc->pebs_enabled |= 1ULL << hwc->idx;
442
443 if (x86_pmu.intel_cap.pebs_trap && event->attr.precise_ip > 1)
444 intel_pmu_lbr_enable(event);
445} 443}
446 444
447void intel_pmu_pebs_disable(struct perf_event *event) 445void intel_pmu_pebs_disable(struct perf_event *event)
@@ -454,9 +452,6 @@ void intel_pmu_pebs_disable(struct perf_event *event)
454 wrmsrl(MSR_IA32_PEBS_ENABLE, cpuc->pebs_enabled); 452 wrmsrl(MSR_IA32_PEBS_ENABLE, cpuc->pebs_enabled);
455 453
456 hwc->config |= ARCH_PERFMON_EVENTSEL_INT; 454 hwc->config |= ARCH_PERFMON_EVENTSEL_INT;
457
458 if (x86_pmu.intel_cap.pebs_trap && event->attr.precise_ip > 1)
459 intel_pmu_lbr_disable(event);
460} 455}
461 456
462void intel_pmu_pebs_enable_all(void) 457void intel_pmu_pebs_enable_all(void)
@@ -475,17 +470,6 @@ void intel_pmu_pebs_disable_all(void)
475 wrmsrl(MSR_IA32_PEBS_ENABLE, 0); 470 wrmsrl(MSR_IA32_PEBS_ENABLE, 0);
476} 471}
477 472
478#include <asm/insn.h>
479
480static inline bool kernel_ip(unsigned long ip)
481{
482#ifdef CONFIG_X86_32
483 return ip > PAGE_OFFSET;
484#else
485 return (long)ip < 0;
486#endif
487}
488
489static int intel_pmu_pebs_fixup_ip(struct pt_regs *regs) 473static int intel_pmu_pebs_fixup_ip(struct pt_regs *regs)
490{ 474{
491 struct cpu_hw_events *cpuc = &__get_cpu_var(cpu_hw_events); 475 struct cpu_hw_events *cpuc = &__get_cpu_var(cpu_hw_events);
@@ -572,6 +556,7 @@ static void __intel_pmu_pebs_event(struct perf_event *event,
572 * both formats and we don't use the other fields in this 556 * both formats and we don't use the other fields in this
573 * routine. 557 * routine.
574 */ 558 */
559 struct cpu_hw_events *cpuc = &__get_cpu_var(cpu_hw_events);
575 struct pebs_record_core *pebs = __pebs; 560 struct pebs_record_core *pebs = __pebs;
576 struct perf_sample_data data; 561 struct perf_sample_data data;
577 struct pt_regs regs; 562 struct pt_regs regs;
@@ -602,6 +587,9 @@ static void __intel_pmu_pebs_event(struct perf_event *event,
602 else 587 else
603 regs.flags &= ~PERF_EFLAGS_EXACT; 588 regs.flags &= ~PERF_EFLAGS_EXACT;
604 589
590 if (has_branch_stack(event))
591 data.br_stack = &cpuc->lbr_stack;
592
605 if (perf_event_overflow(event, &data, &regs)) 593 if (perf_event_overflow(event, &data, &regs))
606 x86_pmu_stop(event, 0); 594 x86_pmu_stop(event, 0);
607} 595}
diff --git a/arch/x86/kernel/cpu/perf_event_intel_lbr.c b/arch/x86/kernel/cpu/perf_event_intel_lbr.c
index 47a7e63bfe54..520b4265fcd2 100644
--- a/arch/x86/kernel/cpu/perf_event_intel_lbr.c
+++ b/arch/x86/kernel/cpu/perf_event_intel_lbr.c
@@ -3,6 +3,7 @@
3 3
4#include <asm/perf_event.h> 4#include <asm/perf_event.h>
5#include <asm/msr.h> 5#include <asm/msr.h>
6#include <asm/insn.h>
6 7
7#include "perf_event.h" 8#include "perf_event.h"
8 9
@@ -14,6 +15,100 @@ enum {
14}; 15};
15 16
16/* 17/*
18 * Intel LBR_SELECT bits
19 * Intel Vol3a, April 2011, Section 16.7 Table 16-10
20 *
21 * Hardware branch filter (not available on all CPUs)
22 */
23#define LBR_KERNEL_BIT 0 /* do not capture at ring0 */
24#define LBR_USER_BIT 1 /* do not capture at ring > 0 */
25#define LBR_JCC_BIT 2 /* do not capture conditional branches */
26#define LBR_REL_CALL_BIT 3 /* do not capture relative calls */
27#define LBR_IND_CALL_BIT 4 /* do not capture indirect calls */
28#define LBR_RETURN_BIT 5 /* do not capture near returns */
29#define LBR_IND_JMP_BIT 6 /* do not capture indirect jumps */
30#define LBR_REL_JMP_BIT 7 /* do not capture relative jumps */
31#define LBR_FAR_BIT 8 /* do not capture far branches */
32
33#define LBR_KERNEL (1 << LBR_KERNEL_BIT)
34#define LBR_USER (1 << LBR_USER_BIT)
35#define LBR_JCC (1 << LBR_JCC_BIT)
36#define LBR_REL_CALL (1 << LBR_REL_CALL_BIT)
37#define LBR_IND_CALL (1 << LBR_IND_CALL_BIT)
38#define LBR_RETURN (1 << LBR_RETURN_BIT)
39#define LBR_REL_JMP (1 << LBR_REL_JMP_BIT)
40#define LBR_IND_JMP (1 << LBR_IND_JMP_BIT)
41#define LBR_FAR (1 << LBR_FAR_BIT)
42
43#define LBR_PLM (LBR_KERNEL | LBR_USER)
44
45#define LBR_SEL_MASK 0x1ff /* valid bits in LBR_SELECT */
46#define LBR_NOT_SUPP -1 /* LBR filter not supported */
47#define LBR_IGN 0 /* ignored */
48
49#define LBR_ANY \
50 (LBR_JCC |\
51 LBR_REL_CALL |\
52 LBR_IND_CALL |\
53 LBR_RETURN |\
54 LBR_REL_JMP |\
55 LBR_IND_JMP |\
56 LBR_FAR)
57
58#define LBR_FROM_FLAG_MISPRED (1ULL << 63)
59
60#define for_each_branch_sample_type(x) \
61 for ((x) = PERF_SAMPLE_BRANCH_USER; \
62 (x) < PERF_SAMPLE_BRANCH_MAX; (x) <<= 1)
63
64/*
65 * x86control flow change classification
66 * x86control flow changes include branches, interrupts, traps, faults
67 */
68enum {
69 X86_BR_NONE = 0, /* unknown */
70
71 X86_BR_USER = 1 << 0, /* branch target is user */
72 X86_BR_KERNEL = 1 << 1, /* branch target is kernel */
73
74 X86_BR_CALL = 1 << 2, /* call */
75 X86_BR_RET = 1 << 3, /* return */
76 X86_BR_SYSCALL = 1 << 4, /* syscall */
77 X86_BR_SYSRET = 1 << 5, /* syscall return */
78 X86_BR_INT = 1 << 6, /* sw interrupt */
79 X86_BR_IRET = 1 << 7, /* return from interrupt */
80 X86_BR_JCC = 1 << 8, /* conditional */
81 X86_BR_JMP = 1 << 9, /* jump */
82 X86_BR_IRQ = 1 << 10,/* hw interrupt or trap or fault */
83 X86_BR_IND_CALL = 1 << 11,/* indirect calls */
84};
85
86#define X86_BR_PLM (X86_BR_USER | X86_BR_KERNEL)
87
88#define X86_BR_ANY \
89 (X86_BR_CALL |\
90 X86_BR_RET |\
91 X86_BR_SYSCALL |\
92 X86_BR_SYSRET |\
93 X86_BR_INT |\
94 X86_BR_IRET |\
95 X86_BR_JCC |\
96 X86_BR_JMP |\
97 X86_BR_IRQ |\
98 X86_BR_IND_CALL)
99
100#define X86_BR_ALL (X86_BR_PLM | X86_BR_ANY)
101
102#define X86_BR_ANY_CALL \
103 (X86_BR_CALL |\
104 X86_BR_IND_CALL |\
105 X86_BR_SYSCALL |\
106 X86_BR_IRQ |\
107 X86_BR_INT)
108
109static void intel_pmu_lbr_filter(struct cpu_hw_events *cpuc);
110
111/*
17 * We only support LBR implementations that have FREEZE_LBRS_ON_PMI 112 * We only support LBR implementations that have FREEZE_LBRS_ON_PMI
18 * otherwise it becomes near impossible to get a reliable stack. 113 * otherwise it becomes near impossible to get a reliable stack.
19 */ 114 */
@@ -21,6 +116,10 @@ enum {
21static void __intel_pmu_lbr_enable(void) 116static void __intel_pmu_lbr_enable(void)
22{ 117{
23 u64 debugctl; 118 u64 debugctl;
119 struct cpu_hw_events *cpuc = &__get_cpu_var(cpu_hw_events);
120
121 if (cpuc->lbr_sel)
122 wrmsrl(MSR_LBR_SELECT, cpuc->lbr_sel->config);
24 123
25 rdmsrl(MSR_IA32_DEBUGCTLMSR, debugctl); 124 rdmsrl(MSR_IA32_DEBUGCTLMSR, debugctl);
26 debugctl |= (DEBUGCTLMSR_LBR | DEBUGCTLMSR_FREEZE_LBRS_ON_PMI); 125 debugctl |= (DEBUGCTLMSR_LBR | DEBUGCTLMSR_FREEZE_LBRS_ON_PMI);
@@ -76,11 +175,11 @@ void intel_pmu_lbr_enable(struct perf_event *event)
76 * Reset the LBR stack if we changed task context to 175 * Reset the LBR stack if we changed task context to
77 * avoid data leaks. 176 * avoid data leaks.
78 */ 177 */
79
80 if (event->ctx->task && cpuc->lbr_context != event->ctx) { 178 if (event->ctx->task && cpuc->lbr_context != event->ctx) {
81 intel_pmu_lbr_reset(); 179 intel_pmu_lbr_reset();
82 cpuc->lbr_context = event->ctx; 180 cpuc->lbr_context = event->ctx;
83 } 181 }
182 cpuc->br_sel = event->hw.branch_reg.reg;
84 183
85 cpuc->lbr_users++; 184 cpuc->lbr_users++;
86} 185}
@@ -95,8 +194,11 @@ void intel_pmu_lbr_disable(struct perf_event *event)
95 cpuc->lbr_users--; 194 cpuc->lbr_users--;
96 WARN_ON_ONCE(cpuc->lbr_users < 0); 195 WARN_ON_ONCE(cpuc->lbr_users < 0);
97 196
98 if (cpuc->enabled && !cpuc->lbr_users) 197 if (cpuc->enabled && !cpuc->lbr_users) {
99 __intel_pmu_lbr_disable(); 198 __intel_pmu_lbr_disable();
199 /* avoid stale pointer */
200 cpuc->lbr_context = NULL;
201 }
100} 202}
101 203
102void intel_pmu_lbr_enable_all(void) 204void intel_pmu_lbr_enable_all(void)
@@ -115,6 +217,9 @@ void intel_pmu_lbr_disable_all(void)
115 __intel_pmu_lbr_disable(); 217 __intel_pmu_lbr_disable();
116} 218}
117 219
220/*
221 * TOS = most recently recorded branch
222 */
118static inline u64 intel_pmu_lbr_tos(void) 223static inline u64 intel_pmu_lbr_tos(void)
119{ 224{
120 u64 tos; 225 u64 tos;
@@ -142,15 +247,15 @@ static void intel_pmu_lbr_read_32(struct cpu_hw_events *cpuc)
142 247
143 rdmsrl(x86_pmu.lbr_from + lbr_idx, msr_lastbranch.lbr); 248 rdmsrl(x86_pmu.lbr_from + lbr_idx, msr_lastbranch.lbr);
144 249
145 cpuc->lbr_entries[i].from = msr_lastbranch.from; 250 cpuc->lbr_entries[i].from = msr_lastbranch.from;
146 cpuc->lbr_entries[i].to = msr_lastbranch.to; 251 cpuc->lbr_entries[i].to = msr_lastbranch.to;
147 cpuc->lbr_entries[i].flags = 0; 252 cpuc->lbr_entries[i].mispred = 0;
253 cpuc->lbr_entries[i].predicted = 0;
254 cpuc->lbr_entries[i].reserved = 0;
148 } 255 }
149 cpuc->lbr_stack.nr = i; 256 cpuc->lbr_stack.nr = i;
150} 257}
151 258
152#define LBR_FROM_FLAG_MISPRED (1ULL << 63)
153
154/* 259/*
155 * Due to lack of segmentation in Linux the effective address (offset) 260 * Due to lack of segmentation in Linux the effective address (offset)
156 * is the same as the linear address, allowing us to merge the LIP and EIP 261 * is the same as the linear address, allowing us to merge the LIP and EIP
@@ -165,19 +270,22 @@ static void intel_pmu_lbr_read_64(struct cpu_hw_events *cpuc)
165 270
166 for (i = 0; i < x86_pmu.lbr_nr; i++) { 271 for (i = 0; i < x86_pmu.lbr_nr; i++) {
167 unsigned long lbr_idx = (tos - i) & mask; 272 unsigned long lbr_idx = (tos - i) & mask;
168 u64 from, to, flags = 0; 273 u64 from, to, mis = 0, pred = 0;
169 274
170 rdmsrl(x86_pmu.lbr_from + lbr_idx, from); 275 rdmsrl(x86_pmu.lbr_from + lbr_idx, from);
171 rdmsrl(x86_pmu.lbr_to + lbr_idx, to); 276 rdmsrl(x86_pmu.lbr_to + lbr_idx, to);
172 277
173 if (lbr_format == LBR_FORMAT_EIP_FLAGS) { 278 if (lbr_format == LBR_FORMAT_EIP_FLAGS) {
174 flags = !!(from & LBR_FROM_FLAG_MISPRED); 279 mis = !!(from & LBR_FROM_FLAG_MISPRED);
280 pred = !mis;
175 from = (u64)((((s64)from) << 1) >> 1); 281 from = (u64)((((s64)from) << 1) >> 1);
176 } 282 }
177 283
178 cpuc->lbr_entries[i].from = from; 284 cpuc->lbr_entries[i].from = from;
179 cpuc->lbr_entries[i].to = to; 285 cpuc->lbr_entries[i].to = to;
180 cpuc->lbr_entries[i].flags = flags; 286 cpuc->lbr_entries[i].mispred = mis;
287 cpuc->lbr_entries[i].predicted = pred;
288 cpuc->lbr_entries[i].reserved = 0;
181 } 289 }
182 cpuc->lbr_stack.nr = i; 290 cpuc->lbr_stack.nr = i;
183} 291}
@@ -193,28 +301,404 @@ void intel_pmu_lbr_read(void)
193 intel_pmu_lbr_read_32(cpuc); 301 intel_pmu_lbr_read_32(cpuc);
194 else 302 else
195 intel_pmu_lbr_read_64(cpuc); 303 intel_pmu_lbr_read_64(cpuc);
304
305 intel_pmu_lbr_filter(cpuc);
306}
307
308/*
309 * SW filter is used:
310 * - in case there is no HW filter
311 * - in case the HW filter has errata or limitations
312 */
313static void intel_pmu_setup_sw_lbr_filter(struct perf_event *event)
314{
315 u64 br_type = event->attr.branch_sample_type;
316 int mask = 0;
317
318 if (br_type & PERF_SAMPLE_BRANCH_USER)
319 mask |= X86_BR_USER;
320
321 if (br_type & PERF_SAMPLE_BRANCH_KERNEL)
322 mask |= X86_BR_KERNEL;
323
324 /* we ignore BRANCH_HV here */
325
326 if (br_type & PERF_SAMPLE_BRANCH_ANY)
327 mask |= X86_BR_ANY;
328
329 if (br_type & PERF_SAMPLE_BRANCH_ANY_CALL)
330 mask |= X86_BR_ANY_CALL;
331
332 if (br_type & PERF_SAMPLE_BRANCH_ANY_RETURN)
333 mask |= X86_BR_RET | X86_BR_IRET | X86_BR_SYSRET;
334
335 if (br_type & PERF_SAMPLE_BRANCH_IND_CALL)
336 mask |= X86_BR_IND_CALL;
337 /*
338 * stash actual user request into reg, it may
339 * be used by fixup code for some CPU
340 */
341 event->hw.branch_reg.reg = mask;
342}
343
344/*
345 * setup the HW LBR filter
346 * Used only when available, may not be enough to disambiguate
347 * all branches, may need the help of the SW filter
348 */
349static int intel_pmu_setup_hw_lbr_filter(struct perf_event *event)
350{
351 struct hw_perf_event_extra *reg;
352 u64 br_type = event->attr.branch_sample_type;
353 u64 mask = 0, m;
354 u64 v;
355
356 for_each_branch_sample_type(m) {
357 if (!(br_type & m))
358 continue;
359
360 v = x86_pmu.lbr_sel_map[m];
361 if (v == LBR_NOT_SUPP)
362 return -EOPNOTSUPP;
363
364 if (v != LBR_IGN)
365 mask |= v;
366 }
367 reg = &event->hw.branch_reg;
368 reg->idx = EXTRA_REG_LBR;
369
370 /* LBR_SELECT operates in suppress mode so invert mask */
371 reg->config = ~mask & x86_pmu.lbr_sel_mask;
372
373 return 0;
374}
375
376int intel_pmu_setup_lbr_filter(struct perf_event *event)
377{
378 int ret = 0;
379
380 /*
381 * no LBR on this PMU
382 */
383 if (!x86_pmu.lbr_nr)
384 return -EOPNOTSUPP;
385
386 /*
387 * setup SW LBR filter
388 */
389 intel_pmu_setup_sw_lbr_filter(event);
390
391 /*
392 * setup HW LBR filter, if any
393 */
394 if (x86_pmu.lbr_sel_map)
395 ret = intel_pmu_setup_hw_lbr_filter(event);
396
397 return ret;
196} 398}
197 399
400/*
401 * return the type of control flow change at address "from"
402 * intruction is not necessarily a branch (in case of interrupt).
403 *
404 * The branch type returned also includes the priv level of the
405 * target of the control flow change (X86_BR_USER, X86_BR_KERNEL).
406 *
407 * If a branch type is unknown OR the instruction cannot be
408 * decoded (e.g., text page not present), then X86_BR_NONE is
409 * returned.
410 */
411static int branch_type(unsigned long from, unsigned long to)
412{
413 struct insn insn;
414 void *addr;
415 int bytes, size = MAX_INSN_SIZE;
416 int ret = X86_BR_NONE;
417 int ext, to_plm, from_plm;
418 u8 buf[MAX_INSN_SIZE];
419 int is64 = 0;
420
421 to_plm = kernel_ip(to) ? X86_BR_KERNEL : X86_BR_USER;
422 from_plm = kernel_ip(from) ? X86_BR_KERNEL : X86_BR_USER;
423
424 /*
425 * maybe zero if lbr did not fill up after a reset by the time
426 * we get a PMU interrupt
427 */
428 if (from == 0 || to == 0)
429 return X86_BR_NONE;
430
431 if (from_plm == X86_BR_USER) {
432 /*
433 * can happen if measuring at the user level only
434 * and we interrupt in a kernel thread, e.g., idle.
435 */
436 if (!current->mm)
437 return X86_BR_NONE;
438
439 /* may fail if text not present */
440 bytes = copy_from_user_nmi(buf, (void __user *)from, size);
441 if (bytes != size)
442 return X86_BR_NONE;
443
444 addr = buf;
445 } else
446 addr = (void *)from;
447
448 /*
449 * decoder needs to know the ABI especially
450 * on 64-bit systems running 32-bit apps
451 */
452#ifdef CONFIG_X86_64
453 is64 = kernel_ip((unsigned long)addr) || !test_thread_flag(TIF_IA32);
454#endif
455 insn_init(&insn, addr, is64);
456 insn_get_opcode(&insn);
457
458 switch (insn.opcode.bytes[0]) {
459 case 0xf:
460 switch (insn.opcode.bytes[1]) {
461 case 0x05: /* syscall */
462 case 0x34: /* sysenter */
463 ret = X86_BR_SYSCALL;
464 break;
465 case 0x07: /* sysret */
466 case 0x35: /* sysexit */
467 ret = X86_BR_SYSRET;
468 break;
469 case 0x80 ... 0x8f: /* conditional */
470 ret = X86_BR_JCC;
471 break;
472 default:
473 ret = X86_BR_NONE;
474 }
475 break;
476 case 0x70 ... 0x7f: /* conditional */
477 ret = X86_BR_JCC;
478 break;
479 case 0xc2: /* near ret */
480 case 0xc3: /* near ret */
481 case 0xca: /* far ret */
482 case 0xcb: /* far ret */
483 ret = X86_BR_RET;
484 break;
485 case 0xcf: /* iret */
486 ret = X86_BR_IRET;
487 break;
488 case 0xcc ... 0xce: /* int */
489 ret = X86_BR_INT;
490 break;
491 case 0xe8: /* call near rel */
492 case 0x9a: /* call far absolute */
493 ret = X86_BR_CALL;
494 break;
495 case 0xe0 ... 0xe3: /* loop jmp */
496 ret = X86_BR_JCC;
497 break;
498 case 0xe9 ... 0xeb: /* jmp */
499 ret = X86_BR_JMP;
500 break;
501 case 0xff: /* call near absolute, call far absolute ind */
502 insn_get_modrm(&insn);
503 ext = (insn.modrm.bytes[0] >> 3) & 0x7;
504 switch (ext) {
505 case 2: /* near ind call */
506 case 3: /* far ind call */
507 ret = X86_BR_IND_CALL;
508 break;
509 case 4:
510 case 5:
511 ret = X86_BR_JMP;
512 break;
513 }
514 break;
515 default:
516 ret = X86_BR_NONE;
517 }
518 /*
519 * interrupts, traps, faults (and thus ring transition) may
520 * occur on any instructions. Thus, to classify them correctly,
521 * we need to first look at the from and to priv levels. If they
522 * are different and to is in the kernel, then it indicates
523 * a ring transition. If the from instruction is not a ring
524 * transition instr (syscall, systenter, int), then it means
525 * it was a irq, trap or fault.
526 *
527 * we have no way of detecting kernel to kernel faults.
528 */
529 if (from_plm == X86_BR_USER && to_plm == X86_BR_KERNEL
530 && ret != X86_BR_SYSCALL && ret != X86_BR_INT)
531 ret = X86_BR_IRQ;
532
533 /*
534 * branch priv level determined by target as
535 * is done by HW when LBR_SELECT is implemented
536 */
537 if (ret != X86_BR_NONE)
538 ret |= to_plm;
539
540 return ret;
541}
542
543/*
544 * implement actual branch filter based on user demand.
545 * Hardware may not exactly satisfy that request, thus
546 * we need to inspect opcodes. Mismatched branches are
547 * discarded. Therefore, the number of branches returned
548 * in PERF_SAMPLE_BRANCH_STACK sample may vary.
549 */
550static void
551intel_pmu_lbr_filter(struct cpu_hw_events *cpuc)
552{
553 u64 from, to;
554 int br_sel = cpuc->br_sel;
555 int i, j, type;
556 bool compress = false;
557
558 /* if sampling all branches, then nothing to filter */
559 if ((br_sel & X86_BR_ALL) == X86_BR_ALL)
560 return;
561
562 for (i = 0; i < cpuc->lbr_stack.nr; i++) {
563
564 from = cpuc->lbr_entries[i].from;
565 to = cpuc->lbr_entries[i].to;
566
567 type = branch_type(from, to);
568
569 /* if type does not correspond, then discard */
570 if (type == X86_BR_NONE || (br_sel & type) != type) {
571 cpuc->lbr_entries[i].from = 0;
572 compress = true;
573 }
574 }
575
576 if (!compress)
577 return;
578
579 /* remove all entries with from=0 */
580 for (i = 0; i < cpuc->lbr_stack.nr; ) {
581 if (!cpuc->lbr_entries[i].from) {
582 j = i;
583 while (++j < cpuc->lbr_stack.nr)
584 cpuc->lbr_entries[j-1] = cpuc->lbr_entries[j];
585 cpuc->lbr_stack.nr--;
586 if (!cpuc->lbr_entries[i].from)
587 continue;
588 }
589 i++;
590 }
591}
592
593/*
594 * Map interface branch filters onto LBR filters
595 */
596static const int nhm_lbr_sel_map[PERF_SAMPLE_BRANCH_MAX] = {
597 [PERF_SAMPLE_BRANCH_ANY] = LBR_ANY,
598 [PERF_SAMPLE_BRANCH_USER] = LBR_USER,
599 [PERF_SAMPLE_BRANCH_KERNEL] = LBR_KERNEL,
600 [PERF_SAMPLE_BRANCH_HV] = LBR_IGN,
601 [PERF_SAMPLE_BRANCH_ANY_RETURN] = LBR_RETURN | LBR_REL_JMP
602 | LBR_IND_JMP | LBR_FAR,
603 /*
604 * NHM/WSM erratum: must include REL_JMP+IND_JMP to get CALL branches
605 */
606 [PERF_SAMPLE_BRANCH_ANY_CALL] =
607 LBR_REL_CALL | LBR_IND_CALL | LBR_REL_JMP | LBR_IND_JMP | LBR_FAR,
608 /*
609 * NHM/WSM erratum: must include IND_JMP to capture IND_CALL
610 */
611 [PERF_SAMPLE_BRANCH_IND_CALL] = LBR_IND_CALL | LBR_IND_JMP,
612};
613
614static const int snb_lbr_sel_map[PERF_SAMPLE_BRANCH_MAX] = {
615 [PERF_SAMPLE_BRANCH_ANY] = LBR_ANY,
616 [PERF_SAMPLE_BRANCH_USER] = LBR_USER,
617 [PERF_SAMPLE_BRANCH_KERNEL] = LBR_KERNEL,
618 [PERF_SAMPLE_BRANCH_HV] = LBR_IGN,
619 [PERF_SAMPLE_BRANCH_ANY_RETURN] = LBR_RETURN | LBR_FAR,
620 [PERF_SAMPLE_BRANCH_ANY_CALL] = LBR_REL_CALL | LBR_IND_CALL
621 | LBR_FAR,
622 [PERF_SAMPLE_BRANCH_IND_CALL] = LBR_IND_CALL,
623};
624
625/* core */
198void intel_pmu_lbr_init_core(void) 626void intel_pmu_lbr_init_core(void)
199{ 627{
200 x86_pmu.lbr_nr = 4; 628 x86_pmu.lbr_nr = 4;
201 x86_pmu.lbr_tos = 0x01c9; 629 x86_pmu.lbr_tos = MSR_LBR_TOS;
202 x86_pmu.lbr_from = 0x40; 630 x86_pmu.lbr_from = MSR_LBR_CORE_FROM;
203 x86_pmu.lbr_to = 0x60; 631 x86_pmu.lbr_to = MSR_LBR_CORE_TO;
632
633 /*
634 * SW branch filter usage:
635 * - compensate for lack of HW filter
636 */
637 pr_cont("4-deep LBR, ");
204} 638}
205 639
640/* nehalem/westmere */
206void intel_pmu_lbr_init_nhm(void) 641void intel_pmu_lbr_init_nhm(void)
207{ 642{
208 x86_pmu.lbr_nr = 16; 643 x86_pmu.lbr_nr = 16;
209 x86_pmu.lbr_tos = 0x01c9; 644 x86_pmu.lbr_tos = MSR_LBR_TOS;
210 x86_pmu.lbr_from = 0x680; 645 x86_pmu.lbr_from = MSR_LBR_NHM_FROM;
211 x86_pmu.lbr_to = 0x6c0; 646 x86_pmu.lbr_to = MSR_LBR_NHM_TO;
647
648 x86_pmu.lbr_sel_mask = LBR_SEL_MASK;
649 x86_pmu.lbr_sel_map = nhm_lbr_sel_map;
650
651 /*
652 * SW branch filter usage:
653 * - workaround LBR_SEL errata (see above)
654 * - support syscall, sysret capture.
655 * That requires LBR_FAR but that means far
656 * jmp need to be filtered out
657 */
658 pr_cont("16-deep LBR, ");
659}
660
661/* sandy bridge */
662void intel_pmu_lbr_init_snb(void)
663{
664 x86_pmu.lbr_nr = 16;
665 x86_pmu.lbr_tos = MSR_LBR_TOS;
666 x86_pmu.lbr_from = MSR_LBR_NHM_FROM;
667 x86_pmu.lbr_to = MSR_LBR_NHM_TO;
668
669 x86_pmu.lbr_sel_mask = LBR_SEL_MASK;
670 x86_pmu.lbr_sel_map = snb_lbr_sel_map;
671
672 /*
673 * SW branch filter usage:
674 * - support syscall, sysret capture.
675 * That requires LBR_FAR but that means far
676 * jmp need to be filtered out
677 */
678 pr_cont("16-deep LBR, ");
212} 679}
213 680
681/* atom */
214void intel_pmu_lbr_init_atom(void) 682void intel_pmu_lbr_init_atom(void)
215{ 683{
684 /*
685 * only models starting at stepping 10 seems
686 * to have an operational LBR which can freeze
687 * on PMU interrupt
688 */
689 if (boot_cpu_data.x86_mask < 10) {
690 pr_cont("LBR disabled due to erratum");
691 return;
692 }
693
216 x86_pmu.lbr_nr = 8; 694 x86_pmu.lbr_nr = 8;
217 x86_pmu.lbr_tos = 0x01c9; 695 x86_pmu.lbr_tos = MSR_LBR_TOS;
218 x86_pmu.lbr_from = 0x40; 696 x86_pmu.lbr_from = MSR_LBR_CORE_FROM;
219 x86_pmu.lbr_to = 0x60; 697 x86_pmu.lbr_to = MSR_LBR_CORE_TO;
698
699 /*
700 * SW branch filter usage:
701 * - compensate for lack of HW filter
702 */
703 pr_cont("8-deep LBR, ");
220} 704}
diff --git a/arch/x86/kernel/cpu/perf_event_p6.c b/arch/x86/kernel/cpu/perf_event_p6.c
index c7181befecde..32bcfc7dd230 100644
--- a/arch/x86/kernel/cpu/perf_event_p6.c
+++ b/arch/x86/kernel/cpu/perf_event_p6.c
@@ -87,6 +87,23 @@ static void p6_pmu_enable_event(struct perf_event *event)
87 (void)checking_wrmsrl(hwc->config_base, val); 87 (void)checking_wrmsrl(hwc->config_base, val);
88} 88}
89 89
90PMU_FORMAT_ATTR(event, "config:0-7" );
91PMU_FORMAT_ATTR(umask, "config:8-15" );
92PMU_FORMAT_ATTR(edge, "config:18" );
93PMU_FORMAT_ATTR(pc, "config:19" );
94PMU_FORMAT_ATTR(inv, "config:23" );
95PMU_FORMAT_ATTR(cmask, "config:24-31" );
96
97static struct attribute *intel_p6_formats_attr[] = {
98 &format_attr_event.attr,
99 &format_attr_umask.attr,
100 &format_attr_edge.attr,
101 &format_attr_pc.attr,
102 &format_attr_inv.attr,
103 &format_attr_cmask.attr,
104 NULL,
105};
106
90static __initconst const struct x86_pmu p6_pmu = { 107static __initconst const struct x86_pmu p6_pmu = {
91 .name = "p6", 108 .name = "p6",
92 .handle_irq = x86_pmu_handle_irq, 109 .handle_irq = x86_pmu_handle_irq,
@@ -115,6 +132,8 @@ static __initconst const struct x86_pmu p6_pmu = {
115 .cntval_mask = (1ULL << 32) - 1, 132 .cntval_mask = (1ULL << 32) - 1,
116 .get_event_constraints = x86_get_event_constraints, 133 .get_event_constraints = x86_get_event_constraints,
117 .event_constraints = p6_event_constraints, 134 .event_constraints = p6_event_constraints,
135
136 .format_attrs = intel_p6_formats_attr,
118}; 137};
119 138
120__init int p6_pmu_init(void) 139__init int p6_pmu_init(void)
diff --git a/arch/x86/kernel/irq_32.c b/arch/x86/kernel/irq_32.c
index 40fc86161d92..58b7f27cb3e9 100644
--- a/arch/x86/kernel/irq_32.c
+++ b/arch/x86/kernel/irq_32.c
@@ -100,13 +100,8 @@ execute_on_irq_stack(int overflow, struct irq_desc *desc, int irq)
100 irqctx->tinfo.task = curctx->tinfo.task; 100 irqctx->tinfo.task = curctx->tinfo.task;
101 irqctx->tinfo.previous_esp = current_stack_pointer; 101 irqctx->tinfo.previous_esp = current_stack_pointer;
102 102
103 /* 103 /* Copy the preempt_count so that the [soft]irq checks work. */
104 * Copy the softirq bits in preempt_count so that the 104 irqctx->tinfo.preempt_count = curctx->tinfo.preempt_count;
105 * softirq checks work in the hardirq context.
106 */
107 irqctx->tinfo.preempt_count =
108 (irqctx->tinfo.preempt_count & ~SOFTIRQ_MASK) |
109 (curctx->tinfo.preempt_count & SOFTIRQ_MASK);
110 105
111 if (unlikely(overflow)) 106 if (unlikely(overflow))
112 call_on_stack(print_stack_overflow, isp); 107 call_on_stack(print_stack_overflow, isp);
@@ -196,7 +191,7 @@ bool handle_irq(unsigned irq, struct pt_regs *regs)
196 if (unlikely(!desc)) 191 if (unlikely(!desc))
197 return false; 192 return false;
198 193
199 if (!execute_on_irq_stack(overflow, desc, irq)) { 194 if (user_mode_vm(regs) || !execute_on_irq_stack(overflow, desc, irq)) {
200 if (unlikely(overflow)) 195 if (unlikely(overflow))
201 print_stack_overflow(); 196 print_stack_overflow();
202 desc->handle_irq(irq, desc); 197 desc->handle_irq(irq, desc);
diff --git a/arch/x86/kernel/kprobes-common.h b/arch/x86/kernel/kprobes-common.h
new file mode 100644
index 000000000000..3230b68ef29a
--- /dev/null
+++ b/arch/x86/kernel/kprobes-common.h
@@ -0,0 +1,102 @@
1#ifndef __X86_KERNEL_KPROBES_COMMON_H
2#define __X86_KERNEL_KPROBES_COMMON_H
3
4/* Kprobes and Optprobes common header */
5
6#ifdef CONFIG_X86_64
7#define SAVE_REGS_STRING \
8 /* Skip cs, ip, orig_ax. */ \
9 " subq $24, %rsp\n" \
10 " pushq %rdi\n" \
11 " pushq %rsi\n" \
12 " pushq %rdx\n" \
13 " pushq %rcx\n" \
14 " pushq %rax\n" \
15 " pushq %r8\n" \
16 " pushq %r9\n" \
17 " pushq %r10\n" \
18 " pushq %r11\n" \
19 " pushq %rbx\n" \
20 " pushq %rbp\n" \
21 " pushq %r12\n" \
22 " pushq %r13\n" \
23 " pushq %r14\n" \
24 " pushq %r15\n"
25#define RESTORE_REGS_STRING \
26 " popq %r15\n" \
27 " popq %r14\n" \
28 " popq %r13\n" \
29 " popq %r12\n" \
30 " popq %rbp\n" \
31 " popq %rbx\n" \
32 " popq %r11\n" \
33 " popq %r10\n" \
34 " popq %r9\n" \
35 " popq %r8\n" \
36 " popq %rax\n" \
37 " popq %rcx\n" \
38 " popq %rdx\n" \
39 " popq %rsi\n" \
40 " popq %rdi\n" \
41 /* Skip orig_ax, ip, cs */ \
42 " addq $24, %rsp\n"
43#else
44#define SAVE_REGS_STRING \
45 /* Skip cs, ip, orig_ax and gs. */ \
46 " subl $16, %esp\n" \
47 " pushl %fs\n" \
48 " pushl %es\n" \
49 " pushl %ds\n" \
50 " pushl %eax\n" \
51 " pushl %ebp\n" \
52 " pushl %edi\n" \
53 " pushl %esi\n" \
54 " pushl %edx\n" \
55 " pushl %ecx\n" \
56 " pushl %ebx\n"
57#define RESTORE_REGS_STRING \
58 " popl %ebx\n" \
59 " popl %ecx\n" \
60 " popl %edx\n" \
61 " popl %esi\n" \
62 " popl %edi\n" \
63 " popl %ebp\n" \
64 " popl %eax\n" \
65 /* Skip ds, es, fs, gs, orig_ax, and ip. Note: don't pop cs here*/\
66 " addl $24, %esp\n"
67#endif
68
69/* Ensure if the instruction can be boostable */
70extern int can_boost(kprobe_opcode_t *instruction);
71/* Recover instruction if given address is probed */
72extern unsigned long recover_probed_instruction(kprobe_opcode_t *buf,
73 unsigned long addr);
74/*
75 * Copy an instruction and adjust the displacement if the instruction
76 * uses the %rip-relative addressing mode.
77 */
78extern int __copy_instruction(u8 *dest, u8 *src);
79
80/* Generate a relative-jump/call instruction */
81extern void synthesize_reljump(void *from, void *to);
82extern void synthesize_relcall(void *from, void *to);
83
84#ifdef CONFIG_OPTPROBES
85extern int arch_init_optprobes(void);
86extern int setup_detour_execution(struct kprobe *p, struct pt_regs *regs, int reenter);
87extern unsigned long __recover_optprobed_insn(kprobe_opcode_t *buf, unsigned long addr);
88#else /* !CONFIG_OPTPROBES */
89static inline int arch_init_optprobes(void)
90{
91 return 0;
92}
93static inline int setup_detour_execution(struct kprobe *p, struct pt_regs *regs, int reenter)
94{
95 return 0;
96}
97static inline unsigned long __recover_optprobed_insn(kprobe_opcode_t *buf, unsigned long addr)
98{
99 return addr;
100}
101#endif
102#endif
diff --git a/arch/x86/kernel/kprobes-opt.c b/arch/x86/kernel/kprobes-opt.c
new file mode 100644
index 000000000000..c5e410eed403
--- /dev/null
+++ b/arch/x86/kernel/kprobes-opt.c
@@ -0,0 +1,512 @@
1/*
2 * Kernel Probes Jump Optimization (Optprobes)
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17 *
18 * Copyright (C) IBM Corporation, 2002, 2004
19 * Copyright (C) Hitachi Ltd., 2012
20 */
21#include <linux/kprobes.h>
22#include <linux/ptrace.h>
23#include <linux/string.h>
24#include <linux/slab.h>
25#include <linux/hardirq.h>
26#include <linux/preempt.h>
27#include <linux/module.h>
28#include <linux/kdebug.h>
29#include <linux/kallsyms.h>
30#include <linux/ftrace.h>
31
32#include <asm/cacheflush.h>
33#include <asm/desc.h>
34#include <asm/pgtable.h>
35#include <asm/uaccess.h>
36#include <asm/alternative.h>
37#include <asm/insn.h>
38#include <asm/debugreg.h>
39
40#include "kprobes-common.h"
41
42unsigned long __recover_optprobed_insn(kprobe_opcode_t *buf, unsigned long addr)
43{
44 struct optimized_kprobe *op;
45 struct kprobe *kp;
46 long offs;
47 int i;
48
49 for (i = 0; i < RELATIVEJUMP_SIZE; i++) {
50 kp = get_kprobe((void *)addr - i);
51 /* This function only handles jump-optimized kprobe */
52 if (kp && kprobe_optimized(kp)) {
53 op = container_of(kp, struct optimized_kprobe, kp);
54 /* If op->list is not empty, op is under optimizing */
55 if (list_empty(&op->list))
56 goto found;
57 }
58 }
59
60 return addr;
61found:
62 /*
63 * If the kprobe can be optimized, original bytes which can be
64 * overwritten by jump destination address. In this case, original
65 * bytes must be recovered from op->optinsn.copied_insn buffer.
66 */
67 memcpy(buf, (void *)addr, MAX_INSN_SIZE * sizeof(kprobe_opcode_t));
68 if (addr == (unsigned long)kp->addr) {
69 buf[0] = kp->opcode;
70 memcpy(buf + 1, op->optinsn.copied_insn, RELATIVE_ADDR_SIZE);
71 } else {
72 offs = addr - (unsigned long)kp->addr - 1;
73 memcpy(buf, op->optinsn.copied_insn + offs, RELATIVE_ADDR_SIZE - offs);
74 }
75
76 return (unsigned long)buf;
77}
78
79/* Insert a move instruction which sets a pointer to eax/rdi (1st arg). */
80static void __kprobes synthesize_set_arg1(kprobe_opcode_t *addr, unsigned long val)
81{
82#ifdef CONFIG_X86_64
83 *addr++ = 0x48;
84 *addr++ = 0xbf;
85#else
86 *addr++ = 0xb8;
87#endif
88 *(unsigned long *)addr = val;
89}
90
91static void __used __kprobes kprobes_optinsn_template_holder(void)
92{
93 asm volatile (
94 ".global optprobe_template_entry\n"
95 "optprobe_template_entry:\n"
96#ifdef CONFIG_X86_64
97 /* We don't bother saving the ss register */
98 " pushq %rsp\n"
99 " pushfq\n"
100 SAVE_REGS_STRING
101 " movq %rsp, %rsi\n"
102 ".global optprobe_template_val\n"
103 "optprobe_template_val:\n"
104 ASM_NOP5
105 ASM_NOP5
106 ".global optprobe_template_call\n"
107 "optprobe_template_call:\n"
108 ASM_NOP5
109 /* Move flags to rsp */
110 " movq 144(%rsp), %rdx\n"
111 " movq %rdx, 152(%rsp)\n"
112 RESTORE_REGS_STRING
113 /* Skip flags entry */
114 " addq $8, %rsp\n"
115 " popfq\n"
116#else /* CONFIG_X86_32 */
117 " pushf\n"
118 SAVE_REGS_STRING
119 " movl %esp, %edx\n"
120 ".global optprobe_template_val\n"
121 "optprobe_template_val:\n"
122 ASM_NOP5
123 ".global optprobe_template_call\n"
124 "optprobe_template_call:\n"
125 ASM_NOP5
126 RESTORE_REGS_STRING
127 " addl $4, %esp\n" /* skip cs */
128 " popf\n"
129#endif
130 ".global optprobe_template_end\n"
131 "optprobe_template_end:\n");
132}
133
134#define TMPL_MOVE_IDX \
135 ((long)&optprobe_template_val - (long)&optprobe_template_entry)
136#define TMPL_CALL_IDX \
137 ((long)&optprobe_template_call - (long)&optprobe_template_entry)
138#define TMPL_END_IDX \
139 ((long)&optprobe_template_end - (long)&optprobe_template_entry)
140
141#define INT3_SIZE sizeof(kprobe_opcode_t)
142
143/* Optimized kprobe call back function: called from optinsn */
144static void __kprobes optimized_callback(struct optimized_kprobe *op, struct pt_regs *regs)
145{
146 struct kprobe_ctlblk *kcb = get_kprobe_ctlblk();
147 unsigned long flags;
148
149 /* This is possible if op is under delayed unoptimizing */
150 if (kprobe_disabled(&op->kp))
151 return;
152
153 local_irq_save(flags);
154 if (kprobe_running()) {
155 kprobes_inc_nmissed_count(&op->kp);
156 } else {
157 /* Save skipped registers */
158#ifdef CONFIG_X86_64
159 regs->cs = __KERNEL_CS;
160#else
161 regs->cs = __KERNEL_CS | get_kernel_rpl();
162 regs->gs = 0;
163#endif
164 regs->ip = (unsigned long)op->kp.addr + INT3_SIZE;
165 regs->orig_ax = ~0UL;
166
167 __this_cpu_write(current_kprobe, &op->kp);
168 kcb->kprobe_status = KPROBE_HIT_ACTIVE;
169 opt_pre_handler(&op->kp, regs);
170 __this_cpu_write(current_kprobe, NULL);
171 }
172 local_irq_restore(flags);
173}
174
175static int __kprobes copy_optimized_instructions(u8 *dest, u8 *src)
176{
177 int len = 0, ret;
178
179 while (len < RELATIVEJUMP_SIZE) {
180 ret = __copy_instruction(dest + len, src + len);
181 if (!ret || !can_boost(dest + len))
182 return -EINVAL;
183 len += ret;
184 }
185 /* Check whether the address range is reserved */
186 if (ftrace_text_reserved(src, src + len - 1) ||
187 alternatives_text_reserved(src, src + len - 1) ||
188 jump_label_text_reserved(src, src + len - 1))
189 return -EBUSY;
190
191 return len;
192}
193
194/* Check whether insn is indirect jump */
195static int __kprobes insn_is_indirect_jump(struct insn *insn)
196{
197 return ((insn->opcode.bytes[0] == 0xff &&
198 (X86_MODRM_REG(insn->modrm.value) & 6) == 4) || /* Jump */
199 insn->opcode.bytes[0] == 0xea); /* Segment based jump */
200}
201
202/* Check whether insn jumps into specified address range */
203static int insn_jump_into_range(struct insn *insn, unsigned long start, int len)
204{
205 unsigned long target = 0;
206
207 switch (insn->opcode.bytes[0]) {
208 case 0xe0: /* loopne */
209 case 0xe1: /* loope */
210 case 0xe2: /* loop */
211 case 0xe3: /* jcxz */
212 case 0xe9: /* near relative jump */
213 case 0xeb: /* short relative jump */
214 break;
215 case 0x0f:
216 if ((insn->opcode.bytes[1] & 0xf0) == 0x80) /* jcc near */
217 break;
218 return 0;
219 default:
220 if ((insn->opcode.bytes[0] & 0xf0) == 0x70) /* jcc short */
221 break;
222 return 0;
223 }
224 target = (unsigned long)insn->next_byte + insn->immediate.value;
225
226 return (start <= target && target <= start + len);
227}
228
229/* Decode whole function to ensure any instructions don't jump into target */
230static int __kprobes can_optimize(unsigned long paddr)
231{
232 unsigned long addr, size = 0, offset = 0;
233 struct insn insn;
234 kprobe_opcode_t buf[MAX_INSN_SIZE];
235
236 /* Lookup symbol including addr */
237 if (!kallsyms_lookup_size_offset(paddr, &size, &offset))
238 return 0;
239
240 /*
241 * Do not optimize in the entry code due to the unstable
242 * stack handling.
243 */
244 if ((paddr >= (unsigned long)__entry_text_start) &&
245 (paddr < (unsigned long)__entry_text_end))
246 return 0;
247
248 /* Check there is enough space for a relative jump. */
249 if (size - offset < RELATIVEJUMP_SIZE)
250 return 0;
251
252 /* Decode instructions */
253 addr = paddr - offset;
254 while (addr < paddr - offset + size) { /* Decode until function end */
255 if (search_exception_tables(addr))
256 /*
257 * Since some fixup code will jumps into this function,
258 * we can't optimize kprobe in this function.
259 */
260 return 0;
261 kernel_insn_init(&insn, (void *)recover_probed_instruction(buf, addr));
262 insn_get_length(&insn);
263 /* Another subsystem puts a breakpoint */
264 if (insn.opcode.bytes[0] == BREAKPOINT_INSTRUCTION)
265 return 0;
266 /* Recover address */
267 insn.kaddr = (void *)addr;
268 insn.next_byte = (void *)(addr + insn.length);
269 /* Check any instructions don't jump into target */
270 if (insn_is_indirect_jump(&insn) ||
271 insn_jump_into_range(&insn, paddr + INT3_SIZE,
272 RELATIVE_ADDR_SIZE))
273 return 0;
274 addr += insn.length;
275 }
276
277 return 1;
278}
279
280/* Check optimized_kprobe can actually be optimized. */
281int __kprobes arch_check_optimized_kprobe(struct optimized_kprobe *op)
282{
283 int i;
284 struct kprobe *p;
285
286 for (i = 1; i < op->optinsn.size; i++) {
287 p = get_kprobe(op->kp.addr + i);
288 if (p && !kprobe_disabled(p))
289 return -EEXIST;
290 }
291
292 return 0;
293}
294
295/* Check the addr is within the optimized instructions. */
296int __kprobes
297arch_within_optimized_kprobe(struct optimized_kprobe *op, unsigned long addr)
298{
299 return ((unsigned long)op->kp.addr <= addr &&
300 (unsigned long)op->kp.addr + op->optinsn.size > addr);
301}
302
303/* Free optimized instruction slot */
304static __kprobes
305void __arch_remove_optimized_kprobe(struct optimized_kprobe *op, int dirty)
306{
307 if (op->optinsn.insn) {
308 free_optinsn_slot(op->optinsn.insn, dirty);
309 op->optinsn.insn = NULL;
310 op->optinsn.size = 0;
311 }
312}
313
314void __kprobes arch_remove_optimized_kprobe(struct optimized_kprobe *op)
315{
316 __arch_remove_optimized_kprobe(op, 1);
317}
318
319/*
320 * Copy replacing target instructions
321 * Target instructions MUST be relocatable (checked inside)
322 * This is called when new aggr(opt)probe is allocated or reused.
323 */
324int __kprobes arch_prepare_optimized_kprobe(struct optimized_kprobe *op)
325{
326 u8 *buf;
327 int ret;
328 long rel;
329
330 if (!can_optimize((unsigned long)op->kp.addr))
331 return -EILSEQ;
332
333 op->optinsn.insn = get_optinsn_slot();
334 if (!op->optinsn.insn)
335 return -ENOMEM;
336
337 /*
338 * Verify if the address gap is in 2GB range, because this uses
339 * a relative jump.
340 */
341 rel = (long)op->optinsn.insn - (long)op->kp.addr + RELATIVEJUMP_SIZE;
342 if (abs(rel) > 0x7fffffff)
343 return -ERANGE;
344
345 buf = (u8 *)op->optinsn.insn;
346
347 /* Copy instructions into the out-of-line buffer */
348 ret = copy_optimized_instructions(buf + TMPL_END_IDX, op->kp.addr);
349 if (ret < 0) {
350 __arch_remove_optimized_kprobe(op, 0);
351 return ret;
352 }
353 op->optinsn.size = ret;
354
355 /* Copy arch-dep-instance from template */
356 memcpy(buf, &optprobe_template_entry, TMPL_END_IDX);
357
358 /* Set probe information */
359 synthesize_set_arg1(buf + TMPL_MOVE_IDX, (unsigned long)op);
360
361 /* Set probe function call */
362 synthesize_relcall(buf + TMPL_CALL_IDX, optimized_callback);
363
364 /* Set returning jmp instruction at the tail of out-of-line buffer */
365 synthesize_reljump(buf + TMPL_END_IDX + op->optinsn.size,
366 (u8 *)op->kp.addr + op->optinsn.size);
367
368 flush_icache_range((unsigned long) buf,
369 (unsigned long) buf + TMPL_END_IDX +
370 op->optinsn.size + RELATIVEJUMP_SIZE);
371 return 0;
372}
373
374#define MAX_OPTIMIZE_PROBES 256
375static struct text_poke_param *jump_poke_params;
376static struct jump_poke_buffer {
377 u8 buf[RELATIVEJUMP_SIZE];
378} *jump_poke_bufs;
379
380static void __kprobes setup_optimize_kprobe(struct text_poke_param *tprm,
381 u8 *insn_buf,
382 struct optimized_kprobe *op)
383{
384 s32 rel = (s32)((long)op->optinsn.insn -
385 ((long)op->kp.addr + RELATIVEJUMP_SIZE));
386
387 /* Backup instructions which will be replaced by jump address */
388 memcpy(op->optinsn.copied_insn, op->kp.addr + INT3_SIZE,
389 RELATIVE_ADDR_SIZE);
390
391 insn_buf[0] = RELATIVEJUMP_OPCODE;
392 *(s32 *)(&insn_buf[1]) = rel;
393
394 tprm->addr = op->kp.addr;
395 tprm->opcode = insn_buf;
396 tprm->len = RELATIVEJUMP_SIZE;
397}
398
399/*
400 * Replace breakpoints (int3) with relative jumps.
401 * Caller must call with locking kprobe_mutex and text_mutex.
402 */
403void __kprobes arch_optimize_kprobes(struct list_head *oplist)
404{
405 struct optimized_kprobe *op, *tmp;
406 int c = 0;
407
408 list_for_each_entry_safe(op, tmp, oplist, list) {
409 WARN_ON(kprobe_disabled(&op->kp));
410 /* Setup param */
411 setup_optimize_kprobe(&jump_poke_params[c],
412 jump_poke_bufs[c].buf, op);
413 list_del_init(&op->list);
414 if (++c >= MAX_OPTIMIZE_PROBES)
415 break;
416 }
417
418 /*
419 * text_poke_smp doesn't support NMI/MCE code modifying.
420 * However, since kprobes itself also doesn't support NMI/MCE
421 * code probing, it's not a problem.
422 */
423 text_poke_smp_batch(jump_poke_params, c);
424}
425
426static void __kprobes setup_unoptimize_kprobe(struct text_poke_param *tprm,
427 u8 *insn_buf,
428 struct optimized_kprobe *op)
429{
430 /* Set int3 to first byte for kprobes */
431 insn_buf[0] = BREAKPOINT_INSTRUCTION;
432 memcpy(insn_buf + 1, op->optinsn.copied_insn, RELATIVE_ADDR_SIZE);
433
434 tprm->addr = op->kp.addr;
435 tprm->opcode = insn_buf;
436 tprm->len = RELATIVEJUMP_SIZE;
437}
438
439/*
440 * Recover original instructions and breakpoints from relative jumps.
441 * Caller must call with locking kprobe_mutex.
442 */
443extern void arch_unoptimize_kprobes(struct list_head *oplist,
444 struct list_head *done_list)
445{
446 struct optimized_kprobe *op, *tmp;
447 int c = 0;
448
449 list_for_each_entry_safe(op, tmp, oplist, list) {
450 /* Setup param */
451 setup_unoptimize_kprobe(&jump_poke_params[c],
452 jump_poke_bufs[c].buf, op);
453 list_move(&op->list, done_list);
454 if (++c >= MAX_OPTIMIZE_PROBES)
455 break;
456 }
457
458 /*
459 * text_poke_smp doesn't support NMI/MCE code modifying.
460 * However, since kprobes itself also doesn't support NMI/MCE
461 * code probing, it's not a problem.
462 */
463 text_poke_smp_batch(jump_poke_params, c);
464}
465
466/* Replace a relative jump with a breakpoint (int3). */
467void __kprobes arch_unoptimize_kprobe(struct optimized_kprobe *op)
468{
469 u8 buf[RELATIVEJUMP_SIZE];
470
471 /* Set int3 to first byte for kprobes */
472 buf[0] = BREAKPOINT_INSTRUCTION;
473 memcpy(buf + 1, op->optinsn.copied_insn, RELATIVE_ADDR_SIZE);
474 text_poke_smp(op->kp.addr, buf, RELATIVEJUMP_SIZE);
475}
476
477int __kprobes
478setup_detour_execution(struct kprobe *p, struct pt_regs *regs, int reenter)
479{
480 struct optimized_kprobe *op;
481
482 if (p->flags & KPROBE_FLAG_OPTIMIZED) {
483 /* This kprobe is really able to run optimized path. */
484 op = container_of(p, struct optimized_kprobe, kp);
485 /* Detour through copied instructions */
486 regs->ip = (unsigned long)op->optinsn.insn + TMPL_END_IDX;
487 if (!reenter)
488 reset_current_kprobe();
489 preempt_enable_no_resched();
490 return 1;
491 }
492 return 0;
493}
494
495int __kprobes arch_init_optprobes(void)
496{
497 /* Allocate code buffer and parameter array */
498 jump_poke_bufs = kmalloc(sizeof(struct jump_poke_buffer) *
499 MAX_OPTIMIZE_PROBES, GFP_KERNEL);
500 if (!jump_poke_bufs)
501 return -ENOMEM;
502
503 jump_poke_params = kmalloc(sizeof(struct text_poke_param) *
504 MAX_OPTIMIZE_PROBES, GFP_KERNEL);
505 if (!jump_poke_params) {
506 kfree(jump_poke_bufs);
507 jump_poke_bufs = NULL;
508 return -ENOMEM;
509 }
510
511 return 0;
512}
diff --git a/arch/x86/kernel/kprobes.c b/arch/x86/kernel/kprobes.c
index 7da647d8b64c..e213fc8408d2 100644
--- a/arch/x86/kernel/kprobes.c
+++ b/arch/x86/kernel/kprobes.c
@@ -30,16 +30,15 @@
30 * <jkenisto@us.ibm.com> and Prasanna S Panchamukhi 30 * <jkenisto@us.ibm.com> and Prasanna S Panchamukhi
31 * <prasanna@in.ibm.com> added function-return probes. 31 * <prasanna@in.ibm.com> added function-return probes.
32 * 2005-May Rusty Lynch <rusty.lynch@intel.com> 32 * 2005-May Rusty Lynch <rusty.lynch@intel.com>
33 * Added function return probes functionality 33 * Added function return probes functionality
34 * 2006-Feb Masami Hiramatsu <hiramatu@sdl.hitachi.co.jp> added 34 * 2006-Feb Masami Hiramatsu <hiramatu@sdl.hitachi.co.jp> added
35 * kprobe-booster and kretprobe-booster for i386. 35 * kprobe-booster and kretprobe-booster for i386.
36 * 2007-Dec Masami Hiramatsu <mhiramat@redhat.com> added kprobe-booster 36 * 2007-Dec Masami Hiramatsu <mhiramat@redhat.com> added kprobe-booster
37 * and kretprobe-booster for x86-64 37 * and kretprobe-booster for x86-64
38 * 2007-Dec Masami Hiramatsu <mhiramat@redhat.com>, Arjan van de Ven 38 * 2007-Dec Masami Hiramatsu <mhiramat@redhat.com>, Arjan van de Ven
39 * <arjan@infradead.org> and Jim Keniston <jkenisto@us.ibm.com> 39 * <arjan@infradead.org> and Jim Keniston <jkenisto@us.ibm.com>
40 * unified x86 kprobes code. 40 * unified x86 kprobes code.
41 */ 41 */
42
43#include <linux/kprobes.h> 42#include <linux/kprobes.h>
44#include <linux/ptrace.h> 43#include <linux/ptrace.h>
45#include <linux/string.h> 44#include <linux/string.h>
@@ -59,6 +58,8 @@
59#include <asm/insn.h> 58#include <asm/insn.h>
60#include <asm/debugreg.h> 59#include <asm/debugreg.h>
61 60
61#include "kprobes-common.h"
62
62void jprobe_return_end(void); 63void jprobe_return_end(void);
63 64
64DEFINE_PER_CPU(struct kprobe *, current_kprobe) = NULL; 65DEFINE_PER_CPU(struct kprobe *, current_kprobe) = NULL;
@@ -108,6 +109,7 @@ struct kretprobe_blackpoint kretprobe_blacklist[] = {
108 doesn't switch kernel stack.*/ 109 doesn't switch kernel stack.*/
109 {NULL, NULL} /* Terminator */ 110 {NULL, NULL} /* Terminator */
110}; 111};
112
111const int kretprobe_blacklist_size = ARRAY_SIZE(kretprobe_blacklist); 113const int kretprobe_blacklist_size = ARRAY_SIZE(kretprobe_blacklist);
112 114
113static void __kprobes __synthesize_relative_insn(void *from, void *to, u8 op) 115static void __kprobes __synthesize_relative_insn(void *from, void *to, u8 op)
@@ -123,11 +125,17 @@ static void __kprobes __synthesize_relative_insn(void *from, void *to, u8 op)
123} 125}
124 126
125/* Insert a jump instruction at address 'from', which jumps to address 'to'.*/ 127/* Insert a jump instruction at address 'from', which jumps to address 'to'.*/
126static void __kprobes synthesize_reljump(void *from, void *to) 128void __kprobes synthesize_reljump(void *from, void *to)
127{ 129{
128 __synthesize_relative_insn(from, to, RELATIVEJUMP_OPCODE); 130 __synthesize_relative_insn(from, to, RELATIVEJUMP_OPCODE);
129} 131}
130 132
133/* Insert a call instruction at address 'from', which calls address 'to'.*/
134void __kprobes synthesize_relcall(void *from, void *to)
135{
136 __synthesize_relative_insn(from, to, RELATIVECALL_OPCODE);
137}
138
131/* 139/*
132 * Skip the prefixes of the instruction. 140 * Skip the prefixes of the instruction.
133 */ 141 */
@@ -151,7 +159,7 @@ static kprobe_opcode_t *__kprobes skip_prefixes(kprobe_opcode_t *insn)
151 * Returns non-zero if opcode is boostable. 159 * Returns non-zero if opcode is boostable.
152 * RIP relative instructions are adjusted at copying time in 64 bits mode 160 * RIP relative instructions are adjusted at copying time in 64 bits mode
153 */ 161 */
154static int __kprobes can_boost(kprobe_opcode_t *opcodes) 162int __kprobes can_boost(kprobe_opcode_t *opcodes)
155{ 163{
156 kprobe_opcode_t opcode; 164 kprobe_opcode_t opcode;
157 kprobe_opcode_t *orig_opcodes = opcodes; 165 kprobe_opcode_t *orig_opcodes = opcodes;
@@ -207,13 +215,15 @@ retry:
207 } 215 }
208} 216}
209 217
210/* Recover the probed instruction at addr for further analysis. */ 218static unsigned long
211static int recover_probed_instruction(kprobe_opcode_t *buf, unsigned long addr) 219__recover_probed_insn(kprobe_opcode_t *buf, unsigned long addr)
212{ 220{
213 struct kprobe *kp; 221 struct kprobe *kp;
222
214 kp = get_kprobe((void *)addr); 223 kp = get_kprobe((void *)addr);
224 /* There is no probe, return original address */
215 if (!kp) 225 if (!kp)
216 return -EINVAL; 226 return addr;
217 227
218 /* 228 /*
219 * Basically, kp->ainsn.insn has an original instruction. 229 * Basically, kp->ainsn.insn has an original instruction.
@@ -230,14 +240,29 @@ static int recover_probed_instruction(kprobe_opcode_t *buf, unsigned long addr)
230 */ 240 */
231 memcpy(buf, kp->addr, MAX_INSN_SIZE * sizeof(kprobe_opcode_t)); 241 memcpy(buf, kp->addr, MAX_INSN_SIZE * sizeof(kprobe_opcode_t));
232 buf[0] = kp->opcode; 242 buf[0] = kp->opcode;
233 return 0; 243 return (unsigned long)buf;
244}
245
246/*
247 * Recover the probed instruction at addr for further analysis.
248 * Caller must lock kprobes by kprobe_mutex, or disable preemption
249 * for preventing to release referencing kprobes.
250 */
251unsigned long recover_probed_instruction(kprobe_opcode_t *buf, unsigned long addr)
252{
253 unsigned long __addr;
254
255 __addr = __recover_optprobed_insn(buf, addr);
256 if (__addr != addr)
257 return __addr;
258
259 return __recover_probed_insn(buf, addr);
234} 260}
235 261
236/* Check if paddr is at an instruction boundary */ 262/* Check if paddr is at an instruction boundary */
237static int __kprobes can_probe(unsigned long paddr) 263static int __kprobes can_probe(unsigned long paddr)
238{ 264{
239 int ret; 265 unsigned long addr, __addr, offset = 0;
240 unsigned long addr, offset = 0;
241 struct insn insn; 266 struct insn insn;
242 kprobe_opcode_t buf[MAX_INSN_SIZE]; 267 kprobe_opcode_t buf[MAX_INSN_SIZE];
243 268
@@ -247,26 +272,24 @@ static int __kprobes can_probe(unsigned long paddr)
247 /* Decode instructions */ 272 /* Decode instructions */
248 addr = paddr - offset; 273 addr = paddr - offset;
249 while (addr < paddr) { 274 while (addr < paddr) {
250 kernel_insn_init(&insn, (void *)addr);
251 insn_get_opcode(&insn);
252
253 /* 275 /*
254 * Check if the instruction has been modified by another 276 * Check if the instruction has been modified by another
255 * kprobe, in which case we replace the breakpoint by the 277 * kprobe, in which case we replace the breakpoint by the
256 * original instruction in our buffer. 278 * original instruction in our buffer.
279 * Also, jump optimization will change the breakpoint to
280 * relative-jump. Since the relative-jump itself is
281 * normally used, we just go through if there is no kprobe.
257 */ 282 */
258 if (insn.opcode.bytes[0] == BREAKPOINT_INSTRUCTION) { 283 __addr = recover_probed_instruction(buf, addr);
259 ret = recover_probed_instruction(buf, addr); 284 kernel_insn_init(&insn, (void *)__addr);
260 if (ret)
261 /*
262 * Another debugging subsystem might insert
263 * this breakpoint. In that case, we can't
264 * recover it.
265 */
266 return 0;
267 kernel_insn_init(&insn, buf);
268 }
269 insn_get_length(&insn); 285 insn_get_length(&insn);
286
287 /*
288 * Another debugging subsystem might insert this breakpoint.
289 * In that case, we can't recover it.
290 */
291 if (insn.opcode.bytes[0] == BREAKPOINT_INSTRUCTION)
292 return 0;
270 addr += insn.length; 293 addr += insn.length;
271 } 294 }
272 295
@@ -299,24 +322,16 @@ static int __kprobes is_IF_modifier(kprobe_opcode_t *insn)
299 * If not, return null. 322 * If not, return null.
300 * Only applicable to 64-bit x86. 323 * Only applicable to 64-bit x86.
301 */ 324 */
302static int __kprobes __copy_instruction(u8 *dest, u8 *src, int recover) 325int __kprobes __copy_instruction(u8 *dest, u8 *src)
303{ 326{
304 struct insn insn; 327 struct insn insn;
305 int ret;
306 kprobe_opcode_t buf[MAX_INSN_SIZE]; 328 kprobe_opcode_t buf[MAX_INSN_SIZE];
307 329
308 kernel_insn_init(&insn, src); 330 kernel_insn_init(&insn, (void *)recover_probed_instruction(buf, (unsigned long)src));
309 if (recover) {
310 insn_get_opcode(&insn);
311 if (insn.opcode.bytes[0] == BREAKPOINT_INSTRUCTION) {
312 ret = recover_probed_instruction(buf,
313 (unsigned long)src);
314 if (ret)
315 return 0;
316 kernel_insn_init(&insn, buf);
317 }
318 }
319 insn_get_length(&insn); 331 insn_get_length(&insn);
332 /* Another subsystem puts a breakpoint, failed to recover */
333 if (insn.opcode.bytes[0] == BREAKPOINT_INSTRUCTION)
334 return 0;
320 memcpy(dest, insn.kaddr, insn.length); 335 memcpy(dest, insn.kaddr, insn.length);
321 336
322#ifdef CONFIG_X86_64 337#ifdef CONFIG_X86_64
@@ -337,8 +352,7 @@ static int __kprobes __copy_instruction(u8 *dest, u8 *src, int recover)
337 * extension of the original signed 32-bit displacement would 352 * extension of the original signed 32-bit displacement would
338 * have given. 353 * have given.
339 */ 354 */
340 newdisp = (u8 *) src + (s64) insn.displacement.value - 355 newdisp = (u8 *) src + (s64) insn.displacement.value - (u8 *) dest;
341 (u8 *) dest;
342 BUG_ON((s64) (s32) newdisp != newdisp); /* Sanity check. */ 356 BUG_ON((s64) (s32) newdisp != newdisp); /* Sanity check. */
343 disp = (u8 *) dest + insn_offset_displacement(&insn); 357 disp = (u8 *) dest + insn_offset_displacement(&insn);
344 *(s32 *) disp = (s32) newdisp; 358 *(s32 *) disp = (s32) newdisp;
@@ -349,18 +363,20 @@ static int __kprobes __copy_instruction(u8 *dest, u8 *src, int recover)
349 363
350static void __kprobes arch_copy_kprobe(struct kprobe *p) 364static void __kprobes arch_copy_kprobe(struct kprobe *p)
351{ 365{
366 /* Copy an instruction with recovering if other optprobe modifies it.*/
367 __copy_instruction(p->ainsn.insn, p->addr);
368
352 /* 369 /*
353 * Copy an instruction without recovering int3, because it will be 370 * __copy_instruction can modify the displacement of the instruction,
354 * put by another subsystem. 371 * but it doesn't affect boostable check.
355 */ 372 */
356 __copy_instruction(p->ainsn.insn, p->addr, 0); 373 if (can_boost(p->ainsn.insn))
357
358 if (can_boost(p->addr))
359 p->ainsn.boostable = 0; 374 p->ainsn.boostable = 0;
360 else 375 else
361 p->ainsn.boostable = -1; 376 p->ainsn.boostable = -1;
362 377
363 p->opcode = *p->addr; 378 /* Also, displacement change doesn't affect the first byte */
379 p->opcode = p->ainsn.insn[0];
364} 380}
365 381
366int __kprobes arch_prepare_kprobe(struct kprobe *p) 382int __kprobes arch_prepare_kprobe(struct kprobe *p)
@@ -442,8 +458,8 @@ static void __kprobes restore_btf(void)
442 } 458 }
443} 459}
444 460
445void __kprobes arch_prepare_kretprobe(struct kretprobe_instance *ri, 461void __kprobes
446 struct pt_regs *regs) 462arch_prepare_kretprobe(struct kretprobe_instance *ri, struct pt_regs *regs)
447{ 463{
448 unsigned long *sara = stack_addr(regs); 464 unsigned long *sara = stack_addr(regs);
449 465
@@ -453,16 +469,8 @@ void __kprobes arch_prepare_kretprobe(struct kretprobe_instance *ri,
453 *sara = (unsigned long) &kretprobe_trampoline; 469 *sara = (unsigned long) &kretprobe_trampoline;
454} 470}
455 471
456#ifdef CONFIG_OPTPROBES 472static void __kprobes
457static int __kprobes setup_detour_execution(struct kprobe *p, 473setup_singlestep(struct kprobe *p, struct pt_regs *regs, struct kprobe_ctlblk *kcb, int reenter)
458 struct pt_regs *regs,
459 int reenter);
460#else
461#define setup_detour_execution(p, regs, reenter) (0)
462#endif
463
464static void __kprobes setup_singlestep(struct kprobe *p, struct pt_regs *regs,
465 struct kprobe_ctlblk *kcb, int reenter)
466{ 474{
467 if (setup_detour_execution(p, regs, reenter)) 475 if (setup_detour_execution(p, regs, reenter))
468 return; 476 return;
@@ -504,8 +512,8 @@ static void __kprobes setup_singlestep(struct kprobe *p, struct pt_regs *regs,
504 * within the handler. We save the original kprobes variables and just single 512 * within the handler. We save the original kprobes variables and just single
505 * step on the instruction of the new probe without calling any user handlers. 513 * step on the instruction of the new probe without calling any user handlers.
506 */ 514 */
507static int __kprobes reenter_kprobe(struct kprobe *p, struct pt_regs *regs, 515static int __kprobes
508 struct kprobe_ctlblk *kcb) 516reenter_kprobe(struct kprobe *p, struct pt_regs *regs, struct kprobe_ctlblk *kcb)
509{ 517{
510 switch (kcb->kprobe_status) { 518 switch (kcb->kprobe_status) {
511 case KPROBE_HIT_SSDONE: 519 case KPROBE_HIT_SSDONE:
@@ -600,69 +608,6 @@ static int __kprobes kprobe_handler(struct pt_regs *regs)
600 return 0; 608 return 0;
601} 609}
602 610
603#ifdef CONFIG_X86_64
604#define SAVE_REGS_STRING \
605 /* Skip cs, ip, orig_ax. */ \
606 " subq $24, %rsp\n" \
607 " pushq %rdi\n" \
608 " pushq %rsi\n" \
609 " pushq %rdx\n" \
610 " pushq %rcx\n" \
611 " pushq %rax\n" \
612 " pushq %r8\n" \
613 " pushq %r9\n" \
614 " pushq %r10\n" \
615 " pushq %r11\n" \
616 " pushq %rbx\n" \
617 " pushq %rbp\n" \
618 " pushq %r12\n" \
619 " pushq %r13\n" \
620 " pushq %r14\n" \
621 " pushq %r15\n"
622#define RESTORE_REGS_STRING \
623 " popq %r15\n" \
624 " popq %r14\n" \
625 " popq %r13\n" \
626 " popq %r12\n" \
627 " popq %rbp\n" \
628 " popq %rbx\n" \
629 " popq %r11\n" \
630 " popq %r10\n" \
631 " popq %r9\n" \
632 " popq %r8\n" \
633 " popq %rax\n" \
634 " popq %rcx\n" \
635 " popq %rdx\n" \
636 " popq %rsi\n" \
637 " popq %rdi\n" \
638 /* Skip orig_ax, ip, cs */ \
639 " addq $24, %rsp\n"
640#else
641#define SAVE_REGS_STRING \
642 /* Skip cs, ip, orig_ax and gs. */ \
643 " subl $16, %esp\n" \
644 " pushl %fs\n" \
645 " pushl %es\n" \
646 " pushl %ds\n" \
647 " pushl %eax\n" \
648 " pushl %ebp\n" \
649 " pushl %edi\n" \
650 " pushl %esi\n" \
651 " pushl %edx\n" \
652 " pushl %ecx\n" \
653 " pushl %ebx\n"
654#define RESTORE_REGS_STRING \
655 " popl %ebx\n" \
656 " popl %ecx\n" \
657 " popl %edx\n" \
658 " popl %esi\n" \
659 " popl %edi\n" \
660 " popl %ebp\n" \
661 " popl %eax\n" \
662 /* Skip ds, es, fs, gs, orig_ax, and ip. Note: don't pop cs here*/\
663 " addl $24, %esp\n"
664#endif
665
666/* 611/*
667 * When a retprobed function returns, this code saves registers and 612 * When a retprobed function returns, this code saves registers and
668 * calls trampoline_handler() runs, which calls the kretprobe's handler. 613 * calls trampoline_handler() runs, which calls the kretprobe's handler.
@@ -816,8 +761,8 @@ static __used __kprobes void *trampoline_handler(struct pt_regs *regs)
816 * jump instruction after the copied instruction, that jumps to the next 761 * jump instruction after the copied instruction, that jumps to the next
817 * instruction after the probepoint. 762 * instruction after the probepoint.
818 */ 763 */
819static void __kprobes resume_execution(struct kprobe *p, 764static void __kprobes
820 struct pt_regs *regs, struct kprobe_ctlblk *kcb) 765resume_execution(struct kprobe *p, struct pt_regs *regs, struct kprobe_ctlblk *kcb)
821{ 766{
822 unsigned long *tos = stack_addr(regs); 767 unsigned long *tos = stack_addr(regs);
823 unsigned long copy_ip = (unsigned long)p->ainsn.insn; 768 unsigned long copy_ip = (unsigned long)p->ainsn.insn;
@@ -996,8 +941,8 @@ int __kprobes kprobe_fault_handler(struct pt_regs *regs, int trapnr)
996/* 941/*
997 * Wrapper routine for handling exceptions. 942 * Wrapper routine for handling exceptions.
998 */ 943 */
999int __kprobes kprobe_exceptions_notify(struct notifier_block *self, 944int __kprobes
1000 unsigned long val, void *data) 945kprobe_exceptions_notify(struct notifier_block *self, unsigned long val, void *data)
1001{ 946{
1002 struct die_args *args = data; 947 struct die_args *args = data;
1003 int ret = NOTIFY_DONE; 948 int ret = NOTIFY_DONE;
@@ -1107,466 +1052,9 @@ int __kprobes longjmp_break_handler(struct kprobe *p, struct pt_regs *regs)
1107 return 0; 1052 return 0;
1108} 1053}
1109 1054
1110
1111#ifdef CONFIG_OPTPROBES
1112
1113/* Insert a call instruction at address 'from', which calls address 'to'.*/
1114static void __kprobes synthesize_relcall(void *from, void *to)
1115{
1116 __synthesize_relative_insn(from, to, RELATIVECALL_OPCODE);
1117}
1118
1119/* Insert a move instruction which sets a pointer to eax/rdi (1st arg). */
1120static void __kprobes synthesize_set_arg1(kprobe_opcode_t *addr,
1121 unsigned long val)
1122{
1123#ifdef CONFIG_X86_64
1124 *addr++ = 0x48;
1125 *addr++ = 0xbf;
1126#else
1127 *addr++ = 0xb8;
1128#endif
1129 *(unsigned long *)addr = val;
1130}
1131
1132static void __used __kprobes kprobes_optinsn_template_holder(void)
1133{
1134 asm volatile (
1135 ".global optprobe_template_entry\n"
1136 "optprobe_template_entry: \n"
1137#ifdef CONFIG_X86_64
1138 /* We don't bother saving the ss register */
1139 " pushq %rsp\n"
1140 " pushfq\n"
1141 SAVE_REGS_STRING
1142 " movq %rsp, %rsi\n"
1143 ".global optprobe_template_val\n"
1144 "optprobe_template_val: \n"
1145 ASM_NOP5
1146 ASM_NOP5
1147 ".global optprobe_template_call\n"
1148 "optprobe_template_call: \n"
1149 ASM_NOP5
1150 /* Move flags to rsp */
1151 " movq 144(%rsp), %rdx\n"
1152 " movq %rdx, 152(%rsp)\n"
1153 RESTORE_REGS_STRING
1154 /* Skip flags entry */
1155 " addq $8, %rsp\n"
1156 " popfq\n"
1157#else /* CONFIG_X86_32 */
1158 " pushf\n"
1159 SAVE_REGS_STRING
1160 " movl %esp, %edx\n"
1161 ".global optprobe_template_val\n"
1162 "optprobe_template_val: \n"
1163 ASM_NOP5
1164 ".global optprobe_template_call\n"
1165 "optprobe_template_call: \n"
1166 ASM_NOP5
1167 RESTORE_REGS_STRING
1168 " addl $4, %esp\n" /* skip cs */
1169 " popf\n"
1170#endif
1171 ".global optprobe_template_end\n"
1172 "optprobe_template_end: \n");
1173}
1174
1175#define TMPL_MOVE_IDX \
1176 ((long)&optprobe_template_val - (long)&optprobe_template_entry)
1177#define TMPL_CALL_IDX \
1178 ((long)&optprobe_template_call - (long)&optprobe_template_entry)
1179#define TMPL_END_IDX \
1180 ((long)&optprobe_template_end - (long)&optprobe_template_entry)
1181
1182#define INT3_SIZE sizeof(kprobe_opcode_t)
1183
1184/* Optimized kprobe call back function: called from optinsn */
1185static void __kprobes optimized_callback(struct optimized_kprobe *op,
1186 struct pt_regs *regs)
1187{
1188 struct kprobe_ctlblk *kcb = get_kprobe_ctlblk();
1189 unsigned long flags;
1190
1191 /* This is possible if op is under delayed unoptimizing */
1192 if (kprobe_disabled(&op->kp))
1193 return;
1194
1195 local_irq_save(flags);
1196 if (kprobe_running()) {
1197 kprobes_inc_nmissed_count(&op->kp);
1198 } else {
1199 /* Save skipped registers */
1200#ifdef CONFIG_X86_64
1201 regs->cs = __KERNEL_CS;
1202#else
1203 regs->cs = __KERNEL_CS | get_kernel_rpl();
1204 regs->gs = 0;
1205#endif
1206 regs->ip = (unsigned long)op->kp.addr + INT3_SIZE;
1207 regs->orig_ax = ~0UL;
1208
1209 __this_cpu_write(current_kprobe, &op->kp);
1210 kcb->kprobe_status = KPROBE_HIT_ACTIVE;
1211 opt_pre_handler(&op->kp, regs);
1212 __this_cpu_write(current_kprobe, NULL);
1213 }
1214 local_irq_restore(flags);
1215}
1216
1217static int __kprobes copy_optimized_instructions(u8 *dest, u8 *src)
1218{
1219 int len = 0, ret;
1220
1221 while (len < RELATIVEJUMP_SIZE) {
1222 ret = __copy_instruction(dest + len, src + len, 1);
1223 if (!ret || !can_boost(dest + len))
1224 return -EINVAL;
1225 len += ret;
1226 }
1227 /* Check whether the address range is reserved */
1228 if (ftrace_text_reserved(src, src + len - 1) ||
1229 alternatives_text_reserved(src, src + len - 1) ||
1230 jump_label_text_reserved(src, src + len - 1))
1231 return -EBUSY;
1232
1233 return len;
1234}
1235
1236/* Check whether insn is indirect jump */
1237static int __kprobes insn_is_indirect_jump(struct insn *insn)
1238{
1239 return ((insn->opcode.bytes[0] == 0xff &&
1240 (X86_MODRM_REG(insn->modrm.value) & 6) == 4) || /* Jump */
1241 insn->opcode.bytes[0] == 0xea); /* Segment based jump */
1242}
1243
1244/* Check whether insn jumps into specified address range */
1245static int insn_jump_into_range(struct insn *insn, unsigned long start, int len)
1246{
1247 unsigned long target = 0;
1248
1249 switch (insn->opcode.bytes[0]) {
1250 case 0xe0: /* loopne */
1251 case 0xe1: /* loope */
1252 case 0xe2: /* loop */
1253 case 0xe3: /* jcxz */
1254 case 0xe9: /* near relative jump */
1255 case 0xeb: /* short relative jump */
1256 break;
1257 case 0x0f:
1258 if ((insn->opcode.bytes[1] & 0xf0) == 0x80) /* jcc near */
1259 break;
1260 return 0;
1261 default:
1262 if ((insn->opcode.bytes[0] & 0xf0) == 0x70) /* jcc short */
1263 break;
1264 return 0;
1265 }
1266 target = (unsigned long)insn->next_byte + insn->immediate.value;
1267
1268 return (start <= target && target <= start + len);
1269}
1270
1271/* Decode whole function to ensure any instructions don't jump into target */
1272static int __kprobes can_optimize(unsigned long paddr)
1273{
1274 int ret;
1275 unsigned long addr, size = 0, offset = 0;
1276 struct insn insn;
1277 kprobe_opcode_t buf[MAX_INSN_SIZE];
1278
1279 /* Lookup symbol including addr */
1280 if (!kallsyms_lookup_size_offset(paddr, &size, &offset))
1281 return 0;
1282
1283 /*
1284 * Do not optimize in the entry code due to the unstable
1285 * stack handling.
1286 */
1287 if ((paddr >= (unsigned long )__entry_text_start) &&
1288 (paddr < (unsigned long )__entry_text_end))
1289 return 0;
1290
1291 /* Check there is enough space for a relative jump. */
1292 if (size - offset < RELATIVEJUMP_SIZE)
1293 return 0;
1294
1295 /* Decode instructions */
1296 addr = paddr - offset;
1297 while (addr < paddr - offset + size) { /* Decode until function end */
1298 if (search_exception_tables(addr))
1299 /*
1300 * Since some fixup code will jumps into this function,
1301 * we can't optimize kprobe in this function.
1302 */
1303 return 0;
1304 kernel_insn_init(&insn, (void *)addr);
1305 insn_get_opcode(&insn);
1306 if (insn.opcode.bytes[0] == BREAKPOINT_INSTRUCTION) {
1307 ret = recover_probed_instruction(buf, addr);
1308 if (ret)
1309 return 0;
1310 kernel_insn_init(&insn, buf);
1311 }
1312 insn_get_length(&insn);
1313 /* Recover address */
1314 insn.kaddr = (void *)addr;
1315 insn.next_byte = (void *)(addr + insn.length);
1316 /* Check any instructions don't jump into target */
1317 if (insn_is_indirect_jump(&insn) ||
1318 insn_jump_into_range(&insn, paddr + INT3_SIZE,
1319 RELATIVE_ADDR_SIZE))
1320 return 0;
1321 addr += insn.length;
1322 }
1323
1324 return 1;
1325}
1326
1327/* Check optimized_kprobe can actually be optimized. */
1328int __kprobes arch_check_optimized_kprobe(struct optimized_kprobe *op)
1329{
1330 int i;
1331 struct kprobe *p;
1332
1333 for (i = 1; i < op->optinsn.size; i++) {
1334 p = get_kprobe(op->kp.addr + i);
1335 if (p && !kprobe_disabled(p))
1336 return -EEXIST;
1337 }
1338
1339 return 0;
1340}
1341
1342/* Check the addr is within the optimized instructions. */
1343int __kprobes arch_within_optimized_kprobe(struct optimized_kprobe *op,
1344 unsigned long addr)
1345{
1346 return ((unsigned long)op->kp.addr <= addr &&
1347 (unsigned long)op->kp.addr + op->optinsn.size > addr);
1348}
1349
1350/* Free optimized instruction slot */
1351static __kprobes
1352void __arch_remove_optimized_kprobe(struct optimized_kprobe *op, int dirty)
1353{
1354 if (op->optinsn.insn) {
1355 free_optinsn_slot(op->optinsn.insn, dirty);
1356 op->optinsn.insn = NULL;
1357 op->optinsn.size = 0;
1358 }
1359}
1360
1361void __kprobes arch_remove_optimized_kprobe(struct optimized_kprobe *op)
1362{
1363 __arch_remove_optimized_kprobe(op, 1);
1364}
1365
1366/*
1367 * Copy replacing target instructions
1368 * Target instructions MUST be relocatable (checked inside)
1369 */
1370int __kprobes arch_prepare_optimized_kprobe(struct optimized_kprobe *op)
1371{
1372 u8 *buf;
1373 int ret;
1374 long rel;
1375
1376 if (!can_optimize((unsigned long)op->kp.addr))
1377 return -EILSEQ;
1378
1379 op->optinsn.insn = get_optinsn_slot();
1380 if (!op->optinsn.insn)
1381 return -ENOMEM;
1382
1383 /*
1384 * Verify if the address gap is in 2GB range, because this uses
1385 * a relative jump.
1386 */
1387 rel = (long)op->optinsn.insn - (long)op->kp.addr + RELATIVEJUMP_SIZE;
1388 if (abs(rel) > 0x7fffffff)
1389 return -ERANGE;
1390
1391 buf = (u8 *)op->optinsn.insn;
1392
1393 /* Copy instructions into the out-of-line buffer */
1394 ret = copy_optimized_instructions(buf + TMPL_END_IDX, op->kp.addr);
1395 if (ret < 0) {
1396 __arch_remove_optimized_kprobe(op, 0);
1397 return ret;
1398 }
1399 op->optinsn.size = ret;
1400
1401 /* Copy arch-dep-instance from template */
1402 memcpy(buf, &optprobe_template_entry, TMPL_END_IDX);
1403
1404 /* Set probe information */
1405 synthesize_set_arg1(buf + TMPL_MOVE_IDX, (unsigned long)op);
1406
1407 /* Set probe function call */
1408 synthesize_relcall(buf + TMPL_CALL_IDX, optimized_callback);
1409
1410 /* Set returning jmp instruction at the tail of out-of-line buffer */
1411 synthesize_reljump(buf + TMPL_END_IDX + op->optinsn.size,
1412 (u8 *)op->kp.addr + op->optinsn.size);
1413
1414 flush_icache_range((unsigned long) buf,
1415 (unsigned long) buf + TMPL_END_IDX +
1416 op->optinsn.size + RELATIVEJUMP_SIZE);
1417 return 0;
1418}
1419
1420#define MAX_OPTIMIZE_PROBES 256
1421static struct text_poke_param *jump_poke_params;
1422static struct jump_poke_buffer {
1423 u8 buf[RELATIVEJUMP_SIZE];
1424} *jump_poke_bufs;
1425
1426static void __kprobes setup_optimize_kprobe(struct text_poke_param *tprm,
1427 u8 *insn_buf,
1428 struct optimized_kprobe *op)
1429{
1430 s32 rel = (s32)((long)op->optinsn.insn -
1431 ((long)op->kp.addr + RELATIVEJUMP_SIZE));
1432
1433 /* Backup instructions which will be replaced by jump address */
1434 memcpy(op->optinsn.copied_insn, op->kp.addr + INT3_SIZE,
1435 RELATIVE_ADDR_SIZE);
1436
1437 insn_buf[0] = RELATIVEJUMP_OPCODE;
1438 *(s32 *)(&insn_buf[1]) = rel;
1439
1440 tprm->addr = op->kp.addr;
1441 tprm->opcode = insn_buf;
1442 tprm->len = RELATIVEJUMP_SIZE;
1443}
1444
1445/*
1446 * Replace breakpoints (int3) with relative jumps.
1447 * Caller must call with locking kprobe_mutex and text_mutex.
1448 */
1449void __kprobes arch_optimize_kprobes(struct list_head *oplist)
1450{
1451 struct optimized_kprobe *op, *tmp;
1452 int c = 0;
1453
1454 list_for_each_entry_safe(op, tmp, oplist, list) {
1455 WARN_ON(kprobe_disabled(&op->kp));
1456 /* Setup param */
1457 setup_optimize_kprobe(&jump_poke_params[c],
1458 jump_poke_bufs[c].buf, op);
1459 list_del_init(&op->list);
1460 if (++c >= MAX_OPTIMIZE_PROBES)
1461 break;
1462 }
1463
1464 /*
1465 * text_poke_smp doesn't support NMI/MCE code modifying.
1466 * However, since kprobes itself also doesn't support NMI/MCE
1467 * code probing, it's not a problem.
1468 */
1469 text_poke_smp_batch(jump_poke_params, c);
1470}
1471
1472static void __kprobes setup_unoptimize_kprobe(struct text_poke_param *tprm,
1473 u8 *insn_buf,
1474 struct optimized_kprobe *op)
1475{
1476 /* Set int3 to first byte for kprobes */
1477 insn_buf[0] = BREAKPOINT_INSTRUCTION;
1478 memcpy(insn_buf + 1, op->optinsn.copied_insn, RELATIVE_ADDR_SIZE);
1479
1480 tprm->addr = op->kp.addr;
1481 tprm->opcode = insn_buf;
1482 tprm->len = RELATIVEJUMP_SIZE;
1483}
1484
1485/*
1486 * Recover original instructions and breakpoints from relative jumps.
1487 * Caller must call with locking kprobe_mutex.
1488 */
1489extern void arch_unoptimize_kprobes(struct list_head *oplist,
1490 struct list_head *done_list)
1491{
1492 struct optimized_kprobe *op, *tmp;
1493 int c = 0;
1494
1495 list_for_each_entry_safe(op, tmp, oplist, list) {
1496 /* Setup param */
1497 setup_unoptimize_kprobe(&jump_poke_params[c],
1498 jump_poke_bufs[c].buf, op);
1499 list_move(&op->list, done_list);
1500 if (++c >= MAX_OPTIMIZE_PROBES)
1501 break;
1502 }
1503
1504 /*
1505 * text_poke_smp doesn't support NMI/MCE code modifying.
1506 * However, since kprobes itself also doesn't support NMI/MCE
1507 * code probing, it's not a problem.
1508 */
1509 text_poke_smp_batch(jump_poke_params, c);
1510}
1511
1512/* Replace a relative jump with a breakpoint (int3). */
1513void __kprobes arch_unoptimize_kprobe(struct optimized_kprobe *op)
1514{
1515 u8 buf[RELATIVEJUMP_SIZE];
1516
1517 /* Set int3 to first byte for kprobes */
1518 buf[0] = BREAKPOINT_INSTRUCTION;
1519 memcpy(buf + 1, op->optinsn.copied_insn, RELATIVE_ADDR_SIZE);
1520 text_poke_smp(op->kp.addr, buf, RELATIVEJUMP_SIZE);
1521}
1522
1523static int __kprobes setup_detour_execution(struct kprobe *p,
1524 struct pt_regs *regs,
1525 int reenter)
1526{
1527 struct optimized_kprobe *op;
1528
1529 if (p->flags & KPROBE_FLAG_OPTIMIZED) {
1530 /* This kprobe is really able to run optimized path. */
1531 op = container_of(p, struct optimized_kprobe, kp);
1532 /* Detour through copied instructions */
1533 regs->ip = (unsigned long)op->optinsn.insn + TMPL_END_IDX;
1534 if (!reenter)
1535 reset_current_kprobe();
1536 preempt_enable_no_resched();
1537 return 1;
1538 }
1539 return 0;
1540}
1541
1542static int __kprobes init_poke_params(void)
1543{
1544 /* Allocate code buffer and parameter array */
1545 jump_poke_bufs = kmalloc(sizeof(struct jump_poke_buffer) *
1546 MAX_OPTIMIZE_PROBES, GFP_KERNEL);
1547 if (!jump_poke_bufs)
1548 return -ENOMEM;
1549
1550 jump_poke_params = kmalloc(sizeof(struct text_poke_param) *
1551 MAX_OPTIMIZE_PROBES, GFP_KERNEL);
1552 if (!jump_poke_params) {
1553 kfree(jump_poke_bufs);
1554 jump_poke_bufs = NULL;
1555 return -ENOMEM;
1556 }
1557
1558 return 0;
1559}
1560#else /* !CONFIG_OPTPROBES */
1561static int __kprobes init_poke_params(void)
1562{
1563 return 0;
1564}
1565#endif
1566
1567int __init arch_init_kprobes(void) 1055int __init arch_init_kprobes(void)
1568{ 1056{
1569 return init_poke_params(); 1057 return arch_init_optprobes();
1570} 1058}
1571 1059
1572int __kprobes arch_trampoline_kprobe(struct kprobe *p) 1060int __kprobes arch_trampoline_kprobe(struct kprobe *p)
diff --git a/arch/x86/kernel/kvm.c b/arch/x86/kernel/kvm.c
index f0c6fd6f176b..694d801bf606 100644
--- a/arch/x86/kernel/kvm.c
+++ b/arch/x86/kernel/kvm.c
@@ -438,9 +438,9 @@ void __init kvm_guest_init(void)
438static __init int activate_jump_labels(void) 438static __init int activate_jump_labels(void)
439{ 439{
440 if (has_steal_clock) { 440 if (has_steal_clock) {
441 jump_label_inc(&paravirt_steal_enabled); 441 static_key_slow_inc(&paravirt_steal_enabled);
442 if (steal_acc) 442 if (steal_acc)
443 jump_label_inc(&paravirt_steal_rq_enabled); 443 static_key_slow_inc(&paravirt_steal_rq_enabled);
444 } 444 }
445 445
446 return 0; 446 return 0;
diff --git a/arch/x86/kernel/paravirt.c b/arch/x86/kernel/paravirt.c
index d90272e6bc40..ada2f99388dd 100644
--- a/arch/x86/kernel/paravirt.c
+++ b/arch/x86/kernel/paravirt.c
@@ -202,8 +202,8 @@ static void native_flush_tlb_single(unsigned long addr)
202 __native_flush_tlb_single(addr); 202 __native_flush_tlb_single(addr);
203} 203}
204 204
205struct jump_label_key paravirt_steal_enabled; 205struct static_key paravirt_steal_enabled;
206struct jump_label_key paravirt_steal_rq_enabled; 206struct static_key paravirt_steal_rq_enabled;
207 207
208static u64 native_steal_clock(int cpu) 208static u64 native_steal_clock(int cpu)
209{ 209{
diff --git a/arch/x86/kernel/process.c b/arch/x86/kernel/process.c
index 15763af7bfe3..44eefde92109 100644
--- a/arch/x86/kernel/process.c
+++ b/arch/x86/kernel/process.c
@@ -377,8 +377,8 @@ static inline int hlt_use_halt(void)
377void default_idle(void) 377void default_idle(void)
378{ 378{
379 if (hlt_use_halt()) { 379 if (hlt_use_halt()) {
380 trace_power_start(POWER_CSTATE, 1, smp_processor_id()); 380 trace_power_start_rcuidle(POWER_CSTATE, 1, smp_processor_id());
381 trace_cpu_idle(1, smp_processor_id()); 381 trace_cpu_idle_rcuidle(1, smp_processor_id());
382 current_thread_info()->status &= ~TS_POLLING; 382 current_thread_info()->status &= ~TS_POLLING;
383 /* 383 /*
384 * TS_POLLING-cleared state must be visible before we 384 * TS_POLLING-cleared state must be visible before we
@@ -391,8 +391,8 @@ void default_idle(void)
391 else 391 else
392 local_irq_enable(); 392 local_irq_enable();
393 current_thread_info()->status |= TS_POLLING; 393 current_thread_info()->status |= TS_POLLING;
394 trace_power_end(smp_processor_id()); 394 trace_power_end_rcuidle(smp_processor_id());
395 trace_cpu_idle(PWR_EVENT_EXIT, smp_processor_id()); 395 trace_cpu_idle_rcuidle(PWR_EVENT_EXIT, smp_processor_id());
396 } else { 396 } else {
397 local_irq_enable(); 397 local_irq_enable();
398 /* loop is done by the caller */ 398 /* loop is done by the caller */
@@ -450,8 +450,8 @@ EXPORT_SYMBOL_GPL(cpu_idle_wait);
450static void mwait_idle(void) 450static void mwait_idle(void)
451{ 451{
452 if (!need_resched()) { 452 if (!need_resched()) {
453 trace_power_start(POWER_CSTATE, 1, smp_processor_id()); 453 trace_power_start_rcuidle(POWER_CSTATE, 1, smp_processor_id());
454 trace_cpu_idle(1, smp_processor_id()); 454 trace_cpu_idle_rcuidle(1, smp_processor_id());
455 if (this_cpu_has(X86_FEATURE_CLFLUSH_MONITOR)) 455 if (this_cpu_has(X86_FEATURE_CLFLUSH_MONITOR))
456 clflush((void *)&current_thread_info()->flags); 456 clflush((void *)&current_thread_info()->flags);
457 457
@@ -461,8 +461,8 @@ static void mwait_idle(void)
461 __sti_mwait(0, 0); 461 __sti_mwait(0, 0);
462 else 462 else
463 local_irq_enable(); 463 local_irq_enable();
464 trace_power_end(smp_processor_id()); 464 trace_power_end_rcuidle(smp_processor_id());
465 trace_cpu_idle(PWR_EVENT_EXIT, smp_processor_id()); 465 trace_cpu_idle_rcuidle(PWR_EVENT_EXIT, smp_processor_id());
466 } else 466 } else
467 local_irq_enable(); 467 local_irq_enable();
468} 468}
@@ -474,13 +474,13 @@ static void mwait_idle(void)
474 */ 474 */
475static void poll_idle(void) 475static void poll_idle(void)
476{ 476{
477 trace_power_start(POWER_CSTATE, 0, smp_processor_id()); 477 trace_power_start_rcuidle(POWER_CSTATE, 0, smp_processor_id());
478 trace_cpu_idle(0, smp_processor_id()); 478 trace_cpu_idle_rcuidle(0, smp_processor_id());
479 local_irq_enable(); 479 local_irq_enable();
480 while (!need_resched()) 480 while (!need_resched())
481 cpu_relax(); 481 cpu_relax();
482 trace_power_end(smp_processor_id()); 482 trace_power_end_rcuidle(smp_processor_id());
483 trace_cpu_idle(PWR_EVENT_EXIT, smp_processor_id()); 483 trace_cpu_idle_rcuidle(PWR_EVENT_EXIT, smp_processor_id());
484} 484}
485 485
486/* 486/*
diff --git a/arch/x86/kernel/process_32.c b/arch/x86/kernel/process_32.c
index c08d1ff12b7c..49888fefe794 100644
--- a/arch/x86/kernel/process_32.c
+++ b/arch/x86/kernel/process_32.c
@@ -119,9 +119,7 @@ void cpu_idle(void)
119 } 119 }
120 rcu_idle_exit(); 120 rcu_idle_exit();
121 tick_nohz_idle_exit(); 121 tick_nohz_idle_exit();
122 preempt_enable_no_resched(); 122 schedule_preempt_disabled();
123 schedule();
124 preempt_disable();
125 } 123 }
126} 124}
127 125
diff --git a/arch/x86/kernel/process_64.c b/arch/x86/kernel/process_64.c
index cfa5c90c01db..e34257c70c28 100644
--- a/arch/x86/kernel/process_64.c
+++ b/arch/x86/kernel/process_64.c
@@ -156,9 +156,7 @@ void cpu_idle(void)
156 } 156 }
157 157
158 tick_nohz_idle_exit(); 158 tick_nohz_idle_exit();
159 preempt_enable_no_resched(); 159 schedule_preempt_disabled();
160 schedule();
161 preempt_disable();
162 } 160 }
163} 161}
164 162
diff --git a/arch/x86/kernel/smpboot.c b/arch/x86/kernel/smpboot.c
index 66d250c00d11..58f78165d308 100644
--- a/arch/x86/kernel/smpboot.c
+++ b/arch/x86/kernel/smpboot.c
@@ -291,19 +291,6 @@ notrace static void __cpuinit start_secondary(void *unused)
291 per_cpu(cpu_state, smp_processor_id()) = CPU_ONLINE; 291 per_cpu(cpu_state, smp_processor_id()) = CPU_ONLINE;
292 x86_platform.nmi_init(); 292 x86_platform.nmi_init();
293 293
294 /*
295 * Wait until the cpu which brought this one up marked it
296 * online before enabling interrupts. If we don't do that then
297 * we can end up waking up the softirq thread before this cpu
298 * reached the active state, which makes the scheduler unhappy
299 * and schedule the softirq thread on the wrong cpu. This is
300 * only observable with forced threaded interrupts, but in
301 * theory it could also happen w/o them. It's just way harder
302 * to achieve.
303 */
304 while (!cpumask_test_cpu(smp_processor_id(), cpu_active_mask))
305 cpu_relax();
306
307 /* enable local interrupts */ 294 /* enable local interrupts */
308 local_irq_enable(); 295 local_irq_enable();
309 296
diff --git a/arch/x86/kernel/time.c b/arch/x86/kernel/time.c
index dd5fbf4101fc..c6eba2b42673 100644
--- a/arch/x86/kernel/time.c
+++ b/arch/x86/kernel/time.c
@@ -57,9 +57,6 @@ EXPORT_SYMBOL(profile_pc);
57 */ 57 */
58static irqreturn_t timer_interrupt(int irq, void *dev_id) 58static irqreturn_t timer_interrupt(int irq, void *dev_id)
59{ 59{
60 /* Keep nmi watchdog up to date */
61 inc_irq_stat(irq0_irqs);
62
63 global_clock_event->event_handler(global_clock_event); 60 global_clock_event->event_handler(global_clock_event);
64 61
65 /* MCA bus quirk: Acknowledge irq0 by setting bit 7 in port 0x61 */ 62 /* MCA bus quirk: Acknowledge irq0 by setting bit 7 in port 0x61 */
diff --git a/arch/x86/kernel/tsc.c b/arch/x86/kernel/tsc.c
index a62c201c97ec..183c5925a9fe 100644
--- a/arch/x86/kernel/tsc.c
+++ b/arch/x86/kernel/tsc.c
@@ -620,7 +620,8 @@ static void set_cyc2ns_scale(unsigned long cpu_khz, int cpu)
620 620
621 if (cpu_khz) { 621 if (cpu_khz) {
622 *scale = (NSEC_PER_MSEC << CYC2NS_SCALE_FACTOR)/cpu_khz; 622 *scale = (NSEC_PER_MSEC << CYC2NS_SCALE_FACTOR)/cpu_khz;
623 *offset = ns_now - (tsc_now * *scale >> CYC2NS_SCALE_FACTOR); 623 *offset = ns_now - mult_frac(tsc_now, *scale,
624 (1UL << CYC2NS_SCALE_FACTOR));
624 } 625 }
625 626
626 sched_clock_idle_wakeup_event(0); 627 sched_clock_idle_wakeup_event(0);
diff --git a/arch/x86/kernel/tsc_sync.c b/arch/x86/kernel/tsc_sync.c
index 9eba29b46cb7..fc25e60a5884 100644
--- a/arch/x86/kernel/tsc_sync.c
+++ b/arch/x86/kernel/tsc_sync.c
@@ -42,7 +42,7 @@ static __cpuinitdata int nr_warps;
42/* 42/*
43 * TSC-warp measurement loop running on both CPUs: 43 * TSC-warp measurement loop running on both CPUs:
44 */ 44 */
45static __cpuinit void check_tsc_warp(void) 45static __cpuinit void check_tsc_warp(unsigned int timeout)
46{ 46{
47 cycles_t start, now, prev, end; 47 cycles_t start, now, prev, end;
48 int i; 48 int i;
@@ -51,9 +51,9 @@ static __cpuinit void check_tsc_warp(void)
51 start = get_cycles(); 51 start = get_cycles();
52 rdtsc_barrier(); 52 rdtsc_barrier();
53 /* 53 /*
54 * The measurement runs for 20 msecs: 54 * The measurement runs for 'timeout' msecs:
55 */ 55 */
56 end = start + tsc_khz * 20ULL; 56 end = start + (cycles_t) tsc_khz * timeout;
57 now = start; 57 now = start;
58 58
59 for (i = 0; ; i++) { 59 for (i = 0; ; i++) {
@@ -99,6 +99,25 @@ static __cpuinit void check_tsc_warp(void)
99} 99}
100 100
101/* 101/*
102 * If the target CPU coming online doesn't have any of its core-siblings
103 * online, a timeout of 20msec will be used for the TSC-warp measurement
104 * loop. Otherwise a smaller timeout of 2msec will be used, as we have some
105 * information about this socket already (and this information grows as we
106 * have more and more logical-siblings in that socket).
107 *
108 * Ideally we should be able to skip the TSC sync check on the other
109 * core-siblings, if the first logical CPU in a socket passed the sync test.
110 * But as the TSC is per-logical CPU and can potentially be modified wrongly
111 * by the bios, TSC sync test for smaller duration should be able
112 * to catch such errors. Also this will catch the condition where all the
113 * cores in the socket doesn't get reset at the same time.
114 */
115static inline unsigned int loop_timeout(int cpu)
116{
117 return (cpumask_weight(cpu_core_mask(cpu)) > 1) ? 2 : 20;
118}
119
120/*
102 * Source CPU calls into this - it waits for the freshly booted 121 * Source CPU calls into this - it waits for the freshly booted
103 * target CPU to arrive and then starts the measurement: 122 * target CPU to arrive and then starts the measurement:
104 */ 123 */
@@ -135,7 +154,7 @@ void __cpuinit check_tsc_sync_source(int cpu)
135 */ 154 */
136 atomic_inc(&start_count); 155 atomic_inc(&start_count);
137 156
138 check_tsc_warp(); 157 check_tsc_warp(loop_timeout(cpu));
139 158
140 while (atomic_read(&stop_count) != cpus-1) 159 while (atomic_read(&stop_count) != cpus-1)
141 cpu_relax(); 160 cpu_relax();
@@ -183,7 +202,7 @@ void __cpuinit check_tsc_sync_target(void)
183 while (atomic_read(&start_count) != cpus) 202 while (atomic_read(&start_count) != cpus)
184 cpu_relax(); 203 cpu_relax();
185 204
186 check_tsc_warp(); 205 check_tsc_warp(loop_timeout(smp_processor_id()));
187 206
188 /* 207 /*
189 * Ok, we are done: 208 * Ok, we are done:
diff --git a/arch/x86/kvm/mmu_audit.c b/arch/x86/kvm/mmu_audit.c
index fe15dcc07a6b..ea7b4fd34676 100644
--- a/arch/x86/kvm/mmu_audit.c
+++ b/arch/x86/kvm/mmu_audit.c
@@ -234,7 +234,7 @@ static void audit_vcpu_spte(struct kvm_vcpu *vcpu)
234} 234}
235 235
236static bool mmu_audit; 236static bool mmu_audit;
237static struct jump_label_key mmu_audit_key; 237static struct static_key mmu_audit_key;
238 238
239static void __kvm_mmu_audit(struct kvm_vcpu *vcpu, int point) 239static void __kvm_mmu_audit(struct kvm_vcpu *vcpu, int point)
240{ 240{
@@ -250,7 +250,7 @@ static void __kvm_mmu_audit(struct kvm_vcpu *vcpu, int point)
250 250
251static inline void kvm_mmu_audit(struct kvm_vcpu *vcpu, int point) 251static inline void kvm_mmu_audit(struct kvm_vcpu *vcpu, int point)
252{ 252{
253 if (static_branch((&mmu_audit_key))) 253 if (static_key_false((&mmu_audit_key)))
254 __kvm_mmu_audit(vcpu, point); 254 __kvm_mmu_audit(vcpu, point);
255} 255}
256 256
@@ -259,7 +259,7 @@ static void mmu_audit_enable(void)
259 if (mmu_audit) 259 if (mmu_audit)
260 return; 260 return;
261 261
262 jump_label_inc(&mmu_audit_key); 262 static_key_slow_inc(&mmu_audit_key);
263 mmu_audit = true; 263 mmu_audit = true;
264} 264}
265 265
@@ -268,7 +268,7 @@ static void mmu_audit_disable(void)
268 if (!mmu_audit) 268 if (!mmu_audit)
269 return; 269 return;
270 270
271 jump_label_dec(&mmu_audit_key); 271 static_key_slow_dec(&mmu_audit_key);
272 mmu_audit = false; 272 mmu_audit = false;
273} 273}
274 274
diff --git a/arch/x86/lib/inat.c b/arch/x86/lib/inat.c
index 88ad5fbda6e1..c1f01a8e9f65 100644
--- a/arch/x86/lib/inat.c
+++ b/arch/x86/lib/inat.c
@@ -29,46 +29,46 @@ insn_attr_t inat_get_opcode_attribute(insn_byte_t opcode)
29 return inat_primary_table[opcode]; 29 return inat_primary_table[opcode];
30} 30}
31 31
32insn_attr_t inat_get_escape_attribute(insn_byte_t opcode, insn_byte_t last_pfx, 32int inat_get_last_prefix_id(insn_byte_t last_pfx)
33{
34 insn_attr_t lpfx_attr;
35
36 lpfx_attr = inat_get_opcode_attribute(last_pfx);
37 return inat_last_prefix_id(lpfx_attr);
38}
39
40insn_attr_t inat_get_escape_attribute(insn_byte_t opcode, int lpfx_id,
33 insn_attr_t esc_attr) 41 insn_attr_t esc_attr)
34{ 42{
35 const insn_attr_t *table; 43 const insn_attr_t *table;
36 insn_attr_t lpfx_attr; 44 int n;
37 int n, m = 0;
38 45
39 n = inat_escape_id(esc_attr); 46 n = inat_escape_id(esc_attr);
40 if (last_pfx) { 47
41 lpfx_attr = inat_get_opcode_attribute(last_pfx);
42 m = inat_last_prefix_id(lpfx_attr);
43 }
44 table = inat_escape_tables[n][0]; 48 table = inat_escape_tables[n][0];
45 if (!table) 49 if (!table)
46 return 0; 50 return 0;
47 if (inat_has_variant(table[opcode]) && m) { 51 if (inat_has_variant(table[opcode]) && lpfx_id) {
48 table = inat_escape_tables[n][m]; 52 table = inat_escape_tables[n][lpfx_id];
49 if (!table) 53 if (!table)
50 return 0; 54 return 0;
51 } 55 }
52 return table[opcode]; 56 return table[opcode];
53} 57}
54 58
55insn_attr_t inat_get_group_attribute(insn_byte_t modrm, insn_byte_t last_pfx, 59insn_attr_t inat_get_group_attribute(insn_byte_t modrm, int lpfx_id,
56 insn_attr_t grp_attr) 60 insn_attr_t grp_attr)
57{ 61{
58 const insn_attr_t *table; 62 const insn_attr_t *table;
59 insn_attr_t lpfx_attr; 63 int n;
60 int n, m = 0;
61 64
62 n = inat_group_id(grp_attr); 65 n = inat_group_id(grp_attr);
63 if (last_pfx) { 66
64 lpfx_attr = inat_get_opcode_attribute(last_pfx);
65 m = inat_last_prefix_id(lpfx_attr);
66 }
67 table = inat_group_tables[n][0]; 67 table = inat_group_tables[n][0];
68 if (!table) 68 if (!table)
69 return inat_group_common_attribute(grp_attr); 69 return inat_group_common_attribute(grp_attr);
70 if (inat_has_variant(table[X86_MODRM_REG(modrm)]) && m) { 70 if (inat_has_variant(table[X86_MODRM_REG(modrm)]) && lpfx_id) {
71 table = inat_group_tables[n][m]; 71 table = inat_group_tables[n][lpfx_id];
72 if (!table) 72 if (!table)
73 return inat_group_common_attribute(grp_attr); 73 return inat_group_common_attribute(grp_attr);
74 } 74 }
diff --git a/arch/x86/lib/insn.c b/arch/x86/lib/insn.c
index 5a1f9f3e3fbb..25feb1ae71c5 100644
--- a/arch/x86/lib/insn.c
+++ b/arch/x86/lib/insn.c
@@ -185,7 +185,8 @@ err_out:
185void insn_get_opcode(struct insn *insn) 185void insn_get_opcode(struct insn *insn)
186{ 186{
187 struct insn_field *opcode = &insn->opcode; 187 struct insn_field *opcode = &insn->opcode;
188 insn_byte_t op, pfx; 188 insn_byte_t op;
189 int pfx_id;
189 if (opcode->got) 190 if (opcode->got)
190 return; 191 return;
191 if (!insn->prefixes.got) 192 if (!insn->prefixes.got)
@@ -212,8 +213,8 @@ void insn_get_opcode(struct insn *insn)
212 /* Get escaped opcode */ 213 /* Get escaped opcode */
213 op = get_next(insn_byte_t, insn); 214 op = get_next(insn_byte_t, insn);
214 opcode->bytes[opcode->nbytes++] = op; 215 opcode->bytes[opcode->nbytes++] = op;
215 pfx = insn_last_prefix(insn); 216 pfx_id = insn_last_prefix_id(insn);
216 insn->attr = inat_get_escape_attribute(op, pfx, insn->attr); 217 insn->attr = inat_get_escape_attribute(op, pfx_id, insn->attr);
217 } 218 }
218 if (inat_must_vex(insn->attr)) 219 if (inat_must_vex(insn->attr))
219 insn->attr = 0; /* This instruction is bad */ 220 insn->attr = 0; /* This instruction is bad */
@@ -235,7 +236,7 @@ err_out:
235void insn_get_modrm(struct insn *insn) 236void insn_get_modrm(struct insn *insn)
236{ 237{
237 struct insn_field *modrm = &insn->modrm; 238 struct insn_field *modrm = &insn->modrm;
238 insn_byte_t pfx, mod; 239 insn_byte_t pfx_id, mod;
239 if (modrm->got) 240 if (modrm->got)
240 return; 241 return;
241 if (!insn->opcode.got) 242 if (!insn->opcode.got)
@@ -246,8 +247,8 @@ void insn_get_modrm(struct insn *insn)
246 modrm->value = mod; 247 modrm->value = mod;
247 modrm->nbytes = 1; 248 modrm->nbytes = 1;
248 if (inat_is_group(insn->attr)) { 249 if (inat_is_group(insn->attr)) {
249 pfx = insn_last_prefix(insn); 250 pfx_id = insn_last_prefix_id(insn);
250 insn->attr = inat_get_group_attribute(mod, pfx, 251 insn->attr = inat_get_group_attribute(mod, pfx_id,
251 insn->attr); 252 insn->attr);
252 if (insn_is_avx(insn) && !inat_accept_vex(insn->attr)) 253 if (insn_is_avx(insn) && !inat_accept_vex(insn->attr))
253 insn->attr = 0; /* This is bad */ 254 insn->attr = 0; /* This is bad */
diff --git a/arch/xtensa/kernel/process.c b/arch/xtensa/kernel/process.c
index 47041e7c088c..2c9004770c4e 100644
--- a/arch/xtensa/kernel/process.c
+++ b/arch/xtensa/kernel/process.c
@@ -113,9 +113,7 @@ void cpu_idle(void)
113 while (1) { 113 while (1) {
114 while (!need_resched()) 114 while (!need_resched())
115 platform_idle(); 115 platform_idle();
116 preempt_enable_no_resched(); 116 schedule_preempt_disabled();
117 schedule();
118 preempt_disable();
119 } 117 }
120} 118}
121 119
diff --git a/block/blk-ioc.c b/block/blk-ioc.c
index 8b782a63c297..fb95dd2f889a 100644
--- a/block/blk-ioc.c
+++ b/block/blk-ioc.c
@@ -36,11 +36,23 @@ static void icq_free_icq_rcu(struct rcu_head *head)
36 kmem_cache_free(icq->__rcu_icq_cache, icq); 36 kmem_cache_free(icq->__rcu_icq_cache, icq);
37} 37}
38 38
39/* 39/* Exit an icq. Called with both ioc and q locked. */
40 * Exit and free an icq. Called with both ioc and q locked.
41 */
42static void ioc_exit_icq(struct io_cq *icq) 40static void ioc_exit_icq(struct io_cq *icq)
43{ 41{
42 struct elevator_type *et = icq->q->elevator->type;
43
44 if (icq->flags & ICQ_EXITED)
45 return;
46
47 if (et->ops.elevator_exit_icq_fn)
48 et->ops.elevator_exit_icq_fn(icq);
49
50 icq->flags |= ICQ_EXITED;
51}
52
53/* Release an icq. Called with both ioc and q locked. */
54static void ioc_destroy_icq(struct io_cq *icq)
55{
44 struct io_context *ioc = icq->ioc; 56 struct io_context *ioc = icq->ioc;
45 struct request_queue *q = icq->q; 57 struct request_queue *q = icq->q;
46 struct elevator_type *et = q->elevator->type; 58 struct elevator_type *et = q->elevator->type;
@@ -60,8 +72,7 @@ static void ioc_exit_icq(struct io_cq *icq)
60 if (rcu_dereference_raw(ioc->icq_hint) == icq) 72 if (rcu_dereference_raw(ioc->icq_hint) == icq)
61 rcu_assign_pointer(ioc->icq_hint, NULL); 73 rcu_assign_pointer(ioc->icq_hint, NULL);
62 74
63 if (et->ops.elevator_exit_icq_fn) 75 ioc_exit_icq(icq);
64 et->ops.elevator_exit_icq_fn(icq);
65 76
66 /* 77 /*
67 * @icq->q might have gone away by the time RCU callback runs 78 * @icq->q might have gone away by the time RCU callback runs
@@ -79,7 +90,6 @@ static void ioc_release_fn(struct work_struct *work)
79{ 90{
80 struct io_context *ioc = container_of(work, struct io_context, 91 struct io_context *ioc = container_of(work, struct io_context,
81 release_work); 92 release_work);
82 struct request_queue *last_q = NULL;
83 unsigned long flags; 93 unsigned long flags;
84 94
85 /* 95 /*
@@ -93,44 +103,19 @@ static void ioc_release_fn(struct work_struct *work)
93 while (!hlist_empty(&ioc->icq_list)) { 103 while (!hlist_empty(&ioc->icq_list)) {
94 struct io_cq *icq = hlist_entry(ioc->icq_list.first, 104 struct io_cq *icq = hlist_entry(ioc->icq_list.first,
95 struct io_cq, ioc_node); 105 struct io_cq, ioc_node);
96 struct request_queue *this_q = icq->q; 106 struct request_queue *q = icq->q;
97 107
98 if (this_q != last_q) { 108 if (spin_trylock(q->queue_lock)) {
99 /* 109 ioc_destroy_icq(icq);
100 * Need to switch to @this_q. Once we release 110 spin_unlock(q->queue_lock);
101 * @ioc->lock, it can go away along with @cic. 111 } else {
102 * Hold on to it. 112 spin_unlock_irqrestore(&ioc->lock, flags);
103 */ 113 cpu_relax();
104 __blk_get_queue(this_q); 114 spin_lock_irqsave_nested(&ioc->lock, flags, 1);
105
106 /*
107 * blk_put_queue() might sleep thanks to kobject
108 * idiocy. Always release both locks, put and
109 * restart.
110 */
111 if (last_q) {
112 spin_unlock(last_q->queue_lock);
113 spin_unlock_irqrestore(&ioc->lock, flags);
114 blk_put_queue(last_q);
115 } else {
116 spin_unlock_irqrestore(&ioc->lock, flags);
117 }
118
119 last_q = this_q;
120 spin_lock_irqsave(this_q->queue_lock, flags);
121 spin_lock_nested(&ioc->lock, 1);
122 continue;
123 } 115 }
124 ioc_exit_icq(icq);
125 } 116 }
126 117
127 if (last_q) { 118 spin_unlock_irqrestore(&ioc->lock, flags);
128 spin_unlock(last_q->queue_lock);
129 spin_unlock_irqrestore(&ioc->lock, flags);
130 blk_put_queue(last_q);
131 } else {
132 spin_unlock_irqrestore(&ioc->lock, flags);
133 }
134 119
135 kmem_cache_free(iocontext_cachep, ioc); 120 kmem_cache_free(iocontext_cachep, ioc);
136} 121}
@@ -145,6 +130,7 @@ static void ioc_release_fn(struct work_struct *work)
145void put_io_context(struct io_context *ioc) 130void put_io_context(struct io_context *ioc)
146{ 131{
147 unsigned long flags; 132 unsigned long flags;
133 bool free_ioc = false;
148 134
149 if (ioc == NULL) 135 if (ioc == NULL)
150 return; 136 return;
@@ -159,8 +145,13 @@ void put_io_context(struct io_context *ioc)
159 spin_lock_irqsave(&ioc->lock, flags); 145 spin_lock_irqsave(&ioc->lock, flags);
160 if (!hlist_empty(&ioc->icq_list)) 146 if (!hlist_empty(&ioc->icq_list))
161 schedule_work(&ioc->release_work); 147 schedule_work(&ioc->release_work);
148 else
149 free_ioc = true;
162 spin_unlock_irqrestore(&ioc->lock, flags); 150 spin_unlock_irqrestore(&ioc->lock, flags);
163 } 151 }
152
153 if (free_ioc)
154 kmem_cache_free(iocontext_cachep, ioc);
164} 155}
165EXPORT_SYMBOL(put_io_context); 156EXPORT_SYMBOL(put_io_context);
166 157
@@ -168,13 +159,41 @@ EXPORT_SYMBOL(put_io_context);
168void exit_io_context(struct task_struct *task) 159void exit_io_context(struct task_struct *task)
169{ 160{
170 struct io_context *ioc; 161 struct io_context *ioc;
162 struct io_cq *icq;
163 struct hlist_node *n;
164 unsigned long flags;
171 165
172 task_lock(task); 166 task_lock(task);
173 ioc = task->io_context; 167 ioc = task->io_context;
174 task->io_context = NULL; 168 task->io_context = NULL;
175 task_unlock(task); 169 task_unlock(task);
176 170
177 atomic_dec(&ioc->nr_tasks); 171 if (!atomic_dec_and_test(&ioc->nr_tasks)) {
172 put_io_context(ioc);
173 return;
174 }
175
176 /*
177 * Need ioc lock to walk icq_list and q lock to exit icq. Perform
178 * reverse double locking. Read comment in ioc_release_fn() for
179 * explanation on the nested locking annotation.
180 */
181retry:
182 spin_lock_irqsave_nested(&ioc->lock, flags, 1);
183 hlist_for_each_entry(icq, n, &ioc->icq_list, ioc_node) {
184 if (icq->flags & ICQ_EXITED)
185 continue;
186 if (spin_trylock(icq->q->queue_lock)) {
187 ioc_exit_icq(icq);
188 spin_unlock(icq->q->queue_lock);
189 } else {
190 spin_unlock_irqrestore(&ioc->lock, flags);
191 cpu_relax();
192 goto retry;
193 }
194 }
195 spin_unlock_irqrestore(&ioc->lock, flags);
196
178 put_io_context(ioc); 197 put_io_context(ioc);
179} 198}
180 199
@@ -194,7 +213,7 @@ void ioc_clear_queue(struct request_queue *q)
194 struct io_context *ioc = icq->ioc; 213 struct io_context *ioc = icq->ioc;
195 214
196 spin_lock(&ioc->lock); 215 spin_lock(&ioc->lock);
197 ioc_exit_icq(icq); 216 ioc_destroy_icq(icq);
198 spin_unlock(&ioc->lock); 217 spin_unlock(&ioc->lock);
199 } 218 }
200} 219}
@@ -363,13 +382,13 @@ struct io_cq *ioc_create_icq(struct request_queue *q, gfp_t gfp_mask)
363 return icq; 382 return icq;
364} 383}
365 384
366void ioc_set_changed(struct io_context *ioc, int which) 385void ioc_set_icq_flags(struct io_context *ioc, unsigned int flags)
367{ 386{
368 struct io_cq *icq; 387 struct io_cq *icq;
369 struct hlist_node *n; 388 struct hlist_node *n;
370 389
371 hlist_for_each_entry(icq, n, &ioc->icq_list, ioc_node) 390 hlist_for_each_entry(icq, n, &ioc->icq_list, ioc_node)
372 set_bit(which, &icq->changed); 391 icq->flags |= flags;
373} 392}
374 393
375/** 394/**
@@ -387,7 +406,7 @@ void ioc_ioprio_changed(struct io_context *ioc, int ioprio)
387 406
388 spin_lock_irqsave(&ioc->lock, flags); 407 spin_lock_irqsave(&ioc->lock, flags);
389 ioc->ioprio = ioprio; 408 ioc->ioprio = ioprio;
390 ioc_set_changed(ioc, ICQ_IOPRIO_CHANGED); 409 ioc_set_icq_flags(ioc, ICQ_IOPRIO_CHANGED);
391 spin_unlock_irqrestore(&ioc->lock, flags); 410 spin_unlock_irqrestore(&ioc->lock, flags);
392} 411}
393 412
@@ -404,11 +423,33 @@ void ioc_cgroup_changed(struct io_context *ioc)
404 unsigned long flags; 423 unsigned long flags;
405 424
406 spin_lock_irqsave(&ioc->lock, flags); 425 spin_lock_irqsave(&ioc->lock, flags);
407 ioc_set_changed(ioc, ICQ_CGROUP_CHANGED); 426 ioc_set_icq_flags(ioc, ICQ_CGROUP_CHANGED);
408 spin_unlock_irqrestore(&ioc->lock, flags); 427 spin_unlock_irqrestore(&ioc->lock, flags);
409} 428}
410EXPORT_SYMBOL(ioc_cgroup_changed); 429EXPORT_SYMBOL(ioc_cgroup_changed);
411 430
431/**
432 * icq_get_changed - fetch and clear icq changed mask
433 * @icq: icq of interest
434 *
435 * Fetch and clear ICQ_*_CHANGED bits from @icq. Grabs and releases
436 * @icq->ioc->lock.
437 */
438unsigned icq_get_changed(struct io_cq *icq)
439{
440 unsigned int changed = 0;
441 unsigned long flags;
442
443 if (unlikely(icq->flags & ICQ_CHANGED_MASK)) {
444 spin_lock_irqsave(&icq->ioc->lock, flags);
445 changed = icq->flags & ICQ_CHANGED_MASK;
446 icq->flags &= ~ICQ_CHANGED_MASK;
447 spin_unlock_irqrestore(&icq->ioc->lock, flags);
448 }
449 return changed;
450}
451EXPORT_SYMBOL(icq_get_changed);
452
412static int __init blk_ioc_init(void) 453static int __init blk_ioc_init(void)
413{ 454{
414 iocontext_cachep = kmem_cache_create("blkdev_ioc", 455 iocontext_cachep = kmem_cache_create("blkdev_ioc",
diff --git a/block/blk-softirq.c b/block/blk-softirq.c
index 1366a89d8e66..467c8de88642 100644
--- a/block/blk-softirq.c
+++ b/block/blk-softirq.c
@@ -8,6 +8,7 @@
8#include <linux/blkdev.h> 8#include <linux/blkdev.h>
9#include <linux/interrupt.h> 9#include <linux/interrupt.h>
10#include <linux/cpu.h> 10#include <linux/cpu.h>
11#include <linux/sched.h>
11 12
12#include "blk.h" 13#include "blk.h"
13 14
@@ -103,9 +104,10 @@ static struct notifier_block __cpuinitdata blk_cpu_notifier = {
103 104
104void __blk_complete_request(struct request *req) 105void __blk_complete_request(struct request *req)
105{ 106{
106 int ccpu, cpu, group_cpu = NR_CPUS; 107 int ccpu, cpu;
107 struct request_queue *q = req->q; 108 struct request_queue *q = req->q;
108 unsigned long flags; 109 unsigned long flags;
110 bool shared = false;
109 111
110 BUG_ON(!q->softirq_done_fn); 112 BUG_ON(!q->softirq_done_fn);
111 113
@@ -117,22 +119,20 @@ void __blk_complete_request(struct request *req)
117 */ 119 */
118 if (req->cpu != -1) { 120 if (req->cpu != -1) {
119 ccpu = req->cpu; 121 ccpu = req->cpu;
120 if (!test_bit(QUEUE_FLAG_SAME_FORCE, &q->queue_flags)) { 122 if (!test_bit(QUEUE_FLAG_SAME_FORCE, &q->queue_flags))
121 ccpu = blk_cpu_to_group(ccpu); 123 shared = cpus_share_cache(cpu, ccpu);
122 group_cpu = blk_cpu_to_group(cpu);
123 }
124 } else 124 } else
125 ccpu = cpu; 125 ccpu = cpu;
126 126
127 /* 127 /*
128 * If current CPU and requested CPU are in the same group, running 128 * If current CPU and requested CPU share a cache, run the softirq on
129 * softirq in current CPU. One might concern this is just like 129 * the current CPU. One might concern this is just like
130 * QUEUE_FLAG_SAME_FORCE, but actually not. blk_complete_request() is 130 * QUEUE_FLAG_SAME_FORCE, but actually not. blk_complete_request() is
131 * running in interrupt handler, and currently I/O controller doesn't 131 * running in interrupt handler, and currently I/O controller doesn't
132 * support multiple interrupts, so current CPU is unique actually. This 132 * support multiple interrupts, so current CPU is unique actually. This
133 * avoids IPI sending from current CPU to the first CPU of a group. 133 * avoids IPI sending from current CPU to the first CPU of a group.
134 */ 134 */
135 if (ccpu == cpu || ccpu == group_cpu) { 135 if (ccpu == cpu || shared) {
136 struct list_head *list; 136 struct list_head *list;
137do_local: 137do_local:
138 list = &__get_cpu_var(blk_cpu_done); 138 list = &__get_cpu_var(blk_cpu_done);
diff --git a/block/blk.h b/block/blk.h
index 9c12f80882b0..d45be871329e 100644
--- a/block/blk.h
+++ b/block/blk.h
@@ -166,22 +166,6 @@ static inline int queue_congestion_off_threshold(struct request_queue *q)
166 return q->nr_congestion_off; 166 return q->nr_congestion_off;
167} 167}
168 168
169static inline int blk_cpu_to_group(int cpu)
170{
171 int group = NR_CPUS;
172#ifdef CONFIG_SCHED_MC
173 const struct cpumask *mask = cpu_coregroup_mask(cpu);
174 group = cpumask_first(mask);
175#elif defined(CONFIG_SCHED_SMT)
176 group = cpumask_first(topology_thread_cpumask(cpu));
177#else
178 return cpu;
179#endif
180 if (likely(group < NR_CPUS))
181 return group;
182 return cpu;
183}
184
185/* 169/*
186 * Contribute to IO statistics IFF: 170 * Contribute to IO statistics IFF:
187 * 171 *
diff --git a/block/cfq-iosched.c b/block/cfq-iosched.c
index d0ba50533668..457295253566 100644
--- a/block/cfq-iosched.c
+++ b/block/cfq-iosched.c
@@ -3470,20 +3470,20 @@ cfq_set_request(struct request_queue *q, struct request *rq, gfp_t gfp_mask)
3470 const int rw = rq_data_dir(rq); 3470 const int rw = rq_data_dir(rq);
3471 const bool is_sync = rq_is_sync(rq); 3471 const bool is_sync = rq_is_sync(rq);
3472 struct cfq_queue *cfqq; 3472 struct cfq_queue *cfqq;
3473 unsigned int changed;
3473 3474
3474 might_sleep_if(gfp_mask & __GFP_WAIT); 3475 might_sleep_if(gfp_mask & __GFP_WAIT);
3475 3476
3476 spin_lock_irq(q->queue_lock); 3477 spin_lock_irq(q->queue_lock);
3477 3478
3478 /* handle changed notifications */ 3479 /* handle changed notifications */
3479 if (unlikely(cic->icq.changed)) { 3480 changed = icq_get_changed(&cic->icq);
3480 if (test_and_clear_bit(ICQ_IOPRIO_CHANGED, &cic->icq.changed)) 3481 if (unlikely(changed & ICQ_IOPRIO_CHANGED))
3481 changed_ioprio(cic); 3482 changed_ioprio(cic);
3482#ifdef CONFIG_CFQ_GROUP_IOSCHED 3483#ifdef CONFIG_CFQ_GROUP_IOSCHED
3483 if (test_and_clear_bit(ICQ_CGROUP_CHANGED, &cic->icq.changed)) 3484 if (unlikely(changed & ICQ_CGROUP_CHANGED))
3484 changed_cgroup(cic); 3485 changed_cgroup(cic);
3485#endif 3486#endif
3486 }
3487 3487
3488new_queue: 3488new_queue:
3489 cfqq = cic_to_cfqq(cic, is_sync); 3489 cfqq = cic_to_cfqq(cic, is_sync);
diff --git a/block/genhd.c b/block/genhd.c
index 23b4f7063322..df9816ede75b 100644
--- a/block/genhd.c
+++ b/block/genhd.c
@@ -35,6 +35,7 @@ static DEFINE_IDR(ext_devt_idr);
35 35
36static struct device_type disk_type; 36static struct device_type disk_type;
37 37
38static void disk_alloc_events(struct gendisk *disk);
38static void disk_add_events(struct gendisk *disk); 39static void disk_add_events(struct gendisk *disk);
39static void disk_del_events(struct gendisk *disk); 40static void disk_del_events(struct gendisk *disk);
40static void disk_release_events(struct gendisk *disk); 41static void disk_release_events(struct gendisk *disk);
@@ -601,6 +602,8 @@ void add_disk(struct gendisk *disk)
601 disk->major = MAJOR(devt); 602 disk->major = MAJOR(devt);
602 disk->first_minor = MINOR(devt); 603 disk->first_minor = MINOR(devt);
603 604
605 disk_alloc_events(disk);
606
604 /* Register BDI before referencing it from bdev */ 607 /* Register BDI before referencing it from bdev */
605 bdi = &disk->queue->backing_dev_info; 608 bdi = &disk->queue->backing_dev_info;
606 bdi_register_dev(bdi, disk_devt(disk)); 609 bdi_register_dev(bdi, disk_devt(disk));
@@ -1475,9 +1478,9 @@ static void __disk_unblock_events(struct gendisk *disk, bool check_now)
1475 intv = disk_events_poll_jiffies(disk); 1478 intv = disk_events_poll_jiffies(disk);
1476 set_timer_slack(&ev->dwork.timer, intv / 4); 1479 set_timer_slack(&ev->dwork.timer, intv / 4);
1477 if (check_now) 1480 if (check_now)
1478 queue_delayed_work(system_nrt_wq, &ev->dwork, 0); 1481 queue_delayed_work(system_nrt_freezable_wq, &ev->dwork, 0);
1479 else if (intv) 1482 else if (intv)
1480 queue_delayed_work(system_nrt_wq, &ev->dwork, intv); 1483 queue_delayed_work(system_nrt_freezable_wq, &ev->dwork, intv);
1481out_unlock: 1484out_unlock:
1482 spin_unlock_irqrestore(&ev->lock, flags); 1485 spin_unlock_irqrestore(&ev->lock, flags);
1483} 1486}
@@ -1521,7 +1524,7 @@ void disk_flush_events(struct gendisk *disk, unsigned int mask)
1521 ev->clearing |= mask; 1524 ev->clearing |= mask;
1522 if (!ev->block) { 1525 if (!ev->block) {
1523 cancel_delayed_work(&ev->dwork); 1526 cancel_delayed_work(&ev->dwork);
1524 queue_delayed_work(system_nrt_wq, &ev->dwork, 0); 1527 queue_delayed_work(system_nrt_freezable_wq, &ev->dwork, 0);
1525 } 1528 }
1526 spin_unlock_irq(&ev->lock); 1529 spin_unlock_irq(&ev->lock);
1527} 1530}
@@ -1558,7 +1561,7 @@ unsigned int disk_clear_events(struct gendisk *disk, unsigned int mask)
1558 1561
1559 /* uncondtionally schedule event check and wait for it to finish */ 1562 /* uncondtionally schedule event check and wait for it to finish */
1560 disk_block_events(disk); 1563 disk_block_events(disk);
1561 queue_delayed_work(system_nrt_wq, &ev->dwork, 0); 1564 queue_delayed_work(system_nrt_freezable_wq, &ev->dwork, 0);
1562 flush_delayed_work(&ev->dwork); 1565 flush_delayed_work(&ev->dwork);
1563 __disk_unblock_events(disk, false); 1566 __disk_unblock_events(disk, false);
1564 1567
@@ -1595,7 +1598,7 @@ static void disk_events_workfn(struct work_struct *work)
1595 1598
1596 intv = disk_events_poll_jiffies(disk); 1599 intv = disk_events_poll_jiffies(disk);
1597 if (!ev->block && intv) 1600 if (!ev->block && intv)
1598 queue_delayed_work(system_nrt_wq, &ev->dwork, intv); 1601 queue_delayed_work(system_nrt_freezable_wq, &ev->dwork, intv);
1599 1602
1600 spin_unlock_irq(&ev->lock); 1603 spin_unlock_irq(&ev->lock);
1601 1604
@@ -1733,9 +1736,9 @@ module_param_cb(events_dfl_poll_msecs, &disk_events_dfl_poll_msecs_param_ops,
1733 &disk_events_dfl_poll_msecs, 0644); 1736 &disk_events_dfl_poll_msecs, 0644);
1734 1737
1735/* 1738/*
1736 * disk_{add|del|release}_events - initialize and destroy disk_events. 1739 * disk_{alloc|add|del|release}_events - initialize and destroy disk_events.
1737 */ 1740 */
1738static void disk_add_events(struct gendisk *disk) 1741static void disk_alloc_events(struct gendisk *disk)
1739{ 1742{
1740 struct disk_events *ev; 1743 struct disk_events *ev;
1741 1744
@@ -1748,16 +1751,6 @@ static void disk_add_events(struct gendisk *disk)
1748 return; 1751 return;
1749 } 1752 }
1750 1753
1751 if (sysfs_create_files(&disk_to_dev(disk)->kobj,
1752 disk_events_attrs) < 0) {
1753 pr_warn("%s: failed to create sysfs files for events\n",
1754 disk->disk_name);
1755 kfree(ev);
1756 return;
1757 }
1758
1759 disk->ev = ev;
1760
1761 INIT_LIST_HEAD(&ev->node); 1754 INIT_LIST_HEAD(&ev->node);
1762 ev->disk = disk; 1755 ev->disk = disk;
1763 spin_lock_init(&ev->lock); 1756 spin_lock_init(&ev->lock);
@@ -1766,8 +1759,21 @@ static void disk_add_events(struct gendisk *disk)
1766 ev->poll_msecs = -1; 1759 ev->poll_msecs = -1;
1767 INIT_DELAYED_WORK(&ev->dwork, disk_events_workfn); 1760 INIT_DELAYED_WORK(&ev->dwork, disk_events_workfn);
1768 1761
1762 disk->ev = ev;
1763}
1764
1765static void disk_add_events(struct gendisk *disk)
1766{
1767 if (!disk->ev)
1768 return;
1769
1770 /* FIXME: error handling */
1771 if (sysfs_create_files(&disk_to_dev(disk)->kobj, disk_events_attrs) < 0)
1772 pr_warn("%s: failed to create sysfs files for events\n",
1773 disk->disk_name);
1774
1769 mutex_lock(&disk_events_mutex); 1775 mutex_lock(&disk_events_mutex);
1770 list_add_tail(&ev->node, &disk_events); 1776 list_add_tail(&disk->ev->node, &disk_events);
1771 mutex_unlock(&disk_events_mutex); 1777 mutex_unlock(&disk_events_mutex);
1772 1778
1773 /* 1779 /*
diff --git a/block/partition-generic.c b/block/partition-generic.c
index d06ec1c829c2..6df5d6928a44 100644
--- a/block/partition-generic.c
+++ b/block/partition-generic.c
@@ -389,17 +389,11 @@ static bool disk_unlock_native_capacity(struct gendisk *disk)
389 } 389 }
390} 390}
391 391
392int rescan_partitions(struct gendisk *disk, struct block_device *bdev) 392static int drop_partitions(struct gendisk *disk, struct block_device *bdev)
393{ 393{
394 struct parsed_partitions *state = NULL;
395 struct disk_part_iter piter; 394 struct disk_part_iter piter;
396 struct hd_struct *part; 395 struct hd_struct *part;
397 int p, highest, res; 396 int res;
398rescan:
399 if (state && !IS_ERR(state)) {
400 kfree(state);
401 state = NULL;
402 }
403 397
404 if (bdev->bd_part_count) 398 if (bdev->bd_part_count)
405 return -EBUSY; 399 return -EBUSY;
@@ -412,6 +406,24 @@ rescan:
412 delete_partition(disk, part->partno); 406 delete_partition(disk, part->partno);
413 disk_part_iter_exit(&piter); 407 disk_part_iter_exit(&piter);
414 408
409 return 0;
410}
411
412int rescan_partitions(struct gendisk *disk, struct block_device *bdev)
413{
414 struct parsed_partitions *state = NULL;
415 struct hd_struct *part;
416 int p, highest, res;
417rescan:
418 if (state && !IS_ERR(state)) {
419 kfree(state);
420 state = NULL;
421 }
422
423 res = drop_partitions(disk, bdev);
424 if (res)
425 return res;
426
415 if (disk->fops->revalidate_disk) 427 if (disk->fops->revalidate_disk)
416 disk->fops->revalidate_disk(disk); 428 disk->fops->revalidate_disk(disk);
417 check_disk_size_change(disk, bdev); 429 check_disk_size_change(disk, bdev);
@@ -515,6 +527,26 @@ rescan:
515 return 0; 527 return 0;
516} 528}
517 529
530int invalidate_partitions(struct gendisk *disk, struct block_device *bdev)
531{
532 int res;
533
534 if (!bdev->bd_invalidated)
535 return 0;
536
537 res = drop_partitions(disk, bdev);
538 if (res)
539 return res;
540
541 set_capacity(disk, 0);
542 check_disk_size_change(disk, bdev);
543 bdev->bd_invalidated = 0;
544 /* tell userspace that the media / partition table may have changed */
545 kobject_uevent(&disk_to_dev(disk)->kobj, KOBJ_CHANGE);
546
547 return 0;
548}
549
518unsigned char *read_dev_sector(struct block_device *bdev, sector_t n, Sector *p) 550unsigned char *read_dev_sector(struct block_device *bdev, sector_t n, Sector *p)
519{ 551{
520 struct address_space *mapping = bdev->bd_inode->i_mapping; 552 struct address_space *mapping = bdev->bd_inode->i_mapping;
diff --git a/drivers/block/DAC960.c b/drivers/block/DAC960.c
index e086fbbbe853..8db9089127c5 100644
--- a/drivers/block/DAC960.c
+++ b/drivers/block/DAC960.c
@@ -1177,7 +1177,8 @@ static bool DAC960_V1_EnableMemoryMailboxInterface(DAC960_Controller_T
1177 int TimeoutCounter; 1177 int TimeoutCounter;
1178 int i; 1178 int i;
1179 1179
1180 1180 memset(&CommandMailbox, 0, sizeof(DAC960_V1_CommandMailbox_T));
1181
1181 if (pci_set_dma_mask(Controller->PCIDevice, DMA_BIT_MASK(32))) 1182 if (pci_set_dma_mask(Controller->PCIDevice, DMA_BIT_MASK(32)))
1182 return DAC960_Failure(Controller, "DMA mask out of range"); 1183 return DAC960_Failure(Controller, "DMA mask out of range");
1183 Controller->BounceBufferLimit = DMA_BIT_MASK(32); 1184 Controller->BounceBufferLimit = DMA_BIT_MASK(32);
@@ -4627,7 +4628,8 @@ static void DAC960_V2_ProcessCompletedCommand(DAC960_Command_T *Command)
4627 DAC960_Controller_T *Controller = Command->Controller; 4628 DAC960_Controller_T *Controller = Command->Controller;
4628 DAC960_CommandType_T CommandType = Command->CommandType; 4629 DAC960_CommandType_T CommandType = Command->CommandType;
4629 DAC960_V2_CommandMailbox_T *CommandMailbox = &Command->V2.CommandMailbox; 4630 DAC960_V2_CommandMailbox_T *CommandMailbox = &Command->V2.CommandMailbox;
4630 DAC960_V2_IOCTL_Opcode_T CommandOpcode = CommandMailbox->Common.IOCTL_Opcode; 4631 DAC960_V2_IOCTL_Opcode_T IOCTLOpcode = CommandMailbox->Common.IOCTL_Opcode;
4632 DAC960_V2_CommandOpcode_T CommandOpcode = CommandMailbox->SCSI_10.CommandOpcode;
4631 DAC960_V2_CommandStatus_T CommandStatus = Command->V2.CommandStatus; 4633 DAC960_V2_CommandStatus_T CommandStatus = Command->V2.CommandStatus;
4632 4634
4633 if (CommandType == DAC960_ReadCommand || 4635 if (CommandType == DAC960_ReadCommand ||
@@ -4699,7 +4701,7 @@ static void DAC960_V2_ProcessCompletedCommand(DAC960_Command_T *Command)
4699 { 4701 {
4700 if (Controller->ShutdownMonitoringTimer) 4702 if (Controller->ShutdownMonitoringTimer)
4701 return; 4703 return;
4702 if (CommandOpcode == DAC960_V2_GetControllerInfo) 4704 if (IOCTLOpcode == DAC960_V2_GetControllerInfo)
4703 { 4705 {
4704 DAC960_V2_ControllerInfo_T *NewControllerInfo = 4706 DAC960_V2_ControllerInfo_T *NewControllerInfo =
4705 Controller->V2.NewControllerInformation; 4707 Controller->V2.NewControllerInformation;
@@ -4719,14 +4721,14 @@ static void DAC960_V2_ProcessCompletedCommand(DAC960_Command_T *Command)
4719 memcpy(ControllerInfo, NewControllerInfo, 4721 memcpy(ControllerInfo, NewControllerInfo,
4720 sizeof(DAC960_V2_ControllerInfo_T)); 4722 sizeof(DAC960_V2_ControllerInfo_T));
4721 } 4723 }
4722 else if (CommandOpcode == DAC960_V2_GetEvent) 4724 else if (IOCTLOpcode == DAC960_V2_GetEvent)
4723 { 4725 {
4724 if (CommandStatus == DAC960_V2_NormalCompletion) { 4726 if (CommandStatus == DAC960_V2_NormalCompletion) {
4725 DAC960_V2_ReportEvent(Controller, Controller->V2.Event); 4727 DAC960_V2_ReportEvent(Controller, Controller->V2.Event);
4726 } 4728 }
4727 Controller->V2.NextEventSequenceNumber++; 4729 Controller->V2.NextEventSequenceNumber++;
4728 } 4730 }
4729 else if (CommandOpcode == DAC960_V2_GetPhysicalDeviceInfoValid && 4731 else if (IOCTLOpcode == DAC960_V2_GetPhysicalDeviceInfoValid &&
4730 CommandStatus == DAC960_V2_NormalCompletion) 4732 CommandStatus == DAC960_V2_NormalCompletion)
4731 { 4733 {
4732 DAC960_V2_PhysicalDeviceInfo_T *NewPhysicalDeviceInfo = 4734 DAC960_V2_PhysicalDeviceInfo_T *NewPhysicalDeviceInfo =
@@ -4915,7 +4917,7 @@ static void DAC960_V2_ProcessCompletedCommand(DAC960_Command_T *Command)
4915 NewPhysicalDeviceInfo->LogicalUnit++; 4917 NewPhysicalDeviceInfo->LogicalUnit++;
4916 Controller->V2.PhysicalDeviceIndex++; 4918 Controller->V2.PhysicalDeviceIndex++;
4917 } 4919 }
4918 else if (CommandOpcode == DAC960_V2_GetPhysicalDeviceInfoValid) 4920 else if (IOCTLOpcode == DAC960_V2_GetPhysicalDeviceInfoValid)
4919 { 4921 {
4920 unsigned int DeviceIndex; 4922 unsigned int DeviceIndex;
4921 for (DeviceIndex = Controller->V2.PhysicalDeviceIndex; 4923 for (DeviceIndex = Controller->V2.PhysicalDeviceIndex;
@@ -4938,7 +4940,7 @@ static void DAC960_V2_ProcessCompletedCommand(DAC960_Command_T *Command)
4938 } 4940 }
4939 Controller->V2.NeedPhysicalDeviceInformation = false; 4941 Controller->V2.NeedPhysicalDeviceInformation = false;
4940 } 4942 }
4941 else if (CommandOpcode == DAC960_V2_GetLogicalDeviceInfoValid && 4943 else if (IOCTLOpcode == DAC960_V2_GetLogicalDeviceInfoValid &&
4942 CommandStatus == DAC960_V2_NormalCompletion) 4944 CommandStatus == DAC960_V2_NormalCompletion)
4943 { 4945 {
4944 DAC960_V2_LogicalDeviceInfo_T *NewLogicalDeviceInfo = 4946 DAC960_V2_LogicalDeviceInfo_T *NewLogicalDeviceInfo =
@@ -5065,7 +5067,7 @@ static void DAC960_V2_ProcessCompletedCommand(DAC960_Command_T *Command)
5065 [LogicalDeviceNumber] = true; 5067 [LogicalDeviceNumber] = true;
5066 NewLogicalDeviceInfo->LogicalDeviceNumber++; 5068 NewLogicalDeviceInfo->LogicalDeviceNumber++;
5067 } 5069 }
5068 else if (CommandOpcode == DAC960_V2_GetLogicalDeviceInfoValid) 5070 else if (IOCTLOpcode == DAC960_V2_GetLogicalDeviceInfoValid)
5069 { 5071 {
5070 int LogicalDriveNumber; 5072 int LogicalDriveNumber;
5071 for (LogicalDriveNumber = 0; 5073 for (LogicalDriveNumber = 0;
diff --git a/drivers/block/sx8.c b/drivers/block/sx8.c
index e7472f567c9d..3fb6ab4c8b4e 100644
--- a/drivers/block/sx8.c
+++ b/drivers/block/sx8.c
@@ -1120,7 +1120,7 @@ static inline void carm_handle_resp(struct carm_host *host,
1120 break; 1120 break;
1121 case MISC_GET_FW_VER: { 1121 case MISC_GET_FW_VER: {
1122 struct carm_fw_ver *ver = (struct carm_fw_ver *) 1122 struct carm_fw_ver *ver = (struct carm_fw_ver *)
1123 mem + sizeof(struct carm_msg_get_fw_ver); 1123 (mem + sizeof(struct carm_msg_get_fw_ver));
1124 if (!error) { 1124 if (!error) {
1125 host->fw_ver = le32_to_cpu(ver->version); 1125 host->fw_ver = le32_to_cpu(ver->version);
1126 host->flags |= (ver->features & FL_FW_VER_MASK); 1126 host->flags |= (ver->features & FL_FW_VER_MASK);
diff --git a/drivers/clocksource/acpi_pm.c b/drivers/clocksource/acpi_pm.c
index 6b5cf02c35c8..82e882028fcf 100644
--- a/drivers/clocksource/acpi_pm.c
+++ b/drivers/clocksource/acpi_pm.c
@@ -23,6 +23,7 @@
23#include <linux/init.h> 23#include <linux/init.h>
24#include <linux/pci.h> 24#include <linux/pci.h>
25#include <linux/delay.h> 25#include <linux/delay.h>
26#include <linux/async.h>
26#include <asm/io.h> 27#include <asm/io.h>
27 28
28/* 29/*
@@ -179,17 +180,15 @@ static int verify_pmtmr_rate(void)
179/* Number of reads we try to get two different values */ 180/* Number of reads we try to get two different values */
180#define ACPI_PM_READ_CHECKS 10000 181#define ACPI_PM_READ_CHECKS 10000
181 182
182static int __init init_acpi_pm_clocksource(void) 183static void __init acpi_pm_clocksource_async(void *unused, async_cookie_t cookie)
183{ 184{
184 cycle_t value1, value2; 185 cycle_t value1, value2;
185 unsigned int i, j = 0; 186 unsigned int i, j = 0;
186 187
187 if (!pmtmr_ioport)
188 return -ENODEV;
189 188
190 /* "verify" this timing source: */ 189 /* "verify" this timing source: */
191 for (j = 0; j < ACPI_PM_MONOTONICITY_CHECKS; j++) { 190 for (j = 0; j < ACPI_PM_MONOTONICITY_CHECKS; j++) {
192 udelay(100 * j); 191 usleep_range(100 * j, 100 * j + 100);
193 value1 = clocksource_acpi_pm.read(&clocksource_acpi_pm); 192 value1 = clocksource_acpi_pm.read(&clocksource_acpi_pm);
194 for (i = 0; i < ACPI_PM_READ_CHECKS; i++) { 193 for (i = 0; i < ACPI_PM_READ_CHECKS; i++) {
195 value2 = clocksource_acpi_pm.read(&clocksource_acpi_pm); 194 value2 = clocksource_acpi_pm.read(&clocksource_acpi_pm);
@@ -203,25 +202,34 @@ static int __init init_acpi_pm_clocksource(void)
203 " 0x%#llx, 0x%#llx - aborting.\n", 202 " 0x%#llx, 0x%#llx - aborting.\n",
204 value1, value2); 203 value1, value2);
205 pmtmr_ioport = 0; 204 pmtmr_ioport = 0;
206 return -EINVAL; 205 return;
207 } 206 }
208 if (i == ACPI_PM_READ_CHECKS) { 207 if (i == ACPI_PM_READ_CHECKS) {
209 printk(KERN_INFO "PM-Timer failed consistency check " 208 printk(KERN_INFO "PM-Timer failed consistency check "
210 " (0x%#llx) - aborting.\n", value1); 209 " (0x%#llx) - aborting.\n", value1);
211 pmtmr_ioport = 0; 210 pmtmr_ioport = 0;
212 return -ENODEV; 211 return;
213 } 212 }
214 } 213 }
215 214
216 if (verify_pmtmr_rate() != 0){ 215 if (verify_pmtmr_rate() != 0){
217 pmtmr_ioport = 0; 216 pmtmr_ioport = 0;
218 return -ENODEV; 217 return;
219 } 218 }
220 219
221 return clocksource_register_hz(&clocksource_acpi_pm, 220 clocksource_register_hz(&clocksource_acpi_pm,
222 PMTMR_TICKS_PER_SEC); 221 PMTMR_TICKS_PER_SEC);
223} 222}
224 223
224static int __init init_acpi_pm_clocksource(void)
225{
226 if (!pmtmr_ioport)
227 return -ENODEV;
228
229 async_schedule(acpi_pm_clocksource_async, NULL);
230 return 0;
231}
232
225/* We use fs_initcall because we want the PCI fixups to have run 233/* We use fs_initcall because we want the PCI fixups to have run
226 * but we still need to load before device_initcall 234 * but we still need to load before device_initcall
227 */ 235 */
diff --git a/drivers/clocksource/clksrc-dbx500-prcmu.c b/drivers/clocksource/clksrc-dbx500-prcmu.c
index fb6b6d28b60e..c26c369eb9e6 100644
--- a/drivers/clocksource/clksrc-dbx500-prcmu.c
+++ b/drivers/clocksource/clksrc-dbx500-prcmu.c
@@ -52,7 +52,6 @@ static struct clocksource clocksource_dbx500_prcmu = {
52 .name = "dbx500-prcmu-timer", 52 .name = "dbx500-prcmu-timer",
53 .rating = 300, 53 .rating = 300,
54 .read = clksrc_dbx500_prcmu_read, 54 .read = clksrc_dbx500_prcmu_read,
55 .shift = 10,
56 .mask = CLOCKSOURCE_MASK(32), 55 .mask = CLOCKSOURCE_MASK(32),
57 .flags = CLOCK_SOURCE_IS_CONTINUOUS, 56 .flags = CLOCK_SOURCE_IS_CONTINUOUS,
58}; 57};
@@ -90,7 +89,5 @@ void __init clksrc_dbx500_prcmu_init(void __iomem *base)
90 setup_sched_clock(dbx500_prcmu_sched_clock_read, 89 setup_sched_clock(dbx500_prcmu_sched_clock_read,
91 32, RATE_32K); 90 32, RATE_32K);
92#endif 91#endif
93 clocksource_calc_mult_shift(&clocksource_dbx500_prcmu, 92 clocksource_register_hz(&clocksource_dbx500_prcmu, RATE_32K);
94 RATE_32K, SCHED_CLOCK_MIN_WRAP);
95 clocksource_register(&clocksource_dbx500_prcmu);
96} 93}
diff --git a/drivers/clocksource/cs5535-clockevt.c b/drivers/clocksource/cs5535-clockevt.c
index b7dab32ce63c..540795cd0760 100644
--- a/drivers/clocksource/cs5535-clockevt.c
+++ b/drivers/clocksource/cs5535-clockevt.c
@@ -100,7 +100,6 @@ static struct clock_event_device cs5535_clockevent = {
100 .set_mode = mfgpt_set_mode, 100 .set_mode = mfgpt_set_mode,
101 .set_next_event = mfgpt_next_event, 101 .set_next_event = mfgpt_next_event,
102 .rating = 250, 102 .rating = 250,
103 .cpumask = cpu_all_mask,
104 .shift = 32 103 .shift = 32
105}; 104};
106 105
@@ -133,7 +132,7 @@ static irqreturn_t mfgpt_tick(int irq, void *dev_id)
133 132
134static struct irqaction mfgptirq = { 133static struct irqaction mfgptirq = {
135 .handler = mfgpt_tick, 134 .handler = mfgpt_tick,
136 .flags = IRQF_DISABLED | IRQF_NOBALANCING | IRQF_TIMER, 135 .flags = IRQF_DISABLED | IRQF_NOBALANCING | IRQF_TIMER | IRQF_SHARED,
137 .name = DRV_NAME, 136 .name = DRV_NAME,
138}; 137};
139 138
diff --git a/drivers/clocksource/cyclone.c b/drivers/clocksource/cyclone.c
index 72f811f73e9c..9e0998f22885 100644
--- a/drivers/clocksource/cyclone.c
+++ b/drivers/clocksource/cyclone.c
@@ -55,11 +55,11 @@ static int __init init_cyclone_clocksource(void)
55 } 55 }
56 /* even on 64bit systems, this is only 32bits: */ 56 /* even on 64bit systems, this is only 32bits: */
57 base = readl(reg); 57 base = readl(reg);
58 iounmap(reg);
58 if (!base) { 59 if (!base) {
59 printk(KERN_ERR "Summit chipset: Could not find valid CBAR value.\n"); 60 printk(KERN_ERR "Summit chipset: Could not find valid CBAR value.\n");
60 return -ENODEV; 61 return -ENODEV;
61 } 62 }
62 iounmap(reg);
63 63
64 /* setup PMCC: */ 64 /* setup PMCC: */
65 offset = base + CYCLONE_PMCC_OFFSET; 65 offset = base + CYCLONE_PMCC_OFFSET;
diff --git a/drivers/clocksource/scx200_hrt.c b/drivers/clocksource/scx200_hrt.c
index 27f4d9637b62..64f9e8294434 100644
--- a/drivers/clocksource/scx200_hrt.c
+++ b/drivers/clocksource/scx200_hrt.c
@@ -49,9 +49,6 @@ static cycle_t read_hrt(struct clocksource *cs)
49 return (cycle_t) inl(scx200_cb_base + SCx200_TIMER_OFFSET); 49 return (cycle_t) inl(scx200_cb_base + SCx200_TIMER_OFFSET);
50} 50}
51 51
52#define HRT_SHIFT_1 22
53#define HRT_SHIFT_27 26
54
55static struct clocksource cs_hrt = { 52static struct clocksource cs_hrt = {
56 .name = "scx200_hrt", 53 .name = "scx200_hrt",
57 .rating = 250, 54 .rating = 250,
@@ -63,6 +60,7 @@ static struct clocksource cs_hrt = {
63 60
64static int __init init_hrt_clocksource(void) 61static int __init init_hrt_clocksource(void)
65{ 62{
63 u32 freq;
66 /* Make sure scx200 has initialized the configuration block */ 64 /* Make sure scx200 has initialized the configuration block */
67 if (!scx200_cb_present()) 65 if (!scx200_cb_present())
68 return -ENODEV; 66 return -ENODEV;
@@ -71,7 +69,7 @@ static int __init init_hrt_clocksource(void)
71 if (!request_region(scx200_cb_base + SCx200_TIMER_OFFSET, 69 if (!request_region(scx200_cb_base + SCx200_TIMER_OFFSET,
72 SCx200_TIMER_SIZE, 70 SCx200_TIMER_SIZE,
73 "NatSemi SCx200 High-Resolution Timer")) { 71 "NatSemi SCx200 High-Resolution Timer")) {
74 printk(KERN_WARNING NAME ": unable to lock timer region\n"); 72 pr_warn("unable to lock timer region\n");
75 return -ENODEV; 73 return -ENODEV;
76 } 74 }
77 75
@@ -79,19 +77,13 @@ static int __init init_hrt_clocksource(void)
79 outb(HR_TMEN | (mhz27 ? HR_TMCLKSEL : 0), 77 outb(HR_TMEN | (mhz27 ? HR_TMCLKSEL : 0),
80 scx200_cb_base + SCx200_TMCNFG_OFFSET); 78 scx200_cb_base + SCx200_TMCNFG_OFFSET);
81 79
82 if (mhz27) { 80 freq = (HRT_FREQ + ppm);
83 cs_hrt.shift = HRT_SHIFT_27; 81 if (mhz27)
84 cs_hrt.mult = clocksource_hz2mult((HRT_FREQ + ppm) * 27, 82 freq *= 27;
85 cs_hrt.shift); 83
86 } else { 84 pr_info("enabling scx200 high-res timer (%s MHz +%d ppm)\n", mhz27 ? "27":"1", ppm);
87 cs_hrt.shift = HRT_SHIFT_1;
88 cs_hrt.mult = clocksource_hz2mult(HRT_FREQ + ppm,
89 cs_hrt.shift);
90 }
91 printk(KERN_INFO "enabling scx200 high-res timer (%s MHz +%d ppm)\n",
92 mhz27 ? "27":"1", ppm);
93 85
94 return clocksource_register(&cs_hrt); 86 return clocksource_register_hz(&cs_hrt, freq);
95} 87}
96 88
97module_init(init_hrt_clocksource); 89module_init(init_hrt_clocksource);
diff --git a/drivers/cpuidle/cpuidle.c b/drivers/cpuidle/cpuidle.c
index 59f4261c753a..6588f43017bd 100644
--- a/drivers/cpuidle/cpuidle.c
+++ b/drivers/cpuidle/cpuidle.c
@@ -94,13 +94,13 @@ int cpuidle_idle_call(void)
94 94
95 target_state = &drv->states[next_state]; 95 target_state = &drv->states[next_state];
96 96
97 trace_power_start(POWER_CSTATE, next_state, dev->cpu); 97 trace_power_start_rcuidle(POWER_CSTATE, next_state, dev->cpu);
98 trace_cpu_idle(next_state, dev->cpu); 98 trace_cpu_idle_rcuidle(next_state, dev->cpu);
99 99
100 entered_state = target_state->enter(dev, drv, next_state); 100 entered_state = target_state->enter(dev, drv, next_state);
101 101
102 trace_power_end(dev->cpu); 102 trace_power_end_rcuidle(dev->cpu);
103 trace_cpu_idle(PWR_EVENT_EXIT, dev->cpu); 103 trace_cpu_idle_rcuidle(PWR_EVENT_EXIT, dev->cpu);
104 104
105 if (entered_state >= 0) { 105 if (entered_state >= 0) {
106 /* Update cpuidle counters */ 106 /* Update cpuidle counters */
diff --git a/drivers/gpu/drm/exynos/exynos_drm_connector.c b/drivers/gpu/drm/exynos/exynos_drm_connector.c
index 618bd4d87d28..99d5527b2ca6 100644
--- a/drivers/gpu/drm/exynos/exynos_drm_connector.c
+++ b/drivers/gpu/drm/exynos/exynos_drm_connector.c
@@ -54,14 +54,14 @@ convert_to_display_mode(struct drm_display_mode *mode,
54 mode->vrefresh = timing->refresh; 54 mode->vrefresh = timing->refresh;
55 55
56 mode->hdisplay = timing->xres; 56 mode->hdisplay = timing->xres;
57 mode->hsync_start = mode->hdisplay + timing->left_margin; 57 mode->hsync_start = mode->hdisplay + timing->right_margin;
58 mode->hsync_end = mode->hsync_start + timing->hsync_len; 58 mode->hsync_end = mode->hsync_start + timing->hsync_len;
59 mode->htotal = mode->hsync_end + timing->right_margin; 59 mode->htotal = mode->hsync_end + timing->left_margin;
60 60
61 mode->vdisplay = timing->yres; 61 mode->vdisplay = timing->yres;
62 mode->vsync_start = mode->vdisplay + timing->upper_margin; 62 mode->vsync_start = mode->vdisplay + timing->lower_margin;
63 mode->vsync_end = mode->vsync_start + timing->vsync_len; 63 mode->vsync_end = mode->vsync_start + timing->vsync_len;
64 mode->vtotal = mode->vsync_end + timing->lower_margin; 64 mode->vtotal = mode->vsync_end + timing->upper_margin;
65 mode->width_mm = panel->width_mm; 65 mode->width_mm = panel->width_mm;
66 mode->height_mm = panel->height_mm; 66 mode->height_mm = panel->height_mm;
67 67
@@ -85,14 +85,14 @@ convert_to_video_timing(struct fb_videomode *timing,
85 timing->refresh = drm_mode_vrefresh(mode); 85 timing->refresh = drm_mode_vrefresh(mode);
86 86
87 timing->xres = mode->hdisplay; 87 timing->xres = mode->hdisplay;
88 timing->left_margin = mode->hsync_start - mode->hdisplay; 88 timing->right_margin = mode->hsync_start - mode->hdisplay;
89 timing->hsync_len = mode->hsync_end - mode->hsync_start; 89 timing->hsync_len = mode->hsync_end - mode->hsync_start;
90 timing->right_margin = mode->htotal - mode->hsync_end; 90 timing->left_margin = mode->htotal - mode->hsync_end;
91 91
92 timing->yres = mode->vdisplay; 92 timing->yres = mode->vdisplay;
93 timing->upper_margin = mode->vsync_start - mode->vdisplay; 93 timing->lower_margin = mode->vsync_start - mode->vdisplay;
94 timing->vsync_len = mode->vsync_end - mode->vsync_start; 94 timing->vsync_len = mode->vsync_end - mode->vsync_start;
95 timing->lower_margin = mode->vtotal - mode->vsync_end; 95 timing->upper_margin = mode->vtotal - mode->vsync_end;
96 96
97 if (mode->flags & DRM_MODE_FLAG_INTERLACE) 97 if (mode->flags & DRM_MODE_FLAG_INTERLACE)
98 timing->vmode = FB_VMODE_INTERLACED; 98 timing->vmode = FB_VMODE_INTERLACED;
diff --git a/drivers/gpu/drm/exynos/exynos_drm_drv.c b/drivers/gpu/drm/exynos/exynos_drm_drv.c
index 58820ebd3558..09cc13f791b3 100644
--- a/drivers/gpu/drm/exynos/exynos_drm_drv.c
+++ b/drivers/gpu/drm/exynos/exynos_drm_drv.c
@@ -246,7 +246,7 @@ static struct platform_driver exynos_drm_platform_driver = {
246 .remove = __devexit_p(exynos_drm_platform_remove), 246 .remove = __devexit_p(exynos_drm_platform_remove),
247 .driver = { 247 .driver = {
248 .owner = THIS_MODULE, 248 .owner = THIS_MODULE,
249 .name = DRIVER_NAME, 249 .name = "exynos-drm",
250 }, 250 },
251}; 251};
252 252
diff --git a/drivers/gpu/drm/exynos/exynos_drm_fbdev.c b/drivers/gpu/drm/exynos/exynos_drm_fbdev.c
index 3508700e529b..54f8f074822f 100644
--- a/drivers/gpu/drm/exynos/exynos_drm_fbdev.c
+++ b/drivers/gpu/drm/exynos/exynos_drm_fbdev.c
@@ -46,39 +46,13 @@ struct exynos_drm_fbdev {
46 struct exynos_drm_gem_obj *exynos_gem_obj; 46 struct exynos_drm_gem_obj *exynos_gem_obj;
47}; 47};
48 48
49static int exynos_drm_fbdev_set_par(struct fb_info *info)
50{
51 struct fb_var_screeninfo *var = &info->var;
52
53 switch (var->bits_per_pixel) {
54 case 32:
55 case 24:
56 case 18:
57 case 16:
58 case 12:
59 info->fix.visual = FB_VISUAL_TRUECOLOR;
60 break;
61 case 1:
62 info->fix.visual = FB_VISUAL_MONO01;
63 break;
64 default:
65 info->fix.visual = FB_VISUAL_PSEUDOCOLOR;
66 break;
67 }
68
69 info->fix.line_length = (var->xres_virtual * var->bits_per_pixel) / 8;
70
71 return drm_fb_helper_set_par(info);
72}
73
74
75static struct fb_ops exynos_drm_fb_ops = { 49static struct fb_ops exynos_drm_fb_ops = {
76 .owner = THIS_MODULE, 50 .owner = THIS_MODULE,
77 .fb_fillrect = cfb_fillrect, 51 .fb_fillrect = cfb_fillrect,
78 .fb_copyarea = cfb_copyarea, 52 .fb_copyarea = cfb_copyarea,
79 .fb_imageblit = cfb_imageblit, 53 .fb_imageblit = cfb_imageblit,
80 .fb_check_var = drm_fb_helper_check_var, 54 .fb_check_var = drm_fb_helper_check_var,
81 .fb_set_par = exynos_drm_fbdev_set_par, 55 .fb_set_par = drm_fb_helper_set_par,
82 .fb_blank = drm_fb_helper_blank, 56 .fb_blank = drm_fb_helper_blank,
83 .fb_pan_display = drm_fb_helper_pan_display, 57 .fb_pan_display = drm_fb_helper_pan_display,
84 .fb_setcmap = drm_fb_helper_setcmap, 58 .fb_setcmap = drm_fb_helper_setcmap,
diff --git a/drivers/gpu/drm/exynos/exynos_drm_fimd.c b/drivers/gpu/drm/exynos/exynos_drm_fimd.c
index 360adf2bba04..56458eea0501 100644
--- a/drivers/gpu/drm/exynos/exynos_drm_fimd.c
+++ b/drivers/gpu/drm/exynos/exynos_drm_fimd.c
@@ -817,8 +817,6 @@ static int __devinit fimd_probe(struct platform_device *pdev)
817 goto err_clk_get; 817 goto err_clk_get;
818 } 818 }
819 819
820 clk_enable(ctx->bus_clk);
821
822 ctx->lcd_clk = clk_get(dev, "sclk_fimd"); 820 ctx->lcd_clk = clk_get(dev, "sclk_fimd");
823 if (IS_ERR(ctx->lcd_clk)) { 821 if (IS_ERR(ctx->lcd_clk)) {
824 dev_err(dev, "failed to get lcd clock\n"); 822 dev_err(dev, "failed to get lcd clock\n");
@@ -826,8 +824,6 @@ static int __devinit fimd_probe(struct platform_device *pdev)
826 goto err_bus_clk; 824 goto err_bus_clk;
827 } 825 }
828 826
829 clk_enable(ctx->lcd_clk);
830
831 res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 827 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
832 if (!res) { 828 if (!res) {
833 dev_err(dev, "failed to find registers\n"); 829 dev_err(dev, "failed to find registers\n");
@@ -864,17 +860,11 @@ static int __devinit fimd_probe(struct platform_device *pdev)
864 goto err_req_irq; 860 goto err_req_irq;
865 } 861 }
866 862
867 ctx->clkdiv = fimd_calc_clkdiv(ctx, &panel->timing);
868 ctx->vidcon0 = pdata->vidcon0; 863 ctx->vidcon0 = pdata->vidcon0;
869 ctx->vidcon1 = pdata->vidcon1; 864 ctx->vidcon1 = pdata->vidcon1;
870 ctx->default_win = pdata->default_win; 865 ctx->default_win = pdata->default_win;
871 ctx->panel = panel; 866 ctx->panel = panel;
872 867
873 panel->timing.pixclock = clk_get_rate(ctx->lcd_clk) / ctx->clkdiv;
874
875 DRM_DEBUG_KMS("pixel clock = %d, clkdiv = %d\n",
876 panel->timing.pixclock, ctx->clkdiv);
877
878 subdrv = &ctx->subdrv; 868 subdrv = &ctx->subdrv;
879 869
880 subdrv->probe = fimd_subdrv_probe; 870 subdrv->probe = fimd_subdrv_probe;
@@ -889,10 +879,15 @@ static int __devinit fimd_probe(struct platform_device *pdev)
889 879
890 platform_set_drvdata(pdev, ctx); 880 platform_set_drvdata(pdev, ctx);
891 881
892 pm_runtime_set_active(dev);
893 pm_runtime_enable(dev); 882 pm_runtime_enable(dev);
894 pm_runtime_get_sync(dev); 883 pm_runtime_get_sync(dev);
895 884
885 ctx->clkdiv = fimd_calc_clkdiv(ctx, &panel->timing);
886 panel->timing.pixclock = clk_get_rate(ctx->lcd_clk) / ctx->clkdiv;
887
888 DRM_DEBUG_KMS("pixel clock = %d, clkdiv = %d\n",
889 panel->timing.pixclock, ctx->clkdiv);
890
896 for (win = 0; win < WINDOWS_NR; win++) 891 for (win = 0; win < WINDOWS_NR; win++)
897 fimd_clear_win(ctx, win); 892 fimd_clear_win(ctx, win);
898 893
diff --git a/drivers/gpu/drm/i915/i915_reg.h b/drivers/gpu/drm/i915/i915_reg.h
index 03c53fcf8653..558ac716a328 100644
--- a/drivers/gpu/drm/i915/i915_reg.h
+++ b/drivers/gpu/drm/i915/i915_reg.h
@@ -2689,7 +2689,7 @@
2689#define DVS_FORMAT_RGBX888 (2<<25) 2689#define DVS_FORMAT_RGBX888 (2<<25)
2690#define DVS_FORMAT_RGBX161616 (3<<25) 2690#define DVS_FORMAT_RGBX161616 (3<<25)
2691#define DVS_SOURCE_KEY (1<<22) 2691#define DVS_SOURCE_KEY (1<<22)
2692#define DVS_RGB_ORDER_RGBX (1<<20) 2692#define DVS_RGB_ORDER_XBGR (1<<20)
2693#define DVS_YUV_BYTE_ORDER_MASK (3<<16) 2693#define DVS_YUV_BYTE_ORDER_MASK (3<<16)
2694#define DVS_YUV_ORDER_YUYV (0<<16) 2694#define DVS_YUV_ORDER_YUYV (0<<16)
2695#define DVS_YUV_ORDER_UYVY (1<<16) 2695#define DVS_YUV_ORDER_UYVY (1<<16)
diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c
index f851db7be2cc..397087cf689e 100644
--- a/drivers/gpu/drm/i915/intel_display.c
+++ b/drivers/gpu/drm/i915/intel_display.c
@@ -7828,6 +7828,7 @@ int intel_framebuffer_init(struct drm_device *dev,
7828 case DRM_FORMAT_RGB332: 7828 case DRM_FORMAT_RGB332:
7829 case DRM_FORMAT_RGB565: 7829 case DRM_FORMAT_RGB565:
7830 case DRM_FORMAT_XRGB8888: 7830 case DRM_FORMAT_XRGB8888:
7831 case DRM_FORMAT_XBGR8888:
7831 case DRM_FORMAT_ARGB8888: 7832 case DRM_FORMAT_ARGB8888:
7832 case DRM_FORMAT_XRGB2101010: 7833 case DRM_FORMAT_XRGB2101010:
7833 case DRM_FORMAT_ARGB2101010: 7834 case DRM_FORMAT_ARGB2101010:
diff --git a/drivers/gpu/drm/i915/intel_sprite.c b/drivers/gpu/drm/i915/intel_sprite.c
index 2288abf88cce..a0835040c86b 100644
--- a/drivers/gpu/drm/i915/intel_sprite.c
+++ b/drivers/gpu/drm/i915/intel_sprite.c
@@ -225,16 +225,16 @@ snb_update_plane(struct drm_plane *plane, struct drm_framebuffer *fb,
225 225
226 /* Mask out pixel format bits in case we change it */ 226 /* Mask out pixel format bits in case we change it */
227 dvscntr &= ~DVS_PIXFORMAT_MASK; 227 dvscntr &= ~DVS_PIXFORMAT_MASK;
228 dvscntr &= ~DVS_RGB_ORDER_RGBX; 228 dvscntr &= ~DVS_RGB_ORDER_XBGR;
229 dvscntr &= ~DVS_YUV_BYTE_ORDER_MASK; 229 dvscntr &= ~DVS_YUV_BYTE_ORDER_MASK;
230 230
231 switch (fb->pixel_format) { 231 switch (fb->pixel_format) {
232 case DRM_FORMAT_XBGR8888: 232 case DRM_FORMAT_XBGR8888:
233 dvscntr |= DVS_FORMAT_RGBX888; 233 dvscntr |= DVS_FORMAT_RGBX888 | DVS_RGB_ORDER_XBGR;
234 pixel_size = 4; 234 pixel_size = 4;
235 break; 235 break;
236 case DRM_FORMAT_XRGB8888: 236 case DRM_FORMAT_XRGB8888:
237 dvscntr |= DVS_FORMAT_RGBX888 | DVS_RGB_ORDER_RGBX; 237 dvscntr |= DVS_FORMAT_RGBX888;
238 pixel_size = 4; 238 pixel_size = 4;
239 break; 239 break;
240 case DRM_FORMAT_YUYV: 240 case DRM_FORMAT_YUYV:
diff --git a/drivers/hwmon/pmbus/zl6100.c b/drivers/hwmon/pmbus/zl6100.c
index 880b90cf4d32..e3e8420b7b81 100644
--- a/drivers/hwmon/pmbus/zl6100.c
+++ b/drivers/hwmon/pmbus/zl6100.c
@@ -200,17 +200,11 @@ static int zl6100_probe(struct i2c_client *client,
200 data->id = mid->driver_data; 200 data->id = mid->driver_data;
201 201
202 /* 202 /*
203 * ZL2005, ZL2008, ZL2105, and ZL6100 are known to require a wait time 203 * According to information from the chip vendor, all currently
204 * between I2C accesses. ZL2004 and ZL6105 are known to be safe. 204 * supported chips are known to require a wait time between I2C
205 * Other chips have not yet been tested. 205 * accesses.
206 *
207 * Only clear the wait time for chips known to be safe. The wait time
208 * can be cleared later for additional chips if tests show that it
209 * is not needed (in other words, better be safe than sorry).
210 */ 206 */
211 data->delay = delay; 207 data->delay = delay;
212 if (data->id == zl2004 || data->id == zl6105)
213 data->delay = 0;
214 208
215 /* 209 /*
216 * Since there was a direct I2C device access above, wait before 210 * Since there was a direct I2C device access above, wait before
diff --git a/drivers/hwmon/w83627ehf.c b/drivers/hwmon/w83627ehf.c
index 5276d1933dbc..a658d62c5e10 100644
--- a/drivers/hwmon/w83627ehf.c
+++ b/drivers/hwmon/w83627ehf.c
@@ -39,7 +39,7 @@
39 0x8860 0xa1 39 0x8860 0xa1
40 w83627dhg 9 5 4 3 0xa020 0xc1 0x5ca3 40 w83627dhg 9 5 4 3 0xa020 0xc1 0x5ca3
41 w83627dhg-p 9 5 4 3 0xb070 0xc1 0x5ca3 41 w83627dhg-p 9 5 4 3 0xb070 0xc1 0x5ca3
42 w83627uhg 8 2 2 2 0xa230 0xc1 0x5ca3 42 w83627uhg 8 2 2 3 0xa230 0xc1 0x5ca3
43 w83667hg 9 5 3 3 0xa510 0xc1 0x5ca3 43 w83667hg 9 5 3 3 0xa510 0xc1 0x5ca3
44 w83667hg-b 9 5 3 4 0xb350 0xc1 0x5ca3 44 w83667hg-b 9 5 3 4 0xb350 0xc1 0x5ca3
45 nct6775f 9 4 3 9 0xb470 0xc1 0x5ca3 45 nct6775f 9 4 3 9 0xb470 0xc1 0x5ca3
@@ -1607,7 +1607,7 @@ store_##reg(struct device *dev, struct device_attribute *attr, \
1607 val = step_time_to_reg(val, data->pwm_mode[nr]); \ 1607 val = step_time_to_reg(val, data->pwm_mode[nr]); \
1608 mutex_lock(&data->update_lock); \ 1608 mutex_lock(&data->update_lock); \
1609 data->reg[nr] = val; \ 1609 data->reg[nr] = val; \
1610 w83627ehf_write_value(data, W83627EHF_REG_##REG[nr], val); \ 1610 w83627ehf_write_value(data, data->REG_##REG[nr], val); \
1611 mutex_unlock(&data->update_lock); \ 1611 mutex_unlock(&data->update_lock); \
1612 return count; \ 1612 return count; \
1613} \ 1613} \
@@ -2004,7 +2004,8 @@ static int __devinit w83627ehf_probe(struct platform_device *pdev)
2004 goto exit; 2004 goto exit;
2005 } 2005 }
2006 2006
2007 data = kzalloc(sizeof(struct w83627ehf_data), GFP_KERNEL); 2007 data = devm_kzalloc(&pdev->dev, sizeof(struct w83627ehf_data),
2008 GFP_KERNEL);
2008 if (!data) { 2009 if (!data) {
2009 err = -ENOMEM; 2010 err = -ENOMEM;
2010 goto exit_release; 2011 goto exit_release;
@@ -2157,16 +2158,16 @@ static int __devinit w83627ehf_probe(struct platform_device *pdev)
2157 w83627ehf_set_temp_reg_ehf(data, 3); 2158 w83627ehf_set_temp_reg_ehf(data, 3);
2158 2159
2159 /* 2160 /*
2160 * Temperature sources for temp1 and temp2 are selected with 2161 * Temperature sources for temp2 and temp3 are selected with
2161 * bank 0, registers 0x49 and 0x4a. 2162 * bank 0, registers 0x49 and 0x4a.
2162 */ 2163 */
2163 data->temp_src[0] = 0; /* SYSTIN */ 2164 data->temp_src[0] = 0; /* SYSTIN */
2164 reg = w83627ehf_read_value(data, 0x49) & 0x07; 2165 reg = w83627ehf_read_value(data, 0x49) & 0x07;
2165 /* Adjust to have the same mapping as other source registers */ 2166 /* Adjust to have the same mapping as other source registers */
2166 if (reg == 0) 2167 if (reg == 0)
2167 data->temp_src[1]++; 2168 data->temp_src[1] = 1;
2168 else if (reg >= 2 && reg <= 5) 2169 else if (reg >= 2 && reg <= 5)
2169 data->temp_src[1] += 2; 2170 data->temp_src[1] = reg + 2;
2170 else /* should never happen */ 2171 else /* should never happen */
2171 data->have_temp &= ~(1 << 1); 2172 data->have_temp &= ~(1 << 1);
2172 reg = w83627ehf_read_value(data, 0x4a); 2173 reg = w83627ehf_read_value(data, 0x4a);
@@ -2493,9 +2494,8 @@ static int __devinit w83627ehf_probe(struct platform_device *pdev)
2493 2494
2494exit_remove: 2495exit_remove:
2495 w83627ehf_device_remove_files(dev); 2496 w83627ehf_device_remove_files(dev);
2496 kfree(data);
2497 platform_set_drvdata(pdev, NULL);
2498exit_release: 2497exit_release:
2498 platform_set_drvdata(pdev, NULL);
2499 release_region(res->start, IOREGION_LENGTH); 2499 release_region(res->start, IOREGION_LENGTH);
2500exit: 2500exit:
2501 return err; 2501 return err;
@@ -2509,7 +2509,6 @@ static int __devexit w83627ehf_remove(struct platform_device *pdev)
2509 w83627ehf_device_remove_files(&pdev->dev); 2509 w83627ehf_device_remove_files(&pdev->dev);
2510 release_region(data->addr, IOREGION_LENGTH); 2510 release_region(data->addr, IOREGION_LENGTH);
2511 platform_set_drvdata(pdev, NULL); 2511 platform_set_drvdata(pdev, NULL);
2512 kfree(data);
2513 2512
2514 return 0; 2513 return 0;
2515} 2514}
diff --git a/drivers/i2c/algos/i2c-algo-bit.c b/drivers/i2c/algos/i2c-algo-bit.c
index 525c7345fa0b..24f94f4ae395 100644
--- a/drivers/i2c/algos/i2c-algo-bit.c
+++ b/drivers/i2c/algos/i2c-algo-bit.c
@@ -103,8 +103,14 @@ static int sclhi(struct i2c_algo_bit_data *adap)
103 * chips may hold it low ("clock stretching") while they 103 * chips may hold it low ("clock stretching") while they
104 * are processing data internally. 104 * are processing data internally.
105 */ 105 */
106 if (time_after(jiffies, start + adap->timeout)) 106 if (time_after(jiffies, start + adap->timeout)) {
107 /* Test one last time, as we may have been preempted
108 * between last check and timeout test.
109 */
110 if (getscl(adap))
111 break;
107 return -ETIMEDOUT; 112 return -ETIMEDOUT;
113 }
108 cond_resched(); 114 cond_resched();
109 } 115 }
110#ifdef DEBUG 116#ifdef DEBUG
diff --git a/drivers/i2c/i2c-core.c b/drivers/i2c/i2c-core.c
index 1e5606185b4f..e9c18939eda7 100644
--- a/drivers/i2c/i2c-core.c
+++ b/drivers/i2c/i2c-core.c
@@ -1386,8 +1386,10 @@ int i2c_master_send(const struct i2c_client *client, const char *buf, int count)
1386 1386
1387 ret = i2c_transfer(adap, &msg, 1); 1387 ret = i2c_transfer(adap, &msg, 1);
1388 1388
1389 /* If everything went ok (i.e. 1 msg transmitted), return #bytes 1389 /*
1390 transmitted, else error code. */ 1390 * If everything went ok (i.e. 1 msg transmitted), return #bytes
1391 * transmitted, else error code.
1392 */
1391 return (ret == 1) ? count : ret; 1393 return (ret == 1) ? count : ret;
1392} 1394}
1393EXPORT_SYMBOL(i2c_master_send); 1395EXPORT_SYMBOL(i2c_master_send);
@@ -1414,8 +1416,10 @@ int i2c_master_recv(const struct i2c_client *client, char *buf, int count)
1414 1416
1415 ret = i2c_transfer(adap, &msg, 1); 1417 ret = i2c_transfer(adap, &msg, 1);
1416 1418
1417 /* If everything went ok (i.e. 1 msg transmitted), return #bytes 1419 /*
1418 transmitted, else error code. */ 1420 * If everything went ok (i.e. 1 msg received), return #bytes received,
1421 * else error code.
1422 */
1419 return (ret == 1) ? count : ret; 1423 return (ret == 1) ? count : ret;
1420} 1424}
1421EXPORT_SYMBOL(i2c_master_recv); 1425EXPORT_SYMBOL(i2c_master_recv);
diff --git a/drivers/iommu/intel-iommu.c b/drivers/iommu/intel-iommu.c
index c9c6053198d4..a08a53448b72 100644
--- a/drivers/iommu/intel-iommu.c
+++ b/drivers/iommu/intel-iommu.c
@@ -48,8 +48,6 @@
48#define ROOT_SIZE VTD_PAGE_SIZE 48#define ROOT_SIZE VTD_PAGE_SIZE
49#define CONTEXT_SIZE VTD_PAGE_SIZE 49#define CONTEXT_SIZE VTD_PAGE_SIZE
50 50
51#define IS_BRIDGE_HOST_DEVICE(pdev) \
52 ((pdev->class >> 8) == PCI_CLASS_BRIDGE_HOST)
53#define IS_GFX_DEVICE(pdev) ((pdev->class >> 16) == PCI_BASE_CLASS_DISPLAY) 51#define IS_GFX_DEVICE(pdev) ((pdev->class >> 16) == PCI_BASE_CLASS_DISPLAY)
54#define IS_ISA_DEVICE(pdev) ((pdev->class >> 8) == PCI_CLASS_BRIDGE_ISA) 52#define IS_ISA_DEVICE(pdev) ((pdev->class >> 8) == PCI_CLASS_BRIDGE_ISA)
55#define IS_AZALIA(pdev) ((pdev)->vendor == 0x8086 && (pdev)->device == 0x3a3e) 53#define IS_AZALIA(pdev) ((pdev)->vendor == 0x8086 && (pdev)->device == 0x3a3e)
@@ -356,10 +354,18 @@ static int hw_pass_through = 1;
356/* si_domain contains mulitple devices */ 354/* si_domain contains mulitple devices */
357#define DOMAIN_FLAG_STATIC_IDENTITY (1 << 2) 355#define DOMAIN_FLAG_STATIC_IDENTITY (1 << 2)
358 356
357/* define the limit of IOMMUs supported in each domain */
358#ifdef CONFIG_X86
359# define IOMMU_UNITS_SUPPORTED MAX_IO_APICS
360#else
361# define IOMMU_UNITS_SUPPORTED 64
362#endif
363
359struct dmar_domain { 364struct dmar_domain {
360 int id; /* domain id */ 365 int id; /* domain id */
361 int nid; /* node id */ 366 int nid; /* node id */
362 unsigned long iommu_bmp; /* bitmap of iommus this domain uses*/ 367 DECLARE_BITMAP(iommu_bmp, IOMMU_UNITS_SUPPORTED);
368 /* bitmap of iommus this domain uses*/
363 369
364 struct list_head devices; /* all devices' list */ 370 struct list_head devices; /* all devices' list */
365 struct iova_domain iovad; /* iova's that belong to this domain */ 371 struct iova_domain iovad; /* iova's that belong to this domain */
@@ -571,7 +577,7 @@ static struct intel_iommu *domain_get_iommu(struct dmar_domain *domain)
571 BUG_ON(domain->flags & DOMAIN_FLAG_VIRTUAL_MACHINE); 577 BUG_ON(domain->flags & DOMAIN_FLAG_VIRTUAL_MACHINE);
572 BUG_ON(domain->flags & DOMAIN_FLAG_STATIC_IDENTITY); 578 BUG_ON(domain->flags & DOMAIN_FLAG_STATIC_IDENTITY);
573 579
574 iommu_id = find_first_bit(&domain->iommu_bmp, g_num_of_iommus); 580 iommu_id = find_first_bit(domain->iommu_bmp, g_num_of_iommus);
575 if (iommu_id < 0 || iommu_id >= g_num_of_iommus) 581 if (iommu_id < 0 || iommu_id >= g_num_of_iommus)
576 return NULL; 582 return NULL;
577 583
@@ -584,7 +590,7 @@ static void domain_update_iommu_coherency(struct dmar_domain *domain)
584 590
585 domain->iommu_coherency = 1; 591 domain->iommu_coherency = 1;
586 592
587 for_each_set_bit(i, &domain->iommu_bmp, g_num_of_iommus) { 593 for_each_set_bit(i, domain->iommu_bmp, g_num_of_iommus) {
588 if (!ecap_coherent(g_iommus[i]->ecap)) { 594 if (!ecap_coherent(g_iommus[i]->ecap)) {
589 domain->iommu_coherency = 0; 595 domain->iommu_coherency = 0;
590 break; 596 break;
@@ -598,7 +604,7 @@ static void domain_update_iommu_snooping(struct dmar_domain *domain)
598 604
599 domain->iommu_snooping = 1; 605 domain->iommu_snooping = 1;
600 606
601 for_each_set_bit(i, &domain->iommu_bmp, g_num_of_iommus) { 607 for_each_set_bit(i, domain->iommu_bmp, g_num_of_iommus) {
602 if (!ecap_sc_support(g_iommus[i]->ecap)) { 608 if (!ecap_sc_support(g_iommus[i]->ecap)) {
603 domain->iommu_snooping = 0; 609 domain->iommu_snooping = 0;
604 break; 610 break;
@@ -1334,7 +1340,7 @@ static struct dmar_domain *alloc_domain(void)
1334 return NULL; 1340 return NULL;
1335 1341
1336 domain->nid = -1; 1342 domain->nid = -1;
1337 memset(&domain->iommu_bmp, 0, sizeof(unsigned long)); 1343 memset(domain->iommu_bmp, 0, sizeof(domain->iommu_bmp));
1338 domain->flags = 0; 1344 domain->flags = 0;
1339 1345
1340 return domain; 1346 return domain;
@@ -1360,7 +1366,7 @@ static int iommu_attach_domain(struct dmar_domain *domain,
1360 1366
1361 domain->id = num; 1367 domain->id = num;
1362 set_bit(num, iommu->domain_ids); 1368 set_bit(num, iommu->domain_ids);
1363 set_bit(iommu->seq_id, &domain->iommu_bmp); 1369 set_bit(iommu->seq_id, domain->iommu_bmp);
1364 iommu->domains[num] = domain; 1370 iommu->domains[num] = domain;
1365 spin_unlock_irqrestore(&iommu->lock, flags); 1371 spin_unlock_irqrestore(&iommu->lock, flags);
1366 1372
@@ -1385,7 +1391,7 @@ static void iommu_detach_domain(struct dmar_domain *domain,
1385 1391
1386 if (found) { 1392 if (found) {
1387 clear_bit(num, iommu->domain_ids); 1393 clear_bit(num, iommu->domain_ids);
1388 clear_bit(iommu->seq_id, &domain->iommu_bmp); 1394 clear_bit(iommu->seq_id, domain->iommu_bmp);
1389 iommu->domains[num] = NULL; 1395 iommu->domains[num] = NULL;
1390 } 1396 }
1391 spin_unlock_irqrestore(&iommu->lock, flags); 1397 spin_unlock_irqrestore(&iommu->lock, flags);
@@ -1527,7 +1533,7 @@ static void domain_exit(struct dmar_domain *domain)
1527 dma_pte_free_pagetable(domain, 0, DOMAIN_MAX_PFN(domain->gaw)); 1533 dma_pte_free_pagetable(domain, 0, DOMAIN_MAX_PFN(domain->gaw));
1528 1534
1529 for_each_active_iommu(iommu, drhd) 1535 for_each_active_iommu(iommu, drhd)
1530 if (test_bit(iommu->seq_id, &domain->iommu_bmp)) 1536 if (test_bit(iommu->seq_id, domain->iommu_bmp))
1531 iommu_detach_domain(domain, iommu); 1537 iommu_detach_domain(domain, iommu);
1532 1538
1533 free_domain_mem(domain); 1539 free_domain_mem(domain);
@@ -1653,7 +1659,7 @@ static int domain_context_mapping_one(struct dmar_domain *domain, int segment,
1653 spin_unlock_irqrestore(&iommu->lock, flags); 1659 spin_unlock_irqrestore(&iommu->lock, flags);
1654 1660
1655 spin_lock_irqsave(&domain->iommu_lock, flags); 1661 spin_lock_irqsave(&domain->iommu_lock, flags);
1656 if (!test_and_set_bit(iommu->seq_id, &domain->iommu_bmp)) { 1662 if (!test_and_set_bit(iommu->seq_id, domain->iommu_bmp)) {
1657 domain->iommu_count++; 1663 domain->iommu_count++;
1658 if (domain->iommu_count == 1) 1664 if (domain->iommu_count == 1)
1659 domain->nid = iommu->node; 1665 domain->nid = iommu->node;
@@ -2369,18 +2375,18 @@ static int __init iommu_prepare_static_identity_mapping(int hw)
2369 return -EFAULT; 2375 return -EFAULT;
2370 2376
2371 for_each_pci_dev(pdev) { 2377 for_each_pci_dev(pdev) {
2372 /* Skip Host/PCI Bridge devices */
2373 if (IS_BRIDGE_HOST_DEVICE(pdev))
2374 continue;
2375 if (iommu_should_identity_map(pdev, 1)) { 2378 if (iommu_should_identity_map(pdev, 1)) {
2376 printk(KERN_INFO "IOMMU: %s identity mapping for device %s\n",
2377 hw ? "hardware" : "software", pci_name(pdev));
2378
2379 ret = domain_add_dev_info(si_domain, pdev, 2379 ret = domain_add_dev_info(si_domain, pdev,
2380 hw ? CONTEXT_TT_PASS_THROUGH : 2380 hw ? CONTEXT_TT_PASS_THROUGH :
2381 CONTEXT_TT_MULTI_LEVEL); 2381 CONTEXT_TT_MULTI_LEVEL);
2382 if (ret) 2382 if (ret) {
2383 /* device not associated with an iommu */
2384 if (ret == -ENODEV)
2385 continue;
2383 return ret; 2386 return ret;
2387 }
2388 pr_info("IOMMU: %s identity mapping for device %s\n",
2389 hw ? "hardware" : "software", pci_name(pdev));
2384 } 2390 }
2385 } 2391 }
2386 2392
@@ -2402,12 +2408,17 @@ static int __init init_dmars(void)
2402 * endfor 2408 * endfor
2403 */ 2409 */
2404 for_each_drhd_unit(drhd) { 2410 for_each_drhd_unit(drhd) {
2405 g_num_of_iommus++;
2406 /* 2411 /*
2407 * lock not needed as this is only incremented in the single 2412 * lock not needed as this is only incremented in the single
2408 * threaded kernel __init code path all other access are read 2413 * threaded kernel __init code path all other access are read
2409 * only 2414 * only
2410 */ 2415 */
2416 if (g_num_of_iommus < IOMMU_UNITS_SUPPORTED) {
2417 g_num_of_iommus++;
2418 continue;
2419 }
2420 printk_once(KERN_ERR "intel-iommu: exceeded %d IOMMUs\n",
2421 IOMMU_UNITS_SUPPORTED);
2411 } 2422 }
2412 2423
2413 g_iommus = kcalloc(g_num_of_iommus, sizeof(struct intel_iommu *), 2424 g_iommus = kcalloc(g_num_of_iommus, sizeof(struct intel_iommu *),
@@ -3748,7 +3759,7 @@ static void domain_remove_one_dev_info(struct dmar_domain *domain,
3748 if (found == 0) { 3759 if (found == 0) {
3749 unsigned long tmp_flags; 3760 unsigned long tmp_flags;
3750 spin_lock_irqsave(&domain->iommu_lock, tmp_flags); 3761 spin_lock_irqsave(&domain->iommu_lock, tmp_flags);
3751 clear_bit(iommu->seq_id, &domain->iommu_bmp); 3762 clear_bit(iommu->seq_id, domain->iommu_bmp);
3752 domain->iommu_count--; 3763 domain->iommu_count--;
3753 domain_update_iommu_cap(domain); 3764 domain_update_iommu_cap(domain);
3754 spin_unlock_irqrestore(&domain->iommu_lock, tmp_flags); 3765 spin_unlock_irqrestore(&domain->iommu_lock, tmp_flags);
@@ -3790,7 +3801,7 @@ static void vm_domain_remove_all_dev_info(struct dmar_domain *domain)
3790 */ 3801 */
3791 spin_lock_irqsave(&domain->iommu_lock, flags2); 3802 spin_lock_irqsave(&domain->iommu_lock, flags2);
3792 if (test_and_clear_bit(iommu->seq_id, 3803 if (test_and_clear_bit(iommu->seq_id,
3793 &domain->iommu_bmp)) { 3804 domain->iommu_bmp)) {
3794 domain->iommu_count--; 3805 domain->iommu_count--;
3795 domain_update_iommu_cap(domain); 3806 domain_update_iommu_cap(domain);
3796 } 3807 }
@@ -3815,7 +3826,7 @@ static struct dmar_domain *iommu_alloc_vm_domain(void)
3815 3826
3816 domain->id = vm_domid++; 3827 domain->id = vm_domid++;
3817 domain->nid = -1; 3828 domain->nid = -1;
3818 memset(&domain->iommu_bmp, 0, sizeof(unsigned long)); 3829 memset(domain->iommu_bmp, 0, sizeof(domain->iommu_bmp));
3819 domain->flags = DOMAIN_FLAG_VIRTUAL_MACHINE; 3830 domain->flags = DOMAIN_FLAG_VIRTUAL_MACHINE;
3820 3831
3821 return domain; 3832 return domain;
diff --git a/drivers/media/dvb/siano/smsdvb.c b/drivers/media/dvb/siano/smsdvb.c
index 654685c9303e..aa77e54a8fae 100644
--- a/drivers/media/dvb/siano/smsdvb.c
+++ b/drivers/media/dvb/siano/smsdvb.c
@@ -49,9 +49,6 @@ struct smsdvb_client_t {
49 49
50 struct completion tune_done; 50 struct completion tune_done;
51 51
52 /* todo: save freq/band instead whole struct */
53 struct dtv_frontend_properties fe_params;
54
55 struct SMSHOSTLIB_STATISTICS_DVB_S sms_stat_dvb; 52 struct SMSHOSTLIB_STATISTICS_DVB_S sms_stat_dvb;
56 int event_fe_state; 53 int event_fe_state;
57 int event_unc_state; 54 int event_unc_state;
@@ -744,12 +741,124 @@ static int smsdvb_get_frontend(struct dvb_frontend *fe)
744 struct dtv_frontend_properties *fep = &fe->dtv_property_cache; 741 struct dtv_frontend_properties *fep = &fe->dtv_property_cache;
745 struct smsdvb_client_t *client = 742 struct smsdvb_client_t *client =
746 container_of(fe, struct smsdvb_client_t, frontend); 743 container_of(fe, struct smsdvb_client_t, frontend);
744 struct smscore_device_t *coredev = client->coredev;
745 struct TRANSMISSION_STATISTICS_S *td =
746 &client->sms_stat_dvb.TransmissionData;
747 747
748 sms_debug(""); 748 switch (smscore_get_device_mode(coredev)) {
749 case DEVICE_MODE_DVBT:
750 case DEVICE_MODE_DVBT_BDA:
751 fep->frequency = td->Frequency;
752
753 switch (td->Bandwidth) {
754 case 6:
755 fep->bandwidth_hz = 6000000;
756 break;
757 case 7:
758 fep->bandwidth_hz = 7000000;
759 break;
760 case 8:
761 fep->bandwidth_hz = 8000000;
762 break;
763 }
764
765 switch (td->TransmissionMode) {
766 case 2:
767 fep->transmission_mode = TRANSMISSION_MODE_2K;
768 break;
769 case 8:
770 fep->transmission_mode = TRANSMISSION_MODE_8K;
771 }
772
773 switch (td->GuardInterval) {
774 case 0:
775 fep->guard_interval = GUARD_INTERVAL_1_32;
776 break;
777 case 1:
778 fep->guard_interval = GUARD_INTERVAL_1_16;
779 break;
780 case 2:
781 fep->guard_interval = GUARD_INTERVAL_1_8;
782 break;
783 case 3:
784 fep->guard_interval = GUARD_INTERVAL_1_4;
785 break;
786 }
787
788 switch (td->CodeRate) {
789 case 0:
790 fep->code_rate_HP = FEC_1_2;
791 break;
792 case 1:
793 fep->code_rate_HP = FEC_2_3;
794 break;
795 case 2:
796 fep->code_rate_HP = FEC_3_4;
797 break;
798 case 3:
799 fep->code_rate_HP = FEC_5_6;
800 break;
801 case 4:
802 fep->code_rate_HP = FEC_7_8;
803 break;
804 }
805
806 switch (td->LPCodeRate) {
807 case 0:
808 fep->code_rate_LP = FEC_1_2;
809 break;
810 case 1:
811 fep->code_rate_LP = FEC_2_3;
812 break;
813 case 2:
814 fep->code_rate_LP = FEC_3_4;
815 break;
816 case 3:
817 fep->code_rate_LP = FEC_5_6;
818 break;
819 case 4:
820 fep->code_rate_LP = FEC_7_8;
821 break;
822 }
823
824 switch (td->Constellation) {
825 case 0:
826 fep->modulation = QPSK;
827 break;
828 case 1:
829 fep->modulation = QAM_16;
830 break;
831 case 2:
832 fep->modulation = QAM_64;
833 break;
834 }
835
836 switch (td->Hierarchy) {
837 case 0:
838 fep->hierarchy = HIERARCHY_NONE;
839 break;
840 case 1:
841 fep->hierarchy = HIERARCHY_1;
842 break;
843 case 2:
844 fep->hierarchy = HIERARCHY_2;
845 break;
846 case 3:
847 fep->hierarchy = HIERARCHY_4;
848 break;
849 }
749 850
750 /* todo: */ 851 fep->inversion = INVERSION_AUTO;
751 memcpy(fep, &client->fe_params, 852 break;
752 sizeof(struct dtv_frontend_properties)); 853 case DEVICE_MODE_ISDBT:
854 case DEVICE_MODE_ISDBT_BDA:
855 fep->frequency = td->Frequency;
856 fep->bandwidth_hz = 6000000;
857 /* todo: retrive the other parameters */
858 break;
859 default:
860 return -EINVAL;
861 }
753 862
754 return 0; 863 return 0;
755} 864}
@@ -872,11 +981,11 @@ static int smsdvb_hotplug(struct smscore_device_t *coredev,
872 switch (smscore_get_device_mode(coredev)) { 981 switch (smscore_get_device_mode(coredev)) {
873 case DEVICE_MODE_DVBT: 982 case DEVICE_MODE_DVBT:
874 case DEVICE_MODE_DVBT_BDA: 983 case DEVICE_MODE_DVBT_BDA:
875 smsdvb_fe_ops.delsys[0] = SYS_DVBT; 984 client->frontend.ops.delsys[0] = SYS_DVBT;
876 break; 985 break;
877 case DEVICE_MODE_ISDBT: 986 case DEVICE_MODE_ISDBT:
878 case DEVICE_MODE_ISDBT_BDA: 987 case DEVICE_MODE_ISDBT_BDA:
879 smsdvb_fe_ops.delsys[0] = SYS_ISDBT; 988 client->frontend.ops.delsys[0] = SYS_ISDBT;
880 break; 989 break;
881 } 990 }
882 991
diff --git a/drivers/media/video/davinci/isif.c b/drivers/media/video/davinci/isif.c
index 1e63852374be..5278fe7d6d0c 100644
--- a/drivers/media/video/davinci/isif.c
+++ b/drivers/media/video/davinci/isif.c
@@ -34,6 +34,7 @@
34#include <linux/videodev2.h> 34#include <linux/videodev2.h>
35#include <linux/clk.h> 35#include <linux/clk.h>
36#include <linux/err.h> 36#include <linux/err.h>
37#include <linux/module.h>
37 38
38#include <mach/mux.h> 39#include <mach/mux.h>
39 40
diff --git a/drivers/media/video/uvc/uvc_video.c b/drivers/media/video/uvc/uvc_video.c
index c7e69b8f81c9..4a44f9a1bae0 100644
--- a/drivers/media/video/uvc/uvc_video.c
+++ b/drivers/media/video/uvc/uvc_video.c
@@ -611,9 +611,11 @@ void uvc_video_clock_update(struct uvc_streaming *stream,
611 delta_stc = buf->pts - (1UL << 31); 611 delta_stc = buf->pts - (1UL << 31);
612 x1 = first->dev_stc - delta_stc; 612 x1 = first->dev_stc - delta_stc;
613 x2 = last->dev_stc - delta_stc; 613 x2 = last->dev_stc - delta_stc;
614 if (x1 == x2)
615 goto done;
616
614 y1 = (first->dev_sof + 2048) << 16; 617 y1 = (first->dev_sof + 2048) << 16;
615 y2 = (last->dev_sof + 2048) << 16; 618 y2 = (last->dev_sof + 2048) << 16;
616
617 if (y2 < y1) 619 if (y2 < y1)
618 y2 += 2048 << 16; 620 y2 += 2048 << 16;
619 621
@@ -631,14 +633,16 @@ void uvc_video_clock_update(struct uvc_streaming *stream,
631 x1, x2, y1, y2, clock->sof_offset); 633 x1, x2, y1, y2, clock->sof_offset);
632 634
633 /* Second step, SOF to host clock conversion. */ 635 /* Second step, SOF to host clock conversion. */
634 ts = timespec_sub(last->host_ts, first->host_ts);
635 x1 = (uvc_video_clock_host_sof(first) + 2048) << 16; 636 x1 = (uvc_video_clock_host_sof(first) + 2048) << 16;
636 x2 = (uvc_video_clock_host_sof(last) + 2048) << 16; 637 x2 = (uvc_video_clock_host_sof(last) + 2048) << 16;
637 y1 = NSEC_PER_SEC;
638 y2 = (ts.tv_sec + 1) * NSEC_PER_SEC + ts.tv_nsec;
639
640 if (x2 < x1) 638 if (x2 < x1)
641 x2 += 2048 << 16; 639 x2 += 2048 << 16;
640 if (x1 == x2)
641 goto done;
642
643 ts = timespec_sub(last->host_ts, first->host_ts);
644 y1 = NSEC_PER_SEC;
645 y2 = (ts.tv_sec + 1) * NSEC_PER_SEC + ts.tv_nsec;
642 646
643 /* Interpolated and host SOF timestamps can wrap around at slightly 647 /* Interpolated and host SOF timestamps can wrap around at slightly
644 * different times. Handle this by adding or removing 2048 to or from 648 * different times. Handle this by adding or removing 2048 to or from
diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c
index 254521319150..b69f8762b339 100644
--- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c
+++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c
@@ -10824,38 +10824,36 @@ do { \
10824 10824
10825int bnx2x_init_firmware(struct bnx2x *bp) 10825int bnx2x_init_firmware(struct bnx2x *bp)
10826{ 10826{
10827 const char *fw_file_name;
10827 struct bnx2x_fw_file_hdr *fw_hdr; 10828 struct bnx2x_fw_file_hdr *fw_hdr;
10828 int rc; 10829 int rc;
10829 10830
10831 if (bp->firmware)
10832 return 0;
10830 10833
10831 if (!bp->firmware) { 10834 if (CHIP_IS_E1(bp))
10832 const char *fw_file_name; 10835 fw_file_name = FW_FILE_NAME_E1;
10833 10836 else if (CHIP_IS_E1H(bp))
10834 if (CHIP_IS_E1(bp)) 10837 fw_file_name = FW_FILE_NAME_E1H;
10835 fw_file_name = FW_FILE_NAME_E1; 10838 else if (!CHIP_IS_E1x(bp))
10836 else if (CHIP_IS_E1H(bp)) 10839 fw_file_name = FW_FILE_NAME_E2;
10837 fw_file_name = FW_FILE_NAME_E1H; 10840 else {
10838 else if (!CHIP_IS_E1x(bp)) 10841 BNX2X_ERR("Unsupported chip revision\n");
10839 fw_file_name = FW_FILE_NAME_E2; 10842 return -EINVAL;
10840 else { 10843 }
10841 BNX2X_ERR("Unsupported chip revision\n"); 10844 BNX2X_DEV_INFO("Loading %s\n", fw_file_name);
10842 return -EINVAL;
10843 }
10844 BNX2X_DEV_INFO("Loading %s\n", fw_file_name);
10845 10845
10846 rc = request_firmware(&bp->firmware, fw_file_name, 10846 rc = request_firmware(&bp->firmware, fw_file_name, &bp->pdev->dev);
10847 &bp->pdev->dev); 10847 if (rc) {
10848 if (rc) { 10848 BNX2X_ERR("Can't load firmware file %s\n",
10849 BNX2X_ERR("Can't load firmware file %s\n", 10849 fw_file_name);
10850 fw_file_name); 10850 goto request_firmware_exit;
10851 goto request_firmware_exit; 10851 }
10852 }
10853 10852
10854 rc = bnx2x_check_firmware(bp); 10853 rc = bnx2x_check_firmware(bp);
10855 if (rc) { 10854 if (rc) {
10856 BNX2X_ERR("Corrupt firmware file %s\n", fw_file_name); 10855 BNX2X_ERR("Corrupt firmware file %s\n", fw_file_name);
10857 goto request_firmware_exit; 10856 goto request_firmware_exit;
10858 }
10859 } 10857 }
10860 10858
10861 fw_hdr = (struct bnx2x_fw_file_hdr *)bp->firmware->data; 10859 fw_hdr = (struct bnx2x_fw_file_hdr *)bp->firmware->data;
@@ -10901,6 +10899,7 @@ init_ops_alloc_err:
10901 kfree(bp->init_data); 10899 kfree(bp->init_data);
10902request_firmware_exit: 10900request_firmware_exit:
10903 release_firmware(bp->firmware); 10901 release_firmware(bp->firmware);
10902 bp->firmware = NULL;
10904 10903
10905 return rc; 10904 return rc;
10906} 10905}
diff --git a/drivers/net/hyperv/netvsc_drv.c b/drivers/net/hyperv/netvsc_drv.c
index bf01841bda5b..610860f28968 100644
--- a/drivers/net/hyperv/netvsc_drv.c
+++ b/drivers/net/hyperv/netvsc_drv.c
@@ -166,7 +166,7 @@ static int netvsc_start_xmit(struct sk_buff *skb, struct net_device *net)
166 166
167 dev_kfree_skb(skb); 167 dev_kfree_skb(skb);
168 net->stats.tx_dropped++; 168 net->stats.tx_dropped++;
169 return NETDEV_TX_BUSY; 169 return NETDEV_TX_OK;
170 } 170 }
171 171
172 packet->extension = (void *)(unsigned long)packet + 172 packet->extension = (void *)(unsigned long)packet +
@@ -226,7 +226,7 @@ static int netvsc_start_xmit(struct sk_buff *skb, struct net_device *net)
226 dev_kfree_skb_any(skb); 226 dev_kfree_skb_any(skb);
227 } 227 }
228 228
229 return ret ? NETDEV_TX_BUSY : NETDEV_TX_OK; 229 return NETDEV_TX_OK;
230} 230}
231 231
232/* 232/*
diff --git a/drivers/net/usb/usbnet.c b/drivers/net/usb/usbnet.c
index 81b96e303757..59681f01a54e 100644
--- a/drivers/net/usb/usbnet.c
+++ b/drivers/net/usb/usbnet.c
@@ -328,13 +328,13 @@ static int rx_submit (struct usbnet *dev, struct urb *urb, gfp_t flags)
328 unsigned long lockflags; 328 unsigned long lockflags;
329 size_t size = dev->rx_urb_size; 329 size_t size = dev->rx_urb_size;
330 330
331 if ((skb = alloc_skb (size + NET_IP_ALIGN, flags)) == NULL) { 331 skb = __netdev_alloc_skb_ip_align(dev->net, size, flags);
332 if (!skb) {
332 netif_dbg(dev, rx_err, dev->net, "no rx skb\n"); 333 netif_dbg(dev, rx_err, dev->net, "no rx skb\n");
333 usbnet_defer_kevent (dev, EVENT_RX_MEMORY); 334 usbnet_defer_kevent (dev, EVENT_RX_MEMORY);
334 usb_free_urb (urb); 335 usb_free_urb (urb);
335 return -ENOMEM; 336 return -ENOMEM;
336 } 337 }
337 skb_reserve (skb, NET_IP_ALIGN);
338 338
339 entry = (struct skb_data *) skb->cb; 339 entry = (struct skb_data *) skb->cb;
340 entry->urb = urb; 340 entry->urb = urb;
diff --git a/drivers/net/wimax/i2400m/netdev.c b/drivers/net/wimax/i2400m/netdev.c
index 64a110604ad3..63e4b709efa9 100644
--- a/drivers/net/wimax/i2400m/netdev.c
+++ b/drivers/net/wimax/i2400m/netdev.c
@@ -367,38 +367,28 @@ netdev_tx_t i2400m_hard_start_xmit(struct sk_buff *skb,
367{ 367{
368 struct i2400m *i2400m = net_dev_to_i2400m(net_dev); 368 struct i2400m *i2400m = net_dev_to_i2400m(net_dev);
369 struct device *dev = i2400m_dev(i2400m); 369 struct device *dev = i2400m_dev(i2400m);
370 int result; 370 int result = -1;
371 371
372 d_fnstart(3, dev, "(skb %p net_dev %p)\n", skb, net_dev); 372 d_fnstart(3, dev, "(skb %p net_dev %p)\n", skb, net_dev);
373 if (skb_header_cloned(skb)) { 373
374 /* 374 if (skb_header_cloned(skb) &&
375 * Make tcpdump/wireshark happy -- if they are 375 pskb_expand_head(skb, 0, 0, GFP_ATOMIC))
376 * running, the skb is cloned and we will overwrite 376 goto drop;
377 * the mac fields in i2400m_tx_prep_header. Expand
378 * seems to fix this...
379 */
380 result = pskb_expand_head(skb, 0, 0, GFP_ATOMIC);
381 if (result) {
382 result = NETDEV_TX_BUSY;
383 goto error_expand;
384 }
385 }
386 377
387 if (i2400m->state == I2400M_SS_IDLE) 378 if (i2400m->state == I2400M_SS_IDLE)
388 result = i2400m_net_wake_tx(i2400m, net_dev, skb); 379 result = i2400m_net_wake_tx(i2400m, net_dev, skb);
389 else 380 else
390 result = i2400m_net_tx(i2400m, net_dev, skb); 381 result = i2400m_net_tx(i2400m, net_dev, skb);
391 if (result < 0) 382 if (result < 0) {
383drop:
392 net_dev->stats.tx_dropped++; 384 net_dev->stats.tx_dropped++;
393 else { 385 } else {
394 net_dev->stats.tx_packets++; 386 net_dev->stats.tx_packets++;
395 net_dev->stats.tx_bytes += skb->len; 387 net_dev->stats.tx_bytes += skb->len;
396 } 388 }
397 result = NETDEV_TX_OK; 389 dev_kfree_skb(skb);
398error_expand:
399 kfree_skb(skb);
400 d_fnend(3, dev, "(skb %p net_dev %p) = %d\n", skb, net_dev, result); 390 d_fnend(3, dev, "(skb %p net_dev %p) = %d\n", skb, net_dev, result);
401 return result; 391 return NETDEV_TX_OK;
402} 392}
403 393
404 394
diff --git a/drivers/rapidio/devices/tsi721.h b/drivers/rapidio/devices/tsi721.h
index 822e54c394d5..1c226b31af13 100644
--- a/drivers/rapidio/devices/tsi721.h
+++ b/drivers/rapidio/devices/tsi721.h
@@ -118,34 +118,34 @@
118 118
119#define TSI721_IDB_ENTRY_SIZE 64 119#define TSI721_IDB_ENTRY_SIZE 64
120 120
121#define TSI721_IDQ_CTL(x) (0x20000 + (x) * 1000) 121#define TSI721_IDQ_CTL(x) (0x20000 + (x) * 0x1000)
122#define TSI721_IDQ_SUSPEND 0x00000002 122#define TSI721_IDQ_SUSPEND 0x00000002
123#define TSI721_IDQ_INIT 0x00000001 123#define TSI721_IDQ_INIT 0x00000001
124 124
125#define TSI721_IDQ_STS(x) (0x20004 + (x) * 1000) 125#define TSI721_IDQ_STS(x) (0x20004 + (x) * 0x1000)
126#define TSI721_IDQ_RUN 0x00200000 126#define TSI721_IDQ_RUN 0x00200000
127 127
128#define TSI721_IDQ_MASK(x) (0x20008 + (x) * 1000) 128#define TSI721_IDQ_MASK(x) (0x20008 + (x) * 0x1000)
129#define TSI721_IDQ_MASK_MASK 0xffff0000 129#define TSI721_IDQ_MASK_MASK 0xffff0000
130#define TSI721_IDQ_MASK_PATT 0x0000ffff 130#define TSI721_IDQ_MASK_PATT 0x0000ffff
131 131
132#define TSI721_IDQ_RP(x) (0x2000c + (x) * 1000) 132#define TSI721_IDQ_RP(x) (0x2000c + (x) * 0x1000)
133#define TSI721_IDQ_RP_PTR 0x0007ffff 133#define TSI721_IDQ_RP_PTR 0x0007ffff
134 134
135#define TSI721_IDQ_WP(x) (0x20010 + (x) * 1000) 135#define TSI721_IDQ_WP(x) (0x20010 + (x) * 0x1000)
136#define TSI721_IDQ_WP_PTR 0x0007ffff 136#define TSI721_IDQ_WP_PTR 0x0007ffff
137 137
138#define TSI721_IDQ_BASEL(x) (0x20014 + (x) * 1000) 138#define TSI721_IDQ_BASEL(x) (0x20014 + (x) * 0x1000)
139#define TSI721_IDQ_BASEL_ADDR 0xffffffc0 139#define TSI721_IDQ_BASEL_ADDR 0xffffffc0
140#define TSI721_IDQ_BASEU(x) (0x20018 + (x) * 1000) 140#define TSI721_IDQ_BASEU(x) (0x20018 + (x) * 0x1000)
141#define TSI721_IDQ_SIZE(x) (0x2001c + (x) * 1000) 141#define TSI721_IDQ_SIZE(x) (0x2001c + (x) * 0x1000)
142#define TSI721_IDQ_SIZE_VAL(size) (__fls(size) - 4) 142#define TSI721_IDQ_SIZE_VAL(size) (__fls(size) - 4)
143#define TSI721_IDQ_SIZE_MIN 512 143#define TSI721_IDQ_SIZE_MIN 512
144#define TSI721_IDQ_SIZE_MAX (512 * 1024) 144#define TSI721_IDQ_SIZE_MAX (512 * 1024)
145 145
146#define TSI721_SR_CHINT(x) (0x20040 + (x) * 1000) 146#define TSI721_SR_CHINT(x) (0x20040 + (x) * 0x1000)
147#define TSI721_SR_CHINTE(x) (0x20044 + (x) * 1000) 147#define TSI721_SR_CHINTE(x) (0x20044 + (x) * 0x1000)
148#define TSI721_SR_CHINTSET(x) (0x20048 + (x) * 1000) 148#define TSI721_SR_CHINTSET(x) (0x20048 + (x) * 0x1000)
149#define TSI721_SR_CHINT_ODBOK 0x00000020 149#define TSI721_SR_CHINT_ODBOK 0x00000020
150#define TSI721_SR_CHINT_IDBQRCV 0x00000010 150#define TSI721_SR_CHINT_IDBQRCV 0x00000010
151#define TSI721_SR_CHINT_SUSP 0x00000008 151#define TSI721_SR_CHINT_SUSP 0x00000008
@@ -156,7 +156,7 @@
156 156
157#define TSI721_IBWIN_NUM 8 157#define TSI721_IBWIN_NUM 8
158 158
159#define TSI721_IBWINLB(x) (0x29000 + (x) * 20) 159#define TSI721_IBWINLB(x) (0x29000 + (x) * 0x20)
160#define TSI721_IBWINLB_BA 0xfffff000 160#define TSI721_IBWINLB_BA 0xfffff000
161#define TSI721_IBWINLB_WEN 0x00000001 161#define TSI721_IBWINLB_WEN 0x00000001
162 162
@@ -187,13 +187,13 @@
187 */ 187 */
188#define TSI721_OBWIN_NUM TSI721_PC2SR_WINS 188#define TSI721_OBWIN_NUM TSI721_PC2SR_WINS
189 189
190#define TSI721_OBWINLB(x) (0x40000 + (x) * 20) 190#define TSI721_OBWINLB(x) (0x40000 + (x) * 0x20)
191#define TSI721_OBWINLB_BA 0xffff8000 191#define TSI721_OBWINLB_BA 0xffff8000
192#define TSI721_OBWINLB_WEN 0x00000001 192#define TSI721_OBWINLB_WEN 0x00000001
193 193
194#define TSI721_OBWINUB(x) (0x40004 + (x) * 20) 194#define TSI721_OBWINUB(x) (0x40004 + (x) * 0x20)
195 195
196#define TSI721_OBWINSZ(x) (0x40008 + (x) * 20) 196#define TSI721_OBWINSZ(x) (0x40008 + (x) * 0x20)
197#define TSI721_OBWINSZ_SIZE 0x00001f00 197#define TSI721_OBWINSZ_SIZE 0x00001f00
198#define TSI721_OBWIN_SIZE(size) (__fls(size) - 15) 198#define TSI721_OBWIN_SIZE(size) (__fls(size) - 15)
199 199
diff --git a/drivers/regulator/da9052-regulator.c b/drivers/regulator/da9052-regulator.c
index ea4d8f575ac6..09915e89705d 100644
--- a/drivers/regulator/da9052-regulator.c
+++ b/drivers/regulator/da9052-regulator.c
@@ -226,7 +226,7 @@ static int da9052_regulator_set_voltage_int(struct regulator_dev *rdev,
226 if (min_uV < info->min_uV) 226 if (min_uV < info->min_uV)
227 min_uV = info->min_uV; 227 min_uV = info->min_uV;
228 228
229 *selector = (min_uV - info->min_uV) / info->step_uV; 229 *selector = DIV_ROUND_UP(min_uV - info->min_uV, info->step_uV);
230 230
231 ret = da9052_list_voltage(rdev, *selector); 231 ret = da9052_list_voltage(rdev, *selector);
232 if (ret < 0) 232 if (ret < 0)
@@ -318,10 +318,10 @@ static int da9052_set_buckperi_voltage(struct regulator_dev *rdev, int min_uV,
318 if ((regulator->da9052->chip_id == DA9052) && 318 if ((regulator->da9052->chip_id == DA9052) &&
319 (min_uV >= DA9052_CONST_3uV)) 319 (min_uV >= DA9052_CONST_3uV))
320 *selector = DA9052_BUCK_PERI_REG_MAP_UPTO_3uV + 320 *selector = DA9052_BUCK_PERI_REG_MAP_UPTO_3uV +
321 ((min_uV - DA9052_CONST_3uV) / 321 DIV_ROUND_UP(min_uV - DA9052_CONST_3uV,
322 (DA9052_BUCK_PERI_3uV_STEP)); 322 DA9052_BUCK_PERI_3uV_STEP);
323 else 323 else
324 *selector = (min_uV - info->min_uV) / info->step_uV; 324 *selector = DIV_ROUND_UP(min_uV - info->min_uV, info->step_uV);
325 325
326 ret = da9052_list_buckperi_voltage(rdev, *selector); 326 ret = da9052_list_buckperi_voltage(rdev, *selector);
327 if (ret < 0) 327 if (ret < 0)
@@ -400,6 +400,7 @@ static struct regulator_ops da9052_ldo_ops = {
400 .ops = &da9052_ldo5_6_ops,\ 400 .ops = &da9052_ldo5_6_ops,\
401 .type = REGULATOR_VOLTAGE,\ 401 .type = REGULATOR_VOLTAGE,\
402 .id = _id,\ 402 .id = _id,\
403 .n_voltages = (max - min) / step + 1, \
403 .owner = THIS_MODULE,\ 404 .owner = THIS_MODULE,\
404 },\ 405 },\
405 .min_uV = (min) * 1000,\ 406 .min_uV = (min) * 1000,\
@@ -417,6 +418,7 @@ static struct regulator_ops da9052_ldo_ops = {
417 .ops = &da9052_ldo_ops,\ 418 .ops = &da9052_ldo_ops,\
418 .type = REGULATOR_VOLTAGE,\ 419 .type = REGULATOR_VOLTAGE,\
419 .id = _id,\ 420 .id = _id,\
421 .n_voltages = (max - min) / step + 1, \
420 .owner = THIS_MODULE,\ 422 .owner = THIS_MODULE,\
421 },\ 423 },\
422 .min_uV = (min) * 1000,\ 424 .min_uV = (min) * 1000,\
@@ -434,6 +436,7 @@ static struct regulator_ops da9052_ldo_ops = {
434 .ops = &da9052_dcdc_ops,\ 436 .ops = &da9052_dcdc_ops,\
435 .type = REGULATOR_VOLTAGE,\ 437 .type = REGULATOR_VOLTAGE,\
436 .id = _id,\ 438 .id = _id,\
439 .n_voltages = (max - min) / step + 1, \
437 .owner = THIS_MODULE,\ 440 .owner = THIS_MODULE,\
438 },\ 441 },\
439 .min_uV = (min) * 1000,\ 442 .min_uV = (min) * 1000,\
@@ -451,6 +454,7 @@ static struct regulator_ops da9052_ldo_ops = {
451 .ops = &da9052_buckperi_ops,\ 454 .ops = &da9052_buckperi_ops,\
452 .type = REGULATOR_VOLTAGE,\ 455 .type = REGULATOR_VOLTAGE,\
453 .id = _id,\ 456 .id = _id,\
457 .n_voltages = (max - min) / step + 1, \
454 .owner = THIS_MODULE,\ 458 .owner = THIS_MODULE,\
455 },\ 459 },\
456 .min_uV = (min) * 1000,\ 460 .min_uV = (min) * 1000,\
diff --git a/drivers/regulator/tps6524x-regulator.c b/drivers/regulator/tps6524x-regulator.c
index 70b7b1f4f000..2e94686b6fe6 100644
--- a/drivers/regulator/tps6524x-regulator.c
+++ b/drivers/regulator/tps6524x-regulator.c
@@ -481,7 +481,7 @@ static int set_voltage(struct regulator_dev *rdev, int min_uV, int max_uV,
481 if (i >= info->n_voltages) 481 if (i >= info->n_voltages)
482 i = info->n_voltages - 1; 482 i = info->n_voltages - 1;
483 483
484 *selector = info->voltages[i]; 484 *selector = i;
485 485
486 return write_field(hw, &info->voltage, i); 486 return write_field(hw, &info->voltage, i);
487} 487}
diff --git a/drivers/rtc/interface.c b/drivers/rtc/interface.c
index 8a1c031391d6..dc87eda65814 100644
--- a/drivers/rtc/interface.c
+++ b/drivers/rtc/interface.c
@@ -73,6 +73,8 @@ int rtc_set_time(struct rtc_device *rtc, struct rtc_time *tm)
73 err = -EINVAL; 73 err = -EINVAL;
74 74
75 mutex_unlock(&rtc->ops_lock); 75 mutex_unlock(&rtc->ops_lock);
76 /* A timer might have just expired */
77 schedule_work(&rtc->irqwork);
76 return err; 78 return err;
77} 79}
78EXPORT_SYMBOL_GPL(rtc_set_time); 80EXPORT_SYMBOL_GPL(rtc_set_time);
@@ -112,6 +114,8 @@ int rtc_set_mmss(struct rtc_device *rtc, unsigned long secs)
112 err = -EINVAL; 114 err = -EINVAL;
113 115
114 mutex_unlock(&rtc->ops_lock); 116 mutex_unlock(&rtc->ops_lock);
117 /* A timer might have just expired */
118 schedule_work(&rtc->irqwork);
115 119
116 return err; 120 return err;
117} 121}
@@ -380,18 +384,27 @@ EXPORT_SYMBOL_GPL(rtc_set_alarm);
380int rtc_initialize_alarm(struct rtc_device *rtc, struct rtc_wkalrm *alarm) 384int rtc_initialize_alarm(struct rtc_device *rtc, struct rtc_wkalrm *alarm)
381{ 385{
382 int err; 386 int err;
387 struct rtc_time now;
383 388
384 err = rtc_valid_tm(&alarm->time); 389 err = rtc_valid_tm(&alarm->time);
385 if (err != 0) 390 if (err != 0)
386 return err; 391 return err;
387 392
393 err = rtc_read_time(rtc, &now);
394 if (err)
395 return err;
396
388 err = mutex_lock_interruptible(&rtc->ops_lock); 397 err = mutex_lock_interruptible(&rtc->ops_lock);
389 if (err) 398 if (err)
390 return err; 399 return err;
391 400
392 rtc->aie_timer.node.expires = rtc_tm_to_ktime(alarm->time); 401 rtc->aie_timer.node.expires = rtc_tm_to_ktime(alarm->time);
393 rtc->aie_timer.period = ktime_set(0, 0); 402 rtc->aie_timer.period = ktime_set(0, 0);
394 if (alarm->enabled) { 403
404 /* Alarm has to be enabled & in the futrure for us to enqueue it */
405 if (alarm->enabled && (rtc_tm_to_ktime(now).tv64 <
406 rtc->aie_timer.node.expires.tv64)) {
407
395 rtc->aie_timer.enabled = 1; 408 rtc->aie_timer.enabled = 1;
396 timerqueue_add(&rtc->timerqueue, &rtc->aie_timer.node); 409 timerqueue_add(&rtc->timerqueue, &rtc->aie_timer.node);
397 } 410 }
@@ -763,6 +776,14 @@ static int rtc_timer_enqueue(struct rtc_device *rtc, struct rtc_timer *timer)
763 return 0; 776 return 0;
764} 777}
765 778
779static void rtc_alarm_disable(struct rtc_device *rtc)
780{
781 if (!rtc->ops || !rtc->ops->alarm_irq_enable)
782 return;
783
784 rtc->ops->alarm_irq_enable(rtc->dev.parent, false);
785}
786
766/** 787/**
767 * rtc_timer_remove - Removes a rtc_timer from the rtc_device timerqueue 788 * rtc_timer_remove - Removes a rtc_timer from the rtc_device timerqueue
768 * @rtc rtc device 789 * @rtc rtc device
@@ -784,8 +805,10 @@ static void rtc_timer_remove(struct rtc_device *rtc, struct rtc_timer *timer)
784 struct rtc_wkalrm alarm; 805 struct rtc_wkalrm alarm;
785 int err; 806 int err;
786 next = timerqueue_getnext(&rtc->timerqueue); 807 next = timerqueue_getnext(&rtc->timerqueue);
787 if (!next) 808 if (!next) {
809 rtc_alarm_disable(rtc);
788 return; 810 return;
811 }
789 alarm.time = rtc_ktime_to_tm(next->expires); 812 alarm.time = rtc_ktime_to_tm(next->expires);
790 alarm.enabled = 1; 813 alarm.enabled = 1;
791 err = __rtc_set_alarm(rtc, &alarm); 814 err = __rtc_set_alarm(rtc, &alarm);
@@ -847,7 +870,8 @@ again:
847 err = __rtc_set_alarm(rtc, &alarm); 870 err = __rtc_set_alarm(rtc, &alarm);
848 if (err == -ETIME) 871 if (err == -ETIME)
849 goto again; 872 goto again;
850 } 873 } else
874 rtc_alarm_disable(rtc);
851 875
852 mutex_unlock(&rtc->ops_lock); 876 mutex_unlock(&rtc->ops_lock);
853} 877}
diff --git a/drivers/target/iscsi/iscsi_target.c b/drivers/target/iscsi/iscsi_target.c
index 44262908def5..501b27c18145 100644
--- a/drivers/target/iscsi/iscsi_target.c
+++ b/drivers/target/iscsi/iscsi_target.c
@@ -1028,7 +1028,7 @@ done:
1028 return iscsit_add_reject_from_cmd( 1028 return iscsit_add_reject_from_cmd(
1029 ISCSI_REASON_BOOKMARK_NO_RESOURCES, 1029 ISCSI_REASON_BOOKMARK_NO_RESOURCES,
1030 1, 1, buf, cmd); 1030 1, 1, buf, cmd);
1031 } else if (transport_ret == -EINVAL) { 1031 } else if (transport_ret < 0) {
1032 /* 1032 /*
1033 * Unsupported SAM Opcode. CHECK_CONDITION will be sent 1033 * Unsupported SAM Opcode. CHECK_CONDITION will be sent
1034 * in iscsit_execute_cmd() during the CmdSN OOO Execution 1034 * in iscsit_execute_cmd() during the CmdSN OOO Execution
diff --git a/drivers/target/target_core_pr.c b/drivers/target/target_core_pr.c
index b7c779389eea..63e703bb6ac9 100644
--- a/drivers/target/target_core_pr.c
+++ b/drivers/target/target_core_pr.c
@@ -117,7 +117,7 @@ static struct t10_pr_registration *core_scsi3_locate_pr_reg(struct se_device *,
117 struct se_node_acl *, struct se_session *); 117 struct se_node_acl *, struct se_session *);
118static void core_scsi3_put_pr_reg(struct t10_pr_registration *); 118static void core_scsi3_put_pr_reg(struct t10_pr_registration *);
119 119
120static int target_check_scsi2_reservation_conflict(struct se_cmd *cmd, int *ret) 120static int target_check_scsi2_reservation_conflict(struct se_cmd *cmd)
121{ 121{
122 struct se_session *se_sess = cmd->se_sess; 122 struct se_session *se_sess = cmd->se_sess;
123 struct se_subsystem_dev *su_dev = cmd->se_dev->se_sub_dev; 123 struct se_subsystem_dev *su_dev = cmd->se_dev->se_sub_dev;
@@ -127,7 +127,7 @@ static int target_check_scsi2_reservation_conflict(struct se_cmd *cmd, int *ret)
127 int conflict = 0; 127 int conflict = 0;
128 128
129 if (!crh) 129 if (!crh)
130 return false; 130 return -EINVAL;
131 131
132 pr_reg = core_scsi3_locate_pr_reg(cmd->se_dev, se_sess->se_node_acl, 132 pr_reg = core_scsi3_locate_pr_reg(cmd->se_dev, se_sess->se_node_acl,
133 se_sess); 133 se_sess);
@@ -155,16 +155,14 @@ static int target_check_scsi2_reservation_conflict(struct se_cmd *cmd, int *ret)
155 */ 155 */
156 if (pr_reg->pr_res_holder) { 156 if (pr_reg->pr_res_holder) {
157 core_scsi3_put_pr_reg(pr_reg); 157 core_scsi3_put_pr_reg(pr_reg);
158 *ret = 0; 158 return 1;
159 return false;
160 } 159 }
161 if ((pr_reg->pr_res_type == PR_TYPE_WRITE_EXCLUSIVE_REGONLY) || 160 if ((pr_reg->pr_res_type == PR_TYPE_WRITE_EXCLUSIVE_REGONLY) ||
162 (pr_reg->pr_res_type == PR_TYPE_EXCLUSIVE_ACCESS_REGONLY) || 161 (pr_reg->pr_res_type == PR_TYPE_EXCLUSIVE_ACCESS_REGONLY) ||
163 (pr_reg->pr_res_type == PR_TYPE_WRITE_EXCLUSIVE_ALLREG) || 162 (pr_reg->pr_res_type == PR_TYPE_WRITE_EXCLUSIVE_ALLREG) ||
164 (pr_reg->pr_res_type == PR_TYPE_EXCLUSIVE_ACCESS_ALLREG)) { 163 (pr_reg->pr_res_type == PR_TYPE_EXCLUSIVE_ACCESS_ALLREG)) {
165 core_scsi3_put_pr_reg(pr_reg); 164 core_scsi3_put_pr_reg(pr_reg);
166 *ret = 0; 165 return 1;
167 return true;
168 } 166 }
169 core_scsi3_put_pr_reg(pr_reg); 167 core_scsi3_put_pr_reg(pr_reg);
170 conflict = 1; 168 conflict = 1;
@@ -189,10 +187,10 @@ static int target_check_scsi2_reservation_conflict(struct se_cmd *cmd, int *ret)
189 " while active SPC-3 registrations exist," 187 " while active SPC-3 registrations exist,"
190 " returning RESERVATION_CONFLICT\n"); 188 " returning RESERVATION_CONFLICT\n");
191 cmd->scsi_sense_reason = TCM_RESERVATION_CONFLICT; 189 cmd->scsi_sense_reason = TCM_RESERVATION_CONFLICT;
192 return true; 190 return -EBUSY;
193 } 191 }
194 192
195 return false; 193 return 0;
196} 194}
197 195
198int target_scsi2_reservation_release(struct se_task *task) 196int target_scsi2_reservation_release(struct se_task *task)
@@ -201,12 +199,18 @@ int target_scsi2_reservation_release(struct se_task *task)
201 struct se_device *dev = cmd->se_dev; 199 struct se_device *dev = cmd->se_dev;
202 struct se_session *sess = cmd->se_sess; 200 struct se_session *sess = cmd->se_sess;
203 struct se_portal_group *tpg = sess->se_tpg; 201 struct se_portal_group *tpg = sess->se_tpg;
204 int ret = 0; 202 int ret = 0, rc;
205 203
206 if (!sess || !tpg) 204 if (!sess || !tpg)
207 goto out; 205 goto out;
208 if (target_check_scsi2_reservation_conflict(cmd, &ret)) 206 rc = target_check_scsi2_reservation_conflict(cmd);
207 if (rc == 1)
208 goto out;
209 else if (rc < 0) {
210 cmd->scsi_sense_reason = TCM_RESERVATION_CONFLICT;
211 ret = -EINVAL;
209 goto out; 212 goto out;
213 }
210 214
211 ret = 0; 215 ret = 0;
212 spin_lock(&dev->dev_reservation_lock); 216 spin_lock(&dev->dev_reservation_lock);
@@ -243,7 +247,7 @@ int target_scsi2_reservation_reserve(struct se_task *task)
243 struct se_device *dev = cmd->se_dev; 247 struct se_device *dev = cmd->se_dev;
244 struct se_session *sess = cmd->se_sess; 248 struct se_session *sess = cmd->se_sess;
245 struct se_portal_group *tpg = sess->se_tpg; 249 struct se_portal_group *tpg = sess->se_tpg;
246 int ret = 0; 250 int ret = 0, rc;
247 251
248 if ((cmd->t_task_cdb[1] & 0x01) && 252 if ((cmd->t_task_cdb[1] & 0x01) &&
249 (cmd->t_task_cdb[1] & 0x02)) { 253 (cmd->t_task_cdb[1] & 0x02)) {
@@ -259,8 +263,14 @@ int target_scsi2_reservation_reserve(struct se_task *task)
259 */ 263 */
260 if (!sess || !tpg) 264 if (!sess || !tpg)
261 goto out; 265 goto out;
262 if (target_check_scsi2_reservation_conflict(cmd, &ret)) 266 rc = target_check_scsi2_reservation_conflict(cmd);
267 if (rc == 1)
263 goto out; 268 goto out;
269 else if (rc < 0) {
270 cmd->scsi_sense_reason = TCM_RESERVATION_CONFLICT;
271 ret = -EINVAL;
272 goto out;
273 }
264 274
265 ret = 0; 275 ret = 0;
266 spin_lock(&dev->dev_reservation_lock); 276 spin_lock(&dev->dev_reservation_lock);
diff --git a/drivers/target/target_core_transport.c b/drivers/target/target_core_transport.c
index 58cea07b12fb..cd5cd95812bb 100644
--- a/drivers/target/target_core_transport.c
+++ b/drivers/target/target_core_transport.c
@@ -2539,6 +2539,7 @@ static int transport_generic_cmd_sequencer(
2539 cmd, cdb, pr_reg_type) != 0) { 2539 cmd, cdb, pr_reg_type) != 0) {
2540 cmd->se_cmd_flags |= SCF_SCSI_CDB_EXCEPTION; 2540 cmd->se_cmd_flags |= SCF_SCSI_CDB_EXCEPTION;
2541 cmd->se_cmd_flags |= SCF_SCSI_RESERVATION_CONFLICT; 2541 cmd->se_cmd_flags |= SCF_SCSI_RESERVATION_CONFLICT;
2542 cmd->scsi_status = SAM_STAT_RESERVATION_CONFLICT;
2542 cmd->scsi_sense_reason = TCM_RESERVATION_CONFLICT; 2543 cmd->scsi_sense_reason = TCM_RESERVATION_CONFLICT;
2543 return -EBUSY; 2544 return -EBUSY;
2544 } 2545 }
diff --git a/drivers/target/tcm_fc/tfc_sess.c b/drivers/target/tcm_fc/tfc_sess.c
index 4c0507cf808c..eff512b5a2a0 100644
--- a/drivers/target/tcm_fc/tfc_sess.c
+++ b/drivers/target/tcm_fc/tfc_sess.c
@@ -86,16 +86,6 @@ static struct ft_tport *ft_tport_create(struct fc_lport *lport)
86} 86}
87 87
88/* 88/*
89 * Free tport via RCU.
90 */
91static void ft_tport_rcu_free(struct rcu_head *rcu)
92{
93 struct ft_tport *tport = container_of(rcu, struct ft_tport, rcu);
94
95 kfree(tport);
96}
97
98/*
99 * Delete a target local port. 89 * Delete a target local port.
100 * Caller holds ft_lport_lock. 90 * Caller holds ft_lport_lock.
101 */ 91 */
@@ -114,7 +104,7 @@ static void ft_tport_delete(struct ft_tport *tport)
114 tpg->tport = NULL; 104 tpg->tport = NULL;
115 tport->tpg = NULL; 105 tport->tpg = NULL;
116 } 106 }
117 call_rcu(&tport->rcu, ft_tport_rcu_free); 107 kfree_rcu(tport, rcu);
118} 108}
119 109
120/* 110/*
diff --git a/drivers/video/backlight/s6e63m0.c b/drivers/video/backlight/s6e63m0.c
index e132157d8545..516db703dd24 100644
--- a/drivers/video/backlight/s6e63m0.c
+++ b/drivers/video/backlight/s6e63m0.c
@@ -690,7 +690,7 @@ static ssize_t s6e63m0_sysfs_store_gamma_mode(struct device *dev,
690 struct backlight_device *bd = NULL; 690 struct backlight_device *bd = NULL;
691 int brightness, rc; 691 int brightness, rc;
692 692
693 rc = strict_strtoul(buf, 0, (unsigned long *)&lcd->gamma_mode); 693 rc = kstrtouint(buf, 0, &lcd->gamma_mode);
694 if (rc < 0) 694 if (rc < 0)
695 return rc; 695 return rc;
696 696
diff --git a/fs/Kconfig b/fs/Kconfig
index d621f02a3f9e..aa195265362f 100644
--- a/fs/Kconfig
+++ b/fs/Kconfig
@@ -4,6 +4,10 @@
4 4
5menu "File systems" 5menu "File systems"
6 6
7# Use unaligned word dcache accesses
8config DCACHE_WORD_ACCESS
9 bool
10
7if BLOCK 11if BLOCK
8 12
9source "fs/ext2/Kconfig" 13source "fs/ext2/Kconfig"
diff --git a/fs/afs/file.c b/fs/afs/file.c
index 14d89fa58fee..8f6e9234d565 100644
--- a/fs/afs/file.c
+++ b/fs/afs/file.c
@@ -251,7 +251,7 @@ static int afs_readpages(struct file *file, struct address_space *mapping,
251 ASSERT(key != NULL); 251 ASSERT(key != NULL);
252 252
253 vnode = AFS_FS_I(mapping->host); 253 vnode = AFS_FS_I(mapping->host);
254 if (vnode->flags & AFS_VNODE_DELETED) { 254 if (test_bit(AFS_VNODE_DELETED, &vnode->flags)) {
255 _leave(" = -ESTALE"); 255 _leave(" = -ESTALE");
256 return -ESTALE; 256 return -ESTALE;
257 } 257 }
diff --git a/fs/afs/internal.h b/fs/afs/internal.h
index d2b0888126d4..a306bb6d88d9 100644
--- a/fs/afs/internal.h
+++ b/fs/afs/internal.h
@@ -109,7 +109,7 @@ struct afs_call {
109 unsigned reply_size; /* current size of reply */ 109 unsigned reply_size; /* current size of reply */
110 unsigned first_offset; /* offset into mapping[first] */ 110 unsigned first_offset; /* offset into mapping[first] */
111 unsigned last_to; /* amount of mapping[last] */ 111 unsigned last_to; /* amount of mapping[last] */
112 unsigned short offset; /* offset into received data store */ 112 unsigned offset; /* offset into received data store */
113 unsigned char unmarshall; /* unmarshalling phase */ 113 unsigned char unmarshall; /* unmarshalling phase */
114 bool incoming; /* T if incoming call */ 114 bool incoming; /* T if incoming call */
115 bool send_pages; /* T if data from mapping should be sent */ 115 bool send_pages; /* T if data from mapping should be sent */
diff --git a/fs/afs/rxrpc.c b/fs/afs/rxrpc.c
index e45a323aebb4..8ad8c2a0703a 100644
--- a/fs/afs/rxrpc.c
+++ b/fs/afs/rxrpc.c
@@ -314,6 +314,7 @@ int afs_make_call(struct in_addr *addr, struct afs_call *call, gfp_t gfp,
314 struct msghdr msg; 314 struct msghdr msg;
315 struct kvec iov[1]; 315 struct kvec iov[1];
316 int ret; 316 int ret;
317 struct sk_buff *skb;
317 318
318 _enter("%x,{%d},", addr->s_addr, ntohs(call->port)); 319 _enter("%x,{%d},", addr->s_addr, ntohs(call->port));
319 320
@@ -380,6 +381,8 @@ int afs_make_call(struct in_addr *addr, struct afs_call *call, gfp_t gfp,
380 381
381error_do_abort: 382error_do_abort:
382 rxrpc_kernel_abort_call(rxcall, RX_USER_ABORT); 383 rxrpc_kernel_abort_call(rxcall, RX_USER_ABORT);
384 while ((skb = skb_dequeue(&call->rx_queue)))
385 afs_free_skb(skb);
383 rxrpc_kernel_end_call(rxcall); 386 rxrpc_kernel_end_call(rxcall);
384 call->rxcall = NULL; 387 call->rxcall = NULL;
385error_kill_call: 388error_kill_call:
diff --git a/fs/block_dev.c b/fs/block_dev.c
index 0e575d1304b4..5e9f198f7712 100644
--- a/fs/block_dev.c
+++ b/fs/block_dev.c
@@ -1183,8 +1183,12 @@ static int __blkdev_get(struct block_device *bdev, fmode_t mode, int for_part)
1183 * The latter is necessary to prevent ghost 1183 * The latter is necessary to prevent ghost
1184 * partitions on a removed medium. 1184 * partitions on a removed medium.
1185 */ 1185 */
1186 if (bdev->bd_invalidated && (!ret || ret == -ENOMEDIUM)) 1186 if (bdev->bd_invalidated) {
1187 rescan_partitions(disk, bdev); 1187 if (!ret)
1188 rescan_partitions(disk, bdev);
1189 else if (ret == -ENOMEDIUM)
1190 invalidate_partitions(disk, bdev);
1191 }
1188 if (ret) 1192 if (ret)
1189 goto out_clear; 1193 goto out_clear;
1190 } else { 1194 } else {
@@ -1214,8 +1218,12 @@ static int __blkdev_get(struct block_device *bdev, fmode_t mode, int for_part)
1214 if (bdev->bd_disk->fops->open) 1218 if (bdev->bd_disk->fops->open)
1215 ret = bdev->bd_disk->fops->open(bdev, mode); 1219 ret = bdev->bd_disk->fops->open(bdev, mode);
1216 /* the same as first opener case, read comment there */ 1220 /* the same as first opener case, read comment there */
1217 if (bdev->bd_invalidated && (!ret || ret == -ENOMEDIUM)) 1221 if (bdev->bd_invalidated) {
1218 rescan_partitions(bdev->bd_disk, bdev); 1222 if (!ret)
1223 rescan_partitions(bdev->bd_disk, bdev);
1224 else if (ret == -ENOMEDIUM)
1225 invalidate_partitions(bdev->bd_disk, bdev);
1226 }
1219 if (ret) 1227 if (ret)
1220 goto out_unlock_bdev; 1228 goto out_unlock_bdev;
1221 } 1229 }
diff --git a/fs/dcache.c b/fs/dcache.c
index bcbdb33fcc20..11828de68dce 100644
--- a/fs/dcache.c
+++ b/fs/dcache.c
@@ -105,10 +105,10 @@ static unsigned int d_hash_shift __read_mostly;
105static struct hlist_bl_head *dentry_hashtable __read_mostly; 105static struct hlist_bl_head *dentry_hashtable __read_mostly;
106 106
107static inline struct hlist_bl_head *d_hash(const struct dentry *parent, 107static inline struct hlist_bl_head *d_hash(const struct dentry *parent,
108 unsigned long hash) 108 unsigned int hash)
109{ 109{
110 hash += ((unsigned long) parent ^ GOLDEN_RATIO_PRIME) / L1_CACHE_BYTES; 110 hash += (unsigned long) parent / L1_CACHE_BYTES;
111 hash = hash ^ ((hash ^ GOLDEN_RATIO_PRIME) >> D_HASHBITS); 111 hash = hash + (hash >> D_HASHBITS);
112 return dentry_hashtable + (hash & D_HASHMASK); 112 return dentry_hashtable + (hash & D_HASHMASK);
113} 113}
114 114
@@ -144,6 +144,28 @@ int proc_nr_dentry(ctl_table *table, int write, void __user *buffer,
144static inline int dentry_cmp(const unsigned char *cs, size_t scount, 144static inline int dentry_cmp(const unsigned char *cs, size_t scount,
145 const unsigned char *ct, size_t tcount) 145 const unsigned char *ct, size_t tcount)
146{ 146{
147#ifdef CONFIG_DCACHE_WORD_ACCESS
148 unsigned long a,b,mask;
149
150 if (unlikely(scount != tcount))
151 return 1;
152
153 for (;;) {
154 a = *(unsigned long *)cs;
155 b = *(unsigned long *)ct;
156 if (tcount < sizeof(unsigned long))
157 break;
158 if (unlikely(a != b))
159 return 1;
160 cs += sizeof(unsigned long);
161 ct += sizeof(unsigned long);
162 tcount -= sizeof(unsigned long);
163 if (!tcount)
164 return 0;
165 }
166 mask = ~(~0ul << tcount*8);
167 return unlikely(!!((a ^ b) & mask));
168#else
147 if (scount != tcount) 169 if (scount != tcount)
148 return 1; 170 return 1;
149 171
@@ -155,6 +177,7 @@ static inline int dentry_cmp(const unsigned char *cs, size_t scount,
155 tcount--; 177 tcount--;
156 } while (tcount); 178 } while (tcount);
157 return 0; 179 return 0;
180#endif
158} 181}
159 182
160static void __d_free(struct rcu_head *head) 183static void __d_free(struct rcu_head *head)
diff --git a/fs/eventpoll.c b/fs/eventpoll.c
index ea54cdef04dd..4d9d3a45e356 100644
--- a/fs/eventpoll.c
+++ b/fs/eventpoll.c
@@ -988,6 +988,10 @@ static int path_count[PATH_ARR_SIZE];
988 988
989static int path_count_inc(int nests) 989static int path_count_inc(int nests)
990{ 990{
991 /* Allow an arbitrary number of depth 1 paths */
992 if (nests == 0)
993 return 0;
994
991 if (++path_count[nests] > path_limits[nests]) 995 if (++path_count[nests] > path_limits[nests])
992 return -1; 996 return -1;
993 return 0; 997 return 0;
diff --git a/fs/exec.c b/fs/exec.c
index 153dee14fe55..b0695a9900ef 100644
--- a/fs/exec.c
+++ b/fs/exec.c
@@ -63,6 +63,8 @@
63#include <trace/events/task.h> 63#include <trace/events/task.h>
64#include "internal.h" 64#include "internal.h"
65 65
66#include <trace/events/sched.h>
67
66int core_uses_pid; 68int core_uses_pid;
67char core_pattern[CORENAME_MAX_SIZE] = "core"; 69char core_pattern[CORENAME_MAX_SIZE] = "core";
68unsigned int core_pipe_limit; 70unsigned int core_pipe_limit;
@@ -1402,9 +1404,10 @@ int search_binary_handler(struct linux_binprm *bprm,struct pt_regs *regs)
1402 */ 1404 */
1403 bprm->recursion_depth = depth; 1405 bprm->recursion_depth = depth;
1404 if (retval >= 0) { 1406 if (retval >= 0) {
1405 if (depth == 0) 1407 if (depth == 0) {
1406 ptrace_event(PTRACE_EVENT_EXEC, 1408 trace_sched_process_exec(current, old_pid, bprm);
1407 old_pid); 1409 ptrace_event(PTRACE_EVENT_EXEC, old_pid);
1410 }
1408 put_binfmt(fmt); 1411 put_binfmt(fmt);
1409 allow_write_access(bprm->file); 1412 allow_write_access(bprm->file);
1410 if (bprm->file) 1413 if (bprm->file)
diff --git a/fs/namei.c b/fs/namei.c
index 46ea9cc16647..fa96a26d3291 100644
--- a/fs/namei.c
+++ b/fs/namei.c
@@ -1374,6 +1374,126 @@ static inline int can_lookup(struct inode *inode)
1374 return 1; 1374 return 1;
1375} 1375}
1376 1376
1377/*
1378 * We can do the critical dentry name comparison and hashing
1379 * operations one word at a time, but we are limited to:
1380 *
1381 * - Architectures with fast unaligned word accesses. We could
1382 * do a "get_unaligned()" if this helps and is sufficiently
1383 * fast.
1384 *
1385 * - Little-endian machines (so that we can generate the mask
1386 * of low bytes efficiently). Again, we *could* do a byte
1387 * swapping load on big-endian architectures if that is not
1388 * expensive enough to make the optimization worthless.
1389 *
1390 * - non-CONFIG_DEBUG_PAGEALLOC configurations (so that we
1391 * do not trap on the (extremely unlikely) case of a page
1392 * crossing operation.
1393 *
1394 * - Furthermore, we need an efficient 64-bit compile for the
1395 * 64-bit case in order to generate the "number of bytes in
1396 * the final mask". Again, that could be replaced with a
1397 * efficient population count instruction or similar.
1398 */
1399#ifdef CONFIG_DCACHE_WORD_ACCESS
1400
1401#ifdef CONFIG_64BIT
1402
1403/*
1404 * Jan Achrenius on G+: microoptimized version of
1405 * the simpler "(mask & ONEBYTES) * ONEBYTES >> 56"
1406 * that works for the bytemasks without having to
1407 * mask them first.
1408 */
1409static inline long count_masked_bytes(unsigned long mask)
1410{
1411 return mask*0x0001020304050608 >> 56;
1412}
1413
1414static inline unsigned int fold_hash(unsigned long hash)
1415{
1416 hash += hash >> (8*sizeof(int));
1417 return hash;
1418}
1419
1420#else /* 32-bit case */
1421
1422/* Carl Chatfield / Jan Achrenius G+ version for 32-bit */
1423static inline long count_masked_bytes(long mask)
1424{
1425 /* (000000 0000ff 00ffff ffffff) -> ( 1 1 2 3 ) */
1426 long a = (0x0ff0001+mask) >> 23;
1427 /* Fix the 1 for 00 case */
1428 return a & mask;
1429}
1430
1431#define fold_hash(x) (x)
1432
1433#endif
1434
1435unsigned int full_name_hash(const unsigned char *name, unsigned int len)
1436{
1437 unsigned long a, mask;
1438 unsigned long hash = 0;
1439
1440 for (;;) {
1441 a = *(unsigned long *)name;
1442 hash *= 9;
1443 if (len < sizeof(unsigned long))
1444 break;
1445 hash += a;
1446 name += sizeof(unsigned long);
1447 len -= sizeof(unsigned long);
1448 if (!len)
1449 goto done;
1450 }
1451 mask = ~(~0ul << len*8);
1452 hash += mask & a;
1453done:
1454 return fold_hash(hash);
1455}
1456EXPORT_SYMBOL(full_name_hash);
1457
1458#define ONEBYTES 0x0101010101010101ul
1459#define SLASHBYTES 0x2f2f2f2f2f2f2f2ful
1460#define HIGHBITS 0x8080808080808080ul
1461
1462/* Return the high bit set in the first byte that is a zero */
1463static inline unsigned long has_zero(unsigned long a)
1464{
1465 return ((a - ONEBYTES) & ~a) & HIGHBITS;
1466}
1467
1468/*
1469 * Calculate the length and hash of the path component, and
1470 * return the length of the component;
1471 */
1472static inline unsigned long hash_name(const char *name, unsigned int *hashp)
1473{
1474 unsigned long a, mask, hash, len;
1475
1476 hash = a = 0;
1477 len = -sizeof(unsigned long);
1478 do {
1479 hash = (hash + a) * 9;
1480 len += sizeof(unsigned long);
1481 a = *(unsigned long *)(name+len);
1482 /* Do we have any NUL or '/' bytes in this word? */
1483 mask = has_zero(a) | has_zero(a ^ SLASHBYTES);
1484 } while (!mask);
1485
1486 /* The mask *below* the first high bit set */
1487 mask = (mask - 1) & ~mask;
1488 mask >>= 7;
1489 hash += a & mask;
1490 *hashp = fold_hash(hash);
1491
1492 return len + count_masked_bytes(mask);
1493}
1494
1495#else
1496
1377unsigned int full_name_hash(const unsigned char *name, unsigned int len) 1497unsigned int full_name_hash(const unsigned char *name, unsigned int len)
1378{ 1498{
1379 unsigned long hash = init_name_hash(); 1499 unsigned long hash = init_name_hash();
@@ -1402,6 +1522,8 @@ static inline unsigned long hash_name(const char *name, unsigned int *hashp)
1402 return len; 1522 return len;
1403} 1523}
1404 1524
1525#endif
1526
1405/* 1527/*
1406 * Name resolution. 1528 * Name resolution.
1407 * This is the basic name resolution function, turning a pathname into 1529 * This is the basic name resolution function, turning a pathname into
diff --git a/fs/nilfs2/the_nilfs.c b/fs/nilfs2/the_nilfs.c
index d32714094375..501b7f8b739f 100644
--- a/fs/nilfs2/the_nilfs.c
+++ b/fs/nilfs2/the_nilfs.c
@@ -409,6 +409,12 @@ static int nilfs_store_disk_layout(struct the_nilfs *nilfs,
409 nilfs->ns_first_data_block = le64_to_cpu(sbp->s_first_data_block); 409 nilfs->ns_first_data_block = le64_to_cpu(sbp->s_first_data_block);
410 nilfs->ns_r_segments_percentage = 410 nilfs->ns_r_segments_percentage =
411 le32_to_cpu(sbp->s_r_segments_percentage); 411 le32_to_cpu(sbp->s_r_segments_percentage);
412 if (nilfs->ns_r_segments_percentage < 1 ||
413 nilfs->ns_r_segments_percentage > 99) {
414 printk(KERN_ERR "NILFS: invalid reserved segments percentage.\n");
415 return -EINVAL;
416 }
417
412 nilfs_set_nsegments(nilfs, le64_to_cpu(sbp->s_nsegments)); 418 nilfs_set_nsegments(nilfs, le64_to_cpu(sbp->s_nsegments));
413 nilfs->ns_crc_seed = le32_to_cpu(sbp->s_crc_seed); 419 nilfs->ns_crc_seed = le32_to_cpu(sbp->s_crc_seed);
414 return 0; 420 return 0;
@@ -515,6 +521,7 @@ static int nilfs_load_super_block(struct the_nilfs *nilfs,
515 brelse(sbh[1]); 521 brelse(sbh[1]);
516 sbh[1] = NULL; 522 sbh[1] = NULL;
517 sbp[1] = NULL; 523 sbp[1] = NULL;
524 valid[1] = 0;
518 swp = 0; 525 swp = 0;
519 } 526 }
520 if (!valid[swp]) { 527 if (!valid[swp]) {
diff --git a/fs/proc/base.c b/fs/proc/base.c
index d4548dd49b02..965d4bde3a3b 100644
--- a/fs/proc/base.c
+++ b/fs/proc/base.c
@@ -1310,8 +1310,7 @@ sched_autogroup_write(struct file *file, const char __user *buf,
1310 if (!p) 1310 if (!p)
1311 return -ESRCH; 1311 return -ESRCH;
1312 1312
1313 err = nice; 1313 err = proc_sched_autogroup_set_nice(p, nice);
1314 err = proc_sched_autogroup_set_nice(p, &err);
1315 if (err) 1314 if (err)
1316 count = err; 1315 count = err;
1317 1316
diff --git a/include/linux/clocksource.h b/include/linux/clocksource.h
index 081147da0564..fbe89e17124e 100644
--- a/include/linux/clocksource.h
+++ b/include/linux/clocksource.h
@@ -319,13 +319,6 @@ static inline void __clocksource_updatefreq_khz(struct clocksource *cs, u32 khz)
319 __clocksource_updatefreq_scale(cs, 1000, khz); 319 __clocksource_updatefreq_scale(cs, 1000, khz);
320} 320}
321 321
322static inline void
323clocksource_calc_mult_shift(struct clocksource *cs, u32 freq, u32 minsec)
324{
325 return clocks_calc_mult_shift(&cs->mult, &cs->shift, freq,
326 NSEC_PER_SEC, minsec);
327}
328
329#ifdef CONFIG_GENERIC_TIME_VSYSCALL 322#ifdef CONFIG_GENERIC_TIME_VSYSCALL
330extern void 323extern void
331update_vsyscall(struct timespec *ts, struct timespec *wtm, 324update_vsyscall(struct timespec *ts, struct timespec *wtm,
diff --git a/include/linux/ftrace.h b/include/linux/ftrace.h
index 028e26f0bf08..72a6cabb4d5b 100644
--- a/include/linux/ftrace.h
+++ b/include/linux/ftrace.h
@@ -31,16 +31,33 @@ ftrace_enable_sysctl(struct ctl_table *table, int write,
31 31
32typedef void (*ftrace_func_t)(unsigned long ip, unsigned long parent_ip); 32typedef void (*ftrace_func_t)(unsigned long ip, unsigned long parent_ip);
33 33
34/*
35 * FTRACE_OPS_FL_* bits denote the state of ftrace_ops struct and are
36 * set in the flags member.
37 *
38 * ENABLED - set/unset when ftrace_ops is registered/unregistered
39 * GLOBAL - set manualy by ftrace_ops user to denote the ftrace_ops
40 * is part of the global tracers sharing the same filter
41 * via set_ftrace_* debugfs files.
42 * DYNAMIC - set when ftrace_ops is registered to denote dynamically
43 * allocated ftrace_ops which need special care
44 * CONTROL - set manualy by ftrace_ops user to denote the ftrace_ops
45 * could be controled by following calls:
46 * ftrace_function_local_enable
47 * ftrace_function_local_disable
48 */
34enum { 49enum {
35 FTRACE_OPS_FL_ENABLED = 1 << 0, 50 FTRACE_OPS_FL_ENABLED = 1 << 0,
36 FTRACE_OPS_FL_GLOBAL = 1 << 1, 51 FTRACE_OPS_FL_GLOBAL = 1 << 1,
37 FTRACE_OPS_FL_DYNAMIC = 1 << 2, 52 FTRACE_OPS_FL_DYNAMIC = 1 << 2,
53 FTRACE_OPS_FL_CONTROL = 1 << 3,
38}; 54};
39 55
40struct ftrace_ops { 56struct ftrace_ops {
41 ftrace_func_t func; 57 ftrace_func_t func;
42 struct ftrace_ops *next; 58 struct ftrace_ops *next;
43 unsigned long flags; 59 unsigned long flags;
60 int __percpu *disabled;
44#ifdef CONFIG_DYNAMIC_FTRACE 61#ifdef CONFIG_DYNAMIC_FTRACE
45 struct ftrace_hash *notrace_hash; 62 struct ftrace_hash *notrace_hash;
46 struct ftrace_hash *filter_hash; 63 struct ftrace_hash *filter_hash;
@@ -97,6 +114,55 @@ int register_ftrace_function(struct ftrace_ops *ops);
97int unregister_ftrace_function(struct ftrace_ops *ops); 114int unregister_ftrace_function(struct ftrace_ops *ops);
98void clear_ftrace_function(void); 115void clear_ftrace_function(void);
99 116
117/**
118 * ftrace_function_local_enable - enable controlled ftrace_ops on current cpu
119 *
120 * This function enables tracing on current cpu by decreasing
121 * the per cpu control variable.
122 * It must be called with preemption disabled and only on ftrace_ops
123 * registered with FTRACE_OPS_FL_CONTROL. If called without preemption
124 * disabled, this_cpu_ptr will complain when CONFIG_DEBUG_PREEMPT is enabled.
125 */
126static inline void ftrace_function_local_enable(struct ftrace_ops *ops)
127{
128 if (WARN_ON_ONCE(!(ops->flags & FTRACE_OPS_FL_CONTROL)))
129 return;
130
131 (*this_cpu_ptr(ops->disabled))--;
132}
133
134/**
135 * ftrace_function_local_disable - enable controlled ftrace_ops on current cpu
136 *
137 * This function enables tracing on current cpu by decreasing
138 * the per cpu control variable.
139 * It must be called with preemption disabled and only on ftrace_ops
140 * registered with FTRACE_OPS_FL_CONTROL. If called without preemption
141 * disabled, this_cpu_ptr will complain when CONFIG_DEBUG_PREEMPT is enabled.
142 */
143static inline void ftrace_function_local_disable(struct ftrace_ops *ops)
144{
145 if (WARN_ON_ONCE(!(ops->flags & FTRACE_OPS_FL_CONTROL)))
146 return;
147
148 (*this_cpu_ptr(ops->disabled))++;
149}
150
151/**
152 * ftrace_function_local_disabled - returns ftrace_ops disabled value
153 * on current cpu
154 *
155 * This function returns value of ftrace_ops::disabled on current cpu.
156 * It must be called with preemption disabled and only on ftrace_ops
157 * registered with FTRACE_OPS_FL_CONTROL. If called without preemption
158 * disabled, this_cpu_ptr will complain when CONFIG_DEBUG_PREEMPT is enabled.
159 */
160static inline int ftrace_function_local_disabled(struct ftrace_ops *ops)
161{
162 WARN_ON_ONCE(!(ops->flags & FTRACE_OPS_FL_CONTROL));
163 return *this_cpu_ptr(ops->disabled);
164}
165
100extern void ftrace_stub(unsigned long a0, unsigned long a1); 166extern void ftrace_stub(unsigned long a0, unsigned long a1);
101 167
102#else /* !CONFIG_FUNCTION_TRACER */ 168#else /* !CONFIG_FUNCTION_TRACER */
@@ -178,12 +244,13 @@ struct dyn_ftrace {
178}; 244};
179 245
180int ftrace_force_update(void); 246int ftrace_force_update(void);
181void ftrace_set_filter(struct ftrace_ops *ops, unsigned char *buf, 247int ftrace_set_filter(struct ftrace_ops *ops, unsigned char *buf,
182 int len, int reset); 248 int len, int reset);
183void ftrace_set_notrace(struct ftrace_ops *ops, unsigned char *buf, 249int ftrace_set_notrace(struct ftrace_ops *ops, unsigned char *buf,
184 int len, int reset); 250 int len, int reset);
185void ftrace_set_global_filter(unsigned char *buf, int len, int reset); 251void ftrace_set_global_filter(unsigned char *buf, int len, int reset);
186void ftrace_set_global_notrace(unsigned char *buf, int len, int reset); 252void ftrace_set_global_notrace(unsigned char *buf, int len, int reset);
253void ftrace_free_filter(struct ftrace_ops *ops);
187 254
188int register_ftrace_command(struct ftrace_func_command *cmd); 255int register_ftrace_command(struct ftrace_func_command *cmd);
189int unregister_ftrace_command(struct ftrace_func_command *cmd); 256int unregister_ftrace_command(struct ftrace_func_command *cmd);
@@ -314,9 +381,6 @@ extern void ftrace_enable_daemon(void);
314#else 381#else
315static inline int skip_trace(unsigned long ip) { return 0; } 382static inline int skip_trace(unsigned long ip) { return 0; }
316static inline int ftrace_force_update(void) { return 0; } 383static inline int ftrace_force_update(void) { return 0; }
317static inline void ftrace_set_filter(unsigned char *buf, int len, int reset)
318{
319}
320static inline void ftrace_disable_daemon(void) { } 384static inline void ftrace_disable_daemon(void) { }
321static inline void ftrace_enable_daemon(void) { } 385static inline void ftrace_enable_daemon(void) { }
322static inline void ftrace_release_mod(struct module *mod) {} 386static inline void ftrace_release_mod(struct module *mod) {}
@@ -340,6 +404,9 @@ static inline int ftrace_text_reserved(void *start, void *end)
340 */ 404 */
341#define ftrace_regex_open(ops, flag, inod, file) ({ -ENODEV; }) 405#define ftrace_regex_open(ops, flag, inod, file) ({ -ENODEV; })
342#define ftrace_set_early_filter(ops, buf, enable) do { } while (0) 406#define ftrace_set_early_filter(ops, buf, enable) do { } while (0)
407#define ftrace_set_filter(ops, buf, len, reset) ({ -ENODEV; })
408#define ftrace_set_notrace(ops, buf, len, reset) ({ -ENODEV; })
409#define ftrace_free_filter(ops) do { } while (0)
343 410
344static inline ssize_t ftrace_filter_write(struct file *file, const char __user *ubuf, 411static inline ssize_t ftrace_filter_write(struct file *file, const char __user *ubuf,
345 size_t cnt, loff_t *ppos) { return -ENODEV; } 412 size_t cnt, loff_t *ppos) { return -ENODEV; }
diff --git a/include/linux/ftrace_event.h b/include/linux/ftrace_event.h
index c3da42dd22ba..5f3f3be5af09 100644
--- a/include/linux/ftrace_event.h
+++ b/include/linux/ftrace_event.h
@@ -144,8 +144,14 @@ struct event_filter;
144enum trace_reg { 144enum trace_reg {
145 TRACE_REG_REGISTER, 145 TRACE_REG_REGISTER,
146 TRACE_REG_UNREGISTER, 146 TRACE_REG_UNREGISTER,
147#ifdef CONFIG_PERF_EVENTS
147 TRACE_REG_PERF_REGISTER, 148 TRACE_REG_PERF_REGISTER,
148 TRACE_REG_PERF_UNREGISTER, 149 TRACE_REG_PERF_UNREGISTER,
150 TRACE_REG_PERF_OPEN,
151 TRACE_REG_PERF_CLOSE,
152 TRACE_REG_PERF_ADD,
153 TRACE_REG_PERF_DEL,
154#endif
149}; 155};
150 156
151struct ftrace_event_call; 157struct ftrace_event_call;
@@ -157,7 +163,7 @@ struct ftrace_event_class {
157 void *perf_probe; 163 void *perf_probe;
158#endif 164#endif
159 int (*reg)(struct ftrace_event_call *event, 165 int (*reg)(struct ftrace_event_call *event,
160 enum trace_reg type); 166 enum trace_reg type, void *data);
161 int (*define_fields)(struct ftrace_event_call *); 167 int (*define_fields)(struct ftrace_event_call *);
162 struct list_head *(*get_fields)(struct ftrace_event_call *); 168 struct list_head *(*get_fields)(struct ftrace_event_call *);
163 struct list_head fields; 169 struct list_head fields;
@@ -165,7 +171,7 @@ struct ftrace_event_class {
165}; 171};
166 172
167extern int ftrace_event_reg(struct ftrace_event_call *event, 173extern int ftrace_event_reg(struct ftrace_event_call *event,
168 enum trace_reg type); 174 enum trace_reg type, void *data);
169 175
170enum { 176enum {
171 TRACE_EVENT_FL_ENABLED_BIT, 177 TRACE_EVENT_FL_ENABLED_BIT,
@@ -241,6 +247,7 @@ enum {
241 FILTER_STATIC_STRING, 247 FILTER_STATIC_STRING,
242 FILTER_DYN_STRING, 248 FILTER_DYN_STRING,
243 FILTER_PTR_STRING, 249 FILTER_PTR_STRING,
250 FILTER_TRACE_FN,
244}; 251};
245 252
246#define EVENT_STORAGE_SIZE 128 253#define EVENT_STORAGE_SIZE 128
diff --git a/include/linux/genhd.h b/include/linux/genhd.h
index fe23ee768589..e61d3192448e 100644
--- a/include/linux/genhd.h
+++ b/include/linux/genhd.h
@@ -596,6 +596,7 @@ extern char *disk_name (struct gendisk *hd, int partno, char *buf);
596 596
597extern int disk_expand_part_tbl(struct gendisk *disk, int target); 597extern int disk_expand_part_tbl(struct gendisk *disk, int target);
598extern int rescan_partitions(struct gendisk *disk, struct block_device *bdev); 598extern int rescan_partitions(struct gendisk *disk, struct block_device *bdev);
599extern int invalidate_partitions(struct gendisk *disk, struct block_device *bdev);
599extern struct hd_struct * __must_check add_partition(struct gendisk *disk, 600extern struct hd_struct * __must_check add_partition(struct gendisk *disk,
600 int partno, sector_t start, 601 int partno, sector_t start,
601 sector_t len, int flags, 602 sector_t len, int flags,
diff --git a/include/linux/init_task.h b/include/linux/init_task.h
index 9c66b1ada9d7..f994d51f70f2 100644
--- a/include/linux/init_task.h
+++ b/include/linux/init_task.h
@@ -149,7 +149,7 @@ extern struct cred init_cred;
149 }, \ 149 }, \
150 .rt = { \ 150 .rt = { \
151 .run_list = LIST_HEAD_INIT(tsk.rt.run_list), \ 151 .run_list = LIST_HEAD_INIT(tsk.rt.run_list), \
152 .time_slice = HZ, \ 152 .time_slice = RR_TIMESLICE, \
153 .nr_cpus_allowed = NR_CPUS, \ 153 .nr_cpus_allowed = NR_CPUS, \
154 }, \ 154 }, \
155 .tasks = LIST_HEAD_INIT(tsk.tasks), \ 155 .tasks = LIST_HEAD_INIT(tsk.tasks), \
diff --git a/include/linux/interrupt.h b/include/linux/interrupt.h
index a64b00e286f5..3f830e005118 100644
--- a/include/linux/interrupt.h
+++ b/include/linux/interrupt.h
@@ -20,7 +20,6 @@
20#include <linux/atomic.h> 20#include <linux/atomic.h>
21#include <asm/ptrace.h> 21#include <asm/ptrace.h>
22#include <asm/system.h> 22#include <asm/system.h>
23#include <trace/events/irq.h>
24 23
25/* 24/*
26 * These correspond to the IORESOURCE_IRQ_* defines in 25 * These correspond to the IORESOURCE_IRQ_* defines in
@@ -456,11 +455,7 @@ asmlinkage void do_softirq(void);
456asmlinkage void __do_softirq(void); 455asmlinkage void __do_softirq(void);
457extern void open_softirq(int nr, void (*action)(struct softirq_action *)); 456extern void open_softirq(int nr, void (*action)(struct softirq_action *));
458extern void softirq_init(void); 457extern void softirq_init(void);
459static inline void __raise_softirq_irqoff(unsigned int nr) 458extern void __raise_softirq_irqoff(unsigned int nr);
460{
461 trace_softirq_raise(nr);
462 or_softirq_pending(1UL << nr);
463}
464 459
465extern void raise_softirq_irqoff(unsigned int nr); 460extern void raise_softirq_irqoff(unsigned int nr);
466extern void raise_softirq(unsigned int nr); 461extern void raise_softirq(unsigned int nr);
diff --git a/include/linux/iocontext.h b/include/linux/iocontext.h
index 119773eebe31..1a3018063034 100644
--- a/include/linux/iocontext.h
+++ b/include/linux/iocontext.h
@@ -6,8 +6,11 @@
6#include <linux/workqueue.h> 6#include <linux/workqueue.h>
7 7
8enum { 8enum {
9 ICQ_IOPRIO_CHANGED, 9 ICQ_IOPRIO_CHANGED = 1 << 0,
10 ICQ_CGROUP_CHANGED, 10 ICQ_CGROUP_CHANGED = 1 << 1,
11 ICQ_EXITED = 1 << 2,
12
13 ICQ_CHANGED_MASK = ICQ_IOPRIO_CHANGED | ICQ_CGROUP_CHANGED,
11}; 14};
12 15
13/* 16/*
@@ -88,7 +91,7 @@ struct io_cq {
88 struct rcu_head __rcu_head; 91 struct rcu_head __rcu_head;
89 }; 92 };
90 93
91 unsigned long changed; 94 unsigned int flags;
92}; 95};
93 96
94/* 97/*
@@ -139,6 +142,7 @@ struct io_context *get_task_io_context(struct task_struct *task,
139 gfp_t gfp_flags, int node); 142 gfp_t gfp_flags, int node);
140void ioc_ioprio_changed(struct io_context *ioc, int ioprio); 143void ioc_ioprio_changed(struct io_context *ioc, int ioprio);
141void ioc_cgroup_changed(struct io_context *ioc); 144void ioc_cgroup_changed(struct io_context *ioc);
145unsigned int icq_get_changed(struct io_cq *icq);
142#else 146#else
143struct io_context; 147struct io_context;
144static inline void put_io_context(struct io_context *ioc) { } 148static inline void put_io_context(struct io_context *ioc) { }
diff --git a/include/linux/jump_label.h b/include/linux/jump_label.h
index 5ce8b140428f..c513a40510f5 100644
--- a/include/linux/jump_label.h
+++ b/include/linux/jump_label.h
@@ -1,22 +1,69 @@
1#ifndef _LINUX_JUMP_LABEL_H 1#ifndef _LINUX_JUMP_LABEL_H
2#define _LINUX_JUMP_LABEL_H 2#define _LINUX_JUMP_LABEL_H
3 3
4/*
5 * Jump label support
6 *
7 * Copyright (C) 2009-2012 Jason Baron <jbaron@redhat.com>
8 * Copyright (C) 2011-2012 Peter Zijlstra <pzijlstr@redhat.com>
9 *
10 * Jump labels provide an interface to generate dynamic branches using
11 * self-modifying code. Assuming toolchain and architecture support the result
12 * of a "if (static_key_false(&key))" statement is a unconditional branch (which
13 * defaults to false - and the true block is placed out of line).
14 *
15 * However at runtime we can change the branch target using
16 * static_key_slow_{inc,dec}(). These function as a 'reference' count on the key
17 * object and for as long as there are references all branches referring to
18 * that particular key will point to the (out of line) true block.
19 *
20 * Since this relies on modifying code the static_key_slow_{inc,dec}() functions
21 * must be considered absolute slow paths (machine wide synchronization etc.).
22 * OTOH, since the affected branches are unconditional their runtime overhead
23 * will be absolutely minimal, esp. in the default (off) case where the total
24 * effect is a single NOP of appropriate size. The on case will patch in a jump
25 * to the out-of-line block.
26 *
27 * When the control is directly exposed to userspace it is prudent to delay the
28 * decrement to avoid high frequency code modifications which can (and do)
29 * cause significant performance degradation. Struct static_key_deferred and
30 * static_key_slow_dec_deferred() provide for this.
31 *
32 * Lacking toolchain and or architecture support, it falls back to a simple
33 * conditional branch.
34 *
35 * struct static_key my_key = STATIC_KEY_INIT_TRUE;
36 *
37 * if (static_key_true(&my_key)) {
38 * }
39 *
40 * will result in the true case being in-line and starts the key with a single
41 * reference. Mixing static_key_true() and static_key_false() on the same key is not
42 * allowed.
43 *
44 * Not initializing the key (static data is initialized to 0s anyway) is the
45 * same as using STATIC_KEY_INIT_FALSE and static_key_false() is
46 * equivalent with static_branch().
47 *
48*/
49
4#include <linux/types.h> 50#include <linux/types.h>
5#include <linux/compiler.h> 51#include <linux/compiler.h>
6#include <linux/workqueue.h> 52#include <linux/workqueue.h>
7 53
8#if defined(CC_HAVE_ASM_GOTO) && defined(CONFIG_JUMP_LABEL) 54#if defined(CC_HAVE_ASM_GOTO) && defined(CONFIG_JUMP_LABEL)
9 55
10struct jump_label_key { 56struct static_key {
11 atomic_t enabled; 57 atomic_t enabled;
58/* Set lsb bit to 1 if branch is default true, 0 ot */
12 struct jump_entry *entries; 59 struct jump_entry *entries;
13#ifdef CONFIG_MODULES 60#ifdef CONFIG_MODULES
14 struct jump_label_mod *next; 61 struct static_key_mod *next;
15#endif 62#endif
16}; 63};
17 64
18struct jump_label_key_deferred { 65struct static_key_deferred {
19 struct jump_label_key key; 66 struct static_key key;
20 unsigned long timeout; 67 unsigned long timeout;
21 struct delayed_work work; 68 struct delayed_work work;
22}; 69};
@@ -34,13 +81,34 @@ struct module;
34 81
35#ifdef HAVE_JUMP_LABEL 82#ifdef HAVE_JUMP_LABEL
36 83
37#ifdef CONFIG_MODULES 84#define JUMP_LABEL_TRUE_BRANCH 1UL
38#define JUMP_LABEL_INIT {ATOMIC_INIT(0), NULL, NULL} 85
39#else 86static
40#define JUMP_LABEL_INIT {ATOMIC_INIT(0), NULL} 87inline struct jump_entry *jump_label_get_entries(struct static_key *key)
41#endif 88{
89 return (struct jump_entry *)((unsigned long)key->entries
90 & ~JUMP_LABEL_TRUE_BRANCH);
91}
42 92
43static __always_inline bool static_branch(struct jump_label_key *key) 93static inline bool jump_label_get_branch_default(struct static_key *key)
94{
95 if ((unsigned long)key->entries & JUMP_LABEL_TRUE_BRANCH)
96 return true;
97 return false;
98}
99
100static __always_inline bool static_key_false(struct static_key *key)
101{
102 return arch_static_branch(key);
103}
104
105static __always_inline bool static_key_true(struct static_key *key)
106{
107 return !static_key_false(key);
108}
109
110/* Deprecated. Please use 'static_key_false() instead. */
111static __always_inline bool static_branch(struct static_key *key)
44{ 112{
45 return arch_static_branch(key); 113 return arch_static_branch(key);
46} 114}
@@ -56,21 +124,23 @@ extern void arch_jump_label_transform(struct jump_entry *entry,
56extern void arch_jump_label_transform_static(struct jump_entry *entry, 124extern void arch_jump_label_transform_static(struct jump_entry *entry,
57 enum jump_label_type type); 125 enum jump_label_type type);
58extern int jump_label_text_reserved(void *start, void *end); 126extern int jump_label_text_reserved(void *start, void *end);
59extern void jump_label_inc(struct jump_label_key *key); 127extern void static_key_slow_inc(struct static_key *key);
60extern void jump_label_dec(struct jump_label_key *key); 128extern void static_key_slow_dec(struct static_key *key);
61extern void jump_label_dec_deferred(struct jump_label_key_deferred *key); 129extern void static_key_slow_dec_deferred(struct static_key_deferred *key);
62extern bool jump_label_enabled(struct jump_label_key *key);
63extern void jump_label_apply_nops(struct module *mod); 130extern void jump_label_apply_nops(struct module *mod);
64extern void jump_label_rate_limit(struct jump_label_key_deferred *key, 131extern void
65 unsigned long rl); 132jump_label_rate_limit(struct static_key_deferred *key, unsigned long rl);
133
134#define STATIC_KEY_INIT_TRUE ((struct static_key) \
135 { .enabled = ATOMIC_INIT(1), .entries = (void *)1 })
136#define STATIC_KEY_INIT_FALSE ((struct static_key) \
137 { .enabled = ATOMIC_INIT(0), .entries = (void *)0 })
66 138
67#else /* !HAVE_JUMP_LABEL */ 139#else /* !HAVE_JUMP_LABEL */
68 140
69#include <linux/atomic.h> 141#include <linux/atomic.h>
70 142
71#define JUMP_LABEL_INIT {ATOMIC_INIT(0)} 143struct static_key {
72
73struct jump_label_key {
74 atomic_t enabled; 144 atomic_t enabled;
75}; 145};
76 146
@@ -78,30 +148,45 @@ static __always_inline void jump_label_init(void)
78{ 148{
79} 149}
80 150
81struct jump_label_key_deferred { 151struct static_key_deferred {
82 struct jump_label_key key; 152 struct static_key key;
83}; 153};
84 154
85static __always_inline bool static_branch(struct jump_label_key *key) 155static __always_inline bool static_key_false(struct static_key *key)
156{
157 if (unlikely(atomic_read(&key->enabled)) > 0)
158 return true;
159 return false;
160}
161
162static __always_inline bool static_key_true(struct static_key *key)
86{ 163{
87 if (unlikely(atomic_read(&key->enabled))) 164 if (likely(atomic_read(&key->enabled)) > 0)
88 return true; 165 return true;
89 return false; 166 return false;
90} 167}
91 168
92static inline void jump_label_inc(struct jump_label_key *key) 169/* Deprecated. Please use 'static_key_false() instead. */
170static __always_inline bool static_branch(struct static_key *key)
171{
172 if (unlikely(atomic_read(&key->enabled)) > 0)
173 return true;
174 return false;
175}
176
177static inline void static_key_slow_inc(struct static_key *key)
93{ 178{
94 atomic_inc(&key->enabled); 179 atomic_inc(&key->enabled);
95} 180}
96 181
97static inline void jump_label_dec(struct jump_label_key *key) 182static inline void static_key_slow_dec(struct static_key *key)
98{ 183{
99 atomic_dec(&key->enabled); 184 atomic_dec(&key->enabled);
100} 185}
101 186
102static inline void jump_label_dec_deferred(struct jump_label_key_deferred *key) 187static inline void static_key_slow_dec_deferred(struct static_key_deferred *key)
103{ 188{
104 jump_label_dec(&key->key); 189 static_key_slow_dec(&key->key);
105} 190}
106 191
107static inline int jump_label_text_reserved(void *start, void *end) 192static inline int jump_label_text_reserved(void *start, void *end)
@@ -112,23 +197,30 @@ static inline int jump_label_text_reserved(void *start, void *end)
112static inline void jump_label_lock(void) {} 197static inline void jump_label_lock(void) {}
113static inline void jump_label_unlock(void) {} 198static inline void jump_label_unlock(void) {}
114 199
115static inline bool jump_label_enabled(struct jump_label_key *key)
116{
117 return !!atomic_read(&key->enabled);
118}
119
120static inline int jump_label_apply_nops(struct module *mod) 200static inline int jump_label_apply_nops(struct module *mod)
121{ 201{
122 return 0; 202 return 0;
123} 203}
124 204
125static inline void jump_label_rate_limit(struct jump_label_key_deferred *key, 205static inline void
206jump_label_rate_limit(struct static_key_deferred *key,
126 unsigned long rl) 207 unsigned long rl)
127{ 208{
128} 209}
210
211#define STATIC_KEY_INIT_TRUE ((struct static_key) \
212 { .enabled = ATOMIC_INIT(1) })
213#define STATIC_KEY_INIT_FALSE ((struct static_key) \
214 { .enabled = ATOMIC_INIT(0) })
215
129#endif /* HAVE_JUMP_LABEL */ 216#endif /* HAVE_JUMP_LABEL */
130 217
131#define jump_label_key_enabled ((struct jump_label_key){ .enabled = ATOMIC_INIT(1), }) 218#define STATIC_KEY_INIT STATIC_KEY_INIT_FALSE
132#define jump_label_key_disabled ((struct jump_label_key){ .enabled = ATOMIC_INIT(0), }) 219#define jump_label_enabled static_key_enabled
220
221static inline bool static_key_enabled(struct static_key *key)
222{
223 return (atomic_read(&key->enabled) > 0);
224}
133 225
134#endif /* _LINUX_JUMP_LABEL_H */ 226#endif /* _LINUX_JUMP_LABEL_H */
diff --git a/include/linux/kernel.h b/include/linux/kernel.h
index e8343422240a..5582c7985567 100644
--- a/include/linux/kernel.h
+++ b/include/linux/kernel.h
@@ -85,6 +85,19 @@
85} \ 85} \
86) 86)
87 87
88/*
89 * Multiplies an integer by a fraction, while avoiding unnecessary
90 * overflow or loss of precision.
91 */
92#define mult_frac(x, numer, denom)( \
93{ \
94 typeof(x) quot = (x) / (denom); \
95 typeof(x) rem = (x) % (denom); \
96 (quot * (numer)) + ((rem * (numer)) / (denom)); \
97} \
98)
99
100
88#define _RET_IP_ (unsigned long)__builtin_return_address(0) 101#define _RET_IP_ (unsigned long)__builtin_return_address(0)
89#define _THIS_IP_ ({ __label__ __here; __here: (unsigned long)&&__here; }) 102#define _THIS_IP_ ({ __label__ __here; __here: (unsigned long)&&__here; })
90 103
@@ -414,16 +427,10 @@ extern int __must_check hex2bin(u8 *dst, const char *src, size_t count);
414 * Most likely, you want to use tracing_on/tracing_off. 427 * Most likely, you want to use tracing_on/tracing_off.
415 */ 428 */
416#ifdef CONFIG_RING_BUFFER 429#ifdef CONFIG_RING_BUFFER
417void tracing_on(void);
418void tracing_off(void);
419/* trace_off_permanent stops recording with no way to bring it back */ 430/* trace_off_permanent stops recording with no way to bring it back */
420void tracing_off_permanent(void); 431void tracing_off_permanent(void);
421int tracing_is_on(void);
422#else 432#else
423static inline void tracing_on(void) { }
424static inline void tracing_off(void) { }
425static inline void tracing_off_permanent(void) { } 433static inline void tracing_off_permanent(void) { }
426static inline int tracing_is_on(void) { return 0; }
427#endif 434#endif
428 435
429enum ftrace_dump_mode { 436enum ftrace_dump_mode {
@@ -433,6 +440,10 @@ enum ftrace_dump_mode {
433}; 440};
434 441
435#ifdef CONFIG_TRACING 442#ifdef CONFIG_TRACING
443void tracing_on(void);
444void tracing_off(void);
445int tracing_is_on(void);
446
436extern void tracing_start(void); 447extern void tracing_start(void);
437extern void tracing_stop(void); 448extern void tracing_stop(void);
438extern void ftrace_off_permanent(void); 449extern void ftrace_off_permanent(void);
@@ -517,6 +528,11 @@ static inline void tracing_start(void) { }
517static inline void tracing_stop(void) { } 528static inline void tracing_stop(void) { }
518static inline void ftrace_off_permanent(void) { } 529static inline void ftrace_off_permanent(void) { }
519static inline void trace_dump_stack(void) { } 530static inline void trace_dump_stack(void) { }
531
532static inline void tracing_on(void) { }
533static inline void tracing_off(void) { }
534static inline int tracing_is_on(void) { return 0; }
535
520static inline int 536static inline int
521trace_printk(const char *fmt, ...) 537trace_printk(const char *fmt, ...)
522{ 538{
diff --git a/include/linux/math64.h b/include/linux/math64.h
index 23fcdfcba81b..b8ba85544721 100644
--- a/include/linux/math64.h
+++ b/include/linux/math64.h
@@ -6,6 +6,8 @@
6 6
7#if BITS_PER_LONG == 64 7#if BITS_PER_LONG == 64
8 8
9#define div64_long(x,y) div64_s64((x),(y))
10
9/** 11/**
10 * div_u64_rem - unsigned 64bit divide with 32bit divisor with remainder 12 * div_u64_rem - unsigned 64bit divide with 32bit divisor with remainder
11 * 13 *
@@ -45,6 +47,8 @@ static inline s64 div64_s64(s64 dividend, s64 divisor)
45 47
46#elif BITS_PER_LONG == 32 48#elif BITS_PER_LONG == 32
47 49
50#define div64_long(x,y) div_s64((x),(y))
51
48#ifndef div_u64_rem 52#ifndef div_u64_rem
49static inline u64 div_u64_rem(u64 dividend, u32 divisor, u32 *remainder) 53static inline u64 div_u64_rem(u64 dividend, u32 divisor, u32 *remainder)
50{ 54{
diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
index 0eac07c95255..7dfaae7846ab 100644
--- a/include/linux/netdevice.h
+++ b/include/linux/netdevice.h
@@ -214,8 +214,8 @@ enum {
214#include <linux/skbuff.h> 214#include <linux/skbuff.h>
215 215
216#ifdef CONFIG_RPS 216#ifdef CONFIG_RPS
217#include <linux/jump_label.h> 217#include <linux/static_key.h>
218extern struct jump_label_key rps_needed; 218extern struct static_key rps_needed;
219#endif 219#endif
220 220
221struct neighbour; 221struct neighbour;
diff --git a/include/linux/netfilter.h b/include/linux/netfilter.h
index b809265607d0..29734be334c1 100644
--- a/include/linux/netfilter.h
+++ b/include/linux/netfilter.h
@@ -163,13 +163,13 @@ extern struct ctl_path nf_net_ipv4_netfilter_sysctl_path[];
163extern struct list_head nf_hooks[NFPROTO_NUMPROTO][NF_MAX_HOOKS]; 163extern struct list_head nf_hooks[NFPROTO_NUMPROTO][NF_MAX_HOOKS];
164 164
165#if defined(CONFIG_JUMP_LABEL) 165#if defined(CONFIG_JUMP_LABEL)
166#include <linux/jump_label.h> 166#include <linux/static_key.h>
167extern struct jump_label_key nf_hooks_needed[NFPROTO_NUMPROTO][NF_MAX_HOOKS]; 167extern struct static_key nf_hooks_needed[NFPROTO_NUMPROTO][NF_MAX_HOOKS];
168static inline bool nf_hooks_active(u_int8_t pf, unsigned int hook) 168static inline bool nf_hooks_active(u_int8_t pf, unsigned int hook)
169{ 169{
170 if (__builtin_constant_p(pf) && 170 if (__builtin_constant_p(pf) &&
171 __builtin_constant_p(hook)) 171 __builtin_constant_p(hook))
172 return static_branch(&nf_hooks_needed[pf][hook]); 172 return static_key_false(&nf_hooks_needed[pf][hook]);
173 173
174 return !list_empty(&nf_hooks[pf][hook]); 174 return !list_empty(&nf_hooks[pf][hook]);
175} 175}
diff --git a/include/linux/perf_event.h b/include/linux/perf_event.h
index abb2776be1ba..ca9ed4e6a286 100644
--- a/include/linux/perf_event.h
+++ b/include/linux/perf_event.h
@@ -129,11 +129,40 @@ enum perf_event_sample_format {
129 PERF_SAMPLE_PERIOD = 1U << 8, 129 PERF_SAMPLE_PERIOD = 1U << 8,
130 PERF_SAMPLE_STREAM_ID = 1U << 9, 130 PERF_SAMPLE_STREAM_ID = 1U << 9,
131 PERF_SAMPLE_RAW = 1U << 10, 131 PERF_SAMPLE_RAW = 1U << 10,
132 PERF_SAMPLE_BRANCH_STACK = 1U << 11,
132 133
133 PERF_SAMPLE_MAX = 1U << 11, /* non-ABI */ 134 PERF_SAMPLE_MAX = 1U << 12, /* non-ABI */
134}; 135};
135 136
136/* 137/*
138 * values to program into branch_sample_type when PERF_SAMPLE_BRANCH is set
139 *
140 * If the user does not pass priv level information via branch_sample_type,
141 * the kernel uses the event's priv level. Branch and event priv levels do
142 * not have to match. Branch priv level is checked for permissions.
143 *
144 * The branch types can be combined, however BRANCH_ANY covers all types
145 * of branches and therefore it supersedes all the other types.
146 */
147enum perf_branch_sample_type {
148 PERF_SAMPLE_BRANCH_USER = 1U << 0, /* user branches */
149 PERF_SAMPLE_BRANCH_KERNEL = 1U << 1, /* kernel branches */
150 PERF_SAMPLE_BRANCH_HV = 1U << 2, /* hypervisor branches */
151
152 PERF_SAMPLE_BRANCH_ANY = 1U << 3, /* any branch types */
153 PERF_SAMPLE_BRANCH_ANY_CALL = 1U << 4, /* any call branch */
154 PERF_SAMPLE_BRANCH_ANY_RETURN = 1U << 5, /* any return branch */
155 PERF_SAMPLE_BRANCH_IND_CALL = 1U << 6, /* indirect calls */
156
157 PERF_SAMPLE_BRANCH_MAX = 1U << 7, /* non-ABI */
158};
159
160#define PERF_SAMPLE_BRANCH_PLM_ALL \
161 (PERF_SAMPLE_BRANCH_USER|\
162 PERF_SAMPLE_BRANCH_KERNEL|\
163 PERF_SAMPLE_BRANCH_HV)
164
165/*
137 * The format of the data returned by read() on a perf event fd, 166 * The format of the data returned by read() on a perf event fd,
138 * as specified by attr.read_format: 167 * as specified by attr.read_format:
139 * 168 *
@@ -163,6 +192,8 @@ enum perf_event_read_format {
163}; 192};
164 193
165#define PERF_ATTR_SIZE_VER0 64 /* sizeof first published struct */ 194#define PERF_ATTR_SIZE_VER0 64 /* sizeof first published struct */
195#define PERF_ATTR_SIZE_VER1 72 /* add: config2 */
196#define PERF_ATTR_SIZE_VER2 80 /* add: branch_sample_type */
166 197
167/* 198/*
168 * Hardware event_id to monitor via a performance monitoring event: 199 * Hardware event_id to monitor via a performance monitoring event:
@@ -240,6 +271,7 @@ struct perf_event_attr {
240 __u64 bp_len; 271 __u64 bp_len;
241 __u64 config2; /* extension of config1 */ 272 __u64 config2; /* extension of config1 */
242 }; 273 };
274 __u64 branch_sample_type; /* enum branch_sample_type */
243}; 275};
244 276
245/* 277/*
@@ -267,18 +299,31 @@ struct perf_event_mmap_page {
267 /* 299 /*
268 * Bits needed to read the hw events in user-space. 300 * Bits needed to read the hw events in user-space.
269 * 301 *
270 * u32 seq; 302 * u32 seq, time_mult, time_shift, idx, width;
271 * s64 count; 303 * u64 count, enabled, running;
304 * u64 cyc, time_offset;
305 * s64 pmc = 0;
272 * 306 *
273 * do { 307 * do {
274 * seq = pc->lock; 308 * seq = pc->lock;
275 *
276 * barrier() 309 * barrier()
277 * if (pc->index) { 310 *
278 * count = pmc_read(pc->index - 1); 311 * enabled = pc->time_enabled;
279 * count += pc->offset; 312 * running = pc->time_running;
280 * } else 313 *
281 * goto regular_read; 314 * if (pc->cap_usr_time && enabled != running) {
315 * cyc = rdtsc();
316 * time_offset = pc->time_offset;
317 * time_mult = pc->time_mult;
318 * time_shift = pc->time_shift;
319 * }
320 *
321 * idx = pc->index;
322 * count = pc->offset;
323 * if (pc->cap_usr_rdpmc && idx) {
324 * width = pc->pmc_width;
325 * pmc = rdpmc(idx - 1);
326 * }
282 * 327 *
283 * barrier(); 328 * barrier();
284 * } while (pc->lock != seq); 329 * } while (pc->lock != seq);
@@ -291,12 +336,57 @@ struct perf_event_mmap_page {
291 __s64 offset; /* add to hardware event value */ 336 __s64 offset; /* add to hardware event value */
292 __u64 time_enabled; /* time event active */ 337 __u64 time_enabled; /* time event active */
293 __u64 time_running; /* time event on cpu */ 338 __u64 time_running; /* time event on cpu */
339 union {
340 __u64 capabilities;
341 __u64 cap_usr_time : 1,
342 cap_usr_rdpmc : 1,
343 cap_____res : 62;
344 };
345
346 /*
347 * If cap_usr_rdpmc this field provides the bit-width of the value
348 * read using the rdpmc() or equivalent instruction. This can be used
349 * to sign extend the result like:
350 *
351 * pmc <<= 64 - width;
352 * pmc >>= 64 - width; // signed shift right
353 * count += pmc;
354 */
355 __u16 pmc_width;
356
357 /*
358 * If cap_usr_time the below fields can be used to compute the time
359 * delta since time_enabled (in ns) using rdtsc or similar.
360 *
361 * u64 quot, rem;
362 * u64 delta;
363 *
364 * quot = (cyc >> time_shift);
365 * rem = cyc & ((1 << time_shift) - 1);
366 * delta = time_offset + quot * time_mult +
367 * ((rem * time_mult) >> time_shift);
368 *
369 * Where time_offset,time_mult,time_shift and cyc are read in the
370 * seqcount loop described above. This delta can then be added to
371 * enabled and possible running (if idx), improving the scaling:
372 *
373 * enabled += delta;
374 * if (idx)
375 * running += delta;
376 *
377 * quot = count / running;
378 * rem = count % running;
379 * count = quot * enabled + (rem * enabled) / running;
380 */
381 __u16 time_shift;
382 __u32 time_mult;
383 __u64 time_offset;
294 384
295 /* 385 /*
296 * Hole for extension of the self monitor capabilities 386 * Hole for extension of the self monitor capabilities
297 */ 387 */
298 388
299 __u64 __reserved[123]; /* align to 1k */ 389 __u64 __reserved[120]; /* align to 1k */
300 390
301 /* 391 /*
302 * Control data for the mmap() data buffer. 392 * Control data for the mmap() data buffer.
@@ -313,6 +403,13 @@ struct perf_event_mmap_page {
313 __u64 data_tail; /* user-space written tail */ 403 __u64 data_tail; /* user-space written tail */
314}; 404};
315 405
406/*
407 * Build time assertion that we keep the data_head at the intended location.
408 * IOW, validation we got the __reserved[] size right.
409 */
410extern char __assert_mmap_data_head_offset
411 [1 - 2*!!(offsetof(struct perf_event_mmap_page, data_head) != 1024)];
412
316#define PERF_RECORD_MISC_CPUMODE_MASK (7 << 0) 413#define PERF_RECORD_MISC_CPUMODE_MASK (7 << 0)
317#define PERF_RECORD_MISC_CPUMODE_UNKNOWN (0 << 0) 414#define PERF_RECORD_MISC_CPUMODE_UNKNOWN (0 << 0)
318#define PERF_RECORD_MISC_KERNEL (1 << 0) 415#define PERF_RECORD_MISC_KERNEL (1 << 0)
@@ -456,6 +553,8 @@ enum perf_event_type {
456 * 553 *
457 * { u32 size; 554 * { u32 size;
458 * char data[size];}&& PERF_SAMPLE_RAW 555 * char data[size];}&& PERF_SAMPLE_RAW
556 *
557 * { u64 from, to, flags } lbr[nr];} && PERF_SAMPLE_BRANCH_STACK
459 * }; 558 * };
460 */ 559 */
461 PERF_RECORD_SAMPLE = 9, 560 PERF_RECORD_SAMPLE = 9,
@@ -512,8 +611,9 @@ struct perf_guest_info_callbacks {
512#include <linux/ftrace.h> 611#include <linux/ftrace.h>
513#include <linux/cpu.h> 612#include <linux/cpu.h>
514#include <linux/irq_work.h> 613#include <linux/irq_work.h>
515#include <linux/jump_label.h> 614#include <linux/static_key.h>
516#include <linux/atomic.h> 615#include <linux/atomic.h>
616#include <linux/sysfs.h>
517#include <asm/local.h> 617#include <asm/local.h>
518 618
519#define PERF_MAX_STACK_DEPTH 255 619#define PERF_MAX_STACK_DEPTH 255
@@ -528,12 +628,34 @@ struct perf_raw_record {
528 void *data; 628 void *data;
529}; 629};
530 630
631/*
632 * single taken branch record layout:
633 *
634 * from: source instruction (may not always be a branch insn)
635 * to: branch target
636 * mispred: branch target was mispredicted
637 * predicted: branch target was predicted
638 *
639 * support for mispred, predicted is optional. In case it
640 * is not supported mispred = predicted = 0.
641 */
531struct perf_branch_entry { 642struct perf_branch_entry {
532 __u64 from; 643 __u64 from;
533 __u64 to; 644 __u64 to;
534 __u64 flags; 645 __u64 mispred:1, /* target mispredicted */
646 predicted:1,/* target predicted */
647 reserved:62;
535}; 648};
536 649
650/*
651 * branch stack layout:
652 * nr: number of taken branches stored in entries[]
653 *
654 * Note that nr can vary from sample to sample
655 * branches (to, from) are stored from most recent
656 * to least recent, i.e., entries[0] contains the most
657 * recent branch.
658 */
537struct perf_branch_stack { 659struct perf_branch_stack {
538 __u64 nr; 660 __u64 nr;
539 struct perf_branch_entry entries[0]; 661 struct perf_branch_entry entries[0];
@@ -564,7 +686,9 @@ struct hw_perf_event {
564 unsigned long event_base; 686 unsigned long event_base;
565 int idx; 687 int idx;
566 int last_cpu; 688 int last_cpu;
689
567 struct hw_perf_event_extra extra_reg; 690 struct hw_perf_event_extra extra_reg;
691 struct hw_perf_event_extra branch_reg;
568 }; 692 };
569 struct { /* software */ 693 struct { /* software */
570 struct hrtimer hrtimer; 694 struct hrtimer hrtimer;
@@ -616,6 +740,7 @@ struct pmu {
616 struct list_head entry; 740 struct list_head entry;
617 741
618 struct device *dev; 742 struct device *dev;
743 const struct attribute_group **attr_groups;
619 char *name; 744 char *name;
620 int type; 745 int type;
621 746
@@ -681,6 +806,17 @@ struct pmu {
681 * for each successful ->add() during the transaction. 806 * for each successful ->add() during the transaction.
682 */ 807 */
683 void (*cancel_txn) (struct pmu *pmu); /* optional */ 808 void (*cancel_txn) (struct pmu *pmu); /* optional */
809
810 /*
811 * Will return the value for perf_event_mmap_page::index for this event,
812 * if no implementation is provided it will default to: event->hw.idx + 1.
813 */
814 int (*event_idx) (struct perf_event *event); /*optional */
815
816 /*
817 * flush branch stack on context-switches (needed in cpu-wide mode)
818 */
819 void (*flush_branch_stack) (void);
684}; 820};
685 821
686/** 822/**
@@ -850,6 +986,9 @@ struct perf_event {
850#ifdef CONFIG_EVENT_TRACING 986#ifdef CONFIG_EVENT_TRACING
851 struct ftrace_event_call *tp_event; 987 struct ftrace_event_call *tp_event;
852 struct event_filter *filter; 988 struct event_filter *filter;
989#ifdef CONFIG_FUNCTION_TRACER
990 struct ftrace_ops ftrace_ops;
991#endif
853#endif 992#endif
854 993
855#ifdef CONFIG_CGROUP_PERF 994#ifdef CONFIG_CGROUP_PERF
@@ -911,7 +1050,8 @@ struct perf_event_context {
911 u64 parent_gen; 1050 u64 parent_gen;
912 u64 generation; 1051 u64 generation;
913 int pin_count; 1052 int pin_count;
914 int nr_cgroups; /* cgroup events present */ 1053 int nr_cgroups; /* cgroup evts */
1054 int nr_branch_stack; /* branch_stack evt */
915 struct rcu_head rcu_head; 1055 struct rcu_head rcu_head;
916}; 1056};
917 1057
@@ -976,6 +1116,7 @@ perf_event_create_kernel_counter(struct perf_event_attr *attr,
976extern u64 perf_event_read_value(struct perf_event *event, 1116extern u64 perf_event_read_value(struct perf_event *event,
977 u64 *enabled, u64 *running); 1117 u64 *enabled, u64 *running);
978 1118
1119
979struct perf_sample_data { 1120struct perf_sample_data {
980 u64 type; 1121 u64 type;
981 1122
@@ -995,12 +1136,14 @@ struct perf_sample_data {
995 u64 period; 1136 u64 period;
996 struct perf_callchain_entry *callchain; 1137 struct perf_callchain_entry *callchain;
997 struct perf_raw_record *raw; 1138 struct perf_raw_record *raw;
1139 struct perf_branch_stack *br_stack;
998}; 1140};
999 1141
1000static inline void perf_sample_data_init(struct perf_sample_data *data, u64 addr) 1142static inline void perf_sample_data_init(struct perf_sample_data *data, u64 addr)
1001{ 1143{
1002 data->addr = addr; 1144 data->addr = addr;
1003 data->raw = NULL; 1145 data->raw = NULL;
1146 data->br_stack = NULL;
1004} 1147}
1005 1148
1006extern void perf_output_sample(struct perf_output_handle *handle, 1149extern void perf_output_sample(struct perf_output_handle *handle,
@@ -1029,7 +1172,7 @@ static inline int is_software_event(struct perf_event *event)
1029 return event->pmu->task_ctx_nr == perf_sw_context; 1172 return event->pmu->task_ctx_nr == perf_sw_context;
1030} 1173}
1031 1174
1032extern struct jump_label_key perf_swevent_enabled[PERF_COUNT_SW_MAX]; 1175extern struct static_key perf_swevent_enabled[PERF_COUNT_SW_MAX];
1033 1176
1034extern void __perf_sw_event(u32, u64, struct pt_regs *, u64); 1177extern void __perf_sw_event(u32, u64, struct pt_regs *, u64);
1035 1178
@@ -1057,7 +1200,7 @@ perf_sw_event(u32 event_id, u64 nr, struct pt_regs *regs, u64 addr)
1057{ 1200{
1058 struct pt_regs hot_regs; 1201 struct pt_regs hot_regs;
1059 1202
1060 if (static_branch(&perf_swevent_enabled[event_id])) { 1203 if (static_key_false(&perf_swevent_enabled[event_id])) {
1061 if (!regs) { 1204 if (!regs) {
1062 perf_fetch_caller_regs(&hot_regs); 1205 perf_fetch_caller_regs(&hot_regs);
1063 regs = &hot_regs; 1206 regs = &hot_regs;
@@ -1066,12 +1209,12 @@ perf_sw_event(u32 event_id, u64 nr, struct pt_regs *regs, u64 addr)
1066 } 1209 }
1067} 1210}
1068 1211
1069extern struct jump_label_key_deferred perf_sched_events; 1212extern struct static_key_deferred perf_sched_events;
1070 1213
1071static inline void perf_event_task_sched_in(struct task_struct *prev, 1214static inline void perf_event_task_sched_in(struct task_struct *prev,
1072 struct task_struct *task) 1215 struct task_struct *task)
1073{ 1216{
1074 if (static_branch(&perf_sched_events.key)) 1217 if (static_key_false(&perf_sched_events.key))
1075 __perf_event_task_sched_in(prev, task); 1218 __perf_event_task_sched_in(prev, task);
1076} 1219}
1077 1220
@@ -1080,7 +1223,7 @@ static inline void perf_event_task_sched_out(struct task_struct *prev,
1080{ 1223{
1081 perf_sw_event(PERF_COUNT_SW_CONTEXT_SWITCHES, 1, NULL, 0); 1224 perf_sw_event(PERF_COUNT_SW_CONTEXT_SWITCHES, 1, NULL, 0);
1082 1225
1083 if (static_branch(&perf_sched_events.key)) 1226 if (static_key_false(&perf_sched_events.key))
1084 __perf_event_task_sched_out(prev, next); 1227 __perf_event_task_sched_out(prev, next);
1085} 1228}
1086 1229
@@ -1139,6 +1282,11 @@ extern void perf_bp_event(struct perf_event *event, void *data);
1139# define perf_instruction_pointer(regs) instruction_pointer(regs) 1282# define perf_instruction_pointer(regs) instruction_pointer(regs)
1140#endif 1283#endif
1141 1284
1285static inline bool has_branch_stack(struct perf_event *event)
1286{
1287 return event->attr.sample_type & PERF_SAMPLE_BRANCH_STACK;
1288}
1289
1142extern int perf_output_begin(struct perf_output_handle *handle, 1290extern int perf_output_begin(struct perf_output_handle *handle,
1143 struct perf_event *event, unsigned int size); 1291 struct perf_event *event, unsigned int size);
1144extern void perf_output_end(struct perf_output_handle *handle); 1292extern void perf_output_end(struct perf_output_handle *handle);
@@ -1207,5 +1355,18 @@ do { \
1207 register_cpu_notifier(&fn##_nb); \ 1355 register_cpu_notifier(&fn##_nb); \
1208} while (0) 1356} while (0)
1209 1357
1358
1359#define PMU_FORMAT_ATTR(_name, _format) \
1360static ssize_t \
1361_name##_show(struct device *dev, \
1362 struct device_attribute *attr, \
1363 char *page) \
1364{ \
1365 BUILD_BUG_ON(sizeof(_format) >= PAGE_SIZE); \
1366 return sprintf(page, _format "\n"); \
1367} \
1368 \
1369static struct device_attribute format_attr_##_name = __ATTR_RO(_name)
1370
1210#endif /* __KERNEL__ */ 1371#endif /* __KERNEL__ */
1211#endif /* _LINUX_PERF_EVENT_H */ 1372#endif /* _LINUX_PERF_EVENT_H */
diff --git a/include/linux/preempt.h b/include/linux/preempt.h
index 58969b2a8a82..5a710b9c578e 100644
--- a/include/linux/preempt.h
+++ b/include/linux/preempt.h
@@ -48,12 +48,14 @@ do { \
48 barrier(); \ 48 barrier(); \
49} while (0) 49} while (0)
50 50
51#define preempt_enable_no_resched() \ 51#define sched_preempt_enable_no_resched() \
52do { \ 52do { \
53 barrier(); \ 53 barrier(); \
54 dec_preempt_count(); \ 54 dec_preempt_count(); \
55} while (0) 55} while (0)
56 56
57#define preempt_enable_no_resched() sched_preempt_enable_no_resched()
58
57#define preempt_enable() \ 59#define preempt_enable() \
58do { \ 60do { \
59 preempt_enable_no_resched(); \ 61 preempt_enable_no_resched(); \
@@ -92,6 +94,7 @@ do { \
92#else /* !CONFIG_PREEMPT_COUNT */ 94#else /* !CONFIG_PREEMPT_COUNT */
93 95
94#define preempt_disable() do { } while (0) 96#define preempt_disable() do { } while (0)
97#define sched_preempt_enable_no_resched() do { } while (0)
95#define preempt_enable_no_resched() do { } while (0) 98#define preempt_enable_no_resched() do { } while (0)
96#define preempt_enable() do { } while (0) 99#define preempt_enable() do { } while (0)
97 100
diff --git a/include/linux/printk.h b/include/linux/printk.h
index f0e22f75143f..1f77a4174ee0 100644
--- a/include/linux/printk.h
+++ b/include/linux/printk.h
@@ -101,6 +101,11 @@ asmlinkage __printf(1, 2) __cold
101int printk(const char *fmt, ...); 101int printk(const char *fmt, ...);
102 102
103/* 103/*
104 * Special printk facility for scheduler use only, _DO_NOT_USE_ !
105 */
106__printf(1, 2) __cold int printk_sched(const char *fmt, ...);
107
108/*
104 * Please don't use printk_ratelimit(), because it shares ratelimiting state 109 * Please don't use printk_ratelimit(), because it shares ratelimiting state
105 * with all other unrelated printk_ratelimit() callsites. Instead use 110 * with all other unrelated printk_ratelimit() callsites. Instead use
106 * printk_ratelimited() or plain old __ratelimit(). 111 * printk_ratelimited() or plain old __ratelimit().
@@ -127,6 +132,11 @@ int printk(const char *s, ...)
127{ 132{
128 return 0; 133 return 0;
129} 134}
135static inline __printf(1, 2) __cold
136int printk_sched(const char *s, ...)
137{
138 return 0;
139}
130static inline int printk_ratelimit(void) 140static inline int printk_ratelimit(void)
131{ 141{
132 return 0; 142 return 0;
diff --git a/include/linux/rcupdate.h b/include/linux/rcupdate.h
index 81c04f4348ec..937217425c47 100644
--- a/include/linux/rcupdate.h
+++ b/include/linux/rcupdate.h
@@ -190,6 +190,33 @@ extern void rcu_idle_exit(void);
190extern void rcu_irq_enter(void); 190extern void rcu_irq_enter(void);
191extern void rcu_irq_exit(void); 191extern void rcu_irq_exit(void);
192 192
193/**
194 * RCU_NONIDLE - Indicate idle-loop code that needs RCU readers
195 * @a: Code that RCU needs to pay attention to.
196 *
197 * RCU, RCU-bh, and RCU-sched read-side critical sections are forbidden
198 * in the inner idle loop, that is, between the rcu_idle_enter() and
199 * the rcu_idle_exit() -- RCU will happily ignore any such read-side
200 * critical sections. However, things like powertop need tracepoints
201 * in the inner idle loop.
202 *
203 * This macro provides the way out: RCU_NONIDLE(do_something_with_RCU())
204 * will tell RCU that it needs to pay attending, invoke its argument
205 * (in this example, a call to the do_something_with_RCU() function),
206 * and then tell RCU to go back to ignoring this CPU. It is permissible
207 * to nest RCU_NONIDLE() wrappers, but the nesting level is currently
208 * quite limited. If deeper nesting is required, it will be necessary
209 * to adjust DYNTICK_TASK_NESTING_VALUE accordingly.
210 *
211 * This macro may be used from process-level code only.
212 */
213#define RCU_NONIDLE(a) \
214 do { \
215 rcu_idle_exit(); \
216 do { a; } while (0); \
217 rcu_idle_enter(); \
218 } while (0)
219
193/* 220/*
194 * Infrastructure to implement the synchronize_() primitives in 221 * Infrastructure to implement the synchronize_() primitives in
195 * TREE_RCU and rcu_barrier_() primitives in TINY_RCU. 222 * TREE_RCU and rcu_barrier_() primitives in TINY_RCU.
@@ -226,6 +253,15 @@ static inline void destroy_rcu_head_on_stack(struct rcu_head *head)
226} 253}
227#endif /* #else !CONFIG_DEBUG_OBJECTS_RCU_HEAD */ 254#endif /* #else !CONFIG_DEBUG_OBJECTS_RCU_HEAD */
228 255
256#if defined(CONFIG_HOTPLUG_CPU) && defined(CONFIG_PROVE_RCU)
257bool rcu_lockdep_current_cpu_online(void);
258#else /* #if defined(CONFIG_HOTPLUG_CPU) && defined(CONFIG_PROVE_RCU) */
259static inline bool rcu_lockdep_current_cpu_online(void)
260{
261 return 1;
262}
263#endif /* #else #if defined(CONFIG_HOTPLUG_CPU) && defined(CONFIG_PROVE_RCU) */
264
229#ifdef CONFIG_DEBUG_LOCK_ALLOC 265#ifdef CONFIG_DEBUG_LOCK_ALLOC
230 266
231#ifdef CONFIG_PROVE_RCU 267#ifdef CONFIG_PROVE_RCU
@@ -239,13 +275,11 @@ static inline int rcu_is_cpu_idle(void)
239 275
240static inline void rcu_lock_acquire(struct lockdep_map *map) 276static inline void rcu_lock_acquire(struct lockdep_map *map)
241{ 277{
242 WARN_ON_ONCE(rcu_is_cpu_idle());
243 lock_acquire(map, 0, 0, 2, 1, NULL, _THIS_IP_); 278 lock_acquire(map, 0, 0, 2, 1, NULL, _THIS_IP_);
244} 279}
245 280
246static inline void rcu_lock_release(struct lockdep_map *map) 281static inline void rcu_lock_release(struct lockdep_map *map)
247{ 282{
248 WARN_ON_ONCE(rcu_is_cpu_idle());
249 lock_release(map, 1, _THIS_IP_); 283 lock_release(map, 1, _THIS_IP_);
250} 284}
251 285
@@ -270,6 +304,9 @@ extern int debug_lockdep_rcu_enabled(void);
270 * occur in the same context, for example, it is illegal to invoke 304 * occur in the same context, for example, it is illegal to invoke
271 * rcu_read_unlock() in process context if the matching rcu_read_lock() 305 * rcu_read_unlock() in process context if the matching rcu_read_lock()
272 * was invoked from within an irq handler. 306 * was invoked from within an irq handler.
307 *
308 * Note that rcu_read_lock() is disallowed if the CPU is either idle or
309 * offline from an RCU perspective, so check for those as well.
273 */ 310 */
274static inline int rcu_read_lock_held(void) 311static inline int rcu_read_lock_held(void)
275{ 312{
@@ -277,6 +314,8 @@ static inline int rcu_read_lock_held(void)
277 return 1; 314 return 1;
278 if (rcu_is_cpu_idle()) 315 if (rcu_is_cpu_idle())
279 return 0; 316 return 0;
317 if (!rcu_lockdep_current_cpu_online())
318 return 0;
280 return lock_is_held(&rcu_lock_map); 319 return lock_is_held(&rcu_lock_map);
281} 320}
282 321
@@ -313,6 +352,9 @@ extern int rcu_read_lock_bh_held(void);
313 * notice an extended quiescent state to other CPUs that started a grace 352 * notice an extended quiescent state to other CPUs that started a grace
314 * period. Otherwise we would delay any grace period as long as we run in 353 * period. Otherwise we would delay any grace period as long as we run in
315 * the idle task. 354 * the idle task.
355 *
356 * Similarly, we avoid claiming an SRCU read lock held if the current
357 * CPU is offline.
316 */ 358 */
317#ifdef CONFIG_PREEMPT_COUNT 359#ifdef CONFIG_PREEMPT_COUNT
318static inline int rcu_read_lock_sched_held(void) 360static inline int rcu_read_lock_sched_held(void)
@@ -323,6 +365,8 @@ static inline int rcu_read_lock_sched_held(void)
323 return 1; 365 return 1;
324 if (rcu_is_cpu_idle()) 366 if (rcu_is_cpu_idle())
325 return 0; 367 return 0;
368 if (!rcu_lockdep_current_cpu_online())
369 return 0;
326 if (debug_locks) 370 if (debug_locks)
327 lockdep_opinion = lock_is_held(&rcu_sched_lock_map); 371 lockdep_opinion = lock_is_held(&rcu_sched_lock_map);
328 return lockdep_opinion || preempt_count() != 0 || irqs_disabled(); 372 return lockdep_opinion || preempt_count() != 0 || irqs_disabled();
@@ -381,8 +425,22 @@ extern int rcu_my_thread_group_empty(void);
381 } \ 425 } \
382 } while (0) 426 } while (0)
383 427
428#if defined(CONFIG_PROVE_RCU) && !defined(CONFIG_PREEMPT_RCU)
429static inline void rcu_preempt_sleep_check(void)
430{
431 rcu_lockdep_assert(!lock_is_held(&rcu_lock_map),
432 "Illegal context switch in RCU read-side "
433 "critical section");
434}
435#else /* #ifdef CONFIG_PROVE_RCU */
436static inline void rcu_preempt_sleep_check(void)
437{
438}
439#endif /* #else #ifdef CONFIG_PROVE_RCU */
440
384#define rcu_sleep_check() \ 441#define rcu_sleep_check() \
385 do { \ 442 do { \
443 rcu_preempt_sleep_check(); \
386 rcu_lockdep_assert(!lock_is_held(&rcu_bh_lock_map), \ 444 rcu_lockdep_assert(!lock_is_held(&rcu_bh_lock_map), \
387 "Illegal context switch in RCU-bh" \ 445 "Illegal context switch in RCU-bh" \
388 " read-side critical section"); \ 446 " read-side critical section"); \
@@ -470,6 +528,13 @@ extern int rcu_my_thread_group_empty(void);
470 * NULL. Although rcu_access_pointer() may also be used in cases where 528 * NULL. Although rcu_access_pointer() may also be used in cases where
471 * update-side locks prevent the value of the pointer from changing, you 529 * update-side locks prevent the value of the pointer from changing, you
472 * should instead use rcu_dereference_protected() for this use case. 530 * should instead use rcu_dereference_protected() for this use case.
531 *
532 * It is also permissible to use rcu_access_pointer() when read-side
533 * access to the pointer was removed at least one grace period ago, as
534 * is the case in the context of the RCU callback that is freeing up
535 * the data, or after a synchronize_rcu() returns. This can be useful
536 * when tearing down multi-linked structures after a grace period
537 * has elapsed.
473 */ 538 */
474#define rcu_access_pointer(p) __rcu_access_pointer((p), __rcu) 539#define rcu_access_pointer(p) __rcu_access_pointer((p), __rcu)
475 540
@@ -659,6 +724,8 @@ static inline void rcu_read_lock(void)
659 __rcu_read_lock(); 724 __rcu_read_lock();
660 __acquire(RCU); 725 __acquire(RCU);
661 rcu_lock_acquire(&rcu_lock_map); 726 rcu_lock_acquire(&rcu_lock_map);
727 rcu_lockdep_assert(!rcu_is_cpu_idle(),
728 "rcu_read_lock() used illegally while idle");
662} 729}
663 730
664/* 731/*
@@ -678,6 +745,8 @@ static inline void rcu_read_lock(void)
678 */ 745 */
679static inline void rcu_read_unlock(void) 746static inline void rcu_read_unlock(void)
680{ 747{
748 rcu_lockdep_assert(!rcu_is_cpu_idle(),
749 "rcu_read_unlock() used illegally while idle");
681 rcu_lock_release(&rcu_lock_map); 750 rcu_lock_release(&rcu_lock_map);
682 __release(RCU); 751 __release(RCU);
683 __rcu_read_unlock(); 752 __rcu_read_unlock();
@@ -705,6 +774,8 @@ static inline void rcu_read_lock_bh(void)
705 local_bh_disable(); 774 local_bh_disable();
706 __acquire(RCU_BH); 775 __acquire(RCU_BH);
707 rcu_lock_acquire(&rcu_bh_lock_map); 776 rcu_lock_acquire(&rcu_bh_lock_map);
777 rcu_lockdep_assert(!rcu_is_cpu_idle(),
778 "rcu_read_lock_bh() used illegally while idle");
708} 779}
709 780
710/* 781/*
@@ -714,6 +785,8 @@ static inline void rcu_read_lock_bh(void)
714 */ 785 */
715static inline void rcu_read_unlock_bh(void) 786static inline void rcu_read_unlock_bh(void)
716{ 787{
788 rcu_lockdep_assert(!rcu_is_cpu_idle(),
789 "rcu_read_unlock_bh() used illegally while idle");
717 rcu_lock_release(&rcu_bh_lock_map); 790 rcu_lock_release(&rcu_bh_lock_map);
718 __release(RCU_BH); 791 __release(RCU_BH);
719 local_bh_enable(); 792 local_bh_enable();
@@ -737,6 +810,8 @@ static inline void rcu_read_lock_sched(void)
737 preempt_disable(); 810 preempt_disable();
738 __acquire(RCU_SCHED); 811 __acquire(RCU_SCHED);
739 rcu_lock_acquire(&rcu_sched_lock_map); 812 rcu_lock_acquire(&rcu_sched_lock_map);
813 rcu_lockdep_assert(!rcu_is_cpu_idle(),
814 "rcu_read_lock_sched() used illegally while idle");
740} 815}
741 816
742/* Used by lockdep and tracing: cannot be traced, cannot call lockdep. */ 817/* Used by lockdep and tracing: cannot be traced, cannot call lockdep. */
@@ -753,6 +828,8 @@ static inline notrace void rcu_read_lock_sched_notrace(void)
753 */ 828 */
754static inline void rcu_read_unlock_sched(void) 829static inline void rcu_read_unlock_sched(void)
755{ 830{
831 rcu_lockdep_assert(!rcu_is_cpu_idle(),
832 "rcu_read_unlock_sched() used illegally while idle");
756 rcu_lock_release(&rcu_sched_lock_map); 833 rcu_lock_release(&rcu_sched_lock_map);
757 __release(RCU_SCHED); 834 __release(RCU_SCHED);
758 preempt_enable(); 835 preempt_enable();
@@ -841,7 +918,7 @@ void __kfree_rcu(struct rcu_head *head, unsigned long offset)
841 /* See the kfree_rcu() header comment. */ 918 /* See the kfree_rcu() header comment. */
842 BUILD_BUG_ON(!__is_kfree_rcu_offset(offset)); 919 BUILD_BUG_ON(!__is_kfree_rcu_offset(offset));
843 920
844 call_rcu(head, (rcu_callback)offset); 921 kfree_call_rcu(head, (rcu_callback)offset);
845} 922}
846 923
847/** 924/**
diff --git a/include/linux/rcutiny.h b/include/linux/rcutiny.h
index 00b7a5e493d2..e93df77176d1 100644
--- a/include/linux/rcutiny.h
+++ b/include/linux/rcutiny.h
@@ -27,13 +27,9 @@
27 27
28#include <linux/cache.h> 28#include <linux/cache.h>
29 29
30#ifdef CONFIG_RCU_BOOST
31static inline void rcu_init(void) 30static inline void rcu_init(void)
32{ 31{
33} 32}
34#else /* #ifdef CONFIG_RCU_BOOST */
35void rcu_init(void);
36#endif /* #else #ifdef CONFIG_RCU_BOOST */
37 33
38static inline void rcu_barrier_bh(void) 34static inline void rcu_barrier_bh(void)
39{ 35{
@@ -83,6 +79,12 @@ static inline void synchronize_sched_expedited(void)
83 synchronize_sched(); 79 synchronize_sched();
84} 80}
85 81
82static inline void kfree_call_rcu(struct rcu_head *head,
83 void (*func)(struct rcu_head *rcu))
84{
85 call_rcu(head, func);
86}
87
86#ifdef CONFIG_TINY_RCU 88#ifdef CONFIG_TINY_RCU
87 89
88static inline void rcu_preempt_note_context_switch(void) 90static inline void rcu_preempt_note_context_switch(void)
diff --git a/include/linux/rcutree.h b/include/linux/rcutree.h
index 67458468f1a8..e8ee5dd0854c 100644
--- a/include/linux/rcutree.h
+++ b/include/linux/rcutree.h
@@ -61,6 +61,24 @@ extern void synchronize_rcu_bh(void);
61extern void synchronize_sched_expedited(void); 61extern void synchronize_sched_expedited(void);
62extern void synchronize_rcu_expedited(void); 62extern void synchronize_rcu_expedited(void);
63 63
64void kfree_call_rcu(struct rcu_head *head, void (*func)(struct rcu_head *rcu));
65
66/**
67 * synchronize_rcu_bh_expedited - Brute-force RCU-bh grace period
68 *
69 * Wait for an RCU-bh grace period to elapse, but use a "big hammer"
70 * approach to force the grace period to end quickly. This consumes
71 * significant time on all CPUs and is unfriendly to real-time workloads,
72 * so is thus not recommended for any sort of common-case code. In fact,
73 * if you are using synchronize_rcu_bh_expedited() in a loop, please
74 * restructure your code to batch your updates, and then use a single
75 * synchronize_rcu_bh() instead.
76 *
77 * Note that it is illegal to call this function while holding any lock
78 * that is acquired by a CPU-hotplug notifier. And yes, it is also illegal
79 * to call this function from a CPU-hotplug notifier. Failing to observe
80 * these restriction will result in deadlock.
81 */
64static inline void synchronize_rcu_bh_expedited(void) 82static inline void synchronize_rcu_bh_expedited(void)
65{ 83{
66 synchronize_sched_expedited(); 84 synchronize_sched_expedited();
@@ -83,6 +101,7 @@ extern void rcu_sched_force_quiescent_state(void);
83/* A context switch is a grace period for RCU-sched and RCU-bh. */ 101/* A context switch is a grace period for RCU-sched and RCU-bh. */
84static inline int rcu_blocking_is_gp(void) 102static inline int rcu_blocking_is_gp(void)
85{ 103{
104 might_sleep(); /* Check for RCU read-side critical section. */
86 return num_online_cpus() == 1; 105 return num_online_cpus() == 1;
87} 106}
88 107
diff --git a/include/linux/ring_buffer.h b/include/linux/ring_buffer.h
index 67be0376d8e3..7be2e88f23fd 100644
--- a/include/linux/ring_buffer.h
+++ b/include/linux/ring_buffer.h
@@ -151,6 +151,9 @@ int ring_buffer_empty_cpu(struct ring_buffer *buffer, int cpu);
151 151
152void ring_buffer_record_disable(struct ring_buffer *buffer); 152void ring_buffer_record_disable(struct ring_buffer *buffer);
153void ring_buffer_record_enable(struct ring_buffer *buffer); 153void ring_buffer_record_enable(struct ring_buffer *buffer);
154void ring_buffer_record_off(struct ring_buffer *buffer);
155void ring_buffer_record_on(struct ring_buffer *buffer);
156int ring_buffer_record_is_on(struct ring_buffer *buffer);
154void ring_buffer_record_disable_cpu(struct ring_buffer *buffer, int cpu); 157void ring_buffer_record_disable_cpu(struct ring_buffer *buffer, int cpu);
155void ring_buffer_record_enable_cpu(struct ring_buffer *buffer, int cpu); 158void ring_buffer_record_enable_cpu(struct ring_buffer *buffer, int cpu);
156 159
diff --git a/include/linux/sched.h b/include/linux/sched.h
index 0657368bd78f..e074e1e54f85 100644
--- a/include/linux/sched.h
+++ b/include/linux/sched.h
@@ -361,6 +361,7 @@ extern signed long schedule_timeout_interruptible(signed long timeout);
361extern signed long schedule_timeout_killable(signed long timeout); 361extern signed long schedule_timeout_killable(signed long timeout);
362extern signed long schedule_timeout_uninterruptible(signed long timeout); 362extern signed long schedule_timeout_uninterruptible(signed long timeout);
363asmlinkage void schedule(void); 363asmlinkage void schedule(void);
364extern void schedule_preempt_disabled(void);
364extern int mutex_spin_on_owner(struct mutex *lock, struct task_struct *owner); 365extern int mutex_spin_on_owner(struct mutex *lock, struct task_struct *owner);
365 366
366struct nsproxy; 367struct nsproxy;
@@ -905,6 +906,7 @@ struct sched_group_power {
905 * single CPU. 906 * single CPU.
906 */ 907 */
907 unsigned int power, power_orig; 908 unsigned int power, power_orig;
909 unsigned long next_update;
908 /* 910 /*
909 * Number of busy cpus in this group. 911 * Number of busy cpus in this group.
910 */ 912 */
@@ -1052,6 +1054,8 @@ static inline int test_sd_parent(struct sched_domain *sd, int flag)
1052unsigned long default_scale_freq_power(struct sched_domain *sd, int cpu); 1054unsigned long default_scale_freq_power(struct sched_domain *sd, int cpu);
1053unsigned long default_scale_smt_power(struct sched_domain *sd, int cpu); 1055unsigned long default_scale_smt_power(struct sched_domain *sd, int cpu);
1054 1056
1057bool cpus_share_cache(int this_cpu, int that_cpu);
1058
1055#else /* CONFIG_SMP */ 1059#else /* CONFIG_SMP */
1056 1060
1057struct sched_domain_attr; 1061struct sched_domain_attr;
@@ -1061,6 +1065,12 @@ partition_sched_domains(int ndoms_new, cpumask_var_t doms_new[],
1061 struct sched_domain_attr *dattr_new) 1065 struct sched_domain_attr *dattr_new)
1062{ 1066{
1063} 1067}
1068
1069static inline bool cpus_share_cache(int this_cpu, int that_cpu)
1070{
1071 return true;
1072}
1073
1064#endif /* !CONFIG_SMP */ 1074#endif /* !CONFIG_SMP */
1065 1075
1066 1076
@@ -1225,6 +1235,12 @@ struct sched_rt_entity {
1225#endif 1235#endif
1226}; 1236};
1227 1237
1238/*
1239 * default timeslice is 100 msecs (used only for SCHED_RR tasks).
1240 * Timeslices get refilled after they expire.
1241 */
1242#define RR_TIMESLICE (100 * HZ / 1000)
1243
1228struct rcu_node; 1244struct rcu_node;
1229 1245
1230enum perf_event_task_context { 1246enum perf_event_task_context {
@@ -1319,6 +1335,11 @@ struct task_struct {
1319 unsigned sched_reset_on_fork:1; 1335 unsigned sched_reset_on_fork:1;
1320 unsigned sched_contributes_to_load:1; 1336 unsigned sched_contributes_to_load:1;
1321 1337
1338#ifdef CONFIG_GENERIC_HARDIRQS
1339 /* IRQ handler threads */
1340 unsigned irq_thread:1;
1341#endif
1342
1322 pid_t pid; 1343 pid_t pid;
1323 pid_t tgid; 1344 pid_t tgid;
1324 1345
@@ -1427,11 +1448,6 @@ struct task_struct {
1427 * mempolicy */ 1448 * mempolicy */
1428 spinlock_t alloc_lock; 1449 spinlock_t alloc_lock;
1429 1450
1430#ifdef CONFIG_GENERIC_HARDIRQS
1431 /* IRQ handler threads */
1432 struct irqaction *irqaction;
1433#endif
1434
1435 /* Protection of the PI data structures: */ 1451 /* Protection of the PI data structures: */
1436 raw_spinlock_t pi_lock; 1452 raw_spinlock_t pi_lock;
1437 1453
@@ -1863,8 +1879,7 @@ extern void task_clear_jobctl_pending(struct task_struct *task,
1863#ifdef CONFIG_PREEMPT_RCU 1879#ifdef CONFIG_PREEMPT_RCU
1864 1880
1865#define RCU_READ_UNLOCK_BLOCKED (1 << 0) /* blocked while in RCU read-side. */ 1881#define RCU_READ_UNLOCK_BLOCKED (1 << 0) /* blocked while in RCU read-side. */
1866#define RCU_READ_UNLOCK_BOOSTED (1 << 1) /* boosted while in RCU read-side. */ 1882#define RCU_READ_UNLOCK_NEED_QS (1 << 1) /* RCU core needs CPU response. */
1867#define RCU_READ_UNLOCK_NEED_QS (1 << 2) /* RCU core needs CPU response. */
1868 1883
1869static inline void rcu_copy_process(struct task_struct *p) 1884static inline void rcu_copy_process(struct task_struct *p)
1870{ 1885{
@@ -2048,7 +2063,7 @@ extern void sched_autogroup_fork(struct signal_struct *sig);
2048extern void sched_autogroup_exit(struct signal_struct *sig); 2063extern void sched_autogroup_exit(struct signal_struct *sig);
2049#ifdef CONFIG_PROC_FS 2064#ifdef CONFIG_PROC_FS
2050extern void proc_sched_autogroup_show_task(struct task_struct *p, struct seq_file *m); 2065extern void proc_sched_autogroup_show_task(struct task_struct *p, struct seq_file *m);
2051extern int proc_sched_autogroup_set_nice(struct task_struct *p, int *nice); 2066extern int proc_sched_autogroup_set_nice(struct task_struct *p, int nice);
2052#endif 2067#endif
2053#else 2068#else
2054static inline void sched_autogroup_create_attach(struct task_struct *p) { } 2069static inline void sched_autogroup_create_attach(struct task_struct *p) { }
@@ -2065,12 +2080,20 @@ extern unsigned int sysctl_sched_cfs_bandwidth_slice;
2065extern int rt_mutex_getprio(struct task_struct *p); 2080extern int rt_mutex_getprio(struct task_struct *p);
2066extern void rt_mutex_setprio(struct task_struct *p, int prio); 2081extern void rt_mutex_setprio(struct task_struct *p, int prio);
2067extern void rt_mutex_adjust_pi(struct task_struct *p); 2082extern void rt_mutex_adjust_pi(struct task_struct *p);
2083static inline bool tsk_is_pi_blocked(struct task_struct *tsk)
2084{
2085 return tsk->pi_blocked_on != NULL;
2086}
2068#else 2087#else
2069static inline int rt_mutex_getprio(struct task_struct *p) 2088static inline int rt_mutex_getprio(struct task_struct *p)
2070{ 2089{
2071 return p->normal_prio; 2090 return p->normal_prio;
2072} 2091}
2073# define rt_mutex_adjust_pi(p) do { } while (0) 2092# define rt_mutex_adjust_pi(p) do { } while (0)
2093static inline bool tsk_is_pi_blocked(struct task_struct *tsk)
2094{
2095 return false;
2096}
2074#endif 2097#endif
2075 2098
2076extern bool yield_to(struct task_struct *p, bool preempt); 2099extern bool yield_to(struct task_struct *p, bool preempt);
@@ -2389,12 +2412,15 @@ static inline void task_unlock(struct task_struct *p)
2389extern struct sighand_struct *__lock_task_sighand(struct task_struct *tsk, 2412extern struct sighand_struct *__lock_task_sighand(struct task_struct *tsk,
2390 unsigned long *flags); 2413 unsigned long *flags);
2391 2414
2392#define lock_task_sighand(tsk, flags) \ 2415static inline struct sighand_struct *lock_task_sighand(struct task_struct *tsk,
2393({ struct sighand_struct *__ss; \ 2416 unsigned long *flags)
2394 __cond_lock(&(tsk)->sighand->siglock, \ 2417{
2395 (__ss = __lock_task_sighand(tsk, flags))); \ 2418 struct sighand_struct *ret;
2396 __ss; \ 2419
2397}) \ 2420 ret = __lock_task_sighand(tsk, flags);
2421 (void)__cond_lock(&tsk->sighand->siglock, ret);
2422 return ret;
2423}
2398 2424
2399static inline void unlock_task_sighand(struct task_struct *tsk, 2425static inline void unlock_task_sighand(struct task_struct *tsk,
2400 unsigned long *flags) 2426 unsigned long *flags)
diff --git a/include/linux/srcu.h b/include/linux/srcu.h
index e1b005918bbb..d3d5fa54f25e 100644
--- a/include/linux/srcu.h
+++ b/include/linux/srcu.h
@@ -99,15 +99,18 @@ long srcu_batches_completed(struct srcu_struct *sp);
99 * power mode. This way we can notice an extended quiescent state to 99 * power mode. This way we can notice an extended quiescent state to
100 * other CPUs that started a grace period. Otherwise we would delay any 100 * other CPUs that started a grace period. Otherwise we would delay any
101 * grace period as long as we run in the idle task. 101 * grace period as long as we run in the idle task.
102 *
103 * Similarly, we avoid claiming an SRCU read lock held if the current
104 * CPU is offline.
102 */ 105 */
103static inline int srcu_read_lock_held(struct srcu_struct *sp) 106static inline int srcu_read_lock_held(struct srcu_struct *sp)
104{ 107{
105 if (rcu_is_cpu_idle())
106 return 0;
107
108 if (!debug_lockdep_rcu_enabled()) 108 if (!debug_lockdep_rcu_enabled())
109 return 1; 109 return 1;
110 110 if (rcu_is_cpu_idle())
111 return 0;
112 if (!rcu_lockdep_current_cpu_online())
113 return 0;
111 return lock_is_held(&sp->dep_map); 114 return lock_is_held(&sp->dep_map);
112} 115}
113 116
@@ -169,6 +172,8 @@ static inline int srcu_read_lock(struct srcu_struct *sp) __acquires(sp)
169 int retval = __srcu_read_lock(sp); 172 int retval = __srcu_read_lock(sp);
170 173
171 rcu_lock_acquire(&(sp)->dep_map); 174 rcu_lock_acquire(&(sp)->dep_map);
175 rcu_lockdep_assert(!rcu_is_cpu_idle(),
176 "srcu_read_lock() used illegally while idle");
172 return retval; 177 return retval;
173} 178}
174 179
@@ -182,6 +187,8 @@ static inline int srcu_read_lock(struct srcu_struct *sp) __acquires(sp)
182static inline void srcu_read_unlock(struct srcu_struct *sp, int idx) 187static inline void srcu_read_unlock(struct srcu_struct *sp, int idx)
183 __releases(sp) 188 __releases(sp)
184{ 189{
190 rcu_lockdep_assert(!rcu_is_cpu_idle(),
191 "srcu_read_unlock() used illegally while idle");
185 rcu_lock_release(&(sp)->dep_map); 192 rcu_lock_release(&(sp)->dep_map);
186 __srcu_read_unlock(sp, idx); 193 __srcu_read_unlock(sp, idx);
187} 194}
diff --git a/include/linux/static_key.h b/include/linux/static_key.h
new file mode 100644
index 000000000000..27bd3f8a0857
--- /dev/null
+++ b/include/linux/static_key.h
@@ -0,0 +1 @@
#include <linux/jump_label.h>
diff --git a/include/linux/timex.h b/include/linux/timex.h
index aa60fe7b6ed6..b75e1864ed19 100644
--- a/include/linux/timex.h
+++ b/include/linux/timex.h
@@ -234,23 +234,9 @@ struct timex {
234extern unsigned long tick_usec; /* USER_HZ period (usec) */ 234extern unsigned long tick_usec; /* USER_HZ period (usec) */
235extern unsigned long tick_nsec; /* ACTHZ period (nsec) */ 235extern unsigned long tick_nsec; /* ACTHZ period (nsec) */
236 236
237/*
238 * phase-lock loop variables
239 */
240extern int time_status; /* clock synchronization status bits */
241
242extern void ntp_init(void); 237extern void ntp_init(void);
243extern void ntp_clear(void); 238extern void ntp_clear(void);
244 239
245/**
246 * ntp_synced - Returns 1 if the NTP status is not UNSYNC
247 *
248 */
249static inline int ntp_synced(void)
250{
251 return !(time_status & STA_UNSYNC);
252}
253
254/* Required to safely shift negative values */ 240/* Required to safely shift negative values */
255#define shift_right(x, s) ({ \ 241#define shift_right(x, s) ({ \
256 __typeof__(x) __x = (x); \ 242 __typeof__(x) __x = (x); \
@@ -264,10 +250,9 @@ static inline int ntp_synced(void)
264#define NTP_INTERVAL_LENGTH (NSEC_PER_SEC/NTP_INTERVAL_FREQ) 250#define NTP_INTERVAL_LENGTH (NSEC_PER_SEC/NTP_INTERVAL_FREQ)
265 251
266/* Returns how long ticks are at present, in ns / 2^NTP_SCALE_SHIFT. */ 252/* Returns how long ticks are at present, in ns / 2^NTP_SCALE_SHIFT. */
267extern u64 tick_length; 253extern u64 ntp_tick_length(void);
268 254
269extern void second_overflow(void); 255extern void second_overflow(void);
270extern void update_ntp_one_tick(void);
271extern int do_adjtimex(struct timex *); 256extern int do_adjtimex(struct timex *);
272extern void hardpps(const struct timespec *, const struct timespec *); 257extern void hardpps(const struct timespec *, const struct timespec *);
273 258
diff --git a/include/linux/tracepoint.h b/include/linux/tracepoint.h
index df0a779c1bbd..bd96ecd0e05c 100644
--- a/include/linux/tracepoint.h
+++ b/include/linux/tracepoint.h
@@ -17,7 +17,7 @@
17#include <linux/errno.h> 17#include <linux/errno.h>
18#include <linux/types.h> 18#include <linux/types.h>
19#include <linux/rcupdate.h> 19#include <linux/rcupdate.h>
20#include <linux/jump_label.h> 20#include <linux/static_key.h>
21 21
22struct module; 22struct module;
23struct tracepoint; 23struct tracepoint;
@@ -29,7 +29,7 @@ struct tracepoint_func {
29 29
30struct tracepoint { 30struct tracepoint {
31 const char *name; /* Tracepoint name */ 31 const char *name; /* Tracepoint name */
32 struct jump_label_key key; 32 struct static_key key;
33 void (*regfunc)(void); 33 void (*regfunc)(void);
34 void (*unregfunc)(void); 34 void (*unregfunc)(void);
35 struct tracepoint_func __rcu *funcs; 35 struct tracepoint_func __rcu *funcs;
@@ -114,7 +114,7 @@ static inline void tracepoint_synchronize_unregister(void)
114 * as "(void *, void)". The DECLARE_TRACE_NOARGS() will pass in just 114 * as "(void *, void)". The DECLARE_TRACE_NOARGS() will pass in just
115 * "void *data", where as the DECLARE_TRACE() will pass in "void *data, proto". 115 * "void *data", where as the DECLARE_TRACE() will pass in "void *data, proto".
116 */ 116 */
117#define __DO_TRACE(tp, proto, args, cond) \ 117#define __DO_TRACE(tp, proto, args, cond, prercu, postrcu) \
118 do { \ 118 do { \
119 struct tracepoint_func *it_func_ptr; \ 119 struct tracepoint_func *it_func_ptr; \
120 void *it_func; \ 120 void *it_func; \
@@ -122,6 +122,7 @@ static inline void tracepoint_synchronize_unregister(void)
122 \ 122 \
123 if (!(cond)) \ 123 if (!(cond)) \
124 return; \ 124 return; \
125 prercu; \
125 rcu_read_lock_sched_notrace(); \ 126 rcu_read_lock_sched_notrace(); \
126 it_func_ptr = rcu_dereference_sched((tp)->funcs); \ 127 it_func_ptr = rcu_dereference_sched((tp)->funcs); \
127 if (it_func_ptr) { \ 128 if (it_func_ptr) { \
@@ -132,6 +133,7 @@ static inline void tracepoint_synchronize_unregister(void)
132 } while ((++it_func_ptr)->func); \ 133 } while ((++it_func_ptr)->func); \
133 } \ 134 } \
134 rcu_read_unlock_sched_notrace(); \ 135 rcu_read_unlock_sched_notrace(); \
136 postrcu; \
135 } while (0) 137 } while (0)
136 138
137/* 139/*
@@ -139,15 +141,25 @@ static inline void tracepoint_synchronize_unregister(void)
139 * not add unwanted padding between the beginning of the section and the 141 * not add unwanted padding between the beginning of the section and the
140 * structure. Force alignment to the same alignment as the section start. 142 * structure. Force alignment to the same alignment as the section start.
141 */ 143 */
142#define __DECLARE_TRACE(name, proto, args, cond, data_proto, data_args) \ 144#define __DECLARE_TRACE(name, proto, args, cond, data_proto, data_args) \
143 extern struct tracepoint __tracepoint_##name; \ 145 extern struct tracepoint __tracepoint_##name; \
144 static inline void trace_##name(proto) \ 146 static inline void trace_##name(proto) \
145 { \ 147 { \
148 if (static_key_false(&__tracepoint_##name.key)) \
149 __DO_TRACE(&__tracepoint_##name, \
150 TP_PROTO(data_proto), \
151 TP_ARGS(data_args), \
152 TP_CONDITION(cond),,); \
153 } \
154 static inline void trace_##name##_rcuidle(proto) \
155 { \
146 if (static_branch(&__tracepoint_##name.key)) \ 156 if (static_branch(&__tracepoint_##name.key)) \
147 __DO_TRACE(&__tracepoint_##name, \ 157 __DO_TRACE(&__tracepoint_##name, \
148 TP_PROTO(data_proto), \ 158 TP_PROTO(data_proto), \
149 TP_ARGS(data_args), \ 159 TP_ARGS(data_args), \
150 TP_CONDITION(cond)); \ 160 TP_CONDITION(cond), \
161 rcu_idle_exit(), \
162 rcu_idle_enter()); \
151 } \ 163 } \
152 static inline int \ 164 static inline int \
153 register_trace_##name(void (*probe)(data_proto), void *data) \ 165 register_trace_##name(void (*probe)(data_proto), void *data) \
@@ -176,7 +188,7 @@ static inline void tracepoint_synchronize_unregister(void)
176 __attribute__((section("__tracepoints_strings"))) = #name; \ 188 __attribute__((section("__tracepoints_strings"))) = #name; \
177 struct tracepoint __tracepoint_##name \ 189 struct tracepoint __tracepoint_##name \
178 __attribute__((section("__tracepoints"))) = \ 190 __attribute__((section("__tracepoints"))) = \
179 { __tpstrtab_##name, JUMP_LABEL_INIT, reg, unreg, NULL };\ 191 { __tpstrtab_##name, STATIC_KEY_INIT_FALSE, reg, unreg, NULL };\
180 static struct tracepoint * const __tracepoint_ptr_##name __used \ 192 static struct tracepoint * const __tracepoint_ptr_##name __used \
181 __attribute__((section("__tracepoints_ptrs"))) = \ 193 __attribute__((section("__tracepoints_ptrs"))) = \
182 &__tracepoint_##name; 194 &__tracepoint_##name;
@@ -190,9 +202,11 @@ static inline void tracepoint_synchronize_unregister(void)
190 EXPORT_SYMBOL(__tracepoint_##name) 202 EXPORT_SYMBOL(__tracepoint_##name)
191 203
192#else /* !CONFIG_TRACEPOINTS */ 204#else /* !CONFIG_TRACEPOINTS */
193#define __DECLARE_TRACE(name, proto, args, cond, data_proto, data_args) \ 205#define __DECLARE_TRACE(name, proto, args, cond, data_proto, data_args) \
194 static inline void trace_##name(proto) \ 206 static inline void trace_##name(proto) \
195 { } \ 207 { } \
208 static inline void trace_##name##_rcuidle(proto) \
209 { } \
196 static inline int \ 210 static inline int \
197 register_trace_##name(void (*probe)(data_proto), \ 211 register_trace_##name(void (*probe)(data_proto), \
198 void *data) \ 212 void *data) \
diff --git a/include/linux/wait.h b/include/linux/wait.h
index a9ce45e8501c..7d9a9e990ce6 100644
--- a/include/linux/wait.h
+++ b/include/linux/wait.h
@@ -157,7 +157,7 @@ void __wake_up(wait_queue_head_t *q, unsigned int mode, int nr, void *key);
157void __wake_up_locked_key(wait_queue_head_t *q, unsigned int mode, void *key); 157void __wake_up_locked_key(wait_queue_head_t *q, unsigned int mode, void *key);
158void __wake_up_sync_key(wait_queue_head_t *q, unsigned int mode, int nr, 158void __wake_up_sync_key(wait_queue_head_t *q, unsigned int mode, int nr,
159 void *key); 159 void *key);
160void __wake_up_locked(wait_queue_head_t *q, unsigned int mode); 160void __wake_up_locked(wait_queue_head_t *q, unsigned int mode, int nr);
161void __wake_up_sync(wait_queue_head_t *q, unsigned int mode, int nr); 161void __wake_up_sync(wait_queue_head_t *q, unsigned int mode, int nr);
162void __wake_up_bit(wait_queue_head_t *, void *, int); 162void __wake_up_bit(wait_queue_head_t *, void *, int);
163int __wait_on_bit(wait_queue_head_t *, struct wait_bit_queue *, int (*)(void *), unsigned); 163int __wait_on_bit(wait_queue_head_t *, struct wait_bit_queue *, int (*)(void *), unsigned);
@@ -170,7 +170,8 @@ wait_queue_head_t *bit_waitqueue(void *, int);
170#define wake_up(x) __wake_up(x, TASK_NORMAL, 1, NULL) 170#define wake_up(x) __wake_up(x, TASK_NORMAL, 1, NULL)
171#define wake_up_nr(x, nr) __wake_up(x, TASK_NORMAL, nr, NULL) 171#define wake_up_nr(x, nr) __wake_up(x, TASK_NORMAL, nr, NULL)
172#define wake_up_all(x) __wake_up(x, TASK_NORMAL, 0, NULL) 172#define wake_up_all(x) __wake_up(x, TASK_NORMAL, 0, NULL)
173#define wake_up_locked(x) __wake_up_locked((x), TASK_NORMAL) 173#define wake_up_locked(x) __wake_up_locked((x), TASK_NORMAL, 1)
174#define wake_up_all_locked(x) __wake_up_locked((x), TASK_NORMAL, 0)
174 175
175#define wake_up_interruptible(x) __wake_up(x, TASK_INTERRUPTIBLE, 1, NULL) 176#define wake_up_interruptible(x) __wake_up(x, TASK_INTERRUPTIBLE, 1, NULL)
176#define wake_up_interruptible_nr(x, nr) __wake_up(x, TASK_INTERRUPTIBLE, nr, NULL) 177#define wake_up_interruptible_nr(x, nr) __wake_up(x, TASK_INTERRUPTIBLE, nr, NULL)
diff --git a/include/linux/workqueue.h b/include/linux/workqueue.h
index eb8b9f15f2e0..af155450cabb 100644
--- a/include/linux/workqueue.h
+++ b/include/linux/workqueue.h
@@ -289,12 +289,16 @@ enum {
289 * 289 *
290 * system_freezable_wq is equivalent to system_wq except that it's 290 * system_freezable_wq is equivalent to system_wq except that it's
291 * freezable. 291 * freezable.
292 *
293 * system_nrt_freezable_wq is equivalent to system_nrt_wq except that
294 * it's freezable.
292 */ 295 */
293extern struct workqueue_struct *system_wq; 296extern struct workqueue_struct *system_wq;
294extern struct workqueue_struct *system_long_wq; 297extern struct workqueue_struct *system_long_wq;
295extern struct workqueue_struct *system_nrt_wq; 298extern struct workqueue_struct *system_nrt_wq;
296extern struct workqueue_struct *system_unbound_wq; 299extern struct workqueue_struct *system_unbound_wq;
297extern struct workqueue_struct *system_freezable_wq; 300extern struct workqueue_struct *system_freezable_wq;
301extern struct workqueue_struct *system_nrt_freezable_wq;
298 302
299extern struct workqueue_struct * 303extern struct workqueue_struct *
300__alloc_workqueue_key(const char *fmt, unsigned int flags, int max_active, 304__alloc_workqueue_key(const char *fmt, unsigned int flags, int max_active,
diff --git a/include/net/sock.h b/include/net/sock.h
index 91c1c8baf020..dcde2d9268cd 100644
--- a/include/net/sock.h
+++ b/include/net/sock.h
@@ -55,7 +55,7 @@
55#include <linux/uaccess.h> 55#include <linux/uaccess.h>
56#include <linux/memcontrol.h> 56#include <linux/memcontrol.h>
57#include <linux/res_counter.h> 57#include <linux/res_counter.h>
58#include <linux/jump_label.h> 58#include <linux/static_key.h>
59 59
60#include <linux/filter.h> 60#include <linux/filter.h>
61#include <linux/rculist_nulls.h> 61#include <linux/rculist_nulls.h>
@@ -924,13 +924,13 @@ inline void sk_refcnt_debug_release(const struct sock *sk)
924#endif /* SOCK_REFCNT_DEBUG */ 924#endif /* SOCK_REFCNT_DEBUG */
925 925
926#if defined(CONFIG_CGROUP_MEM_RES_CTLR_KMEM) && defined(CONFIG_NET) 926#if defined(CONFIG_CGROUP_MEM_RES_CTLR_KMEM) && defined(CONFIG_NET)
927extern struct jump_label_key memcg_socket_limit_enabled; 927extern struct static_key memcg_socket_limit_enabled;
928static inline struct cg_proto *parent_cg_proto(struct proto *proto, 928static inline struct cg_proto *parent_cg_proto(struct proto *proto,
929 struct cg_proto *cg_proto) 929 struct cg_proto *cg_proto)
930{ 930{
931 return proto->proto_cgroup(parent_mem_cgroup(cg_proto->memcg)); 931 return proto->proto_cgroup(parent_mem_cgroup(cg_proto->memcg));
932} 932}
933#define mem_cgroup_sockets_enabled static_branch(&memcg_socket_limit_enabled) 933#define mem_cgroup_sockets_enabled static_key_false(&memcg_socket_limit_enabled)
934#else 934#else
935#define mem_cgroup_sockets_enabled 0 935#define mem_cgroup_sockets_enabled 0
936static inline struct cg_proto *parent_cg_proto(struct proto *proto, 936static inline struct cg_proto *parent_cg_proto(struct proto *proto,
diff --git a/include/trace/events/power.h b/include/trace/events/power.h
index 1bcc2a8c00e2..14b38940062b 100644
--- a/include/trace/events/power.h
+++ b/include/trace/events/power.h
@@ -151,6 +151,8 @@ enum {
151 events get removed */ 151 events get removed */
152static inline void trace_power_start(u64 type, u64 state, u64 cpuid) {}; 152static inline void trace_power_start(u64 type, u64 state, u64 cpuid) {};
153static inline void trace_power_end(u64 cpuid) {}; 153static inline void trace_power_end(u64 cpuid) {};
154static inline void trace_power_start_rcuidle(u64 type, u64 state, u64 cpuid) {};
155static inline void trace_power_end_rcuidle(u64 cpuid) {};
154static inline void trace_power_frequency(u64 type, u64 state, u64 cpuid) {}; 156static inline void trace_power_frequency(u64 type, u64 state, u64 cpuid) {};
155#endif /* _PWR_EVENT_AVOID_DOUBLE_DEFINING_DEPRECATED */ 157#endif /* _PWR_EVENT_AVOID_DOUBLE_DEFINING_DEPRECATED */
156 158
diff --git a/include/trace/events/printk.h b/include/trace/events/printk.h
new file mode 100644
index 000000000000..94ec79cc011a
--- /dev/null
+++ b/include/trace/events/printk.h
@@ -0,0 +1,41 @@
1#undef TRACE_SYSTEM
2#define TRACE_SYSTEM printk
3
4#if !defined(_TRACE_PRINTK_H) || defined(TRACE_HEADER_MULTI_READ)
5#define _TRACE_PRINTK_H
6
7#include <linux/tracepoint.h>
8
9TRACE_EVENT_CONDITION(console,
10 TP_PROTO(const char *log_buf, unsigned start, unsigned end,
11 unsigned log_buf_len),
12
13 TP_ARGS(log_buf, start, end, log_buf_len),
14
15 TP_CONDITION(start != end),
16
17 TP_STRUCT__entry(
18 __dynamic_array(char, msg, end - start + 1)
19 ),
20
21 TP_fast_assign(
22 if ((start & (log_buf_len - 1)) > (end & (log_buf_len - 1))) {
23 memcpy(__get_dynamic_array(msg),
24 log_buf + (start & (log_buf_len - 1)),
25 log_buf_len - (start & (log_buf_len - 1)));
26 memcpy((char *)__get_dynamic_array(msg) +
27 log_buf_len - (start & (log_buf_len - 1)),
28 log_buf, end & (log_buf_len - 1));
29 } else
30 memcpy(__get_dynamic_array(msg),
31 log_buf + (start & (log_buf_len - 1)),
32 end - start);
33 ((char *)__get_dynamic_array(msg))[end - start] = 0;
34 ),
35
36 TP_printk("%s", __get_str(msg))
37);
38#endif /* _TRACE_PRINTK_H */
39
40/* This part must be outside protection */
41#include <trace/define_trace.h>
diff --git a/include/trace/events/rcu.h b/include/trace/events/rcu.h
index d2d88bed891b..337099783f37 100644
--- a/include/trace/events/rcu.h
+++ b/include/trace/events/rcu.h
@@ -313,19 +313,22 @@ TRACE_EVENT(rcu_prep_idle,
313/* 313/*
314 * Tracepoint for the registration of a single RCU callback function. 314 * Tracepoint for the registration of a single RCU callback function.
315 * The first argument is the type of RCU, the second argument is 315 * The first argument is the type of RCU, the second argument is
316 * a pointer to the RCU callback itself, and the third element is the 316 * a pointer to the RCU callback itself, the third element is the
317 * new RCU callback queue length for the current CPU. 317 * number of lazy callbacks queued, and the fourth element is the
318 * total number of callbacks queued.
318 */ 319 */
319TRACE_EVENT(rcu_callback, 320TRACE_EVENT(rcu_callback,
320 321
321 TP_PROTO(char *rcuname, struct rcu_head *rhp, long qlen), 322 TP_PROTO(char *rcuname, struct rcu_head *rhp, long qlen_lazy,
323 long qlen),
322 324
323 TP_ARGS(rcuname, rhp, qlen), 325 TP_ARGS(rcuname, rhp, qlen_lazy, qlen),
324 326
325 TP_STRUCT__entry( 327 TP_STRUCT__entry(
326 __field(char *, rcuname) 328 __field(char *, rcuname)
327 __field(void *, rhp) 329 __field(void *, rhp)
328 __field(void *, func) 330 __field(void *, func)
331 __field(long, qlen_lazy)
329 __field(long, qlen) 332 __field(long, qlen)
330 ), 333 ),
331 334
@@ -333,11 +336,13 @@ TRACE_EVENT(rcu_callback,
333 __entry->rcuname = rcuname; 336 __entry->rcuname = rcuname;
334 __entry->rhp = rhp; 337 __entry->rhp = rhp;
335 __entry->func = rhp->func; 338 __entry->func = rhp->func;
339 __entry->qlen_lazy = qlen_lazy;
336 __entry->qlen = qlen; 340 __entry->qlen = qlen;
337 ), 341 ),
338 342
339 TP_printk("%s rhp=%p func=%pf %ld", 343 TP_printk("%s rhp=%p func=%pf %ld/%ld",
340 __entry->rcuname, __entry->rhp, __entry->func, __entry->qlen) 344 __entry->rcuname, __entry->rhp, __entry->func,
345 __entry->qlen_lazy, __entry->qlen)
341); 346);
342 347
343/* 348/*
@@ -345,20 +350,21 @@ TRACE_EVENT(rcu_callback,
345 * kfree() form. The first argument is the RCU type, the second argument 350 * kfree() form. The first argument is the RCU type, the second argument
346 * is a pointer to the RCU callback, the third argument is the offset 351 * is a pointer to the RCU callback, the third argument is the offset
347 * of the callback within the enclosing RCU-protected data structure, 352 * of the callback within the enclosing RCU-protected data structure,
348 * and the fourth argument is the new RCU callback queue length for the 353 * the fourth argument is the number of lazy callbacks queued, and the
349 * current CPU. 354 * fifth argument is the total number of callbacks queued.
350 */ 355 */
351TRACE_EVENT(rcu_kfree_callback, 356TRACE_EVENT(rcu_kfree_callback,
352 357
353 TP_PROTO(char *rcuname, struct rcu_head *rhp, unsigned long offset, 358 TP_PROTO(char *rcuname, struct rcu_head *rhp, unsigned long offset,
354 long qlen), 359 long qlen_lazy, long qlen),
355 360
356 TP_ARGS(rcuname, rhp, offset, qlen), 361 TP_ARGS(rcuname, rhp, offset, qlen_lazy, qlen),
357 362
358 TP_STRUCT__entry( 363 TP_STRUCT__entry(
359 __field(char *, rcuname) 364 __field(char *, rcuname)
360 __field(void *, rhp) 365 __field(void *, rhp)
361 __field(unsigned long, offset) 366 __field(unsigned long, offset)
367 __field(long, qlen_lazy)
362 __field(long, qlen) 368 __field(long, qlen)
363 ), 369 ),
364 370
@@ -366,41 +372,45 @@ TRACE_EVENT(rcu_kfree_callback,
366 __entry->rcuname = rcuname; 372 __entry->rcuname = rcuname;
367 __entry->rhp = rhp; 373 __entry->rhp = rhp;
368 __entry->offset = offset; 374 __entry->offset = offset;
375 __entry->qlen_lazy = qlen_lazy;
369 __entry->qlen = qlen; 376 __entry->qlen = qlen;
370 ), 377 ),
371 378
372 TP_printk("%s rhp=%p func=%ld %ld", 379 TP_printk("%s rhp=%p func=%ld %ld/%ld",
373 __entry->rcuname, __entry->rhp, __entry->offset, 380 __entry->rcuname, __entry->rhp, __entry->offset,
374 __entry->qlen) 381 __entry->qlen_lazy, __entry->qlen)
375); 382);
376 383
377/* 384/*
378 * Tracepoint for marking the beginning rcu_do_batch, performed to start 385 * Tracepoint for marking the beginning rcu_do_batch, performed to start
379 * RCU callback invocation. The first argument is the RCU flavor, 386 * RCU callback invocation. The first argument is the RCU flavor,
380 * the second is the total number of callbacks (including those that 387 * the second is the number of lazy callbacks queued, the third is
381 * are not yet ready to be invoked), and the third argument is the 388 * the total number of callbacks queued, and the fourth argument is
382 * current RCU-callback batch limit. 389 * the current RCU-callback batch limit.
383 */ 390 */
384TRACE_EVENT(rcu_batch_start, 391TRACE_EVENT(rcu_batch_start,
385 392
386 TP_PROTO(char *rcuname, long qlen, int blimit), 393 TP_PROTO(char *rcuname, long qlen_lazy, long qlen, int blimit),
387 394
388 TP_ARGS(rcuname, qlen, blimit), 395 TP_ARGS(rcuname, qlen_lazy, qlen, blimit),
389 396
390 TP_STRUCT__entry( 397 TP_STRUCT__entry(
391 __field(char *, rcuname) 398 __field(char *, rcuname)
399 __field(long, qlen_lazy)
392 __field(long, qlen) 400 __field(long, qlen)
393 __field(int, blimit) 401 __field(int, blimit)
394 ), 402 ),
395 403
396 TP_fast_assign( 404 TP_fast_assign(
397 __entry->rcuname = rcuname; 405 __entry->rcuname = rcuname;
406 __entry->qlen_lazy = qlen_lazy;
398 __entry->qlen = qlen; 407 __entry->qlen = qlen;
399 __entry->blimit = blimit; 408 __entry->blimit = blimit;
400 ), 409 ),
401 410
402 TP_printk("%s CBs=%ld bl=%d", 411 TP_printk("%s CBs=%ld/%ld bl=%d",
403 __entry->rcuname, __entry->qlen, __entry->blimit) 412 __entry->rcuname, __entry->qlen_lazy, __entry->qlen,
413 __entry->blimit)
404); 414);
405 415
406/* 416/*
@@ -531,16 +541,21 @@ TRACE_EVENT(rcu_torture_read,
531#else /* #ifdef CONFIG_RCU_TRACE */ 541#else /* #ifdef CONFIG_RCU_TRACE */
532 542
533#define trace_rcu_grace_period(rcuname, gpnum, gpevent) do { } while (0) 543#define trace_rcu_grace_period(rcuname, gpnum, gpevent) do { } while (0)
534#define trace_rcu_grace_period_init(rcuname, gpnum, level, grplo, grphi, qsmask) do { } while (0) 544#define trace_rcu_grace_period_init(rcuname, gpnum, level, grplo, grphi, \
545 qsmask) do { } while (0)
535#define trace_rcu_preempt_task(rcuname, pid, gpnum) do { } while (0) 546#define trace_rcu_preempt_task(rcuname, pid, gpnum) do { } while (0)
536#define trace_rcu_unlock_preempted_task(rcuname, gpnum, pid) do { } while (0) 547#define trace_rcu_unlock_preempted_task(rcuname, gpnum, pid) do { } while (0)
537#define trace_rcu_quiescent_state_report(rcuname, gpnum, mask, qsmask, level, grplo, grphi, gp_tasks) do { } while (0) 548#define trace_rcu_quiescent_state_report(rcuname, gpnum, mask, qsmask, level, \
549 grplo, grphi, gp_tasks) do { } \
550 while (0)
538#define trace_rcu_fqs(rcuname, gpnum, cpu, qsevent) do { } while (0) 551#define trace_rcu_fqs(rcuname, gpnum, cpu, qsevent) do { } while (0)
539#define trace_rcu_dyntick(polarity, oldnesting, newnesting) do { } while (0) 552#define trace_rcu_dyntick(polarity, oldnesting, newnesting) do { } while (0)
540#define trace_rcu_prep_idle(reason) do { } while (0) 553#define trace_rcu_prep_idle(reason) do { } while (0)
541#define trace_rcu_callback(rcuname, rhp, qlen) do { } while (0) 554#define trace_rcu_callback(rcuname, rhp, qlen_lazy, qlen) do { } while (0)
542#define trace_rcu_kfree_callback(rcuname, rhp, offset, qlen) do { } while (0) 555#define trace_rcu_kfree_callback(rcuname, rhp, offset, qlen_lazy, qlen) \
543#define trace_rcu_batch_start(rcuname, qlen, blimit) do { } while (0) 556 do { } while (0)
557#define trace_rcu_batch_start(rcuname, qlen_lazy, qlen, blimit) \
558 do { } while (0)
544#define trace_rcu_invoke_callback(rcuname, rhp) do { } while (0) 559#define trace_rcu_invoke_callback(rcuname, rhp) do { } while (0)
545#define trace_rcu_invoke_kfree_callback(rcuname, rhp, offset) do { } while (0) 560#define trace_rcu_invoke_kfree_callback(rcuname, rhp, offset) do { } while (0)
546#define trace_rcu_batch_end(rcuname, callbacks_invoked, cb, nr, iit, risk) \ 561#define trace_rcu_batch_end(rcuname, callbacks_invoked, cb, nr, iit, risk) \
diff --git a/include/trace/events/sched.h b/include/trace/events/sched.h
index e33ed1bfa113..fbc7b1ad929b 100644
--- a/include/trace/events/sched.h
+++ b/include/trace/events/sched.h
@@ -6,6 +6,7 @@
6 6
7#include <linux/sched.h> 7#include <linux/sched.h>
8#include <linux/tracepoint.h> 8#include <linux/tracepoint.h>
9#include <linux/binfmts.h>
9 10
10/* 11/*
11 * Tracepoint for calling kthread_stop, performed to end a kthread: 12 * Tracepoint for calling kthread_stop, performed to end a kthread:
@@ -276,6 +277,32 @@ TRACE_EVENT(sched_process_fork,
276); 277);
277 278
278/* 279/*
280 * Tracepoint for exec:
281 */
282TRACE_EVENT(sched_process_exec,
283
284 TP_PROTO(struct task_struct *p, pid_t old_pid,
285 struct linux_binprm *bprm),
286
287 TP_ARGS(p, old_pid, bprm),
288
289 TP_STRUCT__entry(
290 __string( filename, bprm->filename )
291 __field( pid_t, pid )
292 __field( pid_t, old_pid )
293 ),
294
295 TP_fast_assign(
296 __assign_str(filename, bprm->filename);
297 __entry->pid = p->pid;
298 __entry->old_pid = p->pid;
299 ),
300
301 TP_printk("filename=%s pid=%d old_pid=%d", __get_str(filename),
302 __entry->pid, __entry->old_pid)
303);
304
305/*
279 * XXX the below sched_stat tracepoints only apply to SCHED_OTHER/BATCH/IDLE 306 * XXX the below sched_stat tracepoints only apply to SCHED_OTHER/BATCH/IDLE
280 * adding sched_stat support to SCHED_FIFO/RR would be welcome. 307 * adding sched_stat support to SCHED_FIFO/RR would be welcome.
281 */ 308 */
diff --git a/include/trace/events/signal.h b/include/trace/events/signal.h
index 17df43464df0..39a8a430d90f 100644
--- a/include/trace/events/signal.h
+++ b/include/trace/events/signal.h
@@ -23,11 +23,23 @@
23 } \ 23 } \
24 } while (0) 24 } while (0)
25 25
26#ifndef TRACE_HEADER_MULTI_READ
27enum {
28 TRACE_SIGNAL_DELIVERED,
29 TRACE_SIGNAL_IGNORED,
30 TRACE_SIGNAL_ALREADY_PENDING,
31 TRACE_SIGNAL_OVERFLOW_FAIL,
32 TRACE_SIGNAL_LOSE_INFO,
33};
34#endif
35
26/** 36/**
27 * signal_generate - called when a signal is generated 37 * signal_generate - called when a signal is generated
28 * @sig: signal number 38 * @sig: signal number
29 * @info: pointer to struct siginfo 39 * @info: pointer to struct siginfo
30 * @task: pointer to struct task_struct 40 * @task: pointer to struct task_struct
41 * @group: shared or private
42 * @result: TRACE_SIGNAL_*
31 * 43 *
32 * Current process sends a 'sig' signal to 'task' process with 44 * Current process sends a 'sig' signal to 'task' process with
33 * 'info' siginfo. If 'info' is SEND_SIG_NOINFO or SEND_SIG_PRIV, 45 * 'info' siginfo. If 'info' is SEND_SIG_NOINFO or SEND_SIG_PRIV,
@@ -37,9 +49,10 @@
37 */ 49 */
38TRACE_EVENT(signal_generate, 50TRACE_EVENT(signal_generate,
39 51
40 TP_PROTO(int sig, struct siginfo *info, struct task_struct *task), 52 TP_PROTO(int sig, struct siginfo *info, struct task_struct *task,
53 int group, int result),
41 54
42 TP_ARGS(sig, info, task), 55 TP_ARGS(sig, info, task, group, result),
43 56
44 TP_STRUCT__entry( 57 TP_STRUCT__entry(
45 __field( int, sig ) 58 __field( int, sig )
@@ -47,6 +60,8 @@ TRACE_EVENT(signal_generate,
47 __field( int, code ) 60 __field( int, code )
48 __array( char, comm, TASK_COMM_LEN ) 61 __array( char, comm, TASK_COMM_LEN )
49 __field( pid_t, pid ) 62 __field( pid_t, pid )
63 __field( int, group )
64 __field( int, result )
50 ), 65 ),
51 66
52 TP_fast_assign( 67 TP_fast_assign(
@@ -54,11 +69,14 @@ TRACE_EVENT(signal_generate,
54 TP_STORE_SIGINFO(__entry, info); 69 TP_STORE_SIGINFO(__entry, info);
55 memcpy(__entry->comm, task->comm, TASK_COMM_LEN); 70 memcpy(__entry->comm, task->comm, TASK_COMM_LEN);
56 __entry->pid = task->pid; 71 __entry->pid = task->pid;
72 __entry->group = group;
73 __entry->result = result;
57 ), 74 ),
58 75
59 TP_printk("sig=%d errno=%d code=%d comm=%s pid=%d", 76 TP_printk("sig=%d errno=%d code=%d comm=%s pid=%d grp=%d res=%d",
60 __entry->sig, __entry->errno, __entry->code, 77 __entry->sig, __entry->errno, __entry->code,
61 __entry->comm, __entry->pid) 78 __entry->comm, __entry->pid, __entry->group,
79 __entry->result)
62); 80);
63 81
64/** 82/**
@@ -101,65 +119,6 @@ TRACE_EVENT(signal_deliver,
101 __entry->sa_handler, __entry->sa_flags) 119 __entry->sa_handler, __entry->sa_flags)
102); 120);
103 121
104DECLARE_EVENT_CLASS(signal_queue_overflow,
105
106 TP_PROTO(int sig, int group, struct siginfo *info),
107
108 TP_ARGS(sig, group, info),
109
110 TP_STRUCT__entry(
111 __field( int, sig )
112 __field( int, group )
113 __field( int, errno )
114 __field( int, code )
115 ),
116
117 TP_fast_assign(
118 __entry->sig = sig;
119 __entry->group = group;
120 TP_STORE_SIGINFO(__entry, info);
121 ),
122
123 TP_printk("sig=%d group=%d errno=%d code=%d",
124 __entry->sig, __entry->group, __entry->errno, __entry->code)
125);
126
127/**
128 * signal_overflow_fail - called when signal queue is overflow
129 * @sig: signal number
130 * @group: signal to process group or not (bool)
131 * @info: pointer to struct siginfo
132 *
133 * Kernel fails to generate 'sig' signal with 'info' siginfo, because
134 * siginfo queue is overflow, and the signal is dropped.
135 * 'group' is not 0 if the signal will be sent to a process group.
136 * 'sig' is always one of RT signals.
137 */
138DEFINE_EVENT(signal_queue_overflow, signal_overflow_fail,
139
140 TP_PROTO(int sig, int group, struct siginfo *info),
141
142 TP_ARGS(sig, group, info)
143);
144
145/**
146 * signal_lose_info - called when siginfo is lost
147 * @sig: signal number
148 * @group: signal to process group or not (bool)
149 * @info: pointer to struct siginfo
150 *
151 * Kernel generates 'sig' signal but loses 'info' siginfo, because siginfo
152 * queue is overflow.
153 * 'group' is not 0 if the signal will be sent to a process group.
154 * 'sig' is always one of non-RT signals.
155 */
156DEFINE_EVENT(signal_queue_overflow, signal_lose_info,
157
158 TP_PROTO(int sig, int group, struct siginfo *info),
159
160 TP_ARGS(sig, group, info)
161);
162
163#endif /* _TRACE_SIGNAL_H */ 122#endif /* _TRACE_SIGNAL_H */
164 123
165/* This part must be outside protection */ 124/* This part must be outside protection */
diff --git a/init/Kconfig b/init/Kconfig
index 3f42cd66f0f8..72f33faca44f 100644
--- a/init/Kconfig
+++ b/init/Kconfig
@@ -438,15 +438,6 @@ config PREEMPT_RCU
438 This option enables preemptible-RCU code that is common between 438 This option enables preemptible-RCU code that is common between
439 the TREE_PREEMPT_RCU and TINY_PREEMPT_RCU implementations. 439 the TREE_PREEMPT_RCU and TINY_PREEMPT_RCU implementations.
440 440
441config RCU_TRACE
442 bool "Enable tracing for RCU"
443 help
444 This option provides tracing in RCU which presents stats
445 in debugfs for debugging RCU implementation.
446
447 Say Y here if you want to enable RCU tracing
448 Say N if you are unsure.
449
450config RCU_FANOUT 441config RCU_FANOUT
451 int "Tree-based hierarchical RCU fanout value" 442 int "Tree-based hierarchical RCU fanout value"
452 range 2 64 if 64BIT 443 range 2 64 if 64BIT
diff --git a/init/main.c b/init/main.c
index ff49a6dacfbb..4990f7ec776a 100644
--- a/init/main.c
+++ b/init/main.c
@@ -374,11 +374,8 @@ static noinline void __init_refok rest_init(void)
374 * at least once to get things moving: 374 * at least once to get things moving:
375 */ 375 */
376 init_idle_bootup_task(current); 376 init_idle_bootup_task(current);
377 preempt_enable_no_resched(); 377 schedule_preempt_disabled();
378 schedule();
379
380 /* Call into cpu_idle with preempt disabled */ 378 /* Call into cpu_idle with preempt disabled */
381 preempt_disable();
382 cpu_idle(); 379 cpu_idle();
383} 380}
384 381
diff --git a/kernel/events/core.c b/kernel/events/core.c
index 1b5c081d8b9f..dc3b05272511 100644
--- a/kernel/events/core.c
+++ b/kernel/events/core.c
@@ -118,6 +118,13 @@ static int cpu_function_call(int cpu, int (*func) (void *info), void *info)
118 PERF_FLAG_FD_OUTPUT |\ 118 PERF_FLAG_FD_OUTPUT |\
119 PERF_FLAG_PID_CGROUP) 119 PERF_FLAG_PID_CGROUP)
120 120
121/*
122 * branch priv levels that need permission checks
123 */
124#define PERF_SAMPLE_BRANCH_PERM_PLM \
125 (PERF_SAMPLE_BRANCH_KERNEL |\
126 PERF_SAMPLE_BRANCH_HV)
127
121enum event_type_t { 128enum event_type_t {
122 EVENT_FLEXIBLE = 0x1, 129 EVENT_FLEXIBLE = 0x1,
123 EVENT_PINNED = 0x2, 130 EVENT_PINNED = 0x2,
@@ -128,8 +135,9 @@ enum event_type_t {
128 * perf_sched_events : >0 events exist 135 * perf_sched_events : >0 events exist
129 * perf_cgroup_events: >0 per-cpu cgroup events exist on this cpu 136 * perf_cgroup_events: >0 per-cpu cgroup events exist on this cpu
130 */ 137 */
131struct jump_label_key_deferred perf_sched_events __read_mostly; 138struct static_key_deferred perf_sched_events __read_mostly;
132static DEFINE_PER_CPU(atomic_t, perf_cgroup_events); 139static DEFINE_PER_CPU(atomic_t, perf_cgroup_events);
140static DEFINE_PER_CPU(atomic_t, perf_branch_stack_events);
133 141
134static atomic_t nr_mmap_events __read_mostly; 142static atomic_t nr_mmap_events __read_mostly;
135static atomic_t nr_comm_events __read_mostly; 143static atomic_t nr_comm_events __read_mostly;
@@ -881,6 +889,9 @@ list_add_event(struct perf_event *event, struct perf_event_context *ctx)
881 if (is_cgroup_event(event)) 889 if (is_cgroup_event(event))
882 ctx->nr_cgroups++; 890 ctx->nr_cgroups++;
883 891
892 if (has_branch_stack(event))
893 ctx->nr_branch_stack++;
894
884 list_add_rcu(&event->event_entry, &ctx->event_list); 895 list_add_rcu(&event->event_entry, &ctx->event_list);
885 if (!ctx->nr_events) 896 if (!ctx->nr_events)
886 perf_pmu_rotate_start(ctx->pmu); 897 perf_pmu_rotate_start(ctx->pmu);
@@ -1020,6 +1031,9 @@ list_del_event(struct perf_event *event, struct perf_event_context *ctx)
1020 cpuctx->cgrp = NULL; 1031 cpuctx->cgrp = NULL;
1021 } 1032 }
1022 1033
1034 if (has_branch_stack(event))
1035 ctx->nr_branch_stack--;
1036
1023 ctx->nr_events--; 1037 ctx->nr_events--;
1024 if (event->attr.inherit_stat) 1038 if (event->attr.inherit_stat)
1025 ctx->nr_stat--; 1039 ctx->nr_stat--;
@@ -2195,6 +2209,66 @@ static void perf_event_context_sched_in(struct perf_event_context *ctx,
2195} 2209}
2196 2210
2197/* 2211/*
2212 * When sampling the branck stack in system-wide, it may be necessary
2213 * to flush the stack on context switch. This happens when the branch
2214 * stack does not tag its entries with the pid of the current task.
2215 * Otherwise it becomes impossible to associate a branch entry with a
2216 * task. This ambiguity is more likely to appear when the branch stack
2217 * supports priv level filtering and the user sets it to monitor only
2218 * at the user level (which could be a useful measurement in system-wide
2219 * mode). In that case, the risk is high of having a branch stack with
2220 * branch from multiple tasks. Flushing may mean dropping the existing
2221 * entries or stashing them somewhere in the PMU specific code layer.
2222 *
2223 * This function provides the context switch callback to the lower code
2224 * layer. It is invoked ONLY when there is at least one system-wide context
2225 * with at least one active event using taken branch sampling.
2226 */
2227static void perf_branch_stack_sched_in(struct task_struct *prev,
2228 struct task_struct *task)
2229{
2230 struct perf_cpu_context *cpuctx;
2231 struct pmu *pmu;
2232 unsigned long flags;
2233
2234 /* no need to flush branch stack if not changing task */
2235 if (prev == task)
2236 return;
2237
2238 local_irq_save(flags);
2239
2240 rcu_read_lock();
2241
2242 list_for_each_entry_rcu(pmu, &pmus, entry) {
2243 cpuctx = this_cpu_ptr(pmu->pmu_cpu_context);
2244
2245 /*
2246 * check if the context has at least one
2247 * event using PERF_SAMPLE_BRANCH_STACK
2248 */
2249 if (cpuctx->ctx.nr_branch_stack > 0
2250 && pmu->flush_branch_stack) {
2251
2252 pmu = cpuctx->ctx.pmu;
2253
2254 perf_ctx_lock(cpuctx, cpuctx->task_ctx);
2255
2256 perf_pmu_disable(pmu);
2257
2258 pmu->flush_branch_stack();
2259
2260 perf_pmu_enable(pmu);
2261
2262 perf_ctx_unlock(cpuctx, cpuctx->task_ctx);
2263 }
2264 }
2265
2266 rcu_read_unlock();
2267
2268 local_irq_restore(flags);
2269}
2270
2271/*
2198 * Called from scheduler to add the events of the current task 2272 * Called from scheduler to add the events of the current task
2199 * with interrupts disabled. 2273 * with interrupts disabled.
2200 * 2274 *
@@ -2225,6 +2299,10 @@ void __perf_event_task_sched_in(struct task_struct *prev,
2225 */ 2299 */
2226 if (atomic_read(&__get_cpu_var(perf_cgroup_events))) 2300 if (atomic_read(&__get_cpu_var(perf_cgroup_events)))
2227 perf_cgroup_sched_in(prev, task); 2301 perf_cgroup_sched_in(prev, task);
2302
2303 /* check for system-wide branch_stack events */
2304 if (atomic_read(&__get_cpu_var(perf_branch_stack_events)))
2305 perf_branch_stack_sched_in(prev, task);
2228} 2306}
2229 2307
2230static u64 perf_calculate_period(struct perf_event *event, u64 nsec, u64 count) 2308static u64 perf_calculate_period(struct perf_event *event, u64 nsec, u64 count)
@@ -2778,7 +2856,7 @@ static void free_event(struct perf_event *event)
2778 2856
2779 if (!event->parent) { 2857 if (!event->parent) {
2780 if (event->attach_state & PERF_ATTACH_TASK) 2858 if (event->attach_state & PERF_ATTACH_TASK)
2781 jump_label_dec_deferred(&perf_sched_events); 2859 static_key_slow_dec_deferred(&perf_sched_events);
2782 if (event->attr.mmap || event->attr.mmap_data) 2860 if (event->attr.mmap || event->attr.mmap_data)
2783 atomic_dec(&nr_mmap_events); 2861 atomic_dec(&nr_mmap_events);
2784 if (event->attr.comm) 2862 if (event->attr.comm)
@@ -2789,7 +2867,15 @@ static void free_event(struct perf_event *event)
2789 put_callchain_buffers(); 2867 put_callchain_buffers();
2790 if (is_cgroup_event(event)) { 2868 if (is_cgroup_event(event)) {
2791 atomic_dec(&per_cpu(perf_cgroup_events, event->cpu)); 2869 atomic_dec(&per_cpu(perf_cgroup_events, event->cpu));
2792 jump_label_dec_deferred(&perf_sched_events); 2870 static_key_slow_dec_deferred(&perf_sched_events);
2871 }
2872
2873 if (has_branch_stack(event)) {
2874 static_key_slow_dec_deferred(&perf_sched_events);
2875 /* is system-wide event */
2876 if (!(event->attach_state & PERF_ATTACH_TASK))
2877 atomic_dec(&per_cpu(perf_branch_stack_events,
2878 event->cpu));
2793 } 2879 }
2794 } 2880 }
2795 2881
@@ -3238,10 +3324,6 @@ int perf_event_task_disable(void)
3238 return 0; 3324 return 0;
3239} 3325}
3240 3326
3241#ifndef PERF_EVENT_INDEX_OFFSET
3242# define PERF_EVENT_INDEX_OFFSET 0
3243#endif
3244
3245static int perf_event_index(struct perf_event *event) 3327static int perf_event_index(struct perf_event *event)
3246{ 3328{
3247 if (event->hw.state & PERF_HES_STOPPED) 3329 if (event->hw.state & PERF_HES_STOPPED)
@@ -3250,21 +3332,26 @@ static int perf_event_index(struct perf_event *event)
3250 if (event->state != PERF_EVENT_STATE_ACTIVE) 3332 if (event->state != PERF_EVENT_STATE_ACTIVE)
3251 return 0; 3333 return 0;
3252 3334
3253 return event->hw.idx + 1 - PERF_EVENT_INDEX_OFFSET; 3335 return event->pmu->event_idx(event);
3254} 3336}
3255 3337
3256static void calc_timer_values(struct perf_event *event, 3338static void calc_timer_values(struct perf_event *event,
3339 u64 *now,
3257 u64 *enabled, 3340 u64 *enabled,
3258 u64 *running) 3341 u64 *running)
3259{ 3342{
3260 u64 now, ctx_time; 3343 u64 ctx_time;
3261 3344
3262 now = perf_clock(); 3345 *now = perf_clock();
3263 ctx_time = event->shadow_ctx_time + now; 3346 ctx_time = event->shadow_ctx_time + *now;
3264 *enabled = ctx_time - event->tstamp_enabled; 3347 *enabled = ctx_time - event->tstamp_enabled;
3265 *running = ctx_time - event->tstamp_running; 3348 *running = ctx_time - event->tstamp_running;
3266} 3349}
3267 3350
3351void __weak arch_perf_update_userpage(struct perf_event_mmap_page *userpg, u64 now)
3352{
3353}
3354
3268/* 3355/*
3269 * Callers need to ensure there can be no nesting of this function, otherwise 3356 * Callers need to ensure there can be no nesting of this function, otherwise
3270 * the seqlock logic goes bad. We can not serialize this because the arch 3357 * the seqlock logic goes bad. We can not serialize this because the arch
@@ -3274,7 +3361,7 @@ void perf_event_update_userpage(struct perf_event *event)
3274{ 3361{
3275 struct perf_event_mmap_page *userpg; 3362 struct perf_event_mmap_page *userpg;
3276 struct ring_buffer *rb; 3363 struct ring_buffer *rb;
3277 u64 enabled, running; 3364 u64 enabled, running, now;
3278 3365
3279 rcu_read_lock(); 3366 rcu_read_lock();
3280 /* 3367 /*
@@ -3286,7 +3373,7 @@ void perf_event_update_userpage(struct perf_event *event)
3286 * because of locking issue as we can be called in 3373 * because of locking issue as we can be called in
3287 * NMI context 3374 * NMI context
3288 */ 3375 */
3289 calc_timer_values(event, &enabled, &running); 3376 calc_timer_values(event, &now, &enabled, &running);
3290 rb = rcu_dereference(event->rb); 3377 rb = rcu_dereference(event->rb);
3291 if (!rb) 3378 if (!rb)
3292 goto unlock; 3379 goto unlock;
@@ -3302,7 +3389,7 @@ void perf_event_update_userpage(struct perf_event *event)
3302 barrier(); 3389 barrier();
3303 userpg->index = perf_event_index(event); 3390 userpg->index = perf_event_index(event);
3304 userpg->offset = perf_event_count(event); 3391 userpg->offset = perf_event_count(event);
3305 if (event->state == PERF_EVENT_STATE_ACTIVE) 3392 if (userpg->index)
3306 userpg->offset -= local64_read(&event->hw.prev_count); 3393 userpg->offset -= local64_read(&event->hw.prev_count);
3307 3394
3308 userpg->time_enabled = enabled + 3395 userpg->time_enabled = enabled +
@@ -3311,6 +3398,8 @@ void perf_event_update_userpage(struct perf_event *event)
3311 userpg->time_running = running + 3398 userpg->time_running = running +
3312 atomic64_read(&event->child_total_time_running); 3399 atomic64_read(&event->child_total_time_running);
3313 3400
3401 arch_perf_update_userpage(userpg, now);
3402
3314 barrier(); 3403 barrier();
3315 ++userpg->lock; 3404 ++userpg->lock;
3316 preempt_enable(); 3405 preempt_enable();
@@ -3568,6 +3657,8 @@ static int perf_mmap(struct file *file, struct vm_area_struct *vma)
3568 event->mmap_user = get_current_user(); 3657 event->mmap_user = get_current_user();
3569 vma->vm_mm->pinned_vm += event->mmap_locked; 3658 vma->vm_mm->pinned_vm += event->mmap_locked;
3570 3659
3660 perf_event_update_userpage(event);
3661
3571unlock: 3662unlock:
3572 if (!ret) 3663 if (!ret)
3573 atomic_inc(&event->mmap_count); 3664 atomic_inc(&event->mmap_count);
@@ -3799,7 +3890,7 @@ static void perf_output_read_group(struct perf_output_handle *handle,
3799static void perf_output_read(struct perf_output_handle *handle, 3890static void perf_output_read(struct perf_output_handle *handle,
3800 struct perf_event *event) 3891 struct perf_event *event)
3801{ 3892{
3802 u64 enabled = 0, running = 0; 3893 u64 enabled = 0, running = 0, now;
3803 u64 read_format = event->attr.read_format; 3894 u64 read_format = event->attr.read_format;
3804 3895
3805 /* 3896 /*
@@ -3812,7 +3903,7 @@ static void perf_output_read(struct perf_output_handle *handle,
3812 * NMI context 3903 * NMI context
3813 */ 3904 */
3814 if (read_format & PERF_FORMAT_TOTAL_TIMES) 3905 if (read_format & PERF_FORMAT_TOTAL_TIMES)
3815 calc_timer_values(event, &enabled, &running); 3906 calc_timer_values(event, &now, &enabled, &running);
3816 3907
3817 if (event->attr.read_format & PERF_FORMAT_GROUP) 3908 if (event->attr.read_format & PERF_FORMAT_GROUP)
3818 perf_output_read_group(handle, event, enabled, running); 3909 perf_output_read_group(handle, event, enabled, running);
@@ -3902,6 +3993,24 @@ void perf_output_sample(struct perf_output_handle *handle,
3902 } 3993 }
3903 } 3994 }
3904 } 3995 }
3996
3997 if (sample_type & PERF_SAMPLE_BRANCH_STACK) {
3998 if (data->br_stack) {
3999 size_t size;
4000
4001 size = data->br_stack->nr
4002 * sizeof(struct perf_branch_entry);
4003
4004 perf_output_put(handle, data->br_stack->nr);
4005 perf_output_copy(handle, data->br_stack->entries, size);
4006 } else {
4007 /*
4008 * we always store at least the value of nr
4009 */
4010 u64 nr = 0;
4011 perf_output_put(handle, nr);
4012 }
4013 }
3905} 4014}
3906 4015
3907void perf_prepare_sample(struct perf_event_header *header, 4016void perf_prepare_sample(struct perf_event_header *header,
@@ -3944,6 +4053,15 @@ void perf_prepare_sample(struct perf_event_header *header,
3944 WARN_ON_ONCE(size & (sizeof(u64)-1)); 4053 WARN_ON_ONCE(size & (sizeof(u64)-1));
3945 header->size += size; 4054 header->size += size;
3946 } 4055 }
4056
4057 if (sample_type & PERF_SAMPLE_BRANCH_STACK) {
4058 int size = sizeof(u64); /* nr */
4059 if (data->br_stack) {
4060 size += data->br_stack->nr
4061 * sizeof(struct perf_branch_entry);
4062 }
4063 header->size += size;
4064 }
3947} 4065}
3948 4066
3949static void perf_event_output(struct perf_event *event, 4067static void perf_event_output(struct perf_event *event,
@@ -4986,7 +5104,7 @@ fail:
4986 return err; 5104 return err;
4987} 5105}
4988 5106
4989struct jump_label_key perf_swevent_enabled[PERF_COUNT_SW_MAX]; 5107struct static_key perf_swevent_enabled[PERF_COUNT_SW_MAX];
4990 5108
4991static void sw_perf_event_destroy(struct perf_event *event) 5109static void sw_perf_event_destroy(struct perf_event *event)
4992{ 5110{
@@ -4994,7 +5112,7 @@ static void sw_perf_event_destroy(struct perf_event *event)
4994 5112
4995 WARN_ON(event->parent); 5113 WARN_ON(event->parent);
4996 5114
4997 jump_label_dec(&perf_swevent_enabled[event_id]); 5115 static_key_slow_dec(&perf_swevent_enabled[event_id]);
4998 swevent_hlist_put(event); 5116 swevent_hlist_put(event);
4999} 5117}
5000 5118
@@ -5005,6 +5123,12 @@ static int perf_swevent_init(struct perf_event *event)
5005 if (event->attr.type != PERF_TYPE_SOFTWARE) 5123 if (event->attr.type != PERF_TYPE_SOFTWARE)
5006 return -ENOENT; 5124 return -ENOENT;
5007 5125
5126 /*
5127 * no branch sampling for software events
5128 */
5129 if (has_branch_stack(event))
5130 return -EOPNOTSUPP;
5131
5008 switch (event_id) { 5132 switch (event_id) {
5009 case PERF_COUNT_SW_CPU_CLOCK: 5133 case PERF_COUNT_SW_CPU_CLOCK:
5010 case PERF_COUNT_SW_TASK_CLOCK: 5134 case PERF_COUNT_SW_TASK_CLOCK:
@@ -5024,13 +5148,18 @@ static int perf_swevent_init(struct perf_event *event)
5024 if (err) 5148 if (err)
5025 return err; 5149 return err;
5026 5150
5027 jump_label_inc(&perf_swevent_enabled[event_id]); 5151 static_key_slow_inc(&perf_swevent_enabled[event_id]);
5028 event->destroy = sw_perf_event_destroy; 5152 event->destroy = sw_perf_event_destroy;
5029 } 5153 }
5030 5154
5031 return 0; 5155 return 0;
5032} 5156}
5033 5157
5158static int perf_swevent_event_idx(struct perf_event *event)
5159{
5160 return 0;
5161}
5162
5034static struct pmu perf_swevent = { 5163static struct pmu perf_swevent = {
5035 .task_ctx_nr = perf_sw_context, 5164 .task_ctx_nr = perf_sw_context,
5036 5165
@@ -5040,6 +5169,8 @@ static struct pmu perf_swevent = {
5040 .start = perf_swevent_start, 5169 .start = perf_swevent_start,
5041 .stop = perf_swevent_stop, 5170 .stop = perf_swevent_stop,
5042 .read = perf_swevent_read, 5171 .read = perf_swevent_read,
5172
5173 .event_idx = perf_swevent_event_idx,
5043}; 5174};
5044 5175
5045#ifdef CONFIG_EVENT_TRACING 5176#ifdef CONFIG_EVENT_TRACING
@@ -5108,6 +5239,12 @@ static int perf_tp_event_init(struct perf_event *event)
5108 if (event->attr.type != PERF_TYPE_TRACEPOINT) 5239 if (event->attr.type != PERF_TYPE_TRACEPOINT)
5109 return -ENOENT; 5240 return -ENOENT;
5110 5241
5242 /*
5243 * no branch sampling for tracepoint events
5244 */
5245 if (has_branch_stack(event))
5246 return -EOPNOTSUPP;
5247
5111 err = perf_trace_init(event); 5248 err = perf_trace_init(event);
5112 if (err) 5249 if (err)
5113 return err; 5250 return err;
@@ -5126,6 +5263,8 @@ static struct pmu perf_tracepoint = {
5126 .start = perf_swevent_start, 5263 .start = perf_swevent_start,
5127 .stop = perf_swevent_stop, 5264 .stop = perf_swevent_stop,
5128 .read = perf_swevent_read, 5265 .read = perf_swevent_read,
5266
5267 .event_idx = perf_swevent_event_idx,
5129}; 5268};
5130 5269
5131static inline void perf_tp_register(void) 5270static inline void perf_tp_register(void)
@@ -5331,6 +5470,12 @@ static int cpu_clock_event_init(struct perf_event *event)
5331 if (event->attr.config != PERF_COUNT_SW_CPU_CLOCK) 5470 if (event->attr.config != PERF_COUNT_SW_CPU_CLOCK)
5332 return -ENOENT; 5471 return -ENOENT;
5333 5472
5473 /*
5474 * no branch sampling for software events
5475 */
5476 if (has_branch_stack(event))
5477 return -EOPNOTSUPP;
5478
5334 perf_swevent_init_hrtimer(event); 5479 perf_swevent_init_hrtimer(event);
5335 5480
5336 return 0; 5481 return 0;
@@ -5345,6 +5490,8 @@ static struct pmu perf_cpu_clock = {
5345 .start = cpu_clock_event_start, 5490 .start = cpu_clock_event_start,
5346 .stop = cpu_clock_event_stop, 5491 .stop = cpu_clock_event_stop,
5347 .read = cpu_clock_event_read, 5492 .read = cpu_clock_event_read,
5493
5494 .event_idx = perf_swevent_event_idx,
5348}; 5495};
5349 5496
5350/* 5497/*
@@ -5403,6 +5550,12 @@ static int task_clock_event_init(struct perf_event *event)
5403 if (event->attr.config != PERF_COUNT_SW_TASK_CLOCK) 5550 if (event->attr.config != PERF_COUNT_SW_TASK_CLOCK)
5404 return -ENOENT; 5551 return -ENOENT;
5405 5552
5553 /*
5554 * no branch sampling for software events
5555 */
5556 if (has_branch_stack(event))
5557 return -EOPNOTSUPP;
5558
5406 perf_swevent_init_hrtimer(event); 5559 perf_swevent_init_hrtimer(event);
5407 5560
5408 return 0; 5561 return 0;
@@ -5417,6 +5570,8 @@ static struct pmu perf_task_clock = {
5417 .start = task_clock_event_start, 5570 .start = task_clock_event_start,
5418 .stop = task_clock_event_stop, 5571 .stop = task_clock_event_stop,
5419 .read = task_clock_event_read, 5572 .read = task_clock_event_read,
5573
5574 .event_idx = perf_swevent_event_idx,
5420}; 5575};
5421 5576
5422static void perf_pmu_nop_void(struct pmu *pmu) 5577static void perf_pmu_nop_void(struct pmu *pmu)
@@ -5444,6 +5599,11 @@ static void perf_pmu_cancel_txn(struct pmu *pmu)
5444 perf_pmu_enable(pmu); 5599 perf_pmu_enable(pmu);
5445} 5600}
5446 5601
5602static int perf_event_idx_default(struct perf_event *event)
5603{
5604 return event->hw.idx + 1;
5605}
5606
5447/* 5607/*
5448 * Ensures all contexts with the same task_ctx_nr have the same 5608 * Ensures all contexts with the same task_ctx_nr have the same
5449 * pmu_cpu_context too. 5609 * pmu_cpu_context too.
@@ -5530,6 +5690,7 @@ static int pmu_dev_alloc(struct pmu *pmu)
5530 if (!pmu->dev) 5690 if (!pmu->dev)
5531 goto out; 5691 goto out;
5532 5692
5693 pmu->dev->groups = pmu->attr_groups;
5533 device_initialize(pmu->dev); 5694 device_initialize(pmu->dev);
5534 ret = dev_set_name(pmu->dev, "%s", pmu->name); 5695 ret = dev_set_name(pmu->dev, "%s", pmu->name);
5535 if (ret) 5696 if (ret)
@@ -5633,6 +5794,9 @@ got_cpu_context:
5633 pmu->pmu_disable = perf_pmu_nop_void; 5794 pmu->pmu_disable = perf_pmu_nop_void;
5634 } 5795 }
5635 5796
5797 if (!pmu->event_idx)
5798 pmu->event_idx = perf_event_idx_default;
5799
5636 list_add_rcu(&pmu->entry, &pmus); 5800 list_add_rcu(&pmu->entry, &pmus);
5637 ret = 0; 5801 ret = 0;
5638unlock: 5802unlock:
@@ -5825,7 +5989,7 @@ done:
5825 5989
5826 if (!event->parent) { 5990 if (!event->parent) {
5827 if (event->attach_state & PERF_ATTACH_TASK) 5991 if (event->attach_state & PERF_ATTACH_TASK)
5828 jump_label_inc(&perf_sched_events.key); 5992 static_key_slow_inc(&perf_sched_events.key);
5829 if (event->attr.mmap || event->attr.mmap_data) 5993 if (event->attr.mmap || event->attr.mmap_data)
5830 atomic_inc(&nr_mmap_events); 5994 atomic_inc(&nr_mmap_events);
5831 if (event->attr.comm) 5995 if (event->attr.comm)
@@ -5839,6 +6003,12 @@ done:
5839 return ERR_PTR(err); 6003 return ERR_PTR(err);
5840 } 6004 }
5841 } 6005 }
6006 if (has_branch_stack(event)) {
6007 static_key_slow_inc(&perf_sched_events.key);
6008 if (!(event->attach_state & PERF_ATTACH_TASK))
6009 atomic_inc(&per_cpu(perf_branch_stack_events,
6010 event->cpu));
6011 }
5842 } 6012 }
5843 6013
5844 return event; 6014 return event;
@@ -5908,6 +6078,40 @@ static int perf_copy_attr(struct perf_event_attr __user *uattr,
5908 if (attr->read_format & ~(PERF_FORMAT_MAX-1)) 6078 if (attr->read_format & ~(PERF_FORMAT_MAX-1))
5909 return -EINVAL; 6079 return -EINVAL;
5910 6080
6081 if (attr->sample_type & PERF_SAMPLE_BRANCH_STACK) {
6082 u64 mask = attr->branch_sample_type;
6083
6084 /* only using defined bits */
6085 if (mask & ~(PERF_SAMPLE_BRANCH_MAX-1))
6086 return -EINVAL;
6087
6088 /* at least one branch bit must be set */
6089 if (!(mask & ~PERF_SAMPLE_BRANCH_PLM_ALL))
6090 return -EINVAL;
6091
6092 /* kernel level capture: check permissions */
6093 if ((mask & PERF_SAMPLE_BRANCH_PERM_PLM)
6094 && perf_paranoid_kernel() && !capable(CAP_SYS_ADMIN))
6095 return -EACCES;
6096
6097 /* propagate priv level, when not set for branch */
6098 if (!(mask & PERF_SAMPLE_BRANCH_PLM_ALL)) {
6099
6100 /* exclude_kernel checked on syscall entry */
6101 if (!attr->exclude_kernel)
6102 mask |= PERF_SAMPLE_BRANCH_KERNEL;
6103
6104 if (!attr->exclude_user)
6105 mask |= PERF_SAMPLE_BRANCH_USER;
6106
6107 if (!attr->exclude_hv)
6108 mask |= PERF_SAMPLE_BRANCH_HV;
6109 /*
6110 * adjust user setting (for HW filter setup)
6111 */
6112 attr->branch_sample_type = mask;
6113 }
6114 }
5911out: 6115out:
5912 return ret; 6116 return ret;
5913 6117
@@ -6063,7 +6267,7 @@ SYSCALL_DEFINE5(perf_event_open,
6063 * - that may need work on context switch 6267 * - that may need work on context switch
6064 */ 6268 */
6065 atomic_inc(&per_cpu(perf_cgroup_events, event->cpu)); 6269 atomic_inc(&per_cpu(perf_cgroup_events, event->cpu));
6066 jump_label_inc(&perf_sched_events.key); 6270 static_key_slow_inc(&perf_sched_events.key);
6067 } 6271 }
6068 6272
6069 /* 6273 /*
diff --git a/kernel/events/hw_breakpoint.c b/kernel/events/hw_breakpoint.c
index ee706ce44aa0..bb38c4d3ee12 100644
--- a/kernel/events/hw_breakpoint.c
+++ b/kernel/events/hw_breakpoint.c
@@ -581,6 +581,12 @@ static int hw_breakpoint_event_init(struct perf_event *bp)
581 if (bp->attr.type != PERF_TYPE_BREAKPOINT) 581 if (bp->attr.type != PERF_TYPE_BREAKPOINT)
582 return -ENOENT; 582 return -ENOENT;
583 583
584 /*
585 * no branch sampling for breakpoint events
586 */
587 if (has_branch_stack(bp))
588 return -EOPNOTSUPP;
589
584 err = register_perf_hw_breakpoint(bp); 590 err = register_perf_hw_breakpoint(bp);
585 if (err) 591 if (err)
586 return err; 592 return err;
@@ -613,6 +619,11 @@ static void hw_breakpoint_stop(struct perf_event *bp, int flags)
613 bp->hw.state = PERF_HES_STOPPED; 619 bp->hw.state = PERF_HES_STOPPED;
614} 620}
615 621
622static int hw_breakpoint_event_idx(struct perf_event *bp)
623{
624 return 0;
625}
626
616static struct pmu perf_breakpoint = { 627static struct pmu perf_breakpoint = {
617 .task_ctx_nr = perf_sw_context, /* could eventually get its own */ 628 .task_ctx_nr = perf_sw_context, /* could eventually get its own */
618 629
@@ -622,6 +633,8 @@ static struct pmu perf_breakpoint = {
622 .start = hw_breakpoint_start, 633 .start = hw_breakpoint_start,
623 .stop = hw_breakpoint_stop, 634 .stop = hw_breakpoint_stop,
624 .read = hw_breakpoint_pmu_read, 635 .read = hw_breakpoint_pmu_read,
636
637 .event_idx = hw_breakpoint_event_idx,
625}; 638};
626 639
627int __init init_hw_breakpoint(void) 640int __init init_hw_breakpoint(void)
diff --git a/kernel/exit.c b/kernel/exit.c
index 4b4042f9bc6a..752d2c0abd19 100644
--- a/kernel/exit.c
+++ b/kernel/exit.c
@@ -935,8 +935,6 @@ void do_exit(long code)
935 schedule(); 935 schedule();
936 } 936 }
937 937
938 exit_irq_thread();
939
940 exit_signals(tsk); /* sets PF_EXITING */ 938 exit_signals(tsk); /* sets PF_EXITING */
941 /* 939 /*
942 * tsk->flags are checked in the futex code to protect against 940 * tsk->flags are checked in the futex code to protect against
@@ -945,6 +943,8 @@ void do_exit(long code)
945 smp_mb(); 943 smp_mb();
946 raw_spin_unlock_wait(&tsk->pi_lock); 944 raw_spin_unlock_wait(&tsk->pi_lock);
947 945
946 exit_irq_thread();
947
948 if (unlikely(in_atomic())) 948 if (unlikely(in_atomic()))
949 printk(KERN_INFO "note: %s[%d] exited with preempt_count %d\n", 949 printk(KERN_INFO "note: %s[%d] exited with preempt_count %d\n",
950 current->comm, task_pid_nr(current), 950 current->comm, task_pid_nr(current),
diff --git a/kernel/futex.c b/kernel/futex.c
index 1614be20173d..72efa1e4359a 100644
--- a/kernel/futex.c
+++ b/kernel/futex.c
@@ -2628,7 +2628,7 @@ void exit_robust_list(struct task_struct *curr)
2628long do_futex(u32 __user *uaddr, int op, u32 val, ktime_t *timeout, 2628long do_futex(u32 __user *uaddr, int op, u32 val, ktime_t *timeout,
2629 u32 __user *uaddr2, u32 val2, u32 val3) 2629 u32 __user *uaddr2, u32 val2, u32 val3)
2630{ 2630{
2631 int ret = -ENOSYS, cmd = op & FUTEX_CMD_MASK; 2631 int cmd = op & FUTEX_CMD_MASK;
2632 unsigned int flags = 0; 2632 unsigned int flags = 0;
2633 2633
2634 if (!(op & FUTEX_PRIVATE_FLAG)) 2634 if (!(op & FUTEX_PRIVATE_FLAG))
@@ -2641,49 +2641,44 @@ long do_futex(u32 __user *uaddr, int op, u32 val, ktime_t *timeout,
2641 } 2641 }
2642 2642
2643 switch (cmd) { 2643 switch (cmd) {
2644 case FUTEX_LOCK_PI:
2645 case FUTEX_UNLOCK_PI:
2646 case FUTEX_TRYLOCK_PI:
2647 case FUTEX_WAIT_REQUEUE_PI:
2648 case FUTEX_CMP_REQUEUE_PI:
2649 if (!futex_cmpxchg_enabled)
2650 return -ENOSYS;
2651 }
2652
2653 switch (cmd) {
2644 case FUTEX_WAIT: 2654 case FUTEX_WAIT:
2645 val3 = FUTEX_BITSET_MATCH_ANY; 2655 val3 = FUTEX_BITSET_MATCH_ANY;
2646 case FUTEX_WAIT_BITSET: 2656 case FUTEX_WAIT_BITSET:
2647 ret = futex_wait(uaddr, flags, val, timeout, val3); 2657 return futex_wait(uaddr, flags, val, timeout, val3);
2648 break;
2649 case FUTEX_WAKE: 2658 case FUTEX_WAKE:
2650 val3 = FUTEX_BITSET_MATCH_ANY; 2659 val3 = FUTEX_BITSET_MATCH_ANY;
2651 case FUTEX_WAKE_BITSET: 2660 case FUTEX_WAKE_BITSET:
2652 ret = futex_wake(uaddr, flags, val, val3); 2661 return futex_wake(uaddr, flags, val, val3);
2653 break;
2654 case FUTEX_REQUEUE: 2662 case FUTEX_REQUEUE:
2655 ret = futex_requeue(uaddr, flags, uaddr2, val, val2, NULL, 0); 2663 return futex_requeue(uaddr, flags, uaddr2, val, val2, NULL, 0);
2656 break;
2657 case FUTEX_CMP_REQUEUE: 2664 case FUTEX_CMP_REQUEUE:
2658 ret = futex_requeue(uaddr, flags, uaddr2, val, val2, &val3, 0); 2665 return futex_requeue(uaddr, flags, uaddr2, val, val2, &val3, 0);
2659 break;
2660 case FUTEX_WAKE_OP: 2666 case FUTEX_WAKE_OP:
2661 ret = futex_wake_op(uaddr, flags, uaddr2, val, val2, val3); 2667 return futex_wake_op(uaddr, flags, uaddr2, val, val2, val3);
2662 break;
2663 case FUTEX_LOCK_PI: 2668 case FUTEX_LOCK_PI:
2664 if (futex_cmpxchg_enabled) 2669 return futex_lock_pi(uaddr, flags, val, timeout, 0);
2665 ret = futex_lock_pi(uaddr, flags, val, timeout, 0);
2666 break;
2667 case FUTEX_UNLOCK_PI: 2670 case FUTEX_UNLOCK_PI:
2668 if (futex_cmpxchg_enabled) 2671 return futex_unlock_pi(uaddr, flags);
2669 ret = futex_unlock_pi(uaddr, flags);
2670 break;
2671 case FUTEX_TRYLOCK_PI: 2672 case FUTEX_TRYLOCK_PI:
2672 if (futex_cmpxchg_enabled) 2673 return futex_lock_pi(uaddr, flags, 0, timeout, 1);
2673 ret = futex_lock_pi(uaddr, flags, 0, timeout, 1);
2674 break;
2675 case FUTEX_WAIT_REQUEUE_PI: 2674 case FUTEX_WAIT_REQUEUE_PI:
2676 val3 = FUTEX_BITSET_MATCH_ANY; 2675 val3 = FUTEX_BITSET_MATCH_ANY;
2677 ret = futex_wait_requeue_pi(uaddr, flags, val, timeout, val3, 2676 return futex_wait_requeue_pi(uaddr, flags, val, timeout, val3,
2678 uaddr2); 2677 uaddr2);
2679 break;
2680 case FUTEX_CMP_REQUEUE_PI: 2678 case FUTEX_CMP_REQUEUE_PI:
2681 ret = futex_requeue(uaddr, flags, uaddr2, val, val2, &val3, 1); 2679 return futex_requeue(uaddr, flags, uaddr2, val, val2, &val3, 1);
2682 break;
2683 default:
2684 ret = -ENOSYS;
2685 } 2680 }
2686 return ret; 2681 return -ENOSYS;
2687} 2682}
2688 2683
2689 2684
diff --git a/kernel/irq/chip.c b/kernel/irq/chip.c
index fb7db75ee0c8..6080f6bc8c33 100644
--- a/kernel/irq/chip.c
+++ b/kernel/irq/chip.c
@@ -16,6 +16,8 @@
16#include <linux/interrupt.h> 16#include <linux/interrupt.h>
17#include <linux/kernel_stat.h> 17#include <linux/kernel_stat.h>
18 18
19#include <trace/events/irq.h>
20
19#include "internals.h" 21#include "internals.h"
20 22
21/** 23/**
@@ -61,8 +63,7 @@ int irq_set_irq_type(unsigned int irq, unsigned int type)
61 return -EINVAL; 63 return -EINVAL;
62 64
63 type &= IRQ_TYPE_SENSE_MASK; 65 type &= IRQ_TYPE_SENSE_MASK;
64 if (type != IRQ_TYPE_NONE) 66 ret = __irq_set_trigger(desc, irq, type);
65 ret = __irq_set_trigger(desc, irq, type);
66 irq_put_desc_busunlock(desc, flags); 67 irq_put_desc_busunlock(desc, flags);
67 return ret; 68 return ret;
68} 69}
diff --git a/kernel/irq/handle.c b/kernel/irq/handle.c
index 470d08c82bbe..6ff84e6a954c 100644
--- a/kernel/irq/handle.c
+++ b/kernel/irq/handle.c
@@ -60,7 +60,7 @@ static void irq_wake_thread(struct irq_desc *desc, struct irqaction *action)
60 * device interrupt, so no irq storm is lurking. If the 60 * device interrupt, so no irq storm is lurking. If the
61 * RUNTHREAD bit is already set, nothing to do. 61 * RUNTHREAD bit is already set, nothing to do.
62 */ 62 */
63 if (test_bit(IRQTF_DIED, &action->thread_flags) || 63 if ((action->thread->flags & PF_EXITING) ||
64 test_and_set_bit(IRQTF_RUNTHREAD, &action->thread_flags)) 64 test_and_set_bit(IRQTF_RUNTHREAD, &action->thread_flags))
65 return; 65 return;
66 66
@@ -110,6 +110,18 @@ static void irq_wake_thread(struct irq_desc *desc, struct irqaction *action)
110 * threads_oneshot untouched and runs the thread another time. 110 * threads_oneshot untouched and runs the thread another time.
111 */ 111 */
112 desc->threads_oneshot |= action->thread_mask; 112 desc->threads_oneshot |= action->thread_mask;
113
114 /*
115 * We increment the threads_active counter in case we wake up
116 * the irq thread. The irq thread decrements the counter when
117 * it returns from the handler or in the exit path and wakes
118 * up waiters which are stuck in synchronize_irq() when the
119 * active count becomes zero. synchronize_irq() is serialized
120 * against this code (hard irq handler) via IRQS_INPROGRESS
121 * like the finalize_oneshot() code. See comment above.
122 */
123 atomic_inc(&desc->threads_active);
124
113 wake_up_process(action->thread); 125 wake_up_process(action->thread);
114} 126}
115 127
diff --git a/kernel/irq/internals.h b/kernel/irq/internals.h
index 40378ff877e7..8e5c56b3b7d9 100644
--- a/kernel/irq/internals.h
+++ b/kernel/irq/internals.h
@@ -20,14 +20,12 @@ extern bool noirqdebug;
20/* 20/*
21 * Bits used by threaded handlers: 21 * Bits used by threaded handlers:
22 * IRQTF_RUNTHREAD - signals that the interrupt handler thread should run 22 * IRQTF_RUNTHREAD - signals that the interrupt handler thread should run
23 * IRQTF_DIED - handler thread died
24 * IRQTF_WARNED - warning "IRQ_WAKE_THREAD w/o thread_fn" has been printed 23 * IRQTF_WARNED - warning "IRQ_WAKE_THREAD w/o thread_fn" has been printed
25 * IRQTF_AFFINITY - irq thread is requested to adjust affinity 24 * IRQTF_AFFINITY - irq thread is requested to adjust affinity
26 * IRQTF_FORCED_THREAD - irq action is force threaded 25 * IRQTF_FORCED_THREAD - irq action is force threaded
27 */ 26 */
28enum { 27enum {
29 IRQTF_RUNTHREAD, 28 IRQTF_RUNTHREAD,
30 IRQTF_DIED,
31 IRQTF_WARNED, 29 IRQTF_WARNED,
32 IRQTF_AFFINITY, 30 IRQTF_AFFINITY,
33 IRQTF_FORCED_THREAD, 31 IRQTF_FORCED_THREAD,
diff --git a/kernel/irq/manage.c b/kernel/irq/manage.c
index 0f0d4704ddd8..b0ccd1ac2d6a 100644
--- a/kernel/irq/manage.c
+++ b/kernel/irq/manage.c
@@ -759,6 +759,13 @@ static irqreturn_t irq_thread_fn(struct irq_desc *desc,
759 return ret; 759 return ret;
760} 760}
761 761
762static void wake_threads_waitq(struct irq_desc *desc)
763{
764 if (atomic_dec_and_test(&desc->threads_active) &&
765 waitqueue_active(&desc->wait_for_threads))
766 wake_up(&desc->wait_for_threads);
767}
768
762/* 769/*
763 * Interrupt handler thread 770 * Interrupt handler thread
764 */ 771 */
@@ -771,57 +778,41 @@ static int irq_thread(void *data)
771 struct irq_desc *desc = irq_to_desc(action->irq); 778 struct irq_desc *desc = irq_to_desc(action->irq);
772 irqreturn_t (*handler_fn)(struct irq_desc *desc, 779 irqreturn_t (*handler_fn)(struct irq_desc *desc,
773 struct irqaction *action); 780 struct irqaction *action);
774 int wake;
775 781
776 if (force_irqthreads & test_bit(IRQTF_FORCED_THREAD, 782 if (force_irqthreads && test_bit(IRQTF_FORCED_THREAD,
777 &action->thread_flags)) 783 &action->thread_flags))
778 handler_fn = irq_forced_thread_fn; 784 handler_fn = irq_forced_thread_fn;
779 else 785 else
780 handler_fn = irq_thread_fn; 786 handler_fn = irq_thread_fn;
781 787
782 sched_setscheduler(current, SCHED_FIFO, &param); 788 sched_setscheduler(current, SCHED_FIFO, &param);
783 current->irqaction = action; 789 current->irq_thread = 1;
784 790
785 while (!irq_wait_for_interrupt(action)) { 791 while (!irq_wait_for_interrupt(action)) {
792 irqreturn_t action_ret;
786 793
787 irq_thread_check_affinity(desc, action); 794 irq_thread_check_affinity(desc, action);
788 795
789 atomic_inc(&desc->threads_active); 796 action_ret = handler_fn(desc, action);
797 if (!noirqdebug)
798 note_interrupt(action->irq, desc, action_ret);
790 799
791 raw_spin_lock_irq(&desc->lock); 800 wake_threads_waitq(desc);
792 if (unlikely(irqd_irq_disabled(&desc->irq_data))) {
793 /*
794 * CHECKME: We might need a dedicated
795 * IRQ_THREAD_PENDING flag here, which
796 * retriggers the thread in check_irq_resend()
797 * but AFAICT IRQS_PENDING should be fine as it
798 * retriggers the interrupt itself --- tglx
799 */
800 desc->istate |= IRQS_PENDING;
801 raw_spin_unlock_irq(&desc->lock);
802 } else {
803 irqreturn_t action_ret;
804
805 raw_spin_unlock_irq(&desc->lock);
806 action_ret = handler_fn(desc, action);
807 if (!noirqdebug)
808 note_interrupt(action->irq, desc, action_ret);
809 }
810
811 wake = atomic_dec_and_test(&desc->threads_active);
812
813 if (wake && waitqueue_active(&desc->wait_for_threads))
814 wake_up(&desc->wait_for_threads);
815 } 801 }
816 802
817 /* Prevent a stale desc->threads_oneshot */
818 irq_finalize_oneshot(desc, action, true);
819
820 /* 803 /*
821 * Clear irqaction. Otherwise exit_irq_thread() would make 804 * This is the regular exit path. __free_irq() is stopping the
805 * thread via kthread_stop() after calling
806 * synchronize_irq(). So neither IRQTF_RUNTHREAD nor the
807 * oneshot mask bit can be set. We cannot verify that as we
808 * cannot touch the oneshot mask at this point anymore as
809 * __setup_irq() might have given out currents thread_mask
810 * again.
811 *
812 * Clear irq_thread. Otherwise exit_irq_thread() would make
822 * fuzz about an active irq thread going into nirvana. 813 * fuzz about an active irq thread going into nirvana.
823 */ 814 */
824 current->irqaction = NULL; 815 current->irq_thread = 0;
825 return 0; 816 return 0;
826} 817}
827 818
@@ -832,27 +823,28 @@ void exit_irq_thread(void)
832{ 823{
833 struct task_struct *tsk = current; 824 struct task_struct *tsk = current;
834 struct irq_desc *desc; 825 struct irq_desc *desc;
826 struct irqaction *action;
835 827
836 if (!tsk->irqaction) 828 if (!tsk->irq_thread)
837 return; 829 return;
838 830
831 action = kthread_data(tsk);
832
839 printk(KERN_ERR 833 printk(KERN_ERR
840 "exiting task \"%s\" (%d) is an active IRQ thread (irq %d)\n", 834 "exiting task \"%s\" (%d) is an active IRQ thread (irq %d)\n",
841 tsk->comm ? tsk->comm : "", tsk->pid, tsk->irqaction->irq); 835 tsk->comm ? tsk->comm : "", tsk->pid, action->irq);
842 836
843 desc = irq_to_desc(tsk->irqaction->irq); 837 desc = irq_to_desc(action->irq);
844 838
845 /* 839 /*
846 * Prevent a stale desc->threads_oneshot. Must be called 840 * If IRQTF_RUNTHREAD is set, we need to decrement
847 * before setting the IRQTF_DIED flag. 841 * desc->threads_active and wake possible waiters.
848 */ 842 */
849 irq_finalize_oneshot(desc, tsk->irqaction, true); 843 if (test_and_clear_bit(IRQTF_RUNTHREAD, &action->thread_flags))
844 wake_threads_waitq(desc);
850 845
851 /* 846 /* Prevent a stale desc->threads_oneshot */
852 * Set the THREAD DIED flag to prevent further wakeups of the 847 irq_finalize_oneshot(desc, action, true);
853 * soon to be gone threaded handler.
854 */
855 set_bit(IRQTF_DIED, &tsk->irqaction->flags);
856} 848}
857 849
858static void irq_setup_forced_threading(struct irqaction *new) 850static void irq_setup_forced_threading(struct irqaction *new)
@@ -1135,8 +1127,7 @@ out_thread:
1135 struct task_struct *t = new->thread; 1127 struct task_struct *t = new->thread;
1136 1128
1137 new->thread = NULL; 1129 new->thread = NULL;
1138 if (likely(!test_bit(IRQTF_DIED, &new->thread_flags))) 1130 kthread_stop(t);
1139 kthread_stop(t);
1140 put_task_struct(t); 1131 put_task_struct(t);
1141 } 1132 }
1142out_mput: 1133out_mput:
@@ -1246,8 +1237,7 @@ static struct irqaction *__free_irq(unsigned int irq, void *dev_id)
1246#endif 1237#endif
1247 1238
1248 if (action->thread) { 1239 if (action->thread) {
1249 if (!test_bit(IRQTF_DIED, &action->thread_flags)) 1240 kthread_stop(action->thread);
1250 kthread_stop(action->thread);
1251 put_task_struct(action->thread); 1241 put_task_struct(action->thread);
1252 } 1242 }
1253 1243
diff --git a/kernel/jump_label.c b/kernel/jump_label.c
index 01d3b70fc98a..43049192b5ec 100644
--- a/kernel/jump_label.c
+++ b/kernel/jump_label.c
@@ -12,7 +12,7 @@
12#include <linux/slab.h> 12#include <linux/slab.h>
13#include <linux/sort.h> 13#include <linux/sort.h>
14#include <linux/err.h> 14#include <linux/err.h>
15#include <linux/jump_label.h> 15#include <linux/static_key.h>
16 16
17#ifdef HAVE_JUMP_LABEL 17#ifdef HAVE_JUMP_LABEL
18 18
@@ -29,11 +29,6 @@ void jump_label_unlock(void)
29 mutex_unlock(&jump_label_mutex); 29 mutex_unlock(&jump_label_mutex);
30} 30}
31 31
32bool jump_label_enabled(struct jump_label_key *key)
33{
34 return !!atomic_read(&key->enabled);
35}
36
37static int jump_label_cmp(const void *a, const void *b) 32static int jump_label_cmp(const void *a, const void *b)
38{ 33{
39 const struct jump_entry *jea = a; 34 const struct jump_entry *jea = a;
@@ -58,56 +53,66 @@ jump_label_sort_entries(struct jump_entry *start, struct jump_entry *stop)
58 sort(start, size, sizeof(struct jump_entry), jump_label_cmp, NULL); 53 sort(start, size, sizeof(struct jump_entry), jump_label_cmp, NULL);
59} 54}
60 55
61static void jump_label_update(struct jump_label_key *key, int enable); 56static void jump_label_update(struct static_key *key, int enable);
62 57
63void jump_label_inc(struct jump_label_key *key) 58void static_key_slow_inc(struct static_key *key)
64{ 59{
65 if (atomic_inc_not_zero(&key->enabled)) 60 if (atomic_inc_not_zero(&key->enabled))
66 return; 61 return;
67 62
68 jump_label_lock(); 63 jump_label_lock();
69 if (atomic_read(&key->enabled) == 0) 64 if (atomic_read(&key->enabled) == 0) {
70 jump_label_update(key, JUMP_LABEL_ENABLE); 65 if (!jump_label_get_branch_default(key))
66 jump_label_update(key, JUMP_LABEL_ENABLE);
67 else
68 jump_label_update(key, JUMP_LABEL_DISABLE);
69 }
71 atomic_inc(&key->enabled); 70 atomic_inc(&key->enabled);
72 jump_label_unlock(); 71 jump_label_unlock();
73} 72}
74EXPORT_SYMBOL_GPL(jump_label_inc); 73EXPORT_SYMBOL_GPL(static_key_slow_inc);
75 74
76static void __jump_label_dec(struct jump_label_key *key, 75static void __static_key_slow_dec(struct static_key *key,
77 unsigned long rate_limit, struct delayed_work *work) 76 unsigned long rate_limit, struct delayed_work *work)
78{ 77{
79 if (!atomic_dec_and_mutex_lock(&key->enabled, &jump_label_mutex)) 78 if (!atomic_dec_and_mutex_lock(&key->enabled, &jump_label_mutex)) {
79 WARN(atomic_read(&key->enabled) < 0,
80 "jump label: negative count!\n");
80 return; 81 return;
82 }
81 83
82 if (rate_limit) { 84 if (rate_limit) {
83 atomic_inc(&key->enabled); 85 atomic_inc(&key->enabled);
84 schedule_delayed_work(work, rate_limit); 86 schedule_delayed_work(work, rate_limit);
85 } else 87 } else {
86 jump_label_update(key, JUMP_LABEL_DISABLE); 88 if (!jump_label_get_branch_default(key))
87 89 jump_label_update(key, JUMP_LABEL_DISABLE);
90 else
91 jump_label_update(key, JUMP_LABEL_ENABLE);
92 }
88 jump_label_unlock(); 93 jump_label_unlock();
89} 94}
90EXPORT_SYMBOL_GPL(jump_label_dec);
91 95
92static void jump_label_update_timeout(struct work_struct *work) 96static void jump_label_update_timeout(struct work_struct *work)
93{ 97{
94 struct jump_label_key_deferred *key = 98 struct static_key_deferred *key =
95 container_of(work, struct jump_label_key_deferred, work.work); 99 container_of(work, struct static_key_deferred, work.work);
96 __jump_label_dec(&key->key, 0, NULL); 100 __static_key_slow_dec(&key->key, 0, NULL);
97} 101}
98 102
99void jump_label_dec(struct jump_label_key *key) 103void static_key_slow_dec(struct static_key *key)
100{ 104{
101 __jump_label_dec(key, 0, NULL); 105 __static_key_slow_dec(key, 0, NULL);
102} 106}
107EXPORT_SYMBOL_GPL(static_key_slow_dec);
103 108
104void jump_label_dec_deferred(struct jump_label_key_deferred *key) 109void static_key_slow_dec_deferred(struct static_key_deferred *key)
105{ 110{
106 __jump_label_dec(&key->key, key->timeout, &key->work); 111 __static_key_slow_dec(&key->key, key->timeout, &key->work);
107} 112}
113EXPORT_SYMBOL_GPL(static_key_slow_dec_deferred);
108 114
109 115void jump_label_rate_limit(struct static_key_deferred *key,
110void jump_label_rate_limit(struct jump_label_key_deferred *key,
111 unsigned long rl) 116 unsigned long rl)
112{ 117{
113 key->timeout = rl; 118 key->timeout = rl;
@@ -150,7 +155,7 @@ void __weak __init_or_module arch_jump_label_transform_static(struct jump_entry
150 arch_jump_label_transform(entry, type); 155 arch_jump_label_transform(entry, type);
151} 156}
152 157
153static void __jump_label_update(struct jump_label_key *key, 158static void __jump_label_update(struct static_key *key,
154 struct jump_entry *entry, 159 struct jump_entry *entry,
155 struct jump_entry *stop, int enable) 160 struct jump_entry *stop, int enable)
156{ 161{
@@ -167,27 +172,40 @@ static void __jump_label_update(struct jump_label_key *key,
167 } 172 }
168} 173}
169 174
175static enum jump_label_type jump_label_type(struct static_key *key)
176{
177 bool true_branch = jump_label_get_branch_default(key);
178 bool state = static_key_enabled(key);
179
180 if ((!true_branch && state) || (true_branch && !state))
181 return JUMP_LABEL_ENABLE;
182
183 return JUMP_LABEL_DISABLE;
184}
185
170void __init jump_label_init(void) 186void __init jump_label_init(void)
171{ 187{
172 struct jump_entry *iter_start = __start___jump_table; 188 struct jump_entry *iter_start = __start___jump_table;
173 struct jump_entry *iter_stop = __stop___jump_table; 189 struct jump_entry *iter_stop = __stop___jump_table;
174 struct jump_label_key *key = NULL; 190 struct static_key *key = NULL;
175 struct jump_entry *iter; 191 struct jump_entry *iter;
176 192
177 jump_label_lock(); 193 jump_label_lock();
178 jump_label_sort_entries(iter_start, iter_stop); 194 jump_label_sort_entries(iter_start, iter_stop);
179 195
180 for (iter = iter_start; iter < iter_stop; iter++) { 196 for (iter = iter_start; iter < iter_stop; iter++) {
181 struct jump_label_key *iterk; 197 struct static_key *iterk;
182 198
183 iterk = (struct jump_label_key *)(unsigned long)iter->key; 199 iterk = (struct static_key *)(unsigned long)iter->key;
184 arch_jump_label_transform_static(iter, jump_label_enabled(iterk) ? 200 arch_jump_label_transform_static(iter, jump_label_type(iterk));
185 JUMP_LABEL_ENABLE : JUMP_LABEL_DISABLE);
186 if (iterk == key) 201 if (iterk == key)
187 continue; 202 continue;
188 203
189 key = iterk; 204 key = iterk;
190 key->entries = iter; 205 /*
206 * Set key->entries to iter, but preserve JUMP_LABEL_TRUE_BRANCH.
207 */
208 *((unsigned long *)&key->entries) += (unsigned long)iter;
191#ifdef CONFIG_MODULES 209#ifdef CONFIG_MODULES
192 key->next = NULL; 210 key->next = NULL;
193#endif 211#endif
@@ -197,8 +215,8 @@ void __init jump_label_init(void)
197 215
198#ifdef CONFIG_MODULES 216#ifdef CONFIG_MODULES
199 217
200struct jump_label_mod { 218struct static_key_mod {
201 struct jump_label_mod *next; 219 struct static_key_mod *next;
202 struct jump_entry *entries; 220 struct jump_entry *entries;
203 struct module *mod; 221 struct module *mod;
204}; 222};
@@ -218,9 +236,9 @@ static int __jump_label_mod_text_reserved(void *start, void *end)
218 start, end); 236 start, end);
219} 237}
220 238
221static void __jump_label_mod_update(struct jump_label_key *key, int enable) 239static void __jump_label_mod_update(struct static_key *key, int enable)
222{ 240{
223 struct jump_label_mod *mod = key->next; 241 struct static_key_mod *mod = key->next;
224 242
225 while (mod) { 243 while (mod) {
226 struct module *m = mod->mod; 244 struct module *m = mod->mod;
@@ -251,11 +269,7 @@ void jump_label_apply_nops(struct module *mod)
251 return; 269 return;
252 270
253 for (iter = iter_start; iter < iter_stop; iter++) { 271 for (iter = iter_start; iter < iter_stop; iter++) {
254 struct jump_label_key *iterk; 272 arch_jump_label_transform_static(iter, JUMP_LABEL_DISABLE);
255
256 iterk = (struct jump_label_key *)(unsigned long)iter->key;
257 arch_jump_label_transform_static(iter, jump_label_enabled(iterk) ?
258 JUMP_LABEL_ENABLE : JUMP_LABEL_DISABLE);
259 } 273 }
260} 274}
261 275
@@ -264,8 +278,8 @@ static int jump_label_add_module(struct module *mod)
264 struct jump_entry *iter_start = mod->jump_entries; 278 struct jump_entry *iter_start = mod->jump_entries;
265 struct jump_entry *iter_stop = iter_start + mod->num_jump_entries; 279 struct jump_entry *iter_stop = iter_start + mod->num_jump_entries;
266 struct jump_entry *iter; 280 struct jump_entry *iter;
267 struct jump_label_key *key = NULL; 281 struct static_key *key = NULL;
268 struct jump_label_mod *jlm; 282 struct static_key_mod *jlm;
269 283
270 /* if the module doesn't have jump label entries, just return */ 284 /* if the module doesn't have jump label entries, just return */
271 if (iter_start == iter_stop) 285 if (iter_start == iter_stop)
@@ -274,28 +288,30 @@ static int jump_label_add_module(struct module *mod)
274 jump_label_sort_entries(iter_start, iter_stop); 288 jump_label_sort_entries(iter_start, iter_stop);
275 289
276 for (iter = iter_start; iter < iter_stop; iter++) { 290 for (iter = iter_start; iter < iter_stop; iter++) {
277 if (iter->key == (jump_label_t)(unsigned long)key) 291 struct static_key *iterk;
278 continue;
279 292
280 key = (struct jump_label_key *)(unsigned long)iter->key; 293 iterk = (struct static_key *)(unsigned long)iter->key;
294 if (iterk == key)
295 continue;
281 296
297 key = iterk;
282 if (__module_address(iter->key) == mod) { 298 if (__module_address(iter->key) == mod) {
283 atomic_set(&key->enabled, 0); 299 /*
284 key->entries = iter; 300 * Set key->entries to iter, but preserve JUMP_LABEL_TRUE_BRANCH.
301 */
302 *((unsigned long *)&key->entries) += (unsigned long)iter;
285 key->next = NULL; 303 key->next = NULL;
286 continue; 304 continue;
287 } 305 }
288 306 jlm = kzalloc(sizeof(struct static_key_mod), GFP_KERNEL);
289 jlm = kzalloc(sizeof(struct jump_label_mod), GFP_KERNEL);
290 if (!jlm) 307 if (!jlm)
291 return -ENOMEM; 308 return -ENOMEM;
292
293 jlm->mod = mod; 309 jlm->mod = mod;
294 jlm->entries = iter; 310 jlm->entries = iter;
295 jlm->next = key->next; 311 jlm->next = key->next;
296 key->next = jlm; 312 key->next = jlm;
297 313
298 if (jump_label_enabled(key)) 314 if (jump_label_type(key) == JUMP_LABEL_ENABLE)
299 __jump_label_update(key, iter, iter_stop, JUMP_LABEL_ENABLE); 315 __jump_label_update(key, iter, iter_stop, JUMP_LABEL_ENABLE);
300 } 316 }
301 317
@@ -307,14 +323,14 @@ static void jump_label_del_module(struct module *mod)
307 struct jump_entry *iter_start = mod->jump_entries; 323 struct jump_entry *iter_start = mod->jump_entries;
308 struct jump_entry *iter_stop = iter_start + mod->num_jump_entries; 324 struct jump_entry *iter_stop = iter_start + mod->num_jump_entries;
309 struct jump_entry *iter; 325 struct jump_entry *iter;
310 struct jump_label_key *key = NULL; 326 struct static_key *key = NULL;
311 struct jump_label_mod *jlm, **prev; 327 struct static_key_mod *jlm, **prev;
312 328
313 for (iter = iter_start; iter < iter_stop; iter++) { 329 for (iter = iter_start; iter < iter_stop; iter++) {
314 if (iter->key == (jump_label_t)(unsigned long)key) 330 if (iter->key == (jump_label_t)(unsigned long)key)
315 continue; 331 continue;
316 332
317 key = (struct jump_label_key *)(unsigned long)iter->key; 333 key = (struct static_key *)(unsigned long)iter->key;
318 334
319 if (__module_address(iter->key) == mod) 335 if (__module_address(iter->key) == mod)
320 continue; 336 continue;
@@ -416,12 +432,13 @@ int jump_label_text_reserved(void *start, void *end)
416 return ret; 432 return ret;
417} 433}
418 434
419static void jump_label_update(struct jump_label_key *key, int enable) 435static void jump_label_update(struct static_key *key, int enable)
420{ 436{
421 struct jump_entry *entry = key->entries, *stop = __stop___jump_table; 437 struct jump_entry *stop = __stop___jump_table;
438 struct jump_entry *entry = jump_label_get_entries(key);
422 439
423#ifdef CONFIG_MODULES 440#ifdef CONFIG_MODULES
424 struct module *mod = __module_address((jump_label_t)key); 441 struct module *mod = __module_address((unsigned long)key);
425 442
426 __jump_label_mod_update(key, enable); 443 __jump_label_mod_update(key, enable);
427 444
diff --git a/kernel/lockdep.c b/kernel/lockdep.c
index 8889f7dd7c46..ea9ee4518c35 100644
--- a/kernel/lockdep.c
+++ b/kernel/lockdep.c
@@ -4176,7 +4176,13 @@ void lockdep_rcu_suspicious(const char *file, const int line, const char *s)
4176 printk("-------------------------------\n"); 4176 printk("-------------------------------\n");
4177 printk("%s:%d %s!\n", file, line, s); 4177 printk("%s:%d %s!\n", file, line, s);
4178 printk("\nother info that might help us debug this:\n\n"); 4178 printk("\nother info that might help us debug this:\n\n");
4179 printk("\nrcu_scheduler_active = %d, debug_locks = %d\n", rcu_scheduler_active, debug_locks); 4179 printk("\n%srcu_scheduler_active = %d, debug_locks = %d\n",
4180 !rcu_lockdep_current_cpu_online()
4181 ? "RCU used illegally from offline CPU!\n"
4182 : rcu_is_cpu_idle()
4183 ? "RCU used illegally from idle CPU!\n"
4184 : "",
4185 rcu_scheduler_active, debug_locks);
4180 4186
4181 /* 4187 /*
4182 * If a CPU is in the RCU-free window in idle (ie: in the section 4188 * If a CPU is in the RCU-free window in idle (ie: in the section
diff --git a/kernel/mutex.c b/kernel/mutex.c
index 89096dd8786f..a307cc9c9526 100644
--- a/kernel/mutex.c
+++ b/kernel/mutex.c
@@ -240,9 +240,7 @@ __mutex_lock_common(struct mutex *lock, long state, unsigned int subclass,
240 240
241 /* didn't get the lock, go to sleep: */ 241 /* didn't get the lock, go to sleep: */
242 spin_unlock_mutex(&lock->wait_lock, flags); 242 spin_unlock_mutex(&lock->wait_lock, flags);
243 preempt_enable_no_resched(); 243 schedule_preempt_disabled();
244 schedule();
245 preempt_disable();
246 spin_lock_mutex(&lock->wait_lock, flags); 244 spin_lock_mutex(&lock->wait_lock, flags);
247 } 245 }
248 246
diff --git a/kernel/printk.c b/kernel/printk.c
index 32690a0b7a18..b663c2c95d39 100644
--- a/kernel/printk.c
+++ b/kernel/printk.c
@@ -44,6 +44,9 @@
44 44
45#include <asm/uaccess.h> 45#include <asm/uaccess.h>
46 46
47#define CREATE_TRACE_POINTS
48#include <trace/events/printk.h>
49
47/* 50/*
48 * Architectures can override it: 51 * Architectures can override it:
49 */ 52 */
@@ -542,6 +545,8 @@ MODULE_PARM_DESC(ignore_loglevel, "ignore loglevel setting, to"
542static void _call_console_drivers(unsigned start, 545static void _call_console_drivers(unsigned start,
543 unsigned end, int msg_log_level) 546 unsigned end, int msg_log_level)
544{ 547{
548 trace_console(&LOG_BUF(0), start, end, log_buf_len);
549
545 if ((msg_log_level < console_loglevel || ignore_loglevel) && 550 if ((msg_log_level < console_loglevel || ignore_loglevel) &&
546 console_drivers && start != end) { 551 console_drivers && start != end) {
547 if ((start & LOG_BUF_MASK) > (end & LOG_BUF_MASK)) { 552 if ((start & LOG_BUF_MASK) > (end & LOG_BUF_MASK)) {
@@ -1211,13 +1216,27 @@ int is_console_locked(void)
1211 return console_locked; 1216 return console_locked;
1212} 1217}
1213 1218
1219/*
1220 * Delayed printk facility, for scheduler-internal messages:
1221 */
1222#define PRINTK_BUF_SIZE 512
1223
1224#define PRINTK_PENDING_WAKEUP 0x01
1225#define PRINTK_PENDING_SCHED 0x02
1226
1214static DEFINE_PER_CPU(int, printk_pending); 1227static DEFINE_PER_CPU(int, printk_pending);
1228static DEFINE_PER_CPU(char [PRINTK_BUF_SIZE], printk_sched_buf);
1215 1229
1216void printk_tick(void) 1230void printk_tick(void)
1217{ 1231{
1218 if (__this_cpu_read(printk_pending)) { 1232 if (__this_cpu_read(printk_pending)) {
1219 __this_cpu_write(printk_pending, 0); 1233 int pending = __this_cpu_xchg(printk_pending, 0);
1220 wake_up_interruptible(&log_wait); 1234 if (pending & PRINTK_PENDING_SCHED) {
1235 char *buf = __get_cpu_var(printk_sched_buf);
1236 printk(KERN_WARNING "[sched_delayed] %s", buf);
1237 }
1238 if (pending & PRINTK_PENDING_WAKEUP)
1239 wake_up_interruptible(&log_wait);
1221 } 1240 }
1222} 1241}
1223 1242
@@ -1231,7 +1250,7 @@ int printk_needs_cpu(int cpu)
1231void wake_up_klogd(void) 1250void wake_up_klogd(void)
1232{ 1251{
1233 if (waitqueue_active(&log_wait)) 1252 if (waitqueue_active(&log_wait))
1234 this_cpu_write(printk_pending, 1); 1253 this_cpu_or(printk_pending, PRINTK_PENDING_WAKEUP);
1235} 1254}
1236 1255
1237/** 1256/**
@@ -1624,6 +1643,26 @@ late_initcall(printk_late_init);
1624 1643
1625#if defined CONFIG_PRINTK 1644#if defined CONFIG_PRINTK
1626 1645
1646int printk_sched(const char *fmt, ...)
1647{
1648 unsigned long flags;
1649 va_list args;
1650 char *buf;
1651 int r;
1652
1653 local_irq_save(flags);
1654 buf = __get_cpu_var(printk_sched_buf);
1655
1656 va_start(args, fmt);
1657 r = vsnprintf(buf, PRINTK_BUF_SIZE, fmt, args);
1658 va_end(args);
1659
1660 __this_cpu_or(printk_pending, PRINTK_PENDING_SCHED);
1661 local_irq_restore(flags);
1662
1663 return r;
1664}
1665
1627/* 1666/*
1628 * printk rate limiting, lifted from the networking subsystem. 1667 * printk rate limiting, lifted from the networking subsystem.
1629 * 1668 *
diff --git a/kernel/rcu.h b/kernel/rcu.h
index aa88baab5f78..8ba99cdc6515 100644
--- a/kernel/rcu.h
+++ b/kernel/rcu.h
@@ -33,8 +33,27 @@
33 * Process-level increment to ->dynticks_nesting field. This allows for 33 * Process-level increment to ->dynticks_nesting field. This allows for
34 * architectures that use half-interrupts and half-exceptions from 34 * architectures that use half-interrupts and half-exceptions from
35 * process context. 35 * process context.
36 *
37 * DYNTICK_TASK_NEST_MASK defines a field of width DYNTICK_TASK_NEST_WIDTH
38 * that counts the number of process-based reasons why RCU cannot
39 * consider the corresponding CPU to be idle, and DYNTICK_TASK_NEST_VALUE
40 * is the value used to increment or decrement this field.
41 *
42 * The rest of the bits could in principle be used to count interrupts,
43 * but this would mean that a negative-one value in the interrupt
44 * field could incorrectly zero out the DYNTICK_TASK_NEST_MASK field.
45 * We therefore provide a two-bit guard field defined by DYNTICK_TASK_MASK
46 * that is set to DYNTICK_TASK_FLAG upon initial exit from idle.
47 * The DYNTICK_TASK_EXIT_IDLE value is thus the combined value used upon
48 * initial exit from idle.
36 */ 49 */
37#define DYNTICK_TASK_NESTING (LLONG_MAX / 2 - 1) 50#define DYNTICK_TASK_NEST_WIDTH 7
51#define DYNTICK_TASK_NEST_VALUE ((LLONG_MAX >> DYNTICK_TASK_NEST_WIDTH) + 1)
52#define DYNTICK_TASK_NEST_MASK (LLONG_MAX - DYNTICK_TASK_NEST_VALUE + 1)
53#define DYNTICK_TASK_FLAG ((DYNTICK_TASK_NEST_VALUE / 8) * 2)
54#define DYNTICK_TASK_MASK ((DYNTICK_TASK_NEST_VALUE / 8) * 3)
55#define DYNTICK_TASK_EXIT_IDLE (DYNTICK_TASK_NEST_VALUE + \
56 DYNTICK_TASK_FLAG)
38 57
39/* 58/*
40 * debug_rcu_head_queue()/debug_rcu_head_unqueue() are used internally 59 * debug_rcu_head_queue()/debug_rcu_head_unqueue() are used internally
@@ -50,7 +69,6 @@ extern struct debug_obj_descr rcuhead_debug_descr;
50 69
51static inline void debug_rcu_head_queue(struct rcu_head *head) 70static inline void debug_rcu_head_queue(struct rcu_head *head)
52{ 71{
53 WARN_ON_ONCE((unsigned long)head & 0x3);
54 debug_object_activate(head, &rcuhead_debug_descr); 72 debug_object_activate(head, &rcuhead_debug_descr);
55 debug_object_active_state(head, &rcuhead_debug_descr, 73 debug_object_active_state(head, &rcuhead_debug_descr,
56 STATE_RCU_HEAD_READY, 74 STATE_RCU_HEAD_READY,
@@ -76,16 +94,18 @@ static inline void debug_rcu_head_unqueue(struct rcu_head *head)
76 94
77extern void kfree(const void *); 95extern void kfree(const void *);
78 96
79static inline void __rcu_reclaim(char *rn, struct rcu_head *head) 97static inline bool __rcu_reclaim(char *rn, struct rcu_head *head)
80{ 98{
81 unsigned long offset = (unsigned long)head->func; 99 unsigned long offset = (unsigned long)head->func;
82 100
83 if (__is_kfree_rcu_offset(offset)) { 101 if (__is_kfree_rcu_offset(offset)) {
84 RCU_TRACE(trace_rcu_invoke_kfree_callback(rn, head, offset)); 102 RCU_TRACE(trace_rcu_invoke_kfree_callback(rn, head, offset));
85 kfree((void *)head - offset); 103 kfree((void *)head - offset);
104 return 1;
86 } else { 105 } else {
87 RCU_TRACE(trace_rcu_invoke_callback(rn, head)); 106 RCU_TRACE(trace_rcu_invoke_callback(rn, head));
88 head->func(head); 107 head->func(head);
108 return 0;
89 } 109 }
90} 110}
91 111
diff --git a/kernel/rcupdate.c b/kernel/rcupdate.c
index 2bc4e135ff23..a86f1741cc27 100644
--- a/kernel/rcupdate.c
+++ b/kernel/rcupdate.c
@@ -88,6 +88,9 @@ EXPORT_SYMBOL_GPL(debug_lockdep_rcu_enabled);
88 * section. 88 * section.
89 * 89 *
90 * Check debug_lockdep_rcu_enabled() to prevent false positives during boot. 90 * Check debug_lockdep_rcu_enabled() to prevent false positives during boot.
91 *
92 * Note that rcu_read_lock() is disallowed if the CPU is either idle or
93 * offline from an RCU perspective, so check for those as well.
91 */ 94 */
92int rcu_read_lock_bh_held(void) 95int rcu_read_lock_bh_held(void)
93{ 96{
@@ -95,6 +98,8 @@ int rcu_read_lock_bh_held(void)
95 return 1; 98 return 1;
96 if (rcu_is_cpu_idle()) 99 if (rcu_is_cpu_idle())
97 return 0; 100 return 0;
101 if (!rcu_lockdep_current_cpu_online())
102 return 0;
98 return in_softirq() || irqs_disabled(); 103 return in_softirq() || irqs_disabled();
99} 104}
100EXPORT_SYMBOL_GPL(rcu_read_lock_bh_held); 105EXPORT_SYMBOL_GPL(rcu_read_lock_bh_held);
diff --git a/kernel/rcutiny.c b/kernel/rcutiny.c
index 977296dca0a4..37a5444204d2 100644
--- a/kernel/rcutiny.c
+++ b/kernel/rcutiny.c
@@ -53,7 +53,7 @@ static void __call_rcu(struct rcu_head *head,
53 53
54#include "rcutiny_plugin.h" 54#include "rcutiny_plugin.h"
55 55
56static long long rcu_dynticks_nesting = DYNTICK_TASK_NESTING; 56static long long rcu_dynticks_nesting = DYNTICK_TASK_EXIT_IDLE;
57 57
58/* Common code for rcu_idle_enter() and rcu_irq_exit(), see kernel/rcutree.c. */ 58/* Common code for rcu_idle_enter() and rcu_irq_exit(), see kernel/rcutree.c. */
59static void rcu_idle_enter_common(long long oldval) 59static void rcu_idle_enter_common(long long oldval)
@@ -88,10 +88,16 @@ void rcu_idle_enter(void)
88 88
89 local_irq_save(flags); 89 local_irq_save(flags);
90 oldval = rcu_dynticks_nesting; 90 oldval = rcu_dynticks_nesting;
91 rcu_dynticks_nesting = 0; 91 WARN_ON_ONCE((rcu_dynticks_nesting & DYNTICK_TASK_NEST_MASK) == 0);
92 if ((rcu_dynticks_nesting & DYNTICK_TASK_NEST_MASK) ==
93 DYNTICK_TASK_NEST_VALUE)
94 rcu_dynticks_nesting = 0;
95 else
96 rcu_dynticks_nesting -= DYNTICK_TASK_NEST_VALUE;
92 rcu_idle_enter_common(oldval); 97 rcu_idle_enter_common(oldval);
93 local_irq_restore(flags); 98 local_irq_restore(flags);
94} 99}
100EXPORT_SYMBOL_GPL(rcu_idle_enter);
95 101
96/* 102/*
97 * Exit an interrupt handler towards idle. 103 * Exit an interrupt handler towards idle.
@@ -140,11 +146,15 @@ void rcu_idle_exit(void)
140 146
141 local_irq_save(flags); 147 local_irq_save(flags);
142 oldval = rcu_dynticks_nesting; 148 oldval = rcu_dynticks_nesting;
143 WARN_ON_ONCE(oldval != 0); 149 WARN_ON_ONCE(rcu_dynticks_nesting < 0);
144 rcu_dynticks_nesting = DYNTICK_TASK_NESTING; 150 if (rcu_dynticks_nesting & DYNTICK_TASK_NEST_MASK)
151 rcu_dynticks_nesting += DYNTICK_TASK_NEST_VALUE;
152 else
153 rcu_dynticks_nesting = DYNTICK_TASK_EXIT_IDLE;
145 rcu_idle_exit_common(oldval); 154 rcu_idle_exit_common(oldval);
146 local_irq_restore(flags); 155 local_irq_restore(flags);
147} 156}
157EXPORT_SYMBOL_GPL(rcu_idle_exit);
148 158
149/* 159/*
150 * Enter an interrupt handler, moving away from idle. 160 * Enter an interrupt handler, moving away from idle.
@@ -258,7 +268,7 @@ static void __rcu_process_callbacks(struct rcu_ctrlblk *rcp)
258 268
259 /* If no RCU callbacks ready to invoke, just return. */ 269 /* If no RCU callbacks ready to invoke, just return. */
260 if (&rcp->rcucblist == rcp->donetail) { 270 if (&rcp->rcucblist == rcp->donetail) {
261 RCU_TRACE(trace_rcu_batch_start(rcp->name, 0, -1)); 271 RCU_TRACE(trace_rcu_batch_start(rcp->name, 0, 0, -1));
262 RCU_TRACE(trace_rcu_batch_end(rcp->name, 0, 272 RCU_TRACE(trace_rcu_batch_end(rcp->name, 0,
263 ACCESS_ONCE(rcp->rcucblist), 273 ACCESS_ONCE(rcp->rcucblist),
264 need_resched(), 274 need_resched(),
@@ -269,7 +279,7 @@ static void __rcu_process_callbacks(struct rcu_ctrlblk *rcp)
269 279
270 /* Move the ready-to-invoke callbacks to a local list. */ 280 /* Move the ready-to-invoke callbacks to a local list. */
271 local_irq_save(flags); 281 local_irq_save(flags);
272 RCU_TRACE(trace_rcu_batch_start(rcp->name, 0, -1)); 282 RCU_TRACE(trace_rcu_batch_start(rcp->name, 0, rcp->qlen, -1));
273 list = rcp->rcucblist; 283 list = rcp->rcucblist;
274 rcp->rcucblist = *rcp->donetail; 284 rcp->rcucblist = *rcp->donetail;
275 *rcp->donetail = NULL; 285 *rcp->donetail = NULL;
@@ -319,6 +329,10 @@ static void rcu_process_callbacks(struct softirq_action *unused)
319 */ 329 */
320void synchronize_sched(void) 330void synchronize_sched(void)
321{ 331{
332 rcu_lockdep_assert(!lock_is_held(&rcu_bh_lock_map) &&
333 !lock_is_held(&rcu_lock_map) &&
334 !lock_is_held(&rcu_sched_lock_map),
335 "Illegal synchronize_sched() in RCU read-side critical section");
322 cond_resched(); 336 cond_resched();
323} 337}
324EXPORT_SYMBOL_GPL(synchronize_sched); 338EXPORT_SYMBOL_GPL(synchronize_sched);
diff --git a/kernel/rcutiny_plugin.h b/kernel/rcutiny_plugin.h
index 9cb1ae4aabdd..22ecea0dfb62 100644
--- a/kernel/rcutiny_plugin.h
+++ b/kernel/rcutiny_plugin.h
@@ -132,6 +132,7 @@ static struct rcu_preempt_ctrlblk rcu_preempt_ctrlblk = {
132 RCU_TRACE(.rcb.name = "rcu_preempt") 132 RCU_TRACE(.rcb.name = "rcu_preempt")
133}; 133};
134 134
135static void rcu_read_unlock_special(struct task_struct *t);
135static int rcu_preempted_readers_exp(void); 136static int rcu_preempted_readers_exp(void);
136static void rcu_report_exp_done(void); 137static void rcu_report_exp_done(void);
137 138
@@ -146,6 +147,16 @@ static int rcu_cpu_blocking_cur_gp(void)
146/* 147/*
147 * Check for a running RCU reader. Because there is only one CPU, 148 * Check for a running RCU reader. Because there is only one CPU,
148 * there can be but one running RCU reader at a time. ;-) 149 * there can be but one running RCU reader at a time. ;-)
150 *
151 * Returns zero if there are no running readers. Returns a positive
152 * number if there is at least one reader within its RCU read-side
153 * critical section. Returns a negative number if an outermost reader
154 * is in the midst of exiting from its RCU read-side critical section
155 *
156 * Returns zero if there are no running readers. Returns a positive
157 * number if there is at least one reader within its RCU read-side
158 * critical section. Returns a negative number if an outermost reader
159 * is in the midst of exiting from its RCU read-side critical section.
149 */ 160 */
150static int rcu_preempt_running_reader(void) 161static int rcu_preempt_running_reader(void)
151{ 162{
@@ -307,7 +318,6 @@ static int rcu_boost(void)
307 t = container_of(tb, struct task_struct, rcu_node_entry); 318 t = container_of(tb, struct task_struct, rcu_node_entry);
308 rt_mutex_init_proxy_locked(&mtx, t); 319 rt_mutex_init_proxy_locked(&mtx, t);
309 t->rcu_boost_mutex = &mtx; 320 t->rcu_boost_mutex = &mtx;
310 t->rcu_read_unlock_special |= RCU_READ_UNLOCK_BOOSTED;
311 raw_local_irq_restore(flags); 321 raw_local_irq_restore(flags);
312 rt_mutex_lock(&mtx); 322 rt_mutex_lock(&mtx);
313 rt_mutex_unlock(&mtx); /* Keep lockdep happy. */ 323 rt_mutex_unlock(&mtx); /* Keep lockdep happy. */
@@ -475,7 +485,7 @@ void rcu_preempt_note_context_switch(void)
475 unsigned long flags; 485 unsigned long flags;
476 486
477 local_irq_save(flags); /* must exclude scheduler_tick(). */ 487 local_irq_save(flags); /* must exclude scheduler_tick(). */
478 if (rcu_preempt_running_reader() && 488 if (rcu_preempt_running_reader() > 0 &&
479 (t->rcu_read_unlock_special & RCU_READ_UNLOCK_BLOCKED) == 0) { 489 (t->rcu_read_unlock_special & RCU_READ_UNLOCK_BLOCKED) == 0) {
480 490
481 /* Possibly blocking in an RCU read-side critical section. */ 491 /* Possibly blocking in an RCU read-side critical section. */
@@ -494,6 +504,13 @@ void rcu_preempt_note_context_switch(void)
494 list_add(&t->rcu_node_entry, &rcu_preempt_ctrlblk.blkd_tasks); 504 list_add(&t->rcu_node_entry, &rcu_preempt_ctrlblk.blkd_tasks);
495 if (rcu_cpu_blocking_cur_gp()) 505 if (rcu_cpu_blocking_cur_gp())
496 rcu_preempt_ctrlblk.gp_tasks = &t->rcu_node_entry; 506 rcu_preempt_ctrlblk.gp_tasks = &t->rcu_node_entry;
507 } else if (rcu_preempt_running_reader() < 0 &&
508 t->rcu_read_unlock_special) {
509 /*
510 * Complete exit from RCU read-side critical section on
511 * behalf of preempted instance of __rcu_read_unlock().
512 */
513 rcu_read_unlock_special(t);
497 } 514 }
498 515
499 /* 516 /*
@@ -526,12 +543,15 @@ EXPORT_SYMBOL_GPL(__rcu_read_lock);
526 * notify RCU core processing or task having blocked during the RCU 543 * notify RCU core processing or task having blocked during the RCU
527 * read-side critical section. 544 * read-side critical section.
528 */ 545 */
529static void rcu_read_unlock_special(struct task_struct *t) 546static noinline void rcu_read_unlock_special(struct task_struct *t)
530{ 547{
531 int empty; 548 int empty;
532 int empty_exp; 549 int empty_exp;
533 unsigned long flags; 550 unsigned long flags;
534 struct list_head *np; 551 struct list_head *np;
552#ifdef CONFIG_RCU_BOOST
553 struct rt_mutex *rbmp = NULL;
554#endif /* #ifdef CONFIG_RCU_BOOST */
535 int special; 555 int special;
536 556
537 /* 557 /*
@@ -552,7 +572,7 @@ static void rcu_read_unlock_special(struct task_struct *t)
552 rcu_preempt_cpu_qs(); 572 rcu_preempt_cpu_qs();
553 573
554 /* Hardware IRQ handlers cannot block. */ 574 /* Hardware IRQ handlers cannot block. */
555 if (in_irq()) { 575 if (in_irq() || in_serving_softirq()) {
556 local_irq_restore(flags); 576 local_irq_restore(flags);
557 return; 577 return;
558 } 578 }
@@ -597,10 +617,10 @@ static void rcu_read_unlock_special(struct task_struct *t)
597 } 617 }
598#ifdef CONFIG_RCU_BOOST 618#ifdef CONFIG_RCU_BOOST
599 /* Unboost self if was boosted. */ 619 /* Unboost self if was boosted. */
600 if (special & RCU_READ_UNLOCK_BOOSTED) { 620 if (t->rcu_boost_mutex != NULL) {
601 t->rcu_read_unlock_special &= ~RCU_READ_UNLOCK_BOOSTED; 621 rbmp = t->rcu_boost_mutex;
602 rt_mutex_unlock(t->rcu_boost_mutex);
603 t->rcu_boost_mutex = NULL; 622 t->rcu_boost_mutex = NULL;
623 rt_mutex_unlock(rbmp);
604 } 624 }
605#endif /* #ifdef CONFIG_RCU_BOOST */ 625#endif /* #ifdef CONFIG_RCU_BOOST */
606 local_irq_restore(flags); 626 local_irq_restore(flags);
@@ -618,13 +638,22 @@ void __rcu_read_unlock(void)
618 struct task_struct *t = current; 638 struct task_struct *t = current;
619 639
620 barrier(); /* needed if we ever invoke rcu_read_unlock in rcutiny.c */ 640 barrier(); /* needed if we ever invoke rcu_read_unlock in rcutiny.c */
621 --t->rcu_read_lock_nesting; 641 if (t->rcu_read_lock_nesting != 1)
622 barrier(); /* decrement before load of ->rcu_read_unlock_special */ 642 --t->rcu_read_lock_nesting;
623 if (t->rcu_read_lock_nesting == 0 && 643 else {
624 unlikely(ACCESS_ONCE(t->rcu_read_unlock_special))) 644 t->rcu_read_lock_nesting = INT_MIN;
625 rcu_read_unlock_special(t); 645 barrier(); /* assign before ->rcu_read_unlock_special load */
646 if (unlikely(ACCESS_ONCE(t->rcu_read_unlock_special)))
647 rcu_read_unlock_special(t);
648 barrier(); /* ->rcu_read_unlock_special load before assign */
649 t->rcu_read_lock_nesting = 0;
650 }
626#ifdef CONFIG_PROVE_LOCKING 651#ifdef CONFIG_PROVE_LOCKING
627 WARN_ON_ONCE(t->rcu_read_lock_nesting < 0); 652 {
653 int rrln = ACCESS_ONCE(t->rcu_read_lock_nesting);
654
655 WARN_ON_ONCE(rrln < 0 && rrln > INT_MIN / 2);
656 }
628#endif /* #ifdef CONFIG_PROVE_LOCKING */ 657#endif /* #ifdef CONFIG_PROVE_LOCKING */
629} 658}
630EXPORT_SYMBOL_GPL(__rcu_read_unlock); 659EXPORT_SYMBOL_GPL(__rcu_read_unlock);
@@ -649,7 +678,7 @@ static void rcu_preempt_check_callbacks(void)
649 invoke_rcu_callbacks(); 678 invoke_rcu_callbacks();
650 if (rcu_preempt_gp_in_progress() && 679 if (rcu_preempt_gp_in_progress() &&
651 rcu_cpu_blocking_cur_gp() && 680 rcu_cpu_blocking_cur_gp() &&
652 rcu_preempt_running_reader()) 681 rcu_preempt_running_reader() > 0)
653 t->rcu_read_unlock_special |= RCU_READ_UNLOCK_NEED_QS; 682 t->rcu_read_unlock_special |= RCU_READ_UNLOCK_NEED_QS;
654} 683}
655 684
@@ -706,6 +735,11 @@ EXPORT_SYMBOL_GPL(call_rcu);
706 */ 735 */
707void synchronize_rcu(void) 736void synchronize_rcu(void)
708{ 737{
738 rcu_lockdep_assert(!lock_is_held(&rcu_bh_lock_map) &&
739 !lock_is_held(&rcu_lock_map) &&
740 !lock_is_held(&rcu_sched_lock_map),
741 "Illegal synchronize_rcu() in RCU read-side critical section");
742
709#ifdef CONFIG_DEBUG_LOCK_ALLOC 743#ifdef CONFIG_DEBUG_LOCK_ALLOC
710 if (!rcu_scheduler_active) 744 if (!rcu_scheduler_active)
711 return; 745 return;
@@ -882,7 +916,8 @@ static void rcu_preempt_process_callbacks(void)
882static void invoke_rcu_callbacks(void) 916static void invoke_rcu_callbacks(void)
883{ 917{
884 have_rcu_kthread_work = 1; 918 have_rcu_kthread_work = 1;
885 wake_up(&rcu_kthread_wq); 919 if (rcu_kthread_task != NULL)
920 wake_up(&rcu_kthread_wq);
886} 921}
887 922
888#ifdef CONFIG_RCU_TRACE 923#ifdef CONFIG_RCU_TRACE
@@ -943,12 +978,16 @@ early_initcall(rcu_spawn_kthreads);
943 978
944#else /* #ifdef CONFIG_RCU_BOOST */ 979#else /* #ifdef CONFIG_RCU_BOOST */
945 980
981/* Hold off callback invocation until early_initcall() time. */
982static int rcu_scheduler_fully_active __read_mostly;
983
946/* 984/*
947 * Start up softirq processing of callbacks. 985 * Start up softirq processing of callbacks.
948 */ 986 */
949void invoke_rcu_callbacks(void) 987void invoke_rcu_callbacks(void)
950{ 988{
951 raise_softirq(RCU_SOFTIRQ); 989 if (rcu_scheduler_fully_active)
990 raise_softirq(RCU_SOFTIRQ);
952} 991}
953 992
954#ifdef CONFIG_RCU_TRACE 993#ifdef CONFIG_RCU_TRACE
@@ -963,10 +1002,14 @@ static bool rcu_is_callbacks_kthread(void)
963 1002
964#endif /* #ifdef CONFIG_RCU_TRACE */ 1003#endif /* #ifdef CONFIG_RCU_TRACE */
965 1004
966void rcu_init(void) 1005static int __init rcu_scheduler_really_started(void)
967{ 1006{
1007 rcu_scheduler_fully_active = 1;
968 open_softirq(RCU_SOFTIRQ, rcu_process_callbacks); 1008 open_softirq(RCU_SOFTIRQ, rcu_process_callbacks);
1009 raise_softirq(RCU_SOFTIRQ); /* Invoke any callbacks from early boot. */
1010 return 0;
969} 1011}
1012early_initcall(rcu_scheduler_really_started);
970 1013
971#endif /* #else #ifdef CONFIG_RCU_BOOST */ 1014#endif /* #else #ifdef CONFIG_RCU_BOOST */
972 1015
diff --git a/kernel/rcutorture.c b/kernel/rcutorture.c
index a58ac285fc69..a89b381a8c6e 100644
--- a/kernel/rcutorture.c
+++ b/kernel/rcutorture.c
@@ -65,7 +65,10 @@ static int fqs_duration; /* Duration of bursts (us), 0 to disable. */
65static int fqs_holdoff; /* Hold time within burst (us). */ 65static int fqs_holdoff; /* Hold time within burst (us). */
66static int fqs_stutter = 3; /* Wait time between bursts (s). */ 66static int fqs_stutter = 3; /* Wait time between bursts (s). */
67static int onoff_interval; /* Wait time between CPU hotplugs, 0=disable. */ 67static int onoff_interval; /* Wait time between CPU hotplugs, 0=disable. */
68static int onoff_holdoff; /* Seconds after boot before CPU hotplugs. */
68static int shutdown_secs; /* Shutdown time (s). <=0 for no shutdown. */ 69static int shutdown_secs; /* Shutdown time (s). <=0 for no shutdown. */
70static int stall_cpu; /* CPU-stall duration (s). 0 for no stall. */
71static int stall_cpu_holdoff = 10; /* Time to wait until stall (s). */
69static int test_boost = 1; /* Test RCU prio boost: 0=no, 1=maybe, 2=yes. */ 72static int test_boost = 1; /* Test RCU prio boost: 0=no, 1=maybe, 2=yes. */
70static int test_boost_interval = 7; /* Interval between boost tests, seconds. */ 73static int test_boost_interval = 7; /* Interval between boost tests, seconds. */
71static int test_boost_duration = 4; /* Duration of each boost test, seconds. */ 74static int test_boost_duration = 4; /* Duration of each boost test, seconds. */
@@ -95,8 +98,14 @@ module_param(fqs_stutter, int, 0444);
95MODULE_PARM_DESC(fqs_stutter, "Wait time between fqs bursts (s)"); 98MODULE_PARM_DESC(fqs_stutter, "Wait time between fqs bursts (s)");
96module_param(onoff_interval, int, 0444); 99module_param(onoff_interval, int, 0444);
97MODULE_PARM_DESC(onoff_interval, "Time between CPU hotplugs (s), 0=disable"); 100MODULE_PARM_DESC(onoff_interval, "Time between CPU hotplugs (s), 0=disable");
101module_param(onoff_holdoff, int, 0444);
102MODULE_PARM_DESC(onoff_holdoff, "Time after boot before CPU hotplugs (s)");
98module_param(shutdown_secs, int, 0444); 103module_param(shutdown_secs, int, 0444);
99MODULE_PARM_DESC(shutdown_secs, "Shutdown time (s), zero to disable."); 104MODULE_PARM_DESC(shutdown_secs, "Shutdown time (s), zero to disable.");
105module_param(stall_cpu, int, 0444);
106MODULE_PARM_DESC(stall_cpu, "Stall duration (s), zero to disable.");
107module_param(stall_cpu_holdoff, int, 0444);
108MODULE_PARM_DESC(stall_cpu_holdoff, "Time to wait before starting stall (s).");
100module_param(test_boost, int, 0444); 109module_param(test_boost, int, 0444);
101MODULE_PARM_DESC(test_boost, "Test RCU prio boost: 0=no, 1=maybe, 2=yes."); 110MODULE_PARM_DESC(test_boost, "Test RCU prio boost: 0=no, 1=maybe, 2=yes.");
102module_param(test_boost_interval, int, 0444); 111module_param(test_boost_interval, int, 0444);
@@ -129,6 +138,7 @@ static struct task_struct *shutdown_task;
129#ifdef CONFIG_HOTPLUG_CPU 138#ifdef CONFIG_HOTPLUG_CPU
130static struct task_struct *onoff_task; 139static struct task_struct *onoff_task;
131#endif /* #ifdef CONFIG_HOTPLUG_CPU */ 140#endif /* #ifdef CONFIG_HOTPLUG_CPU */
141static struct task_struct *stall_task;
132 142
133#define RCU_TORTURE_PIPE_LEN 10 143#define RCU_TORTURE_PIPE_LEN 10
134 144
@@ -990,12 +1000,12 @@ static void rcu_torture_timer(unsigned long unused)
990 rcu_read_lock_bh_held() || 1000 rcu_read_lock_bh_held() ||
991 rcu_read_lock_sched_held() || 1001 rcu_read_lock_sched_held() ||
992 srcu_read_lock_held(&srcu_ctl)); 1002 srcu_read_lock_held(&srcu_ctl));
993 do_trace_rcu_torture_read(cur_ops->name, &p->rtort_rcu);
994 if (p == NULL) { 1003 if (p == NULL) {
995 /* Leave because rcu_torture_writer is not yet underway */ 1004 /* Leave because rcu_torture_writer is not yet underway */
996 cur_ops->readunlock(idx); 1005 cur_ops->readunlock(idx);
997 return; 1006 return;
998 } 1007 }
1008 do_trace_rcu_torture_read(cur_ops->name, &p->rtort_rcu);
999 if (p->rtort_mbtest == 0) 1009 if (p->rtort_mbtest == 0)
1000 atomic_inc(&n_rcu_torture_mberror); 1010 atomic_inc(&n_rcu_torture_mberror);
1001 spin_lock(&rand_lock); 1011 spin_lock(&rand_lock);
@@ -1053,13 +1063,13 @@ rcu_torture_reader(void *arg)
1053 rcu_read_lock_bh_held() || 1063 rcu_read_lock_bh_held() ||
1054 rcu_read_lock_sched_held() || 1064 rcu_read_lock_sched_held() ||
1055 srcu_read_lock_held(&srcu_ctl)); 1065 srcu_read_lock_held(&srcu_ctl));
1056 do_trace_rcu_torture_read(cur_ops->name, &p->rtort_rcu);
1057 if (p == NULL) { 1066 if (p == NULL) {
1058 /* Wait for rcu_torture_writer to get underway */ 1067 /* Wait for rcu_torture_writer to get underway */
1059 cur_ops->readunlock(idx); 1068 cur_ops->readunlock(idx);
1060 schedule_timeout_interruptible(HZ); 1069 schedule_timeout_interruptible(HZ);
1061 continue; 1070 continue;
1062 } 1071 }
1072 do_trace_rcu_torture_read(cur_ops->name, &p->rtort_rcu);
1063 if (p->rtort_mbtest == 0) 1073 if (p->rtort_mbtest == 0)
1064 atomic_inc(&n_rcu_torture_mberror); 1074 atomic_inc(&n_rcu_torture_mberror);
1065 cur_ops->read_delay(&rand); 1075 cur_ops->read_delay(&rand);
@@ -1300,13 +1310,13 @@ rcu_torture_print_module_parms(struct rcu_torture_ops *cur_ops, char *tag)
1300 "fqs_duration=%d fqs_holdoff=%d fqs_stutter=%d " 1310 "fqs_duration=%d fqs_holdoff=%d fqs_stutter=%d "
1301 "test_boost=%d/%d test_boost_interval=%d " 1311 "test_boost=%d/%d test_boost_interval=%d "
1302 "test_boost_duration=%d shutdown_secs=%d " 1312 "test_boost_duration=%d shutdown_secs=%d "
1303 "onoff_interval=%d\n", 1313 "onoff_interval=%d onoff_holdoff=%d\n",
1304 torture_type, tag, nrealreaders, nfakewriters, 1314 torture_type, tag, nrealreaders, nfakewriters,
1305 stat_interval, verbose, test_no_idle_hz, shuffle_interval, 1315 stat_interval, verbose, test_no_idle_hz, shuffle_interval,
1306 stutter, irqreader, fqs_duration, fqs_holdoff, fqs_stutter, 1316 stutter, irqreader, fqs_duration, fqs_holdoff, fqs_stutter,
1307 test_boost, cur_ops->can_boost, 1317 test_boost, cur_ops->can_boost,
1308 test_boost_interval, test_boost_duration, shutdown_secs, 1318 test_boost_interval, test_boost_duration, shutdown_secs,
1309 onoff_interval); 1319 onoff_interval, onoff_holdoff);
1310} 1320}
1311 1321
1312static struct notifier_block rcutorture_shutdown_nb = { 1322static struct notifier_block rcutorture_shutdown_nb = {
@@ -1410,6 +1420,11 @@ rcu_torture_onoff(void *arg)
1410 for_each_online_cpu(cpu) 1420 for_each_online_cpu(cpu)
1411 maxcpu = cpu; 1421 maxcpu = cpu;
1412 WARN_ON(maxcpu < 0); 1422 WARN_ON(maxcpu < 0);
1423 if (onoff_holdoff > 0) {
1424 VERBOSE_PRINTK_STRING("rcu_torture_onoff begin holdoff");
1425 schedule_timeout_interruptible(onoff_holdoff * HZ);
1426 VERBOSE_PRINTK_STRING("rcu_torture_onoff end holdoff");
1427 }
1413 while (!kthread_should_stop()) { 1428 while (!kthread_should_stop()) {
1414 cpu = (rcu_random(&rand) >> 4) % (maxcpu + 1); 1429 cpu = (rcu_random(&rand) >> 4) % (maxcpu + 1);
1415 if (cpu_online(cpu) && cpu_is_hotpluggable(cpu)) { 1430 if (cpu_online(cpu) && cpu_is_hotpluggable(cpu)) {
@@ -1450,12 +1465,15 @@ rcu_torture_onoff(void *arg)
1450static int __cpuinit 1465static int __cpuinit
1451rcu_torture_onoff_init(void) 1466rcu_torture_onoff_init(void)
1452{ 1467{
1468 int ret;
1469
1453 if (onoff_interval <= 0) 1470 if (onoff_interval <= 0)
1454 return 0; 1471 return 0;
1455 onoff_task = kthread_run(rcu_torture_onoff, NULL, "rcu_torture_onoff"); 1472 onoff_task = kthread_run(rcu_torture_onoff, NULL, "rcu_torture_onoff");
1456 if (IS_ERR(onoff_task)) { 1473 if (IS_ERR(onoff_task)) {
1474 ret = PTR_ERR(onoff_task);
1457 onoff_task = NULL; 1475 onoff_task = NULL;
1458 return PTR_ERR(onoff_task); 1476 return ret;
1459 } 1477 }
1460 return 0; 1478 return 0;
1461} 1479}
@@ -1481,6 +1499,63 @@ static void rcu_torture_onoff_cleanup(void)
1481 1499
1482#endif /* #else #ifdef CONFIG_HOTPLUG_CPU */ 1500#endif /* #else #ifdef CONFIG_HOTPLUG_CPU */
1483 1501
1502/*
1503 * CPU-stall kthread. It waits as specified by stall_cpu_holdoff, then
1504 * induces a CPU stall for the time specified by stall_cpu.
1505 */
1506static int __cpuinit rcu_torture_stall(void *args)
1507{
1508 unsigned long stop_at;
1509
1510 VERBOSE_PRINTK_STRING("rcu_torture_stall task started");
1511 if (stall_cpu_holdoff > 0) {
1512 VERBOSE_PRINTK_STRING("rcu_torture_stall begin holdoff");
1513 schedule_timeout_interruptible(stall_cpu_holdoff * HZ);
1514 VERBOSE_PRINTK_STRING("rcu_torture_stall end holdoff");
1515 }
1516 if (!kthread_should_stop()) {
1517 stop_at = get_seconds() + stall_cpu;
1518 /* RCU CPU stall is expected behavior in following code. */
1519 printk(KERN_ALERT "rcu_torture_stall start.\n");
1520 rcu_read_lock();
1521 preempt_disable();
1522 while (ULONG_CMP_LT(get_seconds(), stop_at))
1523 continue; /* Induce RCU CPU stall warning. */
1524 preempt_enable();
1525 rcu_read_unlock();
1526 printk(KERN_ALERT "rcu_torture_stall end.\n");
1527 }
1528 rcutorture_shutdown_absorb("rcu_torture_stall");
1529 while (!kthread_should_stop())
1530 schedule_timeout_interruptible(10 * HZ);
1531 return 0;
1532}
1533
1534/* Spawn CPU-stall kthread, if stall_cpu specified. */
1535static int __init rcu_torture_stall_init(void)
1536{
1537 int ret;
1538
1539 if (stall_cpu <= 0)
1540 return 0;
1541 stall_task = kthread_run(rcu_torture_stall, NULL, "rcu_torture_stall");
1542 if (IS_ERR(stall_task)) {
1543 ret = PTR_ERR(stall_task);
1544 stall_task = NULL;
1545 return ret;
1546 }
1547 return 0;
1548}
1549
1550/* Clean up after the CPU-stall kthread, if one was spawned. */
1551static void rcu_torture_stall_cleanup(void)
1552{
1553 if (stall_task == NULL)
1554 return;
1555 VERBOSE_PRINTK_STRING("Stopping rcu_torture_stall_task.");
1556 kthread_stop(stall_task);
1557}
1558
1484static int rcutorture_cpu_notify(struct notifier_block *self, 1559static int rcutorture_cpu_notify(struct notifier_block *self,
1485 unsigned long action, void *hcpu) 1560 unsigned long action, void *hcpu)
1486{ 1561{
@@ -1523,6 +1598,7 @@ rcu_torture_cleanup(void)
1523 fullstop = FULLSTOP_RMMOD; 1598 fullstop = FULLSTOP_RMMOD;
1524 mutex_unlock(&fullstop_mutex); 1599 mutex_unlock(&fullstop_mutex);
1525 unregister_reboot_notifier(&rcutorture_shutdown_nb); 1600 unregister_reboot_notifier(&rcutorture_shutdown_nb);
1601 rcu_torture_stall_cleanup();
1526 if (stutter_task) { 1602 if (stutter_task) {
1527 VERBOSE_PRINTK_STRING("Stopping rcu_torture_stutter task"); 1603 VERBOSE_PRINTK_STRING("Stopping rcu_torture_stutter task");
1528 kthread_stop(stutter_task); 1604 kthread_stop(stutter_task);
@@ -1602,6 +1678,10 @@ rcu_torture_cleanup(void)
1602 cur_ops->cleanup(); 1678 cur_ops->cleanup();
1603 if (atomic_read(&n_rcu_torture_error)) 1679 if (atomic_read(&n_rcu_torture_error))
1604 rcu_torture_print_module_parms(cur_ops, "End of test: FAILURE"); 1680 rcu_torture_print_module_parms(cur_ops, "End of test: FAILURE");
1681 else if (n_online_successes != n_online_attempts ||
1682 n_offline_successes != n_offline_attempts)
1683 rcu_torture_print_module_parms(cur_ops,
1684 "End of test: RCU_HOTPLUG");
1605 else 1685 else
1606 rcu_torture_print_module_parms(cur_ops, "End of test: SUCCESS"); 1686 rcu_torture_print_module_parms(cur_ops, "End of test: SUCCESS");
1607} 1687}
@@ -1819,6 +1899,7 @@ rcu_torture_init(void)
1819 } 1899 }
1820 rcu_torture_onoff_init(); 1900 rcu_torture_onoff_init();
1821 register_reboot_notifier(&rcutorture_shutdown_nb); 1901 register_reboot_notifier(&rcutorture_shutdown_nb);
1902 rcu_torture_stall_init();
1822 rcutorture_record_test_transition(); 1903 rcutorture_record_test_transition();
1823 mutex_unlock(&fullstop_mutex); 1904 mutex_unlock(&fullstop_mutex);
1824 return 0; 1905 return 0;
diff --git a/kernel/rcutree.c b/kernel/rcutree.c
index 6c4a6722abfd..1050d6d3922c 100644
--- a/kernel/rcutree.c
+++ b/kernel/rcutree.c
@@ -50,6 +50,8 @@
50#include <linux/wait.h> 50#include <linux/wait.h>
51#include <linux/kthread.h> 51#include <linux/kthread.h>
52#include <linux/prefetch.h> 52#include <linux/prefetch.h>
53#include <linux/delay.h>
54#include <linux/stop_machine.h>
53 55
54#include "rcutree.h" 56#include "rcutree.h"
55#include <trace/events/rcu.h> 57#include <trace/events/rcu.h>
@@ -196,7 +198,7 @@ void rcu_note_context_switch(int cpu)
196EXPORT_SYMBOL_GPL(rcu_note_context_switch); 198EXPORT_SYMBOL_GPL(rcu_note_context_switch);
197 199
198DEFINE_PER_CPU(struct rcu_dynticks, rcu_dynticks) = { 200DEFINE_PER_CPU(struct rcu_dynticks, rcu_dynticks) = {
199 .dynticks_nesting = DYNTICK_TASK_NESTING, 201 .dynticks_nesting = DYNTICK_TASK_EXIT_IDLE,
200 .dynticks = ATOMIC_INIT(1), 202 .dynticks = ATOMIC_INIT(1),
201}; 203};
202 204
@@ -208,8 +210,11 @@ module_param(blimit, int, 0);
208module_param(qhimark, int, 0); 210module_param(qhimark, int, 0);
209module_param(qlowmark, int, 0); 211module_param(qlowmark, int, 0);
210 212
211int rcu_cpu_stall_suppress __read_mostly; 213int rcu_cpu_stall_suppress __read_mostly; /* 1 = suppress stall warnings. */
214int rcu_cpu_stall_timeout __read_mostly = CONFIG_RCU_CPU_STALL_TIMEOUT;
215
212module_param(rcu_cpu_stall_suppress, int, 0644); 216module_param(rcu_cpu_stall_suppress, int, 0644);
217module_param(rcu_cpu_stall_timeout, int, 0644);
213 218
214static void force_quiescent_state(struct rcu_state *rsp, int relaxed); 219static void force_quiescent_state(struct rcu_state *rsp, int relaxed);
215static int rcu_pending(int cpu); 220static int rcu_pending(int cpu);
@@ -301,8 +306,6 @@ static struct rcu_node *rcu_get_root(struct rcu_state *rsp)
301 return &rsp->node[0]; 306 return &rsp->node[0];
302} 307}
303 308
304#ifdef CONFIG_SMP
305
306/* 309/*
307 * If the specified CPU is offline, tell the caller that it is in 310 * If the specified CPU is offline, tell the caller that it is in
308 * a quiescent state. Otherwise, whack it with a reschedule IPI. 311 * a quiescent state. Otherwise, whack it with a reschedule IPI.
@@ -317,30 +320,21 @@ static struct rcu_node *rcu_get_root(struct rcu_state *rsp)
317static int rcu_implicit_offline_qs(struct rcu_data *rdp) 320static int rcu_implicit_offline_qs(struct rcu_data *rdp)
318{ 321{
319 /* 322 /*
320 * If the CPU is offline, it is in a quiescent state. We can 323 * If the CPU is offline for more than a jiffy, it is in a quiescent
321 * trust its state not to change because interrupts are disabled. 324 * state. We can trust its state not to change because interrupts
325 * are disabled. The reason for the jiffy's worth of slack is to
326 * handle CPUs initializing on the way up and finding their way
327 * to the idle loop on the way down.
322 */ 328 */
323 if (cpu_is_offline(rdp->cpu)) { 329 if (cpu_is_offline(rdp->cpu) &&
330 ULONG_CMP_LT(rdp->rsp->gp_start + 2, jiffies)) {
324 trace_rcu_fqs(rdp->rsp->name, rdp->gpnum, rdp->cpu, "ofl"); 331 trace_rcu_fqs(rdp->rsp->name, rdp->gpnum, rdp->cpu, "ofl");
325 rdp->offline_fqs++; 332 rdp->offline_fqs++;
326 return 1; 333 return 1;
327 } 334 }
328
329 /*
330 * The CPU is online, so send it a reschedule IPI. This forces
331 * it through the scheduler, and (inefficiently) also handles cases
332 * where idle loops fail to inform RCU about the CPU being idle.
333 */
334 if (rdp->cpu != smp_processor_id())
335 smp_send_reschedule(rdp->cpu);
336 else
337 set_need_resched();
338 rdp->resched_ipi++;
339 return 0; 335 return 0;
340} 336}
341 337
342#endif /* #ifdef CONFIG_SMP */
343
344/* 338/*
345 * rcu_idle_enter_common - inform RCU that current CPU is moving towards idle 339 * rcu_idle_enter_common - inform RCU that current CPU is moving towards idle
346 * 340 *
@@ -366,6 +360,17 @@ static void rcu_idle_enter_common(struct rcu_dynticks *rdtp, long long oldval)
366 atomic_inc(&rdtp->dynticks); 360 atomic_inc(&rdtp->dynticks);
367 smp_mb__after_atomic_inc(); /* Force ordering with next sojourn. */ 361 smp_mb__after_atomic_inc(); /* Force ordering with next sojourn. */
368 WARN_ON_ONCE(atomic_read(&rdtp->dynticks) & 0x1); 362 WARN_ON_ONCE(atomic_read(&rdtp->dynticks) & 0x1);
363
364 /*
365 * The idle task is not permitted to enter the idle loop while
366 * in an RCU read-side critical section.
367 */
368 rcu_lockdep_assert(!lock_is_held(&rcu_lock_map),
369 "Illegal idle entry in RCU read-side critical section.");
370 rcu_lockdep_assert(!lock_is_held(&rcu_bh_lock_map),
371 "Illegal idle entry in RCU-bh read-side critical section.");
372 rcu_lockdep_assert(!lock_is_held(&rcu_sched_lock_map),
373 "Illegal idle entry in RCU-sched read-side critical section.");
369} 374}
370 375
371/** 376/**
@@ -389,10 +394,15 @@ void rcu_idle_enter(void)
389 local_irq_save(flags); 394 local_irq_save(flags);
390 rdtp = &__get_cpu_var(rcu_dynticks); 395 rdtp = &__get_cpu_var(rcu_dynticks);
391 oldval = rdtp->dynticks_nesting; 396 oldval = rdtp->dynticks_nesting;
392 rdtp->dynticks_nesting = 0; 397 WARN_ON_ONCE((oldval & DYNTICK_TASK_NEST_MASK) == 0);
398 if ((oldval & DYNTICK_TASK_NEST_MASK) == DYNTICK_TASK_NEST_VALUE)
399 rdtp->dynticks_nesting = 0;
400 else
401 rdtp->dynticks_nesting -= DYNTICK_TASK_NEST_VALUE;
393 rcu_idle_enter_common(rdtp, oldval); 402 rcu_idle_enter_common(rdtp, oldval);
394 local_irq_restore(flags); 403 local_irq_restore(flags);
395} 404}
405EXPORT_SYMBOL_GPL(rcu_idle_enter);
396 406
397/** 407/**
398 * rcu_irq_exit - inform RCU that current CPU is exiting irq towards idle 408 * rcu_irq_exit - inform RCU that current CPU is exiting irq towards idle
@@ -462,7 +472,7 @@ static void rcu_idle_exit_common(struct rcu_dynticks *rdtp, long long oldval)
462 * Exit idle mode, in other words, -enter- the mode in which RCU 472 * Exit idle mode, in other words, -enter- the mode in which RCU
463 * read-side critical sections can occur. 473 * read-side critical sections can occur.
464 * 474 *
465 * We crowbar the ->dynticks_nesting field to DYNTICK_TASK_NESTING to 475 * We crowbar the ->dynticks_nesting field to DYNTICK_TASK_NEST to
466 * allow for the possibility of usermode upcalls messing up our count 476 * allow for the possibility of usermode upcalls messing up our count
467 * of interrupt nesting level during the busy period that is just 477 * of interrupt nesting level during the busy period that is just
468 * now starting. 478 * now starting.
@@ -476,11 +486,15 @@ void rcu_idle_exit(void)
476 local_irq_save(flags); 486 local_irq_save(flags);
477 rdtp = &__get_cpu_var(rcu_dynticks); 487 rdtp = &__get_cpu_var(rcu_dynticks);
478 oldval = rdtp->dynticks_nesting; 488 oldval = rdtp->dynticks_nesting;
479 WARN_ON_ONCE(oldval != 0); 489 WARN_ON_ONCE(oldval < 0);
480 rdtp->dynticks_nesting = DYNTICK_TASK_NESTING; 490 if (oldval & DYNTICK_TASK_NEST_MASK)
491 rdtp->dynticks_nesting += DYNTICK_TASK_NEST_VALUE;
492 else
493 rdtp->dynticks_nesting = DYNTICK_TASK_EXIT_IDLE;
481 rcu_idle_exit_common(rdtp, oldval); 494 rcu_idle_exit_common(rdtp, oldval);
482 local_irq_restore(flags); 495 local_irq_restore(flags);
483} 496}
497EXPORT_SYMBOL_GPL(rcu_idle_exit);
484 498
485/** 499/**
486 * rcu_irq_enter - inform RCU that current CPU is entering irq away from idle 500 * rcu_irq_enter - inform RCU that current CPU is entering irq away from idle
@@ -581,6 +595,49 @@ int rcu_is_cpu_idle(void)
581} 595}
582EXPORT_SYMBOL(rcu_is_cpu_idle); 596EXPORT_SYMBOL(rcu_is_cpu_idle);
583 597
598#ifdef CONFIG_HOTPLUG_CPU
599
600/*
601 * Is the current CPU online? Disable preemption to avoid false positives
602 * that could otherwise happen due to the current CPU number being sampled,
603 * this task being preempted, its old CPU being taken offline, resuming
604 * on some other CPU, then determining that its old CPU is now offline.
605 * It is OK to use RCU on an offline processor during initial boot, hence
606 * the check for rcu_scheduler_fully_active. Note also that it is OK
607 * for a CPU coming online to use RCU for one jiffy prior to marking itself
608 * online in the cpu_online_mask. Similarly, it is OK for a CPU going
609 * offline to continue to use RCU for one jiffy after marking itself
610 * offline in the cpu_online_mask. This leniency is necessary given the
611 * non-atomic nature of the online and offline processing, for example,
612 * the fact that a CPU enters the scheduler after completing the CPU_DYING
613 * notifiers.
614 *
615 * This is also why RCU internally marks CPUs online during the
616 * CPU_UP_PREPARE phase and offline during the CPU_DEAD phase.
617 *
618 * Disable checking if in an NMI handler because we cannot safely report
619 * errors from NMI handlers anyway.
620 */
621bool rcu_lockdep_current_cpu_online(void)
622{
623 struct rcu_data *rdp;
624 struct rcu_node *rnp;
625 bool ret;
626
627 if (in_nmi())
628 return 1;
629 preempt_disable();
630 rdp = &__get_cpu_var(rcu_sched_data);
631 rnp = rdp->mynode;
632 ret = (rdp->grpmask & rnp->qsmaskinit) ||
633 !rcu_scheduler_fully_active;
634 preempt_enable();
635 return ret;
636}
637EXPORT_SYMBOL_GPL(rcu_lockdep_current_cpu_online);
638
639#endif /* #ifdef CONFIG_HOTPLUG_CPU */
640
584#endif /* #ifdef CONFIG_PROVE_RCU */ 641#endif /* #ifdef CONFIG_PROVE_RCU */
585 642
586/** 643/**
@@ -595,8 +652,6 @@ int rcu_is_cpu_rrupt_from_idle(void)
595 return __get_cpu_var(rcu_dynticks).dynticks_nesting <= 1; 652 return __get_cpu_var(rcu_dynticks).dynticks_nesting <= 1;
596} 653}
597 654
598#ifdef CONFIG_SMP
599
600/* 655/*
601 * Snapshot the specified CPU's dynticks counter so that we can later 656 * Snapshot the specified CPU's dynticks counter so that we can later
602 * credit them with an implicit quiescent state. Return 1 if this CPU 657 * credit them with an implicit quiescent state. Return 1 if this CPU
@@ -640,12 +695,28 @@ static int rcu_implicit_dynticks_qs(struct rcu_data *rdp)
640 return rcu_implicit_offline_qs(rdp); 695 return rcu_implicit_offline_qs(rdp);
641} 696}
642 697
643#endif /* #ifdef CONFIG_SMP */ 698static int jiffies_till_stall_check(void)
699{
700 int till_stall_check = ACCESS_ONCE(rcu_cpu_stall_timeout);
701
702 /*
703 * Limit check must be consistent with the Kconfig limits
704 * for CONFIG_RCU_CPU_STALL_TIMEOUT.
705 */
706 if (till_stall_check < 3) {
707 ACCESS_ONCE(rcu_cpu_stall_timeout) = 3;
708 till_stall_check = 3;
709 } else if (till_stall_check > 300) {
710 ACCESS_ONCE(rcu_cpu_stall_timeout) = 300;
711 till_stall_check = 300;
712 }
713 return till_stall_check * HZ + RCU_STALL_DELAY_DELTA;
714}
644 715
645static void record_gp_stall_check_time(struct rcu_state *rsp) 716static void record_gp_stall_check_time(struct rcu_state *rsp)
646{ 717{
647 rsp->gp_start = jiffies; 718 rsp->gp_start = jiffies;
648 rsp->jiffies_stall = jiffies + RCU_SECONDS_TILL_STALL_CHECK; 719 rsp->jiffies_stall = jiffies + jiffies_till_stall_check();
649} 720}
650 721
651static void print_other_cpu_stall(struct rcu_state *rsp) 722static void print_other_cpu_stall(struct rcu_state *rsp)
@@ -664,13 +735,7 @@ static void print_other_cpu_stall(struct rcu_state *rsp)
664 raw_spin_unlock_irqrestore(&rnp->lock, flags); 735 raw_spin_unlock_irqrestore(&rnp->lock, flags);
665 return; 736 return;
666 } 737 }
667 rsp->jiffies_stall = jiffies + RCU_SECONDS_TILL_STALL_RECHECK; 738 rsp->jiffies_stall = jiffies + 3 * jiffies_till_stall_check() + 3;
668
669 /*
670 * Now rat on any tasks that got kicked up to the root rcu_node
671 * due to CPU offlining.
672 */
673 ndetected = rcu_print_task_stall(rnp);
674 raw_spin_unlock_irqrestore(&rnp->lock, flags); 739 raw_spin_unlock_irqrestore(&rnp->lock, flags);
675 740
676 /* 741 /*
@@ -678,8 +743,9 @@ static void print_other_cpu_stall(struct rcu_state *rsp)
678 * See Documentation/RCU/stallwarn.txt for info on how to debug 743 * See Documentation/RCU/stallwarn.txt for info on how to debug
679 * RCU CPU stall warnings. 744 * RCU CPU stall warnings.
680 */ 745 */
681 printk(KERN_ERR "INFO: %s detected stalls on CPUs/tasks: {", 746 printk(KERN_ERR "INFO: %s detected stalls on CPUs/tasks:",
682 rsp->name); 747 rsp->name);
748 print_cpu_stall_info_begin();
683 rcu_for_each_leaf_node(rsp, rnp) { 749 rcu_for_each_leaf_node(rsp, rnp) {
684 raw_spin_lock_irqsave(&rnp->lock, flags); 750 raw_spin_lock_irqsave(&rnp->lock, flags);
685 ndetected += rcu_print_task_stall(rnp); 751 ndetected += rcu_print_task_stall(rnp);
@@ -688,11 +754,22 @@ static void print_other_cpu_stall(struct rcu_state *rsp)
688 continue; 754 continue;
689 for (cpu = 0; cpu <= rnp->grphi - rnp->grplo; cpu++) 755 for (cpu = 0; cpu <= rnp->grphi - rnp->grplo; cpu++)
690 if (rnp->qsmask & (1UL << cpu)) { 756 if (rnp->qsmask & (1UL << cpu)) {
691 printk(" %d", rnp->grplo + cpu); 757 print_cpu_stall_info(rsp, rnp->grplo + cpu);
692 ndetected++; 758 ndetected++;
693 } 759 }
694 } 760 }
695 printk("} (detected by %d, t=%ld jiffies)\n", 761
762 /*
763 * Now rat on any tasks that got kicked up to the root rcu_node
764 * due to CPU offlining.
765 */
766 rnp = rcu_get_root(rsp);
767 raw_spin_lock_irqsave(&rnp->lock, flags);
768 ndetected = rcu_print_task_stall(rnp);
769 raw_spin_unlock_irqrestore(&rnp->lock, flags);
770
771 print_cpu_stall_info_end();
772 printk(KERN_CONT "(detected by %d, t=%ld jiffies)\n",
696 smp_processor_id(), (long)(jiffies - rsp->gp_start)); 773 smp_processor_id(), (long)(jiffies - rsp->gp_start));
697 if (ndetected == 0) 774 if (ndetected == 0)
698 printk(KERN_ERR "INFO: Stall ended before state dump start\n"); 775 printk(KERN_ERR "INFO: Stall ended before state dump start\n");
@@ -716,15 +793,18 @@ static void print_cpu_stall(struct rcu_state *rsp)
716 * See Documentation/RCU/stallwarn.txt for info on how to debug 793 * See Documentation/RCU/stallwarn.txt for info on how to debug
717 * RCU CPU stall warnings. 794 * RCU CPU stall warnings.
718 */ 795 */
719 printk(KERN_ERR "INFO: %s detected stall on CPU %d (t=%lu jiffies)\n", 796 printk(KERN_ERR "INFO: %s self-detected stall on CPU", rsp->name);
720 rsp->name, smp_processor_id(), jiffies - rsp->gp_start); 797 print_cpu_stall_info_begin();
798 print_cpu_stall_info(rsp, smp_processor_id());
799 print_cpu_stall_info_end();
800 printk(KERN_CONT " (t=%lu jiffies)\n", jiffies - rsp->gp_start);
721 if (!trigger_all_cpu_backtrace()) 801 if (!trigger_all_cpu_backtrace())
722 dump_stack(); 802 dump_stack();
723 803
724 raw_spin_lock_irqsave(&rnp->lock, flags); 804 raw_spin_lock_irqsave(&rnp->lock, flags);
725 if (ULONG_CMP_GE(jiffies, rsp->jiffies_stall)) 805 if (ULONG_CMP_GE(jiffies, rsp->jiffies_stall))
726 rsp->jiffies_stall = 806 rsp->jiffies_stall = jiffies +
727 jiffies + RCU_SECONDS_TILL_STALL_RECHECK; 807 3 * jiffies_till_stall_check() + 3;
728 raw_spin_unlock_irqrestore(&rnp->lock, flags); 808 raw_spin_unlock_irqrestore(&rnp->lock, flags);
729 809
730 set_need_resched(); /* kick ourselves to get things going. */ 810 set_need_resched(); /* kick ourselves to get things going. */
@@ -807,6 +887,7 @@ static void __note_new_gpnum(struct rcu_state *rsp, struct rcu_node *rnp, struct
807 rdp->passed_quiesce = 0; 887 rdp->passed_quiesce = 0;
808 } else 888 } else
809 rdp->qs_pending = 0; 889 rdp->qs_pending = 0;
890 zero_cpu_stall_ticks(rdp);
810 } 891 }
811} 892}
812 893
@@ -943,6 +1024,10 @@ rcu_start_gp_per_cpu(struct rcu_state *rsp, struct rcu_node *rnp, struct rcu_dat
943 * in preparation for detecting the next grace period. The caller must hold 1024 * in preparation for detecting the next grace period. The caller must hold
944 * the root node's ->lock, which is released before return. Hard irqs must 1025 * the root node's ->lock, which is released before return. Hard irqs must
945 * be disabled. 1026 * be disabled.
1027 *
1028 * Note that it is legal for a dying CPU (which is marked as offline) to
1029 * invoke this function. This can happen when the dying CPU reports its
1030 * quiescent state.
946 */ 1031 */
947static void 1032static void
948rcu_start_gp(struct rcu_state *rsp, unsigned long flags) 1033rcu_start_gp(struct rcu_state *rsp, unsigned long flags)
@@ -980,26 +1065,8 @@ rcu_start_gp(struct rcu_state *rsp, unsigned long flags)
980 rsp->fqs_state = RCU_GP_INIT; /* Hold off force_quiescent_state. */ 1065 rsp->fqs_state = RCU_GP_INIT; /* Hold off force_quiescent_state. */
981 rsp->jiffies_force_qs = jiffies + RCU_JIFFIES_TILL_FORCE_QS; 1066 rsp->jiffies_force_qs = jiffies + RCU_JIFFIES_TILL_FORCE_QS;
982 record_gp_stall_check_time(rsp); 1067 record_gp_stall_check_time(rsp);
983
984 /* Special-case the common single-level case. */
985 if (NUM_RCU_NODES == 1) {
986 rcu_preempt_check_blocked_tasks(rnp);
987 rnp->qsmask = rnp->qsmaskinit;
988 rnp->gpnum = rsp->gpnum;
989 rnp->completed = rsp->completed;
990 rsp->fqs_state = RCU_SIGNAL_INIT; /* force_quiescent_state OK */
991 rcu_start_gp_per_cpu(rsp, rnp, rdp);
992 rcu_preempt_boost_start_gp(rnp);
993 trace_rcu_grace_period_init(rsp->name, rnp->gpnum,
994 rnp->level, rnp->grplo,
995 rnp->grphi, rnp->qsmask);
996 raw_spin_unlock_irqrestore(&rnp->lock, flags);
997 return;
998 }
999
1000 raw_spin_unlock(&rnp->lock); /* leave irqs disabled. */ 1068 raw_spin_unlock(&rnp->lock); /* leave irqs disabled. */
1001 1069
1002
1003 /* Exclude any concurrent CPU-hotplug operations. */ 1070 /* Exclude any concurrent CPU-hotplug operations. */
1004 raw_spin_lock(&rsp->onofflock); /* irqs already disabled. */ 1071 raw_spin_lock(&rsp->onofflock); /* irqs already disabled. */
1005 1072
@@ -1245,53 +1312,115 @@ rcu_check_quiescent_state(struct rcu_state *rsp, struct rcu_data *rdp)
1245 1312
1246/* 1313/*
1247 * Move a dying CPU's RCU callbacks to online CPU's callback list. 1314 * Move a dying CPU's RCU callbacks to online CPU's callback list.
1248 * Synchronization is not required because this function executes 1315 * Also record a quiescent state for this CPU for the current grace period.
1249 * in stop_machine() context. 1316 * Synchronization and interrupt disabling are not required because
1317 * this function executes in stop_machine() context. Therefore, cleanup
1318 * operations that might block must be done later from the CPU_DEAD
1319 * notifier.
1320 *
1321 * Note that the outgoing CPU's bit has already been cleared in the
1322 * cpu_online_mask. This allows us to randomly pick a callback
1323 * destination from the bits set in that mask.
1250 */ 1324 */
1251static void rcu_send_cbs_to_online(struct rcu_state *rsp) 1325static void rcu_cleanup_dying_cpu(struct rcu_state *rsp)
1252{ 1326{
1253 int i; 1327 int i;
1254 /* current DYING CPU is cleared in the cpu_online_mask */ 1328 unsigned long mask;
1255 int receive_cpu = cpumask_any(cpu_online_mask); 1329 int receive_cpu = cpumask_any(cpu_online_mask);
1256 struct rcu_data *rdp = this_cpu_ptr(rsp->rda); 1330 struct rcu_data *rdp = this_cpu_ptr(rsp->rda);
1257 struct rcu_data *receive_rdp = per_cpu_ptr(rsp->rda, receive_cpu); 1331 struct rcu_data *receive_rdp = per_cpu_ptr(rsp->rda, receive_cpu);
1332 RCU_TRACE(struct rcu_node *rnp = rdp->mynode); /* For dying CPU. */
1333
1334 /* First, adjust the counts. */
1335 if (rdp->nxtlist != NULL) {
1336 receive_rdp->qlen_lazy += rdp->qlen_lazy;
1337 receive_rdp->qlen += rdp->qlen;
1338 rdp->qlen_lazy = 0;
1339 rdp->qlen = 0;
1340 }
1258 1341
1259 if (rdp->nxtlist == NULL) 1342 /*
1260 return; /* irqs disabled, so comparison is stable. */ 1343 * Next, move ready-to-invoke callbacks to be invoked on some
1344 * other CPU. These will not be required to pass through another
1345 * grace period: They are done, regardless of CPU.
1346 */
1347 if (rdp->nxtlist != NULL &&
1348 rdp->nxttail[RCU_DONE_TAIL] != &rdp->nxtlist) {
1349 struct rcu_head *oldhead;
1350 struct rcu_head **oldtail;
1351 struct rcu_head **newtail;
1352
1353 oldhead = rdp->nxtlist;
1354 oldtail = receive_rdp->nxttail[RCU_DONE_TAIL];
1355 rdp->nxtlist = *rdp->nxttail[RCU_DONE_TAIL];
1356 *rdp->nxttail[RCU_DONE_TAIL] = *oldtail;
1357 *receive_rdp->nxttail[RCU_DONE_TAIL] = oldhead;
1358 newtail = rdp->nxttail[RCU_DONE_TAIL];
1359 for (i = RCU_DONE_TAIL; i < RCU_NEXT_SIZE; i++) {
1360 if (receive_rdp->nxttail[i] == oldtail)
1361 receive_rdp->nxttail[i] = newtail;
1362 if (rdp->nxttail[i] == newtail)
1363 rdp->nxttail[i] = &rdp->nxtlist;
1364 }
1365 }
1261 1366
1262 *receive_rdp->nxttail[RCU_NEXT_TAIL] = rdp->nxtlist; 1367 /*
1263 receive_rdp->nxttail[RCU_NEXT_TAIL] = rdp->nxttail[RCU_NEXT_TAIL]; 1368 * Finally, put the rest of the callbacks at the end of the list.
1264 receive_rdp->qlen += rdp->qlen; 1369 * The ones that made it partway through get to start over: We
1265 receive_rdp->n_cbs_adopted += rdp->qlen; 1370 * cannot assume that grace periods are synchronized across CPUs.
1266 rdp->n_cbs_orphaned += rdp->qlen; 1371 * (We could splice RCU_WAIT_TAIL into RCU_NEXT_READY_TAIL, but
1372 * this does not seem compelling. Not yet, anyway.)
1373 */
1374 if (rdp->nxtlist != NULL) {
1375 *receive_rdp->nxttail[RCU_NEXT_TAIL] = rdp->nxtlist;
1376 receive_rdp->nxttail[RCU_NEXT_TAIL] =
1377 rdp->nxttail[RCU_NEXT_TAIL];
1378 receive_rdp->n_cbs_adopted += rdp->qlen;
1379 rdp->n_cbs_orphaned += rdp->qlen;
1380
1381 rdp->nxtlist = NULL;
1382 for (i = 0; i < RCU_NEXT_SIZE; i++)
1383 rdp->nxttail[i] = &rdp->nxtlist;
1384 }
1267 1385
1268 rdp->nxtlist = NULL; 1386 /*
1269 for (i = 0; i < RCU_NEXT_SIZE; i++) 1387 * Record a quiescent state for the dying CPU. This is safe
1270 rdp->nxttail[i] = &rdp->nxtlist; 1388 * only because we have already cleared out the callbacks.
1271 rdp->qlen = 0; 1389 * (Otherwise, the RCU core might try to schedule the invocation
1390 * of callbacks on this now-offline CPU, which would be bad.)
1391 */
1392 mask = rdp->grpmask; /* rnp->grplo is constant. */
1393 trace_rcu_grace_period(rsp->name,
1394 rnp->gpnum + 1 - !!(rnp->qsmask & mask),
1395 "cpuofl");
1396 rcu_report_qs_rdp(smp_processor_id(), rsp, rdp, rsp->gpnum);
1397 /* Note that rcu_report_qs_rdp() might call trace_rcu_grace_period(). */
1272} 1398}
1273 1399
1274/* 1400/*
1275 * Remove the outgoing CPU from the bitmasks in the rcu_node hierarchy 1401 * The CPU has been completely removed, and some other CPU is reporting
1276 * and move all callbacks from the outgoing CPU to the current one. 1402 * this fact from process context. Do the remainder of the cleanup.
1277 * There can only be one CPU hotplug operation at a time, so no other 1403 * There can only be one CPU hotplug operation at a time, so no other
1278 * CPU can be attempting to update rcu_cpu_kthread_task. 1404 * CPU can be attempting to update rcu_cpu_kthread_task.
1279 */ 1405 */
1280static void __rcu_offline_cpu(int cpu, struct rcu_state *rsp) 1406static void rcu_cleanup_dead_cpu(int cpu, struct rcu_state *rsp)
1281{ 1407{
1282 unsigned long flags; 1408 unsigned long flags;
1283 unsigned long mask; 1409 unsigned long mask;
1284 int need_report = 0; 1410 int need_report = 0;
1285 struct rcu_data *rdp = per_cpu_ptr(rsp->rda, cpu); 1411 struct rcu_data *rdp = per_cpu_ptr(rsp->rda, cpu);
1286 struct rcu_node *rnp; 1412 struct rcu_node *rnp = rdp->mynode; /* Outgoing CPU's rnp. */
1287 1413
1414 /* Adjust any no-longer-needed kthreads. */
1288 rcu_stop_cpu_kthread(cpu); 1415 rcu_stop_cpu_kthread(cpu);
1416 rcu_node_kthread_setaffinity(rnp, -1);
1417
1418 /* Remove the dying CPU from the bitmasks in the rcu_node hierarchy. */
1289 1419
1290 /* Exclude any attempts to start a new grace period. */ 1420 /* Exclude any attempts to start a new grace period. */
1291 raw_spin_lock_irqsave(&rsp->onofflock, flags); 1421 raw_spin_lock_irqsave(&rsp->onofflock, flags);
1292 1422
1293 /* Remove the outgoing CPU from the masks in the rcu_node hierarchy. */ 1423 /* Remove the outgoing CPU from the masks in the rcu_node hierarchy. */
1294 rnp = rdp->mynode; /* this is the outgoing CPU's rnp. */
1295 mask = rdp->grpmask; /* rnp->grplo is constant. */ 1424 mask = rdp->grpmask; /* rnp->grplo is constant. */
1296 do { 1425 do {
1297 raw_spin_lock(&rnp->lock); /* irqs already disabled. */ 1426 raw_spin_lock(&rnp->lock); /* irqs already disabled. */
@@ -1299,20 +1428,11 @@ static void __rcu_offline_cpu(int cpu, struct rcu_state *rsp)
1299 if (rnp->qsmaskinit != 0) { 1428 if (rnp->qsmaskinit != 0) {
1300 if (rnp != rdp->mynode) 1429 if (rnp != rdp->mynode)
1301 raw_spin_unlock(&rnp->lock); /* irqs remain disabled. */ 1430 raw_spin_unlock(&rnp->lock); /* irqs remain disabled. */
1302 else
1303 trace_rcu_grace_period(rsp->name,
1304 rnp->gpnum + 1 -
1305 !!(rnp->qsmask & mask),
1306 "cpuofl");
1307 break; 1431 break;
1308 } 1432 }
1309 if (rnp == rdp->mynode) { 1433 if (rnp == rdp->mynode)
1310 trace_rcu_grace_period(rsp->name,
1311 rnp->gpnum + 1 -
1312 !!(rnp->qsmask & mask),
1313 "cpuofl");
1314 need_report = rcu_preempt_offline_tasks(rsp, rnp, rdp); 1434 need_report = rcu_preempt_offline_tasks(rsp, rnp, rdp);
1315 } else 1435 else
1316 raw_spin_unlock(&rnp->lock); /* irqs remain disabled. */ 1436 raw_spin_unlock(&rnp->lock); /* irqs remain disabled. */
1317 mask = rnp->grpmask; 1437 mask = rnp->grpmask;
1318 rnp = rnp->parent; 1438 rnp = rnp->parent;
@@ -1332,29 +1452,15 @@ static void __rcu_offline_cpu(int cpu, struct rcu_state *rsp)
1332 raw_spin_unlock_irqrestore(&rnp->lock, flags); 1452 raw_spin_unlock_irqrestore(&rnp->lock, flags);
1333 if (need_report & RCU_OFL_TASKS_EXP_GP) 1453 if (need_report & RCU_OFL_TASKS_EXP_GP)
1334 rcu_report_exp_rnp(rsp, rnp, true); 1454 rcu_report_exp_rnp(rsp, rnp, true);
1335 rcu_node_kthread_setaffinity(rnp, -1);
1336}
1337
1338/*
1339 * Remove the specified CPU from the RCU hierarchy and move any pending
1340 * callbacks that it might have to the current CPU. This code assumes
1341 * that at least one CPU in the system will remain running at all times.
1342 * Any attempt to offline -all- CPUs is likely to strand RCU callbacks.
1343 */
1344static void rcu_offline_cpu(int cpu)
1345{
1346 __rcu_offline_cpu(cpu, &rcu_sched_state);
1347 __rcu_offline_cpu(cpu, &rcu_bh_state);
1348 rcu_preempt_offline_cpu(cpu);
1349} 1455}
1350 1456
1351#else /* #ifdef CONFIG_HOTPLUG_CPU */ 1457#else /* #ifdef CONFIG_HOTPLUG_CPU */
1352 1458
1353static void rcu_send_cbs_to_online(struct rcu_state *rsp) 1459static void rcu_cleanup_dying_cpu(struct rcu_state *rsp)
1354{ 1460{
1355} 1461}
1356 1462
1357static void rcu_offline_cpu(int cpu) 1463static void rcu_cleanup_dead_cpu(int cpu, struct rcu_state *rsp)
1358{ 1464{
1359} 1465}
1360 1466
@@ -1368,11 +1474,11 @@ static void rcu_do_batch(struct rcu_state *rsp, struct rcu_data *rdp)
1368{ 1474{
1369 unsigned long flags; 1475 unsigned long flags;
1370 struct rcu_head *next, *list, **tail; 1476 struct rcu_head *next, *list, **tail;
1371 int bl, count; 1477 int bl, count, count_lazy;
1372 1478
1373 /* If no callbacks are ready, just return.*/ 1479 /* If no callbacks are ready, just return.*/
1374 if (!cpu_has_callbacks_ready_to_invoke(rdp)) { 1480 if (!cpu_has_callbacks_ready_to_invoke(rdp)) {
1375 trace_rcu_batch_start(rsp->name, 0, 0); 1481 trace_rcu_batch_start(rsp->name, rdp->qlen_lazy, rdp->qlen, 0);
1376 trace_rcu_batch_end(rsp->name, 0, !!ACCESS_ONCE(rdp->nxtlist), 1482 trace_rcu_batch_end(rsp->name, 0, !!ACCESS_ONCE(rdp->nxtlist),
1377 need_resched(), is_idle_task(current), 1483 need_resched(), is_idle_task(current),
1378 rcu_is_callbacks_kthread()); 1484 rcu_is_callbacks_kthread());
@@ -1384,8 +1490,9 @@ static void rcu_do_batch(struct rcu_state *rsp, struct rcu_data *rdp)
1384 * races with call_rcu() from interrupt handlers. 1490 * races with call_rcu() from interrupt handlers.
1385 */ 1491 */
1386 local_irq_save(flags); 1492 local_irq_save(flags);
1493 WARN_ON_ONCE(cpu_is_offline(smp_processor_id()));
1387 bl = rdp->blimit; 1494 bl = rdp->blimit;
1388 trace_rcu_batch_start(rsp->name, rdp->qlen, bl); 1495 trace_rcu_batch_start(rsp->name, rdp->qlen_lazy, rdp->qlen, bl);
1389 list = rdp->nxtlist; 1496 list = rdp->nxtlist;
1390 rdp->nxtlist = *rdp->nxttail[RCU_DONE_TAIL]; 1497 rdp->nxtlist = *rdp->nxttail[RCU_DONE_TAIL];
1391 *rdp->nxttail[RCU_DONE_TAIL] = NULL; 1498 *rdp->nxttail[RCU_DONE_TAIL] = NULL;
@@ -1396,12 +1503,13 @@ static void rcu_do_batch(struct rcu_state *rsp, struct rcu_data *rdp)
1396 local_irq_restore(flags); 1503 local_irq_restore(flags);
1397 1504
1398 /* Invoke callbacks. */ 1505 /* Invoke callbacks. */
1399 count = 0; 1506 count = count_lazy = 0;
1400 while (list) { 1507 while (list) {
1401 next = list->next; 1508 next = list->next;
1402 prefetch(next); 1509 prefetch(next);
1403 debug_rcu_head_unqueue(list); 1510 debug_rcu_head_unqueue(list);
1404 __rcu_reclaim(rsp->name, list); 1511 if (__rcu_reclaim(rsp->name, list))
1512 count_lazy++;
1405 list = next; 1513 list = next;
1406 /* Stop only if limit reached and CPU has something to do. */ 1514 /* Stop only if limit reached and CPU has something to do. */
1407 if (++count >= bl && 1515 if (++count >= bl &&
@@ -1416,6 +1524,7 @@ static void rcu_do_batch(struct rcu_state *rsp, struct rcu_data *rdp)
1416 rcu_is_callbacks_kthread()); 1524 rcu_is_callbacks_kthread());
1417 1525
1418 /* Update count, and requeue any remaining callbacks. */ 1526 /* Update count, and requeue any remaining callbacks. */
1527 rdp->qlen_lazy -= count_lazy;
1419 rdp->qlen -= count; 1528 rdp->qlen -= count;
1420 rdp->n_cbs_invoked += count; 1529 rdp->n_cbs_invoked += count;
1421 if (list != NULL) { 1530 if (list != NULL) {
@@ -1458,6 +1567,7 @@ static void rcu_do_batch(struct rcu_state *rsp, struct rcu_data *rdp)
1458void rcu_check_callbacks(int cpu, int user) 1567void rcu_check_callbacks(int cpu, int user)
1459{ 1568{
1460 trace_rcu_utilization("Start scheduler-tick"); 1569 trace_rcu_utilization("Start scheduler-tick");
1570 increment_cpu_stall_ticks();
1461 if (user || rcu_is_cpu_rrupt_from_idle()) { 1571 if (user || rcu_is_cpu_rrupt_from_idle()) {
1462 1572
1463 /* 1573 /*
@@ -1492,8 +1602,6 @@ void rcu_check_callbacks(int cpu, int user)
1492 trace_rcu_utilization("End scheduler-tick"); 1602 trace_rcu_utilization("End scheduler-tick");
1493} 1603}
1494 1604
1495#ifdef CONFIG_SMP
1496
1497/* 1605/*
1498 * Scan the leaf rcu_node structures, processing dyntick state for any that 1606 * Scan the leaf rcu_node structures, processing dyntick state for any that
1499 * have not yet encountered a quiescent state, using the function specified. 1607 * have not yet encountered a quiescent state, using the function specified.
@@ -1616,15 +1724,6 @@ unlock_fqs_ret:
1616 trace_rcu_utilization("End fqs"); 1724 trace_rcu_utilization("End fqs");
1617} 1725}
1618 1726
1619#else /* #ifdef CONFIG_SMP */
1620
1621static void force_quiescent_state(struct rcu_state *rsp, int relaxed)
1622{
1623 set_need_resched();
1624}
1625
1626#endif /* #else #ifdef CONFIG_SMP */
1627
1628/* 1727/*
1629 * This does the RCU core processing work for the specified rcu_state 1728 * This does the RCU core processing work for the specified rcu_state
1630 * and rcu_data structures. This may be called only from the CPU to 1729 * and rcu_data structures. This may be called only from the CPU to
@@ -1702,11 +1801,12 @@ static void invoke_rcu_core(void)
1702 1801
1703static void 1802static void
1704__call_rcu(struct rcu_head *head, void (*func)(struct rcu_head *rcu), 1803__call_rcu(struct rcu_head *head, void (*func)(struct rcu_head *rcu),
1705 struct rcu_state *rsp) 1804 struct rcu_state *rsp, bool lazy)
1706{ 1805{
1707 unsigned long flags; 1806 unsigned long flags;
1708 struct rcu_data *rdp; 1807 struct rcu_data *rdp;
1709 1808
1809 WARN_ON_ONCE((unsigned long)head & 0x3); /* Misaligned rcu_head! */
1710 debug_rcu_head_queue(head); 1810 debug_rcu_head_queue(head);
1711 head->func = func; 1811 head->func = func;
1712 head->next = NULL; 1812 head->next = NULL;
@@ -1720,18 +1820,21 @@ __call_rcu(struct rcu_head *head, void (*func)(struct rcu_head *rcu),
1720 * a quiescent state betweentimes. 1820 * a quiescent state betweentimes.
1721 */ 1821 */
1722 local_irq_save(flags); 1822 local_irq_save(flags);
1823 WARN_ON_ONCE(cpu_is_offline(smp_processor_id()));
1723 rdp = this_cpu_ptr(rsp->rda); 1824 rdp = this_cpu_ptr(rsp->rda);
1724 1825
1725 /* Add the callback to our list. */ 1826 /* Add the callback to our list. */
1726 *rdp->nxttail[RCU_NEXT_TAIL] = head; 1827 *rdp->nxttail[RCU_NEXT_TAIL] = head;
1727 rdp->nxttail[RCU_NEXT_TAIL] = &head->next; 1828 rdp->nxttail[RCU_NEXT_TAIL] = &head->next;
1728 rdp->qlen++; 1829 rdp->qlen++;
1830 if (lazy)
1831 rdp->qlen_lazy++;
1729 1832
1730 if (__is_kfree_rcu_offset((unsigned long)func)) 1833 if (__is_kfree_rcu_offset((unsigned long)func))
1731 trace_rcu_kfree_callback(rsp->name, head, (unsigned long)func, 1834 trace_rcu_kfree_callback(rsp->name, head, (unsigned long)func,
1732 rdp->qlen); 1835 rdp->qlen_lazy, rdp->qlen);
1733 else 1836 else
1734 trace_rcu_callback(rsp->name, head, rdp->qlen); 1837 trace_rcu_callback(rsp->name, head, rdp->qlen_lazy, rdp->qlen);
1735 1838
1736 /* If interrupts were disabled, don't dive into RCU core. */ 1839 /* If interrupts were disabled, don't dive into RCU core. */
1737 if (irqs_disabled_flags(flags)) { 1840 if (irqs_disabled_flags(flags)) {
@@ -1778,16 +1881,16 @@ __call_rcu(struct rcu_head *head, void (*func)(struct rcu_head *rcu),
1778 */ 1881 */
1779void call_rcu_sched(struct rcu_head *head, void (*func)(struct rcu_head *rcu)) 1882void call_rcu_sched(struct rcu_head *head, void (*func)(struct rcu_head *rcu))
1780{ 1883{
1781 __call_rcu(head, func, &rcu_sched_state); 1884 __call_rcu(head, func, &rcu_sched_state, 0);
1782} 1885}
1783EXPORT_SYMBOL_GPL(call_rcu_sched); 1886EXPORT_SYMBOL_GPL(call_rcu_sched);
1784 1887
1785/* 1888/*
1786 * Queue an RCU for invocation after a quicker grace period. 1889 * Queue an RCU callback for invocation after a quicker grace period.
1787 */ 1890 */
1788void call_rcu_bh(struct rcu_head *head, void (*func)(struct rcu_head *rcu)) 1891void call_rcu_bh(struct rcu_head *head, void (*func)(struct rcu_head *rcu))
1789{ 1892{
1790 __call_rcu(head, func, &rcu_bh_state); 1893 __call_rcu(head, func, &rcu_bh_state, 0);
1791} 1894}
1792EXPORT_SYMBOL_GPL(call_rcu_bh); 1895EXPORT_SYMBOL_GPL(call_rcu_bh);
1793 1896
@@ -1816,6 +1919,10 @@ EXPORT_SYMBOL_GPL(call_rcu_bh);
1816 */ 1919 */
1817void synchronize_sched(void) 1920void synchronize_sched(void)
1818{ 1921{
1922 rcu_lockdep_assert(!lock_is_held(&rcu_bh_lock_map) &&
1923 !lock_is_held(&rcu_lock_map) &&
1924 !lock_is_held(&rcu_sched_lock_map),
1925 "Illegal synchronize_sched() in RCU-sched read-side critical section");
1819 if (rcu_blocking_is_gp()) 1926 if (rcu_blocking_is_gp())
1820 return; 1927 return;
1821 wait_rcu_gp(call_rcu_sched); 1928 wait_rcu_gp(call_rcu_sched);
@@ -1833,12 +1940,137 @@ EXPORT_SYMBOL_GPL(synchronize_sched);
1833 */ 1940 */
1834void synchronize_rcu_bh(void) 1941void synchronize_rcu_bh(void)
1835{ 1942{
1943 rcu_lockdep_assert(!lock_is_held(&rcu_bh_lock_map) &&
1944 !lock_is_held(&rcu_lock_map) &&
1945 !lock_is_held(&rcu_sched_lock_map),
1946 "Illegal synchronize_rcu_bh() in RCU-bh read-side critical section");
1836 if (rcu_blocking_is_gp()) 1947 if (rcu_blocking_is_gp())
1837 return; 1948 return;
1838 wait_rcu_gp(call_rcu_bh); 1949 wait_rcu_gp(call_rcu_bh);
1839} 1950}
1840EXPORT_SYMBOL_GPL(synchronize_rcu_bh); 1951EXPORT_SYMBOL_GPL(synchronize_rcu_bh);
1841 1952
1953static atomic_t sync_sched_expedited_started = ATOMIC_INIT(0);
1954static atomic_t sync_sched_expedited_done = ATOMIC_INIT(0);
1955
1956static int synchronize_sched_expedited_cpu_stop(void *data)
1957{
1958 /*
1959 * There must be a full memory barrier on each affected CPU
1960 * between the time that try_stop_cpus() is called and the
1961 * time that it returns.
1962 *
1963 * In the current initial implementation of cpu_stop, the
1964 * above condition is already met when the control reaches
1965 * this point and the following smp_mb() is not strictly
1966 * necessary. Do smp_mb() anyway for documentation and
1967 * robustness against future implementation changes.
1968 */
1969 smp_mb(); /* See above comment block. */
1970 return 0;
1971}
1972
1973/**
1974 * synchronize_sched_expedited - Brute-force RCU-sched grace period
1975 *
1976 * Wait for an RCU-sched grace period to elapse, but use a "big hammer"
1977 * approach to force the grace period to end quickly. This consumes
1978 * significant time on all CPUs and is unfriendly to real-time workloads,
1979 * so is thus not recommended for any sort of common-case code. In fact,
1980 * if you are using synchronize_sched_expedited() in a loop, please
1981 * restructure your code to batch your updates, and then use a single
1982 * synchronize_sched() instead.
1983 *
1984 * Note that it is illegal to call this function while holding any lock
1985 * that is acquired by a CPU-hotplug notifier. And yes, it is also illegal
1986 * to call this function from a CPU-hotplug notifier. Failing to observe
1987 * these restriction will result in deadlock.
1988 *
1989 * This implementation can be thought of as an application of ticket
1990 * locking to RCU, with sync_sched_expedited_started and
1991 * sync_sched_expedited_done taking on the roles of the halves
1992 * of the ticket-lock word. Each task atomically increments
1993 * sync_sched_expedited_started upon entry, snapshotting the old value,
1994 * then attempts to stop all the CPUs. If this succeeds, then each
1995 * CPU will have executed a context switch, resulting in an RCU-sched
1996 * grace period. We are then done, so we use atomic_cmpxchg() to
1997 * update sync_sched_expedited_done to match our snapshot -- but
1998 * only if someone else has not already advanced past our snapshot.
1999 *
2000 * On the other hand, if try_stop_cpus() fails, we check the value
2001 * of sync_sched_expedited_done. If it has advanced past our
2002 * initial snapshot, then someone else must have forced a grace period
2003 * some time after we took our snapshot. In this case, our work is
2004 * done for us, and we can simply return. Otherwise, we try again,
2005 * but keep our initial snapshot for purposes of checking for someone
2006 * doing our work for us.
2007 *
2008 * If we fail too many times in a row, we fall back to synchronize_sched().
2009 */
2010void synchronize_sched_expedited(void)
2011{
2012 int firstsnap, s, snap, trycount = 0;
2013
2014 /* Note that atomic_inc_return() implies full memory barrier. */
2015 firstsnap = snap = atomic_inc_return(&sync_sched_expedited_started);
2016 get_online_cpus();
2017 WARN_ON_ONCE(cpu_is_offline(raw_smp_processor_id()));
2018
2019 /*
2020 * Each pass through the following loop attempts to force a
2021 * context switch on each CPU.
2022 */
2023 while (try_stop_cpus(cpu_online_mask,
2024 synchronize_sched_expedited_cpu_stop,
2025 NULL) == -EAGAIN) {
2026 put_online_cpus();
2027
2028 /* No joy, try again later. Or just synchronize_sched(). */
2029 if (trycount++ < 10)
2030 udelay(trycount * num_online_cpus());
2031 else {
2032 synchronize_sched();
2033 return;
2034 }
2035
2036 /* Check to see if someone else did our work for us. */
2037 s = atomic_read(&sync_sched_expedited_done);
2038 if (UINT_CMP_GE((unsigned)s, (unsigned)firstsnap)) {
2039 smp_mb(); /* ensure test happens before caller kfree */
2040 return;
2041 }
2042
2043 /*
2044 * Refetching sync_sched_expedited_started allows later
2045 * callers to piggyback on our grace period. We subtract
2046 * 1 to get the same token that the last incrementer got.
2047 * We retry after they started, so our grace period works
2048 * for them, and they started after our first try, so their
2049 * grace period works for us.
2050 */
2051 get_online_cpus();
2052 snap = atomic_read(&sync_sched_expedited_started);
2053 smp_mb(); /* ensure read is before try_stop_cpus(). */
2054 }
2055
2056 /*
2057 * Everyone up to our most recent fetch is covered by our grace
2058 * period. Update the counter, but only if our work is still
2059 * relevant -- which it won't be if someone who started later
2060 * than we did beat us to the punch.
2061 */
2062 do {
2063 s = atomic_read(&sync_sched_expedited_done);
2064 if (UINT_CMP_GE((unsigned)s, (unsigned)snap)) {
2065 smp_mb(); /* ensure test happens before caller kfree */
2066 break;
2067 }
2068 } while (atomic_cmpxchg(&sync_sched_expedited_done, s, snap) != s);
2069
2070 put_online_cpus();
2071}
2072EXPORT_SYMBOL_GPL(synchronize_sched_expedited);
2073
1842/* 2074/*
1843 * Check to see if there is any immediate RCU-related work to be done 2075 * Check to see if there is any immediate RCU-related work to be done
1844 * by the current CPU, for the specified type of RCU, returning 1 if so. 2076 * by the current CPU, for the specified type of RCU, returning 1 if so.
@@ -1932,7 +2164,7 @@ static int rcu_cpu_has_callbacks(int cpu)
1932 /* RCU callbacks either ready or pending? */ 2164 /* RCU callbacks either ready or pending? */
1933 return per_cpu(rcu_sched_data, cpu).nxtlist || 2165 return per_cpu(rcu_sched_data, cpu).nxtlist ||
1934 per_cpu(rcu_bh_data, cpu).nxtlist || 2166 per_cpu(rcu_bh_data, cpu).nxtlist ||
1935 rcu_preempt_needs_cpu(cpu); 2167 rcu_preempt_cpu_has_callbacks(cpu);
1936} 2168}
1937 2169
1938static DEFINE_PER_CPU(struct rcu_head, rcu_barrier_head) = {NULL}; 2170static DEFINE_PER_CPU(struct rcu_head, rcu_barrier_head) = {NULL};
@@ -2027,9 +2259,10 @@ rcu_boot_init_percpu_data(int cpu, struct rcu_state *rsp)
2027 rdp->nxtlist = NULL; 2259 rdp->nxtlist = NULL;
2028 for (i = 0; i < RCU_NEXT_SIZE; i++) 2260 for (i = 0; i < RCU_NEXT_SIZE; i++)
2029 rdp->nxttail[i] = &rdp->nxtlist; 2261 rdp->nxttail[i] = &rdp->nxtlist;
2262 rdp->qlen_lazy = 0;
2030 rdp->qlen = 0; 2263 rdp->qlen = 0;
2031 rdp->dynticks = &per_cpu(rcu_dynticks, cpu); 2264 rdp->dynticks = &per_cpu(rcu_dynticks, cpu);
2032 WARN_ON_ONCE(rdp->dynticks->dynticks_nesting != DYNTICK_TASK_NESTING); 2265 WARN_ON_ONCE(rdp->dynticks->dynticks_nesting != DYNTICK_TASK_EXIT_IDLE);
2033 WARN_ON_ONCE(atomic_read(&rdp->dynticks->dynticks) != 1); 2266 WARN_ON_ONCE(atomic_read(&rdp->dynticks->dynticks) != 1);
2034 rdp->cpu = cpu; 2267 rdp->cpu = cpu;
2035 rdp->rsp = rsp; 2268 rdp->rsp = rsp;
@@ -2057,7 +2290,7 @@ rcu_init_percpu_data(int cpu, struct rcu_state *rsp, int preemptible)
2057 rdp->qlen_last_fqs_check = 0; 2290 rdp->qlen_last_fqs_check = 0;
2058 rdp->n_force_qs_snap = rsp->n_force_qs; 2291 rdp->n_force_qs_snap = rsp->n_force_qs;
2059 rdp->blimit = blimit; 2292 rdp->blimit = blimit;
2060 rdp->dynticks->dynticks_nesting = DYNTICK_TASK_NESTING; 2293 rdp->dynticks->dynticks_nesting = DYNTICK_TASK_EXIT_IDLE;
2061 atomic_set(&rdp->dynticks->dynticks, 2294 atomic_set(&rdp->dynticks->dynticks,
2062 (atomic_read(&rdp->dynticks->dynticks) & ~0x1) + 1); 2295 (atomic_read(&rdp->dynticks->dynticks) & ~0x1) + 1);
2063 rcu_prepare_for_idle_init(cpu); 2296 rcu_prepare_for_idle_init(cpu);
@@ -2139,16 +2372,18 @@ static int __cpuinit rcu_cpu_notify(struct notifier_block *self,
2139 * touch any data without introducing corruption. We send the 2372 * touch any data without introducing corruption. We send the
2140 * dying CPU's callbacks to an arbitrarily chosen online CPU. 2373 * dying CPU's callbacks to an arbitrarily chosen online CPU.
2141 */ 2374 */
2142 rcu_send_cbs_to_online(&rcu_bh_state); 2375 rcu_cleanup_dying_cpu(&rcu_bh_state);
2143 rcu_send_cbs_to_online(&rcu_sched_state); 2376 rcu_cleanup_dying_cpu(&rcu_sched_state);
2144 rcu_preempt_send_cbs_to_online(); 2377 rcu_preempt_cleanup_dying_cpu();
2145 rcu_cleanup_after_idle(cpu); 2378 rcu_cleanup_after_idle(cpu);
2146 break; 2379 break;
2147 case CPU_DEAD: 2380 case CPU_DEAD:
2148 case CPU_DEAD_FROZEN: 2381 case CPU_DEAD_FROZEN:
2149 case CPU_UP_CANCELED: 2382 case CPU_UP_CANCELED:
2150 case CPU_UP_CANCELED_FROZEN: 2383 case CPU_UP_CANCELED_FROZEN:
2151 rcu_offline_cpu(cpu); 2384 rcu_cleanup_dead_cpu(cpu, &rcu_bh_state);
2385 rcu_cleanup_dead_cpu(cpu, &rcu_sched_state);
2386 rcu_preempt_cleanup_dead_cpu(cpu);
2152 break; 2387 break;
2153 default: 2388 default:
2154 break; 2389 break;
diff --git a/kernel/rcutree.h b/kernel/rcutree.h
index fddff92d6676..cdd1be0a4072 100644
--- a/kernel/rcutree.h
+++ b/kernel/rcutree.h
@@ -239,6 +239,12 @@ struct rcu_data {
239 bool preemptible; /* Preemptible RCU? */ 239 bool preemptible; /* Preemptible RCU? */
240 struct rcu_node *mynode; /* This CPU's leaf of hierarchy */ 240 struct rcu_node *mynode; /* This CPU's leaf of hierarchy */
241 unsigned long grpmask; /* Mask to apply to leaf qsmask. */ 241 unsigned long grpmask; /* Mask to apply to leaf qsmask. */
242#ifdef CONFIG_RCU_CPU_STALL_INFO
243 unsigned long ticks_this_gp; /* The number of scheduling-clock */
244 /* ticks this CPU has handled */
245 /* during and after the last grace */
246 /* period it is aware of. */
247#endif /* #ifdef CONFIG_RCU_CPU_STALL_INFO */
242 248
243 /* 2) batch handling */ 249 /* 2) batch handling */
244 /* 250 /*
@@ -265,7 +271,8 @@ struct rcu_data {
265 */ 271 */
266 struct rcu_head *nxtlist; 272 struct rcu_head *nxtlist;
267 struct rcu_head **nxttail[RCU_NEXT_SIZE]; 273 struct rcu_head **nxttail[RCU_NEXT_SIZE];
268 long qlen; /* # of queued callbacks */ 274 long qlen_lazy; /* # of lazy queued callbacks */
275 long qlen; /* # of queued callbacks, incl lazy */
269 long qlen_last_fqs_check; 276 long qlen_last_fqs_check;
270 /* qlen at last check for QS forcing */ 277 /* qlen at last check for QS forcing */
271 unsigned long n_cbs_invoked; /* count of RCU cbs invoked. */ 278 unsigned long n_cbs_invoked; /* count of RCU cbs invoked. */
@@ -282,7 +289,6 @@ struct rcu_data {
282 /* 4) reasons this CPU needed to be kicked by force_quiescent_state */ 289 /* 4) reasons this CPU needed to be kicked by force_quiescent_state */
283 unsigned long dynticks_fqs; /* Kicked due to dynticks idle. */ 290 unsigned long dynticks_fqs; /* Kicked due to dynticks idle. */
284 unsigned long offline_fqs; /* Kicked due to being offline. */ 291 unsigned long offline_fqs; /* Kicked due to being offline. */
285 unsigned long resched_ipi; /* Sent a resched IPI. */
286 292
287 /* 5) __rcu_pending() statistics. */ 293 /* 5) __rcu_pending() statistics. */
288 unsigned long n_rcu_pending; /* rcu_pending() calls since boot. */ 294 unsigned long n_rcu_pending; /* rcu_pending() calls since boot. */
@@ -313,12 +319,6 @@ struct rcu_data {
313#else 319#else
314#define RCU_STALL_DELAY_DELTA 0 320#define RCU_STALL_DELAY_DELTA 0
315#endif 321#endif
316
317#define RCU_SECONDS_TILL_STALL_CHECK (CONFIG_RCU_CPU_STALL_TIMEOUT * HZ + \
318 RCU_STALL_DELAY_DELTA)
319 /* for rsp->jiffies_stall */
320#define RCU_SECONDS_TILL_STALL_RECHECK (3 * RCU_SECONDS_TILL_STALL_CHECK + 30)
321 /* for rsp->jiffies_stall */
322#define RCU_STALL_RAT_DELAY 2 /* Allow other CPUs time */ 322#define RCU_STALL_RAT_DELAY 2 /* Allow other CPUs time */
323 /* to take at least one */ 323 /* to take at least one */
324 /* scheduling clock irq */ 324 /* scheduling clock irq */
@@ -438,8 +438,8 @@ static void rcu_preempt_check_blocked_tasks(struct rcu_node *rnp);
438static int rcu_preempt_offline_tasks(struct rcu_state *rsp, 438static int rcu_preempt_offline_tasks(struct rcu_state *rsp,
439 struct rcu_node *rnp, 439 struct rcu_node *rnp,
440 struct rcu_data *rdp); 440 struct rcu_data *rdp);
441static void rcu_preempt_offline_cpu(int cpu);
442#endif /* #ifdef CONFIG_HOTPLUG_CPU */ 441#endif /* #ifdef CONFIG_HOTPLUG_CPU */
442static void rcu_preempt_cleanup_dead_cpu(int cpu);
443static void rcu_preempt_check_callbacks(int cpu); 443static void rcu_preempt_check_callbacks(int cpu);
444static void rcu_preempt_process_callbacks(void); 444static void rcu_preempt_process_callbacks(void);
445void call_rcu(struct rcu_head *head, void (*func)(struct rcu_head *rcu)); 445void call_rcu(struct rcu_head *head, void (*func)(struct rcu_head *rcu));
@@ -448,9 +448,9 @@ static void rcu_report_exp_rnp(struct rcu_state *rsp, struct rcu_node *rnp,
448 bool wake); 448 bool wake);
449#endif /* #if defined(CONFIG_HOTPLUG_CPU) || defined(CONFIG_TREE_PREEMPT_RCU) */ 449#endif /* #if defined(CONFIG_HOTPLUG_CPU) || defined(CONFIG_TREE_PREEMPT_RCU) */
450static int rcu_preempt_pending(int cpu); 450static int rcu_preempt_pending(int cpu);
451static int rcu_preempt_needs_cpu(int cpu); 451static int rcu_preempt_cpu_has_callbacks(int cpu);
452static void __cpuinit rcu_preempt_init_percpu_data(int cpu); 452static void __cpuinit rcu_preempt_init_percpu_data(int cpu);
453static void rcu_preempt_send_cbs_to_online(void); 453static void rcu_preempt_cleanup_dying_cpu(void);
454static void __init __rcu_init_preempt(void); 454static void __init __rcu_init_preempt(void);
455static void rcu_initiate_boost(struct rcu_node *rnp, unsigned long flags); 455static void rcu_initiate_boost(struct rcu_node *rnp, unsigned long flags);
456static void rcu_preempt_boost_start_gp(struct rcu_node *rnp); 456static void rcu_preempt_boost_start_gp(struct rcu_node *rnp);
@@ -471,5 +471,10 @@ static void __cpuinit rcu_prepare_kthreads(int cpu);
471static void rcu_prepare_for_idle_init(int cpu); 471static void rcu_prepare_for_idle_init(int cpu);
472static void rcu_cleanup_after_idle(int cpu); 472static void rcu_cleanup_after_idle(int cpu);
473static void rcu_prepare_for_idle(int cpu); 473static void rcu_prepare_for_idle(int cpu);
474static void print_cpu_stall_info_begin(void);
475static void print_cpu_stall_info(struct rcu_state *rsp, int cpu);
476static void print_cpu_stall_info_end(void);
477static void zero_cpu_stall_ticks(struct rcu_data *rdp);
478static void increment_cpu_stall_ticks(void);
474 479
475#endif /* #ifndef RCU_TREE_NONCORE */ 480#endif /* #ifndef RCU_TREE_NONCORE */
diff --git a/kernel/rcutree_plugin.h b/kernel/rcutree_plugin.h
index 8bb35d73e1f9..c023464816be 100644
--- a/kernel/rcutree_plugin.h
+++ b/kernel/rcutree_plugin.h
@@ -25,7 +25,6 @@
25 */ 25 */
26 26
27#include <linux/delay.h> 27#include <linux/delay.h>
28#include <linux/stop_machine.h>
29 28
30#define RCU_KTHREAD_PRIO 1 29#define RCU_KTHREAD_PRIO 1
31 30
@@ -63,7 +62,10 @@ static void __init rcu_bootup_announce_oddness(void)
63 printk(KERN_INFO "\tRCU torture testing starts during boot.\n"); 62 printk(KERN_INFO "\tRCU torture testing starts during boot.\n");
64#endif 63#endif
65#if defined(CONFIG_TREE_PREEMPT_RCU) && !defined(CONFIG_RCU_CPU_STALL_VERBOSE) 64#if defined(CONFIG_TREE_PREEMPT_RCU) && !defined(CONFIG_RCU_CPU_STALL_VERBOSE)
66 printk(KERN_INFO "\tVerbose stalled-CPUs detection is disabled.\n"); 65 printk(KERN_INFO "\tDump stacks of tasks blocking RCU-preempt GP.\n");
66#endif
67#if defined(CONFIG_RCU_CPU_STALL_INFO)
68 printk(KERN_INFO "\tAdditional per-CPU info printed with stalls.\n");
67#endif 69#endif
68#if NUM_RCU_LVL_4 != 0 70#if NUM_RCU_LVL_4 != 0
69 printk(KERN_INFO "\tExperimental four-level hierarchy is enabled.\n"); 71 printk(KERN_INFO "\tExperimental four-level hierarchy is enabled.\n");
@@ -490,6 +492,31 @@ static void rcu_print_detail_task_stall(struct rcu_state *rsp)
490 492
491#endif /* #else #ifdef CONFIG_RCU_CPU_STALL_VERBOSE */ 493#endif /* #else #ifdef CONFIG_RCU_CPU_STALL_VERBOSE */
492 494
495#ifdef CONFIG_RCU_CPU_STALL_INFO
496
497static void rcu_print_task_stall_begin(struct rcu_node *rnp)
498{
499 printk(KERN_ERR "\tTasks blocked on level-%d rcu_node (CPUs %d-%d):",
500 rnp->level, rnp->grplo, rnp->grphi);
501}
502
503static void rcu_print_task_stall_end(void)
504{
505 printk(KERN_CONT "\n");
506}
507
508#else /* #ifdef CONFIG_RCU_CPU_STALL_INFO */
509
510static void rcu_print_task_stall_begin(struct rcu_node *rnp)
511{
512}
513
514static void rcu_print_task_stall_end(void)
515{
516}
517
518#endif /* #else #ifdef CONFIG_RCU_CPU_STALL_INFO */
519
493/* 520/*
494 * Scan the current list of tasks blocked within RCU read-side critical 521 * Scan the current list of tasks blocked within RCU read-side critical
495 * sections, printing out the tid of each. 522 * sections, printing out the tid of each.
@@ -501,12 +528,14 @@ static int rcu_print_task_stall(struct rcu_node *rnp)
501 528
502 if (!rcu_preempt_blocked_readers_cgp(rnp)) 529 if (!rcu_preempt_blocked_readers_cgp(rnp))
503 return 0; 530 return 0;
531 rcu_print_task_stall_begin(rnp);
504 t = list_entry(rnp->gp_tasks, 532 t = list_entry(rnp->gp_tasks,
505 struct task_struct, rcu_node_entry); 533 struct task_struct, rcu_node_entry);
506 list_for_each_entry_continue(t, &rnp->blkd_tasks, rcu_node_entry) { 534 list_for_each_entry_continue(t, &rnp->blkd_tasks, rcu_node_entry) {
507 printk(" P%d", t->pid); 535 printk(KERN_CONT " P%d", t->pid);
508 ndetected++; 536 ndetected++;
509 } 537 }
538 rcu_print_task_stall_end();
510 return ndetected; 539 return ndetected;
511} 540}
512 541
@@ -581,7 +610,7 @@ static int rcu_preempt_offline_tasks(struct rcu_state *rsp,
581 * absolutely necessary, but this is a good performance/complexity 610 * absolutely necessary, but this is a good performance/complexity
582 * tradeoff. 611 * tradeoff.
583 */ 612 */
584 if (rcu_preempt_blocked_readers_cgp(rnp)) 613 if (rcu_preempt_blocked_readers_cgp(rnp) && rnp->qsmask == 0)
585 retval |= RCU_OFL_TASKS_NORM_GP; 614 retval |= RCU_OFL_TASKS_NORM_GP;
586 if (rcu_preempted_readers_exp(rnp)) 615 if (rcu_preempted_readers_exp(rnp))
587 retval |= RCU_OFL_TASKS_EXP_GP; 616 retval |= RCU_OFL_TASKS_EXP_GP;
@@ -618,16 +647,16 @@ static int rcu_preempt_offline_tasks(struct rcu_state *rsp,
618 return retval; 647 return retval;
619} 648}
620 649
650#endif /* #ifdef CONFIG_HOTPLUG_CPU */
651
621/* 652/*
622 * Do CPU-offline processing for preemptible RCU. 653 * Do CPU-offline processing for preemptible RCU.
623 */ 654 */
624static void rcu_preempt_offline_cpu(int cpu) 655static void rcu_preempt_cleanup_dead_cpu(int cpu)
625{ 656{
626 __rcu_offline_cpu(cpu, &rcu_preempt_state); 657 rcu_cleanup_dead_cpu(cpu, &rcu_preempt_state);
627} 658}
628 659
629#endif /* #ifdef CONFIG_HOTPLUG_CPU */
630
631/* 660/*
632 * Check for a quiescent state from the current CPU. When a task blocks, 661 * Check for a quiescent state from the current CPU. When a task blocks,
633 * the task is recorded in the corresponding CPU's rcu_node structure, 662 * the task is recorded in the corresponding CPU's rcu_node structure,
@@ -671,10 +700,24 @@ static void rcu_preempt_do_callbacks(void)
671 */ 700 */
672void call_rcu(struct rcu_head *head, void (*func)(struct rcu_head *rcu)) 701void call_rcu(struct rcu_head *head, void (*func)(struct rcu_head *rcu))
673{ 702{
674 __call_rcu(head, func, &rcu_preempt_state); 703 __call_rcu(head, func, &rcu_preempt_state, 0);
675} 704}
676EXPORT_SYMBOL_GPL(call_rcu); 705EXPORT_SYMBOL_GPL(call_rcu);
677 706
707/*
708 * Queue an RCU callback for lazy invocation after a grace period.
709 * This will likely be later named something like "call_rcu_lazy()",
710 * but this change will require some way of tagging the lazy RCU
711 * callbacks in the list of pending callbacks. Until then, this
712 * function may only be called from __kfree_rcu().
713 */
714void kfree_call_rcu(struct rcu_head *head,
715 void (*func)(struct rcu_head *rcu))
716{
717 __call_rcu(head, func, &rcu_preempt_state, 1);
718}
719EXPORT_SYMBOL_GPL(kfree_call_rcu);
720
678/** 721/**
679 * synchronize_rcu - wait until a grace period has elapsed. 722 * synchronize_rcu - wait until a grace period has elapsed.
680 * 723 *
@@ -688,6 +731,10 @@ EXPORT_SYMBOL_GPL(call_rcu);
688 */ 731 */
689void synchronize_rcu(void) 732void synchronize_rcu(void)
690{ 733{
734 rcu_lockdep_assert(!lock_is_held(&rcu_bh_lock_map) &&
735 !lock_is_held(&rcu_lock_map) &&
736 !lock_is_held(&rcu_sched_lock_map),
737 "Illegal synchronize_rcu() in RCU read-side critical section");
691 if (!rcu_scheduler_active) 738 if (!rcu_scheduler_active)
692 return; 739 return;
693 wait_rcu_gp(call_rcu); 740 wait_rcu_gp(call_rcu);
@@ -788,10 +835,22 @@ sync_rcu_preempt_exp_init(struct rcu_state *rsp, struct rcu_node *rnp)
788 rcu_report_exp_rnp(rsp, rnp, false); /* Don't wake self. */ 835 rcu_report_exp_rnp(rsp, rnp, false); /* Don't wake self. */
789} 836}
790 837
791/* 838/**
792 * Wait for an rcu-preempt grace period, but expedite it. The basic idea 839 * synchronize_rcu_expedited - Brute-force RCU grace period
793 * is to invoke synchronize_sched_expedited() to push all the tasks to 840 *
794 * the ->blkd_tasks lists and wait for this list to drain. 841 * Wait for an RCU-preempt grace period, but expedite it. The basic
842 * idea is to invoke synchronize_sched_expedited() to push all the tasks to
843 * the ->blkd_tasks lists and wait for this list to drain. This consumes
844 * significant time on all CPUs and is unfriendly to real-time workloads,
845 * so is thus not recommended for any sort of common-case code.
846 * In fact, if you are using synchronize_rcu_expedited() in a loop,
847 * please restructure your code to batch your updates, and then Use a
848 * single synchronize_rcu() instead.
849 *
850 * Note that it is illegal to call this function while holding any lock
851 * that is acquired by a CPU-hotplug notifier. And yes, it is also illegal
852 * to call this function from a CPU-hotplug notifier. Failing to observe
853 * these restriction will result in deadlock.
795 */ 854 */
796void synchronize_rcu_expedited(void) 855void synchronize_rcu_expedited(void)
797{ 856{
@@ -869,9 +928,9 @@ static int rcu_preempt_pending(int cpu)
869} 928}
870 929
871/* 930/*
872 * Does preemptible RCU need the CPU to stay out of dynticks mode? 931 * Does preemptible RCU have callbacks on this CPU?
873 */ 932 */
874static int rcu_preempt_needs_cpu(int cpu) 933static int rcu_preempt_cpu_has_callbacks(int cpu)
875{ 934{
876 return !!per_cpu(rcu_preempt_data, cpu).nxtlist; 935 return !!per_cpu(rcu_preempt_data, cpu).nxtlist;
877} 936}
@@ -894,11 +953,12 @@ static void __cpuinit rcu_preempt_init_percpu_data(int cpu)
894} 953}
895 954
896/* 955/*
897 * Move preemptible RCU's callbacks from dying CPU to other online CPU. 956 * Move preemptible RCU's callbacks from dying CPU to other online CPU
957 * and record a quiescent state.
898 */ 958 */
899static void rcu_preempt_send_cbs_to_online(void) 959static void rcu_preempt_cleanup_dying_cpu(void)
900{ 960{
901 rcu_send_cbs_to_online(&rcu_preempt_state); 961 rcu_cleanup_dying_cpu(&rcu_preempt_state);
902} 962}
903 963
904/* 964/*
@@ -1034,16 +1094,16 @@ static int rcu_preempt_offline_tasks(struct rcu_state *rsp,
1034 return 0; 1094 return 0;
1035} 1095}
1036 1096
1097#endif /* #ifdef CONFIG_HOTPLUG_CPU */
1098
1037/* 1099/*
1038 * Because preemptible RCU does not exist, it never needs CPU-offline 1100 * Because preemptible RCU does not exist, it never needs CPU-offline
1039 * processing. 1101 * processing.
1040 */ 1102 */
1041static void rcu_preempt_offline_cpu(int cpu) 1103static void rcu_preempt_cleanup_dead_cpu(int cpu)
1042{ 1104{
1043} 1105}
1044 1106
1045#endif /* #ifdef CONFIG_HOTPLUG_CPU */
1046
1047/* 1107/*
1048 * Because preemptible RCU does not exist, it never has any callbacks 1108 * Because preemptible RCU does not exist, it never has any callbacks
1049 * to check. 1109 * to check.
@@ -1061,6 +1121,22 @@ static void rcu_preempt_process_callbacks(void)
1061} 1121}
1062 1122
1063/* 1123/*
1124 * Queue an RCU callback for lazy invocation after a grace period.
1125 * This will likely be later named something like "call_rcu_lazy()",
1126 * but this change will require some way of tagging the lazy RCU
1127 * callbacks in the list of pending callbacks. Until then, this
1128 * function may only be called from __kfree_rcu().
1129 *
1130 * Because there is no preemptible RCU, we use RCU-sched instead.
1131 */
1132void kfree_call_rcu(struct rcu_head *head,
1133 void (*func)(struct rcu_head *rcu))
1134{
1135 __call_rcu(head, func, &rcu_sched_state, 1);
1136}
1137EXPORT_SYMBOL_GPL(kfree_call_rcu);
1138
1139/*
1064 * Wait for an rcu-preempt grace period, but make it happen quickly. 1140 * Wait for an rcu-preempt grace period, but make it happen quickly.
1065 * But because preemptible RCU does not exist, map to rcu-sched. 1141 * But because preemptible RCU does not exist, map to rcu-sched.
1066 */ 1142 */
@@ -1093,9 +1169,9 @@ static int rcu_preempt_pending(int cpu)
1093} 1169}
1094 1170
1095/* 1171/*
1096 * Because preemptible RCU does not exist, it never needs any CPU. 1172 * Because preemptible RCU does not exist, it never has callbacks
1097 */ 1173 */
1098static int rcu_preempt_needs_cpu(int cpu) 1174static int rcu_preempt_cpu_has_callbacks(int cpu)
1099{ 1175{
1100 return 0; 1176 return 0;
1101} 1177}
@@ -1119,9 +1195,9 @@ static void __cpuinit rcu_preempt_init_percpu_data(int cpu)
1119} 1195}
1120 1196
1121/* 1197/*
1122 * Because there is no preemptible RCU, there are no callbacks to move. 1198 * Because there is no preemptible RCU, there is no cleanup to do.
1123 */ 1199 */
1124static void rcu_preempt_send_cbs_to_online(void) 1200static void rcu_preempt_cleanup_dying_cpu(void)
1125{ 1201{
1126} 1202}
1127 1203
@@ -1823,132 +1899,6 @@ static void __cpuinit rcu_prepare_kthreads(int cpu)
1823 1899
1824#endif /* #else #ifdef CONFIG_RCU_BOOST */ 1900#endif /* #else #ifdef CONFIG_RCU_BOOST */
1825 1901
1826#ifndef CONFIG_SMP
1827
1828void synchronize_sched_expedited(void)
1829{
1830 cond_resched();
1831}
1832EXPORT_SYMBOL_GPL(synchronize_sched_expedited);
1833
1834#else /* #ifndef CONFIG_SMP */
1835
1836static atomic_t sync_sched_expedited_started = ATOMIC_INIT(0);
1837static atomic_t sync_sched_expedited_done = ATOMIC_INIT(0);
1838
1839static int synchronize_sched_expedited_cpu_stop(void *data)
1840{
1841 /*
1842 * There must be a full memory barrier on each affected CPU
1843 * between the time that try_stop_cpus() is called and the
1844 * time that it returns.
1845 *
1846 * In the current initial implementation of cpu_stop, the
1847 * above condition is already met when the control reaches
1848 * this point and the following smp_mb() is not strictly
1849 * necessary. Do smp_mb() anyway for documentation and
1850 * robustness against future implementation changes.
1851 */
1852 smp_mb(); /* See above comment block. */
1853 return 0;
1854}
1855
1856/*
1857 * Wait for an rcu-sched grace period to elapse, but use "big hammer"
1858 * approach to force grace period to end quickly. This consumes
1859 * significant time on all CPUs, and is thus not recommended for
1860 * any sort of common-case code.
1861 *
1862 * Note that it is illegal to call this function while holding any
1863 * lock that is acquired by a CPU-hotplug notifier. Failing to
1864 * observe this restriction will result in deadlock.
1865 *
1866 * This implementation can be thought of as an application of ticket
1867 * locking to RCU, with sync_sched_expedited_started and
1868 * sync_sched_expedited_done taking on the roles of the halves
1869 * of the ticket-lock word. Each task atomically increments
1870 * sync_sched_expedited_started upon entry, snapshotting the old value,
1871 * then attempts to stop all the CPUs. If this succeeds, then each
1872 * CPU will have executed a context switch, resulting in an RCU-sched
1873 * grace period. We are then done, so we use atomic_cmpxchg() to
1874 * update sync_sched_expedited_done to match our snapshot -- but
1875 * only if someone else has not already advanced past our snapshot.
1876 *
1877 * On the other hand, if try_stop_cpus() fails, we check the value
1878 * of sync_sched_expedited_done. If it has advanced past our
1879 * initial snapshot, then someone else must have forced a grace period
1880 * some time after we took our snapshot. In this case, our work is
1881 * done for us, and we can simply return. Otherwise, we try again,
1882 * but keep our initial snapshot for purposes of checking for someone
1883 * doing our work for us.
1884 *
1885 * If we fail too many times in a row, we fall back to synchronize_sched().
1886 */
1887void synchronize_sched_expedited(void)
1888{
1889 int firstsnap, s, snap, trycount = 0;
1890
1891 /* Note that atomic_inc_return() implies full memory barrier. */
1892 firstsnap = snap = atomic_inc_return(&sync_sched_expedited_started);
1893 get_online_cpus();
1894
1895 /*
1896 * Each pass through the following loop attempts to force a
1897 * context switch on each CPU.
1898 */
1899 while (try_stop_cpus(cpu_online_mask,
1900 synchronize_sched_expedited_cpu_stop,
1901 NULL) == -EAGAIN) {
1902 put_online_cpus();
1903
1904 /* No joy, try again later. Or just synchronize_sched(). */
1905 if (trycount++ < 10)
1906 udelay(trycount * num_online_cpus());
1907 else {
1908 synchronize_sched();
1909 return;
1910 }
1911
1912 /* Check to see if someone else did our work for us. */
1913 s = atomic_read(&sync_sched_expedited_done);
1914 if (UINT_CMP_GE((unsigned)s, (unsigned)firstsnap)) {
1915 smp_mb(); /* ensure test happens before caller kfree */
1916 return;
1917 }
1918
1919 /*
1920 * Refetching sync_sched_expedited_started allows later
1921 * callers to piggyback on our grace period. We subtract
1922 * 1 to get the same token that the last incrementer got.
1923 * We retry after they started, so our grace period works
1924 * for them, and they started after our first try, so their
1925 * grace period works for us.
1926 */
1927 get_online_cpus();
1928 snap = atomic_read(&sync_sched_expedited_started);
1929 smp_mb(); /* ensure read is before try_stop_cpus(). */
1930 }
1931
1932 /*
1933 * Everyone up to our most recent fetch is covered by our grace
1934 * period. Update the counter, but only if our work is still
1935 * relevant -- which it won't be if someone who started later
1936 * than we did beat us to the punch.
1937 */
1938 do {
1939 s = atomic_read(&sync_sched_expedited_done);
1940 if (UINT_CMP_GE((unsigned)s, (unsigned)snap)) {
1941 smp_mb(); /* ensure test happens before caller kfree */
1942 break;
1943 }
1944 } while (atomic_cmpxchg(&sync_sched_expedited_done, s, snap) != s);
1945
1946 put_online_cpus();
1947}
1948EXPORT_SYMBOL_GPL(synchronize_sched_expedited);
1949
1950#endif /* #else #ifndef CONFIG_SMP */
1951
1952#if !defined(CONFIG_RCU_FAST_NO_HZ) 1902#if !defined(CONFIG_RCU_FAST_NO_HZ)
1953 1903
1954/* 1904/*
@@ -1981,7 +1931,7 @@ static void rcu_cleanup_after_idle(int cpu)
1981} 1931}
1982 1932
1983/* 1933/*
1984 * Do the idle-entry grace-period work, which, because CONFIG_RCU_FAST_NO_HZ=y, 1934 * Do the idle-entry grace-period work, which, because CONFIG_RCU_FAST_NO_HZ=n,
1985 * is nothing. 1935 * is nothing.
1986 */ 1936 */
1987static void rcu_prepare_for_idle(int cpu) 1937static void rcu_prepare_for_idle(int cpu)
@@ -2015,6 +1965,9 @@ static void rcu_prepare_for_idle(int cpu)
2015 * number, be warned: Setting RCU_IDLE_GP_DELAY too high can hang your 1965 * number, be warned: Setting RCU_IDLE_GP_DELAY too high can hang your
2016 * system. And if you are -that- concerned about energy efficiency, 1966 * system. And if you are -that- concerned about energy efficiency,
2017 * just power the system down and be done with it! 1967 * just power the system down and be done with it!
1968 * RCU_IDLE_LAZY_GP_DELAY gives the number of jiffies that a CPU is
1969 * permitted to sleep in dyntick-idle mode with only lazy RCU
1970 * callbacks pending. Setting this too high can OOM your system.
2018 * 1971 *
2019 * The values below work well in practice. If future workloads require 1972 * The values below work well in practice. If future workloads require
2020 * adjustment, they can be converted into kernel config parameters, though 1973 * adjustment, they can be converted into kernel config parameters, though
@@ -2023,11 +1976,13 @@ static void rcu_prepare_for_idle(int cpu)
2023#define RCU_IDLE_FLUSHES 5 /* Number of dyntick-idle tries. */ 1976#define RCU_IDLE_FLUSHES 5 /* Number of dyntick-idle tries. */
2024#define RCU_IDLE_OPT_FLUSHES 3 /* Optional dyntick-idle tries. */ 1977#define RCU_IDLE_OPT_FLUSHES 3 /* Optional dyntick-idle tries. */
2025#define RCU_IDLE_GP_DELAY 6 /* Roughly one grace period. */ 1978#define RCU_IDLE_GP_DELAY 6 /* Roughly one grace period. */
1979#define RCU_IDLE_LAZY_GP_DELAY (6 * HZ) /* Roughly six seconds. */
2026 1980
2027static DEFINE_PER_CPU(int, rcu_dyntick_drain); 1981static DEFINE_PER_CPU(int, rcu_dyntick_drain);
2028static DEFINE_PER_CPU(unsigned long, rcu_dyntick_holdoff); 1982static DEFINE_PER_CPU(unsigned long, rcu_dyntick_holdoff);
2029static DEFINE_PER_CPU(struct hrtimer, rcu_idle_gp_timer); 1983static DEFINE_PER_CPU(struct hrtimer, rcu_idle_gp_timer);
2030static ktime_t rcu_idle_gp_wait; 1984static ktime_t rcu_idle_gp_wait; /* If some non-lazy callbacks. */
1985static ktime_t rcu_idle_lazy_gp_wait; /* If only lazy callbacks. */
2031 1986
2032/* 1987/*
2033 * Allow the CPU to enter dyntick-idle mode if either: (1) There are no 1988 * Allow the CPU to enter dyntick-idle mode if either: (1) There are no
@@ -2048,6 +2003,48 @@ int rcu_needs_cpu(int cpu)
2048} 2003}
2049 2004
2050/* 2005/*
2006 * Does the specified flavor of RCU have non-lazy callbacks pending on
2007 * the specified CPU? Both RCU flavor and CPU are specified by the
2008 * rcu_data structure.
2009 */
2010static bool __rcu_cpu_has_nonlazy_callbacks(struct rcu_data *rdp)
2011{
2012 return rdp->qlen != rdp->qlen_lazy;
2013}
2014
2015#ifdef CONFIG_TREE_PREEMPT_RCU
2016
2017/*
2018 * Are there non-lazy RCU-preempt callbacks? (There cannot be if there
2019 * is no RCU-preempt in the kernel.)
2020 */
2021static bool rcu_preempt_cpu_has_nonlazy_callbacks(int cpu)
2022{
2023 struct rcu_data *rdp = &per_cpu(rcu_preempt_data, cpu);
2024
2025 return __rcu_cpu_has_nonlazy_callbacks(rdp);
2026}
2027
2028#else /* #ifdef CONFIG_TREE_PREEMPT_RCU */
2029
2030static bool rcu_preempt_cpu_has_nonlazy_callbacks(int cpu)
2031{
2032 return 0;
2033}
2034
2035#endif /* else #ifdef CONFIG_TREE_PREEMPT_RCU */
2036
2037/*
2038 * Does any flavor of RCU have non-lazy callbacks on the specified CPU?
2039 */
2040static bool rcu_cpu_has_nonlazy_callbacks(int cpu)
2041{
2042 return __rcu_cpu_has_nonlazy_callbacks(&per_cpu(rcu_sched_data, cpu)) ||
2043 __rcu_cpu_has_nonlazy_callbacks(&per_cpu(rcu_bh_data, cpu)) ||
2044 rcu_preempt_cpu_has_nonlazy_callbacks(cpu);
2045}
2046
2047/*
2051 * Timer handler used to force CPU to start pushing its remaining RCU 2048 * Timer handler used to force CPU to start pushing its remaining RCU
2052 * callbacks in the case where it entered dyntick-idle mode with callbacks 2049 * callbacks in the case where it entered dyntick-idle mode with callbacks
2053 * pending. The hander doesn't really need to do anything because the 2050 * pending. The hander doesn't really need to do anything because the
@@ -2074,6 +2071,8 @@ static void rcu_prepare_for_idle_init(int cpu)
2074 unsigned int upj = jiffies_to_usecs(RCU_IDLE_GP_DELAY); 2071 unsigned int upj = jiffies_to_usecs(RCU_IDLE_GP_DELAY);
2075 2072
2076 rcu_idle_gp_wait = ns_to_ktime(upj * (u64)1000); 2073 rcu_idle_gp_wait = ns_to_ktime(upj * (u64)1000);
2074 upj = jiffies_to_usecs(RCU_IDLE_LAZY_GP_DELAY);
2075 rcu_idle_lazy_gp_wait = ns_to_ktime(upj * (u64)1000);
2077 firsttime = 0; 2076 firsttime = 0;
2078 } 2077 }
2079} 2078}
@@ -2109,10 +2108,6 @@ static void rcu_cleanup_after_idle(int cpu)
2109 */ 2108 */
2110static void rcu_prepare_for_idle(int cpu) 2109static void rcu_prepare_for_idle(int cpu)
2111{ 2110{
2112 unsigned long flags;
2113
2114 local_irq_save(flags);
2115
2116 /* 2111 /*
2117 * If there are no callbacks on this CPU, enter dyntick-idle mode. 2112 * If there are no callbacks on this CPU, enter dyntick-idle mode.
2118 * Also reset state to avoid prejudicing later attempts. 2113 * Also reset state to avoid prejudicing later attempts.
@@ -2120,7 +2115,6 @@ static void rcu_prepare_for_idle(int cpu)
2120 if (!rcu_cpu_has_callbacks(cpu)) { 2115 if (!rcu_cpu_has_callbacks(cpu)) {
2121 per_cpu(rcu_dyntick_holdoff, cpu) = jiffies - 1; 2116 per_cpu(rcu_dyntick_holdoff, cpu) = jiffies - 1;
2122 per_cpu(rcu_dyntick_drain, cpu) = 0; 2117 per_cpu(rcu_dyntick_drain, cpu) = 0;
2123 local_irq_restore(flags);
2124 trace_rcu_prep_idle("No callbacks"); 2118 trace_rcu_prep_idle("No callbacks");
2125 return; 2119 return;
2126 } 2120 }
@@ -2130,7 +2124,6 @@ static void rcu_prepare_for_idle(int cpu)
2130 * refrained from disabling the scheduling-clock tick. 2124 * refrained from disabling the scheduling-clock tick.
2131 */ 2125 */
2132 if (per_cpu(rcu_dyntick_holdoff, cpu) == jiffies) { 2126 if (per_cpu(rcu_dyntick_holdoff, cpu) == jiffies) {
2133 local_irq_restore(flags);
2134 trace_rcu_prep_idle("In holdoff"); 2127 trace_rcu_prep_idle("In holdoff");
2135 return; 2128 return;
2136 } 2129 }
@@ -2140,18 +2133,22 @@ static void rcu_prepare_for_idle(int cpu)
2140 /* First time through, initialize the counter. */ 2133 /* First time through, initialize the counter. */
2141 per_cpu(rcu_dyntick_drain, cpu) = RCU_IDLE_FLUSHES; 2134 per_cpu(rcu_dyntick_drain, cpu) = RCU_IDLE_FLUSHES;
2142 } else if (per_cpu(rcu_dyntick_drain, cpu) <= RCU_IDLE_OPT_FLUSHES && 2135 } else if (per_cpu(rcu_dyntick_drain, cpu) <= RCU_IDLE_OPT_FLUSHES &&
2143 !rcu_pending(cpu)) { 2136 !rcu_pending(cpu) &&
2137 !local_softirq_pending()) {
2144 /* Can we go dyntick-idle despite still having callbacks? */ 2138 /* Can we go dyntick-idle despite still having callbacks? */
2145 trace_rcu_prep_idle("Dyntick with callbacks"); 2139 trace_rcu_prep_idle("Dyntick with callbacks");
2146 per_cpu(rcu_dyntick_drain, cpu) = 0; 2140 per_cpu(rcu_dyntick_drain, cpu) = 0;
2147 per_cpu(rcu_dyntick_holdoff, cpu) = jiffies - 1; 2141 per_cpu(rcu_dyntick_holdoff, cpu) = jiffies;
2148 hrtimer_start(&per_cpu(rcu_idle_gp_timer, cpu), 2142 if (rcu_cpu_has_nonlazy_callbacks(cpu))
2149 rcu_idle_gp_wait, HRTIMER_MODE_REL); 2143 hrtimer_start(&per_cpu(rcu_idle_gp_timer, cpu),
2144 rcu_idle_gp_wait, HRTIMER_MODE_REL);
2145 else
2146 hrtimer_start(&per_cpu(rcu_idle_gp_timer, cpu),
2147 rcu_idle_lazy_gp_wait, HRTIMER_MODE_REL);
2150 return; /* Nothing more to do immediately. */ 2148 return; /* Nothing more to do immediately. */
2151 } else if (--per_cpu(rcu_dyntick_drain, cpu) <= 0) { 2149 } else if (--per_cpu(rcu_dyntick_drain, cpu) <= 0) {
2152 /* We have hit the limit, so time to give up. */ 2150 /* We have hit the limit, so time to give up. */
2153 per_cpu(rcu_dyntick_holdoff, cpu) = jiffies; 2151 per_cpu(rcu_dyntick_holdoff, cpu) = jiffies;
2154 local_irq_restore(flags);
2155 trace_rcu_prep_idle("Begin holdoff"); 2152 trace_rcu_prep_idle("Begin holdoff");
2156 invoke_rcu_core(); /* Force the CPU out of dyntick-idle. */ 2153 invoke_rcu_core(); /* Force the CPU out of dyntick-idle. */
2157 return; 2154 return;
@@ -2163,23 +2160,17 @@ static void rcu_prepare_for_idle(int cpu)
2163 */ 2160 */
2164#ifdef CONFIG_TREE_PREEMPT_RCU 2161#ifdef CONFIG_TREE_PREEMPT_RCU
2165 if (per_cpu(rcu_preempt_data, cpu).nxtlist) { 2162 if (per_cpu(rcu_preempt_data, cpu).nxtlist) {
2166 local_irq_restore(flags);
2167 rcu_preempt_qs(cpu); 2163 rcu_preempt_qs(cpu);
2168 force_quiescent_state(&rcu_preempt_state, 0); 2164 force_quiescent_state(&rcu_preempt_state, 0);
2169 local_irq_save(flags);
2170 } 2165 }
2171#endif /* #ifdef CONFIG_TREE_PREEMPT_RCU */ 2166#endif /* #ifdef CONFIG_TREE_PREEMPT_RCU */
2172 if (per_cpu(rcu_sched_data, cpu).nxtlist) { 2167 if (per_cpu(rcu_sched_data, cpu).nxtlist) {
2173 local_irq_restore(flags);
2174 rcu_sched_qs(cpu); 2168 rcu_sched_qs(cpu);
2175 force_quiescent_state(&rcu_sched_state, 0); 2169 force_quiescent_state(&rcu_sched_state, 0);
2176 local_irq_save(flags);
2177 } 2170 }
2178 if (per_cpu(rcu_bh_data, cpu).nxtlist) { 2171 if (per_cpu(rcu_bh_data, cpu).nxtlist) {
2179 local_irq_restore(flags);
2180 rcu_bh_qs(cpu); 2172 rcu_bh_qs(cpu);
2181 force_quiescent_state(&rcu_bh_state, 0); 2173 force_quiescent_state(&rcu_bh_state, 0);
2182 local_irq_save(flags);
2183 } 2174 }
2184 2175
2185 /* 2176 /*
@@ -2187,13 +2178,124 @@ static void rcu_prepare_for_idle(int cpu)
2187 * So try forcing the callbacks through the grace period. 2178 * So try forcing the callbacks through the grace period.
2188 */ 2179 */
2189 if (rcu_cpu_has_callbacks(cpu)) { 2180 if (rcu_cpu_has_callbacks(cpu)) {
2190 local_irq_restore(flags);
2191 trace_rcu_prep_idle("More callbacks"); 2181 trace_rcu_prep_idle("More callbacks");
2192 invoke_rcu_core(); 2182 invoke_rcu_core();
2193 } else { 2183 } else
2194 local_irq_restore(flags);
2195 trace_rcu_prep_idle("Callbacks drained"); 2184 trace_rcu_prep_idle("Callbacks drained");
2196 }
2197} 2185}
2198 2186
2199#endif /* #else #if !defined(CONFIG_RCU_FAST_NO_HZ) */ 2187#endif /* #else #if !defined(CONFIG_RCU_FAST_NO_HZ) */
2188
2189#ifdef CONFIG_RCU_CPU_STALL_INFO
2190
2191#ifdef CONFIG_RCU_FAST_NO_HZ
2192
2193static void print_cpu_stall_fast_no_hz(char *cp, int cpu)
2194{
2195 struct hrtimer *hrtp = &per_cpu(rcu_idle_gp_timer, cpu);
2196
2197 sprintf(cp, "drain=%d %c timer=%lld",
2198 per_cpu(rcu_dyntick_drain, cpu),
2199 per_cpu(rcu_dyntick_holdoff, cpu) == jiffies ? 'H' : '.',
2200 hrtimer_active(hrtp)
2201 ? ktime_to_us(hrtimer_get_remaining(hrtp))
2202 : -1);
2203}
2204
2205#else /* #ifdef CONFIG_RCU_FAST_NO_HZ */
2206
2207static void print_cpu_stall_fast_no_hz(char *cp, int cpu)
2208{
2209}
2210
2211#endif /* #else #ifdef CONFIG_RCU_FAST_NO_HZ */
2212
2213/* Initiate the stall-info list. */
2214static void print_cpu_stall_info_begin(void)
2215{
2216 printk(KERN_CONT "\n");
2217}
2218
2219/*
2220 * Print out diagnostic information for the specified stalled CPU.
2221 *
2222 * If the specified CPU is aware of the current RCU grace period
2223 * (flavor specified by rsp), then print the number of scheduling
2224 * clock interrupts the CPU has taken during the time that it has
2225 * been aware. Otherwise, print the number of RCU grace periods
2226 * that this CPU is ignorant of, for example, "1" if the CPU was
2227 * aware of the previous grace period.
2228 *
2229 * Also print out idle and (if CONFIG_RCU_FAST_NO_HZ) idle-entry info.
2230 */
2231static void print_cpu_stall_info(struct rcu_state *rsp, int cpu)
2232{
2233 char fast_no_hz[72];
2234 struct rcu_data *rdp = per_cpu_ptr(rsp->rda, cpu);
2235 struct rcu_dynticks *rdtp = rdp->dynticks;
2236 char *ticks_title;
2237 unsigned long ticks_value;
2238
2239 if (rsp->gpnum == rdp->gpnum) {
2240 ticks_title = "ticks this GP";
2241 ticks_value = rdp->ticks_this_gp;
2242 } else {
2243 ticks_title = "GPs behind";
2244 ticks_value = rsp->gpnum - rdp->gpnum;
2245 }
2246 print_cpu_stall_fast_no_hz(fast_no_hz, cpu);
2247 printk(KERN_ERR "\t%d: (%lu %s) idle=%03x/%llx/%d %s\n",
2248 cpu, ticks_value, ticks_title,
2249 atomic_read(&rdtp->dynticks) & 0xfff,
2250 rdtp->dynticks_nesting, rdtp->dynticks_nmi_nesting,
2251 fast_no_hz);
2252}
2253
2254/* Terminate the stall-info list. */
2255static void print_cpu_stall_info_end(void)
2256{
2257 printk(KERN_ERR "\t");
2258}
2259
2260/* Zero ->ticks_this_gp for all flavors of RCU. */
2261static void zero_cpu_stall_ticks(struct rcu_data *rdp)
2262{
2263 rdp->ticks_this_gp = 0;
2264}
2265
2266/* Increment ->ticks_this_gp for all flavors of RCU. */
2267static void increment_cpu_stall_ticks(void)
2268{
2269 __get_cpu_var(rcu_sched_data).ticks_this_gp++;
2270 __get_cpu_var(rcu_bh_data).ticks_this_gp++;
2271#ifdef CONFIG_TREE_PREEMPT_RCU
2272 __get_cpu_var(rcu_preempt_data).ticks_this_gp++;
2273#endif /* #ifdef CONFIG_TREE_PREEMPT_RCU */
2274}
2275
2276#else /* #ifdef CONFIG_RCU_CPU_STALL_INFO */
2277
2278static void print_cpu_stall_info_begin(void)
2279{
2280 printk(KERN_CONT " {");
2281}
2282
2283static void print_cpu_stall_info(struct rcu_state *rsp, int cpu)
2284{
2285 printk(KERN_CONT " %d", cpu);
2286}
2287
2288static void print_cpu_stall_info_end(void)
2289{
2290 printk(KERN_CONT "} ");
2291}
2292
2293static void zero_cpu_stall_ticks(struct rcu_data *rdp)
2294{
2295}
2296
2297static void increment_cpu_stall_ticks(void)
2298{
2299}
2300
2301#endif /* #else #ifdef CONFIG_RCU_CPU_STALL_INFO */
diff --git a/kernel/rcutree_trace.c b/kernel/rcutree_trace.c
index 654cfe67f0d1..ed459edeff43 100644
--- a/kernel/rcutree_trace.c
+++ b/kernel/rcutree_trace.c
@@ -72,9 +72,9 @@ static void print_one_rcu_data(struct seq_file *m, struct rcu_data *rdp)
72 rdp->dynticks->dynticks_nesting, 72 rdp->dynticks->dynticks_nesting,
73 rdp->dynticks->dynticks_nmi_nesting, 73 rdp->dynticks->dynticks_nmi_nesting,
74 rdp->dynticks_fqs); 74 rdp->dynticks_fqs);
75 seq_printf(m, " of=%lu ri=%lu", rdp->offline_fqs, rdp->resched_ipi); 75 seq_printf(m, " of=%lu", rdp->offline_fqs);
76 seq_printf(m, " ql=%ld qs=%c%c%c%c", 76 seq_printf(m, " ql=%ld/%ld qs=%c%c%c%c",
77 rdp->qlen, 77 rdp->qlen_lazy, rdp->qlen,
78 ".N"[rdp->nxttail[RCU_NEXT_READY_TAIL] != 78 ".N"[rdp->nxttail[RCU_NEXT_READY_TAIL] !=
79 rdp->nxttail[RCU_NEXT_TAIL]], 79 rdp->nxttail[RCU_NEXT_TAIL]],
80 ".R"[rdp->nxttail[RCU_WAIT_TAIL] != 80 ".R"[rdp->nxttail[RCU_WAIT_TAIL] !=
@@ -144,8 +144,8 @@ static void print_one_rcu_data_csv(struct seq_file *m, struct rcu_data *rdp)
144 rdp->dynticks->dynticks_nesting, 144 rdp->dynticks->dynticks_nesting,
145 rdp->dynticks->dynticks_nmi_nesting, 145 rdp->dynticks->dynticks_nmi_nesting,
146 rdp->dynticks_fqs); 146 rdp->dynticks_fqs);
147 seq_printf(m, ",%lu,%lu", rdp->offline_fqs, rdp->resched_ipi); 147 seq_printf(m, ",%lu", rdp->offline_fqs);
148 seq_printf(m, ",%ld,\"%c%c%c%c\"", rdp->qlen, 148 seq_printf(m, ",%ld,%ld,\"%c%c%c%c\"", rdp->qlen_lazy, rdp->qlen,
149 ".N"[rdp->nxttail[RCU_NEXT_READY_TAIL] != 149 ".N"[rdp->nxttail[RCU_NEXT_READY_TAIL] !=
150 rdp->nxttail[RCU_NEXT_TAIL]], 150 rdp->nxttail[RCU_NEXT_TAIL]],
151 ".R"[rdp->nxttail[RCU_WAIT_TAIL] != 151 ".R"[rdp->nxttail[RCU_WAIT_TAIL] !=
@@ -168,7 +168,7 @@ static int show_rcudata_csv(struct seq_file *m, void *unused)
168{ 168{
169 seq_puts(m, "\"CPU\",\"Online?\",\"c\",\"g\",\"pq\",\"pgp\",\"pq\","); 169 seq_puts(m, "\"CPU\",\"Online?\",\"c\",\"g\",\"pq\",\"pgp\",\"pq\",");
170 seq_puts(m, "\"dt\",\"dt nesting\",\"dt NMI nesting\",\"df\","); 170 seq_puts(m, "\"dt\",\"dt nesting\",\"dt NMI nesting\",\"df\",");
171 seq_puts(m, "\"of\",\"ri\",\"ql\",\"qs\""); 171 seq_puts(m, "\"of\",\"qll\",\"ql\",\"qs\"");
172#ifdef CONFIG_RCU_BOOST 172#ifdef CONFIG_RCU_BOOST
173 seq_puts(m, "\"kt\",\"ktl\""); 173 seq_puts(m, "\"kt\",\"ktl\"");
174#endif /* #ifdef CONFIG_RCU_BOOST */ 174#endif /* #ifdef CONFIG_RCU_BOOST */
diff --git a/kernel/sched/auto_group.c b/kernel/sched/auto_group.c
index e8a1f83ee0e7..0984a21076a3 100644
--- a/kernel/sched/auto_group.c
+++ b/kernel/sched/auto_group.c
@@ -195,20 +195,20 @@ __setup("noautogroup", setup_autogroup);
195 195
196#ifdef CONFIG_PROC_FS 196#ifdef CONFIG_PROC_FS
197 197
198int proc_sched_autogroup_set_nice(struct task_struct *p, int *nice) 198int proc_sched_autogroup_set_nice(struct task_struct *p, int nice)
199{ 199{
200 static unsigned long next = INITIAL_JIFFIES; 200 static unsigned long next = INITIAL_JIFFIES;
201 struct autogroup *ag; 201 struct autogroup *ag;
202 int err; 202 int err;
203 203
204 if (*nice < -20 || *nice > 19) 204 if (nice < -20 || nice > 19)
205 return -EINVAL; 205 return -EINVAL;
206 206
207 err = security_task_setnice(current, *nice); 207 err = security_task_setnice(current, nice);
208 if (err) 208 if (err)
209 return err; 209 return err;
210 210
211 if (*nice < 0 && !can_nice(current, *nice)) 211 if (nice < 0 && !can_nice(current, nice))
212 return -EPERM; 212 return -EPERM;
213 213
214 /* this is a heavy operation taking global locks.. */ 214 /* this is a heavy operation taking global locks.. */
@@ -219,9 +219,9 @@ int proc_sched_autogroup_set_nice(struct task_struct *p, int *nice)
219 ag = autogroup_task_get(p); 219 ag = autogroup_task_get(p);
220 220
221 down_write(&ag->lock); 221 down_write(&ag->lock);
222 err = sched_group_set_shares(ag->tg, prio_to_weight[*nice + 20]); 222 err = sched_group_set_shares(ag->tg, prio_to_weight[nice + 20]);
223 if (!err) 223 if (!err)
224 ag->nice = *nice; 224 ag->nice = nice;
225 up_write(&ag->lock); 225 up_write(&ag->lock);
226 226
227 autogroup_kref_put(ag); 227 autogroup_kref_put(ag);
diff --git a/kernel/sched/core.c b/kernel/sched/core.c
index b342f57879e6..d2bd4647586c 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -162,13 +162,13 @@ static int sched_feat_show(struct seq_file *m, void *v)
162 162
163#ifdef HAVE_JUMP_LABEL 163#ifdef HAVE_JUMP_LABEL
164 164
165#define jump_label_key__true jump_label_key_enabled 165#define jump_label_key__true STATIC_KEY_INIT_TRUE
166#define jump_label_key__false jump_label_key_disabled 166#define jump_label_key__false STATIC_KEY_INIT_FALSE
167 167
168#define SCHED_FEAT(name, enabled) \ 168#define SCHED_FEAT(name, enabled) \
169 jump_label_key__##enabled , 169 jump_label_key__##enabled ,
170 170
171struct jump_label_key sched_feat_keys[__SCHED_FEAT_NR] = { 171struct static_key sched_feat_keys[__SCHED_FEAT_NR] = {
172#include "features.h" 172#include "features.h"
173}; 173};
174 174
@@ -176,14 +176,14 @@ struct jump_label_key sched_feat_keys[__SCHED_FEAT_NR] = {
176 176
177static void sched_feat_disable(int i) 177static void sched_feat_disable(int i)
178{ 178{
179 if (jump_label_enabled(&sched_feat_keys[i])) 179 if (static_key_enabled(&sched_feat_keys[i]))
180 jump_label_dec(&sched_feat_keys[i]); 180 static_key_slow_dec(&sched_feat_keys[i]);
181} 181}
182 182
183static void sched_feat_enable(int i) 183static void sched_feat_enable(int i)
184{ 184{
185 if (!jump_label_enabled(&sched_feat_keys[i])) 185 if (!static_key_enabled(&sched_feat_keys[i]))
186 jump_label_inc(&sched_feat_keys[i]); 186 static_key_slow_inc(&sched_feat_keys[i]);
187} 187}
188#else 188#else
189static void sched_feat_disable(int i) { }; 189static void sched_feat_disable(int i) { };
@@ -894,7 +894,7 @@ static void update_rq_clock_task(struct rq *rq, s64 delta)
894 delta -= irq_delta; 894 delta -= irq_delta;
895#endif 895#endif
896#ifdef CONFIG_PARAVIRT_TIME_ACCOUNTING 896#ifdef CONFIG_PARAVIRT_TIME_ACCOUNTING
897 if (static_branch((&paravirt_steal_rq_enabled))) { 897 if (static_key_false((&paravirt_steal_rq_enabled))) {
898 u64 st; 898 u64 st;
899 899
900 steal = paravirt_steal_clock(cpu_of(rq)); 900 steal = paravirt_steal_clock(cpu_of(rq));
@@ -1284,7 +1284,7 @@ static int select_fallback_rq(int cpu, struct task_struct *p)
1284 * leave kernel. 1284 * leave kernel.
1285 */ 1285 */
1286 if (p->mm && printk_ratelimit()) { 1286 if (p->mm && printk_ratelimit()) {
1287 printk(KERN_INFO "process %d (%s) no longer affine to cpu%d\n", 1287 printk_sched("process %d (%s) no longer affine to cpu%d\n",
1288 task_pid_nr(p), p->comm, cpu); 1288 task_pid_nr(p), p->comm, cpu);
1289 } 1289 }
1290 1290
@@ -1507,7 +1507,7 @@ static int ttwu_activate_remote(struct task_struct *p, int wake_flags)
1507} 1507}
1508#endif /* __ARCH_WANT_INTERRUPTS_ON_CTXSW */ 1508#endif /* __ARCH_WANT_INTERRUPTS_ON_CTXSW */
1509 1509
1510static inline int ttwu_share_cache(int this_cpu, int that_cpu) 1510bool cpus_share_cache(int this_cpu, int that_cpu)
1511{ 1511{
1512 return per_cpu(sd_llc_id, this_cpu) == per_cpu(sd_llc_id, that_cpu); 1512 return per_cpu(sd_llc_id, this_cpu) == per_cpu(sd_llc_id, that_cpu);
1513} 1513}
@@ -1518,7 +1518,7 @@ static void ttwu_queue(struct task_struct *p, int cpu)
1518 struct rq *rq = cpu_rq(cpu); 1518 struct rq *rq = cpu_rq(cpu);
1519 1519
1520#if defined(CONFIG_SMP) 1520#if defined(CONFIG_SMP)
1521 if (sched_feat(TTWU_QUEUE) && !ttwu_share_cache(smp_processor_id(), cpu)) { 1521 if (sched_feat(TTWU_QUEUE) && !cpus_share_cache(smp_processor_id(), cpu)) {
1522 sched_clock_cpu(cpu); /* sync clocks x-cpu */ 1522 sched_clock_cpu(cpu); /* sync clocks x-cpu */
1523 ttwu_queue_remote(p, cpu); 1523 ttwu_queue_remote(p, cpu);
1524 return; 1524 return;
@@ -2266,13 +2266,10 @@ calc_load_n(unsigned long load, unsigned long exp,
2266 * Once we've updated the global active value, we need to apply the exponential 2266 * Once we've updated the global active value, we need to apply the exponential
2267 * weights adjusted to the number of cycles missed. 2267 * weights adjusted to the number of cycles missed.
2268 */ 2268 */
2269static void calc_global_nohz(unsigned long ticks) 2269static void calc_global_nohz(void)
2270{ 2270{
2271 long delta, active, n; 2271 long delta, active, n;
2272 2272
2273 if (time_before(jiffies, calc_load_update))
2274 return;
2275
2276 /* 2273 /*
2277 * If we crossed a calc_load_update boundary, make sure to fold 2274 * If we crossed a calc_load_update boundary, make sure to fold
2278 * any pending idle changes, the respective CPUs might have 2275 * any pending idle changes, the respective CPUs might have
@@ -2284,31 +2281,25 @@ static void calc_global_nohz(unsigned long ticks)
2284 atomic_long_add(delta, &calc_load_tasks); 2281 atomic_long_add(delta, &calc_load_tasks);
2285 2282
2286 /* 2283 /*
2287 * If we were idle for multiple load cycles, apply them. 2284 * It could be the one fold was all it took, we done!
2288 */ 2285 */
2289 if (ticks >= LOAD_FREQ) { 2286 if (time_before(jiffies, calc_load_update + 10))
2290 n = ticks / LOAD_FREQ; 2287 return;
2291 2288
2292 active = atomic_long_read(&calc_load_tasks); 2289 /*
2293 active = active > 0 ? active * FIXED_1 : 0; 2290 * Catch-up, fold however many we are behind still
2291 */
2292 delta = jiffies - calc_load_update - 10;
2293 n = 1 + (delta / LOAD_FREQ);
2294 2294
2295 avenrun[0] = calc_load_n(avenrun[0], EXP_1, active, n); 2295 active = atomic_long_read(&calc_load_tasks);
2296 avenrun[1] = calc_load_n(avenrun[1], EXP_5, active, n); 2296 active = active > 0 ? active * FIXED_1 : 0;
2297 avenrun[2] = calc_load_n(avenrun[2], EXP_15, active, n);
2298 2297
2299 calc_load_update += n * LOAD_FREQ; 2298 avenrun[0] = calc_load_n(avenrun[0], EXP_1, active, n);
2300 } 2299 avenrun[1] = calc_load_n(avenrun[1], EXP_5, active, n);
2300 avenrun[2] = calc_load_n(avenrun[2], EXP_15, active, n);
2301 2301
2302 /* 2302 calc_load_update += n * LOAD_FREQ;
2303 * Its possible the remainder of the above division also crosses
2304 * a LOAD_FREQ period, the regular check in calc_global_load()
2305 * which comes after this will take care of that.
2306 *
2307 * Consider us being 11 ticks before a cycle completion, and us
2308 * sleeping for 4*LOAD_FREQ + 22 ticks, then the above code will
2309 * age us 4 cycles, and the test in calc_global_load() will
2310 * pick up the final one.
2311 */
2312} 2303}
2313#else 2304#else
2314void calc_load_account_idle(struct rq *this_rq) 2305void calc_load_account_idle(struct rq *this_rq)
@@ -2320,7 +2311,7 @@ static inline long calc_load_fold_idle(void)
2320 return 0; 2311 return 0;
2321} 2312}
2322 2313
2323static void calc_global_nohz(unsigned long ticks) 2314static void calc_global_nohz(void)
2324{ 2315{
2325} 2316}
2326#endif 2317#endif
@@ -2348,8 +2339,6 @@ void calc_global_load(unsigned long ticks)
2348{ 2339{
2349 long active; 2340 long active;
2350 2341
2351 calc_global_nohz(ticks);
2352
2353 if (time_before(jiffies, calc_load_update + 10)) 2342 if (time_before(jiffies, calc_load_update + 10))
2354 return; 2343 return;
2355 2344
@@ -2361,6 +2350,16 @@ void calc_global_load(unsigned long ticks)
2361 avenrun[2] = calc_load(avenrun[2], EXP_15, active); 2350 avenrun[2] = calc_load(avenrun[2], EXP_15, active);
2362 2351
2363 calc_load_update += LOAD_FREQ; 2352 calc_load_update += LOAD_FREQ;
2353
2354 /*
2355 * Account one period with whatever state we found before
2356 * folding in the nohz state and ageing the entire idle period.
2357 *
2358 * This avoids loosing a sample when we go idle between
2359 * calc_load_account_active() (10 ticks ago) and now and thus
2360 * under-accounting.
2361 */
2362 calc_global_nohz();
2364} 2363}
2365 2364
2366/* 2365/*
@@ -2755,7 +2754,7 @@ void account_idle_time(cputime_t cputime)
2755static __always_inline bool steal_account_process_tick(void) 2754static __always_inline bool steal_account_process_tick(void)
2756{ 2755{
2757#ifdef CONFIG_PARAVIRT 2756#ifdef CONFIG_PARAVIRT
2758 if (static_branch(&paravirt_steal_enabled)) { 2757 if (static_key_false(&paravirt_steal_enabled)) {
2759 u64 steal, st = 0; 2758 u64 steal, st = 0;
2760 2759
2761 steal = paravirt_steal_clock(smp_processor_id()); 2760 steal = paravirt_steal_clock(smp_processor_id());
@@ -3220,14 +3219,14 @@ need_resched:
3220 3219
3221 post_schedule(rq); 3220 post_schedule(rq);
3222 3221
3223 preempt_enable_no_resched(); 3222 sched_preempt_enable_no_resched();
3224 if (need_resched()) 3223 if (need_resched())
3225 goto need_resched; 3224 goto need_resched;
3226} 3225}
3227 3226
3228static inline void sched_submit_work(struct task_struct *tsk) 3227static inline void sched_submit_work(struct task_struct *tsk)
3229{ 3228{
3230 if (!tsk->state) 3229 if (!tsk->state || tsk_is_pi_blocked(tsk))
3231 return; 3230 return;
3232 /* 3231 /*
3233 * If we are going to sleep and we have plugged IO queued, 3232 * If we are going to sleep and we have plugged IO queued,
@@ -3246,6 +3245,18 @@ asmlinkage void __sched schedule(void)
3246} 3245}
3247EXPORT_SYMBOL(schedule); 3246EXPORT_SYMBOL(schedule);
3248 3247
3248/**
3249 * schedule_preempt_disabled - called with preemption disabled
3250 *
3251 * Returns with preemption disabled. Note: preempt_count must be 1
3252 */
3253void __sched schedule_preempt_disabled(void)
3254{
3255 sched_preempt_enable_no_resched();
3256 schedule();
3257 preempt_disable();
3258}
3259
3249#ifdef CONFIG_MUTEX_SPIN_ON_OWNER 3260#ifdef CONFIG_MUTEX_SPIN_ON_OWNER
3250 3261
3251static inline bool owner_running(struct mutex *lock, struct task_struct *owner) 3262static inline bool owner_running(struct mutex *lock, struct task_struct *owner)
@@ -3406,9 +3417,9 @@ EXPORT_SYMBOL(__wake_up);
3406/* 3417/*
3407 * Same as __wake_up but called with the spinlock in wait_queue_head_t held. 3418 * Same as __wake_up but called with the spinlock in wait_queue_head_t held.
3408 */ 3419 */
3409void __wake_up_locked(wait_queue_head_t *q, unsigned int mode) 3420void __wake_up_locked(wait_queue_head_t *q, unsigned int mode, int nr)
3410{ 3421{
3411 __wake_up_common(q, mode, 1, 0, NULL); 3422 __wake_up_common(q, mode, nr, 0, NULL);
3412} 3423}
3413EXPORT_SYMBOL_GPL(__wake_up_locked); 3424EXPORT_SYMBOL_GPL(__wake_up_locked);
3414 3425
@@ -3767,6 +3778,24 @@ void rt_mutex_setprio(struct task_struct *p, int prio)
3767 3778
3768 rq = __task_rq_lock(p); 3779 rq = __task_rq_lock(p);
3769 3780
3781 /*
3782 * Idle task boosting is a nono in general. There is one
3783 * exception, when PREEMPT_RT and NOHZ is active:
3784 *
3785 * The idle task calls get_next_timer_interrupt() and holds
3786 * the timer wheel base->lock on the CPU and another CPU wants
3787 * to access the timer (probably to cancel it). We can safely
3788 * ignore the boosting request, as the idle CPU runs this code
3789 * with interrupts disabled and will complete the lock
3790 * protected section without being interrupted. So there is no
3791 * real need to boost.
3792 */
3793 if (unlikely(p == rq->idle)) {
3794 WARN_ON(p != rq->curr);
3795 WARN_ON(p->pi_blocked_on);
3796 goto out_unlock;
3797 }
3798
3770 trace_sched_pi_setprio(p, prio); 3799 trace_sched_pi_setprio(p, prio);
3771 oldprio = p->prio; 3800 oldprio = p->prio;
3772 prev_class = p->sched_class; 3801 prev_class = p->sched_class;
@@ -3790,11 +3819,10 @@ void rt_mutex_setprio(struct task_struct *p, int prio)
3790 enqueue_task(rq, p, oldprio < prio ? ENQUEUE_HEAD : 0); 3819 enqueue_task(rq, p, oldprio < prio ? ENQUEUE_HEAD : 0);
3791 3820
3792 check_class_changed(rq, p, prev_class, oldprio); 3821 check_class_changed(rq, p, prev_class, oldprio);
3822out_unlock:
3793 __task_rq_unlock(rq); 3823 __task_rq_unlock(rq);
3794} 3824}
3795
3796#endif 3825#endif
3797
3798void set_user_nice(struct task_struct *p, long nice) 3826void set_user_nice(struct task_struct *p, long nice)
3799{ 3827{
3800 int old_prio, delta, on_rq; 3828 int old_prio, delta, on_rq;
@@ -4474,7 +4502,7 @@ SYSCALL_DEFINE0(sched_yield)
4474 __release(rq->lock); 4502 __release(rq->lock);
4475 spin_release(&rq->lock.dep_map, 1, _THIS_IP_); 4503 spin_release(&rq->lock.dep_map, 1, _THIS_IP_);
4476 do_raw_spin_unlock(&rq->lock); 4504 do_raw_spin_unlock(&rq->lock);
4477 preempt_enable_no_resched(); 4505 sched_preempt_enable_no_resched();
4478 4506
4479 schedule(); 4507 schedule();
4480 4508
@@ -4548,8 +4576,24 @@ EXPORT_SYMBOL(__cond_resched_softirq);
4548/** 4576/**
4549 * yield - yield the current processor to other threads. 4577 * yield - yield the current processor to other threads.
4550 * 4578 *
4551 * This is a shortcut for kernel-space yielding - it marks the 4579 * Do not ever use this function, there's a 99% chance you're doing it wrong.
4552 * thread runnable and calls sys_sched_yield(). 4580 *
4581 * The scheduler is at all times free to pick the calling task as the most
4582 * eligible task to run, if removing the yield() call from your code breaks
4583 * it, its already broken.
4584 *
4585 * Typical broken usage is:
4586 *
4587 * while (!event)
4588 * yield();
4589 *
4590 * where one assumes that yield() will let 'the other' process run that will
4591 * make event true. If the current task is a SCHED_FIFO task that will never
4592 * happen. Never use yield() as a progress guarantee!!
4593 *
4594 * If you want to use yield() to wait for something, use wait_event().
4595 * If you want to use yield() to be 'nice' for others, use cond_resched().
4596 * If you still want to use yield(), do not!
4553 */ 4597 */
4554void __sched yield(void) 4598void __sched yield(void)
4555{ 4599{
@@ -5381,7 +5425,7 @@ static int __cpuinit sched_cpu_active(struct notifier_block *nfb,
5381 unsigned long action, void *hcpu) 5425 unsigned long action, void *hcpu)
5382{ 5426{
5383 switch (action & ~CPU_TASKS_FROZEN) { 5427 switch (action & ~CPU_TASKS_FROZEN) {
5384 case CPU_ONLINE: 5428 case CPU_STARTING:
5385 case CPU_DOWN_FAILED: 5429 case CPU_DOWN_FAILED:
5386 set_cpu_active((long)hcpu, true); 5430 set_cpu_active((long)hcpu, true);
5387 return NOTIFY_OK; 5431 return NOTIFY_OK;
@@ -5753,7 +5797,7 @@ static void destroy_sched_domains(struct sched_domain *sd, int cpu)
5753 * 5797 *
5754 * Also keep a unique ID per domain (we use the first cpu number in 5798 * Also keep a unique ID per domain (we use the first cpu number in
5755 * the cpumask of the domain), this allows us to quickly tell if 5799 * the cpumask of the domain), this allows us to quickly tell if
5756 * two cpus are in the same cache domain, see ttwu_share_cache(). 5800 * two cpus are in the same cache domain, see cpus_share_cache().
5757 */ 5801 */
5758DEFINE_PER_CPU(struct sched_domain *, sd_llc); 5802DEFINE_PER_CPU(struct sched_domain *, sd_llc);
5759DEFINE_PER_CPU(int, sd_llc_id); 5803DEFINE_PER_CPU(int, sd_llc_id);
@@ -6930,6 +6974,9 @@ void __init sched_init(void)
6930 rq->online = 0; 6974 rq->online = 0;
6931 rq->idle_stamp = 0; 6975 rq->idle_stamp = 0;
6932 rq->avg_idle = 2*sysctl_sched_migration_cost; 6976 rq->avg_idle = 2*sysctl_sched_migration_cost;
6977
6978 INIT_LIST_HEAD(&rq->cfs_tasks);
6979
6933 rq_attach_root(rq, &def_root_domain); 6980 rq_attach_root(rq, &def_root_domain);
6934#ifdef CONFIG_NO_HZ 6981#ifdef CONFIG_NO_HZ
6935 rq->nohz_flags = 0; 6982 rq->nohz_flags = 0;
diff --git a/kernel/sched/debug.c b/kernel/sched/debug.c
index 2a075e10004b..09acaa15161d 100644
--- a/kernel/sched/debug.c
+++ b/kernel/sched/debug.c
@@ -288,7 +288,6 @@ static void print_cpu(struct seq_file *m, int cpu)
288 288
289 P(yld_count); 289 P(yld_count);
290 290
291 P(sched_switch);
292 P(sched_count); 291 P(sched_count);
293 P(sched_goidle); 292 P(sched_goidle);
294#ifdef CONFIG_SMP 293#ifdef CONFIG_SMP
diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
index aca16b843b7e..94340c7544a9 100644
--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -776,29 +776,16 @@ update_stats_curr_start(struct cfs_rq *cfs_rq, struct sched_entity *se)
776 * Scheduling class queueing methods: 776 * Scheduling class queueing methods:
777 */ 777 */
778 778
779#if defined CONFIG_SMP && defined CONFIG_FAIR_GROUP_SCHED
780static void
781add_cfs_task_weight(struct cfs_rq *cfs_rq, unsigned long weight)
782{
783 cfs_rq->task_weight += weight;
784}
785#else
786static inline void
787add_cfs_task_weight(struct cfs_rq *cfs_rq, unsigned long weight)
788{
789}
790#endif
791
792static void 779static void
793account_entity_enqueue(struct cfs_rq *cfs_rq, struct sched_entity *se) 780account_entity_enqueue(struct cfs_rq *cfs_rq, struct sched_entity *se)
794{ 781{
795 update_load_add(&cfs_rq->load, se->load.weight); 782 update_load_add(&cfs_rq->load, se->load.weight);
796 if (!parent_entity(se)) 783 if (!parent_entity(se))
797 update_load_add(&rq_of(cfs_rq)->load, se->load.weight); 784 update_load_add(&rq_of(cfs_rq)->load, se->load.weight);
798 if (entity_is_task(se)) { 785#ifdef CONFIG_SMP
799 add_cfs_task_weight(cfs_rq, se->load.weight); 786 if (entity_is_task(se))
800 list_add(&se->group_node, &cfs_rq->tasks); 787 list_add_tail(&se->group_node, &rq_of(cfs_rq)->cfs_tasks);
801 } 788#endif
802 cfs_rq->nr_running++; 789 cfs_rq->nr_running++;
803} 790}
804 791
@@ -808,10 +795,8 @@ account_entity_dequeue(struct cfs_rq *cfs_rq, struct sched_entity *se)
808 update_load_sub(&cfs_rq->load, se->load.weight); 795 update_load_sub(&cfs_rq->load, se->load.weight);
809 if (!parent_entity(se)) 796 if (!parent_entity(se))
810 update_load_sub(&rq_of(cfs_rq)->load, se->load.weight); 797 update_load_sub(&rq_of(cfs_rq)->load, se->load.weight);
811 if (entity_is_task(se)) { 798 if (entity_is_task(se))
812 add_cfs_task_weight(cfs_rq, -se->load.weight);
813 list_del_init(&se->group_node); 799 list_del_init(&se->group_node);
814 }
815 cfs_rq->nr_running--; 800 cfs_rq->nr_running--;
816} 801}
817 802
@@ -1401,20 +1386,20 @@ entity_tick(struct cfs_rq *cfs_rq, struct sched_entity *curr, int queued)
1401#ifdef CONFIG_CFS_BANDWIDTH 1386#ifdef CONFIG_CFS_BANDWIDTH
1402 1387
1403#ifdef HAVE_JUMP_LABEL 1388#ifdef HAVE_JUMP_LABEL
1404static struct jump_label_key __cfs_bandwidth_used; 1389static struct static_key __cfs_bandwidth_used;
1405 1390
1406static inline bool cfs_bandwidth_used(void) 1391static inline bool cfs_bandwidth_used(void)
1407{ 1392{
1408 return static_branch(&__cfs_bandwidth_used); 1393 return static_key_false(&__cfs_bandwidth_used);
1409} 1394}
1410 1395
1411void account_cfs_bandwidth_used(int enabled, int was_enabled) 1396void account_cfs_bandwidth_used(int enabled, int was_enabled)
1412{ 1397{
1413 /* only need to count groups transitioning between enabled/!enabled */ 1398 /* only need to count groups transitioning between enabled/!enabled */
1414 if (enabled && !was_enabled) 1399 if (enabled && !was_enabled)
1415 jump_label_inc(&__cfs_bandwidth_used); 1400 static_key_slow_inc(&__cfs_bandwidth_used);
1416 else if (!enabled && was_enabled) 1401 else if (!enabled && was_enabled)
1417 jump_label_dec(&__cfs_bandwidth_used); 1402 static_key_slow_dec(&__cfs_bandwidth_used);
1418} 1403}
1419#else /* HAVE_JUMP_LABEL */ 1404#else /* HAVE_JUMP_LABEL */
1420static bool cfs_bandwidth_used(void) 1405static bool cfs_bandwidth_used(void)
@@ -2672,8 +2657,6 @@ static int select_idle_sibling(struct task_struct *p, int target)
2672 /* 2657 /*
2673 * Otherwise, iterate the domains and find an elegible idle cpu. 2658 * Otherwise, iterate the domains and find an elegible idle cpu.
2674 */ 2659 */
2675 rcu_read_lock();
2676
2677 sd = rcu_dereference(per_cpu(sd_llc, target)); 2660 sd = rcu_dereference(per_cpu(sd_llc, target));
2678 for_each_lower_domain(sd) { 2661 for_each_lower_domain(sd) {
2679 sg = sd->groups; 2662 sg = sd->groups;
@@ -2695,8 +2678,6 @@ next:
2695 } while (sg != sd->groups); 2678 } while (sg != sd->groups);
2696 } 2679 }
2697done: 2680done:
2698 rcu_read_unlock();
2699
2700 return target; 2681 return target;
2701} 2682}
2702 2683
@@ -2922,7 +2903,7 @@ static void check_preempt_wakeup(struct rq *rq, struct task_struct *p, int wake_
2922 return; 2903 return;
2923 2904
2924 /* 2905 /*
2925 * This is possible from callers such as pull_task(), in which we 2906 * This is possible from callers such as move_task(), in which we
2926 * unconditionally check_prempt_curr() after an enqueue (which may have 2907 * unconditionally check_prempt_curr() after an enqueue (which may have
2927 * lead to a throttle). This both saves work and prevents false 2908 * lead to a throttle). This both saves work and prevents false
2928 * next-buddy nomination below. 2909 * next-buddy nomination below.
@@ -3086,17 +3067,39 @@ static bool yield_to_task_fair(struct rq *rq, struct task_struct *p, bool preemp
3086 * Fair scheduling class load-balancing methods: 3067 * Fair scheduling class load-balancing methods:
3087 */ 3068 */
3088 3069
3070static unsigned long __read_mostly max_load_balance_interval = HZ/10;
3071
3072#define LBF_ALL_PINNED 0x01
3073#define LBF_NEED_BREAK 0x02
3074
3075struct lb_env {
3076 struct sched_domain *sd;
3077
3078 int src_cpu;
3079 struct rq *src_rq;
3080
3081 int dst_cpu;
3082 struct rq *dst_rq;
3083
3084 enum cpu_idle_type idle;
3085 long load_move;
3086 unsigned int flags;
3087
3088 unsigned int loop;
3089 unsigned int loop_break;
3090 unsigned int loop_max;
3091};
3092
3089/* 3093/*
3090 * pull_task - move a task from a remote runqueue to the local runqueue. 3094 * move_task - move a task from one runqueue to another runqueue.
3091 * Both runqueues must be locked. 3095 * Both runqueues must be locked.
3092 */ 3096 */
3093static void pull_task(struct rq *src_rq, struct task_struct *p, 3097static void move_task(struct task_struct *p, struct lb_env *env)
3094 struct rq *this_rq, int this_cpu)
3095{ 3098{
3096 deactivate_task(src_rq, p, 0); 3099 deactivate_task(env->src_rq, p, 0);
3097 set_task_cpu(p, this_cpu); 3100 set_task_cpu(p, env->dst_cpu);
3098 activate_task(this_rq, p, 0); 3101 activate_task(env->dst_rq, p, 0);
3099 check_preempt_curr(this_rq, p, 0); 3102 check_preempt_curr(env->dst_rq, p, 0);
3100} 3103}
3101 3104
3102/* 3105/*
@@ -3131,19 +3134,11 @@ task_hot(struct task_struct *p, u64 now, struct sched_domain *sd)
3131 return delta < (s64)sysctl_sched_migration_cost; 3134 return delta < (s64)sysctl_sched_migration_cost;
3132} 3135}
3133 3136
3134#define LBF_ALL_PINNED 0x01
3135#define LBF_NEED_BREAK 0x02 /* clears into HAD_BREAK */
3136#define LBF_HAD_BREAK 0x04
3137#define LBF_HAD_BREAKS 0x0C /* count HAD_BREAKs overflows into ABORT */
3138#define LBF_ABORT 0x10
3139
3140/* 3137/*
3141 * can_migrate_task - may task p from runqueue rq be migrated to this_cpu? 3138 * can_migrate_task - may task p from runqueue rq be migrated to this_cpu?
3142 */ 3139 */
3143static 3140static
3144int can_migrate_task(struct task_struct *p, struct rq *rq, int this_cpu, 3141int can_migrate_task(struct task_struct *p, struct lb_env *env)
3145 struct sched_domain *sd, enum cpu_idle_type idle,
3146 int *lb_flags)
3147{ 3142{
3148 int tsk_cache_hot = 0; 3143 int tsk_cache_hot = 0;
3149 /* 3144 /*
@@ -3152,13 +3147,13 @@ int can_migrate_task(struct task_struct *p, struct rq *rq, int this_cpu,
3152 * 2) cannot be migrated to this CPU due to cpus_allowed, or 3147 * 2) cannot be migrated to this CPU due to cpus_allowed, or
3153 * 3) are cache-hot on their current CPU. 3148 * 3) are cache-hot on their current CPU.
3154 */ 3149 */
3155 if (!cpumask_test_cpu(this_cpu, tsk_cpus_allowed(p))) { 3150 if (!cpumask_test_cpu(env->dst_cpu, tsk_cpus_allowed(p))) {
3156 schedstat_inc(p, se.statistics.nr_failed_migrations_affine); 3151 schedstat_inc(p, se.statistics.nr_failed_migrations_affine);
3157 return 0; 3152 return 0;
3158 } 3153 }
3159 *lb_flags &= ~LBF_ALL_PINNED; 3154 env->flags &= ~LBF_ALL_PINNED;
3160 3155
3161 if (task_running(rq, p)) { 3156 if (task_running(env->src_rq, p)) {
3162 schedstat_inc(p, se.statistics.nr_failed_migrations_running); 3157 schedstat_inc(p, se.statistics.nr_failed_migrations_running);
3163 return 0; 3158 return 0;
3164 } 3159 }
@@ -3169,12 +3164,12 @@ int can_migrate_task(struct task_struct *p, struct rq *rq, int this_cpu,
3169 * 2) too many balance attempts have failed. 3164 * 2) too many balance attempts have failed.
3170 */ 3165 */
3171 3166
3172 tsk_cache_hot = task_hot(p, rq->clock_task, sd); 3167 tsk_cache_hot = task_hot(p, env->src_rq->clock_task, env->sd);
3173 if (!tsk_cache_hot || 3168 if (!tsk_cache_hot ||
3174 sd->nr_balance_failed > sd->cache_nice_tries) { 3169 env->sd->nr_balance_failed > env->sd->cache_nice_tries) {
3175#ifdef CONFIG_SCHEDSTATS 3170#ifdef CONFIG_SCHEDSTATS
3176 if (tsk_cache_hot) { 3171 if (tsk_cache_hot) {
3177 schedstat_inc(sd, lb_hot_gained[idle]); 3172 schedstat_inc(env->sd, lb_hot_gained[env->idle]);
3178 schedstat_inc(p, se.statistics.nr_forced_migrations); 3173 schedstat_inc(p, se.statistics.nr_forced_migrations);
3179 } 3174 }
3180#endif 3175#endif
@@ -3195,65 +3190,80 @@ int can_migrate_task(struct task_struct *p, struct rq *rq, int this_cpu,
3195 * 3190 *
3196 * Called with both runqueues locked. 3191 * Called with both runqueues locked.
3197 */ 3192 */
3198static int 3193static int move_one_task(struct lb_env *env)
3199move_one_task(struct rq *this_rq, int this_cpu, struct rq *busiest,
3200 struct sched_domain *sd, enum cpu_idle_type idle)
3201{ 3194{
3202 struct task_struct *p, *n; 3195 struct task_struct *p, *n;
3203 struct cfs_rq *cfs_rq;
3204 int pinned = 0;
3205 3196
3206 for_each_leaf_cfs_rq(busiest, cfs_rq) { 3197 list_for_each_entry_safe(p, n, &env->src_rq->cfs_tasks, se.group_node) {
3207 list_for_each_entry_safe(p, n, &cfs_rq->tasks, se.group_node) { 3198 if (throttled_lb_pair(task_group(p), env->src_rq->cpu, env->dst_cpu))
3208 if (throttled_lb_pair(task_group(p), 3199 continue;
3209 busiest->cpu, this_cpu))
3210 break;
3211 3200
3212 if (!can_migrate_task(p, busiest, this_cpu, 3201 if (!can_migrate_task(p, env))
3213 sd, idle, &pinned)) 3202 continue;
3214 continue;
3215 3203
3216 pull_task(busiest, p, this_rq, this_cpu); 3204 move_task(p, env);
3217 /* 3205 /*
3218 * Right now, this is only the second place pull_task() 3206 * Right now, this is only the second place move_task()
3219 * is called, so we can safely collect pull_task() 3207 * is called, so we can safely collect move_task()
3220 * stats here rather than inside pull_task(). 3208 * stats here rather than inside move_task().
3221 */ 3209 */
3222 schedstat_inc(sd, lb_gained[idle]); 3210 schedstat_inc(env->sd, lb_gained[env->idle]);
3223 return 1; 3211 return 1;
3224 }
3225 } 3212 }
3226
3227 return 0; 3213 return 0;
3228} 3214}
3229 3215
3230static unsigned long 3216static unsigned long task_h_load(struct task_struct *p);
3231balance_tasks(struct rq *this_rq, int this_cpu, struct rq *busiest, 3217
3232 unsigned long max_load_move, struct sched_domain *sd, 3218/*
3233 enum cpu_idle_type idle, int *lb_flags, 3219 * move_tasks tries to move up to load_move weighted load from busiest to
3234 struct cfs_rq *busiest_cfs_rq) 3220 * this_rq, as part of a balancing operation within domain "sd".
3221 * Returns 1 if successful and 0 otherwise.
3222 *
3223 * Called with both runqueues locked.
3224 */
3225static int move_tasks(struct lb_env *env)
3235{ 3226{
3236 int loops = 0, pulled = 0; 3227 struct list_head *tasks = &env->src_rq->cfs_tasks;
3237 long rem_load_move = max_load_move; 3228 struct task_struct *p;
3238 struct task_struct *p, *n; 3229 unsigned long load;
3230 int pulled = 0;
3231
3232 if (env->load_move <= 0)
3233 return 0;
3239 3234
3240 if (max_load_move == 0) 3235 while (!list_empty(tasks)) {
3241 goto out; 3236 p = list_first_entry(tasks, struct task_struct, se.group_node);
3242 3237
3243 list_for_each_entry_safe(p, n, &busiest_cfs_rq->tasks, se.group_node) { 3238 env->loop++;
3244 if (loops++ > sysctl_sched_nr_migrate) { 3239 /* We've more or less seen every task there is, call it quits */
3245 *lb_flags |= LBF_NEED_BREAK; 3240 if (env->loop > env->loop_max)
3241 break;
3242
3243 /* take a breather every nr_migrate tasks */
3244 if (env->loop > env->loop_break) {
3245 env->loop_break += sysctl_sched_nr_migrate;
3246 env->flags |= LBF_NEED_BREAK;
3246 break; 3247 break;
3247 } 3248 }
3248 3249
3249 if ((p->se.load.weight >> 1) > rem_load_move || 3250 if (throttled_lb_pair(task_group(p), env->src_cpu, env->dst_cpu))
3250 !can_migrate_task(p, busiest, this_cpu, sd, idle, 3251 goto next;
3251 lb_flags)) 3252
3252 continue; 3253 load = task_h_load(p);
3254
3255 if (load < 16 && !env->sd->nr_balance_failed)
3256 goto next;
3257
3258 if ((load / 2) > env->load_move)
3259 goto next;
3253 3260
3254 pull_task(busiest, p, this_rq, this_cpu); 3261 if (!can_migrate_task(p, env))
3262 goto next;
3263
3264 move_task(p, env);
3255 pulled++; 3265 pulled++;
3256 rem_load_move -= p->se.load.weight; 3266 env->load_move -= load;
3257 3267
3258#ifdef CONFIG_PREEMPT 3268#ifdef CONFIG_PREEMPT
3259 /* 3269 /*
@@ -3261,28 +3271,30 @@ balance_tasks(struct rq *this_rq, int this_cpu, struct rq *busiest,
3261 * kernels will stop after the first task is pulled to minimize 3271 * kernels will stop after the first task is pulled to minimize
3262 * the critical section. 3272 * the critical section.
3263 */ 3273 */
3264 if (idle == CPU_NEWLY_IDLE) { 3274 if (env->idle == CPU_NEWLY_IDLE)
3265 *lb_flags |= LBF_ABORT;
3266 break; 3275 break;
3267 }
3268#endif 3276#endif
3269 3277
3270 /* 3278 /*
3271 * We only want to steal up to the prescribed amount of 3279 * We only want to steal up to the prescribed amount of
3272 * weighted load. 3280 * weighted load.
3273 */ 3281 */
3274 if (rem_load_move <= 0) 3282 if (env->load_move <= 0)
3275 break; 3283 break;
3284
3285 continue;
3286next:
3287 list_move_tail(&p->se.group_node, tasks);
3276 } 3288 }
3277out: 3289
3278 /* 3290 /*
3279 * Right now, this is one of only two places pull_task() is called, 3291 * Right now, this is one of only two places move_task() is called,
3280 * so we can safely collect pull_task() stats here rather than 3292 * so we can safely collect move_task() stats here rather than
3281 * inside pull_task(). 3293 * inside move_task().
3282 */ 3294 */
3283 schedstat_add(sd, lb_gained[idle], pulled); 3295 schedstat_add(env->sd, lb_gained[env->idle], pulled);
3284 3296
3285 return max_load_move - rem_load_move; 3297 return pulled;
3286} 3298}
3287 3299
3288#ifdef CONFIG_FAIR_GROUP_SCHED 3300#ifdef CONFIG_FAIR_GROUP_SCHED
@@ -3362,113 +3374,35 @@ static int tg_load_down(struct task_group *tg, void *data)
3362 3374
3363static void update_h_load(long cpu) 3375static void update_h_load(long cpu)
3364{ 3376{
3377 rcu_read_lock();
3365 walk_tg_tree(tg_load_down, tg_nop, (void *)cpu); 3378 walk_tg_tree(tg_load_down, tg_nop, (void *)cpu);
3379 rcu_read_unlock();
3366} 3380}
3367 3381
3368static unsigned long 3382static unsigned long task_h_load(struct task_struct *p)
3369load_balance_fair(struct rq *this_rq, int this_cpu, struct rq *busiest,
3370 unsigned long max_load_move,
3371 struct sched_domain *sd, enum cpu_idle_type idle,
3372 int *lb_flags)
3373{ 3383{
3374 long rem_load_move = max_load_move; 3384 struct cfs_rq *cfs_rq = task_cfs_rq(p);
3375 struct cfs_rq *busiest_cfs_rq; 3385 unsigned long load;
3376
3377 rcu_read_lock();
3378 update_h_load(cpu_of(busiest));
3379
3380 for_each_leaf_cfs_rq(busiest, busiest_cfs_rq) {
3381 unsigned long busiest_h_load = busiest_cfs_rq->h_load;
3382 unsigned long busiest_weight = busiest_cfs_rq->load.weight;
3383 u64 rem_load, moved_load;
3384
3385 if (*lb_flags & (LBF_NEED_BREAK|LBF_ABORT))
3386 break;
3387
3388 /*
3389 * empty group or part of a throttled hierarchy
3390 */
3391 if (!busiest_cfs_rq->task_weight ||
3392 throttled_lb_pair(busiest_cfs_rq->tg, cpu_of(busiest), this_cpu))
3393 continue;
3394
3395 rem_load = (u64)rem_load_move * busiest_weight;
3396 rem_load = div_u64(rem_load, busiest_h_load + 1);
3397
3398 moved_load = balance_tasks(this_rq, this_cpu, busiest,
3399 rem_load, sd, idle, lb_flags,
3400 busiest_cfs_rq);
3401
3402 if (!moved_load)
3403 continue;
3404 3386
3405 moved_load *= busiest_h_load; 3387 load = p->se.load.weight;
3406 moved_load = div_u64(moved_load, busiest_weight + 1); 3388 load = div_u64(load * cfs_rq->h_load, cfs_rq->load.weight + 1);
3407 3389
3408 rem_load_move -= moved_load; 3390 return load;
3409 if (rem_load_move < 0)
3410 break;
3411 }
3412 rcu_read_unlock();
3413
3414 return max_load_move - rem_load_move;
3415} 3391}
3416#else 3392#else
3417static inline void update_shares(int cpu) 3393static inline void update_shares(int cpu)
3418{ 3394{
3419} 3395}
3420 3396
3421static unsigned long 3397static inline void update_h_load(long cpu)
3422load_balance_fair(struct rq *this_rq, int this_cpu, struct rq *busiest,
3423 unsigned long max_load_move,
3424 struct sched_domain *sd, enum cpu_idle_type idle,
3425 int *lb_flags)
3426{ 3398{
3427 return balance_tasks(this_rq, this_cpu, busiest,
3428 max_load_move, sd, idle, lb_flags,
3429 &busiest->cfs);
3430} 3399}
3431#endif
3432 3400
3433/* 3401static unsigned long task_h_load(struct task_struct *p)
3434 * move_tasks tries to move up to max_load_move weighted load from busiest to
3435 * this_rq, as part of a balancing operation within domain "sd".
3436 * Returns 1 if successful and 0 otherwise.
3437 *
3438 * Called with both runqueues locked.
3439 */
3440static int move_tasks(struct rq *this_rq, int this_cpu, struct rq *busiest,
3441 unsigned long max_load_move,
3442 struct sched_domain *sd, enum cpu_idle_type idle,
3443 int *lb_flags)
3444{ 3402{
3445 unsigned long total_load_moved = 0, load_moved; 3403 return p->se.load.weight;
3446
3447 do {
3448 load_moved = load_balance_fair(this_rq, this_cpu, busiest,
3449 max_load_move - total_load_moved,
3450 sd, idle, lb_flags);
3451
3452 total_load_moved += load_moved;
3453
3454 if (*lb_flags & (LBF_NEED_BREAK|LBF_ABORT))
3455 break;
3456
3457#ifdef CONFIG_PREEMPT
3458 /*
3459 * NEWIDLE balancing is a source of latency, so preemptible
3460 * kernels will stop after the first task is pulled to minimize
3461 * the critical section.
3462 */
3463 if (idle == CPU_NEWLY_IDLE && this_rq->nr_running) {
3464 *lb_flags |= LBF_ABORT;
3465 break;
3466 }
3467#endif
3468 } while (load_moved && max_load_move > total_load_moved);
3469
3470 return total_load_moved > 0;
3471} 3404}
3405#endif
3472 3406
3473/********** Helpers for find_busiest_group ************************/ 3407/********** Helpers for find_busiest_group ************************/
3474/* 3408/*
@@ -3778,6 +3712,11 @@ void update_group_power(struct sched_domain *sd, int cpu)
3778 struct sched_domain *child = sd->child; 3712 struct sched_domain *child = sd->child;
3779 struct sched_group *group, *sdg = sd->groups; 3713 struct sched_group *group, *sdg = sd->groups;
3780 unsigned long power; 3714 unsigned long power;
3715 unsigned long interval;
3716
3717 interval = msecs_to_jiffies(sd->balance_interval);
3718 interval = clamp(interval, 1UL, max_load_balance_interval);
3719 sdg->sgp->next_update = jiffies + interval;
3781 3720
3782 if (!child) { 3721 if (!child) {
3783 update_cpu_power(sd, cpu); 3722 update_cpu_power(sd, cpu);
@@ -3885,12 +3824,15 @@ static inline void update_sg_lb_stats(struct sched_domain *sd,
3885 * domains. In the newly idle case, we will allow all the cpu's 3824 * domains. In the newly idle case, we will allow all the cpu's
3886 * to do the newly idle load balance. 3825 * to do the newly idle load balance.
3887 */ 3826 */
3888 if (idle != CPU_NEWLY_IDLE && local_group) { 3827 if (local_group) {
3889 if (balance_cpu != this_cpu) { 3828 if (idle != CPU_NEWLY_IDLE) {
3890 *balance = 0; 3829 if (balance_cpu != this_cpu) {
3891 return; 3830 *balance = 0;
3892 } 3831 return;
3893 update_group_power(sd, this_cpu); 3832 }
3833 update_group_power(sd, this_cpu);
3834 } else if (time_after_eq(jiffies, group->sgp->next_update))
3835 update_group_power(sd, this_cpu);
3894 } 3836 }
3895 3837
3896 /* Adjust by relative CPU power of the group */ 3838 /* Adjust by relative CPU power of the group */
@@ -4453,13 +4395,21 @@ static int load_balance(int this_cpu, struct rq *this_rq,
4453 struct sched_domain *sd, enum cpu_idle_type idle, 4395 struct sched_domain *sd, enum cpu_idle_type idle,
4454 int *balance) 4396 int *balance)
4455{ 4397{
4456 int ld_moved, lb_flags = 0, active_balance = 0; 4398 int ld_moved, active_balance = 0;
4457 struct sched_group *group; 4399 struct sched_group *group;
4458 unsigned long imbalance; 4400 unsigned long imbalance;
4459 struct rq *busiest; 4401 struct rq *busiest;
4460 unsigned long flags; 4402 unsigned long flags;
4461 struct cpumask *cpus = __get_cpu_var(load_balance_tmpmask); 4403 struct cpumask *cpus = __get_cpu_var(load_balance_tmpmask);
4462 4404
4405 struct lb_env env = {
4406 .sd = sd,
4407 .dst_cpu = this_cpu,
4408 .dst_rq = this_rq,
4409 .idle = idle,
4410 .loop_break = sysctl_sched_nr_migrate,
4411 };
4412
4463 cpumask_copy(cpus, cpu_active_mask); 4413 cpumask_copy(cpus, cpu_active_mask);
4464 4414
4465 schedstat_inc(sd, lb_count[idle]); 4415 schedstat_inc(sd, lb_count[idle]);
@@ -4494,32 +4444,34 @@ redo:
4494 * still unbalanced. ld_moved simply stays zero, so it is 4444 * still unbalanced. ld_moved simply stays zero, so it is
4495 * correctly treated as an imbalance. 4445 * correctly treated as an imbalance.
4496 */ 4446 */
4497 lb_flags |= LBF_ALL_PINNED; 4447 env.flags |= LBF_ALL_PINNED;
4448 env.load_move = imbalance;
4449 env.src_cpu = busiest->cpu;
4450 env.src_rq = busiest;
4451 env.loop_max = busiest->nr_running;
4452
4453more_balance:
4498 local_irq_save(flags); 4454 local_irq_save(flags);
4499 double_rq_lock(this_rq, busiest); 4455 double_rq_lock(this_rq, busiest);
4500 ld_moved = move_tasks(this_rq, this_cpu, busiest, 4456 if (!env.loop)
4501 imbalance, sd, idle, &lb_flags); 4457 update_h_load(env.src_cpu);
4458 ld_moved += move_tasks(&env);
4502 double_rq_unlock(this_rq, busiest); 4459 double_rq_unlock(this_rq, busiest);
4503 local_irq_restore(flags); 4460 local_irq_restore(flags);
4504 4461
4462 if (env.flags & LBF_NEED_BREAK) {
4463 env.flags &= ~LBF_NEED_BREAK;
4464 goto more_balance;
4465 }
4466
4505 /* 4467 /*
4506 * some other cpu did the load balance for us. 4468 * some other cpu did the load balance for us.
4507 */ 4469 */
4508 if (ld_moved && this_cpu != smp_processor_id()) 4470 if (ld_moved && this_cpu != smp_processor_id())
4509 resched_cpu(this_cpu); 4471 resched_cpu(this_cpu);
4510 4472
4511 if (lb_flags & LBF_ABORT)
4512 goto out_balanced;
4513
4514 if (lb_flags & LBF_NEED_BREAK) {
4515 lb_flags += LBF_HAD_BREAK - LBF_NEED_BREAK;
4516 if (lb_flags & LBF_ABORT)
4517 goto out_balanced;
4518 goto redo;
4519 }
4520
4521 /* All tasks on this runqueue were pinned by CPU affinity */ 4473 /* All tasks on this runqueue were pinned by CPU affinity */
4522 if (unlikely(lb_flags & LBF_ALL_PINNED)) { 4474 if (unlikely(env.flags & LBF_ALL_PINNED)) {
4523 cpumask_clear_cpu(cpu_of(busiest), cpus); 4475 cpumask_clear_cpu(cpu_of(busiest), cpus);
4524 if (!cpumask_empty(cpus)) 4476 if (!cpumask_empty(cpus))
4525 goto redo; 4477 goto redo;
@@ -4549,7 +4501,7 @@ redo:
4549 tsk_cpus_allowed(busiest->curr))) { 4501 tsk_cpus_allowed(busiest->curr))) {
4550 raw_spin_unlock_irqrestore(&busiest->lock, 4502 raw_spin_unlock_irqrestore(&busiest->lock,
4551 flags); 4503 flags);
4552 lb_flags |= LBF_ALL_PINNED; 4504 env.flags |= LBF_ALL_PINNED;
4553 goto out_one_pinned; 4505 goto out_one_pinned;
4554 } 4506 }
4555 4507
@@ -4602,7 +4554,7 @@ out_balanced:
4602 4554
4603out_one_pinned: 4555out_one_pinned:
4604 /* tune up the balancing interval */ 4556 /* tune up the balancing interval */
4605 if (((lb_flags & LBF_ALL_PINNED) && 4557 if (((env.flags & LBF_ALL_PINNED) &&
4606 sd->balance_interval < MAX_PINNED_INTERVAL) || 4558 sd->balance_interval < MAX_PINNED_INTERVAL) ||
4607 (sd->balance_interval < sd->max_interval)) 4559 (sd->balance_interval < sd->max_interval))
4608 sd->balance_interval *= 2; 4560 sd->balance_interval *= 2;
@@ -4712,10 +4664,18 @@ static int active_load_balance_cpu_stop(void *data)
4712 } 4664 }
4713 4665
4714 if (likely(sd)) { 4666 if (likely(sd)) {
4667 struct lb_env env = {
4668 .sd = sd,
4669 .dst_cpu = target_cpu,
4670 .dst_rq = target_rq,
4671 .src_cpu = busiest_rq->cpu,
4672 .src_rq = busiest_rq,
4673 .idle = CPU_IDLE,
4674 };
4675
4715 schedstat_inc(sd, alb_count); 4676 schedstat_inc(sd, alb_count);
4716 4677
4717 if (move_one_task(target_rq, target_cpu, busiest_rq, 4678 if (move_one_task(&env))
4718 sd, CPU_IDLE))
4719 schedstat_inc(sd, alb_pushed); 4679 schedstat_inc(sd, alb_pushed);
4720 else 4680 else
4721 schedstat_inc(sd, alb_failed); 4681 schedstat_inc(sd, alb_failed);
@@ -4947,8 +4907,6 @@ static int __cpuinit sched_ilb_notifier(struct notifier_block *nfb,
4947 4907
4948static DEFINE_SPINLOCK(balancing); 4908static DEFINE_SPINLOCK(balancing);
4949 4909
4950static unsigned long __read_mostly max_load_balance_interval = HZ/10;
4951
4952/* 4910/*
4953 * Scale the max load_balance interval with the number of CPUs in the system. 4911 * Scale the max load_balance interval with the number of CPUs in the system.
4954 * This trades load-balance latency on larger machines for less cross talk. 4912 * This trades load-balance latency on larger machines for less cross talk.
@@ -5342,7 +5300,6 @@ static void set_curr_task_fair(struct rq *rq)
5342void init_cfs_rq(struct cfs_rq *cfs_rq) 5300void init_cfs_rq(struct cfs_rq *cfs_rq)
5343{ 5301{
5344 cfs_rq->tasks_timeline = RB_ROOT; 5302 cfs_rq->tasks_timeline = RB_ROOT;
5345 INIT_LIST_HEAD(&cfs_rq->tasks);
5346 cfs_rq->min_vruntime = (u64)(-(1LL << 20)); 5303 cfs_rq->min_vruntime = (u64)(-(1LL << 20));
5347#ifndef CONFIG_64BIT 5304#ifndef CONFIG_64BIT
5348 cfs_rq->min_vruntime_copy = cfs_rq->min_vruntime; 5305 cfs_rq->min_vruntime_copy = cfs_rq->min_vruntime;
@@ -5614,6 +5571,7 @@ __init void init_sched_fair_class(void)
5614 open_softirq(SCHED_SOFTIRQ, run_rebalance_domains); 5571 open_softirq(SCHED_SOFTIRQ, run_rebalance_domains);
5615 5572
5616#ifdef CONFIG_NO_HZ 5573#ifdef CONFIG_NO_HZ
5574 nohz.next_balance = jiffies;
5617 zalloc_cpumask_var(&nohz.idle_cpus_mask, GFP_NOWAIT); 5575 zalloc_cpumask_var(&nohz.idle_cpus_mask, GFP_NOWAIT);
5618 cpu_notifier(sched_ilb_notifier, 0); 5576 cpu_notifier(sched_ilb_notifier, 0);
5619#endif 5577#endif
diff --git a/kernel/sched/rt.c b/kernel/sched/rt.c
index f42ae7fb5ec5..b60dad720173 100644
--- a/kernel/sched/rt.c
+++ b/kernel/sched/rt.c
@@ -778,12 +778,9 @@ static inline int balance_runtime(struct rt_rq *rt_rq)
778 778
779static int do_sched_rt_period_timer(struct rt_bandwidth *rt_b, int overrun) 779static int do_sched_rt_period_timer(struct rt_bandwidth *rt_b, int overrun)
780{ 780{
781 int i, idle = 1; 781 int i, idle = 1, throttled = 0;
782 const struct cpumask *span; 782 const struct cpumask *span;
783 783
784 if (!rt_bandwidth_enabled() || rt_b->rt_runtime == RUNTIME_INF)
785 return 1;
786
787 span = sched_rt_period_mask(); 784 span = sched_rt_period_mask();
788 for_each_cpu(i, span) { 785 for_each_cpu(i, span) {
789 int enqueue = 0; 786 int enqueue = 0;
@@ -818,12 +815,17 @@ static int do_sched_rt_period_timer(struct rt_bandwidth *rt_b, int overrun)
818 if (!rt_rq_throttled(rt_rq)) 815 if (!rt_rq_throttled(rt_rq))
819 enqueue = 1; 816 enqueue = 1;
820 } 817 }
818 if (rt_rq->rt_throttled)
819 throttled = 1;
821 820
822 if (enqueue) 821 if (enqueue)
823 sched_rt_rq_enqueue(rt_rq); 822 sched_rt_rq_enqueue(rt_rq);
824 raw_spin_unlock(&rq->lock); 823 raw_spin_unlock(&rq->lock);
825 } 824 }
826 825
826 if (!throttled && (!rt_bandwidth_enabled() || rt_b->rt_runtime == RUNTIME_INF))
827 return 1;
828
827 return idle; 829 return idle;
828} 830}
829 831
@@ -855,8 +857,30 @@ static int sched_rt_runtime_exceeded(struct rt_rq *rt_rq)
855 return 0; 857 return 0;
856 858
857 if (rt_rq->rt_time > runtime) { 859 if (rt_rq->rt_time > runtime) {
858 rt_rq->rt_throttled = 1; 860 struct rt_bandwidth *rt_b = sched_rt_bandwidth(rt_rq);
859 printk_once(KERN_WARNING "sched: RT throttling activated\n"); 861
862 /*
863 * Don't actually throttle groups that have no runtime assigned
864 * but accrue some time due to boosting.
865 */
866 if (likely(rt_b->rt_runtime)) {
867 static bool once = false;
868
869 rt_rq->rt_throttled = 1;
870
871 if (!once) {
872 once = true;
873 printk_sched("sched: RT throttling activated\n");
874 }
875 } else {
876 /*
877 * In case we did anyway, make it go away,
878 * replenishment is a joke, since it will replenish us
879 * with exactly 0 ns.
880 */
881 rt_rq->rt_time = 0;
882 }
883
860 if (rt_rq_throttled(rt_rq)) { 884 if (rt_rq_throttled(rt_rq)) {
861 sched_rt_rq_dequeue(rt_rq); 885 sched_rt_rq_dequeue(rt_rq);
862 return 1; 886 return 1;
@@ -884,7 +908,8 @@ static void update_curr_rt(struct rq *rq)
884 if (unlikely((s64)delta_exec < 0)) 908 if (unlikely((s64)delta_exec < 0))
885 delta_exec = 0; 909 delta_exec = 0;
886 910
887 schedstat_set(curr->se.statistics.exec_max, max(curr->se.statistics.exec_max, delta_exec)); 911 schedstat_set(curr->se.statistics.exec_max,
912 max(curr->se.statistics.exec_max, delta_exec));
888 913
889 curr->se.sum_exec_runtime += delta_exec; 914 curr->se.sum_exec_runtime += delta_exec;
890 account_group_exec_runtime(curr, delta_exec); 915 account_group_exec_runtime(curr, delta_exec);
@@ -1972,7 +1997,7 @@ static void task_tick_rt(struct rq *rq, struct task_struct *p, int queued)
1972 if (--p->rt.time_slice) 1997 if (--p->rt.time_slice)
1973 return; 1998 return;
1974 1999
1975 p->rt.time_slice = DEF_TIMESLICE; 2000 p->rt.time_slice = RR_TIMESLICE;
1976 2001
1977 /* 2002 /*
1978 * Requeue to the end of queue if we are not the only element 2003 * Requeue to the end of queue if we are not the only element
@@ -2000,7 +2025,7 @@ static unsigned int get_rr_interval_rt(struct rq *rq, struct task_struct *task)
2000 * Time slice is 0 for SCHED_FIFO tasks 2025 * Time slice is 0 for SCHED_FIFO tasks
2001 */ 2026 */
2002 if (task->policy == SCHED_RR) 2027 if (task->policy == SCHED_RR)
2003 return DEF_TIMESLICE; 2028 return RR_TIMESLICE;
2004 else 2029 else
2005 return 0; 2030 return 0;
2006} 2031}
diff --git a/kernel/sched/sched.h b/kernel/sched/sched.h
index 98c0c2623db8..42b1f304b044 100644
--- a/kernel/sched/sched.h
+++ b/kernel/sched/sched.h
@@ -36,11 +36,7 @@ extern __read_mostly int scheduler_running;
36 36
37/* 37/*
38 * These are the 'tuning knobs' of the scheduler: 38 * These are the 'tuning knobs' of the scheduler:
39 *
40 * default timeslice is 100 msecs (used only for SCHED_RR tasks).
41 * Timeslices get refilled after they expire.
42 */ 39 */
43#define DEF_TIMESLICE (100 * HZ / 1000)
44 40
45/* 41/*
46 * single value that denotes runtime == period, ie unlimited time. 42 * single value that denotes runtime == period, ie unlimited time.
@@ -216,9 +212,6 @@ struct cfs_rq {
216 struct rb_root tasks_timeline; 212 struct rb_root tasks_timeline;
217 struct rb_node *rb_leftmost; 213 struct rb_node *rb_leftmost;
218 214
219 struct list_head tasks;
220 struct list_head *balance_iterator;
221
222 /* 215 /*
223 * 'curr' points to currently running entity on this cfs_rq. 216 * 'curr' points to currently running entity on this cfs_rq.
224 * It is set to NULL otherwise (i.e when none are currently running). 217 * It is set to NULL otherwise (i.e when none are currently running).
@@ -246,11 +239,6 @@ struct cfs_rq {
246 239
247#ifdef CONFIG_SMP 240#ifdef CONFIG_SMP
248 /* 241 /*
249 * the part of load.weight contributed by tasks
250 */
251 unsigned long task_weight;
252
253 /*
254 * h_load = weight * f(tg) 242 * h_load = weight * f(tg)
255 * 243 *
256 * Where f(tg) is the recursive weight fraction assigned to 244 * Where f(tg) is the recursive weight fraction assigned to
@@ -424,6 +412,8 @@ struct rq {
424 int cpu; 412 int cpu;
425 int online; 413 int online;
426 414
415 struct list_head cfs_tasks;
416
427 u64 rt_avg; 417 u64 rt_avg;
428 u64 age_stamp; 418 u64 age_stamp;
429 u64 idle_stamp; 419 u64 idle_stamp;
@@ -462,7 +452,6 @@ struct rq {
462 unsigned int yld_count; 452 unsigned int yld_count;
463 453
464 /* schedule() stats */ 454 /* schedule() stats */
465 unsigned int sched_switch;
466 unsigned int sched_count; 455 unsigned int sched_count;
467 unsigned int sched_goidle; 456 unsigned int sched_goidle;
468 457
@@ -611,7 +600,7 @@ static inline void __set_task_cpu(struct task_struct *p, unsigned int cpu)
611 * Tunables that become constants when CONFIG_SCHED_DEBUG is off: 600 * Tunables that become constants when CONFIG_SCHED_DEBUG is off:
612 */ 601 */
613#ifdef CONFIG_SCHED_DEBUG 602#ifdef CONFIG_SCHED_DEBUG
614# include <linux/jump_label.h> 603# include <linux/static_key.h>
615# define const_debug __read_mostly 604# define const_debug __read_mostly
616#else 605#else
617# define const_debug const 606# define const_debug const
@@ -630,18 +619,18 @@ enum {
630#undef SCHED_FEAT 619#undef SCHED_FEAT
631 620
632#if defined(CONFIG_SCHED_DEBUG) && defined(HAVE_JUMP_LABEL) 621#if defined(CONFIG_SCHED_DEBUG) && defined(HAVE_JUMP_LABEL)
633static __always_inline bool static_branch__true(struct jump_label_key *key) 622static __always_inline bool static_branch__true(struct static_key *key)
634{ 623{
635 return likely(static_branch(key)); /* Not out of line branch. */ 624 return static_key_true(key); /* Not out of line branch. */
636} 625}
637 626
638static __always_inline bool static_branch__false(struct jump_label_key *key) 627static __always_inline bool static_branch__false(struct static_key *key)
639{ 628{
640 return unlikely(static_branch(key)); /* Out of line branch. */ 629 return static_key_false(key); /* Out of line branch. */
641} 630}
642 631
643#define SCHED_FEAT(name, enabled) \ 632#define SCHED_FEAT(name, enabled) \
644static __always_inline bool static_branch_##name(struct jump_label_key *key) \ 633static __always_inline bool static_branch_##name(struct static_key *key) \
645{ \ 634{ \
646 return static_branch__##enabled(key); \ 635 return static_branch__##enabled(key); \
647} 636}
@@ -650,7 +639,7 @@ static __always_inline bool static_branch_##name(struct jump_label_key *key) \
650 639
651#undef SCHED_FEAT 640#undef SCHED_FEAT
652 641
653extern struct jump_label_key sched_feat_keys[__SCHED_FEAT_NR]; 642extern struct static_key sched_feat_keys[__SCHED_FEAT_NR];
654#define sched_feat(x) (static_branch_##x(&sched_feat_keys[__SCHED_FEAT_##x])) 643#define sched_feat(x) (static_branch_##x(&sched_feat_keys[__SCHED_FEAT_##x]))
655#else /* !(SCHED_DEBUG && HAVE_JUMP_LABEL) */ 644#else /* !(SCHED_DEBUG && HAVE_JUMP_LABEL) */
656#define sched_feat(x) (sysctl_sched_features & (1UL << __SCHED_FEAT_##x)) 645#define sched_feat(x) (sysctl_sched_features & (1UL << __SCHED_FEAT_##x))
diff --git a/kernel/sched/stats.c b/kernel/sched/stats.c
index 2a581ba8e190..903ffa9e8872 100644
--- a/kernel/sched/stats.c
+++ b/kernel/sched/stats.c
@@ -32,9 +32,9 @@ static int show_schedstat(struct seq_file *seq, void *v)
32 32
33 /* runqueue-specific stats */ 33 /* runqueue-specific stats */
34 seq_printf(seq, 34 seq_printf(seq,
35 "cpu%d %u %u %u %u %u %u %llu %llu %lu", 35 "cpu%d %u 0 %u %u %u %u %llu %llu %lu",
36 cpu, rq->yld_count, 36 cpu, rq->yld_count,
37 rq->sched_switch, rq->sched_count, rq->sched_goidle, 37 rq->sched_count, rq->sched_goidle,
38 rq->ttwu_count, rq->ttwu_local, 38 rq->ttwu_count, rq->ttwu_local,
39 rq->rq_cpu_time, 39 rq->rq_cpu_time,
40 rq->rq_sched_info.run_delay, rq->rq_sched_info.pcount); 40 rq->rq_sched_info.run_delay, rq->rq_sched_info.pcount);
diff --git a/kernel/signal.c b/kernel/signal.c
index c73c4284160e..8511e39813c7 100644
--- a/kernel/signal.c
+++ b/kernel/signal.c
@@ -1054,13 +1054,13 @@ static int __send_signal(int sig, struct siginfo *info, struct task_struct *t,
1054 struct sigpending *pending; 1054 struct sigpending *pending;
1055 struct sigqueue *q; 1055 struct sigqueue *q;
1056 int override_rlimit; 1056 int override_rlimit;
1057 1057 int ret = 0, result;
1058 trace_signal_generate(sig, info, t);
1059 1058
1060 assert_spin_locked(&t->sighand->siglock); 1059 assert_spin_locked(&t->sighand->siglock);
1061 1060
1061 result = TRACE_SIGNAL_IGNORED;
1062 if (!prepare_signal(sig, t, from_ancestor_ns)) 1062 if (!prepare_signal(sig, t, from_ancestor_ns))
1063 return 0; 1063 goto ret;
1064 1064
1065 pending = group ? &t->signal->shared_pending : &t->pending; 1065 pending = group ? &t->signal->shared_pending : &t->pending;
1066 /* 1066 /*
@@ -1068,8 +1068,11 @@ static int __send_signal(int sig, struct siginfo *info, struct task_struct *t,
1068 * exactly one non-rt signal, so that we can get more 1068 * exactly one non-rt signal, so that we can get more
1069 * detailed information about the cause of the signal. 1069 * detailed information about the cause of the signal.
1070 */ 1070 */
1071 result = TRACE_SIGNAL_ALREADY_PENDING;
1071 if (legacy_queue(pending, sig)) 1072 if (legacy_queue(pending, sig))
1072 return 0; 1073 goto ret;
1074
1075 result = TRACE_SIGNAL_DELIVERED;
1073 /* 1076 /*
1074 * fast-pathed signals for kernel-internal things like SIGSTOP 1077 * fast-pathed signals for kernel-internal things like SIGSTOP
1075 * or SIGKILL. 1078 * or SIGKILL.
@@ -1127,14 +1130,15 @@ static int __send_signal(int sig, struct siginfo *info, struct task_struct *t,
1127 * signal was rt and sent by user using something 1130 * signal was rt and sent by user using something
1128 * other than kill(). 1131 * other than kill().
1129 */ 1132 */
1130 trace_signal_overflow_fail(sig, group, info); 1133 result = TRACE_SIGNAL_OVERFLOW_FAIL;
1131 return -EAGAIN; 1134 ret = -EAGAIN;
1135 goto ret;
1132 } else { 1136 } else {
1133 /* 1137 /*
1134 * This is a silent loss of information. We still 1138 * This is a silent loss of information. We still
1135 * send the signal, but the *info bits are lost. 1139 * send the signal, but the *info bits are lost.
1136 */ 1140 */
1137 trace_signal_lose_info(sig, group, info); 1141 result = TRACE_SIGNAL_LOSE_INFO;
1138 } 1142 }
1139 } 1143 }
1140 1144
@@ -1142,7 +1146,9 @@ out_set:
1142 signalfd_notify(t, sig); 1146 signalfd_notify(t, sig);
1143 sigaddset(&pending->signal, sig); 1147 sigaddset(&pending->signal, sig);
1144 complete_signal(sig, t, group); 1148 complete_signal(sig, t, group);
1145 return 0; 1149ret:
1150 trace_signal_generate(sig, info, t, group, result);
1151 return ret;
1146} 1152}
1147 1153
1148static int send_signal(int sig, struct siginfo *info, struct task_struct *t, 1154static int send_signal(int sig, struct siginfo *info, struct task_struct *t,
@@ -1585,7 +1591,7 @@ int send_sigqueue(struct sigqueue *q, struct task_struct *t, int group)
1585 int sig = q->info.si_signo; 1591 int sig = q->info.si_signo;
1586 struct sigpending *pending; 1592 struct sigpending *pending;
1587 unsigned long flags; 1593 unsigned long flags;
1588 int ret; 1594 int ret, result;
1589 1595
1590 BUG_ON(!(q->flags & SIGQUEUE_PREALLOC)); 1596 BUG_ON(!(q->flags & SIGQUEUE_PREALLOC));
1591 1597
@@ -1594,6 +1600,7 @@ int send_sigqueue(struct sigqueue *q, struct task_struct *t, int group)
1594 goto ret; 1600 goto ret;
1595 1601
1596 ret = 1; /* the signal is ignored */ 1602 ret = 1; /* the signal is ignored */
1603 result = TRACE_SIGNAL_IGNORED;
1597 if (!prepare_signal(sig, t, 0)) 1604 if (!prepare_signal(sig, t, 0))
1598 goto out; 1605 goto out;
1599 1606
@@ -1605,6 +1612,7 @@ int send_sigqueue(struct sigqueue *q, struct task_struct *t, int group)
1605 */ 1612 */
1606 BUG_ON(q->info.si_code != SI_TIMER); 1613 BUG_ON(q->info.si_code != SI_TIMER);
1607 q->info.si_overrun++; 1614 q->info.si_overrun++;
1615 result = TRACE_SIGNAL_ALREADY_PENDING;
1608 goto out; 1616 goto out;
1609 } 1617 }
1610 q->info.si_overrun = 0; 1618 q->info.si_overrun = 0;
@@ -1614,7 +1622,9 @@ int send_sigqueue(struct sigqueue *q, struct task_struct *t, int group)
1614 list_add_tail(&q->list, &pending->list); 1622 list_add_tail(&q->list, &pending->list);
1615 sigaddset(&pending->signal, sig); 1623 sigaddset(&pending->signal, sig);
1616 complete_signal(sig, t, group); 1624 complete_signal(sig, t, group);
1625 result = TRACE_SIGNAL_DELIVERED;
1617out: 1626out:
1627 trace_signal_generate(sig, &q->info, t, group, result);
1618 unlock_task_sighand(t, &flags); 1628 unlock_task_sighand(t, &flags);
1619ret: 1629ret:
1620 return ret; 1630 return ret;
diff --git a/kernel/softirq.c b/kernel/softirq.c
index 4eb3a0fa351e..671f9594e368 100644
--- a/kernel/softirq.c
+++ b/kernel/softirq.c
@@ -297,7 +297,7 @@ void irq_enter(void)
297 int cpu = smp_processor_id(); 297 int cpu = smp_processor_id();
298 298
299 rcu_irq_enter(); 299 rcu_irq_enter();
300 if (idle_cpu(cpu) && !in_interrupt()) { 300 if (is_idle_task(current) && !in_interrupt()) {
301 /* 301 /*
302 * Prevent raise_softirq from needlessly waking up ksoftirqd 302 * Prevent raise_softirq from needlessly waking up ksoftirqd
303 * here, as softirq will be serviced on return from interrupt. 303 * here, as softirq will be serviced on return from interrupt.
@@ -310,31 +310,21 @@ void irq_enter(void)
310 __irq_enter(); 310 __irq_enter();
311} 311}
312 312
313#ifdef __ARCH_IRQ_EXIT_IRQS_DISABLED
314static inline void invoke_softirq(void) 313static inline void invoke_softirq(void)
315{ 314{
316 if (!force_irqthreads) 315 if (!force_irqthreads) {
316#ifdef __ARCH_IRQ_EXIT_IRQS_DISABLED
317 __do_softirq(); 317 __do_softirq();
318 else {
319 __local_bh_disable((unsigned long)__builtin_return_address(0),
320 SOFTIRQ_OFFSET);
321 wakeup_softirqd();
322 __local_bh_enable(SOFTIRQ_OFFSET);
323 }
324}
325#else 318#else
326static inline void invoke_softirq(void)
327{
328 if (!force_irqthreads)
329 do_softirq(); 319 do_softirq();
330 else { 320#endif
321 } else {
331 __local_bh_disable((unsigned long)__builtin_return_address(0), 322 __local_bh_disable((unsigned long)__builtin_return_address(0),
332 SOFTIRQ_OFFSET); 323 SOFTIRQ_OFFSET);
333 wakeup_softirqd(); 324 wakeup_softirqd();
334 __local_bh_enable(SOFTIRQ_OFFSET); 325 __local_bh_enable(SOFTIRQ_OFFSET);
335 } 326 }
336} 327}
337#endif
338 328
339/* 329/*
340 * Exit an interrupt context. Process softirqs if needed and possible: 330 * Exit an interrupt context. Process softirqs if needed and possible:
@@ -353,7 +343,7 @@ void irq_exit(void)
353 tick_nohz_irq_exit(); 343 tick_nohz_irq_exit();
354#endif 344#endif
355 rcu_irq_exit(); 345 rcu_irq_exit();
356 preempt_enable_no_resched(); 346 sched_preempt_enable_no_resched();
357} 347}
358 348
359/* 349/*
@@ -385,6 +375,12 @@ void raise_softirq(unsigned int nr)
385 local_irq_restore(flags); 375 local_irq_restore(flags);
386} 376}
387 377
378void __raise_softirq_irqoff(unsigned int nr)
379{
380 trace_softirq_raise(nr);
381 or_softirq_pending(1UL << nr);
382}
383
388void open_softirq(int nr, void (*action)(struct softirq_action *)) 384void open_softirq(int nr, void (*action)(struct softirq_action *))
389{ 385{
390 softirq_vec[nr].action = action; 386 softirq_vec[nr].action = action;
@@ -744,9 +740,7 @@ static int run_ksoftirqd(void * __bind_cpu)
744 while (!kthread_should_stop()) { 740 while (!kthread_should_stop()) {
745 preempt_disable(); 741 preempt_disable();
746 if (!local_softirq_pending()) { 742 if (!local_softirq_pending()) {
747 preempt_enable_no_resched(); 743 schedule_preempt_disabled();
748 schedule();
749 preempt_disable();
750 } 744 }
751 745
752 __set_current_state(TASK_RUNNING); 746 __set_current_state(TASK_RUNNING);
@@ -761,7 +755,7 @@ static int run_ksoftirqd(void * __bind_cpu)
761 if (local_softirq_pending()) 755 if (local_softirq_pending())
762 __do_softirq(); 756 __do_softirq();
763 local_irq_enable(); 757 local_irq_enable();
764 preempt_enable_no_resched(); 758 sched_preempt_enable_no_resched();
765 cond_resched(); 759 cond_resched();
766 preempt_disable(); 760 preempt_disable();
767 rcu_note_context_switch((long)__bind_cpu); 761 rcu_note_context_switch((long)__bind_cpu);
diff --git a/kernel/srcu.c b/kernel/srcu.c
index 0febf61e1aa3..ba35f3a4a1f4 100644
--- a/kernel/srcu.c
+++ b/kernel/srcu.c
@@ -172,6 +172,12 @@ static void __synchronize_srcu(struct srcu_struct *sp, void (*sync_func)(void))
172{ 172{
173 int idx; 173 int idx;
174 174
175 rcu_lockdep_assert(!lock_is_held(&sp->dep_map) &&
176 !lock_is_held(&rcu_bh_lock_map) &&
177 !lock_is_held(&rcu_lock_map) &&
178 !lock_is_held(&rcu_sched_lock_map),
179 "Illegal synchronize_srcu() in same-type SRCU (or RCU) read-side critical section");
180
175 idx = sp->completed; 181 idx = sp->completed;
176 mutex_lock(&sp->mutex); 182 mutex_lock(&sp->mutex);
177 183
@@ -280,19 +286,26 @@ void synchronize_srcu(struct srcu_struct *sp)
280EXPORT_SYMBOL_GPL(synchronize_srcu); 286EXPORT_SYMBOL_GPL(synchronize_srcu);
281 287
282/** 288/**
283 * synchronize_srcu_expedited - like synchronize_srcu, but less patient 289 * synchronize_srcu_expedited - Brute-force SRCU grace period
284 * @sp: srcu_struct with which to synchronize. 290 * @sp: srcu_struct with which to synchronize.
285 * 291 *
286 * Flip the completed counter, and wait for the old count to drain to zero. 292 * Wait for an SRCU grace period to elapse, but use a "big hammer"
287 * As with classic RCU, the updater must use some separate means of 293 * approach to force the grace period to end quickly. This consumes
288 * synchronizing concurrent updates. Can block; must be called from 294 * significant time on all CPUs and is unfriendly to real-time workloads,
289 * process context. 295 * so is thus not recommended for any sort of common-case code. In fact,
296 * if you are using synchronize_srcu_expedited() in a loop, please
297 * restructure your code to batch your updates, and then use a single
298 * synchronize_srcu() instead.
290 * 299 *
291 * Note that it is illegal to call synchronize_srcu_expedited() 300 * Note that it is illegal to call this function while holding any lock
292 * from the corresponding SRCU read-side critical section; doing so 301 * that is acquired by a CPU-hotplug notifier. And yes, it is also illegal
293 * will result in deadlock. However, it is perfectly legal to call 302 * to call this function from a CPU-hotplug notifier. Failing to observe
294 * synchronize_srcu_expedited() on one srcu_struct from some other 303 * these restriction will result in deadlock. It is also illegal to call
295 * srcu_struct's read-side critical section. 304 * synchronize_srcu_expedited() from the corresponding SRCU read-side
305 * critical section; doing so will result in deadlock. However, it is
306 * perfectly legal to call synchronize_srcu_expedited() on one srcu_struct
307 * from some other srcu_struct's read-side critical section, as long as
308 * the resulting graph of srcu_structs is acyclic.
296 */ 309 */
297void synchronize_srcu_expedited(struct srcu_struct *sp) 310void synchronize_srcu_expedited(struct srcu_struct *sp)
298{ 311{
diff --git a/kernel/sys.c b/kernel/sys.c
index 40701538fbd1..888d227fd195 100644
--- a/kernel/sys.c
+++ b/kernel/sys.c
@@ -1706,7 +1706,7 @@ static int prctl_set_mm(int opt, unsigned long addr,
1706 if (arg4 | arg5) 1706 if (arg4 | arg5)
1707 return -EINVAL; 1707 return -EINVAL;
1708 1708
1709 if (!capable(CAP_SYS_ADMIN)) 1709 if (!capable(CAP_SYS_RESOURCE))
1710 return -EPERM; 1710 return -EPERM;
1711 1711
1712 if (addr >= TASK_SIZE) 1712 if (addr >= TASK_SIZE)
diff --git a/kernel/time/ntp.c b/kernel/time/ntp.c
index f6117a4c7cb8..6e039b144daf 100644
--- a/kernel/time/ntp.c
+++ b/kernel/time/ntp.c
@@ -22,13 +22,16 @@
22 * NTP timekeeping variables: 22 * NTP timekeeping variables:
23 */ 23 */
24 24
25DEFINE_SPINLOCK(ntp_lock);
26
27
25/* USER_HZ period (usecs): */ 28/* USER_HZ period (usecs): */
26unsigned long tick_usec = TICK_USEC; 29unsigned long tick_usec = TICK_USEC;
27 30
28/* ACTHZ period (nsecs): */ 31/* ACTHZ period (nsecs): */
29unsigned long tick_nsec; 32unsigned long tick_nsec;
30 33
31u64 tick_length; 34static u64 tick_length;
32static u64 tick_length_base; 35static u64 tick_length_base;
33 36
34static struct hrtimer leap_timer; 37static struct hrtimer leap_timer;
@@ -49,7 +52,7 @@ static struct hrtimer leap_timer;
49static int time_state = TIME_OK; 52static int time_state = TIME_OK;
50 53
51/* clock status bits: */ 54/* clock status bits: */
52int time_status = STA_UNSYNC; 55static int time_status = STA_UNSYNC;
53 56
54/* TAI offset (secs): */ 57/* TAI offset (secs): */
55static long time_tai; 58static long time_tai;
@@ -133,7 +136,7 @@ static inline void pps_reset_freq_interval(void)
133/** 136/**
134 * pps_clear - Clears the PPS state variables 137 * pps_clear - Clears the PPS state variables
135 * 138 *
136 * Must be called while holding a write on the xtime_lock 139 * Must be called while holding a write on the ntp_lock
137 */ 140 */
138static inline void pps_clear(void) 141static inline void pps_clear(void)
139{ 142{
@@ -149,7 +152,7 @@ static inline void pps_clear(void)
149 * the last PPS signal. When it reaches 0, indicate that PPS signal is 152 * the last PPS signal. When it reaches 0, indicate that PPS signal is
150 * missing. 153 * missing.
151 * 154 *
152 * Must be called while holding a write on the xtime_lock 155 * Must be called while holding a write on the ntp_lock
153 */ 156 */
154static inline void pps_dec_valid(void) 157static inline void pps_dec_valid(void)
155{ 158{
@@ -233,6 +236,17 @@ static inline void pps_fill_timex(struct timex *txc)
233 236
234#endif /* CONFIG_NTP_PPS */ 237#endif /* CONFIG_NTP_PPS */
235 238
239
240/**
241 * ntp_synced - Returns 1 if the NTP status is not UNSYNC
242 *
243 */
244static inline int ntp_synced(void)
245{
246 return !(time_status & STA_UNSYNC);
247}
248
249
236/* 250/*
237 * NTP methods: 251 * NTP methods:
238 */ 252 */
@@ -275,7 +289,7 @@ static inline s64 ntp_update_offset_fll(s64 offset64, long secs)
275 289
276 time_status |= STA_MODE; 290 time_status |= STA_MODE;
277 291
278 return div_s64(offset64 << (NTP_SCALE_SHIFT - SHIFT_FLL), secs); 292 return div64_long(offset64 << (NTP_SCALE_SHIFT - SHIFT_FLL), secs);
279} 293}
280 294
281static void ntp_update_offset(long offset) 295static void ntp_update_offset(long offset)
@@ -330,11 +344,13 @@ static void ntp_update_offset(long offset)
330 344
331/** 345/**
332 * ntp_clear - Clears the NTP state variables 346 * ntp_clear - Clears the NTP state variables
333 *
334 * Must be called while holding a write on the xtime_lock
335 */ 347 */
336void ntp_clear(void) 348void ntp_clear(void)
337{ 349{
350 unsigned long flags;
351
352 spin_lock_irqsave(&ntp_lock, flags);
353
338 time_adjust = 0; /* stop active adjtime() */ 354 time_adjust = 0; /* stop active adjtime() */
339 time_status |= STA_UNSYNC; 355 time_status |= STA_UNSYNC;
340 time_maxerror = NTP_PHASE_LIMIT; 356 time_maxerror = NTP_PHASE_LIMIT;
@@ -347,8 +363,23 @@ void ntp_clear(void)
347 363
348 /* Clear PPS state variables */ 364 /* Clear PPS state variables */
349 pps_clear(); 365 pps_clear();
366 spin_unlock_irqrestore(&ntp_lock, flags);
367
350} 368}
351 369
370
371u64 ntp_tick_length(void)
372{
373 unsigned long flags;
374 s64 ret;
375
376 spin_lock_irqsave(&ntp_lock, flags);
377 ret = tick_length;
378 spin_unlock_irqrestore(&ntp_lock, flags);
379 return ret;
380}
381
382
352/* 383/*
353 * Leap second processing. If in leap-insert state at the end of the 384 * Leap second processing. If in leap-insert state at the end of the
354 * day, the system clock is set back one second; if in leap-delete 385 * day, the system clock is set back one second; if in leap-delete
@@ -357,14 +388,15 @@ void ntp_clear(void)
357static enum hrtimer_restart ntp_leap_second(struct hrtimer *timer) 388static enum hrtimer_restart ntp_leap_second(struct hrtimer *timer)
358{ 389{
359 enum hrtimer_restart res = HRTIMER_NORESTART; 390 enum hrtimer_restart res = HRTIMER_NORESTART;
391 unsigned long flags;
392 int leap = 0;
360 393
361 write_seqlock(&xtime_lock); 394 spin_lock_irqsave(&ntp_lock, flags);
362
363 switch (time_state) { 395 switch (time_state) {
364 case TIME_OK: 396 case TIME_OK:
365 break; 397 break;
366 case TIME_INS: 398 case TIME_INS:
367 timekeeping_leap_insert(-1); 399 leap = -1;
368 time_state = TIME_OOP; 400 time_state = TIME_OOP;
369 printk(KERN_NOTICE 401 printk(KERN_NOTICE
370 "Clock: inserting leap second 23:59:60 UTC\n"); 402 "Clock: inserting leap second 23:59:60 UTC\n");
@@ -372,7 +404,7 @@ static enum hrtimer_restart ntp_leap_second(struct hrtimer *timer)
372 res = HRTIMER_RESTART; 404 res = HRTIMER_RESTART;
373 break; 405 break;
374 case TIME_DEL: 406 case TIME_DEL:
375 timekeeping_leap_insert(1); 407 leap = 1;
376 time_tai--; 408 time_tai--;
377 time_state = TIME_WAIT; 409 time_state = TIME_WAIT;
378 printk(KERN_NOTICE 410 printk(KERN_NOTICE
@@ -387,8 +419,14 @@ static enum hrtimer_restart ntp_leap_second(struct hrtimer *timer)
387 time_state = TIME_OK; 419 time_state = TIME_OK;
388 break; 420 break;
389 } 421 }
422 spin_unlock_irqrestore(&ntp_lock, flags);
390 423
391 write_sequnlock(&xtime_lock); 424 /*
425 * We have to call this outside of the ntp_lock to keep
426 * the proper locking hierarchy
427 */
428 if (leap)
429 timekeeping_leap_insert(leap);
392 430
393 return res; 431 return res;
394} 432}
@@ -404,6 +442,9 @@ static enum hrtimer_restart ntp_leap_second(struct hrtimer *timer)
404void second_overflow(void) 442void second_overflow(void)
405{ 443{
406 s64 delta; 444 s64 delta;
445 unsigned long flags;
446
447 spin_lock_irqsave(&ntp_lock, flags);
407 448
408 /* Bump the maxerror field */ 449 /* Bump the maxerror field */
409 time_maxerror += MAXFREQ / NSEC_PER_USEC; 450 time_maxerror += MAXFREQ / NSEC_PER_USEC;
@@ -423,23 +464,25 @@ void second_overflow(void)
423 pps_dec_valid(); 464 pps_dec_valid();
424 465
425 if (!time_adjust) 466 if (!time_adjust)
426 return; 467 goto out;
427 468
428 if (time_adjust > MAX_TICKADJ) { 469 if (time_adjust > MAX_TICKADJ) {
429 time_adjust -= MAX_TICKADJ; 470 time_adjust -= MAX_TICKADJ;
430 tick_length += MAX_TICKADJ_SCALED; 471 tick_length += MAX_TICKADJ_SCALED;
431 return; 472 goto out;
432 } 473 }
433 474
434 if (time_adjust < -MAX_TICKADJ) { 475 if (time_adjust < -MAX_TICKADJ) {
435 time_adjust += MAX_TICKADJ; 476 time_adjust += MAX_TICKADJ;
436 tick_length -= MAX_TICKADJ_SCALED; 477 tick_length -= MAX_TICKADJ_SCALED;
437 return; 478 goto out;
438 } 479 }
439 480
440 tick_length += (s64)(time_adjust * NSEC_PER_USEC / NTP_INTERVAL_FREQ) 481 tick_length += (s64)(time_adjust * NSEC_PER_USEC / NTP_INTERVAL_FREQ)
441 << NTP_SCALE_SHIFT; 482 << NTP_SCALE_SHIFT;
442 time_adjust = 0; 483 time_adjust = 0;
484out:
485 spin_unlock_irqrestore(&ntp_lock, flags);
443} 486}
444 487
445#ifdef CONFIG_GENERIC_CMOS_UPDATE 488#ifdef CONFIG_GENERIC_CMOS_UPDATE
@@ -663,7 +706,7 @@ int do_adjtimex(struct timex *txc)
663 706
664 getnstimeofday(&ts); 707 getnstimeofday(&ts);
665 708
666 write_seqlock_irq(&xtime_lock); 709 spin_lock_irq(&ntp_lock);
667 710
668 if (txc->modes & ADJ_ADJTIME) { 711 if (txc->modes & ADJ_ADJTIME) {
669 long save_adjust = time_adjust; 712 long save_adjust = time_adjust;
@@ -705,7 +748,7 @@ int do_adjtimex(struct timex *txc)
705 /* fill PPS status fields */ 748 /* fill PPS status fields */
706 pps_fill_timex(txc); 749 pps_fill_timex(txc);
707 750
708 write_sequnlock_irq(&xtime_lock); 751 spin_unlock_irq(&ntp_lock);
709 752
710 txc->time.tv_sec = ts.tv_sec; 753 txc->time.tv_sec = ts.tv_sec;
711 txc->time.tv_usec = ts.tv_nsec; 754 txc->time.tv_usec = ts.tv_nsec;
@@ -903,7 +946,7 @@ void hardpps(const struct timespec *phase_ts, const struct timespec *raw_ts)
903 946
904 pts_norm = pps_normalize_ts(*phase_ts); 947 pts_norm = pps_normalize_ts(*phase_ts);
905 948
906 write_seqlock_irqsave(&xtime_lock, flags); 949 spin_lock_irqsave(&ntp_lock, flags);
907 950
908 /* clear the error bits, they will be set again if needed */ 951 /* clear the error bits, they will be set again if needed */
909 time_status &= ~(STA_PPSJITTER | STA_PPSWANDER | STA_PPSERROR); 952 time_status &= ~(STA_PPSJITTER | STA_PPSWANDER | STA_PPSERROR);
@@ -916,7 +959,7 @@ void hardpps(const struct timespec *phase_ts, const struct timespec *raw_ts)
916 * just start the frequency interval */ 959 * just start the frequency interval */
917 if (unlikely(pps_fbase.tv_sec == 0)) { 960 if (unlikely(pps_fbase.tv_sec == 0)) {
918 pps_fbase = *raw_ts; 961 pps_fbase = *raw_ts;
919 write_sequnlock_irqrestore(&xtime_lock, flags); 962 spin_unlock_irqrestore(&ntp_lock, flags);
920 return; 963 return;
921 } 964 }
922 965
@@ -931,7 +974,7 @@ void hardpps(const struct timespec *phase_ts, const struct timespec *raw_ts)
931 time_status |= STA_PPSJITTER; 974 time_status |= STA_PPSJITTER;
932 /* restart the frequency calibration interval */ 975 /* restart the frequency calibration interval */
933 pps_fbase = *raw_ts; 976 pps_fbase = *raw_ts;
934 write_sequnlock_irqrestore(&xtime_lock, flags); 977 spin_unlock_irqrestore(&ntp_lock, flags);
935 pr_err("hardpps: PPSJITTER: bad pulse\n"); 978 pr_err("hardpps: PPSJITTER: bad pulse\n");
936 return; 979 return;
937 } 980 }
@@ -948,7 +991,7 @@ void hardpps(const struct timespec *phase_ts, const struct timespec *raw_ts)
948 991
949 hardpps_update_phase(pts_norm.nsec); 992 hardpps_update_phase(pts_norm.nsec);
950 993
951 write_sequnlock_irqrestore(&xtime_lock, flags); 994 spin_unlock_irqrestore(&ntp_lock, flags);
952} 995}
953EXPORT_SYMBOL(hardpps); 996EXPORT_SYMBOL(hardpps);
954 997
diff --git a/kernel/time/tick-broadcast.c b/kernel/time/tick-broadcast.c
index fd4a7b1625a2..e883f57a3cd3 100644
--- a/kernel/time/tick-broadcast.c
+++ b/kernel/time/tick-broadcast.c
@@ -575,11 +575,15 @@ void tick_broadcast_switch_to_oneshot(void)
575 unsigned long flags; 575 unsigned long flags;
576 576
577 raw_spin_lock_irqsave(&tick_broadcast_lock, flags); 577 raw_spin_lock_irqsave(&tick_broadcast_lock, flags);
578 if (cpumask_empty(tick_get_broadcast_mask()))
579 goto end;
578 580
579 tick_broadcast_device.mode = TICKDEV_MODE_ONESHOT; 581 tick_broadcast_device.mode = TICKDEV_MODE_ONESHOT;
580 bc = tick_broadcast_device.evtdev; 582 bc = tick_broadcast_device.evtdev;
581 if (bc) 583 if (bc)
582 tick_broadcast_setup_oneshot(bc); 584 tick_broadcast_setup_oneshot(bc);
585
586end:
583 raw_spin_unlock_irqrestore(&tick_broadcast_lock, flags); 587 raw_spin_unlock_irqrestore(&tick_broadcast_lock, flags);
584} 588}
585 589
diff --git a/kernel/time/tick-sched.c b/kernel/time/tick-sched.c
index 7656642e4b8e..3526038f2836 100644
--- a/kernel/time/tick-sched.c
+++ b/kernel/time/tick-sched.c
@@ -182,11 +182,7 @@ static void tick_nohz_stop_idle(int cpu, ktime_t now)
182 182
183static ktime_t tick_nohz_start_idle(int cpu, struct tick_sched *ts) 183static ktime_t tick_nohz_start_idle(int cpu, struct tick_sched *ts)
184{ 184{
185 ktime_t now; 185 ktime_t now = ktime_get();
186
187 now = ktime_get();
188
189 update_ts_time_stats(cpu, ts, now, NULL);
190 186
191 ts->idle_entrytime = now; 187 ts->idle_entrytime = now;
192 ts->idle_active = 1; 188 ts->idle_active = 1;
@@ -562,20 +558,21 @@ void tick_nohz_idle_exit(void)
562 558
563 local_irq_disable(); 559 local_irq_disable();
564 560
565 if (ts->idle_active || (ts->inidle && ts->tick_stopped)) 561 WARN_ON_ONCE(!ts->inidle);
562
563 ts->inidle = 0;
564
565 if (ts->idle_active || ts->tick_stopped)
566 now = ktime_get(); 566 now = ktime_get();
567 567
568 if (ts->idle_active) 568 if (ts->idle_active)
569 tick_nohz_stop_idle(cpu, now); 569 tick_nohz_stop_idle(cpu, now);
570 570
571 if (!ts->inidle || !ts->tick_stopped) { 571 if (!ts->tick_stopped) {
572 ts->inidle = 0;
573 local_irq_enable(); 572 local_irq_enable();
574 return; 573 return;
575 } 574 }
576 575
577 ts->inidle = 0;
578
579 /* Update jiffies first */ 576 /* Update jiffies first */
580 select_nohz_load_balancer(0); 577 select_nohz_load_balancer(0);
581 tick_do_update_jiffies64(now); 578 tick_do_update_jiffies64(now);
diff --git a/kernel/time/timekeeping.c b/kernel/time/timekeeping.c
index 0c6358186401..403c2a092830 100644
--- a/kernel/time/timekeeping.c
+++ b/kernel/time/timekeeping.c
@@ -25,6 +25,8 @@
25struct timekeeper { 25struct timekeeper {
26 /* Current clocksource used for timekeeping. */ 26 /* Current clocksource used for timekeeping. */
27 struct clocksource *clock; 27 struct clocksource *clock;
28 /* NTP adjusted clock multiplier */
29 u32 mult;
28 /* The shift value of the current clocksource. */ 30 /* The shift value of the current clocksource. */
29 int shift; 31 int shift;
30 32
@@ -45,12 +47,47 @@ struct timekeeper {
45 /* Shift conversion between clock shifted nano seconds and 47 /* Shift conversion between clock shifted nano seconds and
46 * ntp shifted nano seconds. */ 48 * ntp shifted nano seconds. */
47 int ntp_error_shift; 49 int ntp_error_shift;
48 /* NTP adjusted clock multiplier */ 50
49 u32 mult; 51 /* The current time */
52 struct timespec xtime;
53 /*
54 * wall_to_monotonic is what we need to add to xtime (or xtime corrected
55 * for sub jiffie times) to get to monotonic time. Monotonic is pegged
56 * at zero at system boot time, so wall_to_monotonic will be negative,
57 * however, we will ALWAYS keep the tv_nsec part positive so we can use
58 * the usual normalization.
59 *
60 * wall_to_monotonic is moved after resume from suspend for the
61 * monotonic time not to jump. We need to add total_sleep_time to
62 * wall_to_monotonic to get the real boot based time offset.
63 *
64 * - wall_to_monotonic is no longer the boot time, getboottime must be
65 * used instead.
66 */
67 struct timespec wall_to_monotonic;
68 /* time spent in suspend */
69 struct timespec total_sleep_time;
70 /* The raw monotonic time for the CLOCK_MONOTONIC_RAW posix clock. */
71 struct timespec raw_time;
72
73 /* Seqlock for all timekeeper values */
74 seqlock_t lock;
50}; 75};
51 76
52static struct timekeeper timekeeper; 77static struct timekeeper timekeeper;
53 78
79/*
80 * This read-write spinlock protects us from races in SMP while
81 * playing with xtime.
82 */
83__cacheline_aligned_in_smp DEFINE_SEQLOCK(xtime_lock);
84
85
86/* flag for if timekeeping is suspended */
87int __read_mostly timekeeping_suspended;
88
89
90
54/** 91/**
55 * timekeeper_setup_internals - Set up internals to use clocksource clock. 92 * timekeeper_setup_internals - Set up internals to use clocksource clock.
56 * 93 *
@@ -135,47 +172,28 @@ static inline s64 timekeeping_get_ns_raw(void)
135 return clocksource_cyc2ns(cycle_delta, clock->mult, clock->shift); 172 return clocksource_cyc2ns(cycle_delta, clock->mult, clock->shift);
136} 173}
137 174
138/* 175/* must hold write on timekeeper.lock */
139 * This read-write spinlock protects us from races in SMP while 176static void timekeeping_update(bool clearntp)
140 * playing with xtime. 177{
141 */ 178 if (clearntp) {
142__cacheline_aligned_in_smp DEFINE_SEQLOCK(xtime_lock); 179 timekeeper.ntp_error = 0;
143 180 ntp_clear();
144 181 }
145/* 182 update_vsyscall(&timekeeper.xtime, &timekeeper.wall_to_monotonic,
146 * The current time 183 timekeeper.clock, timekeeper.mult);
147 * wall_to_monotonic is what we need to add to xtime (or xtime corrected 184}
148 * for sub jiffie times) to get to monotonic time. Monotonic is pegged
149 * at zero at system boot time, so wall_to_monotonic will be negative,
150 * however, we will ALWAYS keep the tv_nsec part positive so we can use
151 * the usual normalization.
152 *
153 * wall_to_monotonic is moved after resume from suspend for the monotonic
154 * time not to jump. We need to add total_sleep_time to wall_to_monotonic
155 * to get the real boot based time offset.
156 *
157 * - wall_to_monotonic is no longer the boot time, getboottime must be
158 * used instead.
159 */
160static struct timespec xtime __attribute__ ((aligned (16)));
161static struct timespec wall_to_monotonic __attribute__ ((aligned (16)));
162static struct timespec total_sleep_time;
163
164/*
165 * The raw monotonic time for the CLOCK_MONOTONIC_RAW posix clock.
166 */
167static struct timespec raw_time;
168 185
169/* flag for if timekeeping is suspended */
170int __read_mostly timekeeping_suspended;
171 186
172/* must hold xtime_lock */
173void timekeeping_leap_insert(int leapsecond) 187void timekeeping_leap_insert(int leapsecond)
174{ 188{
175 xtime.tv_sec += leapsecond; 189 unsigned long flags;
176 wall_to_monotonic.tv_sec -= leapsecond; 190
177 update_vsyscall(&xtime, &wall_to_monotonic, timekeeper.clock, 191 write_seqlock_irqsave(&timekeeper.lock, flags);
178 timekeeper.mult); 192 timekeeper.xtime.tv_sec += leapsecond;
193 timekeeper.wall_to_monotonic.tv_sec -= leapsecond;
194 timekeeping_update(false);
195 write_sequnlock_irqrestore(&timekeeper.lock, flags);
196
179} 197}
180 198
181/** 199/**
@@ -202,10 +220,10 @@ static void timekeeping_forward_now(void)
202 /* If arch requires, add in gettimeoffset() */ 220 /* If arch requires, add in gettimeoffset() */
203 nsec += arch_gettimeoffset(); 221 nsec += arch_gettimeoffset();
204 222
205 timespec_add_ns(&xtime, nsec); 223 timespec_add_ns(&timekeeper.xtime, nsec);
206 224
207 nsec = clocksource_cyc2ns(cycle_delta, clock->mult, clock->shift); 225 nsec = clocksource_cyc2ns(cycle_delta, clock->mult, clock->shift);
208 timespec_add_ns(&raw_time, nsec); 226 timespec_add_ns(&timekeeper.raw_time, nsec);
209} 227}
210 228
211/** 229/**
@@ -222,15 +240,15 @@ void getnstimeofday(struct timespec *ts)
222 WARN_ON(timekeeping_suspended); 240 WARN_ON(timekeeping_suspended);
223 241
224 do { 242 do {
225 seq = read_seqbegin(&xtime_lock); 243 seq = read_seqbegin(&timekeeper.lock);
226 244
227 *ts = xtime; 245 *ts = timekeeper.xtime;
228 nsecs = timekeeping_get_ns(); 246 nsecs = timekeeping_get_ns();
229 247
230 /* If arch requires, add in gettimeoffset() */ 248 /* If arch requires, add in gettimeoffset() */
231 nsecs += arch_gettimeoffset(); 249 nsecs += arch_gettimeoffset();
232 250
233 } while (read_seqretry(&xtime_lock, seq)); 251 } while (read_seqretry(&timekeeper.lock, seq));
234 252
235 timespec_add_ns(ts, nsecs); 253 timespec_add_ns(ts, nsecs);
236} 254}
@@ -245,14 +263,16 @@ ktime_t ktime_get(void)
245 WARN_ON(timekeeping_suspended); 263 WARN_ON(timekeeping_suspended);
246 264
247 do { 265 do {
248 seq = read_seqbegin(&xtime_lock); 266 seq = read_seqbegin(&timekeeper.lock);
249 secs = xtime.tv_sec + wall_to_monotonic.tv_sec; 267 secs = timekeeper.xtime.tv_sec +
250 nsecs = xtime.tv_nsec + wall_to_monotonic.tv_nsec; 268 timekeeper.wall_to_monotonic.tv_sec;
269 nsecs = timekeeper.xtime.tv_nsec +
270 timekeeper.wall_to_monotonic.tv_nsec;
251 nsecs += timekeeping_get_ns(); 271 nsecs += timekeeping_get_ns();
252 /* If arch requires, add in gettimeoffset() */ 272 /* If arch requires, add in gettimeoffset() */
253 nsecs += arch_gettimeoffset(); 273 nsecs += arch_gettimeoffset();
254 274
255 } while (read_seqretry(&xtime_lock, seq)); 275 } while (read_seqretry(&timekeeper.lock, seq));
256 /* 276 /*
257 * Use ktime_set/ktime_add_ns to create a proper ktime on 277 * Use ktime_set/ktime_add_ns to create a proper ktime on
258 * 32-bit architectures without CONFIG_KTIME_SCALAR. 278 * 32-bit architectures without CONFIG_KTIME_SCALAR.
@@ -278,14 +298,14 @@ void ktime_get_ts(struct timespec *ts)
278 WARN_ON(timekeeping_suspended); 298 WARN_ON(timekeeping_suspended);
279 299
280 do { 300 do {
281 seq = read_seqbegin(&xtime_lock); 301 seq = read_seqbegin(&timekeeper.lock);
282 *ts = xtime; 302 *ts = timekeeper.xtime;
283 tomono = wall_to_monotonic; 303 tomono = timekeeper.wall_to_monotonic;
284 nsecs = timekeeping_get_ns(); 304 nsecs = timekeeping_get_ns();
285 /* If arch requires, add in gettimeoffset() */ 305 /* If arch requires, add in gettimeoffset() */
286 nsecs += arch_gettimeoffset(); 306 nsecs += arch_gettimeoffset();
287 307
288 } while (read_seqretry(&xtime_lock, seq)); 308 } while (read_seqretry(&timekeeper.lock, seq));
289 309
290 set_normalized_timespec(ts, ts->tv_sec + tomono.tv_sec, 310 set_normalized_timespec(ts, ts->tv_sec + tomono.tv_sec,
291 ts->tv_nsec + tomono.tv_nsec + nsecs); 311 ts->tv_nsec + tomono.tv_nsec + nsecs);
@@ -313,10 +333,10 @@ void getnstime_raw_and_real(struct timespec *ts_raw, struct timespec *ts_real)
313 do { 333 do {
314 u32 arch_offset; 334 u32 arch_offset;
315 335
316 seq = read_seqbegin(&xtime_lock); 336 seq = read_seqbegin(&timekeeper.lock);
317 337
318 *ts_raw = raw_time; 338 *ts_raw = timekeeper.raw_time;
319 *ts_real = xtime; 339 *ts_real = timekeeper.xtime;
320 340
321 nsecs_raw = timekeeping_get_ns_raw(); 341 nsecs_raw = timekeeping_get_ns_raw();
322 nsecs_real = timekeeping_get_ns(); 342 nsecs_real = timekeeping_get_ns();
@@ -326,7 +346,7 @@ void getnstime_raw_and_real(struct timespec *ts_raw, struct timespec *ts_real)
326 nsecs_raw += arch_offset; 346 nsecs_raw += arch_offset;
327 nsecs_real += arch_offset; 347 nsecs_real += arch_offset;
328 348
329 } while (read_seqretry(&xtime_lock, seq)); 349 } while (read_seqretry(&timekeeper.lock, seq));
330 350
331 timespec_add_ns(ts_raw, nsecs_raw); 351 timespec_add_ns(ts_raw, nsecs_raw);
332 timespec_add_ns(ts_real, nsecs_real); 352 timespec_add_ns(ts_real, nsecs_real);
@@ -365,23 +385,19 @@ int do_settimeofday(const struct timespec *tv)
365 if ((unsigned long)tv->tv_nsec >= NSEC_PER_SEC) 385 if ((unsigned long)tv->tv_nsec >= NSEC_PER_SEC)
366 return -EINVAL; 386 return -EINVAL;
367 387
368 write_seqlock_irqsave(&xtime_lock, flags); 388 write_seqlock_irqsave(&timekeeper.lock, flags);
369 389
370 timekeeping_forward_now(); 390 timekeeping_forward_now();
371 391
372 ts_delta.tv_sec = tv->tv_sec - xtime.tv_sec; 392 ts_delta.tv_sec = tv->tv_sec - timekeeper.xtime.tv_sec;
373 ts_delta.tv_nsec = tv->tv_nsec - xtime.tv_nsec; 393 ts_delta.tv_nsec = tv->tv_nsec - timekeeper.xtime.tv_nsec;
374 wall_to_monotonic = timespec_sub(wall_to_monotonic, ts_delta); 394 timekeeper.wall_to_monotonic =
375 395 timespec_sub(timekeeper.wall_to_monotonic, ts_delta);
376 xtime = *tv;
377 396
378 timekeeper.ntp_error = 0; 397 timekeeper.xtime = *tv;
379 ntp_clear(); 398 timekeeping_update(true);
380
381 update_vsyscall(&xtime, &wall_to_monotonic, timekeeper.clock,
382 timekeeper.mult);
383 399
384 write_sequnlock_irqrestore(&xtime_lock, flags); 400 write_sequnlock_irqrestore(&timekeeper.lock, flags);
385 401
386 /* signal hrtimers about time change */ 402 /* signal hrtimers about time change */
387 clock_was_set(); 403 clock_was_set();
@@ -405,20 +421,17 @@ int timekeeping_inject_offset(struct timespec *ts)
405 if ((unsigned long)ts->tv_nsec >= NSEC_PER_SEC) 421 if ((unsigned long)ts->tv_nsec >= NSEC_PER_SEC)
406 return -EINVAL; 422 return -EINVAL;
407 423
408 write_seqlock_irqsave(&xtime_lock, flags); 424 write_seqlock_irqsave(&timekeeper.lock, flags);
409 425
410 timekeeping_forward_now(); 426 timekeeping_forward_now();
411 427
412 xtime = timespec_add(xtime, *ts); 428 timekeeper.xtime = timespec_add(timekeeper.xtime, *ts);
413 wall_to_monotonic = timespec_sub(wall_to_monotonic, *ts); 429 timekeeper.wall_to_monotonic =
414 430 timespec_sub(timekeeper.wall_to_monotonic, *ts);
415 timekeeper.ntp_error = 0;
416 ntp_clear();
417 431
418 update_vsyscall(&xtime, &wall_to_monotonic, timekeeper.clock, 432 timekeeping_update(true);
419 timekeeper.mult);
420 433
421 write_sequnlock_irqrestore(&xtime_lock, flags); 434 write_sequnlock_irqrestore(&timekeeper.lock, flags);
422 435
423 /* signal hrtimers about time change */ 436 /* signal hrtimers about time change */
424 clock_was_set(); 437 clock_was_set();
@@ -490,11 +503,11 @@ void getrawmonotonic(struct timespec *ts)
490 s64 nsecs; 503 s64 nsecs;
491 504
492 do { 505 do {
493 seq = read_seqbegin(&xtime_lock); 506 seq = read_seqbegin(&timekeeper.lock);
494 nsecs = timekeeping_get_ns_raw(); 507 nsecs = timekeeping_get_ns_raw();
495 *ts = raw_time; 508 *ts = timekeeper.raw_time;
496 509
497 } while (read_seqretry(&xtime_lock, seq)); 510 } while (read_seqretry(&timekeeper.lock, seq));
498 511
499 timespec_add_ns(ts, nsecs); 512 timespec_add_ns(ts, nsecs);
500} 513}
@@ -510,24 +523,30 @@ int timekeeping_valid_for_hres(void)
510 int ret; 523 int ret;
511 524
512 do { 525 do {
513 seq = read_seqbegin(&xtime_lock); 526 seq = read_seqbegin(&timekeeper.lock);
514 527
515 ret = timekeeper.clock->flags & CLOCK_SOURCE_VALID_FOR_HRES; 528 ret = timekeeper.clock->flags & CLOCK_SOURCE_VALID_FOR_HRES;
516 529
517 } while (read_seqretry(&xtime_lock, seq)); 530 } while (read_seqretry(&timekeeper.lock, seq));
518 531
519 return ret; 532 return ret;
520} 533}
521 534
522/** 535/**
523 * timekeeping_max_deferment - Returns max time the clocksource can be deferred 536 * timekeeping_max_deferment - Returns max time the clocksource can be deferred
524 *
525 * Caller must observe xtime_lock via read_seqbegin/read_seqretry to
526 * ensure that the clocksource does not change!
527 */ 537 */
528u64 timekeeping_max_deferment(void) 538u64 timekeeping_max_deferment(void)
529{ 539{
530 return timekeeper.clock->max_idle_ns; 540 unsigned long seq;
541 u64 ret;
542 do {
543 seq = read_seqbegin(&timekeeper.lock);
544
545 ret = timekeeper.clock->max_idle_ns;
546
547 } while (read_seqretry(&timekeeper.lock, seq));
548
549 return ret;
531} 550}
532 551
533/** 552/**
@@ -572,28 +591,29 @@ void __init timekeeping_init(void)
572 read_persistent_clock(&now); 591 read_persistent_clock(&now);
573 read_boot_clock(&boot); 592 read_boot_clock(&boot);
574 593
575 write_seqlock_irqsave(&xtime_lock, flags); 594 seqlock_init(&timekeeper.lock);
576 595
577 ntp_init(); 596 ntp_init();
578 597
598 write_seqlock_irqsave(&timekeeper.lock, flags);
579 clock = clocksource_default_clock(); 599 clock = clocksource_default_clock();
580 if (clock->enable) 600 if (clock->enable)
581 clock->enable(clock); 601 clock->enable(clock);
582 timekeeper_setup_internals(clock); 602 timekeeper_setup_internals(clock);
583 603
584 xtime.tv_sec = now.tv_sec; 604 timekeeper.xtime.tv_sec = now.tv_sec;
585 xtime.tv_nsec = now.tv_nsec; 605 timekeeper.xtime.tv_nsec = now.tv_nsec;
586 raw_time.tv_sec = 0; 606 timekeeper.raw_time.tv_sec = 0;
587 raw_time.tv_nsec = 0; 607 timekeeper.raw_time.tv_nsec = 0;
588 if (boot.tv_sec == 0 && boot.tv_nsec == 0) { 608 if (boot.tv_sec == 0 && boot.tv_nsec == 0) {
589 boot.tv_sec = xtime.tv_sec; 609 boot.tv_sec = timekeeper.xtime.tv_sec;
590 boot.tv_nsec = xtime.tv_nsec; 610 boot.tv_nsec = timekeeper.xtime.tv_nsec;
591 } 611 }
592 set_normalized_timespec(&wall_to_monotonic, 612 set_normalized_timespec(&timekeeper.wall_to_monotonic,
593 -boot.tv_sec, -boot.tv_nsec); 613 -boot.tv_sec, -boot.tv_nsec);
594 total_sleep_time.tv_sec = 0; 614 timekeeper.total_sleep_time.tv_sec = 0;
595 total_sleep_time.tv_nsec = 0; 615 timekeeper.total_sleep_time.tv_nsec = 0;
596 write_sequnlock_irqrestore(&xtime_lock, flags); 616 write_sequnlock_irqrestore(&timekeeper.lock, flags);
597} 617}
598 618
599/* time in seconds when suspend began */ 619/* time in seconds when suspend began */
@@ -614,9 +634,11 @@ static void __timekeeping_inject_sleeptime(struct timespec *delta)
614 return; 634 return;
615 } 635 }
616 636
617 xtime = timespec_add(xtime, *delta); 637 timekeeper.xtime = timespec_add(timekeeper.xtime, *delta);
618 wall_to_monotonic = timespec_sub(wall_to_monotonic, *delta); 638 timekeeper.wall_to_monotonic =
619 total_sleep_time = timespec_add(total_sleep_time, *delta); 639 timespec_sub(timekeeper.wall_to_monotonic, *delta);
640 timekeeper.total_sleep_time = timespec_add(
641 timekeeper.total_sleep_time, *delta);
620} 642}
621 643
622 644
@@ -640,17 +662,15 @@ void timekeeping_inject_sleeptime(struct timespec *delta)
640 if (!(ts.tv_sec == 0 && ts.tv_nsec == 0)) 662 if (!(ts.tv_sec == 0 && ts.tv_nsec == 0))
641 return; 663 return;
642 664
643 write_seqlock_irqsave(&xtime_lock, flags); 665 write_seqlock_irqsave(&timekeeper.lock, flags);
666
644 timekeeping_forward_now(); 667 timekeeping_forward_now();
645 668
646 __timekeeping_inject_sleeptime(delta); 669 __timekeeping_inject_sleeptime(delta);
647 670
648 timekeeper.ntp_error = 0; 671 timekeeping_update(true);
649 ntp_clear();
650 update_vsyscall(&xtime, &wall_to_monotonic, timekeeper.clock,
651 timekeeper.mult);
652 672
653 write_sequnlock_irqrestore(&xtime_lock, flags); 673 write_sequnlock_irqrestore(&timekeeper.lock, flags);
654 674
655 /* signal hrtimers about time change */ 675 /* signal hrtimers about time change */
656 clock_was_set(); 676 clock_was_set();
@@ -673,7 +693,7 @@ static void timekeeping_resume(void)
673 693
674 clocksource_resume(); 694 clocksource_resume();
675 695
676 write_seqlock_irqsave(&xtime_lock, flags); 696 write_seqlock_irqsave(&timekeeper.lock, flags);
677 697
678 if (timespec_compare(&ts, &timekeeping_suspend_time) > 0) { 698 if (timespec_compare(&ts, &timekeeping_suspend_time) > 0) {
679 ts = timespec_sub(ts, timekeeping_suspend_time); 699 ts = timespec_sub(ts, timekeeping_suspend_time);
@@ -683,7 +703,7 @@ static void timekeeping_resume(void)
683 timekeeper.clock->cycle_last = timekeeper.clock->read(timekeeper.clock); 703 timekeeper.clock->cycle_last = timekeeper.clock->read(timekeeper.clock);
684 timekeeper.ntp_error = 0; 704 timekeeper.ntp_error = 0;
685 timekeeping_suspended = 0; 705 timekeeping_suspended = 0;
686 write_sequnlock_irqrestore(&xtime_lock, flags); 706 write_sequnlock_irqrestore(&timekeeper.lock, flags);
687 707
688 touch_softlockup_watchdog(); 708 touch_softlockup_watchdog();
689 709
@@ -701,7 +721,7 @@ static int timekeeping_suspend(void)
701 721
702 read_persistent_clock(&timekeeping_suspend_time); 722 read_persistent_clock(&timekeeping_suspend_time);
703 723
704 write_seqlock_irqsave(&xtime_lock, flags); 724 write_seqlock_irqsave(&timekeeper.lock, flags);
705 timekeeping_forward_now(); 725 timekeeping_forward_now();
706 timekeeping_suspended = 1; 726 timekeeping_suspended = 1;
707 727
@@ -711,7 +731,7 @@ static int timekeeping_suspend(void)
711 * try to compensate so the difference in system time 731 * try to compensate so the difference in system time
712 * and persistent_clock time stays close to constant. 732 * and persistent_clock time stays close to constant.
713 */ 733 */
714 delta = timespec_sub(xtime, timekeeping_suspend_time); 734 delta = timespec_sub(timekeeper.xtime, timekeeping_suspend_time);
715 delta_delta = timespec_sub(delta, old_delta); 735 delta_delta = timespec_sub(delta, old_delta);
716 if (abs(delta_delta.tv_sec) >= 2) { 736 if (abs(delta_delta.tv_sec) >= 2) {
717 /* 737 /*
@@ -724,7 +744,7 @@ static int timekeeping_suspend(void)
724 timekeeping_suspend_time = 744 timekeeping_suspend_time =
725 timespec_add(timekeeping_suspend_time, delta_delta); 745 timespec_add(timekeeping_suspend_time, delta_delta);
726 } 746 }
727 write_sequnlock_irqrestore(&xtime_lock, flags); 747 write_sequnlock_irqrestore(&timekeeper.lock, flags);
728 748
729 clockevents_notify(CLOCK_EVT_NOTIFY_SUSPEND, NULL); 749 clockevents_notify(CLOCK_EVT_NOTIFY_SUSPEND, NULL);
730 clocksource_suspend(); 750 clocksource_suspend();
@@ -775,7 +795,7 @@ static __always_inline int timekeeping_bigadjust(s64 error, s64 *interval,
775 * Now calculate the error in (1 << look_ahead) ticks, but first 795 * Now calculate the error in (1 << look_ahead) ticks, but first
776 * remove the single look ahead already included in the error. 796 * remove the single look ahead already included in the error.
777 */ 797 */
778 tick_error = tick_length >> (timekeeper.ntp_error_shift + 1); 798 tick_error = ntp_tick_length() >> (timekeeper.ntp_error_shift + 1);
779 tick_error -= timekeeper.xtime_interval >> 1; 799 tick_error -= timekeeper.xtime_interval >> 1;
780 error = ((error - tick_error) >> look_ahead) + tick_error; 800 error = ((error - tick_error) >> look_ahead) + tick_error;
781 801
@@ -943,22 +963,22 @@ static cycle_t logarithmic_accumulation(cycle_t offset, int shift)
943 timekeeper.xtime_nsec += timekeeper.xtime_interval << shift; 963 timekeeper.xtime_nsec += timekeeper.xtime_interval << shift;
944 while (timekeeper.xtime_nsec >= nsecps) { 964 while (timekeeper.xtime_nsec >= nsecps) {
945 timekeeper.xtime_nsec -= nsecps; 965 timekeeper.xtime_nsec -= nsecps;
946 xtime.tv_sec++; 966 timekeeper.xtime.tv_sec++;
947 second_overflow(); 967 second_overflow();
948 } 968 }
949 969
950 /* Accumulate raw time */ 970 /* Accumulate raw time */
951 raw_nsecs = timekeeper.raw_interval << shift; 971 raw_nsecs = timekeeper.raw_interval << shift;
952 raw_nsecs += raw_time.tv_nsec; 972 raw_nsecs += timekeeper.raw_time.tv_nsec;
953 if (raw_nsecs >= NSEC_PER_SEC) { 973 if (raw_nsecs >= NSEC_PER_SEC) {
954 u64 raw_secs = raw_nsecs; 974 u64 raw_secs = raw_nsecs;
955 raw_nsecs = do_div(raw_secs, NSEC_PER_SEC); 975 raw_nsecs = do_div(raw_secs, NSEC_PER_SEC);
956 raw_time.tv_sec += raw_secs; 976 timekeeper.raw_time.tv_sec += raw_secs;
957 } 977 }
958 raw_time.tv_nsec = raw_nsecs; 978 timekeeper.raw_time.tv_nsec = raw_nsecs;
959 979
960 /* Accumulate error between NTP and clock interval */ 980 /* Accumulate error between NTP and clock interval */
961 timekeeper.ntp_error += tick_length << shift; 981 timekeeper.ntp_error += ntp_tick_length() << shift;
962 timekeeper.ntp_error -= 982 timekeeper.ntp_error -=
963 (timekeeper.xtime_interval + timekeeper.xtime_remainder) << 983 (timekeeper.xtime_interval + timekeeper.xtime_remainder) <<
964 (timekeeper.ntp_error_shift + shift); 984 (timekeeper.ntp_error_shift + shift);
@@ -970,17 +990,19 @@ static cycle_t logarithmic_accumulation(cycle_t offset, int shift)
970/** 990/**
971 * update_wall_time - Uses the current clocksource to increment the wall time 991 * update_wall_time - Uses the current clocksource to increment the wall time
972 * 992 *
973 * Called from the timer interrupt, must hold a write on xtime_lock.
974 */ 993 */
975static void update_wall_time(void) 994static void update_wall_time(void)
976{ 995{
977 struct clocksource *clock; 996 struct clocksource *clock;
978 cycle_t offset; 997 cycle_t offset;
979 int shift = 0, maxshift; 998 int shift = 0, maxshift;
999 unsigned long flags;
1000
1001 write_seqlock_irqsave(&timekeeper.lock, flags);
980 1002
981 /* Make sure we're fully resumed: */ 1003 /* Make sure we're fully resumed: */
982 if (unlikely(timekeeping_suspended)) 1004 if (unlikely(timekeeping_suspended))
983 return; 1005 goto out;
984 1006
985 clock = timekeeper.clock; 1007 clock = timekeeper.clock;
986 1008
@@ -989,7 +1011,8 @@ static void update_wall_time(void)
989#else 1011#else
990 offset = (clock->read(clock) - clock->cycle_last) & clock->mask; 1012 offset = (clock->read(clock) - clock->cycle_last) & clock->mask;
991#endif 1013#endif
992 timekeeper.xtime_nsec = (s64)xtime.tv_nsec << timekeeper.shift; 1014 timekeeper.xtime_nsec = (s64)timekeeper.xtime.tv_nsec <<
1015 timekeeper.shift;
993 1016
994 /* 1017 /*
995 * With NO_HZ we may have to accumulate many cycle_intervals 1018 * With NO_HZ we may have to accumulate many cycle_intervals
@@ -1002,7 +1025,7 @@ static void update_wall_time(void)
1002 shift = ilog2(offset) - ilog2(timekeeper.cycle_interval); 1025 shift = ilog2(offset) - ilog2(timekeeper.cycle_interval);
1003 shift = max(0, shift); 1026 shift = max(0, shift);
1004 /* Bound shift to one less then what overflows tick_length */ 1027 /* Bound shift to one less then what overflows tick_length */
1005 maxshift = (8*sizeof(tick_length) - (ilog2(tick_length)+1)) - 1; 1028 maxshift = (64 - (ilog2(ntp_tick_length())+1)) - 1;
1006 shift = min(shift, maxshift); 1029 shift = min(shift, maxshift);
1007 while (offset >= timekeeper.cycle_interval) { 1030 while (offset >= timekeeper.cycle_interval) {
1008 offset = logarithmic_accumulation(offset, shift); 1031 offset = logarithmic_accumulation(offset, shift);
@@ -1040,8 +1063,10 @@ static void update_wall_time(void)
1040 * Store full nanoseconds into xtime after rounding it up and 1063 * Store full nanoseconds into xtime after rounding it up and
1041 * add the remainder to the error difference. 1064 * add the remainder to the error difference.
1042 */ 1065 */
1043 xtime.tv_nsec = ((s64) timekeeper.xtime_nsec >> timekeeper.shift) + 1; 1066 timekeeper.xtime.tv_nsec = ((s64)timekeeper.xtime_nsec >>
1044 timekeeper.xtime_nsec -= (s64) xtime.tv_nsec << timekeeper.shift; 1067 timekeeper.shift) + 1;
1068 timekeeper.xtime_nsec -= (s64)timekeeper.xtime.tv_nsec <<
1069 timekeeper.shift;
1045 timekeeper.ntp_error += timekeeper.xtime_nsec << 1070 timekeeper.ntp_error += timekeeper.xtime_nsec <<
1046 timekeeper.ntp_error_shift; 1071 timekeeper.ntp_error_shift;
1047 1072
@@ -1049,15 +1074,17 @@ static void update_wall_time(void)
1049 * Finally, make sure that after the rounding 1074 * Finally, make sure that after the rounding
1050 * xtime.tv_nsec isn't larger then NSEC_PER_SEC 1075 * xtime.tv_nsec isn't larger then NSEC_PER_SEC
1051 */ 1076 */
1052 if (unlikely(xtime.tv_nsec >= NSEC_PER_SEC)) { 1077 if (unlikely(timekeeper.xtime.tv_nsec >= NSEC_PER_SEC)) {
1053 xtime.tv_nsec -= NSEC_PER_SEC; 1078 timekeeper.xtime.tv_nsec -= NSEC_PER_SEC;
1054 xtime.tv_sec++; 1079 timekeeper.xtime.tv_sec++;
1055 second_overflow(); 1080 second_overflow();
1056 } 1081 }
1057 1082
1058 /* check to see if there is a new clocksource to use */ 1083 timekeeping_update(false);
1059 update_vsyscall(&xtime, &wall_to_monotonic, timekeeper.clock, 1084
1060 timekeeper.mult); 1085out:
1086 write_sequnlock_irqrestore(&timekeeper.lock, flags);
1087
1061} 1088}
1062 1089
1063/** 1090/**
@@ -1074,8 +1101,10 @@ static void update_wall_time(void)
1074void getboottime(struct timespec *ts) 1101void getboottime(struct timespec *ts)
1075{ 1102{
1076 struct timespec boottime = { 1103 struct timespec boottime = {
1077 .tv_sec = wall_to_monotonic.tv_sec + total_sleep_time.tv_sec, 1104 .tv_sec = timekeeper.wall_to_monotonic.tv_sec +
1078 .tv_nsec = wall_to_monotonic.tv_nsec + total_sleep_time.tv_nsec 1105 timekeeper.total_sleep_time.tv_sec,
1106 .tv_nsec = timekeeper.wall_to_monotonic.tv_nsec +
1107 timekeeper.total_sleep_time.tv_nsec
1079 }; 1108 };
1080 1109
1081 set_normalized_timespec(ts, -boottime.tv_sec, -boottime.tv_nsec); 1110 set_normalized_timespec(ts, -boottime.tv_sec, -boottime.tv_nsec);
@@ -1101,13 +1130,13 @@ void get_monotonic_boottime(struct timespec *ts)
1101 WARN_ON(timekeeping_suspended); 1130 WARN_ON(timekeeping_suspended);
1102 1131
1103 do { 1132 do {
1104 seq = read_seqbegin(&xtime_lock); 1133 seq = read_seqbegin(&timekeeper.lock);
1105 *ts = xtime; 1134 *ts = timekeeper.xtime;
1106 tomono = wall_to_monotonic; 1135 tomono = timekeeper.wall_to_monotonic;
1107 sleep = total_sleep_time; 1136 sleep = timekeeper.total_sleep_time;
1108 nsecs = timekeeping_get_ns(); 1137 nsecs = timekeeping_get_ns();
1109 1138
1110 } while (read_seqretry(&xtime_lock, seq)); 1139 } while (read_seqretry(&timekeeper.lock, seq));
1111 1140
1112 set_normalized_timespec(ts, ts->tv_sec + tomono.tv_sec + sleep.tv_sec, 1141 set_normalized_timespec(ts, ts->tv_sec + tomono.tv_sec + sleep.tv_sec,
1113 ts->tv_nsec + tomono.tv_nsec + sleep.tv_nsec + nsecs); 1142 ts->tv_nsec + tomono.tv_nsec + sleep.tv_nsec + nsecs);
@@ -1137,19 +1166,19 @@ EXPORT_SYMBOL_GPL(ktime_get_boottime);
1137 */ 1166 */
1138void monotonic_to_bootbased(struct timespec *ts) 1167void monotonic_to_bootbased(struct timespec *ts)
1139{ 1168{
1140 *ts = timespec_add(*ts, total_sleep_time); 1169 *ts = timespec_add(*ts, timekeeper.total_sleep_time);
1141} 1170}
1142EXPORT_SYMBOL_GPL(monotonic_to_bootbased); 1171EXPORT_SYMBOL_GPL(monotonic_to_bootbased);
1143 1172
1144unsigned long get_seconds(void) 1173unsigned long get_seconds(void)
1145{ 1174{
1146 return xtime.tv_sec; 1175 return timekeeper.xtime.tv_sec;
1147} 1176}
1148EXPORT_SYMBOL(get_seconds); 1177EXPORT_SYMBOL(get_seconds);
1149 1178
1150struct timespec __current_kernel_time(void) 1179struct timespec __current_kernel_time(void)
1151{ 1180{
1152 return xtime; 1181 return timekeeper.xtime;
1153} 1182}
1154 1183
1155struct timespec current_kernel_time(void) 1184struct timespec current_kernel_time(void)
@@ -1158,10 +1187,10 @@ struct timespec current_kernel_time(void)
1158 unsigned long seq; 1187 unsigned long seq;
1159 1188
1160 do { 1189 do {
1161 seq = read_seqbegin(&xtime_lock); 1190 seq = read_seqbegin(&timekeeper.lock);
1162 1191
1163 now = xtime; 1192 now = timekeeper.xtime;
1164 } while (read_seqretry(&xtime_lock, seq)); 1193 } while (read_seqretry(&timekeeper.lock, seq));
1165 1194
1166 return now; 1195 return now;
1167} 1196}
@@ -1173,11 +1202,11 @@ struct timespec get_monotonic_coarse(void)
1173 unsigned long seq; 1202 unsigned long seq;
1174 1203
1175 do { 1204 do {
1176 seq = read_seqbegin(&xtime_lock); 1205 seq = read_seqbegin(&timekeeper.lock);
1177 1206
1178 now = xtime; 1207 now = timekeeper.xtime;
1179 mono = wall_to_monotonic; 1208 mono = timekeeper.wall_to_monotonic;
1180 } while (read_seqretry(&xtime_lock, seq)); 1209 } while (read_seqretry(&timekeeper.lock, seq));
1181 1210
1182 set_normalized_timespec(&now, now.tv_sec + mono.tv_sec, 1211 set_normalized_timespec(&now, now.tv_sec + mono.tv_sec,
1183 now.tv_nsec + mono.tv_nsec); 1212 now.tv_nsec + mono.tv_nsec);
@@ -1209,11 +1238,11 @@ void get_xtime_and_monotonic_and_sleep_offset(struct timespec *xtim,
1209 unsigned long seq; 1238 unsigned long seq;
1210 1239
1211 do { 1240 do {
1212 seq = read_seqbegin(&xtime_lock); 1241 seq = read_seqbegin(&timekeeper.lock);
1213 *xtim = xtime; 1242 *xtim = timekeeper.xtime;
1214 *wtom = wall_to_monotonic; 1243 *wtom = timekeeper.wall_to_monotonic;
1215 *sleep = total_sleep_time; 1244 *sleep = timekeeper.total_sleep_time;
1216 } while (read_seqretry(&xtime_lock, seq)); 1245 } while (read_seqretry(&timekeeper.lock, seq));
1217} 1246}
1218 1247
1219/** 1248/**
@@ -1225,9 +1254,10 @@ ktime_t ktime_get_monotonic_offset(void)
1225 struct timespec wtom; 1254 struct timespec wtom;
1226 1255
1227 do { 1256 do {
1228 seq = read_seqbegin(&xtime_lock); 1257 seq = read_seqbegin(&timekeeper.lock);
1229 wtom = wall_to_monotonic; 1258 wtom = timekeeper.wall_to_monotonic;
1230 } while (read_seqretry(&xtime_lock, seq)); 1259 } while (read_seqretry(&timekeeper.lock, seq));
1260
1231 return timespec_to_ktime(wtom); 1261 return timespec_to_ktime(wtom);
1232} 1262}
1233 1263
diff --git a/kernel/trace/Kconfig b/kernel/trace/Kconfig
index cd3134510f3d..a1d2849f2473 100644
--- a/kernel/trace/Kconfig
+++ b/kernel/trace/Kconfig
@@ -141,7 +141,7 @@ if FTRACE
141config FUNCTION_TRACER 141config FUNCTION_TRACER
142 bool "Kernel Function Tracer" 142 bool "Kernel Function Tracer"
143 depends on HAVE_FUNCTION_TRACER 143 depends on HAVE_FUNCTION_TRACER
144 select FRAME_POINTER if !ARM_UNWIND && !S390 && !MICROBLAZE 144 select FRAME_POINTER if !ARM_UNWIND && !PPC && !S390 && !MICROBLAZE
145 select KALLSYMS 145 select KALLSYMS
146 select GENERIC_TRACER 146 select GENERIC_TRACER
147 select CONTEXT_SWITCH_TRACER 147 select CONTEXT_SWITCH_TRACER
diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c
index 683d559a0eef..0fa92f677c92 100644
--- a/kernel/trace/ftrace.c
+++ b/kernel/trace/ftrace.c
@@ -62,6 +62,8 @@
62#define FTRACE_HASH_DEFAULT_BITS 10 62#define FTRACE_HASH_DEFAULT_BITS 10
63#define FTRACE_HASH_MAX_BITS 12 63#define FTRACE_HASH_MAX_BITS 12
64 64
65#define FL_GLOBAL_CONTROL_MASK (FTRACE_OPS_FL_GLOBAL | FTRACE_OPS_FL_CONTROL)
66
65/* ftrace_enabled is a method to turn ftrace on or off */ 67/* ftrace_enabled is a method to turn ftrace on or off */
66int ftrace_enabled __read_mostly; 68int ftrace_enabled __read_mostly;
67static int last_ftrace_enabled; 69static int last_ftrace_enabled;
@@ -89,12 +91,14 @@ static struct ftrace_ops ftrace_list_end __read_mostly = {
89}; 91};
90 92
91static struct ftrace_ops *ftrace_global_list __read_mostly = &ftrace_list_end; 93static struct ftrace_ops *ftrace_global_list __read_mostly = &ftrace_list_end;
94static struct ftrace_ops *ftrace_control_list __read_mostly = &ftrace_list_end;
92static struct ftrace_ops *ftrace_ops_list __read_mostly = &ftrace_list_end; 95static struct ftrace_ops *ftrace_ops_list __read_mostly = &ftrace_list_end;
93ftrace_func_t ftrace_trace_function __read_mostly = ftrace_stub; 96ftrace_func_t ftrace_trace_function __read_mostly = ftrace_stub;
94static ftrace_func_t __ftrace_trace_function_delay __read_mostly = ftrace_stub; 97static ftrace_func_t __ftrace_trace_function_delay __read_mostly = ftrace_stub;
95ftrace_func_t __ftrace_trace_function __read_mostly = ftrace_stub; 98ftrace_func_t __ftrace_trace_function __read_mostly = ftrace_stub;
96ftrace_func_t ftrace_pid_function __read_mostly = ftrace_stub; 99ftrace_func_t ftrace_pid_function __read_mostly = ftrace_stub;
97static struct ftrace_ops global_ops; 100static struct ftrace_ops global_ops;
101static struct ftrace_ops control_ops;
98 102
99static void 103static void
100ftrace_ops_list_func(unsigned long ip, unsigned long parent_ip); 104ftrace_ops_list_func(unsigned long ip, unsigned long parent_ip);
@@ -168,6 +172,32 @@ static void ftrace_test_stop_func(unsigned long ip, unsigned long parent_ip)
168} 172}
169#endif 173#endif
170 174
175static void control_ops_disable_all(struct ftrace_ops *ops)
176{
177 int cpu;
178
179 for_each_possible_cpu(cpu)
180 *per_cpu_ptr(ops->disabled, cpu) = 1;
181}
182
183static int control_ops_alloc(struct ftrace_ops *ops)
184{
185 int __percpu *disabled;
186
187 disabled = alloc_percpu(int);
188 if (!disabled)
189 return -ENOMEM;
190
191 ops->disabled = disabled;
192 control_ops_disable_all(ops);
193 return 0;
194}
195
196static void control_ops_free(struct ftrace_ops *ops)
197{
198 free_percpu(ops->disabled);
199}
200
171static void update_global_ops(void) 201static void update_global_ops(void)
172{ 202{
173 ftrace_func_t func; 203 ftrace_func_t func;
@@ -219,7 +249,8 @@ static void update_ftrace_function(void)
219#else 249#else
220 __ftrace_trace_function = func; 250 __ftrace_trace_function = func;
221#endif 251#endif
222 ftrace_trace_function = ftrace_test_stop_func; 252 ftrace_trace_function =
253 (func == ftrace_stub) ? func : ftrace_test_stop_func;
223#endif 254#endif
224} 255}
225 256
@@ -259,6 +290,26 @@ static int remove_ftrace_ops(struct ftrace_ops **list, struct ftrace_ops *ops)
259 return 0; 290 return 0;
260} 291}
261 292
293static void add_ftrace_list_ops(struct ftrace_ops **list,
294 struct ftrace_ops *main_ops,
295 struct ftrace_ops *ops)
296{
297 int first = *list == &ftrace_list_end;
298 add_ftrace_ops(list, ops);
299 if (first)
300 add_ftrace_ops(&ftrace_ops_list, main_ops);
301}
302
303static int remove_ftrace_list_ops(struct ftrace_ops **list,
304 struct ftrace_ops *main_ops,
305 struct ftrace_ops *ops)
306{
307 int ret = remove_ftrace_ops(list, ops);
308 if (!ret && *list == &ftrace_list_end)
309 ret = remove_ftrace_ops(&ftrace_ops_list, main_ops);
310 return ret;
311}
312
262static int __register_ftrace_function(struct ftrace_ops *ops) 313static int __register_ftrace_function(struct ftrace_ops *ops)
263{ 314{
264 if (ftrace_disabled) 315 if (ftrace_disabled)
@@ -270,15 +321,20 @@ static int __register_ftrace_function(struct ftrace_ops *ops)
270 if (WARN_ON(ops->flags & FTRACE_OPS_FL_ENABLED)) 321 if (WARN_ON(ops->flags & FTRACE_OPS_FL_ENABLED))
271 return -EBUSY; 322 return -EBUSY;
272 323
324 /* We don't support both control and global flags set. */
325 if ((ops->flags & FL_GLOBAL_CONTROL_MASK) == FL_GLOBAL_CONTROL_MASK)
326 return -EINVAL;
327
273 if (!core_kernel_data((unsigned long)ops)) 328 if (!core_kernel_data((unsigned long)ops))
274 ops->flags |= FTRACE_OPS_FL_DYNAMIC; 329 ops->flags |= FTRACE_OPS_FL_DYNAMIC;
275 330
276 if (ops->flags & FTRACE_OPS_FL_GLOBAL) { 331 if (ops->flags & FTRACE_OPS_FL_GLOBAL) {
277 int first = ftrace_global_list == &ftrace_list_end; 332 add_ftrace_list_ops(&ftrace_global_list, &global_ops, ops);
278 add_ftrace_ops(&ftrace_global_list, ops);
279 ops->flags |= FTRACE_OPS_FL_ENABLED; 333 ops->flags |= FTRACE_OPS_FL_ENABLED;
280 if (first) 334 } else if (ops->flags & FTRACE_OPS_FL_CONTROL) {
281 add_ftrace_ops(&ftrace_ops_list, &global_ops); 335 if (control_ops_alloc(ops))
336 return -ENOMEM;
337 add_ftrace_list_ops(&ftrace_control_list, &control_ops, ops);
282 } else 338 } else
283 add_ftrace_ops(&ftrace_ops_list, ops); 339 add_ftrace_ops(&ftrace_ops_list, ops);
284 340
@@ -302,11 +358,23 @@ static int __unregister_ftrace_function(struct ftrace_ops *ops)
302 return -EINVAL; 358 return -EINVAL;
303 359
304 if (ops->flags & FTRACE_OPS_FL_GLOBAL) { 360 if (ops->flags & FTRACE_OPS_FL_GLOBAL) {
305 ret = remove_ftrace_ops(&ftrace_global_list, ops); 361 ret = remove_ftrace_list_ops(&ftrace_global_list,
306 if (!ret && ftrace_global_list == &ftrace_list_end) 362 &global_ops, ops);
307 ret = remove_ftrace_ops(&ftrace_ops_list, &global_ops);
308 if (!ret) 363 if (!ret)
309 ops->flags &= ~FTRACE_OPS_FL_ENABLED; 364 ops->flags &= ~FTRACE_OPS_FL_ENABLED;
365 } else if (ops->flags & FTRACE_OPS_FL_CONTROL) {
366 ret = remove_ftrace_list_ops(&ftrace_control_list,
367 &control_ops, ops);
368 if (!ret) {
369 /*
370 * The ftrace_ops is now removed from the list,
371 * so there'll be no new users. We must ensure
372 * all current users are done before we free
373 * the control data.
374 */
375 synchronize_sched();
376 control_ops_free(ops);
377 }
310 } else 378 } else
311 ret = remove_ftrace_ops(&ftrace_ops_list, ops); 379 ret = remove_ftrace_ops(&ftrace_ops_list, ops);
312 380
@@ -1119,6 +1187,12 @@ static void free_ftrace_hash_rcu(struct ftrace_hash *hash)
1119 call_rcu_sched(&hash->rcu, __free_ftrace_hash_rcu); 1187 call_rcu_sched(&hash->rcu, __free_ftrace_hash_rcu);
1120} 1188}
1121 1189
1190void ftrace_free_filter(struct ftrace_ops *ops)
1191{
1192 free_ftrace_hash(ops->filter_hash);
1193 free_ftrace_hash(ops->notrace_hash);
1194}
1195
1122static struct ftrace_hash *alloc_ftrace_hash(int size_bits) 1196static struct ftrace_hash *alloc_ftrace_hash(int size_bits)
1123{ 1197{
1124 struct ftrace_hash *hash; 1198 struct ftrace_hash *hash;
@@ -1129,7 +1203,7 @@ static struct ftrace_hash *alloc_ftrace_hash(int size_bits)
1129 return NULL; 1203 return NULL;
1130 1204
1131 size = 1 << size_bits; 1205 size = 1 << size_bits;
1132 hash->buckets = kzalloc(sizeof(*hash->buckets) * size, GFP_KERNEL); 1206 hash->buckets = kcalloc(size, sizeof(*hash->buckets), GFP_KERNEL);
1133 1207
1134 if (!hash->buckets) { 1208 if (!hash->buckets) {
1135 kfree(hash); 1209 kfree(hash);
@@ -3146,8 +3220,10 @@ ftrace_set_regex(struct ftrace_ops *ops, unsigned char *buf, int len,
3146 mutex_lock(&ftrace_regex_lock); 3220 mutex_lock(&ftrace_regex_lock);
3147 if (reset) 3221 if (reset)
3148 ftrace_filter_reset(hash); 3222 ftrace_filter_reset(hash);
3149 if (buf) 3223 if (buf && !ftrace_match_records(hash, buf, len)) {
3150 ftrace_match_records(hash, buf, len); 3224 ret = -EINVAL;
3225 goto out_regex_unlock;
3226 }
3151 3227
3152 mutex_lock(&ftrace_lock); 3228 mutex_lock(&ftrace_lock);
3153 ret = ftrace_hash_move(ops, enable, orig_hash, hash); 3229 ret = ftrace_hash_move(ops, enable, orig_hash, hash);
@@ -3157,6 +3233,7 @@ ftrace_set_regex(struct ftrace_ops *ops, unsigned char *buf, int len,
3157 3233
3158 mutex_unlock(&ftrace_lock); 3234 mutex_unlock(&ftrace_lock);
3159 3235
3236 out_regex_unlock:
3160 mutex_unlock(&ftrace_regex_lock); 3237 mutex_unlock(&ftrace_regex_lock);
3161 3238
3162 free_ftrace_hash(hash); 3239 free_ftrace_hash(hash);
@@ -3173,10 +3250,10 @@ ftrace_set_regex(struct ftrace_ops *ops, unsigned char *buf, int len,
3173 * Filters denote which functions should be enabled when tracing is enabled. 3250 * Filters denote which functions should be enabled when tracing is enabled.
3174 * If @buf is NULL and reset is set, all functions will be enabled for tracing. 3251 * If @buf is NULL and reset is set, all functions will be enabled for tracing.
3175 */ 3252 */
3176void ftrace_set_filter(struct ftrace_ops *ops, unsigned char *buf, 3253int ftrace_set_filter(struct ftrace_ops *ops, unsigned char *buf,
3177 int len, int reset) 3254 int len, int reset)
3178{ 3255{
3179 ftrace_set_regex(ops, buf, len, reset, 1); 3256 return ftrace_set_regex(ops, buf, len, reset, 1);
3180} 3257}
3181EXPORT_SYMBOL_GPL(ftrace_set_filter); 3258EXPORT_SYMBOL_GPL(ftrace_set_filter);
3182 3259
@@ -3191,10 +3268,10 @@ EXPORT_SYMBOL_GPL(ftrace_set_filter);
3191 * is enabled. If @buf is NULL and reset is set, all functions will be enabled 3268 * is enabled. If @buf is NULL and reset is set, all functions will be enabled
3192 * for tracing. 3269 * for tracing.
3193 */ 3270 */
3194void ftrace_set_notrace(struct ftrace_ops *ops, unsigned char *buf, 3271int ftrace_set_notrace(struct ftrace_ops *ops, unsigned char *buf,
3195 int len, int reset) 3272 int len, int reset)
3196{ 3273{
3197 ftrace_set_regex(ops, buf, len, reset, 0); 3274 return ftrace_set_regex(ops, buf, len, reset, 0);
3198} 3275}
3199EXPORT_SYMBOL_GPL(ftrace_set_notrace); 3276EXPORT_SYMBOL_GPL(ftrace_set_notrace);
3200/** 3277/**
@@ -3871,6 +3948,36 @@ ftrace_ops_test(struct ftrace_ops *ops, unsigned long ip)
3871#endif /* CONFIG_DYNAMIC_FTRACE */ 3948#endif /* CONFIG_DYNAMIC_FTRACE */
3872 3949
3873static void 3950static void
3951ftrace_ops_control_func(unsigned long ip, unsigned long parent_ip)
3952{
3953 struct ftrace_ops *op;
3954
3955 if (unlikely(trace_recursion_test(TRACE_CONTROL_BIT)))
3956 return;
3957
3958 /*
3959 * Some of the ops may be dynamically allocated,
3960 * they must be freed after a synchronize_sched().
3961 */
3962 preempt_disable_notrace();
3963 trace_recursion_set(TRACE_CONTROL_BIT);
3964 op = rcu_dereference_raw(ftrace_control_list);
3965 while (op != &ftrace_list_end) {
3966 if (!ftrace_function_local_disabled(op) &&
3967 ftrace_ops_test(op, ip))
3968 op->func(ip, parent_ip);
3969
3970 op = rcu_dereference_raw(op->next);
3971 };
3972 trace_recursion_clear(TRACE_CONTROL_BIT);
3973 preempt_enable_notrace();
3974}
3975
3976static struct ftrace_ops control_ops = {
3977 .func = ftrace_ops_control_func,
3978};
3979
3980static void
3874ftrace_ops_list_func(unsigned long ip, unsigned long parent_ip) 3981ftrace_ops_list_func(unsigned long ip, unsigned long parent_ip)
3875{ 3982{
3876 struct ftrace_ops *op; 3983 struct ftrace_ops *op;
diff --git a/kernel/trace/ring_buffer.c b/kernel/trace/ring_buffer.c
index f5b7b5c1195b..cf8d11e91efd 100644
--- a/kernel/trace/ring_buffer.c
+++ b/kernel/trace/ring_buffer.c
@@ -154,33 +154,10 @@ enum {
154 154
155static unsigned long ring_buffer_flags __read_mostly = RB_BUFFERS_ON; 155static unsigned long ring_buffer_flags __read_mostly = RB_BUFFERS_ON;
156 156
157#define BUF_PAGE_HDR_SIZE offsetof(struct buffer_data_page, data) 157/* Used for individual buffers (after the counter) */
158 158#define RB_BUFFER_OFF (1 << 20)
159/**
160 * tracing_on - enable all tracing buffers
161 *
162 * This function enables all tracing buffers that may have been
163 * disabled with tracing_off.
164 */
165void tracing_on(void)
166{
167 set_bit(RB_BUFFERS_ON_BIT, &ring_buffer_flags);
168}
169EXPORT_SYMBOL_GPL(tracing_on);
170 159
171/** 160#define BUF_PAGE_HDR_SIZE offsetof(struct buffer_data_page, data)
172 * tracing_off - turn off all tracing buffers
173 *
174 * This function stops all tracing buffers from recording data.
175 * It does not disable any overhead the tracers themselves may
176 * be causing. This function simply causes all recording to
177 * the ring buffers to fail.
178 */
179void tracing_off(void)
180{
181 clear_bit(RB_BUFFERS_ON_BIT, &ring_buffer_flags);
182}
183EXPORT_SYMBOL_GPL(tracing_off);
184 161
185/** 162/**
186 * tracing_off_permanent - permanently disable ring buffers 163 * tracing_off_permanent - permanently disable ring buffers
@@ -193,15 +170,6 @@ void tracing_off_permanent(void)
193 set_bit(RB_BUFFERS_DISABLED_BIT, &ring_buffer_flags); 170 set_bit(RB_BUFFERS_DISABLED_BIT, &ring_buffer_flags);
194} 171}
195 172
196/**
197 * tracing_is_on - show state of ring buffers enabled
198 */
199int tracing_is_on(void)
200{
201 return ring_buffer_flags == RB_BUFFERS_ON;
202}
203EXPORT_SYMBOL_GPL(tracing_is_on);
204
205#define RB_EVNT_HDR_SIZE (offsetof(struct ring_buffer_event, array)) 173#define RB_EVNT_HDR_SIZE (offsetof(struct ring_buffer_event, array))
206#define RB_ALIGNMENT 4U 174#define RB_ALIGNMENT 4U
207#define RB_MAX_SMALL_DATA (RB_ALIGNMENT * RINGBUF_TYPE_DATA_TYPE_LEN_MAX) 175#define RB_MAX_SMALL_DATA (RB_ALIGNMENT * RINGBUF_TYPE_DATA_TYPE_LEN_MAX)
@@ -2619,6 +2587,63 @@ void ring_buffer_record_enable(struct ring_buffer *buffer)
2619EXPORT_SYMBOL_GPL(ring_buffer_record_enable); 2587EXPORT_SYMBOL_GPL(ring_buffer_record_enable);
2620 2588
2621/** 2589/**
2590 * ring_buffer_record_off - stop all writes into the buffer
2591 * @buffer: The ring buffer to stop writes to.
2592 *
2593 * This prevents all writes to the buffer. Any attempt to write
2594 * to the buffer after this will fail and return NULL.
2595 *
2596 * This is different than ring_buffer_record_disable() as
2597 * it works like an on/off switch, where as the disable() verison
2598 * must be paired with a enable().
2599 */
2600void ring_buffer_record_off(struct ring_buffer *buffer)
2601{
2602 unsigned int rd;
2603 unsigned int new_rd;
2604
2605 do {
2606 rd = atomic_read(&buffer->record_disabled);
2607 new_rd = rd | RB_BUFFER_OFF;
2608 } while (atomic_cmpxchg(&buffer->record_disabled, rd, new_rd) != rd);
2609}
2610EXPORT_SYMBOL_GPL(ring_buffer_record_off);
2611
2612/**
2613 * ring_buffer_record_on - restart writes into the buffer
2614 * @buffer: The ring buffer to start writes to.
2615 *
2616 * This enables all writes to the buffer that was disabled by
2617 * ring_buffer_record_off().
2618 *
2619 * This is different than ring_buffer_record_enable() as
2620 * it works like an on/off switch, where as the enable() verison
2621 * must be paired with a disable().
2622 */
2623void ring_buffer_record_on(struct ring_buffer *buffer)
2624{
2625 unsigned int rd;
2626 unsigned int new_rd;
2627
2628 do {
2629 rd = atomic_read(&buffer->record_disabled);
2630 new_rd = rd & ~RB_BUFFER_OFF;
2631 } while (atomic_cmpxchg(&buffer->record_disabled, rd, new_rd) != rd);
2632}
2633EXPORT_SYMBOL_GPL(ring_buffer_record_on);
2634
2635/**
2636 * ring_buffer_record_is_on - return true if the ring buffer can write
2637 * @buffer: The ring buffer to see if write is enabled
2638 *
2639 * Returns true if the ring buffer is in a state that it accepts writes.
2640 */
2641int ring_buffer_record_is_on(struct ring_buffer *buffer)
2642{
2643 return !atomic_read(&buffer->record_disabled);
2644}
2645
2646/**
2622 * ring_buffer_record_disable_cpu - stop all writes into the cpu_buffer 2647 * ring_buffer_record_disable_cpu - stop all writes into the cpu_buffer
2623 * @buffer: The ring buffer to stop writes to. 2648 * @buffer: The ring buffer to stop writes to.
2624 * @cpu: The CPU buffer to stop 2649 * @cpu: The CPU buffer to stop
@@ -4039,68 +4064,6 @@ int ring_buffer_read_page(struct ring_buffer *buffer,
4039} 4064}
4040EXPORT_SYMBOL_GPL(ring_buffer_read_page); 4065EXPORT_SYMBOL_GPL(ring_buffer_read_page);
4041 4066
4042#ifdef CONFIG_TRACING
4043static ssize_t
4044rb_simple_read(struct file *filp, char __user *ubuf,
4045 size_t cnt, loff_t *ppos)
4046{
4047 unsigned long *p = filp->private_data;
4048 char buf[64];
4049 int r;
4050
4051 if (test_bit(RB_BUFFERS_DISABLED_BIT, p))
4052 r = sprintf(buf, "permanently disabled\n");
4053 else
4054 r = sprintf(buf, "%d\n", test_bit(RB_BUFFERS_ON_BIT, p));
4055
4056 return simple_read_from_buffer(ubuf, cnt, ppos, buf, r);
4057}
4058
4059static ssize_t
4060rb_simple_write(struct file *filp, const char __user *ubuf,
4061 size_t cnt, loff_t *ppos)
4062{
4063 unsigned long *p = filp->private_data;
4064 unsigned long val;
4065 int ret;
4066
4067 ret = kstrtoul_from_user(ubuf, cnt, 10, &val);
4068 if (ret)
4069 return ret;
4070
4071 if (val)
4072 set_bit(RB_BUFFERS_ON_BIT, p);
4073 else
4074 clear_bit(RB_BUFFERS_ON_BIT, p);
4075
4076 (*ppos)++;
4077
4078 return cnt;
4079}
4080
4081static const struct file_operations rb_simple_fops = {
4082 .open = tracing_open_generic,
4083 .read = rb_simple_read,
4084 .write = rb_simple_write,
4085 .llseek = default_llseek,
4086};
4087
4088
4089static __init int rb_init_debugfs(void)
4090{
4091 struct dentry *d_tracer;
4092
4093 d_tracer = tracing_init_dentry();
4094
4095 trace_create_file("tracing_on", 0644, d_tracer,
4096 &ring_buffer_flags, &rb_simple_fops);
4097
4098 return 0;
4099}
4100
4101fs_initcall(rb_init_debugfs);
4102#endif
4103
4104#ifdef CONFIG_HOTPLUG_CPU 4067#ifdef CONFIG_HOTPLUG_CPU
4105static int rb_cpu_notify(struct notifier_block *self, 4068static int rb_cpu_notify(struct notifier_block *self,
4106 unsigned long action, void *hcpu) 4069 unsigned long action, void *hcpu)
diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
index a3f1bc5d2a00..3a19c354edd6 100644
--- a/kernel/trace/trace.c
+++ b/kernel/trace/trace.c
@@ -36,6 +36,7 @@
36#include <linux/ctype.h> 36#include <linux/ctype.h>
37#include <linux/init.h> 37#include <linux/init.h>
38#include <linux/poll.h> 38#include <linux/poll.h>
39#include <linux/nmi.h>
39#include <linux/fs.h> 40#include <linux/fs.h>
40 41
41#include "trace.h" 42#include "trace.h"
@@ -352,6 +353,59 @@ static void wakeup_work_handler(struct work_struct *work)
352static DECLARE_DELAYED_WORK(wakeup_work, wakeup_work_handler); 353static DECLARE_DELAYED_WORK(wakeup_work, wakeup_work_handler);
353 354
354/** 355/**
356 * tracing_on - enable tracing buffers
357 *
358 * This function enables tracing buffers that may have been
359 * disabled with tracing_off.
360 */
361void tracing_on(void)
362{
363 if (global_trace.buffer)
364 ring_buffer_record_on(global_trace.buffer);
365 /*
366 * This flag is only looked at when buffers haven't been
367 * allocated yet. We don't really care about the race
368 * between setting this flag and actually turning
369 * on the buffer.
370 */
371 global_trace.buffer_disabled = 0;
372}
373EXPORT_SYMBOL_GPL(tracing_on);
374
375/**
376 * tracing_off - turn off tracing buffers
377 *
378 * This function stops the tracing buffers from recording data.
379 * It does not disable any overhead the tracers themselves may
380 * be causing. This function simply causes all recording to
381 * the ring buffers to fail.
382 */
383void tracing_off(void)
384{
385 if (global_trace.buffer)
386 ring_buffer_record_on(global_trace.buffer);
387 /*
388 * This flag is only looked at when buffers haven't been
389 * allocated yet. We don't really care about the race
390 * between setting this flag and actually turning
391 * on the buffer.
392 */
393 global_trace.buffer_disabled = 1;
394}
395EXPORT_SYMBOL_GPL(tracing_off);
396
397/**
398 * tracing_is_on - show state of ring buffers enabled
399 */
400int tracing_is_on(void)
401{
402 if (global_trace.buffer)
403 return ring_buffer_record_is_on(global_trace.buffer);
404 return !global_trace.buffer_disabled;
405}
406EXPORT_SYMBOL_GPL(tracing_is_on);
407
408/**
355 * trace_wake_up - wake up tasks waiting for trace input 409 * trace_wake_up - wake up tasks waiting for trace input
356 * 410 *
357 * Schedules a delayed work to wake up any task that is blocked on the 411 * Schedules a delayed work to wake up any task that is blocked on the
@@ -2764,12 +2818,12 @@ static const char readme_msg[] =
2764 "tracing mini-HOWTO:\n\n" 2818 "tracing mini-HOWTO:\n\n"
2765 "# mount -t debugfs nodev /sys/kernel/debug\n\n" 2819 "# mount -t debugfs nodev /sys/kernel/debug\n\n"
2766 "# cat /sys/kernel/debug/tracing/available_tracers\n" 2820 "# cat /sys/kernel/debug/tracing/available_tracers\n"
2767 "wakeup preemptirqsoff preemptoff irqsoff function sched_switch nop\n\n" 2821 "wakeup wakeup_rt preemptirqsoff preemptoff irqsoff function nop\n\n"
2768 "# cat /sys/kernel/debug/tracing/current_tracer\n" 2822 "# cat /sys/kernel/debug/tracing/current_tracer\n"
2769 "nop\n" 2823 "nop\n"
2770 "# echo sched_switch > /sys/kernel/debug/tracing/current_tracer\n" 2824 "# echo wakeup > /sys/kernel/debug/tracing/current_tracer\n"
2771 "# cat /sys/kernel/debug/tracing/current_tracer\n" 2825 "# cat /sys/kernel/debug/tracing/current_tracer\n"
2772 "sched_switch\n" 2826 "wakeup\n"
2773 "# cat /sys/kernel/debug/tracing/trace_options\n" 2827 "# cat /sys/kernel/debug/tracing/trace_options\n"
2774 "noprint-parent nosym-offset nosym-addr noverbose\n" 2828 "noprint-parent nosym-offset nosym-addr noverbose\n"
2775 "# echo print-parent > /sys/kernel/debug/tracing/trace_options\n" 2829 "# echo print-parent > /sys/kernel/debug/tracing/trace_options\n"
@@ -4567,6 +4621,55 @@ static __init void create_trace_options_dir(void)
4567 create_trace_option_core_file(trace_options[i], i); 4621 create_trace_option_core_file(trace_options[i], i);
4568} 4622}
4569 4623
4624static ssize_t
4625rb_simple_read(struct file *filp, char __user *ubuf,
4626 size_t cnt, loff_t *ppos)
4627{
4628 struct ring_buffer *buffer = filp->private_data;
4629 char buf[64];
4630 int r;
4631
4632 if (buffer)
4633 r = ring_buffer_record_is_on(buffer);
4634 else
4635 r = 0;
4636
4637 r = sprintf(buf, "%d\n", r);
4638
4639 return simple_read_from_buffer(ubuf, cnt, ppos, buf, r);
4640}
4641
4642static ssize_t
4643rb_simple_write(struct file *filp, const char __user *ubuf,
4644 size_t cnt, loff_t *ppos)
4645{
4646 struct ring_buffer *buffer = filp->private_data;
4647 unsigned long val;
4648 int ret;
4649
4650 ret = kstrtoul_from_user(ubuf, cnt, 10, &val);
4651 if (ret)
4652 return ret;
4653
4654 if (buffer) {
4655 if (val)
4656 ring_buffer_record_on(buffer);
4657 else
4658 ring_buffer_record_off(buffer);
4659 }
4660
4661 (*ppos)++;
4662
4663 return cnt;
4664}
4665
4666static const struct file_operations rb_simple_fops = {
4667 .open = tracing_open_generic,
4668 .read = rb_simple_read,
4669 .write = rb_simple_write,
4670 .llseek = default_llseek,
4671};
4672
4570static __init int tracer_init_debugfs(void) 4673static __init int tracer_init_debugfs(void)
4571{ 4674{
4572 struct dentry *d_tracer; 4675 struct dentry *d_tracer;
@@ -4626,6 +4729,9 @@ static __init int tracer_init_debugfs(void)
4626 trace_create_file("trace_clock", 0644, d_tracer, NULL, 4729 trace_create_file("trace_clock", 0644, d_tracer, NULL,
4627 &trace_clock_fops); 4730 &trace_clock_fops);
4628 4731
4732 trace_create_file("tracing_on", 0644, d_tracer,
4733 global_trace.buffer, &rb_simple_fops);
4734
4629#ifdef CONFIG_DYNAMIC_FTRACE 4735#ifdef CONFIG_DYNAMIC_FTRACE
4630 trace_create_file("dyn_ftrace_total_info", 0444, d_tracer, 4736 trace_create_file("dyn_ftrace_total_info", 0444, d_tracer,
4631 &ftrace_update_tot_cnt, &tracing_dyn_info_fops); 4737 &ftrace_update_tot_cnt, &tracing_dyn_info_fops);
@@ -4798,6 +4904,7 @@ __ftrace_dump(bool disable_tracing, enum ftrace_dump_mode oops_dump_mode)
4798 if (ret != TRACE_TYPE_NO_CONSUME) 4904 if (ret != TRACE_TYPE_NO_CONSUME)
4799 trace_consume(&iter); 4905 trace_consume(&iter);
4800 } 4906 }
4907 touch_nmi_watchdog();
4801 4908
4802 trace_printk_seq(&iter.seq); 4909 trace_printk_seq(&iter.seq);
4803 } 4910 }
@@ -4863,6 +4970,8 @@ __init static int tracer_alloc_buffers(void)
4863 goto out_free_cpumask; 4970 goto out_free_cpumask;
4864 } 4971 }
4865 global_trace.entries = ring_buffer_size(global_trace.buffer); 4972 global_trace.entries = ring_buffer_size(global_trace.buffer);
4973 if (global_trace.buffer_disabled)
4974 tracing_off();
4866 4975
4867 4976
4868#ifdef CONFIG_TRACER_MAX_TRACE 4977#ifdef CONFIG_TRACER_MAX_TRACE
diff --git a/kernel/trace/trace.h b/kernel/trace/trace.h
index b93ecbadad6d..95059f091a24 100644
--- a/kernel/trace/trace.h
+++ b/kernel/trace/trace.h
@@ -56,17 +56,23 @@ enum trace_type {
56#define F_STRUCT(args...) args 56#define F_STRUCT(args...) args
57 57
58#undef FTRACE_ENTRY 58#undef FTRACE_ENTRY
59#define FTRACE_ENTRY(name, struct_name, id, tstruct, print) \ 59#define FTRACE_ENTRY(name, struct_name, id, tstruct, print, filter) \
60 struct struct_name { \ 60 struct struct_name { \
61 struct trace_entry ent; \ 61 struct trace_entry ent; \
62 tstruct \ 62 tstruct \
63 } 63 }
64 64
65#undef TP_ARGS 65#undef TP_ARGS
66#define TP_ARGS(args...) args 66#define TP_ARGS(args...) args
67 67
68#undef FTRACE_ENTRY_DUP 68#undef FTRACE_ENTRY_DUP
69#define FTRACE_ENTRY_DUP(name, name_struct, id, tstruct, printk) 69#define FTRACE_ENTRY_DUP(name, name_struct, id, tstruct, printk, filter)
70
71#undef FTRACE_ENTRY_REG
72#define FTRACE_ENTRY_REG(name, struct_name, id, tstruct, print, \
73 filter, regfn) \
74 FTRACE_ENTRY(name, struct_name, id, PARAMS(tstruct), PARAMS(print), \
75 filter)
70 76
71#include "trace_entries.h" 77#include "trace_entries.h"
72 78
@@ -148,6 +154,7 @@ struct trace_array {
148 struct ring_buffer *buffer; 154 struct ring_buffer *buffer;
149 unsigned long entries; 155 unsigned long entries;
150 int cpu; 156 int cpu;
157 int buffer_disabled;
151 cycle_t time_start; 158 cycle_t time_start;
152 struct task_struct *waiter; 159 struct task_struct *waiter;
153 struct trace_array_cpu *data[NR_CPUS]; 160 struct trace_array_cpu *data[NR_CPUS];
@@ -288,6 +295,8 @@ struct tracer {
288/* for function tracing recursion */ 295/* for function tracing recursion */
289#define TRACE_INTERNAL_BIT (1<<11) 296#define TRACE_INTERNAL_BIT (1<<11)
290#define TRACE_GLOBAL_BIT (1<<12) 297#define TRACE_GLOBAL_BIT (1<<12)
298#define TRACE_CONTROL_BIT (1<<13)
299
291/* 300/*
292 * Abuse of the trace_recursion. 301 * Abuse of the trace_recursion.
293 * As we need a way to maintain state if we are tracing the function 302 * As we need a way to maintain state if we are tracing the function
@@ -589,6 +598,8 @@ static inline int ftrace_trace_task(struct task_struct *task)
589static inline int ftrace_is_dead(void) { return 0; } 598static inline int ftrace_is_dead(void) { return 0; }
590#endif 599#endif
591 600
601int ftrace_event_is_function(struct ftrace_event_call *call);
602
592/* 603/*
593 * struct trace_parser - servers for reading the user input separated by spaces 604 * struct trace_parser - servers for reading the user input separated by spaces
594 * @cont: set if the input is not complete - no final space char was found 605 * @cont: set if the input is not complete - no final space char was found
@@ -766,9 +777,7 @@ struct filter_pred {
766 u64 val; 777 u64 val;
767 struct regex regex; 778 struct regex regex;
768 unsigned short *ops; 779 unsigned short *ops;
769#ifdef CONFIG_FTRACE_STARTUP_TEST
770 struct ftrace_event_field *field; 780 struct ftrace_event_field *field;
771#endif
772 int offset; 781 int offset;
773 int not; 782 int not;
774 int op; 783 int op;
@@ -818,12 +827,20 @@ extern const char *__start___trace_bprintk_fmt[];
818extern const char *__stop___trace_bprintk_fmt[]; 827extern const char *__stop___trace_bprintk_fmt[];
819 828
820#undef FTRACE_ENTRY 829#undef FTRACE_ENTRY
821#define FTRACE_ENTRY(call, struct_name, id, tstruct, print) \ 830#define FTRACE_ENTRY(call, struct_name, id, tstruct, print, filter) \
822 extern struct ftrace_event_call \ 831 extern struct ftrace_event_call \
823 __attribute__((__aligned__(4))) event_##call; 832 __attribute__((__aligned__(4))) event_##call;
824#undef FTRACE_ENTRY_DUP 833#undef FTRACE_ENTRY_DUP
825#define FTRACE_ENTRY_DUP(call, struct_name, id, tstruct, print) \ 834#define FTRACE_ENTRY_DUP(call, struct_name, id, tstruct, print, filter) \
826 FTRACE_ENTRY(call, struct_name, id, PARAMS(tstruct), PARAMS(print)) 835 FTRACE_ENTRY(call, struct_name, id, PARAMS(tstruct), PARAMS(print), \
836 filter)
827#include "trace_entries.h" 837#include "trace_entries.h"
828 838
839#ifdef CONFIG_FUNCTION_TRACER
840int perf_ftrace_event_register(struct ftrace_event_call *call,
841 enum trace_reg type, void *data);
842#else
843#define perf_ftrace_event_register NULL
844#endif /* CONFIG_FUNCTION_TRACER */
845
829#endif /* _LINUX_KERNEL_TRACE_H */ 846#endif /* _LINUX_KERNEL_TRACE_H */
diff --git a/kernel/trace/trace_entries.h b/kernel/trace/trace_entries.h
index 205dcac89206..4108e1250ca2 100644
--- a/kernel/trace/trace_entries.h
+++ b/kernel/trace/trace_entries.h
@@ -55,7 +55,7 @@
55/* 55/*
56 * Function trace entry - function address and parent function address: 56 * Function trace entry - function address and parent function address:
57 */ 57 */
58FTRACE_ENTRY(function, ftrace_entry, 58FTRACE_ENTRY_REG(function, ftrace_entry,
59 59
60 TRACE_FN, 60 TRACE_FN,
61 61
@@ -64,7 +64,11 @@ FTRACE_ENTRY(function, ftrace_entry,
64 __field( unsigned long, parent_ip ) 64 __field( unsigned long, parent_ip )
65 ), 65 ),
66 66
67 F_printk(" %lx <-- %lx", __entry->ip, __entry->parent_ip) 67 F_printk(" %lx <-- %lx", __entry->ip, __entry->parent_ip),
68
69 FILTER_TRACE_FN,
70
71 perf_ftrace_event_register
68); 72);
69 73
70/* Function call entry */ 74/* Function call entry */
@@ -78,7 +82,9 @@ FTRACE_ENTRY(funcgraph_entry, ftrace_graph_ent_entry,
78 __field_desc( int, graph_ent, depth ) 82 __field_desc( int, graph_ent, depth )
79 ), 83 ),
80 84
81 F_printk("--> %lx (%d)", __entry->func, __entry->depth) 85 F_printk("--> %lx (%d)", __entry->func, __entry->depth),
86
87 FILTER_OTHER
82); 88);
83 89
84/* Function return entry */ 90/* Function return entry */
@@ -98,7 +104,9 @@ FTRACE_ENTRY(funcgraph_exit, ftrace_graph_ret_entry,
98 F_printk("<-- %lx (%d) (start: %llx end: %llx) over: %d", 104 F_printk("<-- %lx (%d) (start: %llx end: %llx) over: %d",
99 __entry->func, __entry->depth, 105 __entry->func, __entry->depth,
100 __entry->calltime, __entry->rettime, 106 __entry->calltime, __entry->rettime,
101 __entry->depth) 107 __entry->depth),
108
109 FILTER_OTHER
102); 110);
103 111
104/* 112/*
@@ -127,8 +135,9 @@ FTRACE_ENTRY(context_switch, ctx_switch_entry,
127 F_printk("%u:%u:%u ==> %u:%u:%u [%03u]", 135 F_printk("%u:%u:%u ==> %u:%u:%u [%03u]",
128 __entry->prev_pid, __entry->prev_prio, __entry->prev_state, 136 __entry->prev_pid, __entry->prev_prio, __entry->prev_state,
129 __entry->next_pid, __entry->next_prio, __entry->next_state, 137 __entry->next_pid, __entry->next_prio, __entry->next_state,
130 __entry->next_cpu 138 __entry->next_cpu),
131 ) 139
140 FILTER_OTHER
132); 141);
133 142
134/* 143/*
@@ -146,8 +155,9 @@ FTRACE_ENTRY_DUP(wakeup, ctx_switch_entry,
146 F_printk("%u:%u:%u ==+ %u:%u:%u [%03u]", 155 F_printk("%u:%u:%u ==+ %u:%u:%u [%03u]",
147 __entry->prev_pid, __entry->prev_prio, __entry->prev_state, 156 __entry->prev_pid, __entry->prev_prio, __entry->prev_state,
148 __entry->next_pid, __entry->next_prio, __entry->next_state, 157 __entry->next_pid, __entry->next_prio, __entry->next_state,
149 __entry->next_cpu 158 __entry->next_cpu),
150 ) 159
160 FILTER_OTHER
151); 161);
152 162
153/* 163/*
@@ -176,7 +186,9 @@ FTRACE_ENTRY(kernel_stack, stack_entry,
176 "\t=> (" IP_FMT ")\n\t=> (" IP_FMT ")\n", 186 "\t=> (" IP_FMT ")\n\t=> (" IP_FMT ")\n",
177 __entry->caller[0], __entry->caller[1], __entry->caller[2], 187 __entry->caller[0], __entry->caller[1], __entry->caller[2],
178 __entry->caller[3], __entry->caller[4], __entry->caller[5], 188 __entry->caller[3], __entry->caller[4], __entry->caller[5],
179 __entry->caller[6], __entry->caller[7]) 189 __entry->caller[6], __entry->caller[7]),
190
191 FILTER_OTHER
180); 192);
181 193
182FTRACE_ENTRY(user_stack, userstack_entry, 194FTRACE_ENTRY(user_stack, userstack_entry,
@@ -193,7 +205,9 @@ FTRACE_ENTRY(user_stack, userstack_entry,
193 "\t=> (" IP_FMT ")\n\t=> (" IP_FMT ")\n", 205 "\t=> (" IP_FMT ")\n\t=> (" IP_FMT ")\n",
194 __entry->caller[0], __entry->caller[1], __entry->caller[2], 206 __entry->caller[0], __entry->caller[1], __entry->caller[2],
195 __entry->caller[3], __entry->caller[4], __entry->caller[5], 207 __entry->caller[3], __entry->caller[4], __entry->caller[5],
196 __entry->caller[6], __entry->caller[7]) 208 __entry->caller[6], __entry->caller[7]),
209
210 FILTER_OTHER
197); 211);
198 212
199/* 213/*
@@ -210,7 +224,9 @@ FTRACE_ENTRY(bprint, bprint_entry,
210 ), 224 ),
211 225
212 F_printk("%08lx fmt:%p", 226 F_printk("%08lx fmt:%p",
213 __entry->ip, __entry->fmt) 227 __entry->ip, __entry->fmt),
228
229 FILTER_OTHER
214); 230);
215 231
216FTRACE_ENTRY(print, print_entry, 232FTRACE_ENTRY(print, print_entry,
@@ -223,7 +239,9 @@ FTRACE_ENTRY(print, print_entry,
223 ), 239 ),
224 240
225 F_printk("%08lx %s", 241 F_printk("%08lx %s",
226 __entry->ip, __entry->buf) 242 __entry->ip, __entry->buf),
243
244 FILTER_OTHER
227); 245);
228 246
229FTRACE_ENTRY(mmiotrace_rw, trace_mmiotrace_rw, 247FTRACE_ENTRY(mmiotrace_rw, trace_mmiotrace_rw,
@@ -242,7 +260,9 @@ FTRACE_ENTRY(mmiotrace_rw, trace_mmiotrace_rw,
242 260
243 F_printk("%lx %lx %lx %d %x %x", 261 F_printk("%lx %lx %lx %d %x %x",
244 (unsigned long)__entry->phys, __entry->value, __entry->pc, 262 (unsigned long)__entry->phys, __entry->value, __entry->pc,
245 __entry->map_id, __entry->opcode, __entry->width) 263 __entry->map_id, __entry->opcode, __entry->width),
264
265 FILTER_OTHER
246); 266);
247 267
248FTRACE_ENTRY(mmiotrace_map, trace_mmiotrace_map, 268FTRACE_ENTRY(mmiotrace_map, trace_mmiotrace_map,
@@ -260,7 +280,9 @@ FTRACE_ENTRY(mmiotrace_map, trace_mmiotrace_map,
260 280
261 F_printk("%lx %lx %lx %d %x", 281 F_printk("%lx %lx %lx %d %x",
262 (unsigned long)__entry->phys, __entry->virt, __entry->len, 282 (unsigned long)__entry->phys, __entry->virt, __entry->len,
263 __entry->map_id, __entry->opcode) 283 __entry->map_id, __entry->opcode),
284
285 FILTER_OTHER
264); 286);
265 287
266 288
@@ -280,6 +302,8 @@ FTRACE_ENTRY(branch, trace_branch,
280 302
281 F_printk("%u:%s:%s (%u)", 303 F_printk("%u:%s:%s (%u)",
282 __entry->line, 304 __entry->line,
283 __entry->func, __entry->file, __entry->correct) 305 __entry->func, __entry->file, __entry->correct),
306
307 FILTER_OTHER
284); 308);
285 309
diff --git a/kernel/trace/trace_event_perf.c b/kernel/trace/trace_event_perf.c
index 19a359d5e6d5..fee3752ae8f6 100644
--- a/kernel/trace/trace_event_perf.c
+++ b/kernel/trace/trace_event_perf.c
@@ -24,6 +24,11 @@ static int total_ref_count;
24static int perf_trace_event_perm(struct ftrace_event_call *tp_event, 24static int perf_trace_event_perm(struct ftrace_event_call *tp_event,
25 struct perf_event *p_event) 25 struct perf_event *p_event)
26{ 26{
27 /* The ftrace function trace is allowed only for root. */
28 if (ftrace_event_is_function(tp_event) &&
29 perf_paranoid_kernel() && !capable(CAP_SYS_ADMIN))
30 return -EPERM;
31
27 /* No tracing, just counting, so no obvious leak */ 32 /* No tracing, just counting, so no obvious leak */
28 if (!(p_event->attr.sample_type & PERF_SAMPLE_RAW)) 33 if (!(p_event->attr.sample_type & PERF_SAMPLE_RAW))
29 return 0; 34 return 0;
@@ -44,23 +49,17 @@ static int perf_trace_event_perm(struct ftrace_event_call *tp_event,
44 return 0; 49 return 0;
45} 50}
46 51
47static int perf_trace_event_init(struct ftrace_event_call *tp_event, 52static int perf_trace_event_reg(struct ftrace_event_call *tp_event,
48 struct perf_event *p_event) 53 struct perf_event *p_event)
49{ 54{
50 struct hlist_head __percpu *list; 55 struct hlist_head __percpu *list;
51 int ret; 56 int ret = -ENOMEM;
52 int cpu; 57 int cpu;
53 58
54 ret = perf_trace_event_perm(tp_event, p_event);
55 if (ret)
56 return ret;
57
58 p_event->tp_event = tp_event; 59 p_event->tp_event = tp_event;
59 if (tp_event->perf_refcount++ > 0) 60 if (tp_event->perf_refcount++ > 0)
60 return 0; 61 return 0;
61 62
62 ret = -ENOMEM;
63
64 list = alloc_percpu(struct hlist_head); 63 list = alloc_percpu(struct hlist_head);
65 if (!list) 64 if (!list)
66 goto fail; 65 goto fail;
@@ -83,7 +82,7 @@ static int perf_trace_event_init(struct ftrace_event_call *tp_event,
83 } 82 }
84 } 83 }
85 84
86 ret = tp_event->class->reg(tp_event, TRACE_REG_PERF_REGISTER); 85 ret = tp_event->class->reg(tp_event, TRACE_REG_PERF_REGISTER, NULL);
87 if (ret) 86 if (ret)
88 goto fail; 87 goto fail;
89 88
@@ -108,6 +107,69 @@ fail:
108 return ret; 107 return ret;
109} 108}
110 109
110static void perf_trace_event_unreg(struct perf_event *p_event)
111{
112 struct ftrace_event_call *tp_event = p_event->tp_event;
113 int i;
114
115 if (--tp_event->perf_refcount > 0)
116 goto out;
117
118 tp_event->class->reg(tp_event, TRACE_REG_PERF_UNREGISTER, NULL);
119
120 /*
121 * Ensure our callback won't be called anymore. The buffers
122 * will be freed after that.
123 */
124 tracepoint_synchronize_unregister();
125
126 free_percpu(tp_event->perf_events);
127 tp_event->perf_events = NULL;
128
129 if (!--total_ref_count) {
130 for (i = 0; i < PERF_NR_CONTEXTS; i++) {
131 free_percpu(perf_trace_buf[i]);
132 perf_trace_buf[i] = NULL;
133 }
134 }
135out:
136 module_put(tp_event->mod);
137}
138
139static int perf_trace_event_open(struct perf_event *p_event)
140{
141 struct ftrace_event_call *tp_event = p_event->tp_event;
142 return tp_event->class->reg(tp_event, TRACE_REG_PERF_OPEN, p_event);
143}
144
145static void perf_trace_event_close(struct perf_event *p_event)
146{
147 struct ftrace_event_call *tp_event = p_event->tp_event;
148 tp_event->class->reg(tp_event, TRACE_REG_PERF_CLOSE, p_event);
149}
150
151static int perf_trace_event_init(struct ftrace_event_call *tp_event,
152 struct perf_event *p_event)
153{
154 int ret;
155
156 ret = perf_trace_event_perm(tp_event, p_event);
157 if (ret)
158 return ret;
159
160 ret = perf_trace_event_reg(tp_event, p_event);
161 if (ret)
162 return ret;
163
164 ret = perf_trace_event_open(p_event);
165 if (ret) {
166 perf_trace_event_unreg(p_event);
167 return ret;
168 }
169
170 return 0;
171}
172
111int perf_trace_init(struct perf_event *p_event) 173int perf_trace_init(struct perf_event *p_event)
112{ 174{
113 struct ftrace_event_call *tp_event; 175 struct ftrace_event_call *tp_event;
@@ -130,6 +192,14 @@ int perf_trace_init(struct perf_event *p_event)
130 return ret; 192 return ret;
131} 193}
132 194
195void perf_trace_destroy(struct perf_event *p_event)
196{
197 mutex_lock(&event_mutex);
198 perf_trace_event_close(p_event);
199 perf_trace_event_unreg(p_event);
200 mutex_unlock(&event_mutex);
201}
202
133int perf_trace_add(struct perf_event *p_event, int flags) 203int perf_trace_add(struct perf_event *p_event, int flags)
134{ 204{
135 struct ftrace_event_call *tp_event = p_event->tp_event; 205 struct ftrace_event_call *tp_event = p_event->tp_event;
@@ -146,43 +216,14 @@ int perf_trace_add(struct perf_event *p_event, int flags)
146 list = this_cpu_ptr(pcpu_list); 216 list = this_cpu_ptr(pcpu_list);
147 hlist_add_head_rcu(&p_event->hlist_entry, list); 217 hlist_add_head_rcu(&p_event->hlist_entry, list);
148 218
149 return 0; 219 return tp_event->class->reg(tp_event, TRACE_REG_PERF_ADD, p_event);
150} 220}
151 221
152void perf_trace_del(struct perf_event *p_event, int flags) 222void perf_trace_del(struct perf_event *p_event, int flags)
153{ 223{
154 hlist_del_rcu(&p_event->hlist_entry);
155}
156
157void perf_trace_destroy(struct perf_event *p_event)
158{
159 struct ftrace_event_call *tp_event = p_event->tp_event; 224 struct ftrace_event_call *tp_event = p_event->tp_event;
160 int i; 225 hlist_del_rcu(&p_event->hlist_entry);
161 226 tp_event->class->reg(tp_event, TRACE_REG_PERF_DEL, p_event);
162 mutex_lock(&event_mutex);
163 if (--tp_event->perf_refcount > 0)
164 goto out;
165
166 tp_event->class->reg(tp_event, TRACE_REG_PERF_UNREGISTER);
167
168 /*
169 * Ensure our callback won't be called anymore. The buffers
170 * will be freed after that.
171 */
172 tracepoint_synchronize_unregister();
173
174 free_percpu(tp_event->perf_events);
175 tp_event->perf_events = NULL;
176
177 if (!--total_ref_count) {
178 for (i = 0; i < PERF_NR_CONTEXTS; i++) {
179 free_percpu(perf_trace_buf[i]);
180 perf_trace_buf[i] = NULL;
181 }
182 }
183out:
184 module_put(tp_event->mod);
185 mutex_unlock(&event_mutex);
186} 227}
187 228
188__kprobes void *perf_trace_buf_prepare(int size, unsigned short type, 229__kprobes void *perf_trace_buf_prepare(int size, unsigned short type,
@@ -214,3 +255,86 @@ __kprobes void *perf_trace_buf_prepare(int size, unsigned short type,
214 return raw_data; 255 return raw_data;
215} 256}
216EXPORT_SYMBOL_GPL(perf_trace_buf_prepare); 257EXPORT_SYMBOL_GPL(perf_trace_buf_prepare);
258
259#ifdef CONFIG_FUNCTION_TRACER
260static void
261perf_ftrace_function_call(unsigned long ip, unsigned long parent_ip)
262{
263 struct ftrace_entry *entry;
264 struct hlist_head *head;
265 struct pt_regs regs;
266 int rctx;
267
268#define ENTRY_SIZE (ALIGN(sizeof(struct ftrace_entry) + sizeof(u32), \
269 sizeof(u64)) - sizeof(u32))
270
271 BUILD_BUG_ON(ENTRY_SIZE > PERF_MAX_TRACE_SIZE);
272
273 perf_fetch_caller_regs(&regs);
274
275 entry = perf_trace_buf_prepare(ENTRY_SIZE, TRACE_FN, NULL, &rctx);
276 if (!entry)
277 return;
278
279 entry->ip = ip;
280 entry->parent_ip = parent_ip;
281
282 head = this_cpu_ptr(event_function.perf_events);
283 perf_trace_buf_submit(entry, ENTRY_SIZE, rctx, 0,
284 1, &regs, head);
285
286#undef ENTRY_SIZE
287}
288
289static int perf_ftrace_function_register(struct perf_event *event)
290{
291 struct ftrace_ops *ops = &event->ftrace_ops;
292
293 ops->flags |= FTRACE_OPS_FL_CONTROL;
294 ops->func = perf_ftrace_function_call;
295 return register_ftrace_function(ops);
296}
297
298static int perf_ftrace_function_unregister(struct perf_event *event)
299{
300 struct ftrace_ops *ops = &event->ftrace_ops;
301 int ret = unregister_ftrace_function(ops);
302 ftrace_free_filter(ops);
303 return ret;
304}
305
306static void perf_ftrace_function_enable(struct perf_event *event)
307{
308 ftrace_function_local_enable(&event->ftrace_ops);
309}
310
311static void perf_ftrace_function_disable(struct perf_event *event)
312{
313 ftrace_function_local_disable(&event->ftrace_ops);
314}
315
316int perf_ftrace_event_register(struct ftrace_event_call *call,
317 enum trace_reg type, void *data)
318{
319 switch (type) {
320 case TRACE_REG_REGISTER:
321 case TRACE_REG_UNREGISTER:
322 break;
323 case TRACE_REG_PERF_REGISTER:
324 case TRACE_REG_PERF_UNREGISTER:
325 return 0;
326 case TRACE_REG_PERF_OPEN:
327 return perf_ftrace_function_register(data);
328 case TRACE_REG_PERF_CLOSE:
329 return perf_ftrace_function_unregister(data);
330 case TRACE_REG_PERF_ADD:
331 perf_ftrace_function_enable(data);
332 return 0;
333 case TRACE_REG_PERF_DEL:
334 perf_ftrace_function_disable(data);
335 return 0;
336 }
337
338 return -EINVAL;
339}
340#endif /* CONFIG_FUNCTION_TRACER */
diff --git a/kernel/trace/trace_events.c b/kernel/trace/trace_events.c
index c212a7f934ec..079a93ae8a9d 100644
--- a/kernel/trace/trace_events.c
+++ b/kernel/trace/trace_events.c
@@ -147,7 +147,8 @@ int trace_event_raw_init(struct ftrace_event_call *call)
147} 147}
148EXPORT_SYMBOL_GPL(trace_event_raw_init); 148EXPORT_SYMBOL_GPL(trace_event_raw_init);
149 149
150int ftrace_event_reg(struct ftrace_event_call *call, enum trace_reg type) 150int ftrace_event_reg(struct ftrace_event_call *call,
151 enum trace_reg type, void *data)
151{ 152{
152 switch (type) { 153 switch (type) {
153 case TRACE_REG_REGISTER: 154 case TRACE_REG_REGISTER:
@@ -170,6 +171,11 @@ int ftrace_event_reg(struct ftrace_event_call *call, enum trace_reg type)
170 call->class->perf_probe, 171 call->class->perf_probe,
171 call); 172 call);
172 return 0; 173 return 0;
174 case TRACE_REG_PERF_OPEN:
175 case TRACE_REG_PERF_CLOSE:
176 case TRACE_REG_PERF_ADD:
177 case TRACE_REG_PERF_DEL:
178 return 0;
173#endif 179#endif
174 } 180 }
175 return 0; 181 return 0;
@@ -209,7 +215,7 @@ static int ftrace_event_enable_disable(struct ftrace_event_call *call,
209 tracing_stop_cmdline_record(); 215 tracing_stop_cmdline_record();
210 call->flags &= ~TRACE_EVENT_FL_RECORDED_CMD; 216 call->flags &= ~TRACE_EVENT_FL_RECORDED_CMD;
211 } 217 }
212 call->class->reg(call, TRACE_REG_UNREGISTER); 218 call->class->reg(call, TRACE_REG_UNREGISTER, NULL);
213 } 219 }
214 break; 220 break;
215 case 1: 221 case 1:
@@ -218,7 +224,7 @@ static int ftrace_event_enable_disable(struct ftrace_event_call *call,
218 tracing_start_cmdline_record(); 224 tracing_start_cmdline_record();
219 call->flags |= TRACE_EVENT_FL_RECORDED_CMD; 225 call->flags |= TRACE_EVENT_FL_RECORDED_CMD;
220 } 226 }
221 ret = call->class->reg(call, TRACE_REG_REGISTER); 227 ret = call->class->reg(call, TRACE_REG_REGISTER, NULL);
222 if (ret) { 228 if (ret) {
223 tracing_stop_cmdline_record(); 229 tracing_stop_cmdline_record();
224 pr_info("event trace: Could not enable event " 230 pr_info("event trace: Could not enable event "
diff --git a/kernel/trace/trace_events_filter.c b/kernel/trace/trace_events_filter.c
index 24aee7127451..431dba8b7542 100644
--- a/kernel/trace/trace_events_filter.c
+++ b/kernel/trace/trace_events_filter.c
@@ -81,6 +81,7 @@ enum {
81 FILT_ERR_TOO_MANY_PREDS, 81 FILT_ERR_TOO_MANY_PREDS,
82 FILT_ERR_MISSING_FIELD, 82 FILT_ERR_MISSING_FIELD,
83 FILT_ERR_INVALID_FILTER, 83 FILT_ERR_INVALID_FILTER,
84 FILT_ERR_IP_FIELD_ONLY,
84}; 85};
85 86
86static char *err_text[] = { 87static char *err_text[] = {
@@ -96,6 +97,7 @@ static char *err_text[] = {
96 "Too many terms in predicate expression", 97 "Too many terms in predicate expression",
97 "Missing field name and/or value", 98 "Missing field name and/or value",
98 "Meaningless filter expression", 99 "Meaningless filter expression",
100 "Only 'ip' field is supported for function trace",
99}; 101};
100 102
101struct opstack_op { 103struct opstack_op {
@@ -685,7 +687,7 @@ find_event_field(struct ftrace_event_call *call, char *name)
685 687
686static int __alloc_pred_stack(struct pred_stack *stack, int n_preds) 688static int __alloc_pred_stack(struct pred_stack *stack, int n_preds)
687{ 689{
688 stack->preds = kzalloc(sizeof(*stack->preds)*(n_preds + 1), GFP_KERNEL); 690 stack->preds = kcalloc(n_preds + 1, sizeof(*stack->preds), GFP_KERNEL);
689 if (!stack->preds) 691 if (!stack->preds)
690 return -ENOMEM; 692 return -ENOMEM;
691 stack->index = n_preds; 693 stack->index = n_preds;
@@ -826,8 +828,7 @@ static int __alloc_preds(struct event_filter *filter, int n_preds)
826 if (filter->preds) 828 if (filter->preds)
827 __free_preds(filter); 829 __free_preds(filter);
828 830
829 filter->preds = 831 filter->preds = kcalloc(n_preds, sizeof(*filter->preds), GFP_KERNEL);
830 kzalloc(sizeof(*filter->preds) * n_preds, GFP_KERNEL);
831 832
832 if (!filter->preds) 833 if (!filter->preds)
833 return -ENOMEM; 834 return -ENOMEM;
@@ -900,6 +901,11 @@ int filter_assign_type(const char *type)
900 return FILTER_OTHER; 901 return FILTER_OTHER;
901} 902}
902 903
904static bool is_function_field(struct ftrace_event_field *field)
905{
906 return field->filter_type == FILTER_TRACE_FN;
907}
908
903static bool is_string_field(struct ftrace_event_field *field) 909static bool is_string_field(struct ftrace_event_field *field)
904{ 910{
905 return field->filter_type == FILTER_DYN_STRING || 911 return field->filter_type == FILTER_DYN_STRING ||
@@ -987,6 +993,11 @@ static int init_pred(struct filter_parse_state *ps,
987 fn = filter_pred_strloc; 993 fn = filter_pred_strloc;
988 else 994 else
989 fn = filter_pred_pchar; 995 fn = filter_pred_pchar;
996 } else if (is_function_field(field)) {
997 if (strcmp(field->name, "ip")) {
998 parse_error(ps, FILT_ERR_IP_FIELD_ONLY, 0);
999 return -EINVAL;
1000 }
990 } else { 1001 } else {
991 if (field->is_signed) 1002 if (field->is_signed)
992 ret = strict_strtoll(pred->regex.pattern, 0, &val); 1003 ret = strict_strtoll(pred->regex.pattern, 0, &val);
@@ -1334,10 +1345,7 @@ static struct filter_pred *create_pred(struct filter_parse_state *ps,
1334 1345
1335 strcpy(pred.regex.pattern, operand2); 1346 strcpy(pred.regex.pattern, operand2);
1336 pred.regex.len = strlen(pred.regex.pattern); 1347 pred.regex.len = strlen(pred.regex.pattern);
1337
1338#ifdef CONFIG_FTRACE_STARTUP_TEST
1339 pred.field = field; 1348 pred.field = field;
1340#endif
1341 return init_pred(ps, field, &pred) ? NULL : &pred; 1349 return init_pred(ps, field, &pred) ? NULL : &pred;
1342} 1350}
1343 1351
@@ -1486,7 +1494,7 @@ static int fold_pred(struct filter_pred *preds, struct filter_pred *root)
1486 children = count_leafs(preds, &preds[root->left]); 1494 children = count_leafs(preds, &preds[root->left]);
1487 children += count_leafs(preds, &preds[root->right]); 1495 children += count_leafs(preds, &preds[root->right]);
1488 1496
1489 root->ops = kzalloc(sizeof(*root->ops) * children, GFP_KERNEL); 1497 root->ops = kcalloc(children, sizeof(*root->ops), GFP_KERNEL);
1490 if (!root->ops) 1498 if (!root->ops)
1491 return -ENOMEM; 1499 return -ENOMEM;
1492 1500
@@ -1950,6 +1958,148 @@ void ftrace_profile_free_filter(struct perf_event *event)
1950 __free_filter(filter); 1958 __free_filter(filter);
1951} 1959}
1952 1960
1961struct function_filter_data {
1962 struct ftrace_ops *ops;
1963 int first_filter;
1964 int first_notrace;
1965};
1966
1967#ifdef CONFIG_FUNCTION_TRACER
1968static char **
1969ftrace_function_filter_re(char *buf, int len, int *count)
1970{
1971 char *str, *sep, **re;
1972
1973 str = kstrndup(buf, len, GFP_KERNEL);
1974 if (!str)
1975 return NULL;
1976
1977 /*
1978 * The argv_split function takes white space
1979 * as a separator, so convert ',' into spaces.
1980 */
1981 while ((sep = strchr(str, ',')))
1982 *sep = ' ';
1983
1984 re = argv_split(GFP_KERNEL, str, count);
1985 kfree(str);
1986 return re;
1987}
1988
1989static int ftrace_function_set_regexp(struct ftrace_ops *ops, int filter,
1990 int reset, char *re, int len)
1991{
1992 int ret;
1993
1994 if (filter)
1995 ret = ftrace_set_filter(ops, re, len, reset);
1996 else
1997 ret = ftrace_set_notrace(ops, re, len, reset);
1998
1999 return ret;
2000}
2001
2002static int __ftrace_function_set_filter(int filter, char *buf, int len,
2003 struct function_filter_data *data)
2004{
2005 int i, re_cnt, ret;
2006 int *reset;
2007 char **re;
2008
2009 reset = filter ? &data->first_filter : &data->first_notrace;
2010
2011 /*
2012 * The 'ip' field could have multiple filters set, separated
2013 * either by space or comma. We first cut the filter and apply
2014 * all pieces separatelly.
2015 */
2016 re = ftrace_function_filter_re(buf, len, &re_cnt);
2017 if (!re)
2018 return -EINVAL;
2019
2020 for (i = 0; i < re_cnt; i++) {
2021 ret = ftrace_function_set_regexp(data->ops, filter, *reset,
2022 re[i], strlen(re[i]));
2023 if (ret)
2024 break;
2025
2026 if (*reset)
2027 *reset = 0;
2028 }
2029
2030 argv_free(re);
2031 return ret;
2032}
2033
2034static int ftrace_function_check_pred(struct filter_pred *pred, int leaf)
2035{
2036 struct ftrace_event_field *field = pred->field;
2037
2038 if (leaf) {
2039 /*
2040 * Check the leaf predicate for function trace, verify:
2041 * - only '==' and '!=' is used
2042 * - the 'ip' field is used
2043 */
2044 if ((pred->op != OP_EQ) && (pred->op != OP_NE))
2045 return -EINVAL;
2046
2047 if (strcmp(field->name, "ip"))
2048 return -EINVAL;
2049 } else {
2050 /*
2051 * Check the non leaf predicate for function trace, verify:
2052 * - only '||' is used
2053 */
2054 if (pred->op != OP_OR)
2055 return -EINVAL;
2056 }
2057
2058 return 0;
2059}
2060
2061static int ftrace_function_set_filter_cb(enum move_type move,
2062 struct filter_pred *pred,
2063 int *err, void *data)
2064{
2065 /* Checking the node is valid for function trace. */
2066 if ((move != MOVE_DOWN) ||
2067 (pred->left != FILTER_PRED_INVALID)) {
2068 *err = ftrace_function_check_pred(pred, 0);
2069 } else {
2070 *err = ftrace_function_check_pred(pred, 1);
2071 if (*err)
2072 return WALK_PRED_ABORT;
2073
2074 *err = __ftrace_function_set_filter(pred->op == OP_EQ,
2075 pred->regex.pattern,
2076 pred->regex.len,
2077 data);
2078 }
2079
2080 return (*err) ? WALK_PRED_ABORT : WALK_PRED_DEFAULT;
2081}
2082
2083static int ftrace_function_set_filter(struct perf_event *event,
2084 struct event_filter *filter)
2085{
2086 struct function_filter_data data = {
2087 .first_filter = 1,
2088 .first_notrace = 1,
2089 .ops = &event->ftrace_ops,
2090 };
2091
2092 return walk_pred_tree(filter->preds, filter->root,
2093 ftrace_function_set_filter_cb, &data);
2094}
2095#else
2096static int ftrace_function_set_filter(struct perf_event *event,
2097 struct event_filter *filter)
2098{
2099 return -ENODEV;
2100}
2101#endif /* CONFIG_FUNCTION_TRACER */
2102
1953int ftrace_profile_set_filter(struct perf_event *event, int event_id, 2103int ftrace_profile_set_filter(struct perf_event *event, int event_id,
1954 char *filter_str) 2104 char *filter_str)
1955{ 2105{
@@ -1970,9 +2120,16 @@ int ftrace_profile_set_filter(struct perf_event *event, int event_id,
1970 goto out_unlock; 2120 goto out_unlock;
1971 2121
1972 err = create_filter(call, filter_str, false, &filter); 2122 err = create_filter(call, filter_str, false, &filter);
1973 if (!err) 2123 if (err)
1974 event->filter = filter; 2124 goto free_filter;
2125
2126 if (ftrace_event_is_function(call))
2127 err = ftrace_function_set_filter(event, filter);
1975 else 2128 else
2129 event->filter = filter;
2130
2131free_filter:
2132 if (err || ftrace_event_is_function(call))
1976 __free_filter(filter); 2133 __free_filter(filter);
1977 2134
1978out_unlock: 2135out_unlock:
diff --git a/kernel/trace/trace_export.c b/kernel/trace/trace_export.c
index ad4000c71be0..3dd15e8bc856 100644
--- a/kernel/trace/trace_export.c
+++ b/kernel/trace/trace_export.c
@@ -18,6 +18,16 @@
18#undef TRACE_SYSTEM 18#undef TRACE_SYSTEM
19#define TRACE_SYSTEM ftrace 19#define TRACE_SYSTEM ftrace
20 20
21/*
22 * The FTRACE_ENTRY_REG macro allows ftrace entry to define register
23 * function and thus become accesible via perf.
24 */
25#undef FTRACE_ENTRY_REG
26#define FTRACE_ENTRY_REG(name, struct_name, id, tstruct, print, \
27 filter, regfn) \
28 FTRACE_ENTRY(name, struct_name, id, PARAMS(tstruct), PARAMS(print), \
29 filter)
30
21/* not needed for this file */ 31/* not needed for this file */
22#undef __field_struct 32#undef __field_struct
23#define __field_struct(type, item) 33#define __field_struct(type, item)
@@ -44,21 +54,22 @@
44#define F_printk(fmt, args...) fmt, args 54#define F_printk(fmt, args...) fmt, args
45 55
46#undef FTRACE_ENTRY 56#undef FTRACE_ENTRY
47#define FTRACE_ENTRY(name, struct_name, id, tstruct, print) \ 57#define FTRACE_ENTRY(name, struct_name, id, tstruct, print, filter) \
48struct ____ftrace_##name { \ 58struct ____ftrace_##name { \
49 tstruct \ 59 tstruct \
50}; \ 60}; \
51static void __always_unused ____ftrace_check_##name(void) \ 61static void __always_unused ____ftrace_check_##name(void) \
52{ \ 62{ \
53 struct ____ftrace_##name *__entry = NULL; \ 63 struct ____ftrace_##name *__entry = NULL; \
54 \ 64 \
55 /* force compile-time check on F_printk() */ \ 65 /* force compile-time check on F_printk() */ \
56 printk(print); \ 66 printk(print); \
57} 67}
58 68
59#undef FTRACE_ENTRY_DUP 69#undef FTRACE_ENTRY_DUP
60#define FTRACE_ENTRY_DUP(name, struct_name, id, tstruct, print) \ 70#define FTRACE_ENTRY_DUP(name, struct_name, id, tstruct, print, filter) \
61 FTRACE_ENTRY(name, struct_name, id, PARAMS(tstruct), PARAMS(print)) 71 FTRACE_ENTRY(name, struct_name, id, PARAMS(tstruct), PARAMS(print), \
72 filter)
62 73
63#include "trace_entries.h" 74#include "trace_entries.h"
64 75
@@ -67,7 +78,7 @@ static void __always_unused ____ftrace_check_##name(void) \
67 ret = trace_define_field(event_call, #type, #item, \ 78 ret = trace_define_field(event_call, #type, #item, \
68 offsetof(typeof(field), item), \ 79 offsetof(typeof(field), item), \
69 sizeof(field.item), \ 80 sizeof(field.item), \
70 is_signed_type(type), FILTER_OTHER); \ 81 is_signed_type(type), filter_type); \
71 if (ret) \ 82 if (ret) \
72 return ret; 83 return ret;
73 84
@@ -77,7 +88,7 @@ static void __always_unused ____ftrace_check_##name(void) \
77 offsetof(typeof(field), \ 88 offsetof(typeof(field), \
78 container.item), \ 89 container.item), \
79 sizeof(field.container.item), \ 90 sizeof(field.container.item), \
80 is_signed_type(type), FILTER_OTHER); \ 91 is_signed_type(type), filter_type); \
81 if (ret) \ 92 if (ret) \
82 return ret; 93 return ret;
83 94
@@ -91,7 +102,7 @@ static void __always_unused ____ftrace_check_##name(void) \
91 ret = trace_define_field(event_call, event_storage, #item, \ 102 ret = trace_define_field(event_call, event_storage, #item, \
92 offsetof(typeof(field), item), \ 103 offsetof(typeof(field), item), \
93 sizeof(field.item), \ 104 sizeof(field.item), \
94 is_signed_type(type), FILTER_OTHER); \ 105 is_signed_type(type), filter_type); \
95 mutex_unlock(&event_storage_mutex); \ 106 mutex_unlock(&event_storage_mutex); \
96 if (ret) \ 107 if (ret) \
97 return ret; \ 108 return ret; \
@@ -104,7 +115,7 @@ static void __always_unused ____ftrace_check_##name(void) \
104 offsetof(typeof(field), \ 115 offsetof(typeof(field), \
105 container.item), \ 116 container.item), \
106 sizeof(field.container.item), \ 117 sizeof(field.container.item), \
107 is_signed_type(type), FILTER_OTHER); \ 118 is_signed_type(type), filter_type); \
108 if (ret) \ 119 if (ret) \
109 return ret; 120 return ret;
110 121
@@ -112,17 +123,18 @@ static void __always_unused ____ftrace_check_##name(void) \
112#define __dynamic_array(type, item) \ 123#define __dynamic_array(type, item) \
113 ret = trace_define_field(event_call, #type, #item, \ 124 ret = trace_define_field(event_call, #type, #item, \
114 offsetof(typeof(field), item), \ 125 offsetof(typeof(field), item), \
115 0, is_signed_type(type), FILTER_OTHER);\ 126 0, is_signed_type(type), filter_type);\
116 if (ret) \ 127 if (ret) \
117 return ret; 128 return ret;
118 129
119#undef FTRACE_ENTRY 130#undef FTRACE_ENTRY
120#define FTRACE_ENTRY(name, struct_name, id, tstruct, print) \ 131#define FTRACE_ENTRY(name, struct_name, id, tstruct, print, filter) \
121int \ 132int \
122ftrace_define_fields_##name(struct ftrace_event_call *event_call) \ 133ftrace_define_fields_##name(struct ftrace_event_call *event_call) \
123{ \ 134{ \
124 struct struct_name field; \ 135 struct struct_name field; \
125 int ret; \ 136 int ret; \
137 int filter_type = filter; \
126 \ 138 \
127 tstruct; \ 139 tstruct; \
128 \ 140 \
@@ -152,13 +164,15 @@ ftrace_define_fields_##name(struct ftrace_event_call *event_call) \
152#undef F_printk 164#undef F_printk
153#define F_printk(fmt, args...) __stringify(fmt) ", " __stringify(args) 165#define F_printk(fmt, args...) __stringify(fmt) ", " __stringify(args)
154 166
155#undef FTRACE_ENTRY 167#undef FTRACE_ENTRY_REG
156#define FTRACE_ENTRY(call, struct_name, etype, tstruct, print) \ 168#define FTRACE_ENTRY_REG(call, struct_name, etype, tstruct, print, filter,\
169 regfn) \
157 \ 170 \
158struct ftrace_event_class event_class_ftrace_##call = { \ 171struct ftrace_event_class event_class_ftrace_##call = { \
159 .system = __stringify(TRACE_SYSTEM), \ 172 .system = __stringify(TRACE_SYSTEM), \
160 .define_fields = ftrace_define_fields_##call, \ 173 .define_fields = ftrace_define_fields_##call, \
161 .fields = LIST_HEAD_INIT(event_class_ftrace_##call.fields),\ 174 .fields = LIST_HEAD_INIT(event_class_ftrace_##call.fields),\
175 .reg = regfn, \
162}; \ 176}; \
163 \ 177 \
164struct ftrace_event_call __used event_##call = { \ 178struct ftrace_event_call __used event_##call = { \
@@ -170,4 +184,14 @@ struct ftrace_event_call __used event_##call = { \
170struct ftrace_event_call __used \ 184struct ftrace_event_call __used \
171__attribute__((section("_ftrace_events"))) *__event_##call = &event_##call; 185__attribute__((section("_ftrace_events"))) *__event_##call = &event_##call;
172 186
187#undef FTRACE_ENTRY
188#define FTRACE_ENTRY(call, struct_name, etype, tstruct, print, filter) \
189 FTRACE_ENTRY_REG(call, struct_name, etype, \
190 PARAMS(tstruct), PARAMS(print), filter, NULL)
191
192int ftrace_event_is_function(struct ftrace_event_call *call)
193{
194 return call == &event_function;
195}
196
173#include "trace_entries.h" 197#include "trace_entries.h"
diff --git a/kernel/trace/trace_kprobe.c b/kernel/trace/trace_kprobe.c
index 00d527c945a4..580a05ec926b 100644
--- a/kernel/trace/trace_kprobe.c
+++ b/kernel/trace/trace_kprobe.c
@@ -1892,7 +1892,8 @@ static __kprobes void kretprobe_perf_func(struct kretprobe_instance *ri,
1892#endif /* CONFIG_PERF_EVENTS */ 1892#endif /* CONFIG_PERF_EVENTS */
1893 1893
1894static __kprobes 1894static __kprobes
1895int kprobe_register(struct ftrace_event_call *event, enum trace_reg type) 1895int kprobe_register(struct ftrace_event_call *event,
1896 enum trace_reg type, void *data)
1896{ 1897{
1897 struct trace_probe *tp = (struct trace_probe *)event->data; 1898 struct trace_probe *tp = (struct trace_probe *)event->data;
1898 1899
@@ -1909,6 +1910,11 @@ int kprobe_register(struct ftrace_event_call *event, enum trace_reg type)
1909 case TRACE_REG_PERF_UNREGISTER: 1910 case TRACE_REG_PERF_UNREGISTER:
1910 disable_trace_probe(tp, TP_FLAG_PROFILE); 1911 disable_trace_probe(tp, TP_FLAG_PROFILE);
1911 return 0; 1912 return 0;
1913 case TRACE_REG_PERF_OPEN:
1914 case TRACE_REG_PERF_CLOSE:
1915 case TRACE_REG_PERF_ADD:
1916 case TRACE_REG_PERF_DEL:
1917 return 0;
1912#endif 1918#endif
1913 } 1919 }
1914 return 0; 1920 return 0;
diff --git a/kernel/trace/trace_output.c b/kernel/trace/trace_output.c
index 0d6ff3555942..c5a01873567d 100644
--- a/kernel/trace/trace_output.c
+++ b/kernel/trace/trace_output.c
@@ -300,7 +300,7 @@ ftrace_print_flags_seq(struct trace_seq *p, const char *delim,
300 unsigned long mask; 300 unsigned long mask;
301 const char *str; 301 const char *str;
302 const char *ret = p->buffer + p->len; 302 const char *ret = p->buffer + p->len;
303 int i; 303 int i, first = 1;
304 304
305 for (i = 0; flag_array[i].name && flags; i++) { 305 for (i = 0; flag_array[i].name && flags; i++) {
306 306
@@ -310,14 +310,16 @@ ftrace_print_flags_seq(struct trace_seq *p, const char *delim,
310 310
311 str = flag_array[i].name; 311 str = flag_array[i].name;
312 flags &= ~mask; 312 flags &= ~mask;
313 if (p->len && delim) 313 if (!first && delim)
314 trace_seq_puts(p, delim); 314 trace_seq_puts(p, delim);
315 else
316 first = 0;
315 trace_seq_puts(p, str); 317 trace_seq_puts(p, str);
316 } 318 }
317 319
318 /* check for left over flags */ 320 /* check for left over flags */
319 if (flags) { 321 if (flags) {
320 if (p->len && delim) 322 if (!first && delim)
321 trace_seq_puts(p, delim); 323 trace_seq_puts(p, delim);
322 trace_seq_printf(p, "0x%lx", flags); 324 trace_seq_printf(p, "0x%lx", flags);
323 } 325 }
@@ -344,7 +346,7 @@ ftrace_print_symbols_seq(struct trace_seq *p, unsigned long val,
344 break; 346 break;
345 } 347 }
346 348
347 if (!p->len) 349 if (ret == (const char *)(p->buffer + p->len))
348 trace_seq_printf(p, "0x%lx", val); 350 trace_seq_printf(p, "0x%lx", val);
349 351
350 trace_seq_putc(p, 0); 352 trace_seq_putc(p, 0);
@@ -370,7 +372,7 @@ ftrace_print_symbols_seq_u64(struct trace_seq *p, unsigned long long val,
370 break; 372 break;
371 } 373 }
372 374
373 if (!p->len) 375 if (ret == (const char *)(p->buffer + p->len))
374 trace_seq_printf(p, "0x%llx", val); 376 trace_seq_printf(p, "0x%llx", val);
375 377
376 trace_seq_putc(p, 0); 378 trace_seq_putc(p, 0);
diff --git a/kernel/trace/trace_syscalls.c b/kernel/trace/trace_syscalls.c
index cb654542c1a1..96fc73369099 100644
--- a/kernel/trace/trace_syscalls.c
+++ b/kernel/trace/trace_syscalls.c
@@ -17,9 +17,9 @@ static DECLARE_BITMAP(enabled_enter_syscalls, NR_syscalls);
17static DECLARE_BITMAP(enabled_exit_syscalls, NR_syscalls); 17static DECLARE_BITMAP(enabled_exit_syscalls, NR_syscalls);
18 18
19static int syscall_enter_register(struct ftrace_event_call *event, 19static int syscall_enter_register(struct ftrace_event_call *event,
20 enum trace_reg type); 20 enum trace_reg type, void *data);
21static int syscall_exit_register(struct ftrace_event_call *event, 21static int syscall_exit_register(struct ftrace_event_call *event,
22 enum trace_reg type); 22 enum trace_reg type, void *data);
23 23
24static int syscall_enter_define_fields(struct ftrace_event_call *call); 24static int syscall_enter_define_fields(struct ftrace_event_call *call);
25static int syscall_exit_define_fields(struct ftrace_event_call *call); 25static int syscall_exit_define_fields(struct ftrace_event_call *call);
@@ -468,8 +468,8 @@ int __init init_ftrace_syscalls(void)
468 unsigned long addr; 468 unsigned long addr;
469 int i; 469 int i;
470 470
471 syscalls_metadata = kzalloc(sizeof(*syscalls_metadata) * 471 syscalls_metadata = kcalloc(NR_syscalls, sizeof(*syscalls_metadata),
472 NR_syscalls, GFP_KERNEL); 472 GFP_KERNEL);
473 if (!syscalls_metadata) { 473 if (!syscalls_metadata) {
474 WARN_ON(1); 474 WARN_ON(1);
475 return -ENOMEM; 475 return -ENOMEM;
@@ -649,7 +649,7 @@ void perf_sysexit_disable(struct ftrace_event_call *call)
649#endif /* CONFIG_PERF_EVENTS */ 649#endif /* CONFIG_PERF_EVENTS */
650 650
651static int syscall_enter_register(struct ftrace_event_call *event, 651static int syscall_enter_register(struct ftrace_event_call *event,
652 enum trace_reg type) 652 enum trace_reg type, void *data)
653{ 653{
654 switch (type) { 654 switch (type) {
655 case TRACE_REG_REGISTER: 655 case TRACE_REG_REGISTER:
@@ -664,13 +664,18 @@ static int syscall_enter_register(struct ftrace_event_call *event,
664 case TRACE_REG_PERF_UNREGISTER: 664 case TRACE_REG_PERF_UNREGISTER:
665 perf_sysenter_disable(event); 665 perf_sysenter_disable(event);
666 return 0; 666 return 0;
667 case TRACE_REG_PERF_OPEN:
668 case TRACE_REG_PERF_CLOSE:
669 case TRACE_REG_PERF_ADD:
670 case TRACE_REG_PERF_DEL:
671 return 0;
667#endif 672#endif
668 } 673 }
669 return 0; 674 return 0;
670} 675}
671 676
672static int syscall_exit_register(struct ftrace_event_call *event, 677static int syscall_exit_register(struct ftrace_event_call *event,
673 enum trace_reg type) 678 enum trace_reg type, void *data)
674{ 679{
675 switch (type) { 680 switch (type) {
676 case TRACE_REG_REGISTER: 681 case TRACE_REG_REGISTER:
@@ -685,6 +690,11 @@ static int syscall_exit_register(struct ftrace_event_call *event,
685 case TRACE_REG_PERF_UNREGISTER: 690 case TRACE_REG_PERF_UNREGISTER:
686 perf_sysexit_disable(event); 691 perf_sysexit_disable(event);
687 return 0; 692 return 0;
693 case TRACE_REG_PERF_OPEN:
694 case TRACE_REG_PERF_CLOSE:
695 case TRACE_REG_PERF_ADD:
696 case TRACE_REG_PERF_DEL:
697 return 0;
688#endif 698#endif
689 } 699 }
690 return 0; 700 return 0;
diff --git a/kernel/tracepoint.c b/kernel/tracepoint.c
index f1539decd99d..d96ba22dabfa 100644
--- a/kernel/tracepoint.c
+++ b/kernel/tracepoint.c
@@ -25,7 +25,7 @@
25#include <linux/err.h> 25#include <linux/err.h>
26#include <linux/slab.h> 26#include <linux/slab.h>
27#include <linux/sched.h> 27#include <linux/sched.h>
28#include <linux/jump_label.h> 28#include <linux/static_key.h>
29 29
30extern struct tracepoint * const __start___tracepoints_ptrs[]; 30extern struct tracepoint * const __start___tracepoints_ptrs[];
31extern struct tracepoint * const __stop___tracepoints_ptrs[]; 31extern struct tracepoint * const __stop___tracepoints_ptrs[];
@@ -256,9 +256,9 @@ static void set_tracepoint(struct tracepoint_entry **entry,
256{ 256{
257 WARN_ON(strcmp((*entry)->name, elem->name) != 0); 257 WARN_ON(strcmp((*entry)->name, elem->name) != 0);
258 258
259 if (elem->regfunc && !jump_label_enabled(&elem->key) && active) 259 if (elem->regfunc && !static_key_enabled(&elem->key) && active)
260 elem->regfunc(); 260 elem->regfunc();
261 else if (elem->unregfunc && jump_label_enabled(&elem->key) && !active) 261 else if (elem->unregfunc && static_key_enabled(&elem->key) && !active)
262 elem->unregfunc(); 262 elem->unregfunc();
263 263
264 /* 264 /*
@@ -269,10 +269,10 @@ static void set_tracepoint(struct tracepoint_entry **entry,
269 * is used. 269 * is used.
270 */ 270 */
271 rcu_assign_pointer(elem->funcs, (*entry)->funcs); 271 rcu_assign_pointer(elem->funcs, (*entry)->funcs);
272 if (active && !jump_label_enabled(&elem->key)) 272 if (active && !static_key_enabled(&elem->key))
273 jump_label_inc(&elem->key); 273 static_key_slow_inc(&elem->key);
274 else if (!active && jump_label_enabled(&elem->key)) 274 else if (!active && static_key_enabled(&elem->key))
275 jump_label_dec(&elem->key); 275 static_key_slow_dec(&elem->key);
276} 276}
277 277
278/* 278/*
@@ -283,11 +283,11 @@ static void set_tracepoint(struct tracepoint_entry **entry,
283 */ 283 */
284static void disable_tracepoint(struct tracepoint *elem) 284static void disable_tracepoint(struct tracepoint *elem)
285{ 285{
286 if (elem->unregfunc && jump_label_enabled(&elem->key)) 286 if (elem->unregfunc && static_key_enabled(&elem->key))
287 elem->unregfunc(); 287 elem->unregfunc();
288 288
289 if (jump_label_enabled(&elem->key)) 289 if (static_key_enabled(&elem->key))
290 jump_label_dec(&elem->key); 290 static_key_slow_dec(&elem->key);
291 rcu_assign_pointer(elem->funcs, NULL); 291 rcu_assign_pointer(elem->funcs, NULL);
292} 292}
293 293
diff --git a/kernel/watchdog.c b/kernel/watchdog.c
index d117262deba3..14bc092fb12c 100644
--- a/kernel/watchdog.c
+++ b/kernel/watchdog.c
@@ -3,12 +3,9 @@
3 * 3 *
4 * started by Don Zickus, Copyright (C) 2010 Red Hat, Inc. 4 * started by Don Zickus, Copyright (C) 2010 Red Hat, Inc.
5 * 5 *
6 * this code detects hard lockups: incidents in where on a CPU 6 * Note: Most of this code is borrowed heavily from the original softlockup
7 * the kernel does not respond to anything except NMI. 7 * detector, so thanks to Ingo for the initial implementation.
8 * 8 * Some chunks also taken from the old x86-specific nmi watchdog code, thanks
9 * Note: Most of this code is borrowed heavily from softlockup.c,
10 * so thanks to Ingo for the initial implementation.
11 * Some chunks also taken from arch/x86/kernel/apic/nmi.c, thanks
12 * to those contributors as well. 9 * to those contributors as well.
13 */ 10 */
14 11
@@ -117,9 +114,10 @@ static unsigned long get_sample_period(void)
117{ 114{
118 /* 115 /*
119 * convert watchdog_thresh from seconds to ns 116 * convert watchdog_thresh from seconds to ns
120 * the divide by 5 is to give hrtimer 5 chances to 117 * the divide by 5 is to give hrtimer several chances (two
121 * increment before the hardlockup detector generates 118 * or three with the current relation between the soft
122 * a warning 119 * and hard thresholds) to increment before the
120 * hardlockup detector generates a warning
123 */ 121 */
124 return get_softlockup_thresh() * (NSEC_PER_SEC / 5); 122 return get_softlockup_thresh() * (NSEC_PER_SEC / 5);
125} 123}
@@ -336,9 +334,11 @@ static int watchdog(void *unused)
336 334
337 set_current_state(TASK_INTERRUPTIBLE); 335 set_current_state(TASK_INTERRUPTIBLE);
338 /* 336 /*
339 * Run briefly once per second to reset the softlockup timestamp. 337 * Run briefly (kicked by the hrtimer callback function) once every
340 * If this gets delayed for more than 60 seconds then the 338 * get_sample_period() seconds (4 seconds by default) to reset the
341 * debug-printout triggers in watchdog_timer_fn(). 339 * softlockup timestamp. If this gets delayed for more than
340 * 2*watchdog_thresh seconds then the debug-printout triggers in
341 * watchdog_timer_fn().
342 */ 342 */
343 while (!kthread_should_stop()) { 343 while (!kthread_should_stop()) {
344 __touch_watchdog(); 344 __touch_watchdog();
diff --git a/kernel/workqueue.c b/kernel/workqueue.c
index bec7b5b53e03..f2c5638bb5ab 100644
--- a/kernel/workqueue.c
+++ b/kernel/workqueue.c
@@ -253,11 +253,13 @@ struct workqueue_struct *system_long_wq __read_mostly;
253struct workqueue_struct *system_nrt_wq __read_mostly; 253struct workqueue_struct *system_nrt_wq __read_mostly;
254struct workqueue_struct *system_unbound_wq __read_mostly; 254struct workqueue_struct *system_unbound_wq __read_mostly;
255struct workqueue_struct *system_freezable_wq __read_mostly; 255struct workqueue_struct *system_freezable_wq __read_mostly;
256struct workqueue_struct *system_nrt_freezable_wq __read_mostly;
256EXPORT_SYMBOL_GPL(system_wq); 257EXPORT_SYMBOL_GPL(system_wq);
257EXPORT_SYMBOL_GPL(system_long_wq); 258EXPORT_SYMBOL_GPL(system_long_wq);
258EXPORT_SYMBOL_GPL(system_nrt_wq); 259EXPORT_SYMBOL_GPL(system_nrt_wq);
259EXPORT_SYMBOL_GPL(system_unbound_wq); 260EXPORT_SYMBOL_GPL(system_unbound_wq);
260EXPORT_SYMBOL_GPL(system_freezable_wq); 261EXPORT_SYMBOL_GPL(system_freezable_wq);
262EXPORT_SYMBOL_GPL(system_nrt_freezable_wq);
261 263
262#define CREATE_TRACE_POINTS 264#define CREATE_TRACE_POINTS
263#include <trace/events/workqueue.h> 265#include <trace/events/workqueue.h>
@@ -3833,8 +3835,11 @@ static int __init init_workqueues(void)
3833 WQ_UNBOUND_MAX_ACTIVE); 3835 WQ_UNBOUND_MAX_ACTIVE);
3834 system_freezable_wq = alloc_workqueue("events_freezable", 3836 system_freezable_wq = alloc_workqueue("events_freezable",
3835 WQ_FREEZABLE, 0); 3837 WQ_FREEZABLE, 0);
3838 system_nrt_freezable_wq = alloc_workqueue("events_nrt_freezable",
3839 WQ_NON_REENTRANT | WQ_FREEZABLE, 0);
3836 BUG_ON(!system_wq || !system_long_wq || !system_nrt_wq || 3840 BUG_ON(!system_wq || !system_long_wq || !system_nrt_wq ||
3837 !system_unbound_wq || !system_freezable_wq); 3841 !system_unbound_wq || !system_freezable_wq ||
3842 !system_nrt_freezable_wq);
3838 return 0; 3843 return 0;
3839} 3844}
3840early_initcall(init_workqueues); 3845early_initcall(init_workqueues);
diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug
index 8745ac7d1f75..05037dc9bde7 100644
--- a/lib/Kconfig.debug
+++ b/lib/Kconfig.debug
@@ -166,18 +166,21 @@ config LOCKUP_DETECTOR
166 hard and soft lockups. 166 hard and soft lockups.
167 167
168 Softlockups are bugs that cause the kernel to loop in kernel 168 Softlockups are bugs that cause the kernel to loop in kernel
169 mode for more than 60 seconds, without giving other tasks a 169 mode for more than 20 seconds, without giving other tasks a
170 chance to run. The current stack trace is displayed upon 170 chance to run. The current stack trace is displayed upon
171 detection and the system will stay locked up. 171 detection and the system will stay locked up.
172 172
173 Hardlockups are bugs that cause the CPU to loop in kernel mode 173 Hardlockups are bugs that cause the CPU to loop in kernel mode
174 for more than 60 seconds, without letting other interrupts have a 174 for more than 10 seconds, without letting other interrupts have a
175 chance to run. The current stack trace is displayed upon detection 175 chance to run. The current stack trace is displayed upon detection
176 and the system will stay locked up. 176 and the system will stay locked up.
177 177
178 The overhead should be minimal. A periodic hrtimer runs to 178 The overhead should be minimal. A periodic hrtimer runs to
179 generate interrupts and kick the watchdog task every 10-12 seconds. 179 generate interrupts and kick the watchdog task every 4 seconds.
180 An NMI is generated every 60 seconds or so to check for hardlockups. 180 An NMI is generated every 10 seconds or so to check for hardlockups.
181
182 The frequency of hrtimer and NMI events and the soft and hard lockup
183 thresholds can be controlled through the sysctl watchdog_thresh.
181 184
182config HARDLOCKUP_DETECTOR 185config HARDLOCKUP_DETECTOR
183 def_bool LOCKUP_DETECTOR && PERF_EVENTS && HAVE_PERF_EVENTS_NMI && \ 186 def_bool LOCKUP_DETECTOR && PERF_EVENTS && HAVE_PERF_EVENTS_NMI && \
@@ -189,7 +192,8 @@ config BOOTPARAM_HARDLOCKUP_PANIC
189 help 192 help
190 Say Y here to enable the kernel to panic on "hard lockups", 193 Say Y here to enable the kernel to panic on "hard lockups",
191 which are bugs that cause the kernel to loop in kernel 194 which are bugs that cause the kernel to loop in kernel
192 mode with interrupts disabled for more than 60 seconds. 195 mode with interrupts disabled for more than 10 seconds (configurable
196 using the watchdog_thresh sysctl).
193 197
194 Say N if unsure. 198 Say N if unsure.
195 199
@@ -206,8 +210,8 @@ config BOOTPARAM_SOFTLOCKUP_PANIC
206 help 210 help
207 Say Y here to enable the kernel to panic on "soft lockups", 211 Say Y here to enable the kernel to panic on "soft lockups",
208 which are bugs that cause the kernel to loop in kernel 212 which are bugs that cause the kernel to loop in kernel
209 mode for more than 60 seconds, without giving other tasks a 213 mode for more than 20 seconds (configurable using the watchdog_thresh
210 chance to run. 214 sysctl), without giving other tasks a chance to run.
211 215
212 The panic can be used in combination with panic_timeout, 216 The panic can be used in combination with panic_timeout,
213 to cause the system to reboot automatically after a 217 to cause the system to reboot automatically after a
@@ -927,6 +931,30 @@ config RCU_CPU_STALL_VERBOSE
927 931
928 Say Y if you want to enable such checks. 932 Say Y if you want to enable such checks.
929 933
934config RCU_CPU_STALL_INFO
935 bool "Print additional diagnostics on RCU CPU stall"
936 depends on (TREE_RCU || TREE_PREEMPT_RCU) && DEBUG_KERNEL
937 default n
938 help
939 For each stalled CPU that is aware of the current RCU grace
940 period, print out additional per-CPU diagnostic information
941 regarding scheduling-clock ticks, idle state, and,
942 for RCU_FAST_NO_HZ kernels, idle-entry state.
943
944 Say N if you are unsure.
945
946 Say Y if you want to enable such diagnostics.
947
948config RCU_TRACE
949 bool "Enable tracing for RCU"
950 depends on DEBUG_KERNEL
951 help
952 This option provides tracing in RCU which presents stats
953 in debugfs for debugging RCU implementation.
954
955 Say Y here if you want to enable RCU tracing
956 Say N if you are unsure.
957
930config KPROBES_SANITY_TEST 958config KPROBES_SANITY_TEST
931 bool "Kprobes sanity tests" 959 bool "Kprobes sanity tests"
932 depends on DEBUG_KERNEL 960 depends on DEBUG_KERNEL
diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index d0e57a3cda18..58a08fc7414a 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -230,10 +230,30 @@ struct mem_cgroup {
230 * the counter to account for memory usage 230 * the counter to account for memory usage
231 */ 231 */
232 struct res_counter res; 232 struct res_counter res;
233 /* 233
234 * the counter to account for mem+swap usage. 234 union {
235 */ 235 /*
236 struct res_counter memsw; 236 * the counter to account for mem+swap usage.
237 */
238 struct res_counter memsw;
239
240 /*
241 * rcu_freeing is used only when freeing struct mem_cgroup,
242 * so put it into a union to avoid wasting more memory.
243 * It must be disjoint from the css field. It could be
244 * in a union with the res field, but res plays a much
245 * larger part in mem_cgroup life than memsw, and might
246 * be of interest, even at time of free, when debugging.
247 * So share rcu_head with the less interesting memsw.
248 */
249 struct rcu_head rcu_freeing;
250 /*
251 * But when using vfree(), that cannot be done at
252 * interrupt time, so we must then queue the work.
253 */
254 struct work_struct work_freeing;
255 };
256
237 /* 257 /*
238 * Per cgroup active and inactive list, similar to the 258 * Per cgroup active and inactive list, similar to the
239 * per zone LRU lists. 259 * per zone LRU lists.
@@ -4780,6 +4800,27 @@ out_free:
4780} 4800}
4781 4801
4782/* 4802/*
4803 * Helpers for freeing a vzalloc()ed mem_cgroup by RCU,
4804 * but in process context. The work_freeing structure is overlaid
4805 * on the rcu_freeing structure, which itself is overlaid on memsw.
4806 */
4807static void vfree_work(struct work_struct *work)
4808{
4809 struct mem_cgroup *memcg;
4810
4811 memcg = container_of(work, struct mem_cgroup, work_freeing);
4812 vfree(memcg);
4813}
4814static void vfree_rcu(struct rcu_head *rcu_head)
4815{
4816 struct mem_cgroup *memcg;
4817
4818 memcg = container_of(rcu_head, struct mem_cgroup, rcu_freeing);
4819 INIT_WORK(&memcg->work_freeing, vfree_work);
4820 schedule_work(&memcg->work_freeing);
4821}
4822
4823/*
4783 * At destroying mem_cgroup, references from swap_cgroup can remain. 4824 * At destroying mem_cgroup, references from swap_cgroup can remain.
4784 * (scanning all at force_empty is too costly...) 4825 * (scanning all at force_empty is too costly...)
4785 * 4826 *
@@ -4802,9 +4843,9 @@ static void __mem_cgroup_free(struct mem_cgroup *memcg)
4802 4843
4803 free_percpu(memcg->stat); 4844 free_percpu(memcg->stat);
4804 if (sizeof(struct mem_cgroup) < PAGE_SIZE) 4845 if (sizeof(struct mem_cgroup) < PAGE_SIZE)
4805 kfree(memcg); 4846 kfree_rcu(memcg, rcu_freeing);
4806 else 4847 else
4807 vfree(memcg); 4848 call_rcu(&memcg->rcu_freeing, vfree_rcu);
4808} 4849}
4809 4850
4810static void mem_cgroup_get(struct mem_cgroup *memcg) 4851static void mem_cgroup_get(struct mem_cgroup *memcg)
diff --git a/net/core/dev.c b/net/core/dev.c
index 6ca32f6b3105..6982bfd6a781 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -134,7 +134,7 @@
134#include <linux/inetdevice.h> 134#include <linux/inetdevice.h>
135#include <linux/cpu_rmap.h> 135#include <linux/cpu_rmap.h>
136#include <linux/net_tstamp.h> 136#include <linux/net_tstamp.h>
137#include <linux/jump_label.h> 137#include <linux/static_key.h>
138#include <net/flow_keys.h> 138#include <net/flow_keys.h>
139 139
140#include "net-sysfs.h" 140#include "net-sysfs.h"
@@ -1441,11 +1441,11 @@ int call_netdevice_notifiers(unsigned long val, struct net_device *dev)
1441} 1441}
1442EXPORT_SYMBOL(call_netdevice_notifiers); 1442EXPORT_SYMBOL(call_netdevice_notifiers);
1443 1443
1444static struct jump_label_key netstamp_needed __read_mostly; 1444static struct static_key netstamp_needed __read_mostly;
1445#ifdef HAVE_JUMP_LABEL 1445#ifdef HAVE_JUMP_LABEL
1446/* We are not allowed to call jump_label_dec() from irq context 1446/* We are not allowed to call static_key_slow_dec() from irq context
1447 * If net_disable_timestamp() is called from irq context, defer the 1447 * If net_disable_timestamp() is called from irq context, defer the
1448 * jump_label_dec() calls. 1448 * static_key_slow_dec() calls.
1449 */ 1449 */
1450static atomic_t netstamp_needed_deferred; 1450static atomic_t netstamp_needed_deferred;
1451#endif 1451#endif
@@ -1457,12 +1457,12 @@ void net_enable_timestamp(void)
1457 1457
1458 if (deferred) { 1458 if (deferred) {
1459 while (--deferred) 1459 while (--deferred)
1460 jump_label_dec(&netstamp_needed); 1460 static_key_slow_dec(&netstamp_needed);
1461 return; 1461 return;
1462 } 1462 }
1463#endif 1463#endif
1464 WARN_ON(in_interrupt()); 1464 WARN_ON(in_interrupt());
1465 jump_label_inc(&netstamp_needed); 1465 static_key_slow_inc(&netstamp_needed);
1466} 1466}
1467EXPORT_SYMBOL(net_enable_timestamp); 1467EXPORT_SYMBOL(net_enable_timestamp);
1468 1468
@@ -1474,19 +1474,19 @@ void net_disable_timestamp(void)
1474 return; 1474 return;
1475 } 1475 }
1476#endif 1476#endif
1477 jump_label_dec(&netstamp_needed); 1477 static_key_slow_dec(&netstamp_needed);
1478} 1478}
1479EXPORT_SYMBOL(net_disable_timestamp); 1479EXPORT_SYMBOL(net_disable_timestamp);
1480 1480
1481static inline void net_timestamp_set(struct sk_buff *skb) 1481static inline void net_timestamp_set(struct sk_buff *skb)
1482{ 1482{
1483 skb->tstamp.tv64 = 0; 1483 skb->tstamp.tv64 = 0;
1484 if (static_branch(&netstamp_needed)) 1484 if (static_key_false(&netstamp_needed))
1485 __net_timestamp(skb); 1485 __net_timestamp(skb);
1486} 1486}
1487 1487
1488#define net_timestamp_check(COND, SKB) \ 1488#define net_timestamp_check(COND, SKB) \
1489 if (static_branch(&netstamp_needed)) { \ 1489 if (static_key_false(&netstamp_needed)) { \
1490 if ((COND) && !(SKB)->tstamp.tv64) \ 1490 if ((COND) && !(SKB)->tstamp.tv64) \
1491 __net_timestamp(SKB); \ 1491 __net_timestamp(SKB); \
1492 } \ 1492 } \
@@ -2660,7 +2660,7 @@ EXPORT_SYMBOL(__skb_get_rxhash);
2660struct rps_sock_flow_table __rcu *rps_sock_flow_table __read_mostly; 2660struct rps_sock_flow_table __rcu *rps_sock_flow_table __read_mostly;
2661EXPORT_SYMBOL(rps_sock_flow_table); 2661EXPORT_SYMBOL(rps_sock_flow_table);
2662 2662
2663struct jump_label_key rps_needed __read_mostly; 2663struct static_key rps_needed __read_mostly;
2664 2664
2665static struct rps_dev_flow * 2665static struct rps_dev_flow *
2666set_rps_cpu(struct net_device *dev, struct sk_buff *skb, 2666set_rps_cpu(struct net_device *dev, struct sk_buff *skb,
@@ -2945,7 +2945,7 @@ int netif_rx(struct sk_buff *skb)
2945 2945
2946 trace_netif_rx(skb); 2946 trace_netif_rx(skb);
2947#ifdef CONFIG_RPS 2947#ifdef CONFIG_RPS
2948 if (static_branch(&rps_needed)) { 2948 if (static_key_false(&rps_needed)) {
2949 struct rps_dev_flow voidflow, *rflow = &voidflow; 2949 struct rps_dev_flow voidflow, *rflow = &voidflow;
2950 int cpu; 2950 int cpu;
2951 2951
@@ -3309,7 +3309,7 @@ int netif_receive_skb(struct sk_buff *skb)
3309 return NET_RX_SUCCESS; 3309 return NET_RX_SUCCESS;
3310 3310
3311#ifdef CONFIG_RPS 3311#ifdef CONFIG_RPS
3312 if (static_branch(&rps_needed)) { 3312 if (static_key_false(&rps_needed)) {
3313 struct rps_dev_flow voidflow, *rflow = &voidflow; 3313 struct rps_dev_flow voidflow, *rflow = &voidflow;
3314 int cpu, ret; 3314 int cpu, ret;
3315 3315
diff --git a/net/core/net-sysfs.c b/net/core/net-sysfs.c
index a1727cda03d7..495586232aa1 100644
--- a/net/core/net-sysfs.c
+++ b/net/core/net-sysfs.c
@@ -608,10 +608,10 @@ static ssize_t store_rps_map(struct netdev_rx_queue *queue,
608 spin_unlock(&rps_map_lock); 608 spin_unlock(&rps_map_lock);
609 609
610 if (map) 610 if (map)
611 jump_label_inc(&rps_needed); 611 static_key_slow_inc(&rps_needed);
612 if (old_map) { 612 if (old_map) {
613 kfree_rcu(old_map, rcu); 613 kfree_rcu(old_map, rcu);
614 jump_label_dec(&rps_needed); 614 static_key_slow_dec(&rps_needed);
615 } 615 }
616 free_cpumask_var(mask); 616 free_cpumask_var(mask);
617 return len; 617 return len;
diff --git a/net/core/sock.c b/net/core/sock.c
index 02f8dfe320b7..95aff9c7419b 100644
--- a/net/core/sock.c
+++ b/net/core/sock.c
@@ -111,7 +111,7 @@
111#include <linux/init.h> 111#include <linux/init.h>
112#include <linux/highmem.h> 112#include <linux/highmem.h>
113#include <linux/user_namespace.h> 113#include <linux/user_namespace.h>
114#include <linux/jump_label.h> 114#include <linux/static_key.h>
115#include <linux/memcontrol.h> 115#include <linux/memcontrol.h>
116 116
117#include <asm/uaccess.h> 117#include <asm/uaccess.h>
@@ -184,7 +184,7 @@ void mem_cgroup_sockets_destroy(struct cgroup *cgrp, struct cgroup_subsys *ss)
184static struct lock_class_key af_family_keys[AF_MAX]; 184static struct lock_class_key af_family_keys[AF_MAX];
185static struct lock_class_key af_family_slock_keys[AF_MAX]; 185static struct lock_class_key af_family_slock_keys[AF_MAX];
186 186
187struct jump_label_key memcg_socket_limit_enabled; 187struct static_key memcg_socket_limit_enabled;
188EXPORT_SYMBOL(memcg_socket_limit_enabled); 188EXPORT_SYMBOL(memcg_socket_limit_enabled);
189 189
190/* 190/*
diff --git a/net/core/sysctl_net_core.c b/net/core/sysctl_net_core.c
index d05559d4d9cd..0c2850874254 100644
--- a/net/core/sysctl_net_core.c
+++ b/net/core/sysctl_net_core.c
@@ -69,9 +69,9 @@ static int rps_sock_flow_sysctl(ctl_table *table, int write,
69 if (sock_table != orig_sock_table) { 69 if (sock_table != orig_sock_table) {
70 rcu_assign_pointer(rps_sock_flow_table, sock_table); 70 rcu_assign_pointer(rps_sock_flow_table, sock_table);
71 if (sock_table) 71 if (sock_table)
72 jump_label_inc(&rps_needed); 72 static_key_slow_inc(&rps_needed);
73 if (orig_sock_table) { 73 if (orig_sock_table) {
74 jump_label_dec(&rps_needed); 74 static_key_slow_dec(&rps_needed);
75 synchronize_rcu(); 75 synchronize_rcu();
76 vfree(orig_sock_table); 76 vfree(orig_sock_table);
77 } 77 }
diff --git a/net/ipv4/cipso_ipv4.c b/net/ipv4/cipso_ipv4.c
index 86f3b885b4f3..c48adc565e92 100644
--- a/net/ipv4/cipso_ipv4.c
+++ b/net/ipv4/cipso_ipv4.c
@@ -1857,11 +1857,6 @@ static int cipso_v4_genopt(unsigned char *buf, u32 buf_len,
1857 return CIPSO_V4_HDR_LEN + ret_val; 1857 return CIPSO_V4_HDR_LEN + ret_val;
1858} 1858}
1859 1859
1860static void opt_kfree_rcu(struct rcu_head *head)
1861{
1862 kfree(container_of(head, struct ip_options_rcu, rcu));
1863}
1864
1865/** 1860/**
1866 * cipso_v4_sock_setattr - Add a CIPSO option to a socket 1861 * cipso_v4_sock_setattr - Add a CIPSO option to a socket
1867 * @sk: the socket 1862 * @sk: the socket
@@ -1938,7 +1933,7 @@ int cipso_v4_sock_setattr(struct sock *sk,
1938 } 1933 }
1939 rcu_assign_pointer(sk_inet->inet_opt, opt); 1934 rcu_assign_pointer(sk_inet->inet_opt, opt);
1940 if (old) 1935 if (old)
1941 call_rcu(&old->rcu, opt_kfree_rcu); 1936 kfree_rcu(old, rcu);
1942 1937
1943 return 0; 1938 return 0;
1944 1939
@@ -2005,7 +2000,7 @@ int cipso_v4_req_setattr(struct request_sock *req,
2005 req_inet = inet_rsk(req); 2000 req_inet = inet_rsk(req);
2006 opt = xchg(&req_inet->opt, opt); 2001 opt = xchg(&req_inet->opt, opt);
2007 if (opt) 2002 if (opt)
2008 call_rcu(&opt->rcu, opt_kfree_rcu); 2003 kfree_rcu(opt, rcu);
2009 2004
2010 return 0; 2005 return 0;
2011 2006
@@ -2075,7 +2070,7 @@ static int cipso_v4_delopt(struct ip_options_rcu **opt_ptr)
2075 * remove the entire option struct */ 2070 * remove the entire option struct */
2076 *opt_ptr = NULL; 2071 *opt_ptr = NULL;
2077 hdr_delta = opt->opt.optlen; 2072 hdr_delta = opt->opt.optlen;
2078 call_rcu(&opt->rcu, opt_kfree_rcu); 2073 kfree_rcu(opt, rcu);
2079 } 2074 }
2080 2075
2081 return hdr_delta; 2076 return hdr_delta;
diff --git a/net/ipv4/ip_sockglue.c b/net/ipv4/ip_sockglue.c
index 8aa87c19fa00..5343d9ac510b 100644
--- a/net/ipv4/ip_sockglue.c
+++ b/net/ipv4/ip_sockglue.c
@@ -445,11 +445,6 @@ out:
445} 445}
446 446
447 447
448static void opt_kfree_rcu(struct rcu_head *head)
449{
450 kfree(container_of(head, struct ip_options_rcu, rcu));
451}
452
453/* 448/*
454 * Socket option code for IP. This is the end of the line after any 449 * Socket option code for IP. This is the end of the line after any
455 * TCP,UDP etc options on an IP socket. 450 * TCP,UDP etc options on an IP socket.
@@ -525,7 +520,7 @@ static int do_ip_setsockopt(struct sock *sk, int level,
525 } 520 }
526 rcu_assign_pointer(inet->inet_opt, opt); 521 rcu_assign_pointer(inet->inet_opt, opt);
527 if (old) 522 if (old)
528 call_rcu(&old->rcu, opt_kfree_rcu); 523 kfree_rcu(old, rcu);
529 break; 524 break;
530 } 525 }
531 case IP_PKTINFO: 526 case IP_PKTINFO:
diff --git a/net/ipv4/tcp_memcontrol.c b/net/ipv4/tcp_memcontrol.c
index 49978788a9dc..602fb305365f 100644
--- a/net/ipv4/tcp_memcontrol.c
+++ b/net/ipv4/tcp_memcontrol.c
@@ -111,7 +111,7 @@ void tcp_destroy_cgroup(struct cgroup *cgrp, struct cgroup_subsys *ss)
111 val = res_counter_read_u64(&tcp->tcp_memory_allocated, RES_LIMIT); 111 val = res_counter_read_u64(&tcp->tcp_memory_allocated, RES_LIMIT);
112 112
113 if (val != RESOURCE_MAX) 113 if (val != RESOURCE_MAX)
114 jump_label_dec(&memcg_socket_limit_enabled); 114 static_key_slow_dec(&memcg_socket_limit_enabled);
115} 115}
116EXPORT_SYMBOL(tcp_destroy_cgroup); 116EXPORT_SYMBOL(tcp_destroy_cgroup);
117 117
@@ -143,9 +143,9 @@ static int tcp_update_limit(struct mem_cgroup *memcg, u64 val)
143 net->ipv4.sysctl_tcp_mem[i]); 143 net->ipv4.sysctl_tcp_mem[i]);
144 144
145 if (val == RESOURCE_MAX && old_lim != RESOURCE_MAX) 145 if (val == RESOURCE_MAX && old_lim != RESOURCE_MAX)
146 jump_label_dec(&memcg_socket_limit_enabled); 146 static_key_slow_dec(&memcg_socket_limit_enabled);
147 else if (old_lim == RESOURCE_MAX && val != RESOURCE_MAX) 147 else if (old_lim == RESOURCE_MAX && val != RESOURCE_MAX)
148 jump_label_inc(&memcg_socket_limit_enabled); 148 static_key_slow_inc(&memcg_socket_limit_enabled);
149 149
150 return 0; 150 return 0;
151} 151}
diff --git a/net/ipv6/mcast.c b/net/ipv6/mcast.c
index b853f06cc148..16c33e308121 100644
--- a/net/ipv6/mcast.c
+++ b/net/ipv6/mcast.c
@@ -257,7 +257,6 @@ static struct inet6_dev *ip6_mc_find_dev_rcu(struct net *net,
257 257
258 if (rt) { 258 if (rt) {
259 dev = rt->dst.dev; 259 dev = rt->dst.dev;
260 dev_hold(dev);
261 dst_release(&rt->dst); 260 dst_release(&rt->dst);
262 } 261 }
263 } else 262 } else
diff --git a/net/ipv6/route.c b/net/ipv6/route.c
index 8c2e3ab58f2a..22b766407de1 100644
--- a/net/ipv6/route.c
+++ b/net/ipv6/route.c
@@ -1077,7 +1077,7 @@ struct dst_entry *icmp6_dst_alloc(struct net_device *dev,
1077 struct net *net = dev_net(dev); 1077 struct net *net = dev_net(dev);
1078 1078
1079 if (unlikely(!idev)) 1079 if (unlikely(!idev))
1080 return NULL; 1080 return ERR_PTR(-ENODEV);
1081 1081
1082 rt = ip6_dst_alloc(&net->ipv6.ip6_dst_ops, dev, 0); 1082 rt = ip6_dst_alloc(&net->ipv6.ip6_dst_ops, dev, 0);
1083 if (unlikely(!rt)) { 1083 if (unlikely(!rt)) {
diff --git a/net/mac80211/mesh_pathtbl.c b/net/mac80211/mesh_pathtbl.c
index edf167e3b8f3..30420bc1f699 100644
--- a/net/mac80211/mesh_pathtbl.c
+++ b/net/mac80211/mesh_pathtbl.c
@@ -413,12 +413,6 @@ struct mesh_path *mesh_path_lookup_by_idx(int idx, struct ieee80211_sub_if_data
413 return NULL; 413 return NULL;
414} 414}
415 415
416static void mesh_gate_node_reclaim(struct rcu_head *rp)
417{
418 struct mpath_node *node = container_of(rp, struct mpath_node, rcu);
419 kfree(node);
420}
421
422/** 416/**
423 * mesh_path_add_gate - add the given mpath to a mesh gate to our path table 417 * mesh_path_add_gate - add the given mpath to a mesh gate to our path table
424 * @mpath: gate path to add to table 418 * @mpath: gate path to add to table
@@ -479,7 +473,7 @@ static int mesh_gate_del(struct mesh_table *tbl, struct mesh_path *mpath)
479 if (gate->mpath == mpath) { 473 if (gate->mpath == mpath) {
480 spin_lock_bh(&tbl->gates_lock); 474 spin_lock_bh(&tbl->gates_lock);
481 hlist_del_rcu(&gate->list); 475 hlist_del_rcu(&gate->list);
482 call_rcu(&gate->rcu, mesh_gate_node_reclaim); 476 kfree_rcu(gate, rcu);
483 spin_unlock_bh(&tbl->gates_lock); 477 spin_unlock_bh(&tbl->gates_lock);
484 mpath->sdata->u.mesh.num_gates--; 478 mpath->sdata->u.mesh.num_gates--;
485 mpath->is_gate = false; 479 mpath->is_gate = false;
diff --git a/net/netfilter/core.c b/net/netfilter/core.c
index b4e8ff05b301..e1b7e051332e 100644
--- a/net/netfilter/core.c
+++ b/net/netfilter/core.c
@@ -56,7 +56,7 @@ struct list_head nf_hooks[NFPROTO_NUMPROTO][NF_MAX_HOOKS] __read_mostly;
56EXPORT_SYMBOL(nf_hooks); 56EXPORT_SYMBOL(nf_hooks);
57 57
58#if defined(CONFIG_JUMP_LABEL) 58#if defined(CONFIG_JUMP_LABEL)
59struct jump_label_key nf_hooks_needed[NFPROTO_NUMPROTO][NF_MAX_HOOKS]; 59struct static_key nf_hooks_needed[NFPROTO_NUMPROTO][NF_MAX_HOOKS];
60EXPORT_SYMBOL(nf_hooks_needed); 60EXPORT_SYMBOL(nf_hooks_needed);
61#endif 61#endif
62 62
@@ -77,7 +77,7 @@ int nf_register_hook(struct nf_hook_ops *reg)
77 list_add_rcu(&reg->list, elem->list.prev); 77 list_add_rcu(&reg->list, elem->list.prev);
78 mutex_unlock(&nf_hook_mutex); 78 mutex_unlock(&nf_hook_mutex);
79#if defined(CONFIG_JUMP_LABEL) 79#if defined(CONFIG_JUMP_LABEL)
80 jump_label_inc(&nf_hooks_needed[reg->pf][reg->hooknum]); 80 static_key_slow_inc(&nf_hooks_needed[reg->pf][reg->hooknum]);
81#endif 81#endif
82 return 0; 82 return 0;
83} 83}
@@ -89,7 +89,7 @@ void nf_unregister_hook(struct nf_hook_ops *reg)
89 list_del_rcu(&reg->list); 89 list_del_rcu(&reg->list);
90 mutex_unlock(&nf_hook_mutex); 90 mutex_unlock(&nf_hook_mutex);
91#if defined(CONFIG_JUMP_LABEL) 91#if defined(CONFIG_JUMP_LABEL)
92 jump_label_dec(&nf_hooks_needed[reg->pf][reg->hooknum]); 92 static_key_slow_dec(&nf_hooks_needed[reg->pf][reg->hooknum]);
93#endif 93#endif
94 synchronize_net(); 94 synchronize_net();
95} 95}
diff --git a/net/netfilter/nf_conntrack_netlink.c b/net/netfilter/nf_conntrack_netlink.c
index 10687692831e..b49da6c925b3 100644
--- a/net/netfilter/nf_conntrack_netlink.c
+++ b/net/netfilter/nf_conntrack_netlink.c
@@ -943,20 +943,21 @@ ctnetlink_del_conntrack(struct sock *ctnl, struct sk_buff *skb,
943 } 943 }
944 } 944 }
945 945
946 if (nf_conntrack_event_report(IPCT_DESTROY, ct, 946 if (del_timer(&ct->timeout)) {
947 NETLINK_CB(skb).pid, 947 if (nf_conntrack_event_report(IPCT_DESTROY, ct,
948 nlmsg_report(nlh)) < 0) { 948 NETLINK_CB(skb).pid,
949 nlmsg_report(nlh)) < 0) {
950 nf_ct_delete_from_lists(ct);
951 /* we failed to report the event, try later */
952 nf_ct_insert_dying_list(ct);
953 nf_ct_put(ct);
954 return 0;
955 }
956 /* death_by_timeout would report the event again */
957 set_bit(IPS_DYING_BIT, &ct->status);
949 nf_ct_delete_from_lists(ct); 958 nf_ct_delete_from_lists(ct);
950 /* we failed to report the event, try later */
951 nf_ct_insert_dying_list(ct);
952 nf_ct_put(ct); 959 nf_ct_put(ct);
953 return 0;
954 } 960 }
955
956 /* death_by_timeout would report the event again */
957 set_bit(IPS_DYING_BIT, &ct->status);
958
959 nf_ct_kill(ct);
960 nf_ct_put(ct); 961 nf_ct_put(ct);
961 962
962 return 0; 963 return 0;
diff --git a/net/sched/sch_sfq.c b/net/sched/sch_sfq.c
index 60d47180f043..02a21abea65e 100644
--- a/net/sched/sch_sfq.c
+++ b/net/sched/sch_sfq.c
@@ -469,11 +469,15 @@ enqueue:
469 if (slot->qlen == 1) { /* The flow is new */ 469 if (slot->qlen == 1) { /* The flow is new */
470 if (q->tail == NULL) { /* It is the first flow */ 470 if (q->tail == NULL) { /* It is the first flow */
471 slot->next = x; 471 slot->next = x;
472 q->tail = slot;
473 } else { 472 } else {
474 slot->next = q->tail->next; 473 slot->next = q->tail->next;
475 q->tail->next = x; 474 q->tail->next = x;
476 } 475 }
476 /* We put this flow at the end of our flow list.
477 * This might sound unfair for a new flow to wait after old ones,
478 * but we could endup servicing new flows only, and freeze old ones.
479 */
480 q->tail = slot;
477 /* We could use a bigger initial quantum for new flows */ 481 /* We could use a bigger initial quantum for new flows */
478 slot->allot = q->scaled_quantum; 482 slot->allot = q->scaled_quantum;
479 } 483 }
diff --git a/tools/perf/Documentation/Makefile b/tools/perf/Documentation/Makefile
index 4626a398836a..ca600e09c8d4 100644
--- a/tools/perf/Documentation/Makefile
+++ b/tools/perf/Documentation/Makefile
@@ -1,3 +1,10 @@
1OUTPUT := ./
2ifeq ("$(origin O)", "command line")
3 ifneq ($(O),)
4 OUTPUT := $(O)/
5 endif
6endif
7
1MAN1_TXT= \ 8MAN1_TXT= \
2 $(filter-out $(addsuffix .txt, $(ARTICLES) $(SP_ARTICLES)), \ 9 $(filter-out $(addsuffix .txt, $(ARTICLES) $(SP_ARTICLES)), \
3 $(wildcard perf-*.txt)) \ 10 $(wildcard perf-*.txt)) \
@@ -6,10 +13,11 @@ MAN5_TXT=
6MAN7_TXT= 13MAN7_TXT=
7 14
8MAN_TXT = $(MAN1_TXT) $(MAN5_TXT) $(MAN7_TXT) 15MAN_TXT = $(MAN1_TXT) $(MAN5_TXT) $(MAN7_TXT)
9MAN_XML=$(patsubst %.txt,%.xml,$(MAN_TXT)) 16_MAN_XML=$(patsubst %.txt,%.xml,$(MAN_TXT))
10MAN_HTML=$(patsubst %.txt,%.html,$(MAN_TXT)) 17_MAN_HTML=$(patsubst %.txt,%.html,$(MAN_TXT))
11 18
12DOC_HTML=$(MAN_HTML) 19MAN_XML=$(addprefix $(OUTPUT),$(_MAN_XML))
20MAN_HTML=$(addprefix $(OUTPUT),$(_MAN_HTML))
13 21
14ARTICLES = 22ARTICLES =
15# with their own formatting rules. 23# with their own formatting rules.
@@ -18,11 +26,17 @@ API_DOCS = $(patsubst %.txt,%,$(filter-out technical/api-index-skel.txt technica
18SP_ARTICLES += $(API_DOCS) 26SP_ARTICLES += $(API_DOCS)
19SP_ARTICLES += technical/api-index 27SP_ARTICLES += technical/api-index
20 28
21DOC_HTML += $(patsubst %,%.html,$(ARTICLES) $(SP_ARTICLES)) 29_DOC_HTML = $(_MAN_HTML)
30_DOC_HTML+=$(patsubst %,%.html,$(ARTICLES) $(SP_ARTICLES))
31DOC_HTML=$(addprefix $(OUTPUT),$(_DOC_HTML))
22 32
23DOC_MAN1=$(patsubst %.txt,%.1,$(MAN1_TXT)) 33_DOC_MAN1=$(patsubst %.txt,%.1,$(MAN1_TXT))
24DOC_MAN5=$(patsubst %.txt,%.5,$(MAN5_TXT)) 34_DOC_MAN5=$(patsubst %.txt,%.5,$(MAN5_TXT))
25DOC_MAN7=$(patsubst %.txt,%.7,$(MAN7_TXT)) 35_DOC_MAN7=$(patsubst %.txt,%.7,$(MAN7_TXT))
36
37DOC_MAN1=$(addprefix $(OUTPUT),$(_DOC_MAN1))
38DOC_MAN5=$(addprefix $(OUTPUT),$(_DOC_MAN5))
39DOC_MAN7=$(addprefix $(OUTPUT),$(_DOC_MAN7))
26 40
27# Make the path relative to DESTDIR, not prefix 41# Make the path relative to DESTDIR, not prefix
28ifndef DESTDIR 42ifndef DESTDIR
@@ -150,9 +164,9 @@ man1: $(DOC_MAN1)
150man5: $(DOC_MAN5) 164man5: $(DOC_MAN5)
151man7: $(DOC_MAN7) 165man7: $(DOC_MAN7)
152 166
153info: perf.info perfman.info 167info: $(OUTPUT)perf.info $(OUTPUT)perfman.info
154 168
155pdf: user-manual.pdf 169pdf: $(OUTPUT)user-manual.pdf
156 170
157install: install-man 171install: install-man
158 172
@@ -166,7 +180,7 @@ install-man: man
166 180
167install-info: info 181install-info: info
168 $(INSTALL) -d -m 755 $(DESTDIR)$(infodir) 182 $(INSTALL) -d -m 755 $(DESTDIR)$(infodir)
169 $(INSTALL) -m 644 perf.info perfman.info $(DESTDIR)$(infodir) 183 $(INSTALL) -m 644 $(OUTPUT)perf.info $(OUTPUT)perfman.info $(DESTDIR)$(infodir)
170 if test -r $(DESTDIR)$(infodir)/dir; then \ 184 if test -r $(DESTDIR)$(infodir)/dir; then \
171 $(INSTALL_INFO) --info-dir=$(DESTDIR)$(infodir) perf.info ;\ 185 $(INSTALL_INFO) --info-dir=$(DESTDIR)$(infodir) perf.info ;\
172 $(INSTALL_INFO) --info-dir=$(DESTDIR)$(infodir) perfman.info ;\ 186 $(INSTALL_INFO) --info-dir=$(DESTDIR)$(infodir) perfman.info ;\
@@ -176,7 +190,7 @@ install-info: info
176 190
177install-pdf: pdf 191install-pdf: pdf
178 $(INSTALL) -d -m 755 $(DESTDIR)$(pdfdir) 192 $(INSTALL) -d -m 755 $(DESTDIR)$(pdfdir)
179 $(INSTALL) -m 644 user-manual.pdf $(DESTDIR)$(pdfdir) 193 $(INSTALL) -m 644 $(OUTPUT)user-manual.pdf $(DESTDIR)$(pdfdir)
180 194
181#install-html: html 195#install-html: html
182# '$(SHELL_PATH_SQ)' ./install-webdoc.sh $(DESTDIR)$(htmldir) 196# '$(SHELL_PATH_SQ)' ./install-webdoc.sh $(DESTDIR)$(htmldir)
@@ -189,14 +203,14 @@ install-pdf: pdf
189# 203#
190# Determine "include::" file references in asciidoc files. 204# Determine "include::" file references in asciidoc files.
191# 205#
192doc.dep : $(wildcard *.txt) build-docdep.perl 206$(OUTPUT)doc.dep : $(wildcard *.txt) build-docdep.perl
193 $(QUIET_GEN)$(RM) $@+ $@ && \ 207 $(QUIET_GEN)$(RM) $@+ $@ && \
194 $(PERL_PATH) ./build-docdep.perl >$@+ $(QUIET_STDERR) && \ 208 $(PERL_PATH) ./build-docdep.perl >$@+ $(QUIET_STDERR) && \
195 mv $@+ $@ 209 mv $@+ $@
196 210
197-include doc.dep 211-include $(OUPTUT)doc.dep
198 212
199cmds_txt = cmds-ancillaryinterrogators.txt \ 213_cmds_txt = cmds-ancillaryinterrogators.txt \
200 cmds-ancillarymanipulators.txt \ 214 cmds-ancillarymanipulators.txt \
201 cmds-mainporcelain.txt \ 215 cmds-mainporcelain.txt \
202 cmds-plumbinginterrogators.txt \ 216 cmds-plumbinginterrogators.txt \
@@ -205,32 +219,36 @@ cmds_txt = cmds-ancillaryinterrogators.txt \
205 cmds-synchelpers.txt \ 219 cmds-synchelpers.txt \
206 cmds-purehelpers.txt \ 220 cmds-purehelpers.txt \
207 cmds-foreignscminterface.txt 221 cmds-foreignscminterface.txt
222cmds_txt=$(addprefix $(OUTPUT),$(_cmds_txt))
208 223
209$(cmds_txt): cmd-list.made 224$(cmds_txt): $(OUTPUT)cmd-list.made
210 225
211cmd-list.made: cmd-list.perl ../command-list.txt $(MAN1_TXT) 226$(OUTPUT)cmd-list.made: cmd-list.perl ../command-list.txt $(MAN1_TXT)
212 $(QUIET_GEN)$(RM) $@ && \ 227 $(QUIET_GEN)$(RM) $@ && \
213 $(PERL_PATH) ./cmd-list.perl ../command-list.txt $(QUIET_STDERR) && \ 228 $(PERL_PATH) ./cmd-list.perl ../command-list.txt $(QUIET_STDERR) && \
214 date >$@ 229 date >$@
215 230
216clean: 231clean:
217 $(RM) *.xml *.xml+ *.html *.html+ *.1 *.5 *.7 232 $(RM) $(MAN_XML) $(addsuffix +,$(MAN_XML))
218 $(RM) *.texi *.texi+ *.texi++ perf.info perfman.info 233 $(RM) $(MAN_HTML) $(addsuffix +,$(MAN_HTML))
219 $(RM) howto-index.txt howto/*.html doc.dep 234 $(RM) $(DOC_HTML) $(DOC_MAN1) $(DOC_MAN5) $(DOC_MAN7)
220 $(RM) technical/api-*.html technical/api-index.txt 235 $(RM) $(OUTPUT)*.texi $(OUTPUT)*.texi+ $(OUTPUT)*.texi++
221 $(RM) $(cmds_txt) *.made 236 $(RM) $(OUTPUT)perf.info $(OUTPUT)perfman.info
222 237 $(RM) $(OUTPUT)howto-index.txt $(OUTPUT)howto/*.html $(OUTPUT)doc.dep
223$(MAN_HTML): %.html : %.txt 238 $(RM) $(OUTPUT)technical/api-*.html $(OUTPUT)technical/api-index.txt
239 $(RM) $(cmds_txt) $(OUTPUT)*.made
240
241$(MAN_HTML): $(OUTPUT)%.html : %.txt
224 $(QUIET_ASCIIDOC)$(RM) $@+ $@ && \ 242 $(QUIET_ASCIIDOC)$(RM) $@+ $@ && \
225 $(ASCIIDOC) -b xhtml11 -d manpage -f asciidoc.conf \ 243 $(ASCIIDOC) -b xhtml11 -d manpage -f asciidoc.conf \
226 $(ASCIIDOC_EXTRA) -aperf_version=$(PERF_VERSION) -o $@+ $< && \ 244 $(ASCIIDOC_EXTRA) -aperf_version=$(PERF_VERSION) -o $@+ $< && \
227 mv $@+ $@ 245 mv $@+ $@
228 246
229%.1 %.5 %.7 : %.xml 247$(OUTPUT)%.1 $(OUTPUT)%.5 $(OUTPUT)%.7 : $(OUTPUT)%.xml
230 $(QUIET_XMLTO)$(RM) $@ && \ 248 $(QUIET_XMLTO)$(RM) $@ && \
231 xmlto -m $(MANPAGE_XSL) $(XMLTO_EXTRA) man $< 249 xmlto -o $(OUTPUT) -m $(MANPAGE_XSL) $(XMLTO_EXTRA) man $<
232 250
233%.xml : %.txt 251$(OUTPUT)%.xml : %.txt
234 $(QUIET_ASCIIDOC)$(RM) $@+ $@ && \ 252 $(QUIET_ASCIIDOC)$(RM) $@+ $@ && \
235 $(ASCIIDOC) -b docbook -d manpage -f asciidoc.conf \ 253 $(ASCIIDOC) -b docbook -d manpage -f asciidoc.conf \
236 $(ASCIIDOC_EXTRA) -aperf_version=$(PERF_VERSION) -o $@+ $< && \ 254 $(ASCIIDOC_EXTRA) -aperf_version=$(PERF_VERSION) -o $@+ $< && \
@@ -239,25 +257,25 @@ $(MAN_HTML): %.html : %.txt
239XSLT = docbook.xsl 257XSLT = docbook.xsl
240XSLTOPTS = --xinclude --stringparam html.stylesheet docbook-xsl.css 258XSLTOPTS = --xinclude --stringparam html.stylesheet docbook-xsl.css
241 259
242user-manual.html: user-manual.xml 260$(OUTPUT)user-manual.html: $(OUTPUT)user-manual.xml
243 $(QUIET_XSLTPROC)xsltproc $(XSLTOPTS) -o $@ $(XSLT) $< 261 $(QUIET_XSLTPROC)xsltproc $(XSLTOPTS) -o $@ $(XSLT) $<
244 262
245perf.info: user-manual.texi 263$(OUTPUT)perf.info: $(OUTPUT)user-manual.texi
246 $(QUIET_MAKEINFO)$(MAKEINFO) --no-split -o $@ user-manual.texi 264 $(QUIET_MAKEINFO)$(MAKEINFO) --no-split -o $@ $(OUTPUT)user-manual.texi
247 265
248user-manual.texi: user-manual.xml 266$(OUTPUT)user-manual.texi: $(OUTPUT)user-manual.xml
249 $(QUIET_DB2TEXI)$(RM) $@+ $@ && \ 267 $(QUIET_DB2TEXI)$(RM) $@+ $@ && \
250 $(DOCBOOK2X_TEXI) user-manual.xml --encoding=UTF-8 --to-stdout >$@++ && \ 268 $(DOCBOOK2X_TEXI) $(OUTPUT)user-manual.xml --encoding=UTF-8 --to-stdout >$@++ && \
251 $(PERL_PATH) fix-texi.perl <$@++ >$@+ && \ 269 $(PERL_PATH) fix-texi.perl <$@++ >$@+ && \
252 rm $@++ && \ 270 rm $@++ && \
253 mv $@+ $@ 271 mv $@+ $@
254 272
255user-manual.pdf: user-manual.xml 273$(OUTPUT)user-manual.pdf: $(OUTPUT)user-manual.xml
256 $(QUIET_DBLATEX)$(RM) $@+ $@ && \ 274 $(QUIET_DBLATEX)$(RM) $@+ $@ && \
257 $(DBLATEX) -o $@+ -p /etc/asciidoc/dblatex/asciidoc-dblatex.xsl -s /etc/asciidoc/dblatex/asciidoc-dblatex.sty $< && \ 275 $(DBLATEX) -o $@+ -p /etc/asciidoc/dblatex/asciidoc-dblatex.xsl -s /etc/asciidoc/dblatex/asciidoc-dblatex.sty $< && \
258 mv $@+ $@ 276 mv $@+ $@
259 277
260perfman.texi: $(MAN_XML) cat-texi.perl 278$(OUTPUT)perfman.texi: $(MAN_XML) cat-texi.perl
261 $(QUIET_DB2TEXI)$(RM) $@+ $@ && \ 279 $(QUIET_DB2TEXI)$(RM) $@+ $@ && \
262 ($(foreach xml,$(MAN_XML),$(DOCBOOK2X_TEXI) --encoding=UTF-8 \ 280 ($(foreach xml,$(MAN_XML),$(DOCBOOK2X_TEXI) --encoding=UTF-8 \
263 --to-stdout $(xml) &&) true) > $@++ && \ 281 --to-stdout $(xml) &&) true) > $@++ && \
@@ -265,7 +283,7 @@ perfman.texi: $(MAN_XML) cat-texi.perl
265 rm $@++ && \ 283 rm $@++ && \
266 mv $@+ $@ 284 mv $@+ $@
267 285
268perfman.info: perfman.texi 286$(OUTPUT)perfman.info: $(OUTPUT)perfman.texi
269 $(QUIET_MAKEINFO)$(MAKEINFO) --no-split --no-validate $*.texi 287 $(QUIET_MAKEINFO)$(MAKEINFO) --no-split --no-validate $*.texi
270 288
271$(patsubst %.txt,%.texi,$(MAN_TXT)): %.texi : %.xml 289$(patsubst %.txt,%.texi,$(MAN_TXT)): %.texi : %.xml
diff --git a/tools/perf/Documentation/perf-lock.txt b/tools/perf/Documentation/perf-lock.txt
index d6b2a4f2108b..c7f5f55634ac 100644
--- a/tools/perf/Documentation/perf-lock.txt
+++ b/tools/perf/Documentation/perf-lock.txt
@@ -8,7 +8,7 @@ perf-lock - Analyze lock events
8SYNOPSIS 8SYNOPSIS
9-------- 9--------
10[verse] 10[verse]
11'perf lock' {record|report|trace} 11'perf lock' {record|report|script|info}
12 12
13DESCRIPTION 13DESCRIPTION
14----------- 14-----------
@@ -20,10 +20,13 @@ and statistics with this 'perf lock' command.
20 produces the file "perf.data" which contains tracing 20 produces the file "perf.data" which contains tracing
21 results of lock events. 21 results of lock events.
22 22
23 'perf lock trace' shows raw lock events.
24
25 'perf lock report' reports statistical data. 23 'perf lock report' reports statistical data.
26 24
25 'perf lock script' shows raw lock events.
26
27 'perf lock info' shows metadata like threads or addresses
28 of lock instances.
29
27COMMON OPTIONS 30COMMON OPTIONS
28-------------- 31--------------
29 32
@@ -47,6 +50,17 @@ REPORT OPTIONS
47 Sorting key. Possible values: acquired (default), contended, 50 Sorting key. Possible values: acquired (default), contended,
48 wait_total, wait_max, wait_min. 51 wait_total, wait_max, wait_min.
49 52
53INFO OPTIONS
54------------
55
56-t::
57--threads::
58 dump thread list in perf.data
59
60-m::
61--map::
62 dump map of lock instances (address:name table)
63
50SEE ALSO 64SEE ALSO
51-------- 65--------
52linkperf:perf[1] 66linkperf:perf[1]
diff --git a/tools/perf/Documentation/perf-record.txt b/tools/perf/Documentation/perf-record.txt
index 2937f7e14bb7..a1386b2fff00 100644
--- a/tools/perf/Documentation/perf-record.txt
+++ b/tools/perf/Documentation/perf-record.txt
@@ -52,11 +52,15 @@ OPTIONS
52 52
53-p:: 53-p::
54--pid=:: 54--pid=::
55 Record events on existing process ID. 55 Record events on existing process ID (comma separated list).
56 56
57-t:: 57-t::
58--tid=:: 58--tid=::
59 Record events on existing thread ID. 59 Record events on existing thread ID (comma separated list).
60
61-u::
62--uid=::
63 Record events in threads owned by uid. Name or number.
60 64
61-r:: 65-r::
62--realtime=:: 66--realtime=::
@@ -148,6 +152,36 @@ an empty cgroup (monitor all the time) using, e.g., -G foo,,bar. Cgroups must ha
148corresponding events, i.e., they always refer to events defined earlier on the command 152corresponding events, i.e., they always refer to events defined earlier on the command
149line. 153line.
150 154
155-b::
156--branch-any::
157Enable taken branch stack sampling. Any type of taken branch may be sampled.
158This is a shortcut for --branch-filter any. See --branch-filter for more infos.
159
160-j::
161--branch-filter::
162Enable taken branch stack sampling. Each sample captures a series of consecutive
163taken branches. The number of branches captured with each sample depends on the
164underlying hardware, the type of branches of interest, and the executed code.
165It is possible to select the types of branches captured by enabling filters. The
166following filters are defined:
167
168 - any: any type of branches
169 - any_call: any function call or system call
170 - any_ret: any function return or system call return
171 - any_ind: any indirect branch
172 - u: only when the branch target is at the user level
173 - k: only when the branch target is in the kernel
174 - hv: only when the target is at the hypervisor level
175
176+
177The option requires at least one branch type among any, any_call, any_ret, ind_call.
178The privilege levels may be ommitted, in which case, the privilege levels of the associated
179event are applied to the branch filter. Both kernel (k) and hypervisor (hv) privilege
180levels are subject to permissions. When sampling on multiple events, branch stack sampling
181is enabled for all the sampling events. The sampled branch type is the same for all events.
182The various filters must be specified as a comma separated list: --branch-filter any_ret,u,k
183Note that this feature may not be available on all processors.
184
151SEE ALSO 185SEE ALSO
152-------- 186--------
153linkperf:perf-stat[1], linkperf:perf-list[1] 187linkperf:perf-stat[1], linkperf:perf-list[1]
diff --git a/tools/perf/Documentation/perf-report.txt b/tools/perf/Documentation/perf-report.txt
index 9b430e98712e..2d89f02719b5 100644
--- a/tools/perf/Documentation/perf-report.txt
+++ b/tools/perf/Documentation/perf-report.txt
@@ -48,6 +48,9 @@ OPTIONS
48 Only consider these symbols. CSV that understands 48 Only consider these symbols. CSV that understands
49 file://filename entries. 49 file://filename entries.
50 50
51--symbol-filter=::
52 Only show symbols that match (partially) with this filter.
53
51-U:: 54-U::
52--hide-unresolved:: 55--hide-unresolved::
53 Only display entries resolved to a symbol. 56 Only display entries resolved to a symbol.
@@ -110,6 +113,8 @@ OPTIONS
110 requires a tty, if one is not present, as when piping to other 113 requires a tty, if one is not present, as when piping to other
111 commands, the stdio interface is used. 114 commands, the stdio interface is used.
112 115
116--gtk:: Use the GTK2 interface.
117
113-k:: 118-k::
114--vmlinux=<file>:: 119--vmlinux=<file>::
115 vmlinux pathname 120 vmlinux pathname
@@ -153,6 +158,16 @@ OPTIONS
153 information which may be very large and thus may clutter the display. 158 information which may be very large and thus may clutter the display.
154 It currently includes: cpu and numa topology of the host system. 159 It currently includes: cpu and numa topology of the host system.
155 160
161-b::
162--branch-stack::
163 Use the addresses of sampled taken branches instead of the instruction
164 address to build the histograms. To generate meaningful output, the
165 perf.data file must have been obtained using perf record -b or
166 perf record --branch-filter xxx where xxx is a branch filter option.
167 perf report is able to auto-detect whether a perf.data file contains
168 branch stacks and it will automatically switch to the branch view mode,
169 unless --no-branch-stack is used.
170
156SEE ALSO 171SEE ALSO
157-------- 172--------
158linkperf:perf-stat[1], linkperf:perf-annotate[1] 173linkperf:perf-stat[1], linkperf:perf-annotate[1]
diff --git a/tools/perf/Documentation/perf-script.txt b/tools/perf/Documentation/perf-script.txt
index 2f6cef43da25..e9cbfcddfa3f 100644
--- a/tools/perf/Documentation/perf-script.txt
+++ b/tools/perf/Documentation/perf-script.txt
@@ -115,7 +115,7 @@ OPTIONS
115-f:: 115-f::
116--fields:: 116--fields::
117 Comma separated list of fields to print. Options are: 117 Comma separated list of fields to print. Options are:
118 comm, tid, pid, time, cpu, event, trace, ip, sym, dso, addr. 118 comm, tid, pid, time, cpu, event, trace, ip, sym, dso, addr, symoff.
119 Field list can be prepended with the type, trace, sw or hw, 119 Field list can be prepended with the type, trace, sw or hw,
120 to indicate to which event type the field list applies. 120 to indicate to which event type the field list applies.
121 e.g., -f sw:comm,tid,time,ip,sym and -f trace:time,cpu,trace 121 e.g., -f sw:comm,tid,time,ip,sym and -f trace:time,cpu,trace
@@ -200,6 +200,9 @@ OPTIONS
200 It currently includes: cpu and numa topology of the host system. 200 It currently includes: cpu and numa topology of the host system.
201 It can only be used with the perf script report mode. 201 It can only be used with the perf script report mode.
202 202
203--show-kernel-path::
204 Try to resolve the path of [kernel.kallsyms]
205
203SEE ALSO 206SEE ALSO
204-------- 207--------
205linkperf:perf-record[1], linkperf:perf-script-perl[1], 208linkperf:perf-record[1], linkperf:perf-script-perl[1],
diff --git a/tools/perf/Documentation/perf-stat.txt b/tools/perf/Documentation/perf-stat.txt
index 8966b9ab2014..2fa173b51970 100644
--- a/tools/perf/Documentation/perf-stat.txt
+++ b/tools/perf/Documentation/perf-stat.txt
@@ -35,11 +35,11 @@ OPTIONS
35 child tasks do not inherit counters 35 child tasks do not inherit counters
36-p:: 36-p::
37--pid=<pid>:: 37--pid=<pid>::
38 stat events on existing process id 38 stat events on existing process id (comma separated list)
39 39
40-t:: 40-t::
41--tid=<tid>:: 41--tid=<tid>::
42 stat events on existing thread id 42 stat events on existing thread id (comma separated list)
43 43
44 44
45-a:: 45-a::
diff --git a/tools/perf/Documentation/perf-top.txt b/tools/perf/Documentation/perf-top.txt
index b1a5bbbfebef..4a5680cb242e 100644
--- a/tools/perf/Documentation/perf-top.txt
+++ b/tools/perf/Documentation/perf-top.txt
@@ -72,11 +72,15 @@ Default is to monitor all CPUS.
72 72
73-p <pid>:: 73-p <pid>::
74--pid=<pid>:: 74--pid=<pid>::
75 Profile events on existing Process ID. 75 Profile events on existing Process ID (comma separated list).
76 76
77-t <tid>:: 77-t <tid>::
78--tid=<tid>:: 78--tid=<tid>::
79 Profile events on existing thread ID. 79 Profile events on existing thread ID (comma separated list).
80
81-u::
82--uid=::
83 Record events in threads owned by uid. Name or number.
80 84
81-r <priority>:: 85-r <priority>::
82--realtime=<priority>:: 86--realtime=<priority>::
diff --git a/tools/perf/MANIFEST b/tools/perf/MANIFEST
index 1078c5fadd5b..5476bc0a1eac 100644
--- a/tools/perf/MANIFEST
+++ b/tools/perf/MANIFEST
@@ -9,6 +9,7 @@ lib/rbtree.c
9include/linux/swab.h 9include/linux/swab.h
10arch/*/include/asm/unistd*.h 10arch/*/include/asm/unistd*.h
11arch/*/lib/memcpy*.S 11arch/*/lib/memcpy*.S
12arch/*/lib/memset*.S
12include/linux/poison.h 13include/linux/poison.h
13include/linux/magic.h 14include/linux/magic.h
14include/linux/hw_breakpoint.h 15include/linux/hw_breakpoint.h
diff --git a/tools/perf/Makefile b/tools/perf/Makefile
index 8a4b9bccf8b2..b492e3a51268 100644
--- a/tools/perf/Makefile
+++ b/tools/perf/Makefile
@@ -15,6 +15,16 @@ endif
15 15
16# Define V to have a more verbose compile. 16# Define V to have a more verbose compile.
17# 17#
18# Define O to save output files in a separate directory.
19#
20# Define ARCH as name of target architecture if you want cross-builds.
21#
22# Define CROSS_COMPILE as prefix name of compiler if you want cross-builds.
23#
24# Define NO_LIBPERL to disable perl script extension.
25#
26# Define NO_LIBPYTHON to disable python script extension.
27#
18# Define PYTHON to point to the python binary if the default 28# Define PYTHON to point to the python binary if the default
19# `python' is not correct; for example: PYTHON=python2 29# `python' is not correct; for example: PYTHON=python2
20# 30#
@@ -32,6 +42,10 @@ endif
32# Define NO_DWARF if you do not want debug-info analysis feature at all. 42# Define NO_DWARF if you do not want debug-info analysis feature at all.
33# 43#
34# Define WERROR=0 to disable treating any warnings as errors. 44# Define WERROR=0 to disable treating any warnings as errors.
45#
46# Define NO_NEWT if you do not want TUI support.
47#
48# Define NO_DEMANGLE if you do not want C++ symbol demangling.
35 49
36$(OUTPUT)PERF-VERSION-FILE: .FORCE-PERF-VERSION-FILE 50$(OUTPUT)PERF-VERSION-FILE: .FORCE-PERF-VERSION-FILE
37 @$(SHELL_PATH) util/PERF-VERSION-GEN $(OUTPUT) 51 @$(SHELL_PATH) util/PERF-VERSION-GEN $(OUTPUT)
@@ -47,6 +61,8 @@ ARCH ?= $(shell echo $(uname_M) | sed -e s/i.86/i386/ -e s/sun4u/sparc64/ \
47 61
48CC = $(CROSS_COMPILE)gcc 62CC = $(CROSS_COMPILE)gcc
49AR = $(CROSS_COMPILE)ar 63AR = $(CROSS_COMPILE)ar
64FLEX = $(CROSS_COMPILE)flex
65BISON= $(CROSS_COMPILE)bison
50 66
51# Additional ARCH settings for x86 67# Additional ARCH settings for x86
52ifeq ($(ARCH),i386) 68ifeq ($(ARCH),i386)
@@ -61,7 +77,7 @@ ifeq ($(ARCH),x86_64)
61 ifeq (${IS_X86_64}, 1) 77 ifeq (${IS_X86_64}, 1)
62 RAW_ARCH := x86_64 78 RAW_ARCH := x86_64
63 ARCH_CFLAGS := -DARCH_X86_64 79 ARCH_CFLAGS := -DARCH_X86_64
64 ARCH_INCLUDE = ../../arch/x86/lib/memcpy_64.S 80 ARCH_INCLUDE = ../../arch/x86/lib/memcpy_64.S ../../arch/x86/lib/memset_64.S
65 endif 81 endif
66endif 82endif
67 83
@@ -183,7 +199,10 @@ SCRIPT_SH += perf-archive.sh
183grep-libs = $(filter -l%,$(1)) 199grep-libs = $(filter -l%,$(1))
184strip-libs = $(filter-out -l%,$(1)) 200strip-libs = $(filter-out -l%,$(1))
185 201
186$(OUTPUT)python/perf.so: $(PYRF_OBJS) 202PYTHON_EXT_SRCS := $(shell grep -v ^\# util/python-ext-sources)
203PYTHON_EXT_DEPS := util/python-ext-sources util/setup.py
204
205$(OUTPUT)python/perf.so: $(PYRF_OBJS) $(PYTHON_EXT_SRCS) $(PYTHON_EXT_DEPS)
187 $(QUIET_GEN)CFLAGS='$(BASIC_CFLAGS)' $(PYTHON_WORD) util/setup.py \ 206 $(QUIET_GEN)CFLAGS='$(BASIC_CFLAGS)' $(PYTHON_WORD) util/setup.py \
188 --quiet build_ext; \ 207 --quiet build_ext; \
189 mkdir -p $(OUTPUT)python && \ 208 mkdir -p $(OUTPUT)python && \
@@ -258,6 +277,8 @@ LIB_H += util/callchain.h
258LIB_H += util/build-id.h 277LIB_H += util/build-id.h
259LIB_H += util/debug.h 278LIB_H += util/debug.h
260LIB_H += util/debugfs.h 279LIB_H += util/debugfs.h
280LIB_H += util/sysfs.h
281LIB_H += util/pmu.h
261LIB_H += util/event.h 282LIB_H += util/event.h
262LIB_H += util/evsel.h 283LIB_H += util/evsel.h
263LIB_H += util/evlist.h 284LIB_H += util/evlist.h
@@ -304,6 +325,8 @@ LIB_OBJS += $(OUTPUT)util/build-id.o
304LIB_OBJS += $(OUTPUT)util/config.o 325LIB_OBJS += $(OUTPUT)util/config.o
305LIB_OBJS += $(OUTPUT)util/ctype.o 326LIB_OBJS += $(OUTPUT)util/ctype.o
306LIB_OBJS += $(OUTPUT)util/debugfs.o 327LIB_OBJS += $(OUTPUT)util/debugfs.o
328LIB_OBJS += $(OUTPUT)util/sysfs.o
329LIB_OBJS += $(OUTPUT)util/pmu.o
307LIB_OBJS += $(OUTPUT)util/environment.o 330LIB_OBJS += $(OUTPUT)util/environment.o
308LIB_OBJS += $(OUTPUT)util/event.o 331LIB_OBJS += $(OUTPUT)util/event.o
309LIB_OBJS += $(OUTPUT)util/evlist.o 332LIB_OBJS += $(OUTPUT)util/evlist.o
@@ -340,6 +363,10 @@ LIB_OBJS += $(OUTPUT)util/session.o
340LIB_OBJS += $(OUTPUT)util/thread.o 363LIB_OBJS += $(OUTPUT)util/thread.o
341LIB_OBJS += $(OUTPUT)util/thread_map.o 364LIB_OBJS += $(OUTPUT)util/thread_map.o
342LIB_OBJS += $(OUTPUT)util/trace-event-parse.o 365LIB_OBJS += $(OUTPUT)util/trace-event-parse.o
366LIB_OBJS += $(OUTPUT)util/parse-events-flex.o
367LIB_OBJS += $(OUTPUT)util/parse-events-bison.o
368LIB_OBJS += $(OUTPUT)util/pmu-flex.o
369LIB_OBJS += $(OUTPUT)util/pmu-bison.o
343LIB_OBJS += $(OUTPUT)util/trace-event-read.o 370LIB_OBJS += $(OUTPUT)util/trace-event-read.o
344LIB_OBJS += $(OUTPUT)util/trace-event-info.o 371LIB_OBJS += $(OUTPUT)util/trace-event-info.o
345LIB_OBJS += $(OUTPUT)util/trace-event-scripting.o 372LIB_OBJS += $(OUTPUT)util/trace-event-scripting.o
@@ -361,8 +388,10 @@ BUILTIN_OBJS += $(OUTPUT)bench/sched-messaging.o
361BUILTIN_OBJS += $(OUTPUT)bench/sched-pipe.o 388BUILTIN_OBJS += $(OUTPUT)bench/sched-pipe.o
362ifeq ($(RAW_ARCH),x86_64) 389ifeq ($(RAW_ARCH),x86_64)
363BUILTIN_OBJS += $(OUTPUT)bench/mem-memcpy-x86-64-asm.o 390BUILTIN_OBJS += $(OUTPUT)bench/mem-memcpy-x86-64-asm.o
391BUILTIN_OBJS += $(OUTPUT)bench/mem-memset-x86-64-asm.o
364endif 392endif
365BUILTIN_OBJS += $(OUTPUT)bench/mem-memcpy.o 393BUILTIN_OBJS += $(OUTPUT)bench/mem-memcpy.o
394BUILTIN_OBJS += $(OUTPUT)bench/mem-memset.o
366 395
367BUILTIN_OBJS += $(OUTPUT)builtin-diff.o 396BUILTIN_OBJS += $(OUTPUT)builtin-diff.o
368BUILTIN_OBJS += $(OUTPUT)builtin-evlist.o 397BUILTIN_OBJS += $(OUTPUT)builtin-evlist.o
@@ -480,6 +509,20 @@ else
480 endif 509 endif
481endif 510endif
482 511
512ifdef NO_GTK2
513 BASIC_CFLAGS += -DNO_GTK2
514else
515 FLAGS_GTK2=$(ALL_CFLAGS) $(ALL_LDFLAGS) $(EXTLIBS) $(shell pkg-config --libs --cflags gtk+-2.0)
516 ifneq ($(call try-cc,$(SOURCE_GTK2),$(FLAGS_GTK2)),y)
517 msg := $(warning GTK2 not found, disables GTK2 support. Please install gtk2-devel or libgtk2.0-dev);
518 BASIC_CFLAGS += -DNO_GTK2_SUPPORT
519 else
520 BASIC_CFLAGS += $(shell pkg-config --cflags gtk+-2.0)
521 EXTLIBS += $(shell pkg-config --libs gtk+-2.0)
522 LIB_OBJS += $(OUTPUT)util/gtk/browser.o
523 endif
524endif
525
483ifdef NO_LIBPERL 526ifdef NO_LIBPERL
484 BASIC_CFLAGS += -DNO_LIBPERL 527 BASIC_CFLAGS += -DNO_LIBPERL
485else 528else
@@ -626,6 +669,8 @@ ifndef V
626 QUIET_LINK = @echo ' ' LINK $@; 669 QUIET_LINK = @echo ' ' LINK $@;
627 QUIET_MKDIR = @echo ' ' MKDIR $@; 670 QUIET_MKDIR = @echo ' ' MKDIR $@;
628 QUIET_GEN = @echo ' ' GEN $@; 671 QUIET_GEN = @echo ' ' GEN $@;
672 QUIET_FLEX = @echo ' ' FLEX $@;
673 QUIET_BISON = @echo ' ' BISON $@;
629endif 674endif
630endif 675endif
631 676
@@ -706,12 +751,19 @@ $(OUTPUT)perf.o perf.spec \
706 $(SCRIPTS) \ 751 $(SCRIPTS) \
707 : $(OUTPUT)PERF-VERSION-FILE 752 : $(OUTPUT)PERF-VERSION-FILE
708 753
754.SUFFIXES:
755.SUFFIXES: .o .c .S .s
756
709$(OUTPUT)%.o: %.c $(OUTPUT)PERF-CFLAGS 757$(OUTPUT)%.o: %.c $(OUTPUT)PERF-CFLAGS
710 $(QUIET_CC)$(CC) -o $@ -c $(ALL_CFLAGS) $< 758 $(QUIET_CC)$(CC) -o $@ -c $(ALL_CFLAGS) $<
759$(OUTPUT)%.i: %.c $(OUTPUT)PERF-CFLAGS
760 $(QUIET_CC)$(CC) -o $@ -E $(ALL_CFLAGS) $<
711$(OUTPUT)%.s: %.c $(OUTPUT)PERF-CFLAGS 761$(OUTPUT)%.s: %.c $(OUTPUT)PERF-CFLAGS
712 $(QUIET_CC)$(CC) -S $(ALL_CFLAGS) $< 762 $(QUIET_CC)$(CC) -o $@ -S $(ALL_CFLAGS) $<
713$(OUTPUT)%.o: %.S 763$(OUTPUT)%.o: %.S
714 $(QUIET_CC)$(CC) -o $@ -c $(ALL_CFLAGS) $< 764 $(QUIET_CC)$(CC) -o $@ -c $(ALL_CFLAGS) $<
765$(OUTPUT)%.s: %.S
766 $(QUIET_CC)$(CC) -o $@ -E $(ALL_CFLAGS) $<
715 767
716$(OUTPUT)util/exec_cmd.o: util/exec_cmd.c $(OUTPUT)PERF-CFLAGS 768$(OUTPUT)util/exec_cmd.o: util/exec_cmd.c $(OUTPUT)PERF-CFLAGS
717 $(QUIET_CC)$(CC) -o $@ -c $(ALL_CFLAGS) \ 769 $(QUIET_CC)$(CC) -o $@ -c $(ALL_CFLAGS) \
@@ -738,6 +790,12 @@ $(OUTPUT)util/ui/browsers/map.o: util/ui/browsers/map.c $(OUTPUT)PERF-CFLAGS
738$(OUTPUT)util/rbtree.o: ../../lib/rbtree.c $(OUTPUT)PERF-CFLAGS 790$(OUTPUT)util/rbtree.o: ../../lib/rbtree.c $(OUTPUT)PERF-CFLAGS
739 $(QUIET_CC)$(CC) -o $@ -c $(ALL_CFLAGS) -DETC_PERFCONFIG='"$(ETC_PERFCONFIG_SQ)"' $< 791 $(QUIET_CC)$(CC) -o $@ -c $(ALL_CFLAGS) -DETC_PERFCONFIG='"$(ETC_PERFCONFIG_SQ)"' $<
740 792
793$(OUTPUT)util/parse-events-flex.o: util/parse-events-flex.c $(OUTPUT)PERF-CFLAGS
794 $(QUIET_CC)$(CC) -o $@ -c $(ALL_CFLAGS) -Wno-redundant-decls -Wno-switch-default -Wno-unused-function $<
795
796$(OUTPUT)util/pmu-flex.o: util/pmu-flex.c $(OUTPUT)PERF-CFLAGS
797 $(QUIET_CC)$(CC) -o $@ -c $(ALL_CFLAGS) -Wno-redundant-decls -Wno-switch-default -Wno-unused-function $<
798
741$(OUTPUT)util/scripting-engines/trace-event-perl.o: util/scripting-engines/trace-event-perl.c $(OUTPUT)PERF-CFLAGS 799$(OUTPUT)util/scripting-engines/trace-event-perl.o: util/scripting-engines/trace-event-perl.c $(OUTPUT)PERF-CFLAGS
742 $(QUIET_CC)$(CC) -o $@ -c $(ALL_CFLAGS) $(PERL_EMBED_CCOPTS) -Wno-redundant-decls -Wno-strict-prototypes -Wno-unused-parameter -Wno-shadow $< 800 $(QUIET_CC)$(CC) -o $@ -c $(ALL_CFLAGS) $(PERL_EMBED_CCOPTS) -Wno-redundant-decls -Wno-strict-prototypes -Wno-unused-parameter -Wno-shadow $<
743 801
@@ -774,6 +832,8 @@ help:
774 @echo ' html - make html documentation' 832 @echo ' html - make html documentation'
775 @echo ' info - make GNU info documentation (access with info <foo>)' 833 @echo ' info - make GNU info documentation (access with info <foo>)'
776 @echo ' pdf - make pdf documentation' 834 @echo ' pdf - make pdf documentation'
835 @echo ' event-parser - make event parser code'
836 @echo ' pmu-parser - make pmu format parser code'
777 @echo ' TAGS - use etags to make tag information for source browsing' 837 @echo ' TAGS - use etags to make tag information for source browsing'
778 @echo ' tags - use ctags to make tag information for source browsing' 838 @echo ' tags - use ctags to make tag information for source browsing'
779 @echo ' cscope - use cscope to make interactive browsing database' 839 @echo ' cscope - use cscope to make interactive browsing database'
@@ -794,7 +854,6 @@ help:
794 @echo ' quick-install-html - install the html documentation quickly' 854 @echo ' quick-install-html - install the html documentation quickly'
795 @echo '' 855 @echo ''
796 @echo 'Perf maintainer targets:' 856 @echo 'Perf maintainer targets:'
797 @echo ' distclean - alias to clean'
798 @echo ' clean - clean all binary objects and build output' 857 @echo ' clean - clean all binary objects and build output'
799 858
800doc: 859doc:
@@ -824,6 +883,14 @@ cscope:
824 $(RM) cscope* 883 $(RM) cscope*
825 $(FIND) . -name '*.[hcS]' -print | xargs cscope -b 884 $(FIND) . -name '*.[hcS]' -print | xargs cscope -b
826 885
886event-parser:
887 $(QUIET_BISON)$(BISON) -v util/parse-events.y -d -o util/parse-events-bison.c
888 $(QUIET_FLEX)$(FLEX) --header-file=util/parse-events-flex.h -t util/parse-events.l > util/parse-events-flex.c
889
890pmu-parser:
891 $(QUIET_BISON)$(BISON) -v util/pmu.y -d -o util/pmu-bison.c
892 $(QUIET_FLEX)$(FLEX) --header-file=util/pmu-flex.h -t util/pmu.l > util/pmu-flex.c
893
827### Detect prefix changes 894### Detect prefix changes
828TRACK_CFLAGS = $(subst ','\'',$(ALL_CFLAGS)):\ 895TRACK_CFLAGS = $(subst ','\'',$(ALL_CFLAGS)):\
829 $(bindir_SQ):$(perfexecdir_SQ):$(template_dir_SQ):$(prefix_SQ) 896 $(bindir_SQ):$(perfexecdir_SQ):$(template_dir_SQ):$(prefix_SQ)
diff --git a/tools/perf/bench/bench.h b/tools/perf/bench/bench.h
index f7781c6267c0..a09bece6dad2 100644
--- a/tools/perf/bench/bench.h
+++ b/tools/perf/bench/bench.h
@@ -4,6 +4,7 @@
4extern int bench_sched_messaging(int argc, const char **argv, const char *prefix); 4extern int bench_sched_messaging(int argc, const char **argv, const char *prefix);
5extern int bench_sched_pipe(int argc, const char **argv, const char *prefix); 5extern int bench_sched_pipe(int argc, const char **argv, const char *prefix);
6extern int bench_mem_memcpy(int argc, const char **argv, const char *prefix __used); 6extern int bench_mem_memcpy(int argc, const char **argv, const char *prefix __used);
7extern int bench_mem_memset(int argc, const char **argv, const char *prefix);
7 8
8#define BENCH_FORMAT_DEFAULT_STR "default" 9#define BENCH_FORMAT_DEFAULT_STR "default"
9#define BENCH_FORMAT_DEFAULT 0 10#define BENCH_FORMAT_DEFAULT 0
diff --git a/tools/perf/bench/mem-memcpy-x86-64-asm-def.h b/tools/perf/bench/mem-memcpy-x86-64-asm-def.h
index d588b87696fc..d66ab799b35f 100644
--- a/tools/perf/bench/mem-memcpy-x86-64-asm-def.h
+++ b/tools/perf/bench/mem-memcpy-x86-64-asm-def.h
@@ -2,3 +2,11 @@
2MEMCPY_FN(__memcpy, 2MEMCPY_FN(__memcpy,
3 "x86-64-unrolled", 3 "x86-64-unrolled",
4 "unrolled memcpy() in arch/x86/lib/memcpy_64.S") 4 "unrolled memcpy() in arch/x86/lib/memcpy_64.S")
5
6MEMCPY_FN(memcpy_c,
7 "x86-64-movsq",
8 "movsq-based memcpy() in arch/x86/lib/memcpy_64.S")
9
10MEMCPY_FN(memcpy_c_e,
11 "x86-64-movsb",
12 "movsb-based memcpy() in arch/x86/lib/memcpy_64.S")
diff --git a/tools/perf/bench/mem-memcpy-x86-64-asm.S b/tools/perf/bench/mem-memcpy-x86-64-asm.S
index 185a96d66dd1..fcd9cf00600a 100644
--- a/tools/perf/bench/mem-memcpy-x86-64-asm.S
+++ b/tools/perf/bench/mem-memcpy-x86-64-asm.S
@@ -1,4 +1,8 @@
1 1#define memcpy MEMCPY /* don't hide glibc's memcpy() */
2#define altinstr_replacement text
3#define globl p2align 4; .globl
4#define Lmemcpy_c globl memcpy_c; memcpy_c
5#define Lmemcpy_c_e globl memcpy_c_e; memcpy_c_e
2#include "../../../arch/x86/lib/memcpy_64.S" 6#include "../../../arch/x86/lib/memcpy_64.S"
3/* 7/*
4 * We need to provide note.GNU-stack section, saying that we want 8 * We need to provide note.GNU-stack section, saying that we want
diff --git a/tools/perf/bench/mem-memcpy.c b/tools/perf/bench/mem-memcpy.c
index db82021f4b91..71557225bf92 100644
--- a/tools/perf/bench/mem-memcpy.c
+++ b/tools/perf/bench/mem-memcpy.c
@@ -5,7 +5,6 @@
5 * 5 *
6 * Written by Hitoshi Mitake <mitake@dcl.info.waseda.ac.jp> 6 * Written by Hitoshi Mitake <mitake@dcl.info.waseda.ac.jp>
7 */ 7 */
8#include <ctype.h>
9 8
10#include "../perf.h" 9#include "../perf.h"
11#include "../util/util.h" 10#include "../util/util.h"
@@ -24,6 +23,7 @@
24 23
25static const char *length_str = "1MB"; 24static const char *length_str = "1MB";
26static const char *routine = "default"; 25static const char *routine = "default";
26static int iterations = 1;
27static bool use_clock; 27static bool use_clock;
28static int clock_fd; 28static int clock_fd;
29static bool only_prefault; 29static bool only_prefault;
@@ -35,6 +35,8 @@ static const struct option options[] = {
35 "available unit: B, MB, GB (upper and lower)"), 35 "available unit: B, MB, GB (upper and lower)"),
36 OPT_STRING('r', "routine", &routine, "default", 36 OPT_STRING('r', "routine", &routine, "default",
37 "Specify routine to copy"), 37 "Specify routine to copy"),
38 OPT_INTEGER('i', "iterations", &iterations,
39 "repeat memcpy() invocation this number of times"),
38 OPT_BOOLEAN('c', "clock", &use_clock, 40 OPT_BOOLEAN('c', "clock", &use_clock,
39 "Use CPU clock for measuring"), 41 "Use CPU clock for measuring"),
40 OPT_BOOLEAN('o', "only-prefault", &only_prefault, 42 OPT_BOOLEAN('o', "only-prefault", &only_prefault,
@@ -121,6 +123,7 @@ static u64 do_memcpy_clock(memcpy_t fn, size_t len, bool prefault)
121{ 123{
122 u64 clock_start = 0ULL, clock_end = 0ULL; 124 u64 clock_start = 0ULL, clock_end = 0ULL;
123 void *src = NULL, *dst = NULL; 125 void *src = NULL, *dst = NULL;
126 int i;
124 127
125 alloc_mem(&src, &dst, len); 128 alloc_mem(&src, &dst, len);
126 129
@@ -128,7 +131,8 @@ static u64 do_memcpy_clock(memcpy_t fn, size_t len, bool prefault)
128 fn(dst, src, len); 131 fn(dst, src, len);
129 132
130 clock_start = get_clock(); 133 clock_start = get_clock();
131 fn(dst, src, len); 134 for (i = 0; i < iterations; ++i)
135 fn(dst, src, len);
132 clock_end = get_clock(); 136 clock_end = get_clock();
133 137
134 free(src); 138 free(src);
@@ -140,6 +144,7 @@ static double do_memcpy_gettimeofday(memcpy_t fn, size_t len, bool prefault)
140{ 144{
141 struct timeval tv_start, tv_end, tv_diff; 145 struct timeval tv_start, tv_end, tv_diff;
142 void *src = NULL, *dst = NULL; 146 void *src = NULL, *dst = NULL;
147 int i;
143 148
144 alloc_mem(&src, &dst, len); 149 alloc_mem(&src, &dst, len);
145 150
@@ -147,7 +152,8 @@ static double do_memcpy_gettimeofday(memcpy_t fn, size_t len, bool prefault)
147 fn(dst, src, len); 152 fn(dst, src, len);
148 153
149 BUG_ON(gettimeofday(&tv_start, NULL)); 154 BUG_ON(gettimeofday(&tv_start, NULL));
150 fn(dst, src, len); 155 for (i = 0; i < iterations; ++i)
156 fn(dst, src, len);
151 BUG_ON(gettimeofday(&tv_end, NULL)); 157 BUG_ON(gettimeofday(&tv_end, NULL));
152 158
153 timersub(&tv_end, &tv_start, &tv_diff); 159 timersub(&tv_end, &tv_start, &tv_diff);
diff --git a/tools/perf/bench/mem-memset-arch.h b/tools/perf/bench/mem-memset-arch.h
new file mode 100644
index 000000000000..a040fa77665b
--- /dev/null
+++ b/tools/perf/bench/mem-memset-arch.h
@@ -0,0 +1,12 @@
1
2#ifdef ARCH_X86_64
3
4#define MEMSET_FN(fn, name, desc) \
5 extern void *fn(void *, int, size_t);
6
7#include "mem-memset-x86-64-asm-def.h"
8
9#undef MEMSET_FN
10
11#endif
12
diff --git a/tools/perf/bench/mem-memset-x86-64-asm-def.h b/tools/perf/bench/mem-memset-x86-64-asm-def.h
new file mode 100644
index 000000000000..a71dff97c1f5
--- /dev/null
+++ b/tools/perf/bench/mem-memset-x86-64-asm-def.h
@@ -0,0 +1,12 @@
1
2MEMSET_FN(__memset,
3 "x86-64-unrolled",
4 "unrolled memset() in arch/x86/lib/memset_64.S")
5
6MEMSET_FN(memset_c,
7 "x86-64-stosq",
8 "movsq-based memset() in arch/x86/lib/memset_64.S")
9
10MEMSET_FN(memset_c_e,
11 "x86-64-stosb",
12 "movsb-based memset() in arch/x86/lib/memset_64.S")
diff --git a/tools/perf/bench/mem-memset-x86-64-asm.S b/tools/perf/bench/mem-memset-x86-64-asm.S
new file mode 100644
index 000000000000..9e5af89ed13a
--- /dev/null
+++ b/tools/perf/bench/mem-memset-x86-64-asm.S
@@ -0,0 +1,13 @@
1#define memset MEMSET /* don't hide glibc's memset() */
2#define altinstr_replacement text
3#define globl p2align 4; .globl
4#define Lmemset_c globl memset_c; memset_c
5#define Lmemset_c_e globl memset_c_e; memset_c_e
6#include "../../../arch/x86/lib/memset_64.S"
7
8/*
9 * We need to provide note.GNU-stack section, saying that we want
10 * NOT executable stack. Otherwise the final linking will assume that
11 * the ELF stack should not be restricted at all and set it RWX.
12 */
13.section .note.GNU-stack,"",@progbits
diff --git a/tools/perf/bench/mem-memset.c b/tools/perf/bench/mem-memset.c
new file mode 100644
index 000000000000..e9079185bd72
--- /dev/null
+++ b/tools/perf/bench/mem-memset.c
@@ -0,0 +1,297 @@
1/*
2 * mem-memset.c
3 *
4 * memset: Simple memory set in various ways
5 *
6 * Trivial clone of mem-memcpy.c.
7 */
8
9#include "../perf.h"
10#include "../util/util.h"
11#include "../util/parse-options.h"
12#include "../util/header.h"
13#include "bench.h"
14#include "mem-memset-arch.h"
15
16#include <stdio.h>
17#include <stdlib.h>
18#include <string.h>
19#include <sys/time.h>
20#include <errno.h>
21
22#define K 1024
23
24static const char *length_str = "1MB";
25static const char *routine = "default";
26static int iterations = 1;
27static bool use_clock;
28static int clock_fd;
29static bool only_prefault;
30static bool no_prefault;
31
32static const struct option options[] = {
33 OPT_STRING('l', "length", &length_str, "1MB",
34 "Specify length of memory to copy. "
35 "available unit: B, MB, GB (upper and lower)"),
36 OPT_STRING('r', "routine", &routine, "default",
37 "Specify routine to copy"),
38 OPT_INTEGER('i', "iterations", &iterations,
39 "repeat memset() invocation this number of times"),
40 OPT_BOOLEAN('c', "clock", &use_clock,
41 "Use CPU clock for measuring"),
42 OPT_BOOLEAN('o', "only-prefault", &only_prefault,
43 "Show only the result with page faults before memset()"),
44 OPT_BOOLEAN('n', "no-prefault", &no_prefault,
45 "Show only the result without page faults before memset()"),
46 OPT_END()
47};
48
49typedef void *(*memset_t)(void *, int, size_t);
50
51struct routine {
52 const char *name;
53 const char *desc;
54 memset_t fn;
55};
56
57static const struct routine routines[] = {
58 { "default",
59 "Default memset() provided by glibc",
60 memset },
61#ifdef ARCH_X86_64
62
63#define MEMSET_FN(fn, name, desc) { name, desc, fn },
64#include "mem-memset-x86-64-asm-def.h"
65#undef MEMSET_FN
66
67#endif
68
69 { NULL,
70 NULL,
71 NULL }
72};
73
74static const char * const bench_mem_memset_usage[] = {
75 "perf bench mem memset <options>",
76 NULL
77};
78
79static struct perf_event_attr clock_attr = {
80 .type = PERF_TYPE_HARDWARE,
81 .config = PERF_COUNT_HW_CPU_CYCLES
82};
83
84static void init_clock(void)
85{
86 clock_fd = sys_perf_event_open(&clock_attr, getpid(), -1, -1, 0);
87
88 if (clock_fd < 0 && errno == ENOSYS)
89 die("No CONFIG_PERF_EVENTS=y kernel support configured?\n");
90 else
91 BUG_ON(clock_fd < 0);
92}
93
94static u64 get_clock(void)
95{
96 int ret;
97 u64 clk;
98
99 ret = read(clock_fd, &clk, sizeof(u64));
100 BUG_ON(ret != sizeof(u64));
101
102 return clk;
103}
104
105static double timeval2double(struct timeval *ts)
106{
107 return (double)ts->tv_sec +
108 (double)ts->tv_usec / (double)1000000;
109}
110
111static void alloc_mem(void **dst, size_t length)
112{
113 *dst = zalloc(length);
114 if (!dst)
115 die("memory allocation failed - maybe length is too large?\n");
116}
117
118static u64 do_memset_clock(memset_t fn, size_t len, bool prefault)
119{
120 u64 clock_start = 0ULL, clock_end = 0ULL;
121 void *dst = NULL;
122 int i;
123
124 alloc_mem(&dst, len);
125
126 if (prefault)
127 fn(dst, -1, len);
128
129 clock_start = get_clock();
130 for (i = 0; i < iterations; ++i)
131 fn(dst, i, len);
132 clock_end = get_clock();
133
134 free(dst);
135 return clock_end - clock_start;
136}
137
138static double do_memset_gettimeofday(memset_t fn, size_t len, bool prefault)
139{
140 struct timeval tv_start, tv_end, tv_diff;
141 void *dst = NULL;
142 int i;
143
144 alloc_mem(&dst, len);
145
146 if (prefault)
147 fn(dst, -1, len);
148
149 BUG_ON(gettimeofday(&tv_start, NULL));
150 for (i = 0; i < iterations; ++i)
151 fn(dst, i, len);
152 BUG_ON(gettimeofday(&tv_end, NULL));
153
154 timersub(&tv_end, &tv_start, &tv_diff);
155
156 free(dst);
157 return (double)((double)len / timeval2double(&tv_diff));
158}
159
160#define pf (no_prefault ? 0 : 1)
161
162#define print_bps(x) do { \
163 if (x < K) \
164 printf(" %14lf B/Sec", x); \
165 else if (x < K * K) \
166 printf(" %14lfd KB/Sec", x / K); \
167 else if (x < K * K * K) \
168 printf(" %14lf MB/Sec", x / K / K); \
169 else \
170 printf(" %14lf GB/Sec", x / K / K / K); \
171 } while (0)
172
173int bench_mem_memset(int argc, const char **argv,
174 const char *prefix __used)
175{
176 int i;
177 size_t len;
178 double result_bps[2];
179 u64 result_clock[2];
180
181 argc = parse_options(argc, argv, options,
182 bench_mem_memset_usage, 0);
183
184 if (use_clock)
185 init_clock();
186
187 len = (size_t)perf_atoll((char *)length_str);
188
189 result_clock[0] = result_clock[1] = 0ULL;
190 result_bps[0] = result_bps[1] = 0.0;
191
192 if ((s64)len <= 0) {
193 fprintf(stderr, "Invalid length:%s\n", length_str);
194 return 1;
195 }
196
197 /* same to without specifying either of prefault and no-prefault */
198 if (only_prefault && no_prefault)
199 only_prefault = no_prefault = false;
200
201 for (i = 0; routines[i].name; i++) {
202 if (!strcmp(routines[i].name, routine))
203 break;
204 }
205 if (!routines[i].name) {
206 printf("Unknown routine:%s\n", routine);
207 printf("Available routines...\n");
208 for (i = 0; routines[i].name; i++) {
209 printf("\t%s ... %s\n",
210 routines[i].name, routines[i].desc);
211 }
212 return 1;
213 }
214
215 if (bench_format == BENCH_FORMAT_DEFAULT)
216 printf("# Copying %s Bytes ...\n\n", length_str);
217
218 if (!only_prefault && !no_prefault) {
219 /* show both of results */
220 if (use_clock) {
221 result_clock[0] =
222 do_memset_clock(routines[i].fn, len, false);
223 result_clock[1] =
224 do_memset_clock(routines[i].fn, len, true);
225 } else {
226 result_bps[0] =
227 do_memset_gettimeofday(routines[i].fn,
228 len, false);
229 result_bps[1] =
230 do_memset_gettimeofday(routines[i].fn,
231 len, true);
232 }
233 } else {
234 if (use_clock) {
235 result_clock[pf] =
236 do_memset_clock(routines[i].fn,
237 len, only_prefault);
238 } else {
239 result_bps[pf] =
240 do_memset_gettimeofday(routines[i].fn,
241 len, only_prefault);
242 }
243 }
244
245 switch (bench_format) {
246 case BENCH_FORMAT_DEFAULT:
247 if (!only_prefault && !no_prefault) {
248 if (use_clock) {
249 printf(" %14lf Clock/Byte\n",
250 (double)result_clock[0]
251 / (double)len);
252 printf(" %14lf Clock/Byte (with prefault)\n ",
253 (double)result_clock[1]
254 / (double)len);
255 } else {
256 print_bps(result_bps[0]);
257 printf("\n");
258 print_bps(result_bps[1]);
259 printf(" (with prefault)\n");
260 }
261 } else {
262 if (use_clock) {
263 printf(" %14lf Clock/Byte",
264 (double)result_clock[pf]
265 / (double)len);
266 } else
267 print_bps(result_bps[pf]);
268
269 printf("%s\n", only_prefault ? " (with prefault)" : "");
270 }
271 break;
272 case BENCH_FORMAT_SIMPLE:
273 if (!only_prefault && !no_prefault) {
274 if (use_clock) {
275 printf("%lf %lf\n",
276 (double)result_clock[0] / (double)len,
277 (double)result_clock[1] / (double)len);
278 } else {
279 printf("%lf %lf\n",
280 result_bps[0], result_bps[1]);
281 }
282 } else {
283 if (use_clock) {
284 printf("%lf\n", (double)result_clock[pf]
285 / (double)len);
286 } else
287 printf("%lf\n", result_bps[pf]);
288 }
289 break;
290 default:
291 /* reaching this means there's some disaster: */
292 die("unknown format: %d\n", bench_format);
293 break;
294 }
295
296 return 0;
297}
diff --git a/tools/perf/builtin-bench.c b/tools/perf/builtin-bench.c
index fcb96269852a..b0e74ab2d7a2 100644
--- a/tools/perf/builtin-bench.c
+++ b/tools/perf/builtin-bench.c
@@ -52,6 +52,9 @@ static struct bench_suite mem_suites[] = {
52 { "memcpy", 52 { "memcpy",
53 "Simple memory copy in various ways", 53 "Simple memory copy in various ways",
54 bench_mem_memcpy }, 54 bench_mem_memcpy },
55 { "memset",
56 "Simple memory set in various ways",
57 bench_mem_memset },
55 suite_all, 58 suite_all,
56 { NULL, 59 { NULL,
57 NULL, 60 NULL,
diff --git a/tools/perf/builtin-diff.c b/tools/perf/builtin-diff.c
index 4f19513d7dda..d29d350fb2b7 100644
--- a/tools/perf/builtin-diff.c
+++ b/tools/perf/builtin-diff.c
@@ -24,6 +24,11 @@ static char diff__default_sort_order[] = "dso,symbol";
24static bool force; 24static bool force;
25static bool show_displacement; 25static bool show_displacement;
26 26
27struct perf_diff {
28 struct perf_tool tool;
29 struct perf_session *session;
30};
31
27static int hists__add_entry(struct hists *self, 32static int hists__add_entry(struct hists *self,
28 struct addr_location *al, u64 period) 33 struct addr_location *al, u64 period)
29{ 34{
@@ -32,12 +37,14 @@ static int hists__add_entry(struct hists *self,
32 return -ENOMEM; 37 return -ENOMEM;
33} 38}
34 39
35static int diff__process_sample_event(struct perf_tool *tool __used, 40static int diff__process_sample_event(struct perf_tool *tool,
36 union perf_event *event, 41 union perf_event *event,
37 struct perf_sample *sample, 42 struct perf_sample *sample,
38 struct perf_evsel *evsel __used, 43 struct perf_evsel *evsel __used,
39 struct machine *machine) 44 struct machine *machine)
40{ 45{
46 struct perf_diff *_diff = container_of(tool, struct perf_diff, tool);
47 struct perf_session *session = _diff->session;
41 struct addr_location al; 48 struct addr_location al;
42 49
43 if (perf_event__preprocess_sample(event, machine, &al, sample, NULL) < 0) { 50 if (perf_event__preprocess_sample(event, machine, &al, sample, NULL) < 0) {
@@ -49,24 +56,26 @@ static int diff__process_sample_event(struct perf_tool *tool __used,
49 if (al.filtered || al.sym == NULL) 56 if (al.filtered || al.sym == NULL)
50 return 0; 57 return 0;
51 58
52 if (hists__add_entry(&evsel->hists, &al, sample->period)) { 59 if (hists__add_entry(&session->hists, &al, sample->period)) {
53 pr_warning("problem incrementing symbol period, skipping event\n"); 60 pr_warning("problem incrementing symbol period, skipping event\n");
54 return -1; 61 return -1;
55 } 62 }
56 63
57 evsel->hists.stats.total_period += sample->period; 64 session->hists.stats.total_period += sample->period;
58 return 0; 65 return 0;
59} 66}
60 67
61static struct perf_tool perf_diff = { 68static struct perf_diff diff = {
62 .sample = diff__process_sample_event, 69 .tool = {
63 .mmap = perf_event__process_mmap, 70 .sample = diff__process_sample_event,
64 .comm = perf_event__process_comm, 71 .mmap = perf_event__process_mmap,
65 .exit = perf_event__process_task, 72 .comm = perf_event__process_comm,
66 .fork = perf_event__process_task, 73 .exit = perf_event__process_task,
67 .lost = perf_event__process_lost, 74 .fork = perf_event__process_task,
68 .ordered_samples = true, 75 .lost = perf_event__process_lost,
69 .ordering_requires_timestamps = true, 76 .ordered_samples = true,
77 .ordering_requires_timestamps = true,
78 },
70}; 79};
71 80
72static void perf_session__insert_hist_entry_by_name(struct rb_root *root, 81static void perf_session__insert_hist_entry_by_name(struct rb_root *root,
@@ -107,12 +116,6 @@ static void hists__resort_entries(struct hists *self)
107 self->entries = tmp; 116 self->entries = tmp;
108} 117}
109 118
110static void hists__set_positions(struct hists *self)
111{
112 hists__output_resort(self);
113 hists__resort_entries(self);
114}
115
116static struct hist_entry *hists__find_entry(struct hists *self, 119static struct hist_entry *hists__find_entry(struct hists *self,
117 struct hist_entry *he) 120 struct hist_entry *he)
118{ 121{
@@ -146,30 +149,37 @@ static void hists__match(struct hists *older, struct hists *newer)
146static int __cmd_diff(void) 149static int __cmd_diff(void)
147{ 150{
148 int ret, i; 151 int ret, i;
152#define older (session[0])
153#define newer (session[1])
149 struct perf_session *session[2]; 154 struct perf_session *session[2];
150 155
151 session[0] = perf_session__new(input_old, O_RDONLY, force, false, &perf_diff); 156 older = perf_session__new(input_old, O_RDONLY, force, false,
152 session[1] = perf_session__new(input_new, O_RDONLY, force, false, &perf_diff); 157 &diff.tool);
158 newer = perf_session__new(input_new, O_RDONLY, force, false,
159 &diff.tool);
153 if (session[0] == NULL || session[1] == NULL) 160 if (session[0] == NULL || session[1] == NULL)
154 return -ENOMEM; 161 return -ENOMEM;
155 162
156 for (i = 0; i < 2; ++i) { 163 for (i = 0; i < 2; ++i) {
157 ret = perf_session__process_events(session[i], &perf_diff); 164 diff.session = session[i];
165 ret = perf_session__process_events(session[i], &diff.tool);
158 if (ret) 166 if (ret)
159 goto out_delete; 167 goto out_delete;
168 hists__output_resort(&session[i]->hists);
160 } 169 }
161 170
162 hists__output_resort(&session[1]->hists);
163 if (show_displacement) 171 if (show_displacement)
164 hists__set_positions(&session[0]->hists); 172 hists__resort_entries(&older->hists);
165 173
166 hists__match(&session[0]->hists, &session[1]->hists); 174 hists__match(&older->hists, &newer->hists);
167 hists__fprintf(&session[1]->hists, &session[0]->hists, 175 hists__fprintf(&newer->hists, &older->hists,
168 show_displacement, true, 0, 0, stdout); 176 show_displacement, true, 0, 0, stdout);
169out_delete: 177out_delete:
170 for (i = 0; i < 2; ++i) 178 for (i = 0; i < 2; ++i)
171 perf_session__delete(session[i]); 179 perf_session__delete(session[i]);
172 return ret; 180 return ret;
181#undef older
182#undef newer
173} 183}
174 184
175static const char * const diff_usage[] = { 185static const char * const diff_usage[] = {
diff --git a/tools/perf/builtin-lock.c b/tools/perf/builtin-lock.c
index 2296c391d0f5..12c814838993 100644
--- a/tools/perf/builtin-lock.c
+++ b/tools/perf/builtin-lock.c
@@ -922,12 +922,12 @@ static const struct option info_options[] = {
922 OPT_BOOLEAN('t', "threads", &info_threads, 922 OPT_BOOLEAN('t', "threads", &info_threads,
923 "dump thread list in perf.data"), 923 "dump thread list in perf.data"),
924 OPT_BOOLEAN('m', "map", &info_map, 924 OPT_BOOLEAN('m', "map", &info_map,
925 "map of lock instances (name:address table)"), 925 "map of lock instances (address:name table)"),
926 OPT_END() 926 OPT_END()
927}; 927};
928 928
929static const char * const lock_usage[] = { 929static const char * const lock_usage[] = {
930 "perf lock [<options>] {record|trace|report}", 930 "perf lock [<options>] {record|report|script|info}",
931 NULL 931 NULL
932}; 932};
933 933
diff --git a/tools/perf/builtin-probe.c b/tools/perf/builtin-probe.c
index fb8566181f27..4935c09dd5b5 100644
--- a/tools/perf/builtin-probe.c
+++ b/tools/perf/builtin-probe.c
@@ -58,7 +58,7 @@ static struct {
58 struct perf_probe_event events[MAX_PROBES]; 58 struct perf_probe_event events[MAX_PROBES];
59 struct strlist *dellist; 59 struct strlist *dellist;
60 struct line_range line_range; 60 struct line_range line_range;
61 const char *target_module; 61 const char *target;
62 int max_probe_points; 62 int max_probe_points;
63 struct strfilter *filter; 63 struct strfilter *filter;
64} params; 64} params;
@@ -246,7 +246,7 @@ static const struct option options[] = {
246 "file", "vmlinux pathname"), 246 "file", "vmlinux pathname"),
247 OPT_STRING('s', "source", &symbol_conf.source_prefix, 247 OPT_STRING('s', "source", &symbol_conf.source_prefix,
248 "directory", "path to kernel source"), 248 "directory", "path to kernel source"),
249 OPT_STRING('m', "module", &params.target_module, 249 OPT_STRING('m', "module", &params.target,
250 "modname|path", 250 "modname|path",
251 "target module name (for online) or path (for offline)"), 251 "target module name (for online) or path (for offline)"),
252#endif 252#endif
@@ -333,7 +333,7 @@ int cmd_probe(int argc, const char **argv, const char *prefix __used)
333 if (!params.filter) 333 if (!params.filter)
334 params.filter = strfilter__new(DEFAULT_FUNC_FILTER, 334 params.filter = strfilter__new(DEFAULT_FUNC_FILTER,
335 NULL); 335 NULL);
336 ret = show_available_funcs(params.target_module, 336 ret = show_available_funcs(params.target,
337 params.filter); 337 params.filter);
338 strfilter__delete(params.filter); 338 strfilter__delete(params.filter);
339 if (ret < 0) 339 if (ret < 0)
@@ -354,7 +354,7 @@ int cmd_probe(int argc, const char **argv, const char *prefix __used)
354 usage_with_options(probe_usage, options); 354 usage_with_options(probe_usage, options);
355 } 355 }
356 356
357 ret = show_line_range(&params.line_range, params.target_module); 357 ret = show_line_range(&params.line_range, params.target);
358 if (ret < 0) 358 if (ret < 0)
359 pr_err(" Error: Failed to show lines. (%d)\n", ret); 359 pr_err(" Error: Failed to show lines. (%d)\n", ret);
360 return ret; 360 return ret;
@@ -371,7 +371,7 @@ int cmd_probe(int argc, const char **argv, const char *prefix __used)
371 371
372 ret = show_available_vars(params.events, params.nevents, 372 ret = show_available_vars(params.events, params.nevents,
373 params.max_probe_points, 373 params.max_probe_points,
374 params.target_module, 374 params.target,
375 params.filter, 375 params.filter,
376 params.show_ext_vars); 376 params.show_ext_vars);
377 strfilter__delete(params.filter); 377 strfilter__delete(params.filter);
@@ -393,7 +393,7 @@ int cmd_probe(int argc, const char **argv, const char *prefix __used)
393 if (params.nevents) { 393 if (params.nevents) {
394 ret = add_perf_probe_events(params.events, params.nevents, 394 ret = add_perf_probe_events(params.events, params.nevents,
395 params.max_probe_points, 395 params.max_probe_points,
396 params.target_module, 396 params.target,
397 params.force_add); 397 params.force_add);
398 if (ret < 0) { 398 if (ret < 0) {
399 pr_err(" Error: Failed to add events. (%d)\n", ret); 399 pr_err(" Error: Failed to add events. (%d)\n", ret);
diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c
index 227b6ae99785..be4e1eee782e 100644
--- a/tools/perf/builtin-record.c
+++ b/tools/perf/builtin-record.c
@@ -44,6 +44,7 @@ struct perf_record {
44 struct perf_evlist *evlist; 44 struct perf_evlist *evlist;
45 struct perf_session *session; 45 struct perf_session *session;
46 const char *progname; 46 const char *progname;
47 const char *uid_str;
47 int output; 48 int output;
48 unsigned int page_size; 49 unsigned int page_size;
49 int realtime_prio; 50 int realtime_prio;
@@ -208,7 +209,7 @@ fallback_missing_features:
208 if (opts->exclude_guest_missing) 209 if (opts->exclude_guest_missing)
209 attr->exclude_guest = attr->exclude_host = 0; 210 attr->exclude_guest = attr->exclude_host = 0;
210retry_sample_id: 211retry_sample_id:
211 attr->sample_id_all = opts->sample_id_all_avail ? 1 : 0; 212 attr->sample_id_all = opts->sample_id_all_missing ? 0 : 1;
212try_again: 213try_again:
213 if (perf_evsel__open(pos, evlist->cpus, evlist->threads, 214 if (perf_evsel__open(pos, evlist->cpus, evlist->threads,
214 opts->group, group_fd) < 0) { 215 opts->group, group_fd) < 0) {
@@ -227,11 +228,11 @@ try_again:
227 "guest or host samples.\n"); 228 "guest or host samples.\n");
228 opts->exclude_guest_missing = true; 229 opts->exclude_guest_missing = true;
229 goto fallback_missing_features; 230 goto fallback_missing_features;
230 } else if (opts->sample_id_all_avail) { 231 } else if (!opts->sample_id_all_missing) {
231 /* 232 /*
232 * Old kernel, no attr->sample_id_type_all field 233 * Old kernel, no attr->sample_id_type_all field
233 */ 234 */
234 opts->sample_id_all_avail = false; 235 opts->sample_id_all_missing = true;
235 if (!opts->sample_time && !opts->raw_samples && !time_needed) 236 if (!opts->sample_time && !opts->raw_samples && !time_needed)
236 attr->sample_type &= ~PERF_SAMPLE_TIME; 237 attr->sample_type &= ~PERF_SAMPLE_TIME;
237 238
@@ -396,7 +397,7 @@ static int __cmd_record(struct perf_record *rec, int argc, const char **argv)
396{ 397{
397 struct stat st; 398 struct stat st;
398 int flags; 399 int flags;
399 int err, output; 400 int err, output, feat;
400 unsigned long waking = 0; 401 unsigned long waking = 0;
401 const bool forks = argc > 0; 402 const bool forks = argc > 0;
402 struct machine *machine; 403 struct machine *machine;
@@ -463,8 +464,17 @@ static int __cmd_record(struct perf_record *rec, int argc, const char **argv)
463 464
464 rec->session = session; 465 rec->session = session;
465 466
466 if (!rec->no_buildid) 467 for (feat = HEADER_FIRST_FEATURE; feat < HEADER_LAST_FEATURE; feat++)
467 perf_header__set_feat(&session->header, HEADER_BUILD_ID); 468 perf_header__set_feat(&session->header, feat);
469
470 if (rec->no_buildid)
471 perf_header__clear_feat(&session->header, HEADER_BUILD_ID);
472
473 if (!have_tracepoints(&evsel_list->entries))
474 perf_header__clear_feat(&session->header, HEADER_TRACE_INFO);
475
476 if (!rec->opts.branch_stack)
477 perf_header__clear_feat(&session->header, HEADER_BRANCH_STACK);
468 478
469 if (!rec->file_new) { 479 if (!rec->file_new) {
470 err = perf_session__read_header(session, output); 480 err = perf_session__read_header(session, output);
@@ -472,22 +482,6 @@ static int __cmd_record(struct perf_record *rec, int argc, const char **argv)
472 goto out_delete_session; 482 goto out_delete_session;
473 } 483 }
474 484
475 if (have_tracepoints(&evsel_list->entries))
476 perf_header__set_feat(&session->header, HEADER_TRACE_INFO);
477
478 perf_header__set_feat(&session->header, HEADER_HOSTNAME);
479 perf_header__set_feat(&session->header, HEADER_OSRELEASE);
480 perf_header__set_feat(&session->header, HEADER_ARCH);
481 perf_header__set_feat(&session->header, HEADER_CPUDESC);
482 perf_header__set_feat(&session->header, HEADER_NRCPUS);
483 perf_header__set_feat(&session->header, HEADER_EVENT_DESC);
484 perf_header__set_feat(&session->header, HEADER_CMDLINE);
485 perf_header__set_feat(&session->header, HEADER_VERSION);
486 perf_header__set_feat(&session->header, HEADER_CPU_TOPOLOGY);
487 perf_header__set_feat(&session->header, HEADER_TOTAL_MEM);
488 perf_header__set_feat(&session->header, HEADER_NUMA_TOPOLOGY);
489 perf_header__set_feat(&session->header, HEADER_CPUID);
490
491 if (forks) { 485 if (forks) {
492 err = perf_evlist__prepare_workload(evsel_list, opts, argv); 486 err = perf_evlist__prepare_workload(evsel_list, opts, argv);
493 if (err < 0) { 487 if (err < 0) {
@@ -647,6 +641,90 @@ out_delete_session:
647 return err; 641 return err;
648} 642}
649 643
644#define BRANCH_OPT(n, m) \
645 { .name = n, .mode = (m) }
646
647#define BRANCH_END { .name = NULL }
648
649struct branch_mode {
650 const char *name;
651 int mode;
652};
653
654static const struct branch_mode branch_modes[] = {
655 BRANCH_OPT("u", PERF_SAMPLE_BRANCH_USER),
656 BRANCH_OPT("k", PERF_SAMPLE_BRANCH_KERNEL),
657 BRANCH_OPT("hv", PERF_SAMPLE_BRANCH_HV),
658 BRANCH_OPT("any", PERF_SAMPLE_BRANCH_ANY),
659 BRANCH_OPT("any_call", PERF_SAMPLE_BRANCH_ANY_CALL),
660 BRANCH_OPT("any_ret", PERF_SAMPLE_BRANCH_ANY_RETURN),
661 BRANCH_OPT("ind_call", PERF_SAMPLE_BRANCH_IND_CALL),
662 BRANCH_END
663};
664
665static int
666parse_branch_stack(const struct option *opt, const char *str, int unset)
667{
668#define ONLY_PLM \
669 (PERF_SAMPLE_BRANCH_USER |\
670 PERF_SAMPLE_BRANCH_KERNEL |\
671 PERF_SAMPLE_BRANCH_HV)
672
673 uint64_t *mode = (uint64_t *)opt->value;
674 const struct branch_mode *br;
675 char *s, *os = NULL, *p;
676 int ret = -1;
677
678 if (unset)
679 return 0;
680
681 /*
682 * cannot set it twice, -b + --branch-filter for instance
683 */
684 if (*mode)
685 return -1;
686
687 /* str may be NULL in case no arg is passed to -b */
688 if (str) {
689 /* because str is read-only */
690 s = os = strdup(str);
691 if (!s)
692 return -1;
693
694 for (;;) {
695 p = strchr(s, ',');
696 if (p)
697 *p = '\0';
698
699 for (br = branch_modes; br->name; br++) {
700 if (!strcasecmp(s, br->name))
701 break;
702 }
703 if (!br->name) {
704 ui__warning("unknown branch filter %s,"
705 " check man page\n", s);
706 goto error;
707 }
708
709 *mode |= br->mode;
710
711 if (!p)
712 break;
713
714 s = p + 1;
715 }
716 }
717 ret = 0;
718
719 /* default to any branch */
720 if ((*mode & ~ONLY_PLM) == 0) {
721 *mode = PERF_SAMPLE_BRANCH_ANY;
722 }
723error:
724 free(os);
725 return ret;
726}
727
650static const char * const record_usage[] = { 728static const char * const record_usage[] = {
651 "perf record [<options>] [<command>]", 729 "perf record [<options>] [<command>]",
652 "perf record [<options>] -- <command> [<options>]", 730 "perf record [<options>] -- <command> [<options>]",
@@ -665,13 +743,10 @@ static const char * const record_usage[] = {
665 */ 743 */
666static struct perf_record record = { 744static struct perf_record record = {
667 .opts = { 745 .opts = {
668 .target_pid = -1,
669 .target_tid = -1,
670 .mmap_pages = UINT_MAX, 746 .mmap_pages = UINT_MAX,
671 .user_freq = UINT_MAX, 747 .user_freq = UINT_MAX,
672 .user_interval = ULLONG_MAX, 748 .user_interval = ULLONG_MAX,
673 .freq = 1000, 749 .freq = 1000,
674 .sample_id_all_avail = true,
675 }, 750 },
676 .write_mode = WRITE_FORCE, 751 .write_mode = WRITE_FORCE,
677 .file_new = true, 752 .file_new = true,
@@ -690,9 +765,9 @@ const struct option record_options[] = {
690 parse_events_option), 765 parse_events_option),
691 OPT_CALLBACK(0, "filter", &record.evlist, "filter", 766 OPT_CALLBACK(0, "filter", &record.evlist, "filter",
692 "event filter", parse_filter), 767 "event filter", parse_filter),
693 OPT_INTEGER('p', "pid", &record.opts.target_pid, 768 OPT_STRING('p', "pid", &record.opts.target_pid, "pid",
694 "record events on existing process id"), 769 "record events on existing process id"),
695 OPT_INTEGER('t', "tid", &record.opts.target_tid, 770 OPT_STRING('t', "tid", &record.opts.target_tid, "tid",
696 "record events on existing thread id"), 771 "record events on existing thread id"),
697 OPT_INTEGER('r', "realtime", &record.realtime_prio, 772 OPT_INTEGER('r', "realtime", &record.realtime_prio,
698 "collect data with this RT SCHED_FIFO priority"), 773 "collect data with this RT SCHED_FIFO priority"),
@@ -738,6 +813,15 @@ const struct option record_options[] = {
738 OPT_CALLBACK('G', "cgroup", &record.evlist, "name", 813 OPT_CALLBACK('G', "cgroup", &record.evlist, "name",
739 "monitor event in cgroup name only", 814 "monitor event in cgroup name only",
740 parse_cgroups), 815 parse_cgroups),
816 OPT_STRING('u', "uid", &record.uid_str, "user", "user to profile"),
817
818 OPT_CALLBACK_NOOPT('b', "branch-any", &record.opts.branch_stack,
819 "branch any", "sample any taken branches",
820 parse_branch_stack),
821
822 OPT_CALLBACK('j', "branch-filter", &record.opts.branch_stack,
823 "branch filter mask", "branch stack filter modes",
824 parse_branch_stack),
741 OPT_END() 825 OPT_END()
742}; 826};
743 827
@@ -758,8 +842,8 @@ int cmd_record(int argc, const char **argv, const char *prefix __used)
758 842
759 argc = parse_options(argc, argv, record_options, record_usage, 843 argc = parse_options(argc, argv, record_options, record_usage,
760 PARSE_OPT_STOP_AT_NON_OPTION); 844 PARSE_OPT_STOP_AT_NON_OPTION);
761 if (!argc && rec->opts.target_pid == -1 && rec->opts.target_tid == -1 && 845 if (!argc && !rec->opts.target_pid && !rec->opts.target_tid &&
762 !rec->opts.system_wide && !rec->opts.cpu_list) 846 !rec->opts.system_wide && !rec->opts.cpu_list && !rec->uid_str)
763 usage_with_options(record_usage, record_options); 847 usage_with_options(record_usage, record_options);
764 848
765 if (rec->force && rec->append_file) { 849 if (rec->force && rec->append_file) {
@@ -799,11 +883,17 @@ int cmd_record(int argc, const char **argv, const char *prefix __used)
799 goto out_symbol_exit; 883 goto out_symbol_exit;
800 } 884 }
801 885
802 if (rec->opts.target_pid != -1) 886 rec->opts.uid = parse_target_uid(rec->uid_str, rec->opts.target_tid,
887 rec->opts.target_pid);
888 if (rec->uid_str != NULL && rec->opts.uid == UINT_MAX - 1)
889 goto out_free_fd;
890
891 if (rec->opts.target_pid)
803 rec->opts.target_tid = rec->opts.target_pid; 892 rec->opts.target_tid = rec->opts.target_pid;
804 893
805 if (perf_evlist__create_maps(evsel_list, rec->opts.target_pid, 894 if (perf_evlist__create_maps(evsel_list, rec->opts.target_pid,
806 rec->opts.target_tid, rec->opts.cpu_list) < 0) 895 rec->opts.target_tid, rec->opts.uid,
896 rec->opts.cpu_list) < 0)
807 usage_with_options(record_usage, record_options); 897 usage_with_options(record_usage, record_options);
808 898
809 list_for_each_entry(pos, &evsel_list->entries, node) { 899 list_for_each_entry(pos, &evsel_list->entries, node) {
diff --git a/tools/perf/builtin-report.c b/tools/perf/builtin-report.c
index 25d34d483e49..2e317438980b 100644
--- a/tools/perf/builtin-report.c
+++ b/tools/perf/builtin-report.c
@@ -40,7 +40,7 @@ struct perf_report {
40 struct perf_tool tool; 40 struct perf_tool tool;
41 struct perf_session *session; 41 struct perf_session *session;
42 char const *input_name; 42 char const *input_name;
43 bool force, use_tui, use_stdio; 43 bool force, use_tui, use_gtk, use_stdio;
44 bool hide_unresolved; 44 bool hide_unresolved;
45 bool dont_use_callchains; 45 bool dont_use_callchains;
46 bool show_full_info; 46 bool show_full_info;
@@ -50,9 +50,86 @@ struct perf_report {
50 const char *pretty_printing_style; 50 const char *pretty_printing_style;
51 symbol_filter_t annotate_init; 51 symbol_filter_t annotate_init;
52 const char *cpu_list; 52 const char *cpu_list;
53 const char *symbol_filter_str;
53 DECLARE_BITMAP(cpu_bitmap, MAX_NR_CPUS); 54 DECLARE_BITMAP(cpu_bitmap, MAX_NR_CPUS);
54}; 55};
55 56
57static int perf_report__add_branch_hist_entry(struct perf_tool *tool,
58 struct addr_location *al,
59 struct perf_sample *sample,
60 struct perf_evsel *evsel,
61 struct machine *machine)
62{
63 struct perf_report *rep = container_of(tool, struct perf_report, tool);
64 struct symbol *parent = NULL;
65 int err = 0;
66 unsigned i;
67 struct hist_entry *he;
68 struct branch_info *bi, *bx;
69
70 if ((sort__has_parent || symbol_conf.use_callchain)
71 && sample->callchain) {
72 err = machine__resolve_callchain(machine, evsel, al->thread,
73 sample->callchain, &parent);
74 if (err)
75 return err;
76 }
77
78 bi = machine__resolve_bstack(machine, al->thread,
79 sample->branch_stack);
80 if (!bi)
81 return -ENOMEM;
82
83 for (i = 0; i < sample->branch_stack->nr; i++) {
84 if (rep->hide_unresolved && !(bi[i].from.sym && bi[i].to.sym))
85 continue;
86 /*
87 * The report shows the percentage of total branches captured
88 * and not events sampled. Thus we use a pseudo period of 1.
89 */
90 he = __hists__add_branch_entry(&evsel->hists, al, parent,
91 &bi[i], 1);
92 if (he) {
93 struct annotation *notes;
94 err = -ENOMEM;
95 bx = he->branch_info;
96 if (bx->from.sym && use_browser > 0) {
97 notes = symbol__annotation(bx->from.sym);
98 if (!notes->src
99 && symbol__alloc_hist(bx->from.sym) < 0)
100 goto out;
101
102 err = symbol__inc_addr_samples(bx->from.sym,
103 bx->from.map,
104 evsel->idx,
105 bx->from.al_addr);
106 if (err)
107 goto out;
108 }
109
110 if (bx->to.sym && use_browser > 0) {
111 notes = symbol__annotation(bx->to.sym);
112 if (!notes->src
113 && symbol__alloc_hist(bx->to.sym) < 0)
114 goto out;
115
116 err = symbol__inc_addr_samples(bx->to.sym,
117 bx->to.map,
118 evsel->idx,
119 bx->to.al_addr);
120 if (err)
121 goto out;
122 }
123 evsel->hists.stats.total_period += 1;
124 hists__inc_nr_events(&evsel->hists, PERF_RECORD_SAMPLE);
125 err = 0;
126 } else
127 return -ENOMEM;
128 }
129out:
130 return err;
131}
132
56static int perf_evsel__add_hist_entry(struct perf_evsel *evsel, 133static int perf_evsel__add_hist_entry(struct perf_evsel *evsel,
57 struct addr_location *al, 134 struct addr_location *al,
58 struct perf_sample *sample, 135 struct perf_sample *sample,
@@ -126,14 +203,21 @@ static int process_sample_event(struct perf_tool *tool,
126 if (rep->cpu_list && !test_bit(sample->cpu, rep->cpu_bitmap)) 203 if (rep->cpu_list && !test_bit(sample->cpu, rep->cpu_bitmap))
127 return 0; 204 return 0;
128 205
129 if (al.map != NULL) 206 if (sort__branch_mode == 1) {
130 al.map->dso->hit = 1; 207 if (perf_report__add_branch_hist_entry(tool, &al, sample,
208 evsel, machine)) {
209 pr_debug("problem adding lbr entry, skipping event\n");
210 return -1;
211 }
212 } else {
213 if (al.map != NULL)
214 al.map->dso->hit = 1;
131 215
132 if (perf_evsel__add_hist_entry(evsel, &al, sample, machine)) { 216 if (perf_evsel__add_hist_entry(evsel, &al, sample, machine)) {
133 pr_debug("problem incrementing symbol period, skipping event\n"); 217 pr_debug("problem incrementing symbol period, skipping event\n");
134 return -1; 218 return -1;
219 }
135 } 220 }
136
137 return 0; 221 return 0;
138} 222}
139 223
@@ -188,6 +272,15 @@ static int perf_report__setup_sample_type(struct perf_report *rep)
188 } 272 }
189 } 273 }
190 274
275 if (sort__branch_mode == 1) {
276 if (!(self->sample_type & PERF_SAMPLE_BRANCH_STACK)) {
277 fprintf(stderr, "selected -b but no branch data."
278 " Did you call perf record without"
279 " -b?\n");
280 return -1;
281 }
282 }
283
191 return 0; 284 return 0;
192} 285}
193 286
@@ -246,7 +339,7 @@ static int __cmd_report(struct perf_report *rep)
246{ 339{
247 int ret = -EINVAL; 340 int ret = -EINVAL;
248 u64 nr_samples; 341 u64 nr_samples;
249 struct perf_session *session; 342 struct perf_session *session = rep->session;
250 struct perf_evsel *pos; 343 struct perf_evsel *pos;
251 struct map *kernel_map; 344 struct map *kernel_map;
252 struct kmap *kernel_kmap; 345 struct kmap *kernel_kmap;
@@ -254,13 +347,6 @@ static int __cmd_report(struct perf_report *rep)
254 347
255 signal(SIGINT, sig_handler); 348 signal(SIGINT, sig_handler);
256 349
257 session = perf_session__new(rep->input_name, O_RDONLY,
258 rep->force, false, &rep->tool);
259 if (session == NULL)
260 return -ENOMEM;
261
262 rep->session = session;
263
264 if (rep->cpu_list) { 350 if (rep->cpu_list) {
265 ret = perf_session__cpu_bitmap(session, rep->cpu_list, 351 ret = perf_session__cpu_bitmap(session, rep->cpu_list,
266 rep->cpu_bitmap); 352 rep->cpu_bitmap);
@@ -315,6 +401,9 @@ static int __cmd_report(struct perf_report *rep)
315 list_for_each_entry(pos, &session->evlist->entries, node) { 401 list_for_each_entry(pos, &session->evlist->entries, node) {
316 struct hists *hists = &pos->hists; 402 struct hists *hists = &pos->hists;
317 403
404 if (pos->idx == 0)
405 hists->symbol_filter_str = rep->symbol_filter_str;
406
318 hists__collapse_resort(hists); 407 hists__collapse_resort(hists);
319 hists__output_resort(hists); 408 hists__output_resort(hists);
320 nr_samples += hists->stats.nr_events[PERF_RECORD_SAMPLE]; 409 nr_samples += hists->stats.nr_events[PERF_RECORD_SAMPLE];
@@ -326,8 +415,13 @@ static int __cmd_report(struct perf_report *rep)
326 } 415 }
327 416
328 if (use_browser > 0) { 417 if (use_browser > 0) {
329 perf_evlist__tui_browse_hists(session->evlist, help, 418 if (use_browser == 1) {
330 NULL, NULL, 0); 419 perf_evlist__tui_browse_hists(session->evlist, help,
420 NULL, NULL, 0);
421 } else if (use_browser == 2) {
422 perf_evlist__gtk_browse_hists(session->evlist, help,
423 NULL, NULL, 0);
424 }
331 } else 425 } else
332 perf_evlist__tty_browse_hists(session->evlist, rep, help); 426 perf_evlist__tty_browse_hists(session->evlist, rep, help);
333 427
@@ -427,9 +521,19 @@ setup:
427 return 0; 521 return 0;
428} 522}
429 523
524static int
525parse_branch_mode(const struct option *opt __used, const char *str __used, int unset)
526{
527 sort__branch_mode = !unset;
528 return 0;
529}
530
430int cmd_report(int argc, const char **argv, const char *prefix __used) 531int cmd_report(int argc, const char **argv, const char *prefix __used)
431{ 532{
533 struct perf_session *session;
432 struct stat st; 534 struct stat st;
535 bool has_br_stack = false;
536 int ret = -1;
433 char callchain_default_opt[] = "fractal,0.5,callee"; 537 char callchain_default_opt[] = "fractal,0.5,callee";
434 const char * const report_usage[] = { 538 const char * const report_usage[] = {
435 "perf report [<options>]", 539 "perf report [<options>]",
@@ -474,10 +578,12 @@ int cmd_report(int argc, const char **argv, const char *prefix __used)
474 OPT_STRING(0, "pretty", &report.pretty_printing_style, "key", 578 OPT_STRING(0, "pretty", &report.pretty_printing_style, "key",
475 "pretty printing style key: normal raw"), 579 "pretty printing style key: normal raw"),
476 OPT_BOOLEAN(0, "tui", &report.use_tui, "Use the TUI interface"), 580 OPT_BOOLEAN(0, "tui", &report.use_tui, "Use the TUI interface"),
581 OPT_BOOLEAN(0, "gtk", &report.use_gtk, "Use the GTK2 interface"),
477 OPT_BOOLEAN(0, "stdio", &report.use_stdio, 582 OPT_BOOLEAN(0, "stdio", &report.use_stdio,
478 "Use the stdio interface"), 583 "Use the stdio interface"),
479 OPT_STRING('s', "sort", &sort_order, "key[,key2...]", 584 OPT_STRING('s', "sort", &sort_order, "key[,key2...]",
480 "sort by key(s): pid, comm, dso, symbol, parent"), 585 "sort by key(s): pid, comm, dso, symbol, parent, dso_to,"
586 " dso_from, symbol_to, symbol_from, mispredict"),
481 OPT_BOOLEAN(0, "showcpuutilization", &symbol_conf.show_cpu_utilization, 587 OPT_BOOLEAN(0, "showcpuutilization", &symbol_conf.show_cpu_utilization,
482 "Show sample percentage for different cpu modes"), 588 "Show sample percentage for different cpu modes"),
483 OPT_STRING('p', "parent", &parent_pattern, "regex", 589 OPT_STRING('p', "parent", &parent_pattern, "regex",
@@ -495,6 +601,8 @@ int cmd_report(int argc, const char **argv, const char *prefix __used)
495 "only consider symbols in these comms"), 601 "only consider symbols in these comms"),
496 OPT_STRING('S', "symbols", &symbol_conf.sym_list_str, "symbol[,symbol...]", 602 OPT_STRING('S', "symbols", &symbol_conf.sym_list_str, "symbol[,symbol...]",
497 "only consider these symbols"), 603 "only consider these symbols"),
604 OPT_STRING(0, "symbol-filter", &report.symbol_filter_str, "filter",
605 "only show symbols that (partially) match with this filter"),
498 OPT_STRING('w', "column-widths", &symbol_conf.col_width_list_str, 606 OPT_STRING('w', "column-widths", &symbol_conf.col_width_list_str,
499 "width[,width...]", 607 "width[,width...]",
500 "don't try to adjust column width, use these fixed values"), 608 "don't try to adjust column width, use these fixed values"),
@@ -517,6 +625,8 @@ int cmd_report(int argc, const char **argv, const char *prefix __used)
517 "Specify disassembler style (e.g. -M intel for intel syntax)"), 625 "Specify disassembler style (e.g. -M intel for intel syntax)"),
518 OPT_BOOLEAN(0, "show-total-period", &symbol_conf.show_total_period, 626 OPT_BOOLEAN(0, "show-total-period", &symbol_conf.show_total_period,
519 "Show a column with the sum of periods"), 627 "Show a column with the sum of periods"),
628 OPT_CALLBACK_NOOPT('b', "branch-stack", &sort__branch_mode, "",
629 "use branch records for histogram filling", parse_branch_mode),
520 OPT_END() 630 OPT_END()
521 }; 631 };
522 632
@@ -526,6 +636,8 @@ int cmd_report(int argc, const char **argv, const char *prefix __used)
526 use_browser = 0; 636 use_browser = 0;
527 else if (report.use_tui) 637 else if (report.use_tui)
528 use_browser = 1; 638 use_browser = 1;
639 else if (report.use_gtk)
640 use_browser = 2;
529 641
530 if (report.inverted_callchain) 642 if (report.inverted_callchain)
531 callchain_param.order = ORDER_CALLER; 643 callchain_param.order = ORDER_CALLER;
@@ -536,11 +648,39 @@ int cmd_report(int argc, const char **argv, const char *prefix __used)
536 else 648 else
537 report.input_name = "perf.data"; 649 report.input_name = "perf.data";
538 } 650 }
651 session = perf_session__new(report.input_name, O_RDONLY,
652 report.force, false, &report.tool);
653 if (session == NULL)
654 return -ENOMEM;
539 655
540 if (strcmp(report.input_name, "-") != 0) 656 report.session = session;
541 setup_browser(true); 657
542 else 658 has_br_stack = perf_header__has_feat(&session->header,
659 HEADER_BRANCH_STACK);
660
661 if (sort__branch_mode == -1 && has_br_stack)
662 sort__branch_mode = 1;
663
664 /* sort__branch_mode could be 0 if --no-branch-stack */
665 if (sort__branch_mode == 1) {
666 /*
667 * if no sort_order is provided, then specify
668 * branch-mode specific order
669 */
670 if (sort_order == default_sort_order)
671 sort_order = "comm,dso_from,symbol_from,"
672 "dso_to,symbol_to";
673
674 }
675
676 if (strcmp(report.input_name, "-") != 0) {
677 if (report.use_gtk)
678 perf_gtk_setup_browser(argc, argv, true);
679 else
680 setup_browser(true);
681 } else {
543 use_browser = 0; 682 use_browser = 0;
683 }
544 684
545 /* 685 /*
546 * Only in the newt browser we are doing integrated annotation, 686 * Only in the newt browser we are doing integrated annotation,
@@ -568,13 +708,13 @@ int cmd_report(int argc, const char **argv, const char *prefix __used)
568 } 708 }
569 709
570 if (symbol__init() < 0) 710 if (symbol__init() < 0)
571 return -1; 711 goto error;
572 712
573 setup_sorting(report_usage, options); 713 setup_sorting(report_usage, options);
574 714
575 if (parent_pattern != default_parent_pattern) { 715 if (parent_pattern != default_parent_pattern) {
576 if (sort_dimension__add("parent") < 0) 716 if (sort_dimension__add("parent") < 0)
577 return -1; 717 goto error;
578 718
579 /* 719 /*
580 * Only show the parent fields if we explicitly 720 * Only show the parent fields if we explicitly
@@ -586,15 +726,31 @@ int cmd_report(int argc, const char **argv, const char *prefix __used)
586 } else 726 } else
587 symbol_conf.exclude_other = false; 727 symbol_conf.exclude_other = false;
588 728
589 /* 729 if (argc) {
590 * Any (unrecognized) arguments left? 730 /*
591 */ 731 * Special case: if there's an argument left then assume that
592 if (argc) 732 * it's a symbol filter:
593 usage_with_options(report_usage, options); 733 */
734 if (argc > 1)
735 usage_with_options(report_usage, options);
736
737 report.symbol_filter_str = argv[0];
738 }
594 739
595 sort_entry__setup_elide(&sort_dso, symbol_conf.dso_list, "dso", stdout);
596 sort_entry__setup_elide(&sort_comm, symbol_conf.comm_list, "comm", stdout); 740 sort_entry__setup_elide(&sort_comm, symbol_conf.comm_list, "comm", stdout);
597 sort_entry__setup_elide(&sort_sym, symbol_conf.sym_list, "symbol", stdout);
598 741
599 return __cmd_report(&report); 742 if (sort__branch_mode == 1) {
743 sort_entry__setup_elide(&sort_dso_from, symbol_conf.dso_from_list, "dso_from", stdout);
744 sort_entry__setup_elide(&sort_dso_to, symbol_conf.dso_to_list, "dso_to", stdout);
745 sort_entry__setup_elide(&sort_sym_from, symbol_conf.sym_from_list, "sym_from", stdout);
746 sort_entry__setup_elide(&sort_sym_to, symbol_conf.sym_to_list, "sym_to", stdout);
747 } else {
748 sort_entry__setup_elide(&sort_dso, symbol_conf.dso_list, "dso", stdout);
749 sort_entry__setup_elide(&sort_sym, symbol_conf.sym_list, "symbol", stdout);
750 }
751
752 ret = __cmd_report(&report);
753error:
754 perf_session__delete(session);
755 return ret;
600} 756}
diff --git a/tools/perf/builtin-script.c b/tools/perf/builtin-script.c
index bb68ddf257b7..d4ce733b9eba 100644
--- a/tools/perf/builtin-script.c
+++ b/tools/perf/builtin-script.c
@@ -40,6 +40,7 @@ enum perf_output_field {
40 PERF_OUTPUT_SYM = 1U << 8, 40 PERF_OUTPUT_SYM = 1U << 8,
41 PERF_OUTPUT_DSO = 1U << 9, 41 PERF_OUTPUT_DSO = 1U << 9,
42 PERF_OUTPUT_ADDR = 1U << 10, 42 PERF_OUTPUT_ADDR = 1U << 10,
43 PERF_OUTPUT_SYMOFFSET = 1U << 11,
43}; 44};
44 45
45struct output_option { 46struct output_option {
@@ -57,6 +58,7 @@ struct output_option {
57 {.str = "sym", .field = PERF_OUTPUT_SYM}, 58 {.str = "sym", .field = PERF_OUTPUT_SYM},
58 {.str = "dso", .field = PERF_OUTPUT_DSO}, 59 {.str = "dso", .field = PERF_OUTPUT_DSO},
59 {.str = "addr", .field = PERF_OUTPUT_ADDR}, 60 {.str = "addr", .field = PERF_OUTPUT_ADDR},
61 {.str = "symoff", .field = PERF_OUTPUT_SYMOFFSET},
60}; 62};
61 63
62/* default set to maintain compatibility with current format */ 64/* default set to maintain compatibility with current format */
@@ -193,6 +195,11 @@ static int perf_evsel__check_attr(struct perf_evsel *evsel,
193 "to symbols.\n"); 195 "to symbols.\n");
194 return -EINVAL; 196 return -EINVAL;
195 } 197 }
198 if (PRINT_FIELD(SYMOFFSET) && !PRINT_FIELD(SYM)) {
199 pr_err("Display of offsets requested but symbol is not"
200 "selected.\n");
201 return -EINVAL;
202 }
196 if (PRINT_FIELD(DSO) && !PRINT_FIELD(IP) && !PRINT_FIELD(ADDR)) { 203 if (PRINT_FIELD(DSO) && !PRINT_FIELD(IP) && !PRINT_FIELD(ADDR)) {
197 pr_err("Display of DSO requested but neither sample IP nor " 204 pr_err("Display of DSO requested but neither sample IP nor "
198 "sample address\nis selected. Hence, no addresses to convert " 205 "sample address\nis selected. Hence, no addresses to convert "
@@ -300,10 +307,17 @@ static void print_sample_start(struct perf_sample *sample,
300 } else 307 } else
301 evname = __event_name(attr->type, attr->config); 308 evname = __event_name(attr->type, attr->config);
302 309
303 printf("%s: ", evname ? evname : "(unknown)"); 310 printf("%s: ", evname ? evname : "[unknown]");
304 } 311 }
305} 312}
306 313
314static bool is_bts_event(struct perf_event_attr *attr)
315{
316 return ((attr->type == PERF_TYPE_HARDWARE) &&
317 (attr->config & PERF_COUNT_HW_BRANCH_INSTRUCTIONS) &&
318 (attr->sample_period == 1));
319}
320
307static bool sample_addr_correlates_sym(struct perf_event_attr *attr) 321static bool sample_addr_correlates_sym(struct perf_event_attr *attr)
308{ 322{
309 if ((attr->type == PERF_TYPE_SOFTWARE) && 323 if ((attr->type == PERF_TYPE_SOFTWARE) &&
@@ -312,6 +326,9 @@ static bool sample_addr_correlates_sym(struct perf_event_attr *attr)
312 (attr->config == PERF_COUNT_SW_PAGE_FAULTS_MAJ))) 326 (attr->config == PERF_COUNT_SW_PAGE_FAULTS_MAJ)))
313 return true; 327 return true;
314 328
329 if (is_bts_event(attr))
330 return true;
331
315 return false; 332 return false;
316} 333}
317 334
@@ -323,7 +340,6 @@ static void print_sample_addr(union perf_event *event,
323{ 340{
324 struct addr_location al; 341 struct addr_location al;
325 u8 cpumode = event->header.misc & PERF_RECORD_MISC_CPUMODE_MASK; 342 u8 cpumode = event->header.misc & PERF_RECORD_MISC_CPUMODE_MASK;
326 const char *symname, *dsoname;
327 343
328 printf("%16" PRIx64, sample->addr); 344 printf("%16" PRIx64, sample->addr);
329 345
@@ -343,22 +359,46 @@ static void print_sample_addr(union perf_event *event,
343 al.sym = map__find_symbol(al.map, al.addr, NULL); 359 al.sym = map__find_symbol(al.map, al.addr, NULL);
344 360
345 if (PRINT_FIELD(SYM)) { 361 if (PRINT_FIELD(SYM)) {
346 if (al.sym && al.sym->name) 362 printf(" ");
347 symname = al.sym->name; 363 if (PRINT_FIELD(SYMOFFSET))
364 symbol__fprintf_symname_offs(al.sym, &al, stdout);
348 else 365 else
349 symname = ""; 366 symbol__fprintf_symname(al.sym, stdout);
350
351 printf(" %16s", symname);
352 } 367 }
353 368
354 if (PRINT_FIELD(DSO)) { 369 if (PRINT_FIELD(DSO)) {
355 if (al.map && al.map->dso && al.map->dso->name) 370 printf(" (");
356 dsoname = al.map->dso->name; 371 map__fprintf_dsoname(al.map, stdout);
357 else 372 printf(")");
358 dsoname = ""; 373 }
374}
359 375
360 printf(" (%s)", dsoname); 376static void print_sample_bts(union perf_event *event,
377 struct perf_sample *sample,
378 struct perf_evsel *evsel,
379 struct machine *machine,
380 struct thread *thread)
381{
382 struct perf_event_attr *attr = &evsel->attr;
383
384 /* print branch_from information */
385 if (PRINT_FIELD(IP)) {
386 if (!symbol_conf.use_callchain)
387 printf(" ");
388 else
389 printf("\n");
390 perf_event__print_ip(event, sample, machine, evsel,
391 PRINT_FIELD(SYM), PRINT_FIELD(DSO),
392 PRINT_FIELD(SYMOFFSET));
361 } 393 }
394
395 printf(" => ");
396
397 /* print branch_to information */
398 if (PRINT_FIELD(ADDR))
399 print_sample_addr(event, sample, machine, thread, attr);
400
401 printf("\n");
362} 402}
363 403
364static void process_event(union perf_event *event __unused, 404static void process_event(union perf_event *event __unused,
@@ -374,6 +414,11 @@ static void process_event(union perf_event *event __unused,
374 414
375 print_sample_start(sample, thread, attr); 415 print_sample_start(sample, thread, attr);
376 416
417 if (is_bts_event(attr)) {
418 print_sample_bts(event, sample, evsel, machine, thread);
419 return;
420 }
421
377 if (PRINT_FIELD(TRACE)) 422 if (PRINT_FIELD(TRACE))
378 print_trace_event(sample->cpu, sample->raw_data, 423 print_trace_event(sample->cpu, sample->raw_data,
379 sample->raw_size); 424 sample->raw_size);
@@ -387,7 +432,8 @@ static void process_event(union perf_event *event __unused,
387 else 432 else
388 printf("\n"); 433 printf("\n");
389 perf_event__print_ip(event, sample, machine, evsel, 434 perf_event__print_ip(event, sample, machine, evsel,
390 PRINT_FIELD(SYM), PRINT_FIELD(DSO)); 435 PRINT_FIELD(SYM), PRINT_FIELD(DSO),
436 PRINT_FIELD(SYMOFFSET));
391 } 437 }
392 438
393 printf("\n"); 439 printf("\n");
@@ -1097,7 +1143,10 @@ static const struct option options[] = {
1097 OPT_STRING(0, "symfs", &symbol_conf.symfs, "directory", 1143 OPT_STRING(0, "symfs", &symbol_conf.symfs, "directory",
1098 "Look for files with symbols relative to this directory"), 1144 "Look for files with symbols relative to this directory"),
1099 OPT_CALLBACK('f', "fields", NULL, "str", 1145 OPT_CALLBACK('f', "fields", NULL, "str",
1100 "comma separated output fields prepend with 'type:'. Valid types: hw,sw,trace,raw. Fields: comm,tid,pid,time,cpu,event,trace,ip,sym,dso,addr", 1146 "comma separated output fields prepend with 'type:'. "
1147 "Valid types: hw,sw,trace,raw. "
1148 "Fields: comm,tid,pid,time,cpu,event,trace,ip,sym,dso,"
1149 "addr,symoff",
1101 parse_output_fields), 1150 parse_output_fields),
1102 OPT_BOOLEAN('a', "all-cpus", &system_wide, 1151 OPT_BOOLEAN('a', "all-cpus", &system_wide,
1103 "system-wide collection from all CPUs"), 1152 "system-wide collection from all CPUs"),
@@ -1106,6 +1155,9 @@ static const struct option options[] = {
1106 "only display events for these comms"), 1155 "only display events for these comms"),
1107 OPT_BOOLEAN('I', "show-info", &show_full_info, 1156 OPT_BOOLEAN('I', "show-info", &show_full_info,
1108 "display extended information from perf.data file"), 1157 "display extended information from perf.data file"),
1158 OPT_BOOLEAN('\0', "show-kernel-path", &symbol_conf.show_kernel_path,
1159 "Show the path of [kernel.kallsyms]"),
1160
1109 OPT_END() 1161 OPT_END()
1110}; 1162};
1111 1163
diff --git a/tools/perf/builtin-stat.c b/tools/perf/builtin-stat.c
index f5d2a63eba66..c941bb640f49 100644
--- a/tools/perf/builtin-stat.c
+++ b/tools/perf/builtin-stat.c
@@ -182,8 +182,8 @@ static int run_count = 1;
182static bool no_inherit = false; 182static bool no_inherit = false;
183static bool scale = true; 183static bool scale = true;
184static bool no_aggr = false; 184static bool no_aggr = false;
185static pid_t target_pid = -1; 185static const char *target_pid;
186static pid_t target_tid = -1; 186static const char *target_tid;
187static pid_t child_pid = -1; 187static pid_t child_pid = -1;
188static bool null_run = false; 188static bool null_run = false;
189static int detailed_run = 0; 189static int detailed_run = 0;
@@ -296,7 +296,7 @@ static int create_perf_stat_counter(struct perf_evsel *evsel,
296 if (system_wide) 296 if (system_wide)
297 return perf_evsel__open_per_cpu(evsel, evsel_list->cpus, 297 return perf_evsel__open_per_cpu(evsel, evsel_list->cpus,
298 group, group_fd); 298 group, group_fd);
299 if (target_pid == -1 && target_tid == -1) { 299 if (!target_pid && !target_tid && (!group || evsel == first)) {
300 attr->disabled = 1; 300 attr->disabled = 1;
301 attr->enable_on_exec = 1; 301 attr->enable_on_exec = 1;
302 } 302 }
@@ -446,7 +446,7 @@ static int run_perf_stat(int argc __used, const char **argv)
446 exit(-1); 446 exit(-1);
447 } 447 }
448 448
449 if (target_tid == -1 && target_pid == -1 && !system_wide) 449 if (!target_tid && !target_pid && !system_wide)
450 evsel_list->threads->map[0] = child_pid; 450 evsel_list->threads->map[0] = child_pid;
451 451
452 /* 452 /*
@@ -576,6 +576,8 @@ static void nsec_printout(int cpu, struct perf_evsel *evsel, double avg)
576 if (perf_evsel__match(evsel, SOFTWARE, SW_TASK_CLOCK)) 576 if (perf_evsel__match(evsel, SOFTWARE, SW_TASK_CLOCK))
577 fprintf(output, " # %8.3f CPUs utilized ", 577 fprintf(output, " # %8.3f CPUs utilized ",
578 avg / avg_stats(&walltime_nsecs_stats)); 578 avg / avg_stats(&walltime_nsecs_stats));
579 else
580 fprintf(output, " ");
579} 581}
580 582
581/* used for get_ratio_color() */ 583/* used for get_ratio_color() */
@@ -844,12 +846,18 @@ static void abs_printout(int cpu, struct perf_evsel *evsel, double avg)
844 846
845 fprintf(output, " # %8.3f GHz ", ratio); 847 fprintf(output, " # %8.3f GHz ", ratio);
846 } else if (runtime_nsecs_stats[cpu].n != 0) { 848 } else if (runtime_nsecs_stats[cpu].n != 0) {
849 char unit = 'M';
850
847 total = avg_stats(&runtime_nsecs_stats[cpu]); 851 total = avg_stats(&runtime_nsecs_stats[cpu]);
848 852
849 if (total) 853 if (total)
850 ratio = 1000.0 * avg / total; 854 ratio = 1000.0 * avg / total;
855 if (ratio < 0.001) {
856 ratio *= 1000;
857 unit = 'K';
858 }
851 859
852 fprintf(output, " # %8.3f M/sec ", ratio); 860 fprintf(output, " # %8.3f %c/sec ", ratio, unit);
853 } else { 861 } else {
854 fprintf(output, " "); 862 fprintf(output, " ");
855 } 863 }
@@ -960,14 +968,14 @@ static void print_stat(int argc, const char **argv)
960 if (!csv_output) { 968 if (!csv_output) {
961 fprintf(output, "\n"); 969 fprintf(output, "\n");
962 fprintf(output, " Performance counter stats for "); 970 fprintf(output, " Performance counter stats for ");
963 if(target_pid == -1 && target_tid == -1) { 971 if (!target_pid && !target_tid) {
964 fprintf(output, "\'%s", argv[0]); 972 fprintf(output, "\'%s", argv[0]);
965 for (i = 1; i < argc; i++) 973 for (i = 1; i < argc; i++)
966 fprintf(output, " %s", argv[i]); 974 fprintf(output, " %s", argv[i]);
967 } else if (target_pid != -1) 975 } else if (target_pid)
968 fprintf(output, "process id \'%d", target_pid); 976 fprintf(output, "process id \'%s", target_pid);
969 else 977 else
970 fprintf(output, "thread id \'%d", target_tid); 978 fprintf(output, "thread id \'%s", target_tid);
971 979
972 fprintf(output, "\'"); 980 fprintf(output, "\'");
973 if (run_count > 1) 981 if (run_count > 1)
@@ -1041,10 +1049,10 @@ static const struct option options[] = {
1041 "event filter", parse_filter), 1049 "event filter", parse_filter),
1042 OPT_BOOLEAN('i', "no-inherit", &no_inherit, 1050 OPT_BOOLEAN('i', "no-inherit", &no_inherit,
1043 "child tasks do not inherit counters"), 1051 "child tasks do not inherit counters"),
1044 OPT_INTEGER('p', "pid", &target_pid, 1052 OPT_STRING('p', "pid", &target_pid, "pid",
1045 "stat events on existing process id"), 1053 "stat events on existing process id"),
1046 OPT_INTEGER('t', "tid", &target_tid, 1054 OPT_STRING('t', "tid", &target_tid, "tid",
1047 "stat events on existing thread id"), 1055 "stat events on existing thread id"),
1048 OPT_BOOLEAN('a', "all-cpus", &system_wide, 1056 OPT_BOOLEAN('a', "all-cpus", &system_wide,
1049 "system-wide collection from all CPUs"), 1057 "system-wide collection from all CPUs"),
1050 OPT_BOOLEAN('g', "group", &group, 1058 OPT_BOOLEAN('g', "group", &group,
@@ -1182,7 +1190,7 @@ int cmd_stat(int argc, const char **argv, const char *prefix __used)
1182 } else if (big_num_opt == 0) /* User passed --no-big-num */ 1190 } else if (big_num_opt == 0) /* User passed --no-big-num */
1183 big_num = false; 1191 big_num = false;
1184 1192
1185 if (!argc && target_pid == -1 && target_tid == -1) 1193 if (!argc && !target_pid && !target_tid)
1186 usage_with_options(stat_usage, options); 1194 usage_with_options(stat_usage, options);
1187 if (run_count <= 0) 1195 if (run_count <= 0)
1188 usage_with_options(stat_usage, options); 1196 usage_with_options(stat_usage, options);
@@ -1198,10 +1206,11 @@ int cmd_stat(int argc, const char **argv, const char *prefix __used)
1198 if (add_default_attributes()) 1206 if (add_default_attributes())
1199 goto out; 1207 goto out;
1200 1208
1201 if (target_pid != -1) 1209 if (target_pid)
1202 target_tid = target_pid; 1210 target_tid = target_pid;
1203 1211
1204 evsel_list->threads = thread_map__new(target_pid, target_tid); 1212 evsel_list->threads = thread_map__new_str(target_pid,
1213 target_tid, UINT_MAX);
1205 if (evsel_list->threads == NULL) { 1214 if (evsel_list->threads == NULL) {
1206 pr_err("Problems finding threads of monitor\n"); 1215 pr_err("Problems finding threads of monitor\n");
1207 usage_with_options(stat_usage, options); 1216 usage_with_options(stat_usage, options);
diff --git a/tools/perf/builtin-test.c b/tools/perf/builtin-test.c
index 3854e869dce1..1c5b9801ac61 100644
--- a/tools/perf/builtin-test.c
+++ b/tools/perf/builtin-test.c
@@ -13,8 +13,11 @@
13#include "util/parse-events.h" 13#include "util/parse-events.h"
14#include "util/symbol.h" 14#include "util/symbol.h"
15#include "util/thread_map.h" 15#include "util/thread_map.h"
16#include "util/pmu.h"
16#include "../../include/linux/hw_breakpoint.h" 17#include "../../include/linux/hw_breakpoint.h"
17 18
19#include <sys/mman.h>
20
18static int vmlinux_matches_kallsyms_filter(struct map *map __used, struct symbol *sym) 21static int vmlinux_matches_kallsyms_filter(struct map *map __used, struct symbol *sym)
19{ 22{
20 bool *visited = symbol__priv(sym); 23 bool *visited = symbol__priv(sym);
@@ -276,7 +279,7 @@ static int test__open_syscall_event(void)
276 return -1; 279 return -1;
277 } 280 }
278 281
279 threads = thread_map__new(-1, getpid()); 282 threads = thread_map__new(-1, getpid(), UINT_MAX);
280 if (threads == NULL) { 283 if (threads == NULL) {
281 pr_debug("thread_map__new\n"); 284 pr_debug("thread_map__new\n");
282 return -1; 285 return -1;
@@ -342,7 +345,7 @@ static int test__open_syscall_event_on_all_cpus(void)
342 return -1; 345 return -1;
343 } 346 }
344 347
345 threads = thread_map__new(-1, getpid()); 348 threads = thread_map__new(-1, getpid(), UINT_MAX);
346 if (threads == NULL) { 349 if (threads == NULL) {
347 pr_debug("thread_map__new\n"); 350 pr_debug("thread_map__new\n");
348 return -1; 351 return -1;
@@ -490,7 +493,7 @@ static int test__basic_mmap(void)
490 expected_nr_events[i] = random() % 257; 493 expected_nr_events[i] = random() % 257;
491 } 494 }
492 495
493 threads = thread_map__new(-1, getpid()); 496 threads = thread_map__new(-1, getpid(), UINT_MAX);
494 if (threads == NULL) { 497 if (threads == NULL) {
495 pr_debug("thread_map__new\n"); 498 pr_debug("thread_map__new\n");
496 return -1; 499 return -1;
@@ -648,7 +651,7 @@ static int test__checkevent_raw(struct perf_evlist *evlist)
648 651
649 TEST_ASSERT_VAL("wrong number of entries", 1 == evlist->nr_entries); 652 TEST_ASSERT_VAL("wrong number of entries", 1 == evlist->nr_entries);
650 TEST_ASSERT_VAL("wrong type", PERF_TYPE_RAW == evsel->attr.type); 653 TEST_ASSERT_VAL("wrong type", PERF_TYPE_RAW == evsel->attr.type);
651 TEST_ASSERT_VAL("wrong config", 1 == evsel->attr.config); 654 TEST_ASSERT_VAL("wrong config", 0x1a == evsel->attr.config);
652 return 0; 655 return 0;
653} 656}
654 657
@@ -675,6 +678,24 @@ static int test__checkevent_symbolic_name(struct perf_evlist *evlist)
675 return 0; 678 return 0;
676} 679}
677 680
681static int test__checkevent_symbolic_name_config(struct perf_evlist *evlist)
682{
683 struct perf_evsel *evsel = list_entry(evlist->entries.next,
684 struct perf_evsel, node);
685
686 TEST_ASSERT_VAL("wrong number of entries", 1 == evlist->nr_entries);
687 TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->attr.type);
688 TEST_ASSERT_VAL("wrong config",
689 PERF_COUNT_HW_CPU_CYCLES == evsel->attr.config);
690 TEST_ASSERT_VAL("wrong period",
691 100000 == evsel->attr.sample_period);
692 TEST_ASSERT_VAL("wrong config1",
693 0 == evsel->attr.config1);
694 TEST_ASSERT_VAL("wrong config2",
695 1 == evsel->attr.config2);
696 return 0;
697}
698
678static int test__checkevent_symbolic_alias(struct perf_evlist *evlist) 699static int test__checkevent_symbolic_alias(struct perf_evlist *evlist)
679{ 700{
680 struct perf_evsel *evsel = list_entry(evlist->entries.next, 701 struct perf_evsel *evsel = list_entry(evlist->entries.next,
@@ -856,6 +877,115 @@ static int test__checkevent_genhw_modifier(struct perf_evlist *evlist)
856 return test__checkevent_genhw(evlist); 877 return test__checkevent_genhw(evlist);
857} 878}
858 879
880static int test__checkevent_breakpoint_modifier(struct perf_evlist *evlist)
881{
882 struct perf_evsel *evsel = list_entry(evlist->entries.next,
883 struct perf_evsel, node);
884
885 TEST_ASSERT_VAL("wrong exclude_user", !evsel->attr.exclude_user);
886 TEST_ASSERT_VAL("wrong exclude_kernel", evsel->attr.exclude_kernel);
887 TEST_ASSERT_VAL("wrong exclude_hv", evsel->attr.exclude_hv);
888 TEST_ASSERT_VAL("wrong precise_ip", !evsel->attr.precise_ip);
889
890 return test__checkevent_breakpoint(evlist);
891}
892
893static int test__checkevent_breakpoint_x_modifier(struct perf_evlist *evlist)
894{
895 struct perf_evsel *evsel = list_entry(evlist->entries.next,
896 struct perf_evsel, node);
897
898 TEST_ASSERT_VAL("wrong exclude_user", evsel->attr.exclude_user);
899 TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->attr.exclude_kernel);
900 TEST_ASSERT_VAL("wrong exclude_hv", evsel->attr.exclude_hv);
901 TEST_ASSERT_VAL("wrong precise_ip", !evsel->attr.precise_ip);
902
903 return test__checkevent_breakpoint_x(evlist);
904}
905
906static int test__checkevent_breakpoint_r_modifier(struct perf_evlist *evlist)
907{
908 struct perf_evsel *evsel = list_entry(evlist->entries.next,
909 struct perf_evsel, node);
910
911 TEST_ASSERT_VAL("wrong exclude_user", evsel->attr.exclude_user);
912 TEST_ASSERT_VAL("wrong exclude_kernel", evsel->attr.exclude_kernel);
913 TEST_ASSERT_VAL("wrong exclude_hv", !evsel->attr.exclude_hv);
914 TEST_ASSERT_VAL("wrong precise_ip", evsel->attr.precise_ip);
915
916 return test__checkevent_breakpoint_r(evlist);
917}
918
919static int test__checkevent_breakpoint_w_modifier(struct perf_evlist *evlist)
920{
921 struct perf_evsel *evsel = list_entry(evlist->entries.next,
922 struct perf_evsel, node);
923
924 TEST_ASSERT_VAL("wrong exclude_user", !evsel->attr.exclude_user);
925 TEST_ASSERT_VAL("wrong exclude_kernel", evsel->attr.exclude_kernel);
926 TEST_ASSERT_VAL("wrong exclude_hv", evsel->attr.exclude_hv);
927 TEST_ASSERT_VAL("wrong precise_ip", evsel->attr.precise_ip);
928
929 return test__checkevent_breakpoint_w(evlist);
930}
931
932static int test__checkevent_pmu(struct perf_evlist *evlist)
933{
934
935 struct perf_evsel *evsel = list_entry(evlist->entries.next,
936 struct perf_evsel, node);
937
938 TEST_ASSERT_VAL("wrong number of entries", 1 == evlist->nr_entries);
939 TEST_ASSERT_VAL("wrong type", PERF_TYPE_RAW == evsel->attr.type);
940 TEST_ASSERT_VAL("wrong config", 10 == evsel->attr.config);
941 TEST_ASSERT_VAL("wrong config1", 1 == evsel->attr.config1);
942 TEST_ASSERT_VAL("wrong config2", 3 == evsel->attr.config2);
943 TEST_ASSERT_VAL("wrong period", 1000 == evsel->attr.sample_period);
944
945 return 0;
946}
947
948static int test__checkevent_list(struct perf_evlist *evlist)
949{
950 struct perf_evsel *evsel;
951
952 TEST_ASSERT_VAL("wrong number of entries", 3 == evlist->nr_entries);
953
954 /* r1 */
955 evsel = list_entry(evlist->entries.next, struct perf_evsel, node);
956 TEST_ASSERT_VAL("wrong type", PERF_TYPE_RAW == evsel->attr.type);
957 TEST_ASSERT_VAL("wrong config", 1 == evsel->attr.config);
958 TEST_ASSERT_VAL("wrong config1", 0 == evsel->attr.config1);
959 TEST_ASSERT_VAL("wrong config2", 0 == evsel->attr.config2);
960 TEST_ASSERT_VAL("wrong exclude_user", !evsel->attr.exclude_user);
961 TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->attr.exclude_kernel);
962 TEST_ASSERT_VAL("wrong exclude_hv", !evsel->attr.exclude_hv);
963 TEST_ASSERT_VAL("wrong precise_ip", !evsel->attr.precise_ip);
964
965 /* syscalls:sys_enter_open:k */
966 evsel = list_entry(evsel->node.next, struct perf_evsel, node);
967 TEST_ASSERT_VAL("wrong type", PERF_TYPE_TRACEPOINT == evsel->attr.type);
968 TEST_ASSERT_VAL("wrong sample_type",
969 (PERF_SAMPLE_RAW | PERF_SAMPLE_TIME | PERF_SAMPLE_CPU) ==
970 evsel->attr.sample_type);
971 TEST_ASSERT_VAL("wrong sample_period", 1 == evsel->attr.sample_period);
972 TEST_ASSERT_VAL("wrong exclude_user", evsel->attr.exclude_user);
973 TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->attr.exclude_kernel);
974 TEST_ASSERT_VAL("wrong exclude_hv", evsel->attr.exclude_hv);
975 TEST_ASSERT_VAL("wrong precise_ip", !evsel->attr.precise_ip);
976
977 /* 1:1:hp */
978 evsel = list_entry(evsel->node.next, struct perf_evsel, node);
979 TEST_ASSERT_VAL("wrong type", 1 == evsel->attr.type);
980 TEST_ASSERT_VAL("wrong config", 1 == evsel->attr.config);
981 TEST_ASSERT_VAL("wrong exclude_user", evsel->attr.exclude_user);
982 TEST_ASSERT_VAL("wrong exclude_kernel", evsel->attr.exclude_kernel);
983 TEST_ASSERT_VAL("wrong exclude_hv", !evsel->attr.exclude_hv);
984 TEST_ASSERT_VAL("wrong precise_ip", evsel->attr.precise_ip);
985
986 return 0;
987}
988
859static struct test__event_st { 989static struct test__event_st {
860 const char *name; 990 const char *name;
861 __u32 type; 991 __u32 type;
@@ -870,7 +1000,7 @@ static struct test__event_st {
870 .check = test__checkevent_tracepoint_multi, 1000 .check = test__checkevent_tracepoint_multi,
871 }, 1001 },
872 { 1002 {
873 .name = "r1", 1003 .name = "r1a",
874 .check = test__checkevent_raw, 1004 .check = test__checkevent_raw,
875 }, 1005 },
876 { 1006 {
@@ -882,6 +1012,10 @@ static struct test__event_st {
882 .check = test__checkevent_symbolic_name, 1012 .check = test__checkevent_symbolic_name,
883 }, 1013 },
884 { 1014 {
1015 .name = "cycles/period=100000,config2/",
1016 .check = test__checkevent_symbolic_name_config,
1017 },
1018 {
885 .name = "faults", 1019 .name = "faults",
886 .check = test__checkevent_symbolic_alias, 1020 .check = test__checkevent_symbolic_alias,
887 }, 1021 },
@@ -914,7 +1048,7 @@ static struct test__event_st {
914 .check = test__checkevent_tracepoint_multi_modifier, 1048 .check = test__checkevent_tracepoint_multi_modifier,
915 }, 1049 },
916 { 1050 {
917 .name = "r1:kp", 1051 .name = "r1a:kp",
918 .check = test__checkevent_raw_modifier, 1052 .check = test__checkevent_raw_modifier,
919 }, 1053 },
920 { 1054 {
@@ -933,6 +1067,30 @@ static struct test__event_st {
933 .name = "L1-dcache-load-miss:kp", 1067 .name = "L1-dcache-load-miss:kp",
934 .check = test__checkevent_genhw_modifier, 1068 .check = test__checkevent_genhw_modifier,
935 }, 1069 },
1070 {
1071 .name = "mem:0:u",
1072 .check = test__checkevent_breakpoint_modifier,
1073 },
1074 {
1075 .name = "mem:0:x:k",
1076 .check = test__checkevent_breakpoint_x_modifier,
1077 },
1078 {
1079 .name = "mem:0:r:hp",
1080 .check = test__checkevent_breakpoint_r_modifier,
1081 },
1082 {
1083 .name = "mem:0:w:up",
1084 .check = test__checkevent_breakpoint_w_modifier,
1085 },
1086 {
1087 .name = "cpu/config=10,config1,config2=3,period=1000/u",
1088 .check = test__checkevent_pmu,
1089 },
1090 {
1091 .name = "r1,syscalls:sys_enter_open:k,1:1:hp",
1092 .check = test__checkevent_list,
1093 },
936}; 1094};
937 1095
938#define TEST__EVENTS_CNT (sizeof(test__events) / sizeof(struct test__event_st)) 1096#define TEST__EVENTS_CNT (sizeof(test__events) / sizeof(struct test__event_st))
@@ -958,10 +1116,9 @@ static int test__parse_events(void)
958 } 1116 }
959 1117
960 ret = e->check(evlist); 1118 ret = e->check(evlist);
1119 perf_evlist__delete(evlist);
961 if (ret) 1120 if (ret)
962 break; 1121 break;
963
964 perf_evlist__delete(evlist);
965 } 1122 }
966 1123
967 return ret; 1124 return ret;
@@ -1008,12 +1165,9 @@ realloc:
1008static int test__PERF_RECORD(void) 1165static int test__PERF_RECORD(void)
1009{ 1166{
1010 struct perf_record_opts opts = { 1167 struct perf_record_opts opts = {
1011 .target_pid = -1,
1012 .target_tid = -1,
1013 .no_delay = true, 1168 .no_delay = true,
1014 .freq = 10, 1169 .freq = 10,
1015 .mmap_pages = 256, 1170 .mmap_pages = 256,
1016 .sample_id_all_avail = true,
1017 }; 1171 };
1018 cpu_set_t *cpu_mask = NULL; 1172 cpu_set_t *cpu_mask = NULL;
1019 size_t cpu_mask_size = 0; 1173 size_t cpu_mask_size = 0;
@@ -1054,7 +1208,7 @@ static int test__PERF_RECORD(void)
1054 * we're monitoring, the one forked there. 1208 * we're monitoring, the one forked there.
1055 */ 1209 */
1056 err = perf_evlist__create_maps(evlist, opts.target_pid, 1210 err = perf_evlist__create_maps(evlist, opts.target_pid,
1057 opts.target_tid, opts.cpu_list); 1211 opts.target_tid, UINT_MAX, opts.cpu_list);
1058 if (err < 0) { 1212 if (err < 0) {
1059 pr_debug("Not enough memory to create thread/cpu maps\n"); 1213 pr_debug("Not enough memory to create thread/cpu maps\n");
1060 goto out_delete_evlist; 1214 goto out_delete_evlist;
@@ -1296,6 +1450,178 @@ out:
1296 return (err < 0 || errs > 0) ? -1 : 0; 1450 return (err < 0 || errs > 0) ? -1 : 0;
1297} 1451}
1298 1452
1453
1454#if defined(__x86_64__) || defined(__i386__)
1455
1456#define barrier() asm volatile("" ::: "memory")
1457
1458static u64 rdpmc(unsigned int counter)
1459{
1460 unsigned int low, high;
1461
1462 asm volatile("rdpmc" : "=a" (low), "=d" (high) : "c" (counter));
1463
1464 return low | ((u64)high) << 32;
1465}
1466
1467static u64 rdtsc(void)
1468{
1469 unsigned int low, high;
1470
1471 asm volatile("rdtsc" : "=a" (low), "=d" (high));
1472
1473 return low | ((u64)high) << 32;
1474}
1475
1476static u64 mmap_read_self(void *addr)
1477{
1478 struct perf_event_mmap_page *pc = addr;
1479 u32 seq, idx, time_mult = 0, time_shift = 0;
1480 u64 count, cyc = 0, time_offset = 0, enabled, running, delta;
1481
1482 do {
1483 seq = pc->lock;
1484 barrier();
1485
1486 enabled = pc->time_enabled;
1487 running = pc->time_running;
1488
1489 if (enabled != running) {
1490 cyc = rdtsc();
1491 time_mult = pc->time_mult;
1492 time_shift = pc->time_shift;
1493 time_offset = pc->time_offset;
1494 }
1495
1496 idx = pc->index;
1497 count = pc->offset;
1498 if (idx)
1499 count += rdpmc(idx - 1);
1500
1501 barrier();
1502 } while (pc->lock != seq);
1503
1504 if (enabled != running) {
1505 u64 quot, rem;
1506
1507 quot = (cyc >> time_shift);
1508 rem = cyc & ((1 << time_shift) - 1);
1509 delta = time_offset + quot * time_mult +
1510 ((rem * time_mult) >> time_shift);
1511
1512 enabled += delta;
1513 if (idx)
1514 running += delta;
1515
1516 quot = count / running;
1517 rem = count % running;
1518 count = quot * enabled + (rem * enabled) / running;
1519 }
1520
1521 return count;
1522}
1523
1524/*
1525 * If the RDPMC instruction faults then signal this back to the test parent task:
1526 */
1527static void segfault_handler(int sig __used, siginfo_t *info __used, void *uc __used)
1528{
1529 exit(-1);
1530}
1531
1532static int __test__rdpmc(void)
1533{
1534 long page_size = sysconf(_SC_PAGE_SIZE);
1535 volatile int tmp = 0;
1536 u64 i, loops = 1000;
1537 int n;
1538 int fd;
1539 void *addr;
1540 struct perf_event_attr attr = {
1541 .type = PERF_TYPE_HARDWARE,
1542 .config = PERF_COUNT_HW_INSTRUCTIONS,
1543 .exclude_kernel = 1,
1544 };
1545 u64 delta_sum = 0;
1546 struct sigaction sa;
1547
1548 sigfillset(&sa.sa_mask);
1549 sa.sa_sigaction = segfault_handler;
1550 sigaction(SIGSEGV, &sa, NULL);
1551
1552 fprintf(stderr, "\n\n");
1553
1554 fd = sys_perf_event_open(&attr, 0, -1, -1, 0);
1555 if (fd < 0) {
1556 die("Error: sys_perf_event_open() syscall returned "
1557 "with %d (%s)\n", fd, strerror(errno));
1558 }
1559
1560 addr = mmap(NULL, page_size, PROT_READ, MAP_SHARED, fd, 0);
1561 if (addr == (void *)(-1)) {
1562 die("Error: mmap() syscall returned "
1563 "with (%s)\n", strerror(errno));
1564 }
1565
1566 for (n = 0; n < 6; n++) {
1567 u64 stamp, now, delta;
1568
1569 stamp = mmap_read_self(addr);
1570
1571 for (i = 0; i < loops; i++)
1572 tmp++;
1573
1574 now = mmap_read_self(addr);
1575 loops *= 10;
1576
1577 delta = now - stamp;
1578 fprintf(stderr, "%14d: %14Lu\n", n, (long long)delta);
1579
1580 delta_sum += delta;
1581 }
1582
1583 munmap(addr, page_size);
1584 close(fd);
1585
1586 fprintf(stderr, " ");
1587
1588 if (!delta_sum)
1589 return -1;
1590
1591 return 0;
1592}
1593
1594static int test__rdpmc(void)
1595{
1596 int status = 0;
1597 int wret = 0;
1598 int ret;
1599 int pid;
1600
1601 pid = fork();
1602 if (pid < 0)
1603 return -1;
1604
1605 if (!pid) {
1606 ret = __test__rdpmc();
1607
1608 exit(ret);
1609 }
1610
1611 wret = waitpid(pid, &status, 0);
1612 if (wret < 0 || status)
1613 return -1;
1614
1615 return 0;
1616}
1617
1618#endif
1619
1620static int test__perf_pmu(void)
1621{
1622 return perf_pmu__test();
1623}
1624
1299static struct test { 1625static struct test {
1300 const char *desc; 1626 const char *desc;
1301 int (*func)(void); 1627 int (*func)(void);
@@ -1320,11 +1646,21 @@ static struct test {
1320 .desc = "parse events tests", 1646 .desc = "parse events tests",
1321 .func = test__parse_events, 1647 .func = test__parse_events,
1322 }, 1648 },
1649#if defined(__x86_64__) || defined(__i386__)
1650 {
1651 .desc = "x86 rdpmc test",
1652 .func = test__rdpmc,
1653 },
1654#endif
1323 { 1655 {
1324 .desc = "Validate PERF_RECORD_* events & perf_sample fields", 1656 .desc = "Validate PERF_RECORD_* events & perf_sample fields",
1325 .func = test__PERF_RECORD, 1657 .func = test__PERF_RECORD,
1326 }, 1658 },
1327 { 1659 {
1660 .desc = "Test perf pmu format parsing",
1661 .func = test__perf_pmu,
1662 },
1663 {
1328 .func = NULL, 1664 .func = NULL,
1329 }, 1665 },
1330}; 1666};
@@ -1412,7 +1748,5 @@ int cmd_test(int argc, const char **argv, const char *prefix __used)
1412 if (symbol__init() < 0) 1748 if (symbol__init() < 0)
1413 return -1; 1749 return -1;
1414 1750
1415 setup_pager();
1416
1417 return __cmd_test(argc, argv); 1751 return __cmd_test(argc, argv);
1418} 1752}
diff --git a/tools/perf/builtin-top.c b/tools/perf/builtin-top.c
index ecff31257eb3..e3c63aef8efc 100644
--- a/tools/perf/builtin-top.c
+++ b/tools/perf/builtin-top.c
@@ -64,7 +64,6 @@
64#include <linux/unistd.h> 64#include <linux/unistd.h>
65#include <linux/types.h> 65#include <linux/types.h>
66 66
67
68void get_term_dimensions(struct winsize *ws) 67void get_term_dimensions(struct winsize *ws)
69{ 68{
70 char *s = getenv("LINES"); 69 char *s = getenv("LINES");
@@ -544,10 +543,20 @@ static void perf_top__sort_new_samples(void *arg)
544 543
545static void *display_thread_tui(void *arg) 544static void *display_thread_tui(void *arg)
546{ 545{
546 struct perf_evsel *pos;
547 struct perf_top *top = arg; 547 struct perf_top *top = arg;
548 const char *help = "For a higher level overview, try: perf top --sort comm,dso"; 548 const char *help = "For a higher level overview, try: perf top --sort comm,dso";
549 549
550 perf_top__sort_new_samples(top); 550 perf_top__sort_new_samples(top);
551
552 /*
553 * Initialize the uid_filter_str, in the future the TUI will allow
554 * Zooming in/out UIDs. For now juse use whatever the user passed
555 * via --uid.
556 */
557 list_for_each_entry(pos, &top->evlist->entries, node)
558 pos->hists.uid_filter_str = top->uid_str;
559
551 perf_evlist__tui_browse_hists(top->evlist, help, 560 perf_evlist__tui_browse_hists(top->evlist, help,
552 perf_top__sort_new_samples, 561 perf_top__sort_new_samples,
553 top, top->delay_secs); 562 top, top->delay_secs);
@@ -668,6 +677,12 @@ static void perf_event__process_sample(struct perf_tool *tool,
668 return; 677 return;
669 } 678 }
670 679
680 if (!machine) {
681 pr_err("%u unprocessable samples recorded.",
682 top->session->hists.stats.nr_unprocessable_samples++);
683 return;
684 }
685
671 if (event->header.misc & PERF_RECORD_MISC_EXACT_IP) 686 if (event->header.misc & PERF_RECORD_MISC_EXACT_IP)
672 top->exact_samples++; 687 top->exact_samples++;
673 688
@@ -861,7 +876,7 @@ fallback_missing_features:
861 if (top->exclude_guest_missing) 876 if (top->exclude_guest_missing)
862 attr->exclude_guest = attr->exclude_host = 0; 877 attr->exclude_guest = attr->exclude_host = 0;
863retry_sample_id: 878retry_sample_id:
864 attr->sample_id_all = top->sample_id_all_avail ? 1 : 0; 879 attr->sample_id_all = top->sample_id_all_missing ? 0 : 1;
865try_again: 880try_again:
866 if (perf_evsel__open(counter, top->evlist->cpus, 881 if (perf_evsel__open(counter, top->evlist->cpus,
867 top->evlist->threads, top->group, 882 top->evlist->threads, top->group,
@@ -878,11 +893,11 @@ try_again:
878 "guest or host samples.\n"); 893 "guest or host samples.\n");
879 top->exclude_guest_missing = true; 894 top->exclude_guest_missing = true;
880 goto fallback_missing_features; 895 goto fallback_missing_features;
881 } else if (top->sample_id_all_avail) { 896 } else if (!top->sample_id_all_missing) {
882 /* 897 /*
883 * Old kernel, no attr->sample_id_type_all field 898 * Old kernel, no attr->sample_id_type_all field
884 */ 899 */
885 top->sample_id_all_avail = false; 900 top->sample_id_all_missing = true;
886 goto retry_sample_id; 901 goto retry_sample_id;
887 } 902 }
888 } 903 }
@@ -967,7 +982,7 @@ static int __cmd_top(struct perf_top *top)
967 if (ret) 982 if (ret)
968 goto out_delete; 983 goto out_delete;
969 984
970 if (top->target_tid != -1) 985 if (top->target_tid || top->uid != UINT_MAX)
971 perf_event__synthesize_thread_map(&top->tool, top->evlist->threads, 986 perf_event__synthesize_thread_map(&top->tool, top->evlist->threads,
972 perf_event__process, 987 perf_event__process,
973 &top->session->host_machine); 988 &top->session->host_machine);
@@ -1105,10 +1120,8 @@ int cmd_top(int argc, const char **argv, const char *prefix __used)
1105 struct perf_top top = { 1120 struct perf_top top = {
1106 .count_filter = 5, 1121 .count_filter = 5,
1107 .delay_secs = 2, 1122 .delay_secs = 2,
1108 .target_pid = -1, 1123 .uid = UINT_MAX,
1109 .target_tid = -1,
1110 .freq = 1000, /* 1 KHz */ 1124 .freq = 1000, /* 1 KHz */
1111 .sample_id_all_avail = true,
1112 .mmap_pages = 128, 1125 .mmap_pages = 128,
1113 .sym_pcnt_filter = 5, 1126 .sym_pcnt_filter = 5,
1114 }; 1127 };
@@ -1119,9 +1132,9 @@ int cmd_top(int argc, const char **argv, const char *prefix __used)
1119 parse_events_option), 1132 parse_events_option),
1120 OPT_INTEGER('c', "count", &top.default_interval, 1133 OPT_INTEGER('c', "count", &top.default_interval,
1121 "event period to sample"), 1134 "event period to sample"),
1122 OPT_INTEGER('p', "pid", &top.target_pid, 1135 OPT_STRING('p', "pid", &top.target_pid, "pid",
1123 "profile events on existing process id"), 1136 "profile events on existing process id"),
1124 OPT_INTEGER('t', "tid", &top.target_tid, 1137 OPT_STRING('t', "tid", &top.target_tid, "tid",
1125 "profile events on existing thread id"), 1138 "profile events on existing thread id"),
1126 OPT_BOOLEAN('a', "all-cpus", &top.system_wide, 1139 OPT_BOOLEAN('a', "all-cpus", &top.system_wide,
1127 "system-wide collection from all CPUs"), 1140 "system-wide collection from all CPUs"),
@@ -1180,6 +1193,7 @@ int cmd_top(int argc, const char **argv, const char *prefix __used)
1180 "Display raw encoding of assembly instructions (default)"), 1193 "Display raw encoding of assembly instructions (default)"),
1181 OPT_STRING('M', "disassembler-style", &disassembler_style, "disassembler style", 1194 OPT_STRING('M', "disassembler-style", &disassembler_style, "disassembler style",
1182 "Specify disassembler style (e.g. -M intel for intel syntax)"), 1195 "Specify disassembler style (e.g. -M intel for intel syntax)"),
1196 OPT_STRING('u', "uid", &top.uid_str, "user", "user to profile"),
1183 OPT_END() 1197 OPT_END()
1184 }; 1198 };
1185 1199
@@ -1205,18 +1219,22 @@ int cmd_top(int argc, const char **argv, const char *prefix __used)
1205 1219
1206 setup_browser(false); 1220 setup_browser(false);
1207 1221
1222 top.uid = parse_target_uid(top.uid_str, top.target_tid, top.target_pid);
1223 if (top.uid_str != NULL && top.uid == UINT_MAX - 1)
1224 goto out_delete_evlist;
1225
1208 /* CPU and PID are mutually exclusive */ 1226 /* CPU and PID are mutually exclusive */
1209 if (top.target_tid > 0 && top.cpu_list) { 1227 if (top.target_tid && top.cpu_list) {
1210 printf("WARNING: PID switch overriding CPU\n"); 1228 printf("WARNING: PID switch overriding CPU\n");
1211 sleep(1); 1229 sleep(1);
1212 top.cpu_list = NULL; 1230 top.cpu_list = NULL;
1213 } 1231 }
1214 1232
1215 if (top.target_pid != -1) 1233 if (top.target_pid)
1216 top.target_tid = top.target_pid; 1234 top.target_tid = top.target_pid;
1217 1235
1218 if (perf_evlist__create_maps(top.evlist, top.target_pid, 1236 if (perf_evlist__create_maps(top.evlist, top.target_pid,
1219 top.target_tid, top.cpu_list) < 0) 1237 top.target_tid, top.uid, top.cpu_list) < 0)
1220 usage_with_options(top_usage, options); 1238 usage_with_options(top_usage, options);
1221 1239
1222 if (!top.evlist->nr_entries && 1240 if (!top.evlist->nr_entries &&
@@ -1280,6 +1298,7 @@ int cmd_top(int argc, const char **argv, const char *prefix __used)
1280 1298
1281 status = __cmd_top(&top); 1299 status = __cmd_top(&top);
1282 1300
1301out_delete_evlist:
1283 perf_evlist__delete(top.evlist); 1302 perf_evlist__delete(top.evlist);
1284 1303
1285 return status; 1304 return status;
diff --git a/tools/perf/config/feature-tests.mak b/tools/perf/config/feature-tests.mak
index 6170fd2531b5..d9084e03ce56 100644
--- a/tools/perf/config/feature-tests.mak
+++ b/tools/perf/config/feature-tests.mak
@@ -65,6 +65,21 @@ int main(void)
65endef 65endef
66endif 66endif
67 67
68ifndef NO_GTK2
69define SOURCE_GTK2
70#pragma GCC diagnostic ignored \"-Wstrict-prototypes\"
71#include <gtk/gtk.h>
72#pragma GCC diagnostic error \"-Wstrict-prototypes\"
73
74int main(int argc, char *argv[])
75{
76 gtk_init(&argc, &argv);
77
78 return 0;
79}
80endef
81endif
82
68ifndef NO_LIBPERL 83ifndef NO_LIBPERL
69define SOURCE_PERL_EMBED 84define SOURCE_PERL_EMBED
70#include <EXTERN.h> 85#include <EXTERN.h>
diff --git a/tools/perf/perf.h b/tools/perf/perf.h
index 3afa39ac1d40..89e3355ab173 100644
--- a/tools/perf/perf.h
+++ b/tools/perf/perf.h
@@ -173,7 +173,6 @@ sys_perf_event_open(struct perf_event_attr *attr,
173 pid_t pid, int cpu, int group_fd, 173 pid_t pid, int cpu, int group_fd,
174 unsigned long flags) 174 unsigned long flags)
175{ 175{
176 attr->size = sizeof(*attr);
177 return syscall(__NR_perf_event_open, attr, pid, cpu, 176 return syscall(__NR_perf_event_open, attr, pid, cpu,
178 group_fd, flags); 177 group_fd, flags);
179} 178}
@@ -186,14 +185,32 @@ struct ip_callchain {
186 u64 ips[0]; 185 u64 ips[0];
187}; 186};
188 187
188struct branch_flags {
189 u64 mispred:1;
190 u64 predicted:1;
191 u64 reserved:62;
192};
193
194struct branch_entry {
195 u64 from;
196 u64 to;
197 struct branch_flags flags;
198};
199
200struct branch_stack {
201 u64 nr;
202 struct branch_entry entries[0];
203};
204
189extern bool perf_host, perf_guest; 205extern bool perf_host, perf_guest;
190extern const char perf_version_string[]; 206extern const char perf_version_string[];
191 207
192void pthread__unblock_sigwinch(void); 208void pthread__unblock_sigwinch(void);
193 209
194struct perf_record_opts { 210struct perf_record_opts {
195 pid_t target_pid; 211 const char *target_pid;
196 pid_t target_tid; 212 const char *target_tid;
213 uid_t uid;
197 bool call_graph; 214 bool call_graph;
198 bool group; 215 bool group;
199 bool inherit_stat; 216 bool inherit_stat;
@@ -204,13 +221,14 @@ struct perf_record_opts {
204 bool raw_samples; 221 bool raw_samples;
205 bool sample_address; 222 bool sample_address;
206 bool sample_time; 223 bool sample_time;
207 bool sample_id_all_avail; 224 bool sample_id_all_missing;
208 bool exclude_guest_missing; 225 bool exclude_guest_missing;
209 bool system_wide; 226 bool system_wide;
210 bool period; 227 bool period;
211 unsigned int freq; 228 unsigned int freq;
212 unsigned int mmap_pages; 229 unsigned int mmap_pages;
213 unsigned int user_freq; 230 unsigned int user_freq;
231 int branch_stack;
214 u64 default_interval; 232 u64 default_interval;
215 u64 user_interval; 233 u64 user_interval;
216 const char *cpu_list; 234 const char *cpu_list;
diff --git a/tools/perf/python/twatch.py b/tools/perf/python/twatch.py
index df638c438a9f..b11cca584238 100755
--- a/tools/perf/python/twatch.py
+++ b/tools/perf/python/twatch.py
@@ -19,7 +19,7 @@ def main():
19 cpus = perf.cpu_map() 19 cpus = perf.cpu_map()
20 threads = perf.thread_map() 20 threads = perf.thread_map()
21 evsel = perf.evsel(task = 1, comm = 1, mmap = 0, 21 evsel = perf.evsel(task = 1, comm = 1, mmap = 0,
22 wakeup_events = 1, sample_period = 1, 22 wakeup_events = 1, watermark = 1,
23 sample_id_all = 1, 23 sample_id_all = 1,
24 sample_type = perf.SAMPLE_PERIOD | perf.SAMPLE_TID | perf.SAMPLE_CPU | perf.SAMPLE_TID) 24 sample_type = perf.SAMPLE_PERIOD | perf.SAMPLE_TID | perf.SAMPLE_CPU | perf.SAMPLE_TID)
25 evsel.open(cpus = cpus, threads = threads); 25 evsel.open(cpus = cpus, threads = threads);
diff --git a/tools/perf/util/annotate.c b/tools/perf/util/annotate.c
index 011ed2676604..e5a462f1d07c 100644
--- a/tools/perf/util/annotate.c
+++ b/tools/perf/util/annotate.c
@@ -315,7 +315,7 @@ fallback:
315 "Please use:\n\n" 315 "Please use:\n\n"
316 " perf buildid-cache -av vmlinux\n\n" 316 " perf buildid-cache -av vmlinux\n\n"
317 "or:\n\n" 317 "or:\n\n"
318 " --vmlinux vmlinux", 318 " --vmlinux vmlinux\n",
319 sym->name, build_id_msg ?: ""); 319 sym->name, build_id_msg ?: "");
320 goto out_free_filename; 320 goto out_free_filename;
321 } 321 }
diff --git a/tools/perf/util/bitmap.c b/tools/perf/util/bitmap.c
index 5e230acae1e9..0a1adc1111fd 100644
--- a/tools/perf/util/bitmap.c
+++ b/tools/perf/util/bitmap.c
@@ -19,3 +19,13 @@ int __bitmap_weight(const unsigned long *bitmap, int bits)
19 19
20 return w; 20 return w;
21} 21}
22
23void __bitmap_or(unsigned long *dst, const unsigned long *bitmap1,
24 const unsigned long *bitmap2, int bits)
25{
26 int k;
27 int nr = BITS_TO_LONGS(bits);
28
29 for (k = 0; k < nr; k++)
30 dst[k] = bitmap1[k] | bitmap2[k];
31}
diff --git a/tools/perf/util/cache.h b/tools/perf/util/cache.h
index fc5e5a09d5b9..8dd224df3e54 100644
--- a/tools/perf/util/cache.h
+++ b/tools/perf/util/cache.h
@@ -45,6 +45,18 @@ void setup_browser(bool fallback_to_pager);
45void exit_browser(bool wait_for_ok); 45void exit_browser(bool wait_for_ok);
46#endif 46#endif
47 47
48#ifdef NO_GTK2_SUPPORT
49static inline void perf_gtk_setup_browser(int argc __used, const char *argv[] __used, bool fallback_to_pager)
50{
51 if (fallback_to_pager)
52 setup_pager();
53}
54static inline void perf_gtk_exit_browser(bool wait_for_ok __used) {}
55#else
56void perf_gtk_setup_browser(int argc, const char *argv[], bool fallback_to_pager);
57void perf_gtk_exit_browser(bool wait_for_ok);
58#endif
59
48char *alias_lookup(const char *alias); 60char *alias_lookup(const char *alias);
49int split_cmdline(char *cmdline, const char ***argv); 61int split_cmdline(char *cmdline, const char ***argv);
50 62
diff --git a/tools/perf/util/cpumap.c b/tools/perf/util/cpumap.c
index 6893eec693ab..adc72f09914d 100644
--- a/tools/perf/util/cpumap.c
+++ b/tools/perf/util/cpumap.c
@@ -166,6 +166,17 @@ out:
166 return cpus; 166 return cpus;
167} 167}
168 168
169size_t cpu_map__fprintf(struct cpu_map *map, FILE *fp)
170{
171 int i;
172 size_t printed = fprintf(fp, "%d cpu%s: ",
173 map->nr, map->nr > 1 ? "s" : "");
174 for (i = 0; i < map->nr; ++i)
175 printed += fprintf(fp, "%s%d", i ? ", " : "", map->map[i]);
176
177 return printed + fprintf(fp, "\n");
178}
179
169struct cpu_map *cpu_map__dummy_new(void) 180struct cpu_map *cpu_map__dummy_new(void)
170{ 181{
171 struct cpu_map *cpus = malloc(sizeof(*cpus) + sizeof(int)); 182 struct cpu_map *cpus = malloc(sizeof(*cpus) + sizeof(int));
diff --git a/tools/perf/util/cpumap.h b/tools/perf/util/cpumap.h
index 072c0a374794..c41518573c6a 100644
--- a/tools/perf/util/cpumap.h
+++ b/tools/perf/util/cpumap.h
@@ -1,6 +1,8 @@
1#ifndef __PERF_CPUMAP_H 1#ifndef __PERF_CPUMAP_H
2#define __PERF_CPUMAP_H 2#define __PERF_CPUMAP_H
3 3
4#include <stdio.h>
5
4struct cpu_map { 6struct cpu_map {
5 int nr; 7 int nr;
6 int map[]; 8 int map[];
@@ -10,4 +12,6 @@ struct cpu_map *cpu_map__new(const char *cpu_list);
10struct cpu_map *cpu_map__dummy_new(void); 12struct cpu_map *cpu_map__dummy_new(void);
11void cpu_map__delete(struct cpu_map *map); 13void cpu_map__delete(struct cpu_map *map);
12 14
15size_t cpu_map__fprintf(struct cpu_map *map, FILE *fp);
16
13#endif /* __PERF_CPUMAP_H */ 17#endif /* __PERF_CPUMAP_H */
diff --git a/tools/perf/util/ctype.c b/tools/perf/util/ctype.c
index 35073621e5de..aada3ac5e891 100644
--- a/tools/perf/util/ctype.c
+++ b/tools/perf/util/ctype.c
@@ -3,7 +3,7 @@
3 * 3 *
4 * No surprises, and works with signed and unsigned chars. 4 * No surprises, and works with signed and unsigned chars.
5 */ 5 */
6#include "cache.h" 6#include "util.h"
7 7
8enum { 8enum {
9 S = GIT_SPACE, 9 S = GIT_SPACE,
diff --git a/tools/perf/util/debugfs.c b/tools/perf/util/debugfs.c
index ffc35e748e89..dd8b19319c03 100644
--- a/tools/perf/util/debugfs.c
+++ b/tools/perf/util/debugfs.c
@@ -15,32 +15,6 @@ static const char *debugfs_known_mountpoints[] = {
15 0, 15 0,
16}; 16};
17 17
18/* use this to force a umount */
19void debugfs_force_cleanup(void)
20{
21 debugfs_find_mountpoint();
22 debugfs_premounted = 0;
23 debugfs_umount();
24}
25
26/* construct a full path to a debugfs element */
27int debugfs_make_path(const char *element, char *buffer, int size)
28{
29 int len;
30
31 if (strlen(debugfs_mountpoint) == 0) {
32 buffer[0] = '\0';
33 return -1;
34 }
35
36 len = strlen(debugfs_mountpoint) + strlen(element) + 1;
37 if (len >= size)
38 return len+1;
39
40 snprintf(buffer, size-1, "%s/%s", debugfs_mountpoint, element);
41 return 0;
42}
43
44static int debugfs_found; 18static int debugfs_found;
45 19
46/* find the path to the mounted debugfs */ 20/* find the path to the mounted debugfs */
@@ -97,17 +71,6 @@ int debugfs_valid_mountpoint(const char *debugfs)
97 return 0; 71 return 0;
98} 72}
99 73
100
101int debugfs_valid_entry(const char *path)
102{
103 struct stat st;
104
105 if (stat(path, &st))
106 return -errno;
107
108 return 0;
109}
110
111static void debugfs_set_tracing_events_path(const char *mountpoint) 74static void debugfs_set_tracing_events_path(const char *mountpoint)
112{ 75{
113 snprintf(tracing_events_path, sizeof(tracing_events_path), "%s/%s", 76 snprintf(tracing_events_path, sizeof(tracing_events_path), "%s/%s",
@@ -149,107 +112,3 @@ void debugfs_set_path(const char *mountpoint)
149 snprintf(debugfs_mountpoint, sizeof(debugfs_mountpoint), "%s", mountpoint); 112 snprintf(debugfs_mountpoint, sizeof(debugfs_mountpoint), "%s", mountpoint);
150 debugfs_set_tracing_events_path(mountpoint); 113 debugfs_set_tracing_events_path(mountpoint);
151} 114}
152
153/* umount the debugfs */
154
155int debugfs_umount(void)
156{
157 char umountcmd[128];
158 int ret;
159
160 /* if it was already mounted, leave it */
161 if (debugfs_premounted)
162 return 0;
163
164 /* make sure it's a valid mount point */
165 ret = debugfs_valid_mountpoint(debugfs_mountpoint);
166 if (ret)
167 return ret;
168
169 snprintf(umountcmd, sizeof(umountcmd),
170 "/bin/umount %s", debugfs_mountpoint);
171 return system(umountcmd);
172}
173
174int debugfs_write(const char *entry, const char *value)
175{
176 char path[PATH_MAX + 1];
177 int ret, count;
178 int fd;
179
180 /* construct the path */
181 snprintf(path, sizeof(path), "%s/%s", debugfs_mountpoint, entry);
182
183 /* verify that it exists */
184 ret = debugfs_valid_entry(path);
185 if (ret)
186 return ret;
187
188 /* get how many chars we're going to write */
189 count = strlen(value);
190
191 /* open the debugfs entry */
192 fd = open(path, O_RDWR);
193 if (fd < 0)
194 return -errno;
195
196 while (count > 0) {
197 /* write it */
198 ret = write(fd, value, count);
199 if (ret <= 0) {
200 if (ret == EAGAIN)
201 continue;
202 close(fd);
203 return -errno;
204 }
205 count -= ret;
206 }
207
208 /* close it */
209 close(fd);
210
211 /* return success */
212 return 0;
213}
214
215/*
216 * read a debugfs entry
217 * returns the number of chars read or a negative errno
218 */
219int debugfs_read(const char *entry, char *buffer, size_t size)
220{
221 char path[PATH_MAX + 1];
222 int ret;
223 int fd;
224
225 /* construct the path */
226 snprintf(path, sizeof(path), "%s/%s", debugfs_mountpoint, entry);
227
228 /* verify that it exists */
229 ret = debugfs_valid_entry(path);
230 if (ret)
231 return ret;
232
233 /* open the debugfs entry */
234 fd = open(path, O_RDONLY);
235 if (fd < 0)
236 return -errno;
237
238 do {
239 /* read it */
240 ret = read(fd, buffer, size);
241 if (ret == 0) {
242 close(fd);
243 return EOF;
244 }
245 } while (ret < 0 && errno == EAGAIN);
246
247 /* close it */
248 close(fd);
249
250 /* make *sure* there's a null character at the end */
251 buffer[ret] = '\0';
252
253 /* return the number of chars read */
254 return ret;
255}
diff --git a/tools/perf/util/debugfs.h b/tools/perf/util/debugfs.h
index 4a878f735eb0..68f3e87ec57f 100644
--- a/tools/perf/util/debugfs.h
+++ b/tools/perf/util/debugfs.h
@@ -3,14 +3,8 @@
3 3
4const char *debugfs_find_mountpoint(void); 4const char *debugfs_find_mountpoint(void);
5int debugfs_valid_mountpoint(const char *debugfs); 5int debugfs_valid_mountpoint(const char *debugfs);
6int debugfs_valid_entry(const char *path);
7char *debugfs_mount(const char *mountpoint); 6char *debugfs_mount(const char *mountpoint);
8int debugfs_umount(void);
9void debugfs_set_path(const char *mountpoint); 7void debugfs_set_path(const char *mountpoint);
10int debugfs_write(const char *entry, const char *value);
11int debugfs_read(const char *entry, char *buffer, size_t size);
12void debugfs_force_cleanup(void);
13int debugfs_make_path(const char *element, char *buffer, int size);
14 8
15extern char debugfs_mountpoint[]; 9extern char debugfs_mountpoint[];
16extern char tracing_events_path[]; 10extern char tracing_events_path[];
diff --git a/tools/perf/util/event.h b/tools/perf/util/event.h
index cbdeaad9c5e5..1b197280c621 100644
--- a/tools/perf/util/event.h
+++ b/tools/perf/util/event.h
@@ -81,6 +81,7 @@ struct perf_sample {
81 u32 raw_size; 81 u32 raw_size;
82 void *raw_data; 82 void *raw_data;
83 struct ip_callchain *callchain; 83 struct ip_callchain *callchain;
84 struct branch_stack *branch_stack;
84}; 85};
85 86
86#define BUILD_ID_SIZE 20 87#define BUILD_ID_SIZE 20
diff --git a/tools/perf/util/evlist.c b/tools/perf/util/evlist.c
index ea32a061f1c8..1986d8051bd1 100644
--- a/tools/perf/util/evlist.c
+++ b/tools/perf/util/evlist.c
@@ -51,13 +51,15 @@ struct perf_evlist *perf_evlist__new(struct cpu_map *cpus,
51void perf_evlist__config_attrs(struct perf_evlist *evlist, 51void perf_evlist__config_attrs(struct perf_evlist *evlist,
52 struct perf_record_opts *opts) 52 struct perf_record_opts *opts)
53{ 53{
54 struct perf_evsel *evsel; 54 struct perf_evsel *evsel, *first;
55 55
56 if (evlist->cpus->map[0] < 0) 56 if (evlist->cpus->map[0] < 0)
57 opts->no_inherit = true; 57 opts->no_inherit = true;
58 58
59 first = list_entry(evlist->entries.next, struct perf_evsel, node);
60
59 list_for_each_entry(evsel, &evlist->entries, node) { 61 list_for_each_entry(evsel, &evlist->entries, node) {
60 perf_evsel__config(evsel, opts); 62 perf_evsel__config(evsel, opts, first);
61 63
62 if (evlist->nr_entries > 1) 64 if (evlist->nr_entries > 1)
63 evsel->attr.sample_type |= PERF_SAMPLE_ID; 65 evsel->attr.sample_type |= PERF_SAMPLE_ID;
@@ -97,9 +99,9 @@ void perf_evlist__add(struct perf_evlist *evlist, struct perf_evsel *entry)
97 ++evlist->nr_entries; 99 ++evlist->nr_entries;
98} 100}
99 101
100static void perf_evlist__splice_list_tail(struct perf_evlist *evlist, 102void perf_evlist__splice_list_tail(struct perf_evlist *evlist,
101 struct list_head *list, 103 struct list_head *list,
102 int nr_entries) 104 int nr_entries)
103{ 105{
104 list_splice_tail(list, &evlist->entries); 106 list_splice_tail(list, &evlist->entries);
105 evlist->nr_entries += nr_entries; 107 evlist->nr_entries += nr_entries;
@@ -597,15 +599,15 @@ int perf_evlist__mmap(struct perf_evlist *evlist, unsigned int pages,
597 return perf_evlist__mmap_per_cpu(evlist, prot, mask); 599 return perf_evlist__mmap_per_cpu(evlist, prot, mask);
598} 600}
599 601
600int perf_evlist__create_maps(struct perf_evlist *evlist, pid_t target_pid, 602int perf_evlist__create_maps(struct perf_evlist *evlist, const char *target_pid,
601 pid_t target_tid, const char *cpu_list) 603 const char *target_tid, uid_t uid, const char *cpu_list)
602{ 604{
603 evlist->threads = thread_map__new(target_pid, target_tid); 605 evlist->threads = thread_map__new_str(target_pid, target_tid, uid);
604 606
605 if (evlist->threads == NULL) 607 if (evlist->threads == NULL)
606 return -1; 608 return -1;
607 609
608 if (cpu_list == NULL && target_tid != -1) 610 if (uid != UINT_MAX || (cpu_list == NULL && target_tid))
609 evlist->cpus = cpu_map__dummy_new(); 611 evlist->cpus = cpu_map__dummy_new();
610 else 612 else
611 evlist->cpus = cpu_map__new(cpu_list); 613 evlist->cpus = cpu_map__new(cpu_list);
@@ -765,6 +767,7 @@ out_err:
765 list_for_each_entry_reverse(evsel, &evlist->entries, node) 767 list_for_each_entry_reverse(evsel, &evlist->entries, node)
766 perf_evsel__close(evsel, ncpus, nthreads); 768 perf_evsel__close(evsel, ncpus, nthreads);
767 769
770 errno = -err;
768 return err; 771 return err;
769} 772}
770 773
@@ -824,7 +827,7 @@ int perf_evlist__prepare_workload(struct perf_evlist *evlist,
824 exit(-1); 827 exit(-1);
825 } 828 }
826 829
827 if (!opts->system_wide && opts->target_tid == -1 && opts->target_pid == -1) 830 if (!opts->system_wide && !opts->target_tid && !opts->target_pid)
828 evlist->threads->map[0] = evlist->workload.pid; 831 evlist->threads->map[0] = evlist->workload.pid;
829 832
830 close(child_ready_pipe[1]); 833 close(child_ready_pipe[1]);
diff --git a/tools/perf/util/evlist.h b/tools/perf/util/evlist.h
index 8922aeed0467..21f1c9e57f13 100644
--- a/tools/perf/util/evlist.h
+++ b/tools/perf/util/evlist.h
@@ -106,8 +106,8 @@ static inline void perf_evlist__set_maps(struct perf_evlist *evlist,
106 evlist->threads = threads; 106 evlist->threads = threads;
107} 107}
108 108
109int perf_evlist__create_maps(struct perf_evlist *evlist, pid_t target_pid, 109int perf_evlist__create_maps(struct perf_evlist *evlist, const char *target_pid,
110 pid_t target_tid, const char *cpu_list); 110 const char *tid, uid_t uid, const char *cpu_list);
111void perf_evlist__delete_maps(struct perf_evlist *evlist); 111void perf_evlist__delete_maps(struct perf_evlist *evlist);
112int perf_evlist__set_filters(struct perf_evlist *evlist); 112int perf_evlist__set_filters(struct perf_evlist *evlist);
113 113
@@ -117,4 +117,9 @@ u16 perf_evlist__id_hdr_size(const struct perf_evlist *evlist);
117 117
118bool perf_evlist__valid_sample_type(const struct perf_evlist *evlist); 118bool perf_evlist__valid_sample_type(const struct perf_evlist *evlist);
119bool perf_evlist__valid_sample_id_all(const struct perf_evlist *evlist); 119bool perf_evlist__valid_sample_id_all(const struct perf_evlist *evlist);
120
121void perf_evlist__splice_list_tail(struct perf_evlist *evlist,
122 struct list_head *list,
123 int nr_entries);
124
120#endif /* __PERF_EVLIST_H */ 125#endif /* __PERF_EVLIST_H */
diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c
index 7132ee834e0e..d9da62a7234f 100644
--- a/tools/perf/util/evsel.c
+++ b/tools/perf/util/evsel.c
@@ -34,7 +34,7 @@ int __perf_evsel__sample_size(u64 sample_type)
34 return size; 34 return size;
35} 35}
36 36
37static void hists__init(struct hists *hists) 37void hists__init(struct hists *hists)
38{ 38{
39 memset(hists, 0, sizeof(*hists)); 39 memset(hists, 0, sizeof(*hists));
40 hists->entries_in_array[0] = hists->entries_in_array[1] = RB_ROOT; 40 hists->entries_in_array[0] = hists->entries_in_array[1] = RB_ROOT;
@@ -63,12 +63,13 @@ struct perf_evsel *perf_evsel__new(struct perf_event_attr *attr, int idx)
63 return evsel; 63 return evsel;
64} 64}
65 65
66void perf_evsel__config(struct perf_evsel *evsel, struct perf_record_opts *opts) 66void perf_evsel__config(struct perf_evsel *evsel, struct perf_record_opts *opts,
67 struct perf_evsel *first)
67{ 68{
68 struct perf_event_attr *attr = &evsel->attr; 69 struct perf_event_attr *attr = &evsel->attr;
69 int track = !evsel->idx; /* only the first counter needs these */ 70 int track = !evsel->idx; /* only the first counter needs these */
70 71
71 attr->sample_id_all = opts->sample_id_all_avail ? 1 : 0; 72 attr->sample_id_all = opts->sample_id_all_missing ? 0 : 1;
72 attr->inherit = !opts->no_inherit; 73 attr->inherit = !opts->no_inherit;
73 attr->read_format = PERF_FORMAT_TOTAL_TIME_ENABLED | 74 attr->read_format = PERF_FORMAT_TOTAL_TIME_ENABLED |
74 PERF_FORMAT_TOTAL_TIME_RUNNING | 75 PERF_FORMAT_TOTAL_TIME_RUNNING |
@@ -111,7 +112,7 @@ void perf_evsel__config(struct perf_evsel *evsel, struct perf_record_opts *opts)
111 if (opts->period) 112 if (opts->period)
112 attr->sample_type |= PERF_SAMPLE_PERIOD; 113 attr->sample_type |= PERF_SAMPLE_PERIOD;
113 114
114 if (opts->sample_id_all_avail && 115 if (!opts->sample_id_all_missing &&
115 (opts->sample_time || opts->system_wide || 116 (opts->sample_time || opts->system_wide ||
116 !opts->no_inherit || opts->cpu_list)) 117 !opts->no_inherit || opts->cpu_list))
117 attr->sample_type |= PERF_SAMPLE_TIME; 118 attr->sample_type |= PERF_SAMPLE_TIME;
@@ -126,11 +127,16 @@ void perf_evsel__config(struct perf_evsel *evsel, struct perf_record_opts *opts)
126 attr->watermark = 0; 127 attr->watermark = 0;
127 attr->wakeup_events = 1; 128 attr->wakeup_events = 1;
128 } 129 }
130 if (opts->branch_stack) {
131 attr->sample_type |= PERF_SAMPLE_BRANCH_STACK;
132 attr->branch_sample_type = opts->branch_stack;
133 }
129 134
130 attr->mmap = track; 135 attr->mmap = track;
131 attr->comm = track; 136 attr->comm = track;
132 137
133 if (opts->target_pid == -1 && opts->target_tid == -1 && !opts->system_wide) { 138 if (!opts->target_pid && !opts->target_tid && !opts->system_wide &&
139 (!opts->group || evsel == first)) {
134 attr->disabled = 1; 140 attr->disabled = 1;
135 attr->enable_on_exec = 1; 141 attr->enable_on_exec = 1;
136 } 142 }
@@ -536,7 +542,7 @@ int perf_event__parse_sample(const union perf_event *event, u64 type,
536 } 542 }
537 543
538 if (type & PERF_SAMPLE_READ) { 544 if (type & PERF_SAMPLE_READ) {
539 fprintf(stderr, "PERF_SAMPLE_READ is unsuported for now\n"); 545 fprintf(stderr, "PERF_SAMPLE_READ is unsupported for now\n");
540 return -1; 546 return -1;
541 } 547 }
542 548
@@ -576,6 +582,16 @@ int perf_event__parse_sample(const union perf_event *event, u64 type,
576 data->raw_data = (void *) pdata; 582 data->raw_data = (void *) pdata;
577 } 583 }
578 584
585 if (type & PERF_SAMPLE_BRANCH_STACK) {
586 u64 sz;
587
588 data->branch_stack = (struct branch_stack *)array;
589 array++; /* nr */
590
591 sz = data->branch_stack->nr * sizeof(struct branch_entry);
592 sz /= sizeof(u64);
593 array += sz;
594 }
579 return 0; 595 return 0;
580} 596}
581 597
diff --git a/tools/perf/util/evsel.h b/tools/perf/util/evsel.h
index 326b8e4d5035..3d6b3e4cb66b 100644
--- a/tools/perf/util/evsel.h
+++ b/tools/perf/util/evsel.h
@@ -80,7 +80,8 @@ void perf_evsel__exit(struct perf_evsel *evsel);
80void perf_evsel__delete(struct perf_evsel *evsel); 80void perf_evsel__delete(struct perf_evsel *evsel);
81 81
82void perf_evsel__config(struct perf_evsel *evsel, 82void perf_evsel__config(struct perf_evsel *evsel,
83 struct perf_record_opts *opts); 83 struct perf_record_opts *opts,
84 struct perf_evsel *first);
84 85
85int perf_evsel__alloc_fd(struct perf_evsel *evsel, int ncpus, int nthreads); 86int perf_evsel__alloc_fd(struct perf_evsel *evsel, int ncpus, int nthreads);
86int perf_evsel__alloc_id(struct perf_evsel *evsel, int ncpus, int nthreads); 87int perf_evsel__alloc_id(struct perf_evsel *evsel, int ncpus, int nthreads);
@@ -169,4 +170,6 @@ static inline int perf_evsel__sample_size(struct perf_evsel *evsel)
169 return __perf_evsel__sample_size(evsel->attr.sample_type); 170 return __perf_evsel__sample_size(evsel->attr.sample_type);
170} 171}
171 172
173void hists__init(struct hists *hists);
174
172#endif /* __PERF_EVSEL_H */ 175#endif /* __PERF_EVSEL_H */
diff --git a/tools/perf/util/gtk/browser.c b/tools/perf/util/gtk/browser.c
new file mode 100644
index 000000000000..258352a2356c
--- /dev/null
+++ b/tools/perf/util/gtk/browser.c
@@ -0,0 +1,189 @@
1#include "../evlist.h"
2#include "../cache.h"
3#include "../evsel.h"
4#include "../sort.h"
5#include "../hist.h"
6#include "gtk.h"
7
8#include <signal.h>
9
10#define MAX_COLUMNS 32
11
12void perf_gtk_setup_browser(int argc, const char *argv[],
13 bool fallback_to_pager __used)
14{
15 gtk_init(&argc, (char ***)&argv);
16}
17
18void perf_gtk_exit_browser(bool wait_for_ok __used)
19{
20 gtk_main_quit();
21}
22
23static void perf_gtk_signal(int sig)
24{
25 psignal(sig, "perf");
26 gtk_main_quit();
27}
28
29static void perf_gtk_resize_window(GtkWidget *window)
30{
31 GdkRectangle rect;
32 GdkScreen *screen;
33 int monitor;
34 int height;
35 int width;
36
37 screen = gtk_widget_get_screen(window);
38
39 monitor = gdk_screen_get_monitor_at_window(screen, window->window);
40
41 gdk_screen_get_monitor_geometry(screen, monitor, &rect);
42
43 width = rect.width * 3 / 4;
44 height = rect.height * 3 / 4;
45
46 gtk_window_resize(GTK_WINDOW(window), width, height);
47}
48
49static void perf_gtk_show_hists(GtkWidget *window, struct hists *hists)
50{
51 GType col_types[MAX_COLUMNS];
52 GtkCellRenderer *renderer;
53 struct sort_entry *se;
54 GtkListStore *store;
55 struct rb_node *nd;
56 u64 total_period;
57 GtkWidget *view;
58 int col_idx;
59 int nr_cols;
60
61 nr_cols = 0;
62
63 /* The percentage column */
64 col_types[nr_cols++] = G_TYPE_STRING;
65
66 list_for_each_entry(se, &hist_entry__sort_list, list) {
67 if (se->elide)
68 continue;
69
70 col_types[nr_cols++] = G_TYPE_STRING;
71 }
72
73 store = gtk_list_store_newv(nr_cols, col_types);
74
75 view = gtk_tree_view_new();
76
77 renderer = gtk_cell_renderer_text_new();
78
79 col_idx = 0;
80
81 /* The percentage column */
82 gtk_tree_view_insert_column_with_attributes(GTK_TREE_VIEW(view),
83 -1, "Overhead (%)",
84 renderer, "text",
85 col_idx++, NULL);
86
87 list_for_each_entry(se, &hist_entry__sort_list, list) {
88 if (se->elide)
89 continue;
90
91 gtk_tree_view_insert_column_with_attributes(GTK_TREE_VIEW(view),
92 -1, se->se_header,
93 renderer, "text",
94 col_idx++, NULL);
95 }
96
97 gtk_tree_view_set_model(GTK_TREE_VIEW(view), GTK_TREE_MODEL(store));
98
99 g_object_unref(GTK_TREE_MODEL(store));
100
101 total_period = hists->stats.total_period;
102
103 for (nd = rb_first(&hists->entries); nd; nd = rb_next(nd)) {
104 struct hist_entry *h = rb_entry(nd, struct hist_entry, rb_node);
105 GtkTreeIter iter;
106 double percent;
107 char s[512];
108
109 if (h->filtered)
110 continue;
111
112 gtk_list_store_append(store, &iter);
113
114 col_idx = 0;
115
116 percent = (h->period * 100.0) / total_period;
117
118 snprintf(s, ARRAY_SIZE(s), "%.2f", percent);
119
120 gtk_list_store_set(store, &iter, col_idx++, s, -1);
121
122 list_for_each_entry(se, &hist_entry__sort_list, list) {
123 if (se->elide)
124 continue;
125
126 se->se_snprintf(h, s, ARRAY_SIZE(s),
127 hists__col_len(hists, se->se_width_idx));
128
129 gtk_list_store_set(store, &iter, col_idx++, s, -1);
130 }
131 }
132
133 gtk_container_add(GTK_CONTAINER(window), view);
134}
135
136int perf_evlist__gtk_browse_hists(struct perf_evlist *evlist,
137 const char *help __used,
138 void (*timer) (void *arg)__used,
139 void *arg __used, int delay_secs __used)
140{
141 struct perf_evsel *pos;
142 GtkWidget *notebook;
143 GtkWidget *window;
144
145 signal(SIGSEGV, perf_gtk_signal);
146 signal(SIGFPE, perf_gtk_signal);
147 signal(SIGINT, perf_gtk_signal);
148 signal(SIGQUIT, perf_gtk_signal);
149 signal(SIGTERM, perf_gtk_signal);
150
151 window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
152
153 gtk_window_set_title(GTK_WINDOW(window), "perf report");
154
155 g_signal_connect(window, "delete_event", gtk_main_quit, NULL);
156
157 notebook = gtk_notebook_new();
158
159 list_for_each_entry(pos, &evlist->entries, node) {
160 struct hists *hists = &pos->hists;
161 const char *evname = event_name(pos);
162 GtkWidget *scrolled_window;
163 GtkWidget *tab_label;
164
165 scrolled_window = gtk_scrolled_window_new(NULL, NULL);
166
167 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolled_window),
168 GTK_POLICY_AUTOMATIC,
169 GTK_POLICY_AUTOMATIC);
170
171 perf_gtk_show_hists(scrolled_window, hists);
172
173 tab_label = gtk_label_new(evname);
174
175 gtk_notebook_append_page(GTK_NOTEBOOK(notebook), scrolled_window, tab_label);
176 }
177
178 gtk_container_add(GTK_CONTAINER(window), notebook);
179
180 gtk_widget_show_all(window);
181
182 perf_gtk_resize_window(window);
183
184 gtk_window_set_position(GTK_WINDOW(window), GTK_WIN_POS_CENTER);
185
186 gtk_main();
187
188 return 0;
189}
diff --git a/tools/perf/util/gtk/gtk.h b/tools/perf/util/gtk/gtk.h
new file mode 100644
index 000000000000..75177ee04032
--- /dev/null
+++ b/tools/perf/util/gtk/gtk.h
@@ -0,0 +1,8 @@
1#ifndef _PERF_GTK_H_
2#define _PERF_GTK_H_ 1
3
4#pragma GCC diagnostic ignored "-Wstrict-prototypes"
5#include <gtk/gtk.h>
6#pragma GCC diagnostic error "-Wstrict-prototypes"
7
8#endif /* _PERF_GTK_H_ */
diff --git a/tools/perf/util/header.c b/tools/perf/util/header.c
index 14bb035c5fd9..4c7c2d73251f 100644
--- a/tools/perf/util/header.c
+++ b/tools/perf/util/header.c
@@ -63,9 +63,20 @@ char *perf_header__find_event(u64 id)
63 return NULL; 63 return NULL;
64} 64}
65 65
66static const char *__perf_magic = "PERFFILE"; 66/*
67 * magic2 = "PERFILE2"
68 * must be a numerical value to let the endianness
69 * determine the memory layout. That way we are able
70 * to detect endianness when reading the perf.data file
71 * back.
72 *
73 * we check for legacy (PERFFILE) format.
74 */
75static const char *__perf_magic1 = "PERFFILE";
76static const u64 __perf_magic2 = 0x32454c4946524550ULL;
77static const u64 __perf_magic2_sw = 0x50455246494c4532ULL;
67 78
68#define PERF_MAGIC (*(u64 *)__perf_magic) 79#define PERF_MAGIC __perf_magic2
69 80
70struct perf_file_attr { 81struct perf_file_attr {
71 struct perf_event_attr attr; 82 struct perf_event_attr attr;
@@ -1012,6 +1023,12 @@ write_it:
1012 return do_write_string(fd, buffer); 1023 return do_write_string(fd, buffer);
1013} 1024}
1014 1025
1026static int write_branch_stack(int fd __used, struct perf_header *h __used,
1027 struct perf_evlist *evlist __used)
1028{
1029 return 0;
1030}
1031
1015static void print_hostname(struct perf_header *ph, int fd, FILE *fp) 1032static void print_hostname(struct perf_header *ph, int fd, FILE *fp)
1016{ 1033{
1017 char *str = do_read_string(fd, ph); 1034 char *str = do_read_string(fd, ph);
@@ -1133,8 +1150,9 @@ static void print_event_desc(struct perf_header *ph, int fd, FILE *fp)
1133 uint64_t id; 1150 uint64_t id;
1134 void *buf = NULL; 1151 void *buf = NULL;
1135 char *str; 1152 char *str;
1136 u32 nre, sz, nr, i, j, msz; 1153 u32 nre, sz, nr, i, j;
1137 int ret; 1154 ssize_t ret;
1155 size_t msz;
1138 1156
1139 /* number of events */ 1157 /* number of events */
1140 ret = read(fd, &nre, sizeof(nre)); 1158 ret = read(fd, &nre, sizeof(nre));
@@ -1151,15 +1169,9 @@ static void print_event_desc(struct perf_header *ph, int fd, FILE *fp)
1151 if (ph->needs_swap) 1169 if (ph->needs_swap)
1152 sz = bswap_32(sz); 1170 sz = bswap_32(sz);
1153 1171
1154 /*
1155 * ensure it is at least to our ABI rev
1156 */
1157 if (sz < (u32)sizeof(attr))
1158 goto error;
1159
1160 memset(&attr, 0, sizeof(attr)); 1172 memset(&attr, 0, sizeof(attr));
1161 1173
1162 /* read entire region to sync up to next field */ 1174 /* buffer to hold on file attr struct */
1163 buf = malloc(sz); 1175 buf = malloc(sz);
1164 if (!buf) 1176 if (!buf)
1165 goto error; 1177 goto error;
@@ -1170,6 +1182,10 @@ static void print_event_desc(struct perf_header *ph, int fd, FILE *fp)
1170 1182
1171 for (i = 0 ; i < nre; i++) { 1183 for (i = 0 ; i < nre; i++) {
1172 1184
1185 /*
1186 * must read entire on-file attr struct to
1187 * sync up with layout.
1188 */
1173 ret = read(fd, buf, sz); 1189 ret = read(fd, buf, sz);
1174 if (ret != (ssize_t)sz) 1190 if (ret != (ssize_t)sz)
1175 goto error; 1191 goto error;
@@ -1305,25 +1321,204 @@ static void print_cpuid(struct perf_header *ph, int fd, FILE *fp)
1305 free(str); 1321 free(str);
1306} 1322}
1307 1323
1324static void print_branch_stack(struct perf_header *ph __used, int fd __used,
1325 FILE *fp)
1326{
1327 fprintf(fp, "# contains samples with branch stack\n");
1328}
1329
1330static int __event_process_build_id(struct build_id_event *bev,
1331 char *filename,
1332 struct perf_session *session)
1333{
1334 int err = -1;
1335 struct list_head *head;
1336 struct machine *machine;
1337 u16 misc;
1338 struct dso *dso;
1339 enum dso_kernel_type dso_type;
1340
1341 machine = perf_session__findnew_machine(session, bev->pid);
1342 if (!machine)
1343 goto out;
1344
1345 misc = bev->header.misc & PERF_RECORD_MISC_CPUMODE_MASK;
1346
1347 switch (misc) {
1348 case PERF_RECORD_MISC_KERNEL:
1349 dso_type = DSO_TYPE_KERNEL;
1350 head = &machine->kernel_dsos;
1351 break;
1352 case PERF_RECORD_MISC_GUEST_KERNEL:
1353 dso_type = DSO_TYPE_GUEST_KERNEL;
1354 head = &machine->kernel_dsos;
1355 break;
1356 case PERF_RECORD_MISC_USER:
1357 case PERF_RECORD_MISC_GUEST_USER:
1358 dso_type = DSO_TYPE_USER;
1359 head = &machine->user_dsos;
1360 break;
1361 default:
1362 goto out;
1363 }
1364
1365 dso = __dsos__findnew(head, filename);
1366 if (dso != NULL) {
1367 char sbuild_id[BUILD_ID_SIZE * 2 + 1];
1368
1369 dso__set_build_id(dso, &bev->build_id);
1370
1371 if (filename[0] == '[')
1372 dso->kernel = dso_type;
1373
1374 build_id__sprintf(dso->build_id, sizeof(dso->build_id),
1375 sbuild_id);
1376 pr_debug("build id event received for %s: %s\n",
1377 dso->long_name, sbuild_id);
1378 }
1379
1380 err = 0;
1381out:
1382 return err;
1383}
1384
1385static int perf_header__read_build_ids_abi_quirk(struct perf_header *header,
1386 int input, u64 offset, u64 size)
1387{
1388 struct perf_session *session = container_of(header, struct perf_session, header);
1389 struct {
1390 struct perf_event_header header;
1391 u8 build_id[ALIGN(BUILD_ID_SIZE, sizeof(u64))];
1392 char filename[0];
1393 } old_bev;
1394 struct build_id_event bev;
1395 char filename[PATH_MAX];
1396 u64 limit = offset + size;
1397
1398 while (offset < limit) {
1399 ssize_t len;
1400
1401 if (read(input, &old_bev, sizeof(old_bev)) != sizeof(old_bev))
1402 return -1;
1403
1404 if (header->needs_swap)
1405 perf_event_header__bswap(&old_bev.header);
1406
1407 len = old_bev.header.size - sizeof(old_bev);
1408 if (read(input, filename, len) != len)
1409 return -1;
1410
1411 bev.header = old_bev.header;
1412
1413 /*
1414 * As the pid is the missing value, we need to fill
1415 * it properly. The header.misc value give us nice hint.
1416 */
1417 bev.pid = HOST_KERNEL_ID;
1418 if (bev.header.misc == PERF_RECORD_MISC_GUEST_USER ||
1419 bev.header.misc == PERF_RECORD_MISC_GUEST_KERNEL)
1420 bev.pid = DEFAULT_GUEST_KERNEL_ID;
1421
1422 memcpy(bev.build_id, old_bev.build_id, sizeof(bev.build_id));
1423 __event_process_build_id(&bev, filename, session);
1424
1425 offset += bev.header.size;
1426 }
1427
1428 return 0;
1429}
1430
1431static int perf_header__read_build_ids(struct perf_header *header,
1432 int input, u64 offset, u64 size)
1433{
1434 struct perf_session *session = container_of(header, struct perf_session, header);
1435 struct build_id_event bev;
1436 char filename[PATH_MAX];
1437 u64 limit = offset + size, orig_offset = offset;
1438 int err = -1;
1439
1440 while (offset < limit) {
1441 ssize_t len;
1442
1443 if (read(input, &bev, sizeof(bev)) != sizeof(bev))
1444 goto out;
1445
1446 if (header->needs_swap)
1447 perf_event_header__bswap(&bev.header);
1448
1449 len = bev.header.size - sizeof(bev);
1450 if (read(input, filename, len) != len)
1451 goto out;
1452 /*
1453 * The a1645ce1 changeset:
1454 *
1455 * "perf: 'perf kvm' tool for monitoring guest performance from host"
1456 *
1457 * Added a field to struct build_id_event that broke the file
1458 * format.
1459 *
1460 * Since the kernel build-id is the first entry, process the
1461 * table using the old format if the well known
1462 * '[kernel.kallsyms]' string for the kernel build-id has the
1463 * first 4 characters chopped off (where the pid_t sits).
1464 */
1465 if (memcmp(filename, "nel.kallsyms]", 13) == 0) {
1466 if (lseek(input, orig_offset, SEEK_SET) == (off_t)-1)
1467 return -1;
1468 return perf_header__read_build_ids_abi_quirk(header, input, offset, size);
1469 }
1470
1471 __event_process_build_id(&bev, filename, session);
1472
1473 offset += bev.header.size;
1474 }
1475 err = 0;
1476out:
1477 return err;
1478}
1479
1480static int process_trace_info(struct perf_file_section *section __unused,
1481 struct perf_header *ph __unused,
1482 int feat __unused, int fd)
1483{
1484 trace_report(fd, false);
1485 return 0;
1486}
1487
1488static int process_build_id(struct perf_file_section *section,
1489 struct perf_header *ph,
1490 int feat __unused, int fd)
1491{
1492 if (perf_header__read_build_ids(ph, fd, section->offset, section->size))
1493 pr_debug("Failed to read buildids, continuing...\n");
1494 return 0;
1495}
1496
1308struct feature_ops { 1497struct feature_ops {
1309 int (*write)(int fd, struct perf_header *h, struct perf_evlist *evlist); 1498 int (*write)(int fd, struct perf_header *h, struct perf_evlist *evlist);
1310 void (*print)(struct perf_header *h, int fd, FILE *fp); 1499 void (*print)(struct perf_header *h, int fd, FILE *fp);
1500 int (*process)(struct perf_file_section *section,
1501 struct perf_header *h, int feat, int fd);
1311 const char *name; 1502 const char *name;
1312 bool full_only; 1503 bool full_only;
1313}; 1504};
1314 1505
1315#define FEAT_OPA(n, func) \ 1506#define FEAT_OPA(n, func) \
1316 [n] = { .name = #n, .write = write_##func, .print = print_##func } 1507 [n] = { .name = #n, .write = write_##func, .print = print_##func }
1508#define FEAT_OPP(n, func) \
1509 [n] = { .name = #n, .write = write_##func, .print = print_##func, \
1510 .process = process_##func }
1317#define FEAT_OPF(n, func) \ 1511#define FEAT_OPF(n, func) \
1318 [n] = { .name = #n, .write = write_##func, .print = print_##func, .full_only = true } 1512 [n] = { .name = #n, .write = write_##func, .print = print_##func, \
1513 .full_only = true }
1319 1514
1320/* feature_ops not implemented: */ 1515/* feature_ops not implemented: */
1321#define print_trace_info NULL 1516#define print_trace_info NULL
1322#define print_build_id NULL 1517#define print_build_id NULL
1323 1518
1324static const struct feature_ops feat_ops[HEADER_LAST_FEATURE] = { 1519static const struct feature_ops feat_ops[HEADER_LAST_FEATURE] = {
1325 FEAT_OPA(HEADER_TRACE_INFO, trace_info), 1520 FEAT_OPP(HEADER_TRACE_INFO, trace_info),
1326 FEAT_OPA(HEADER_BUILD_ID, build_id), 1521 FEAT_OPP(HEADER_BUILD_ID, build_id),
1327 FEAT_OPA(HEADER_HOSTNAME, hostname), 1522 FEAT_OPA(HEADER_HOSTNAME, hostname),
1328 FEAT_OPA(HEADER_OSRELEASE, osrelease), 1523 FEAT_OPA(HEADER_OSRELEASE, osrelease),
1329 FEAT_OPA(HEADER_VERSION, version), 1524 FEAT_OPA(HEADER_VERSION, version),
@@ -1336,6 +1531,7 @@ static const struct feature_ops feat_ops[HEADER_LAST_FEATURE] = {
1336 FEAT_OPA(HEADER_CMDLINE, cmdline), 1531 FEAT_OPA(HEADER_CMDLINE, cmdline),
1337 FEAT_OPF(HEADER_CPU_TOPOLOGY, cpu_topology), 1532 FEAT_OPF(HEADER_CPU_TOPOLOGY, cpu_topology),
1338 FEAT_OPF(HEADER_NUMA_TOPOLOGY, numa_topology), 1533 FEAT_OPF(HEADER_NUMA_TOPOLOGY, numa_topology),
1534 FEAT_OPA(HEADER_BRANCH_STACK, branch_stack),
1339}; 1535};
1340 1536
1341struct header_print_data { 1537struct header_print_data {
@@ -1620,24 +1816,128 @@ out_free:
1620 return err; 1816 return err;
1621} 1817}
1622 1818
1819static const int attr_file_abi_sizes[] = {
1820 [0] = PERF_ATTR_SIZE_VER0,
1821 [1] = PERF_ATTR_SIZE_VER1,
1822 0,
1823};
1824
1825/*
1826 * In the legacy file format, the magic number is not used to encode endianness.
1827 * hdr_sz was used to encode endianness. But given that hdr_sz can vary based
1828 * on ABI revisions, we need to try all combinations for all endianness to
1829 * detect the endianness.
1830 */
1831static int try_all_file_abis(uint64_t hdr_sz, struct perf_header *ph)
1832{
1833 uint64_t ref_size, attr_size;
1834 int i;
1835
1836 for (i = 0 ; attr_file_abi_sizes[i]; i++) {
1837 ref_size = attr_file_abi_sizes[i]
1838 + sizeof(struct perf_file_section);
1839 if (hdr_sz != ref_size) {
1840 attr_size = bswap_64(hdr_sz);
1841 if (attr_size != ref_size)
1842 continue;
1843
1844 ph->needs_swap = true;
1845 }
1846 pr_debug("ABI%d perf.data file detected, need_swap=%d\n",
1847 i,
1848 ph->needs_swap);
1849 return 0;
1850 }
1851 /* could not determine endianness */
1852 return -1;
1853}
1854
1855#define PERF_PIPE_HDR_VER0 16
1856
1857static const size_t attr_pipe_abi_sizes[] = {
1858 [0] = PERF_PIPE_HDR_VER0,
1859 0,
1860};
1861
1862/*
1863 * In the legacy pipe format, there is an implicit assumption that endiannesss
1864 * between host recording the samples, and host parsing the samples is the
1865 * same. This is not always the case given that the pipe output may always be
1866 * redirected into a file and analyzed on a different machine with possibly a
1867 * different endianness and perf_event ABI revsions in the perf tool itself.
1868 */
1869static int try_all_pipe_abis(uint64_t hdr_sz, struct perf_header *ph)
1870{
1871 u64 attr_size;
1872 int i;
1873
1874 for (i = 0 ; attr_pipe_abi_sizes[i]; i++) {
1875 if (hdr_sz != attr_pipe_abi_sizes[i]) {
1876 attr_size = bswap_64(hdr_sz);
1877 if (attr_size != hdr_sz)
1878 continue;
1879
1880 ph->needs_swap = true;
1881 }
1882 pr_debug("Pipe ABI%d perf.data file detected\n", i);
1883 return 0;
1884 }
1885 return -1;
1886}
1887
1888static int check_magic_endian(u64 magic, uint64_t hdr_sz,
1889 bool is_pipe, struct perf_header *ph)
1890{
1891 int ret;
1892
1893 /* check for legacy format */
1894 ret = memcmp(&magic, __perf_magic1, sizeof(magic));
1895 if (ret == 0) {
1896 pr_debug("legacy perf.data format\n");
1897 if (is_pipe)
1898 return try_all_pipe_abis(hdr_sz, ph);
1899
1900 return try_all_file_abis(hdr_sz, ph);
1901 }
1902 /*
1903 * the new magic number serves two purposes:
1904 * - unique number to identify actual perf.data files
1905 * - encode endianness of file
1906 */
1907
1908 /* check magic number with one endianness */
1909 if (magic == __perf_magic2)
1910 return 0;
1911
1912 /* check magic number with opposite endianness */
1913 if (magic != __perf_magic2_sw)
1914 return -1;
1915
1916 ph->needs_swap = true;
1917
1918 return 0;
1919}
1920
1623int perf_file_header__read(struct perf_file_header *header, 1921int perf_file_header__read(struct perf_file_header *header,
1624 struct perf_header *ph, int fd) 1922 struct perf_header *ph, int fd)
1625{ 1923{
1924 int ret;
1925
1626 lseek(fd, 0, SEEK_SET); 1926 lseek(fd, 0, SEEK_SET);
1627 1927
1628 if (readn(fd, header, sizeof(*header)) <= 0 || 1928 ret = readn(fd, header, sizeof(*header));
1629 memcmp(&header->magic, __perf_magic, sizeof(header->magic))) 1929 if (ret <= 0)
1630 return -1; 1930 return -1;
1631 1931
1632 if (header->attr_size != sizeof(struct perf_file_attr)) { 1932 if (check_magic_endian(header->magic,
1633 u64 attr_size = bswap_64(header->attr_size); 1933 header->attr_size, false, ph) < 0) {
1634 1934 pr_debug("magic/endian check failed\n");
1635 if (attr_size != sizeof(struct perf_file_attr)) 1935 return -1;
1636 return -1; 1936 }
1637 1937
1938 if (ph->needs_swap) {
1638 mem_bswap_64(header, offsetof(struct perf_file_header, 1939 mem_bswap_64(header, offsetof(struct perf_file_header,
1639 adds_features)); 1940 adds_features));
1640 ph->needs_swap = true;
1641 } 1941 }
1642 1942
1643 if (header->size != sizeof(*header)) { 1943 if (header->size != sizeof(*header)) {
@@ -1689,156 +1989,6 @@ int perf_file_header__read(struct perf_file_header *header,
1689 return 0; 1989 return 0;
1690} 1990}
1691 1991
1692static int __event_process_build_id(struct build_id_event *bev,
1693 char *filename,
1694 struct perf_session *session)
1695{
1696 int err = -1;
1697 struct list_head *head;
1698 struct machine *machine;
1699 u16 misc;
1700 struct dso *dso;
1701 enum dso_kernel_type dso_type;
1702
1703 machine = perf_session__findnew_machine(session, bev->pid);
1704 if (!machine)
1705 goto out;
1706
1707 misc = bev->header.misc & PERF_RECORD_MISC_CPUMODE_MASK;
1708
1709 switch (misc) {
1710 case PERF_RECORD_MISC_KERNEL:
1711 dso_type = DSO_TYPE_KERNEL;
1712 head = &machine->kernel_dsos;
1713 break;
1714 case PERF_RECORD_MISC_GUEST_KERNEL:
1715 dso_type = DSO_TYPE_GUEST_KERNEL;
1716 head = &machine->kernel_dsos;
1717 break;
1718 case PERF_RECORD_MISC_USER:
1719 case PERF_RECORD_MISC_GUEST_USER:
1720 dso_type = DSO_TYPE_USER;
1721 head = &machine->user_dsos;
1722 break;
1723 default:
1724 goto out;
1725 }
1726
1727 dso = __dsos__findnew(head, filename);
1728 if (dso != NULL) {
1729 char sbuild_id[BUILD_ID_SIZE * 2 + 1];
1730
1731 dso__set_build_id(dso, &bev->build_id);
1732
1733 if (filename[0] == '[')
1734 dso->kernel = dso_type;
1735
1736 build_id__sprintf(dso->build_id, sizeof(dso->build_id),
1737 sbuild_id);
1738 pr_debug("build id event received for %s: %s\n",
1739 dso->long_name, sbuild_id);
1740 }
1741
1742 err = 0;
1743out:
1744 return err;
1745}
1746
1747static int perf_header__read_build_ids_abi_quirk(struct perf_header *header,
1748 int input, u64 offset, u64 size)
1749{
1750 struct perf_session *session = container_of(header, struct perf_session, header);
1751 struct {
1752 struct perf_event_header header;
1753 u8 build_id[ALIGN(BUILD_ID_SIZE, sizeof(u64))];
1754 char filename[0];
1755 } old_bev;
1756 struct build_id_event bev;
1757 char filename[PATH_MAX];
1758 u64 limit = offset + size;
1759
1760 while (offset < limit) {
1761 ssize_t len;
1762
1763 if (read(input, &old_bev, sizeof(old_bev)) != sizeof(old_bev))
1764 return -1;
1765
1766 if (header->needs_swap)
1767 perf_event_header__bswap(&old_bev.header);
1768
1769 len = old_bev.header.size - sizeof(old_bev);
1770 if (read(input, filename, len) != len)
1771 return -1;
1772
1773 bev.header = old_bev.header;
1774
1775 /*
1776 * As the pid is the missing value, we need to fill
1777 * it properly. The header.misc value give us nice hint.
1778 */
1779 bev.pid = HOST_KERNEL_ID;
1780 if (bev.header.misc == PERF_RECORD_MISC_GUEST_USER ||
1781 bev.header.misc == PERF_RECORD_MISC_GUEST_KERNEL)
1782 bev.pid = DEFAULT_GUEST_KERNEL_ID;
1783
1784 memcpy(bev.build_id, old_bev.build_id, sizeof(bev.build_id));
1785 __event_process_build_id(&bev, filename, session);
1786
1787 offset += bev.header.size;
1788 }
1789
1790 return 0;
1791}
1792
1793static int perf_header__read_build_ids(struct perf_header *header,
1794 int input, u64 offset, u64 size)
1795{
1796 struct perf_session *session = container_of(header, struct perf_session, header);
1797 struct build_id_event bev;
1798 char filename[PATH_MAX];
1799 u64 limit = offset + size, orig_offset = offset;
1800 int err = -1;
1801
1802 while (offset < limit) {
1803 ssize_t len;
1804
1805 if (read(input, &bev, sizeof(bev)) != sizeof(bev))
1806 goto out;
1807
1808 if (header->needs_swap)
1809 perf_event_header__bswap(&bev.header);
1810
1811 len = bev.header.size - sizeof(bev);
1812 if (read(input, filename, len) != len)
1813 goto out;
1814 /*
1815 * The a1645ce1 changeset:
1816 *
1817 * "perf: 'perf kvm' tool for monitoring guest performance from host"
1818 *
1819 * Added a field to struct build_id_event that broke the file
1820 * format.
1821 *
1822 * Since the kernel build-id is the first entry, process the
1823 * table using the old format if the well known
1824 * '[kernel.kallsyms]' string for the kernel build-id has the
1825 * first 4 characters chopped off (where the pid_t sits).
1826 */
1827 if (memcmp(filename, "nel.kallsyms]", 13) == 0) {
1828 if (lseek(input, orig_offset, SEEK_SET) == (off_t)-1)
1829 return -1;
1830 return perf_header__read_build_ids_abi_quirk(header, input, offset, size);
1831 }
1832
1833 __event_process_build_id(&bev, filename, session);
1834
1835 offset += bev.header.size;
1836 }
1837 err = 0;
1838out:
1839 return err;
1840}
1841
1842static int perf_file_section__process(struct perf_file_section *section, 1992static int perf_file_section__process(struct perf_file_section *section,
1843 struct perf_header *ph, 1993 struct perf_header *ph,
1844 int feat, int fd, void *data __used) 1994 int feat, int fd, void *data __used)
@@ -1854,40 +2004,32 @@ static int perf_file_section__process(struct perf_file_section *section,
1854 return 0; 2004 return 0;
1855 } 2005 }
1856 2006
1857 switch (feat) { 2007 if (!feat_ops[feat].process)
1858 case HEADER_TRACE_INFO: 2008 return 0;
1859 trace_report(fd, false);
1860 break;
1861 case HEADER_BUILD_ID:
1862 if (perf_header__read_build_ids(ph, fd, section->offset, section->size))
1863 pr_debug("Failed to read buildids, continuing...\n");
1864 break;
1865 default:
1866 break;
1867 }
1868 2009
1869 return 0; 2010 return feat_ops[feat].process(section, ph, feat, fd);
1870} 2011}
1871 2012
1872static int perf_file_header__read_pipe(struct perf_pipe_file_header *header, 2013static int perf_file_header__read_pipe(struct perf_pipe_file_header *header,
1873 struct perf_header *ph, int fd, 2014 struct perf_header *ph, int fd,
1874 bool repipe) 2015 bool repipe)
1875{ 2016{
1876 if (readn(fd, header, sizeof(*header)) <= 0 || 2017 int ret;
1877 memcmp(&header->magic, __perf_magic, sizeof(header->magic)))
1878 return -1;
1879 2018
1880 if (repipe && do_write(STDOUT_FILENO, header, sizeof(*header)) < 0) 2019 ret = readn(fd, header, sizeof(*header));
2020 if (ret <= 0)
1881 return -1; 2021 return -1;
1882 2022
1883 if (header->size != sizeof(*header)) { 2023 if (check_magic_endian(header->magic, header->size, true, ph) < 0) {
1884 u64 size = bswap_64(header->size); 2024 pr_debug("endian/magic failed\n");
2025 return -1;
2026 }
1885 2027
1886 if (size != sizeof(*header)) 2028 if (ph->needs_swap)
1887 return -1; 2029 header->size = bswap_64(header->size);
1888 2030
1889 ph->needs_swap = true; 2031 if (repipe && do_write(STDOUT_FILENO, header, sizeof(*header)) < 0)
1890 } 2032 return -1;
1891 2033
1892 return 0; 2034 return 0;
1893} 2035}
@@ -1908,6 +2050,52 @@ static int perf_header__read_pipe(struct perf_session *session, int fd)
1908 return 0; 2050 return 0;
1909} 2051}
1910 2052
2053static int read_attr(int fd, struct perf_header *ph,
2054 struct perf_file_attr *f_attr)
2055{
2056 struct perf_event_attr *attr = &f_attr->attr;
2057 size_t sz, left;
2058 size_t our_sz = sizeof(f_attr->attr);
2059 int ret;
2060
2061 memset(f_attr, 0, sizeof(*f_attr));
2062
2063 /* read minimal guaranteed structure */
2064 ret = readn(fd, attr, PERF_ATTR_SIZE_VER0);
2065 if (ret <= 0) {
2066 pr_debug("cannot read %d bytes of header attr\n",
2067 PERF_ATTR_SIZE_VER0);
2068 return -1;
2069 }
2070
2071 /* on file perf_event_attr size */
2072 sz = attr->size;
2073
2074 if (ph->needs_swap)
2075 sz = bswap_32(sz);
2076
2077 if (sz == 0) {
2078 /* assume ABI0 */
2079 sz = PERF_ATTR_SIZE_VER0;
2080 } else if (sz > our_sz) {
2081 pr_debug("file uses a more recent and unsupported ABI"
2082 " (%zu bytes extra)\n", sz - our_sz);
2083 return -1;
2084 }
2085 /* what we have not yet read and that we know about */
2086 left = sz - PERF_ATTR_SIZE_VER0;
2087 if (left) {
2088 void *ptr = attr;
2089 ptr += PERF_ATTR_SIZE_VER0;
2090
2091 ret = readn(fd, ptr, left);
2092 }
2093 /* read perf_file_section, ids are read in caller */
2094 ret = readn(fd, &f_attr->ids, sizeof(f_attr->ids));
2095
2096 return ret <= 0 ? -1 : 0;
2097}
2098
1911int perf_session__read_header(struct perf_session *session, int fd) 2099int perf_session__read_header(struct perf_session *session, int fd)
1912{ 2100{
1913 struct perf_header *header = &session->header; 2101 struct perf_header *header = &session->header;
@@ -1923,19 +2111,17 @@ int perf_session__read_header(struct perf_session *session, int fd)
1923 if (session->fd_pipe) 2111 if (session->fd_pipe)
1924 return perf_header__read_pipe(session, fd); 2112 return perf_header__read_pipe(session, fd);
1925 2113
1926 if (perf_file_header__read(&f_header, header, fd) < 0) { 2114 if (perf_file_header__read(&f_header, header, fd) < 0)
1927 pr_debug("incompatible file format\n");
1928 return -EINVAL; 2115 return -EINVAL;
1929 }
1930 2116
1931 nr_attrs = f_header.attrs.size / sizeof(f_attr); 2117 nr_attrs = f_header.attrs.size / f_header.attr_size;
1932 lseek(fd, f_header.attrs.offset, SEEK_SET); 2118 lseek(fd, f_header.attrs.offset, SEEK_SET);
1933 2119
1934 for (i = 0; i < nr_attrs; i++) { 2120 for (i = 0; i < nr_attrs; i++) {
1935 struct perf_evsel *evsel; 2121 struct perf_evsel *evsel;
1936 off_t tmp; 2122 off_t tmp;
1937 2123
1938 if (readn(fd, &f_attr, sizeof(f_attr)) <= 0) 2124 if (read_attr(fd, header, &f_attr) < 0)
1939 goto out_errno; 2125 goto out_errno;
1940 2126
1941 if (header->needs_swap) 2127 if (header->needs_swap)
diff --git a/tools/perf/util/header.h b/tools/perf/util/header.h
index ac4ec956024e..21a6be09c129 100644
--- a/tools/perf/util/header.h
+++ b/tools/perf/util/header.h
@@ -11,6 +11,7 @@
11 11
12enum { 12enum {
13 HEADER_RESERVED = 0, /* always cleared */ 13 HEADER_RESERVED = 0, /* always cleared */
14 HEADER_FIRST_FEATURE = 1,
14 HEADER_TRACE_INFO = 1, 15 HEADER_TRACE_INFO = 1,
15 HEADER_BUILD_ID, 16 HEADER_BUILD_ID,
16 17
@@ -26,7 +27,7 @@ enum {
26 HEADER_EVENT_DESC, 27 HEADER_EVENT_DESC,
27 HEADER_CPU_TOPOLOGY, 28 HEADER_CPU_TOPOLOGY,
28 HEADER_NUMA_TOPOLOGY, 29 HEADER_NUMA_TOPOLOGY,
29 30 HEADER_BRANCH_STACK,
30 HEADER_LAST_FEATURE, 31 HEADER_LAST_FEATURE,
31 HEADER_FEAT_BITS = 256, 32 HEADER_FEAT_BITS = 256,
32}; 33};
diff --git a/tools/perf/util/hist.c b/tools/perf/util/hist.c
index e11e482bd185..c61235f81260 100644
--- a/tools/perf/util/hist.c
+++ b/tools/perf/util/hist.c
@@ -10,11 +10,14 @@ static bool hists__filter_entry_by_dso(struct hists *hists,
10 struct hist_entry *he); 10 struct hist_entry *he);
11static bool hists__filter_entry_by_thread(struct hists *hists, 11static bool hists__filter_entry_by_thread(struct hists *hists,
12 struct hist_entry *he); 12 struct hist_entry *he);
13static bool hists__filter_entry_by_symbol(struct hists *hists,
14 struct hist_entry *he);
13 15
14enum hist_filter { 16enum hist_filter {
15 HIST_FILTER__DSO, 17 HIST_FILTER__DSO,
16 HIST_FILTER__THREAD, 18 HIST_FILTER__THREAD,
17 HIST_FILTER__PARENT, 19 HIST_FILTER__PARENT,
20 HIST_FILTER__SYMBOL,
18}; 21};
19 22
20struct callchain_param callchain_param = { 23struct callchain_param callchain_param = {
@@ -50,21 +53,25 @@ static void hists__reset_col_len(struct hists *hists)
50 hists__set_col_len(hists, col, 0); 53 hists__set_col_len(hists, col, 0);
51} 54}
52 55
56static void hists__set_unres_dso_col_len(struct hists *hists, int dso)
57{
58 const unsigned int unresolved_col_width = BITS_PER_LONG / 4;
59
60 if (hists__col_len(hists, dso) < unresolved_col_width &&
61 !symbol_conf.col_width_list_str && !symbol_conf.field_sep &&
62 !symbol_conf.dso_list)
63 hists__set_col_len(hists, dso, unresolved_col_width);
64}
65
53static void hists__calc_col_len(struct hists *hists, struct hist_entry *h) 66static void hists__calc_col_len(struct hists *hists, struct hist_entry *h)
54{ 67{
68 const unsigned int unresolved_col_width = BITS_PER_LONG / 4;
55 u16 len; 69 u16 len;
56 70
57 if (h->ms.sym) 71 if (h->ms.sym)
58 hists__new_col_len(hists, HISTC_SYMBOL, h->ms.sym->namelen); 72 hists__new_col_len(hists, HISTC_SYMBOL, h->ms.sym->namelen + 4);
59 else { 73 else
60 const unsigned int unresolved_col_width = BITS_PER_LONG / 4; 74 hists__set_unres_dso_col_len(hists, HISTC_DSO);
61
62 if (hists__col_len(hists, HISTC_DSO) < unresolved_col_width &&
63 !symbol_conf.col_width_list_str && !symbol_conf.field_sep &&
64 !symbol_conf.dso_list)
65 hists__set_col_len(hists, HISTC_DSO,
66 unresolved_col_width);
67 }
68 75
69 len = thread__comm_len(h->thread); 76 len = thread__comm_len(h->thread);
70 if (hists__new_col_len(hists, HISTC_COMM, len)) 77 if (hists__new_col_len(hists, HISTC_COMM, len))
@@ -74,6 +81,37 @@ static void hists__calc_col_len(struct hists *hists, struct hist_entry *h)
74 len = dso__name_len(h->ms.map->dso); 81 len = dso__name_len(h->ms.map->dso);
75 hists__new_col_len(hists, HISTC_DSO, len); 82 hists__new_col_len(hists, HISTC_DSO, len);
76 } 83 }
84
85 if (h->branch_info) {
86 int symlen;
87 /*
88 * +4 accounts for '[x] ' priv level info
89 * +2 account of 0x prefix on raw addresses
90 */
91 if (h->branch_info->from.sym) {
92 symlen = (int)h->branch_info->from.sym->namelen + 4;
93 hists__new_col_len(hists, HISTC_SYMBOL_FROM, symlen);
94
95 symlen = dso__name_len(h->branch_info->from.map->dso);
96 hists__new_col_len(hists, HISTC_DSO_FROM, symlen);
97 } else {
98 symlen = unresolved_col_width + 4 + 2;
99 hists__new_col_len(hists, HISTC_SYMBOL_FROM, symlen);
100 hists__set_unres_dso_col_len(hists, HISTC_DSO_FROM);
101 }
102
103 if (h->branch_info->to.sym) {
104 symlen = (int)h->branch_info->to.sym->namelen + 4;
105 hists__new_col_len(hists, HISTC_SYMBOL_TO, symlen);
106
107 symlen = dso__name_len(h->branch_info->to.map->dso);
108 hists__new_col_len(hists, HISTC_DSO_TO, symlen);
109 } else {
110 symlen = unresolved_col_width + 4 + 2;
111 hists__new_col_len(hists, HISTC_SYMBOL_TO, symlen);
112 hists__set_unres_dso_col_len(hists, HISTC_DSO_TO);
113 }
114 }
77} 115}
78 116
79static void hist_entry__add_cpumode_period(struct hist_entry *he, 117static void hist_entry__add_cpumode_period(struct hist_entry *he,
@@ -195,26 +233,14 @@ static u8 symbol__parent_filter(const struct symbol *parent)
195 return 0; 233 return 0;
196} 234}
197 235
198struct hist_entry *__hists__add_entry(struct hists *hists, 236static struct hist_entry *add_hist_entry(struct hists *hists,
237 struct hist_entry *entry,
199 struct addr_location *al, 238 struct addr_location *al,
200 struct symbol *sym_parent, u64 period) 239 u64 period)
201{ 240{
202 struct rb_node **p; 241 struct rb_node **p;
203 struct rb_node *parent = NULL; 242 struct rb_node *parent = NULL;
204 struct hist_entry *he; 243 struct hist_entry *he;
205 struct hist_entry entry = {
206 .thread = al->thread,
207 .ms = {
208 .map = al->map,
209 .sym = al->sym,
210 },
211 .cpu = al->cpu,
212 .ip = al->addr,
213 .level = al->level,
214 .period = period,
215 .parent = sym_parent,
216 .filtered = symbol__parent_filter(sym_parent),
217 };
218 int cmp; 244 int cmp;
219 245
220 pthread_mutex_lock(&hists->lock); 246 pthread_mutex_lock(&hists->lock);
@@ -225,7 +251,7 @@ struct hist_entry *__hists__add_entry(struct hists *hists,
225 parent = *p; 251 parent = *p;
226 he = rb_entry(parent, struct hist_entry, rb_node_in); 252 he = rb_entry(parent, struct hist_entry, rb_node_in);
227 253
228 cmp = hist_entry__cmp(&entry, he); 254 cmp = hist_entry__cmp(entry, he);
229 255
230 if (!cmp) { 256 if (!cmp) {
231 he->period += period; 257 he->period += period;
@@ -239,7 +265,7 @@ struct hist_entry *__hists__add_entry(struct hists *hists,
239 p = &(*p)->rb_right; 265 p = &(*p)->rb_right;
240 } 266 }
241 267
242 he = hist_entry__new(&entry); 268 he = hist_entry__new(entry);
243 if (!he) 269 if (!he)
244 goto out_unlock; 270 goto out_unlock;
245 271
@@ -252,6 +278,51 @@ out_unlock:
252 return he; 278 return he;
253} 279}
254 280
281struct hist_entry *__hists__add_branch_entry(struct hists *self,
282 struct addr_location *al,
283 struct symbol *sym_parent,
284 struct branch_info *bi,
285 u64 period)
286{
287 struct hist_entry entry = {
288 .thread = al->thread,
289 .ms = {
290 .map = bi->to.map,
291 .sym = bi->to.sym,
292 },
293 .cpu = al->cpu,
294 .ip = bi->to.addr,
295 .level = al->level,
296 .period = period,
297 .parent = sym_parent,
298 .filtered = symbol__parent_filter(sym_parent),
299 .branch_info = bi,
300 };
301
302 return add_hist_entry(self, &entry, al, period);
303}
304
305struct hist_entry *__hists__add_entry(struct hists *self,
306 struct addr_location *al,
307 struct symbol *sym_parent, u64 period)
308{
309 struct hist_entry entry = {
310 .thread = al->thread,
311 .ms = {
312 .map = al->map,
313 .sym = al->sym,
314 },
315 .cpu = al->cpu,
316 .ip = al->addr,
317 .level = al->level,
318 .period = period,
319 .parent = sym_parent,
320 .filtered = symbol__parent_filter(sym_parent),
321 };
322
323 return add_hist_entry(self, &entry, al, period);
324}
325
255int64_t 326int64_t
256hist_entry__cmp(struct hist_entry *left, struct hist_entry *right) 327hist_entry__cmp(struct hist_entry *left, struct hist_entry *right)
257{ 328{
@@ -352,6 +423,7 @@ static void hists__apply_filters(struct hists *hists, struct hist_entry *he)
352{ 423{
353 hists__filter_entry_by_dso(hists, he); 424 hists__filter_entry_by_dso(hists, he);
354 hists__filter_entry_by_thread(hists, he); 425 hists__filter_entry_by_thread(hists, he);
426 hists__filter_entry_by_symbol(hists, he);
355} 427}
356 428
357static void __hists__collapse_resort(struct hists *hists, bool threaded) 429static void __hists__collapse_resort(struct hists *hists, bool threaded)
@@ -819,9 +891,9 @@ static int hist_entry__pcnt_snprintf(struct hist_entry *he, char *s,
819 diff = new_percent - old_percent; 891 diff = new_percent - old_percent;
820 892
821 if (fabs(diff) >= 0.01) 893 if (fabs(diff) >= 0.01)
822 ret += scnprintf(bf, sizeof(bf), "%+4.2F%%", diff); 894 scnprintf(bf, sizeof(bf), "%+4.2F%%", diff);
823 else 895 else
824 ret += scnprintf(bf, sizeof(bf), " "); 896 scnprintf(bf, sizeof(bf), " ");
825 897
826 if (sep) 898 if (sep)
827 ret += scnprintf(s + ret, size - ret, "%c%s", *sep, bf); 899 ret += scnprintf(s + ret, size - ret, "%c%s", *sep, bf);
@@ -830,9 +902,9 @@ static int hist_entry__pcnt_snprintf(struct hist_entry *he, char *s,
830 902
831 if (show_displacement) { 903 if (show_displacement) {
832 if (displacement) 904 if (displacement)
833 ret += scnprintf(bf, sizeof(bf), "%+4ld", displacement); 905 scnprintf(bf, sizeof(bf), "%+4ld", displacement);
834 else 906 else
835 ret += scnprintf(bf, sizeof(bf), " "); 907 scnprintf(bf, sizeof(bf), " ");
836 908
837 if (sep) 909 if (sep)
838 ret += scnprintf(s + ret, size - ret, "%c%s", *sep, bf); 910 ret += scnprintf(s + ret, size - ret, "%c%s", *sep, bf);
@@ -1179,6 +1251,37 @@ void hists__filter_by_thread(struct hists *hists)
1179 } 1251 }
1180} 1252}
1181 1253
1254static bool hists__filter_entry_by_symbol(struct hists *hists,
1255 struct hist_entry *he)
1256{
1257 if (hists->symbol_filter_str != NULL &&
1258 (!he->ms.sym || strstr(he->ms.sym->name,
1259 hists->symbol_filter_str) == NULL)) {
1260 he->filtered |= (1 << HIST_FILTER__SYMBOL);
1261 return true;
1262 }
1263
1264 return false;
1265}
1266
1267void hists__filter_by_symbol(struct hists *hists)
1268{
1269 struct rb_node *nd;
1270
1271 hists->nr_entries = hists->stats.total_period = 0;
1272 hists->stats.nr_events[PERF_RECORD_SAMPLE] = 0;
1273 hists__reset_col_len(hists);
1274
1275 for (nd = rb_first(&hists->entries); nd; nd = rb_next(nd)) {
1276 struct hist_entry *h = rb_entry(nd, struct hist_entry, rb_node);
1277
1278 if (hists__filter_entry_by_symbol(hists, h))
1279 continue;
1280
1281 hists__remove_entry_filter(hists, h, HIST_FILTER__SYMBOL);
1282 }
1283}
1284
1182int hist_entry__inc_addr_samples(struct hist_entry *he, int evidx, u64 ip) 1285int hist_entry__inc_addr_samples(struct hist_entry *he, int evidx, u64 ip)
1183{ 1286{
1184 return symbol__inc_addr_samples(he->ms.sym, he->ms.map, evidx, ip); 1287 return symbol__inc_addr_samples(he->ms.sym, he->ms.map, evidx, ip);
diff --git a/tools/perf/util/hist.h b/tools/perf/util/hist.h
index f55f0a8d1f81..2cae9df40e04 100644
--- a/tools/perf/util/hist.h
+++ b/tools/perf/util/hist.h
@@ -32,6 +32,7 @@ struct events_stats {
32 u32 nr_unknown_events; 32 u32 nr_unknown_events;
33 u32 nr_invalid_chains; 33 u32 nr_invalid_chains;
34 u32 nr_unknown_id; 34 u32 nr_unknown_id;
35 u32 nr_unprocessable_samples;
35}; 36};
36 37
37enum hist_column { 38enum hist_column {
@@ -41,6 +42,11 @@ enum hist_column {
41 HISTC_COMM, 42 HISTC_COMM,
42 HISTC_PARENT, 43 HISTC_PARENT,
43 HISTC_CPU, 44 HISTC_CPU,
45 HISTC_MISPREDICT,
46 HISTC_SYMBOL_FROM,
47 HISTC_SYMBOL_TO,
48 HISTC_DSO_FROM,
49 HISTC_DSO_TO,
44 HISTC_NR_COLS, /* Last entry */ 50 HISTC_NR_COLS, /* Last entry */
45}; 51};
46 52
@@ -55,6 +61,8 @@ struct hists {
55 u64 nr_entries; 61 u64 nr_entries;
56 const struct thread *thread_filter; 62 const struct thread *thread_filter;
57 const struct dso *dso_filter; 63 const struct dso *dso_filter;
64 const char *uid_filter_str;
65 const char *symbol_filter_str;
58 pthread_mutex_t lock; 66 pthread_mutex_t lock;
59 struct events_stats stats; 67 struct events_stats stats;
60 u64 event_stream; 68 u64 event_stream;
@@ -72,6 +80,12 @@ int hist_entry__snprintf(struct hist_entry *self, char *bf, size_t size,
72 struct hists *hists); 80 struct hists *hists);
73void hist_entry__free(struct hist_entry *); 81void hist_entry__free(struct hist_entry *);
74 82
83struct hist_entry *__hists__add_branch_entry(struct hists *self,
84 struct addr_location *al,
85 struct symbol *sym_parent,
86 struct branch_info *bi,
87 u64 period);
88
75void hists__output_resort(struct hists *self); 89void hists__output_resort(struct hists *self);
76void hists__output_resort_threaded(struct hists *hists); 90void hists__output_resort_threaded(struct hists *hists);
77void hists__collapse_resort(struct hists *self); 91void hists__collapse_resort(struct hists *self);
@@ -94,6 +108,7 @@ int hist_entry__annotate(struct hist_entry *self, size_t privsize);
94 108
95void hists__filter_by_dso(struct hists *hists); 109void hists__filter_by_dso(struct hists *hists);
96void hists__filter_by_thread(struct hists *hists); 110void hists__filter_by_thread(struct hists *hists);
111void hists__filter_by_symbol(struct hists *hists);
97 112
98u16 hists__col_len(struct hists *self, enum hist_column col); 113u16 hists__col_len(struct hists *self, enum hist_column col);
99void hists__set_col_len(struct hists *self, enum hist_column col, u16 len); 114void hists__set_col_len(struct hists *self, enum hist_column col, u16 len);
@@ -132,6 +147,23 @@ int perf_evlist__tui_browse_hists(struct perf_evlist *evlist, const char *help,
132 int refresh); 147 int refresh);
133#endif 148#endif
134 149
150#ifdef NO_GTK2_SUPPORT
151static inline
152int perf_evlist__gtk_browse_hists(struct perf_evlist *evlist __used,
153 const char *help __used,
154 void(*timer)(void *arg) __used,
155 void *arg __used,
156 int refresh __used)
157{
158 return 0;
159}
160
161#else
162int perf_evlist__gtk_browse_hists(struct perf_evlist *evlist, const char *help,
163 void(*timer)(void *arg), void *arg,
164 int refresh);
165#endif
166
135unsigned int hists__sort_list_width(struct hists *self); 167unsigned int hists__sort_list_width(struct hists *self);
136 168
137#endif /* __PERF_HIST_H */ 169#endif /* __PERF_HIST_H */
diff --git a/tools/perf/util/include/asm/dwarf2.h b/tools/perf/util/include/asm/dwarf2.h
index bb4198e7837a..afe38199e922 100644
--- a/tools/perf/util/include/asm/dwarf2.h
+++ b/tools/perf/util/include/asm/dwarf2.h
@@ -2,10 +2,12 @@
2#ifndef PERF_DWARF2_H 2#ifndef PERF_DWARF2_H
3#define PERF_DWARF2_H 3#define PERF_DWARF2_H
4 4
5/* dwarf2.h ... dummy header file for including arch/x86/lib/memcpy_64.S */ 5/* dwarf2.h ... dummy header file for including arch/x86/lib/mem{cpy,set}_64.S */
6 6
7#define CFI_STARTPROC 7#define CFI_STARTPROC
8#define CFI_ENDPROC 8#define CFI_ENDPROC
9#define CFI_REMEMBER_STATE
10#define CFI_RESTORE_STATE
9 11
10#endif /* PERF_DWARF2_H */ 12#endif /* PERF_DWARF2_H */
11 13
diff --git a/tools/perf/util/include/linux/bitmap.h b/tools/perf/util/include/linux/bitmap.h
index eda4416efa0a..bb162e40c76c 100644
--- a/tools/perf/util/include/linux/bitmap.h
+++ b/tools/perf/util/include/linux/bitmap.h
@@ -5,6 +5,8 @@
5#include <linux/bitops.h> 5#include <linux/bitops.h>
6 6
7int __bitmap_weight(const unsigned long *bitmap, int bits); 7int __bitmap_weight(const unsigned long *bitmap, int bits);
8void __bitmap_or(unsigned long *dst, const unsigned long *bitmap1,
9 const unsigned long *bitmap2, int bits);
8 10
9#define BITMAP_LAST_WORD_MASK(nbits) \ 11#define BITMAP_LAST_WORD_MASK(nbits) \
10( \ 12( \
@@ -32,4 +34,13 @@ static inline int bitmap_weight(const unsigned long *src, int nbits)
32 return __bitmap_weight(src, nbits); 34 return __bitmap_weight(src, nbits);
33} 35}
34 36
37static inline void bitmap_or(unsigned long *dst, const unsigned long *src1,
38 const unsigned long *src2, int nbits)
39{
40 if (small_const_nbits(nbits))
41 *dst = *src1 | *src2;
42 else
43 __bitmap_or(dst, src1, src2, nbits);
44}
45
35#endif /* _PERF_BITOPS_H */ 46#endif /* _PERF_BITOPS_H */
diff --git a/tools/perf/util/map.c b/tools/perf/util/map.c
index 316aa0ab7122..dea6d1c1a954 100644
--- a/tools/perf/util/map.c
+++ b/tools/perf/util/map.c
@@ -212,6 +212,21 @@ size_t map__fprintf(struct map *self, FILE *fp)
212 self->start, self->end, self->pgoff, self->dso->name); 212 self->start, self->end, self->pgoff, self->dso->name);
213} 213}
214 214
215size_t map__fprintf_dsoname(struct map *map, FILE *fp)
216{
217 const char *dsoname;
218
219 if (map && map->dso && (map->dso->name || map->dso->long_name)) {
220 if (symbol_conf.show_kernel_path && map->dso->long_name)
221 dsoname = map->dso->long_name;
222 else if (map->dso->name)
223 dsoname = map->dso->name;
224 } else
225 dsoname = "[unknown]";
226
227 return fprintf(fp, "%s", dsoname);
228}
229
215/* 230/*
216 * objdump wants/reports absolute IPs for ET_EXEC, and RIPs for ET_DYN. 231 * objdump wants/reports absolute IPs for ET_EXEC, and RIPs for ET_DYN.
217 * map->dso->adjust_symbols==1 for ET_EXEC-like cases. 232 * map->dso->adjust_symbols==1 for ET_EXEC-like cases.
diff --git a/tools/perf/util/map.h b/tools/perf/util/map.h
index 2b8017f8a930..b100c20b7f94 100644
--- a/tools/perf/util/map.h
+++ b/tools/perf/util/map.h
@@ -118,6 +118,7 @@ void map__delete(struct map *self);
118struct map *map__clone(struct map *self); 118struct map *map__clone(struct map *self);
119int map__overlap(struct map *l, struct map *r); 119int map__overlap(struct map *l, struct map *r);
120size_t map__fprintf(struct map *self, FILE *fp); 120size_t map__fprintf(struct map *self, FILE *fp);
121size_t map__fprintf_dsoname(struct map *map, FILE *fp);
121 122
122int map__load(struct map *self, symbol_filter_t filter); 123int map__load(struct map *self, symbol_filter_t filter);
123struct symbol *map__find_symbol(struct map *self, 124struct symbol *map__find_symbol(struct map *self,
diff --git a/tools/perf/util/parse-events-bison.c b/tools/perf/util/parse-events-bison.c
new file mode 100644
index 000000000000..4a4e02aff34e
--- /dev/null
+++ b/tools/perf/util/parse-events-bison.c
@@ -0,0 +1,1917 @@
1/* A Bison parser, made by GNU Bison 2.5. */
2
3/* Bison implementation for Yacc-like parsers in C
4
5 Copyright (C) 1984, 1989-1990, 2000-2011 Free Software Foundation, Inc.
6
7 This program is free software: you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation, either version 3 of the License, or
10 (at your option) any later version.
11
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with this program. If not, see <http://www.gnu.org/licenses/>. */
19
20/* As a special exception, you may create a larger work that contains
21 part or all of the Bison parser skeleton and distribute that work
22 under terms of your choice, so long as that work isn't itself a
23 parser generator using the skeleton or a modified version thereof
24 as a parser skeleton. Alternatively, if you modify or redistribute
25 the parser skeleton itself, you may (at your option) remove this
26 special exception, which will cause the skeleton and the resulting
27 Bison output files to be licensed under the GNU General Public
28 License without this special exception.
29
30 This special exception was added by the Free Software Foundation in
31 version 2.2 of Bison. */
32
33/* C LALR(1) parser skeleton written by Richard Stallman, by
34 simplifying the original so-called "semantic" parser. */
35
36/* All symbols defined below should begin with yy or YY, to avoid
37 infringing on user name space. This should be done even for local
38 variables, as they might otherwise be expanded by user macros.
39 There are some unavoidable exceptions within include files to
40 define necessary library symbols; they are noted "INFRINGES ON
41 USER NAME SPACE" below. */
42
43/* Identify Bison output. */
44#define YYBISON 1
45
46/* Bison version. */
47#define YYBISON_VERSION "2.5"
48
49/* Skeleton name. */
50#define YYSKELETON_NAME "yacc.c"
51
52/* Pure parsers. */
53#define YYPURE 0
54
55/* Push parsers. */
56#define YYPUSH 0
57
58/* Pull parsers. */
59#define YYPULL 1
60
61/* Using locations. */
62#define YYLSP_NEEDED 0
63
64/* Substitute the variable and function names. */
65#define yyparse parse_events_parse
66#define yylex parse_events_lex
67#define yyerror parse_events_error
68#define yylval parse_events_lval
69#define yychar parse_events_char
70#define yydebug parse_events_debug
71#define yynerrs parse_events_nerrs
72
73
74/* Copy the first part of user declarations. */
75
76/* Line 268 of yacc.c */
77#line 7 "util/parse-events.y"
78
79
80#define YYDEBUG 1
81
82#include <linux/compiler.h>
83#include <linux/list.h>
84#include "types.h"
85#include "util.h"
86#include "parse-events.h"
87
88extern int parse_events_lex (void);
89
90#define ABORT_ON(val) \
91do { \
92 if (val) \
93 YYABORT; \
94} while (0)
95
96
97
98/* Line 268 of yacc.c */
99#line 100 "util/parse-events-bison.c"
100
101/* Enabling traces. */
102#ifndef YYDEBUG
103# define YYDEBUG 0
104#endif
105
106/* Enabling verbose error messages. */
107#ifdef YYERROR_VERBOSE
108# undef YYERROR_VERBOSE
109# define YYERROR_VERBOSE 1
110#else
111# define YYERROR_VERBOSE 0
112#endif
113
114/* Enabling the token table. */
115#ifndef YYTOKEN_TABLE
116# define YYTOKEN_TABLE 0
117#endif
118
119
120/* Tokens. */
121#ifndef YYTOKENTYPE
122# define YYTOKENTYPE
123 /* Put the tokens into the symbol table, so that GDB and other debuggers
124 know about them. */
125 enum yytokentype {
126 PE_VALUE = 258,
127 PE_VALUE_SYM = 259,
128 PE_RAW = 260,
129 PE_TERM = 261,
130 PE_NAME = 262,
131 PE_MODIFIER_EVENT = 263,
132 PE_MODIFIER_BP = 264,
133 PE_NAME_CACHE_TYPE = 265,
134 PE_NAME_CACHE_OP_RESULT = 266,
135 PE_PREFIX_MEM = 267,
136 PE_PREFIX_RAW = 268,
137 PE_ERROR = 269
138 };
139#endif
140
141
142
143#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
144typedef union YYSTYPE
145{
146
147/* Line 293 of yacc.c */
148#line 46 "util/parse-events.y"
149
150 char *str;
151 unsigned long num;
152 struct list_head *head;
153 struct parse_events__term *term;
154
155
156
157/* Line 293 of yacc.c */
158#line 159 "util/parse-events-bison.c"
159} YYSTYPE;
160# define YYSTYPE_IS_TRIVIAL 1
161# define yystype YYSTYPE /* obsolescent; will be withdrawn */
162# define YYSTYPE_IS_DECLARED 1
163#endif
164
165
166/* Copy the second part of user declarations. */
167
168
169/* Line 343 of yacc.c */
170#line 171 "util/parse-events-bison.c"
171
172#ifdef short
173# undef short
174#endif
175
176#ifdef YYTYPE_UINT8
177typedef YYTYPE_UINT8 yytype_uint8;
178#else
179typedef unsigned char yytype_uint8;
180#endif
181
182#ifdef YYTYPE_INT8
183typedef YYTYPE_INT8 yytype_int8;
184#elif (defined __STDC__ || defined __C99__FUNC__ \
185 || defined __cplusplus || defined _MSC_VER)
186typedef signed char yytype_int8;
187#else
188typedef short int yytype_int8;
189#endif
190
191#ifdef YYTYPE_UINT16
192typedef YYTYPE_UINT16 yytype_uint16;
193#else
194typedef unsigned short int yytype_uint16;
195#endif
196
197#ifdef YYTYPE_INT16
198typedef YYTYPE_INT16 yytype_int16;
199#else
200typedef short int yytype_int16;
201#endif
202
203#ifndef YYSIZE_T
204# ifdef __SIZE_TYPE__
205# define YYSIZE_T __SIZE_TYPE__
206# elif defined size_t
207# define YYSIZE_T size_t
208# elif ! defined YYSIZE_T && (defined __STDC__ || defined __C99__FUNC__ \
209 || defined __cplusplus || defined _MSC_VER)
210# include <stddef.h> /* INFRINGES ON USER NAME SPACE */
211# define YYSIZE_T size_t
212# else
213# define YYSIZE_T unsigned int
214# endif
215#endif
216
217#define YYSIZE_MAXIMUM ((YYSIZE_T) -1)
218
219#ifndef YY_
220# if defined YYENABLE_NLS && YYENABLE_NLS
221# if ENABLE_NLS
222# include <libintl.h> /* INFRINGES ON USER NAME SPACE */
223# define YY_(msgid) dgettext ("bison-runtime", msgid)
224# endif
225# endif
226# ifndef YY_
227# define YY_(msgid) msgid
228# endif
229#endif
230
231/* Suppress unused-variable warnings by "using" E. */
232#if ! defined lint || defined __GNUC__
233# define YYUSE(e) ((void) (e))
234#else
235# define YYUSE(e) /* empty */
236#endif
237
238/* Identity function, used to suppress warnings about constant conditions. */
239#ifndef lint
240# define YYID(n) (n)
241#else
242#if (defined __STDC__ || defined __C99__FUNC__ \
243 || defined __cplusplus || defined _MSC_VER)
244static int
245YYID (int yyi)
246#else
247static int
248YYID (yyi)
249 int yyi;
250#endif
251{
252 return yyi;
253}
254#endif
255
256#if ! defined yyoverflow || YYERROR_VERBOSE
257
258/* The parser invokes alloca or malloc; define the necessary symbols. */
259
260# ifdef YYSTACK_USE_ALLOCA
261# if YYSTACK_USE_ALLOCA
262# ifdef __GNUC__
263# define YYSTACK_ALLOC __builtin_alloca
264# elif defined __BUILTIN_VA_ARG_INCR
265# include <alloca.h> /* INFRINGES ON USER NAME SPACE */
266# elif defined _AIX
267# define YYSTACK_ALLOC __alloca
268# elif defined _MSC_VER
269# include <malloc.h> /* INFRINGES ON USER NAME SPACE */
270# define alloca _alloca
271# else
272# define YYSTACK_ALLOC alloca
273# if ! defined _ALLOCA_H && ! defined EXIT_SUCCESS && (defined __STDC__ || defined __C99__FUNC__ \
274 || defined __cplusplus || defined _MSC_VER)
275# include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
276# ifndef EXIT_SUCCESS
277# define EXIT_SUCCESS 0
278# endif
279# endif
280# endif
281# endif
282# endif
283
284# ifdef YYSTACK_ALLOC
285 /* Pacify GCC's `empty if-body' warning. */
286# define YYSTACK_FREE(Ptr) do { /* empty */; } while (YYID (0))
287# ifndef YYSTACK_ALLOC_MAXIMUM
288 /* The OS might guarantee only one guard page at the bottom of the stack,
289 and a page size can be as small as 4096 bytes. So we cannot safely
290 invoke alloca (N) if N exceeds 4096. Use a slightly smaller number
291 to allow for a few compiler-allocated temporary stack slots. */
292# define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */
293# endif
294# else
295# define YYSTACK_ALLOC YYMALLOC
296# define YYSTACK_FREE YYFREE
297# ifndef YYSTACK_ALLOC_MAXIMUM
298# define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM
299# endif
300# if (defined __cplusplus && ! defined EXIT_SUCCESS \
301 && ! ((defined YYMALLOC || defined malloc) \
302 && (defined YYFREE || defined free)))
303# include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
304# ifndef EXIT_SUCCESS
305# define EXIT_SUCCESS 0
306# endif
307# endif
308# ifndef YYMALLOC
309# define YYMALLOC malloc
310# if ! defined malloc && ! defined EXIT_SUCCESS && (defined __STDC__ || defined __C99__FUNC__ \
311 || defined __cplusplus || defined _MSC_VER)
312void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */
313# endif
314# endif
315# ifndef YYFREE
316# define YYFREE free
317# if ! defined free && ! defined EXIT_SUCCESS && (defined __STDC__ || defined __C99__FUNC__ \
318 || defined __cplusplus || defined _MSC_VER)
319void free (void *); /* INFRINGES ON USER NAME SPACE */
320# endif
321# endif
322# endif
323#endif /* ! defined yyoverflow || YYERROR_VERBOSE */
324
325
326#if (! defined yyoverflow \
327 && (! defined __cplusplus \
328 || (defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL)))
329
330/* A type that is properly aligned for any stack member. */
331union yyalloc
332{
333 yytype_int16 yyss_alloc;
334 YYSTYPE yyvs_alloc;
335};
336
337/* The size of the maximum gap between one aligned stack and the next. */
338# define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1)
339
340/* The size of an array large to enough to hold all stacks, each with
341 N elements. */
342# define YYSTACK_BYTES(N) \
343 ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE)) \
344 + YYSTACK_GAP_MAXIMUM)
345
346# define YYCOPY_NEEDED 1
347
348/* Relocate STACK from its old location to the new one. The
349 local variables YYSIZE and YYSTACKSIZE give the old and new number of
350 elements in the stack, and YYPTR gives the new location of the
351 stack. Advance YYPTR to a properly aligned location for the next
352 stack. */
353# define YYSTACK_RELOCATE(Stack_alloc, Stack) \
354 do \
355 { \
356 YYSIZE_T yynewbytes; \
357 YYCOPY (&yyptr->Stack_alloc, Stack, yysize); \
358 Stack = &yyptr->Stack_alloc; \
359 yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \
360 yyptr += yynewbytes / sizeof (*yyptr); \
361 } \
362 while (YYID (0))
363
364#endif
365
366#if defined YYCOPY_NEEDED && YYCOPY_NEEDED
367/* Copy COUNT objects from FROM to TO. The source and destination do
368 not overlap. */
369# ifndef YYCOPY
370# if defined __GNUC__ && 1 < __GNUC__
371# define YYCOPY(To, From, Count) \
372 __builtin_memcpy (To, From, (Count) * sizeof (*(From)))
373# else
374# define YYCOPY(To, From, Count) \
375 do \
376 { \
377 YYSIZE_T yyi; \
378 for (yyi = 0; yyi < (Count); yyi++) \
379 (To)[yyi] = (From)[yyi]; \
380 } \
381 while (YYID (0))
382# endif
383# endif
384#endif /* !YYCOPY_NEEDED */
385
386/* YYFINAL -- State number of the termination state. */
387#define YYFINAL 25
388/* YYLAST -- Last index in YYTABLE. */
389#define YYLAST 43
390
391/* YYNTOKENS -- Number of terminals. */
392#define YYNTOKENS 20
393/* YYNNTS -- Number of nonterminals. */
394#define YYNNTS 15
395/* YYNRULES -- Number of rules. */
396#define YYNRULES 35
397/* YYNRULES -- Number of states. */
398#define YYNSTATES 57
399
400/* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */
401#define YYUNDEFTOK 2
402#define YYMAXUTOK 269
403
404#define YYTRANSLATE(YYX) \
405 ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
406
407/* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */
408static const yytype_uint8 yytranslate[] =
409{
410 0, 2, 2, 2, 2, 2, 2, 2, 2, 2,
411 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
412 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
413 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
414 2, 2, 2, 2, 15, 17, 2, 16, 2, 2,
415 2, 2, 2, 2, 2, 2, 2, 2, 18, 2,
416 2, 19, 2, 2, 2, 2, 2, 2, 2, 2,
417 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
418 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
419 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
420 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
421 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
422 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
423 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
424 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
425 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
426 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
427 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
428 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
429 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
430 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
431 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
432 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
433 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
434 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
435 2, 2, 2, 2, 2, 2, 1, 2, 3, 4,
436 5, 6, 7, 8, 9, 10, 11, 12, 13, 14
437};
438
439#if YYDEBUG
440/* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in
441 YYRHS. */
442static const yytype_uint8 yyprhs[] =
443{
444 0, 0, 3, 7, 9, 12, 14, 16, 18, 21,
445 23, 26, 29, 32, 37, 42, 45, 51, 55, 57,
446 63, 67, 71, 75, 77, 81, 83, 87, 91, 93,
447 97, 99, 101, 102, 104, 106
448};
449
450/* YYRHS -- A `-1'-separated list of the rules' RHS. */
451static const yytype_int8 yyrhs[] =
452{
453 21, 0, -1, 21, 15, 22, -1, 22, -1, 23,
454 8, -1, 23, -1, 24, -1, 25, -1, 26, 33,
455 -1, 27, -1, 28, 33, -1, 29, 33, -1, 30,
456 33, -1, 7, 16, 31, 16, -1, 4, 16, 31,
457 16, -1, 4, 34, -1, 10, 17, 11, 17, 11,
458 -1, 10, 17, 11, -1, 10, -1, 12, 3, 18,
459 9, 33, -1, 12, 3, 33, -1, 7, 18, 7,
460 -1, 3, 18, 3, -1, 5, -1, 31, 15, 32,
461 -1, 32, -1, 7, 19, 7, -1, 7, 19, 3,
462 -1, 7, -1, 6, 19, 3, -1, 6, -1, 18,
463 -1, -1, 16, -1, 18, -1, -1
464};
465
466/* YYRLINE[YYN] -- source line where rule number YYN was defined. */
467static const yytype_uint8 yyrline[] =
468{
469 0, 55, 55, 55, 58, 69, 74, 75, 76, 77,
470 78, 79, 80, 83, 90, 99, 108, 113, 118, 124,
471 129, 135, 141, 147, 153, 163, 175, 184, 193, 202,
472 210, 218, 218, 220, 220, 220
473};
474#endif
475
476#if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE
477/* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
478 First, the terminals, then, starting at YYNTOKENS, nonterminals. */
479static const char *const yytname[] =
480{
481 "$end", "error", "$undefined", "PE_VALUE", "PE_VALUE_SYM", "PE_RAW",
482 "PE_TERM", "PE_NAME", "PE_MODIFIER_EVENT", "PE_MODIFIER_BP",
483 "PE_NAME_CACHE_TYPE", "PE_NAME_CACHE_OP_RESULT", "PE_PREFIX_MEM",
484 "PE_PREFIX_RAW", "PE_ERROR", "','", "'/'", "'-'", "':'", "'='",
485 "$accept", "events", "event", "event_def", "event_pmu",
486 "event_legacy_symbol", "event_legacy_cache", "event_legacy_mem",
487 "event_legacy_tracepoint", "event_legacy_numeric", "event_legacy_raw",
488 "event_config", "event_term", "sep_dc", "sep_slash_dc", 0
489};
490#endif
491
492# ifdef YYPRINT
493/* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to
494 token YYLEX-NUM. */
495static const yytype_uint16 yytoknum[] =
496{
497 0, 256, 257, 258, 259, 260, 261, 262, 263, 264,
498 265, 266, 267, 268, 269, 44, 47, 45, 58, 61
499};
500# endif
501
502/* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
503static const yytype_uint8 yyr1[] =
504{
505 0, 20, 21, 21, 22, 22, 23, 23, 23, 23,
506 23, 23, 23, 24, 25, 25, 26, 26, 26, 27,
507 27, 28, 29, 30, 31, 31, 32, 32, 32, 32,
508 32, 33, 33, 34, 34, 34
509};
510
511/* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */
512static const yytype_uint8 yyr2[] =
513{
514 0, 2, 3, 1, 2, 1, 1, 1, 2, 1,
515 2, 2, 2, 4, 4, 2, 5, 3, 1, 5,
516 3, 3, 3, 1, 3, 1, 3, 3, 1, 3,
517 1, 1, 0, 1, 1, 0
518};
519
520/* YYDEFACT[STATE-NAME] -- Default reduction number in state STATE-NUM.
521 Performed when YYTABLE doesn't specify something else to do. Zero
522 means the default is an error. */
523static const yytype_uint8 yydefact[] =
524{
525 0, 0, 35, 23, 0, 18, 0, 0, 3, 5,
526 6, 7, 32, 9, 32, 32, 32, 0, 33, 34,
527 15, 0, 0, 0, 32, 1, 0, 4, 31, 8,
528 10, 11, 12, 22, 30, 28, 0, 25, 0, 21,
529 17, 31, 20, 2, 0, 0, 0, 14, 13, 0,
530 32, 29, 27, 26, 24, 16, 19
531};
532
533/* YYDEFGOTO[NTERM-NUM]. */
534static const yytype_int8 yydefgoto[] =
535{
536 -1, 7, 8, 9, 10, 11, 12, 13, 14, 15,
537 16, 36, 37, 29, 20
538};
539
540/* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
541 STATE-NUM. */
542#define YYPACT_NINF -15
543static const yytype_int8 yypact[] =
544{
545 1, -4, -9, -15, -1, 10, 22, 3, -15, 18,
546 -15, -15, 11, -15, 11, 11, 11, 25, 13, -15,
547 -15, 13, 23, 20, 14, -15, 1, -15, -15, -15,
548 -15, -15, -15, -15, 15, 16, 6, -15, 8, -15,
549 21, 24, -15, -15, 34, 9, 13, -15, -15, 28,
550 11, -15, -15, -15, -15, -15, -15
551};
552
553/* YYPGOTO[NTERM-NUM]. */
554static const yytype_int8 yypgoto[] =
555{
556 -15, -15, 17, -15, -15, -15, -15, -15, -15, -15,
557 -15, 19, -5, -14, -15
558};
559
560/* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If
561 positive, shift that token. If negative, reduce the rule which
562 number is the opposite. If YYTABLE_NINF, syntax error. */
563#define YYTABLE_NINF -1
564static const yytype_uint8 yytable[] =
565{
566 30, 31, 32, 25, 1, 2, 3, 18, 4, 19,
567 42, 5, 52, 6, 17, 21, 53, 22, 26, 34,
568 35, 46, 47, 46, 48, 24, 27, 23, 33, 28,
569 39, 40, 41, 50, 44, 45, 56, 51, 49, 55,
570 38, 54, 0, 43
571};
572
573#define yypact_value_is_default(yystate) \
574 ((yystate) == (-15))
575
576#define yytable_value_is_error(yytable_value) \
577 YYID (0)
578
579static const yytype_int8 yycheck[] =
580{
581 14, 15, 16, 0, 3, 4, 5, 16, 7, 18,
582 24, 10, 3, 12, 18, 16, 7, 18, 15, 6,
583 7, 15, 16, 15, 16, 3, 8, 17, 3, 18,
584 7, 11, 18, 9, 19, 19, 50, 3, 17, 11,
585 21, 46, -1, 26
586};
587
588/* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
589 symbol of state STATE-NUM. */
590static const yytype_uint8 yystos[] =
591{
592 0, 3, 4, 5, 7, 10, 12, 21, 22, 23,
593 24, 25, 26, 27, 28, 29, 30, 18, 16, 18,
594 34, 16, 18, 17, 3, 0, 15, 8, 18, 33,
595 33, 33, 33, 3, 6, 7, 31, 32, 31, 7,
596 11, 18, 33, 22, 19, 19, 15, 16, 16, 17,
597 9, 3, 3, 7, 32, 11, 33
598};
599
600#define yyerrok (yyerrstatus = 0)
601#define yyclearin (yychar = YYEMPTY)
602#define YYEMPTY (-2)
603#define YYEOF 0
604
605#define YYACCEPT goto yyacceptlab
606#define YYABORT goto yyabortlab
607#define YYERROR goto yyerrorlab
608
609
610/* Like YYERROR except do call yyerror. This remains here temporarily
611 to ease the transition to the new meaning of YYERROR, for GCC.
612 Once GCC version 2 has supplanted version 1, this can go. However,
613 YYFAIL appears to be in use. Nevertheless, it is formally deprecated
614 in Bison 2.4.2's NEWS entry, where a plan to phase it out is
615 discussed. */
616
617#define YYFAIL goto yyerrlab
618#if defined YYFAIL
619 /* This is here to suppress warnings from the GCC cpp's
620 -Wunused-macros. Normally we don't worry about that warning, but
621 some users do, and we want to make it easy for users to remove
622 YYFAIL uses, which will produce warnings from Bison 2.5. */
623#endif
624
625#define YYRECOVERING() (!!yyerrstatus)
626
627#define YYBACKUP(Token, Value) \
628do \
629 if (yychar == YYEMPTY && yylen == 1) \
630 { \
631 yychar = (Token); \
632 yylval = (Value); \
633 YYPOPSTACK (1); \
634 goto yybackup; \
635 } \
636 else \
637 { \
638 yyerror (list_all, list_event, idx, YY_("syntax error: cannot back up")); \
639 YYERROR; \
640 } \
641while (YYID (0))
642
643
644#define YYTERROR 1
645#define YYERRCODE 256
646
647
648/* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N].
649 If N is 0, then set CURRENT to the empty location which ends
650 the previous symbol: RHS[0] (always defined). */
651
652#define YYRHSLOC(Rhs, K) ((Rhs)[K])
653#ifndef YYLLOC_DEFAULT
654# define YYLLOC_DEFAULT(Current, Rhs, N) \
655 do \
656 if (YYID (N)) \
657 { \
658 (Current).first_line = YYRHSLOC (Rhs, 1).first_line; \
659 (Current).first_column = YYRHSLOC (Rhs, 1).first_column; \
660 (Current).last_line = YYRHSLOC (Rhs, N).last_line; \
661 (Current).last_column = YYRHSLOC (Rhs, N).last_column; \
662 } \
663 else \
664 { \
665 (Current).first_line = (Current).last_line = \
666 YYRHSLOC (Rhs, 0).last_line; \
667 (Current).first_column = (Current).last_column = \
668 YYRHSLOC (Rhs, 0).last_column; \
669 } \
670 while (YYID (0))
671#endif
672
673
674/* This macro is provided for backward compatibility. */
675
676#ifndef YY_LOCATION_PRINT
677# define YY_LOCATION_PRINT(File, Loc) ((void) 0)
678#endif
679
680
681/* YYLEX -- calling `yylex' with the right arguments. */
682
683#ifdef YYLEX_PARAM
684# define YYLEX yylex (YYLEX_PARAM)
685#else
686# define YYLEX yylex ()
687#endif
688
689/* Enable debugging if requested. */
690#if YYDEBUG
691
692# ifndef YYFPRINTF
693# include <stdio.h> /* INFRINGES ON USER NAME SPACE */
694# define YYFPRINTF fprintf
695# endif
696
697# define YYDPRINTF(Args) \
698do { \
699 if (yydebug) \
700 YYFPRINTF Args; \
701} while (YYID (0))
702
703# define YY_SYMBOL_PRINT(Title, Type, Value, Location) \
704do { \
705 if (yydebug) \
706 { \
707 YYFPRINTF (stderr, "%s ", Title); \
708 yy_symbol_print (stderr, \
709 Type, Value, list_all, list_event, idx); \
710 YYFPRINTF (stderr, "\n"); \
711 } \
712} while (YYID (0))
713
714
715/*--------------------------------.
716| Print this symbol on YYOUTPUT. |
717`--------------------------------*/
718
719/*ARGSUSED*/
720#if (defined __STDC__ || defined __C99__FUNC__ \
721 || defined __cplusplus || defined _MSC_VER)
722static void
723yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep, struct list_head *list_all, struct list_head *list_event, int *idx)
724#else
725static void
726yy_symbol_value_print (yyoutput, yytype, yyvaluep, list_all, list_event, idx)
727 FILE *yyoutput;
728 int yytype;
729 YYSTYPE const * const yyvaluep;
730 struct list_head *list_all;
731 struct list_head *list_event;
732 int *idx;
733#endif
734{
735 if (!yyvaluep)
736 return;
737 YYUSE (list_all);
738 YYUSE (list_event);
739 YYUSE (idx);
740# ifdef YYPRINT
741 if (yytype < YYNTOKENS)
742 YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep);
743# else
744 YYUSE (yyoutput);
745# endif
746 switch (yytype)
747 {
748 default:
749 break;
750 }
751}
752
753
754/*--------------------------------.
755| Print this symbol on YYOUTPUT. |
756`--------------------------------*/
757
758#if (defined __STDC__ || defined __C99__FUNC__ \
759 || defined __cplusplus || defined _MSC_VER)
760static void
761yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep, struct list_head *list_all, struct list_head *list_event, int *idx)
762#else
763static void
764yy_symbol_print (yyoutput, yytype, yyvaluep, list_all, list_event, idx)
765 FILE *yyoutput;
766 int yytype;
767 YYSTYPE const * const yyvaluep;
768 struct list_head *list_all;
769 struct list_head *list_event;
770 int *idx;
771#endif
772{
773 if (yytype < YYNTOKENS)
774 YYFPRINTF (yyoutput, "token %s (", yytname[yytype]);
775 else
776 YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]);
777
778 yy_symbol_value_print (yyoutput, yytype, yyvaluep, list_all, list_event, idx);
779 YYFPRINTF (yyoutput, ")");
780}
781
782/*------------------------------------------------------------------.
783| yy_stack_print -- Print the state stack from its BOTTOM up to its |
784| TOP (included). |
785`------------------------------------------------------------------*/
786
787#if (defined __STDC__ || defined __C99__FUNC__ \
788 || defined __cplusplus || defined _MSC_VER)
789static void
790yy_stack_print (yytype_int16 *yybottom, yytype_int16 *yytop)
791#else
792static void
793yy_stack_print (yybottom, yytop)
794 yytype_int16 *yybottom;
795 yytype_int16 *yytop;
796#endif
797{
798 YYFPRINTF (stderr, "Stack now");
799 for (; yybottom <= yytop; yybottom++)
800 {
801 int yybot = *yybottom;
802 YYFPRINTF (stderr, " %d", yybot);
803 }
804 YYFPRINTF (stderr, "\n");
805}
806
807# define YY_STACK_PRINT(Bottom, Top) \
808do { \
809 if (yydebug) \
810 yy_stack_print ((Bottom), (Top)); \
811} while (YYID (0))
812
813
814/*------------------------------------------------.
815| Report that the YYRULE is going to be reduced. |
816`------------------------------------------------*/
817
818#if (defined __STDC__ || defined __C99__FUNC__ \
819 || defined __cplusplus || defined _MSC_VER)
820static void
821yy_reduce_print (YYSTYPE *yyvsp, int yyrule, struct list_head *list_all, struct list_head *list_event, int *idx)
822#else
823static void
824yy_reduce_print (yyvsp, yyrule, list_all, list_event, idx)
825 YYSTYPE *yyvsp;
826 int yyrule;
827 struct list_head *list_all;
828 struct list_head *list_event;
829 int *idx;
830#endif
831{
832 int yynrhs = yyr2[yyrule];
833 int yyi;
834 unsigned long int yylno = yyrline[yyrule];
835 YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n",
836 yyrule - 1, yylno);
837 /* The symbols being reduced. */
838 for (yyi = 0; yyi < yynrhs; yyi++)
839 {
840 YYFPRINTF (stderr, " $%d = ", yyi + 1);
841 yy_symbol_print (stderr, yyrhs[yyprhs[yyrule] + yyi],
842 &(yyvsp[(yyi + 1) - (yynrhs)])
843 , list_all, list_event, idx);
844 YYFPRINTF (stderr, "\n");
845 }
846}
847
848# define YY_REDUCE_PRINT(Rule) \
849do { \
850 if (yydebug) \
851 yy_reduce_print (yyvsp, Rule, list_all, list_event, idx); \
852} while (YYID (0))
853
854/* Nonzero means print parse trace. It is left uninitialized so that
855 multiple parsers can coexist. */
856int yydebug;
857#else /* !YYDEBUG */
858# define YYDPRINTF(Args)
859# define YY_SYMBOL_PRINT(Title, Type, Value, Location)
860# define YY_STACK_PRINT(Bottom, Top)
861# define YY_REDUCE_PRINT(Rule)
862#endif /* !YYDEBUG */
863
864
865/* YYINITDEPTH -- initial size of the parser's stacks. */
866#ifndef YYINITDEPTH
867# define YYINITDEPTH 200
868#endif
869
870/* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
871 if the built-in stack extension method is used).
872
873 Do not make this value too large; the results are undefined if
874 YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH)
875 evaluated with infinite-precision integer arithmetic. */
876
877#ifndef YYMAXDEPTH
878# define YYMAXDEPTH 10000
879#endif
880
881
882#if YYERROR_VERBOSE
883
884# ifndef yystrlen
885# if defined __GLIBC__ && defined _STRING_H
886# define yystrlen strlen
887# else
888/* Return the length of YYSTR. */
889#if (defined __STDC__ || defined __C99__FUNC__ \
890 || defined __cplusplus || defined _MSC_VER)
891static YYSIZE_T
892yystrlen (const char *yystr)
893#else
894static YYSIZE_T
895yystrlen (yystr)
896 const char *yystr;
897#endif
898{
899 YYSIZE_T yylen;
900 for (yylen = 0; yystr[yylen]; yylen++)
901 continue;
902 return yylen;
903}
904# endif
905# endif
906
907# ifndef yystpcpy
908# if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE
909# define yystpcpy stpcpy
910# else
911/* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
912 YYDEST. */
913#if (defined __STDC__ || defined __C99__FUNC__ \
914 || defined __cplusplus || defined _MSC_VER)
915static char *
916yystpcpy (char *yydest, const char *yysrc)
917#else
918static char *
919yystpcpy (yydest, yysrc)
920 char *yydest;
921 const char *yysrc;
922#endif
923{
924 char *yyd = yydest;
925 const char *yys = yysrc;
926
927 while ((*yyd++ = *yys++) != '\0')
928 continue;
929
930 return yyd - 1;
931}
932# endif
933# endif
934
935# ifndef yytnamerr
936/* Copy to YYRES the contents of YYSTR after stripping away unnecessary
937 quotes and backslashes, so that it's suitable for yyerror. The
938 heuristic is that double-quoting is unnecessary unless the string
939 contains an apostrophe, a comma, or backslash (other than
940 backslash-backslash). YYSTR is taken from yytname. If YYRES is
941 null, do not copy; instead, return the length of what the result
942 would have been. */
943static YYSIZE_T
944yytnamerr (char *yyres, const char *yystr)
945{
946 if (*yystr == '"')
947 {
948 YYSIZE_T yyn = 0;
949 char const *yyp = yystr;
950
951 for (;;)
952 switch (*++yyp)
953 {
954 case '\'':
955 case ',':
956 goto do_not_strip_quotes;
957
958 case '\\':
959 if (*++yyp != '\\')
960 goto do_not_strip_quotes;
961 /* Fall through. */
962 default:
963 if (yyres)
964 yyres[yyn] = *yyp;
965 yyn++;
966 break;
967
968 case '"':
969 if (yyres)
970 yyres[yyn] = '\0';
971 return yyn;
972 }
973 do_not_strip_quotes: ;
974 }
975
976 if (! yyres)
977 return yystrlen (yystr);
978
979 return yystpcpy (yyres, yystr) - yyres;
980}
981# endif
982
983/* Copy into *YYMSG, which is of size *YYMSG_ALLOC, an error message
984 about the unexpected token YYTOKEN for the state stack whose top is
985 YYSSP.
986
987 Return 0 if *YYMSG was successfully written. Return 1 if *YYMSG is
988 not large enough to hold the message. In that case, also set
989 *YYMSG_ALLOC to the required number of bytes. Return 2 if the
990 required number of bytes is too large to store. */
991static int
992yysyntax_error (YYSIZE_T *yymsg_alloc, char **yymsg,
993 yytype_int16 *yyssp, int yytoken)
994{
995 YYSIZE_T yysize0 = yytnamerr (0, yytname[yytoken]);
996 YYSIZE_T yysize = yysize0;
997 YYSIZE_T yysize1;
998 enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 };
999 /* Internationalized format string. */
1000 const char *yyformat = 0;
1001 /* Arguments of yyformat. */
1002 char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM];
1003 /* Number of reported tokens (one for the "unexpected", one per
1004 "expected"). */
1005 int yycount = 0;
1006
1007 /* There are many possibilities here to consider:
1008 - Assume YYFAIL is not used. It's too flawed to consider. See
1009 <http://lists.gnu.org/archive/html/bison-patches/2009-12/msg00024.html>
1010 for details. YYERROR is fine as it does not invoke this
1011 function.
1012 - If this state is a consistent state with a default action, then
1013 the only way this function was invoked is if the default action
1014 is an error action. In that case, don't check for expected
1015 tokens because there are none.
1016 - The only way there can be no lookahead present (in yychar) is if
1017 this state is a consistent state with a default action. Thus,
1018 detecting the absence of a lookahead is sufficient to determine
1019 that there is no unexpected or expected token to report. In that
1020 case, just report a simple "syntax error".
1021 - Don't assume there isn't a lookahead just because this state is a
1022 consistent state with a default action. There might have been a
1023 previous inconsistent state, consistent state with a non-default
1024 action, or user semantic action that manipulated yychar.
1025 - Of course, the expected token list depends on states to have
1026 correct lookahead information, and it depends on the parser not
1027 to perform extra reductions after fetching a lookahead from the
1028 scanner and before detecting a syntax error. Thus, state merging
1029 (from LALR or IELR) and default reductions corrupt the expected
1030 token list. However, the list is correct for canonical LR with
1031 one exception: it will still contain any token that will not be
1032 accepted due to an error action in a later state.
1033 */
1034 if (yytoken != YYEMPTY)
1035 {
1036 int yyn = yypact[*yyssp];
1037 yyarg[yycount++] = yytname[yytoken];
1038 if (!yypact_value_is_default (yyn))
1039 {
1040 /* Start YYX at -YYN if negative to avoid negative indexes in
1041 YYCHECK. In other words, skip the first -YYN actions for
1042 this state because they are default actions. */
1043 int yyxbegin = yyn < 0 ? -yyn : 0;
1044 /* Stay within bounds of both yycheck and yytname. */
1045 int yychecklim = YYLAST - yyn + 1;
1046 int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS;
1047 int yyx;
1048
1049 for (yyx = yyxbegin; yyx < yyxend; ++yyx)
1050 if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR
1051 && !yytable_value_is_error (yytable[yyx + yyn]))
1052 {
1053 if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM)
1054 {
1055 yycount = 1;
1056 yysize = yysize0;
1057 break;
1058 }
1059 yyarg[yycount++] = yytname[yyx];
1060 yysize1 = yysize + yytnamerr (0, yytname[yyx]);
1061 if (! (yysize <= yysize1
1062 && yysize1 <= YYSTACK_ALLOC_MAXIMUM))
1063 return 2;
1064 yysize = yysize1;
1065 }
1066 }
1067 }
1068
1069 switch (yycount)
1070 {
1071# define YYCASE_(N, S) \
1072 case N: \
1073 yyformat = S; \
1074 break
1075 YYCASE_(0, YY_("syntax error"));
1076 YYCASE_(1, YY_("syntax error, unexpected %s"));
1077 YYCASE_(2, YY_("syntax error, unexpected %s, expecting %s"));
1078 YYCASE_(3, YY_("syntax error, unexpected %s, expecting %s or %s"));
1079 YYCASE_(4, YY_("syntax error, unexpected %s, expecting %s or %s or %s"));
1080 YYCASE_(5, YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s"));
1081# undef YYCASE_
1082 }
1083
1084 yysize1 = yysize + yystrlen (yyformat);
1085 if (! (yysize <= yysize1 && yysize1 <= YYSTACK_ALLOC_MAXIMUM))
1086 return 2;
1087 yysize = yysize1;
1088
1089 if (*yymsg_alloc < yysize)
1090 {
1091 *yymsg_alloc = 2 * yysize;
1092 if (! (yysize <= *yymsg_alloc
1093 && *yymsg_alloc <= YYSTACK_ALLOC_MAXIMUM))
1094 *yymsg_alloc = YYSTACK_ALLOC_MAXIMUM;
1095 return 1;
1096 }
1097
1098 /* Avoid sprintf, as that infringes on the user's name space.
1099 Don't have undefined behavior even if the translation
1100 produced a string with the wrong number of "%s"s. */
1101 {
1102 char *yyp = *yymsg;
1103 int yyi = 0;
1104 while ((*yyp = *yyformat) != '\0')
1105 if (*yyp == '%' && yyformat[1] == 's' && yyi < yycount)
1106 {
1107 yyp += yytnamerr (yyp, yyarg[yyi++]);
1108 yyformat += 2;
1109 }
1110 else
1111 {
1112 yyp++;
1113 yyformat++;
1114 }
1115 }
1116 return 0;
1117}
1118#endif /* YYERROR_VERBOSE */
1119
1120/*-----------------------------------------------.
1121| Release the memory associated to this symbol. |
1122`-----------------------------------------------*/
1123
1124/*ARGSUSED*/
1125#if (defined __STDC__ || defined __C99__FUNC__ \
1126 || defined __cplusplus || defined _MSC_VER)
1127static void
1128yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep, struct list_head *list_all, struct list_head *list_event, int *idx)
1129#else
1130static void
1131yydestruct (yymsg, yytype, yyvaluep, list_all, list_event, idx)
1132 const char *yymsg;
1133 int yytype;
1134 YYSTYPE *yyvaluep;
1135 struct list_head *list_all;
1136 struct list_head *list_event;
1137 int *idx;
1138#endif
1139{
1140 YYUSE (yyvaluep);
1141 YYUSE (list_all);
1142 YYUSE (list_event);
1143 YYUSE (idx);
1144
1145 if (!yymsg)
1146 yymsg = "Deleting";
1147 YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp);
1148
1149 switch (yytype)
1150 {
1151
1152 default:
1153 break;
1154 }
1155}
1156
1157
1158/* Prevent warnings from -Wmissing-prototypes. */
1159#ifdef YYPARSE_PARAM
1160#if defined __STDC__ || defined __cplusplus
1161int yyparse (void *YYPARSE_PARAM);
1162#else
1163int yyparse ();
1164#endif
1165#else /* ! YYPARSE_PARAM */
1166#if defined __STDC__ || defined __cplusplus
1167int yyparse (struct list_head *list_all, struct list_head *list_event, int *idx);
1168#else
1169int yyparse ();
1170#endif
1171#endif /* ! YYPARSE_PARAM */
1172
1173
1174/* The lookahead symbol. */
1175int yychar;
1176
1177/* The semantic value of the lookahead symbol. */
1178YYSTYPE yylval;
1179
1180/* Number of syntax errors so far. */
1181int yynerrs;
1182
1183
1184/*----------.
1185| yyparse. |
1186`----------*/
1187
1188#ifdef YYPARSE_PARAM
1189#if (defined __STDC__ || defined __C99__FUNC__ \
1190 || defined __cplusplus || defined _MSC_VER)
1191int
1192yyparse (void *YYPARSE_PARAM)
1193#else
1194int
1195yyparse (YYPARSE_PARAM)
1196 void *YYPARSE_PARAM;
1197#endif
1198#else /* ! YYPARSE_PARAM */
1199#if (defined __STDC__ || defined __C99__FUNC__ \
1200 || defined __cplusplus || defined _MSC_VER)
1201int
1202yyparse (struct list_head *list_all, struct list_head *list_event, int *idx)
1203#else
1204int
1205yyparse (list_all, list_event, idx)
1206 struct list_head *list_all;
1207 struct list_head *list_event;
1208 int *idx;
1209#endif
1210#endif
1211{
1212 int yystate;
1213 /* Number of tokens to shift before error messages enabled. */
1214 int yyerrstatus;
1215
1216 /* The stacks and their tools:
1217 `yyss': related to states.
1218 `yyvs': related to semantic values.
1219
1220 Refer to the stacks thru separate pointers, to allow yyoverflow
1221 to reallocate them elsewhere. */
1222
1223 /* The state stack. */
1224 yytype_int16 yyssa[YYINITDEPTH];
1225 yytype_int16 *yyss;
1226 yytype_int16 *yyssp;
1227
1228 /* The semantic value stack. */
1229 YYSTYPE yyvsa[YYINITDEPTH];
1230 YYSTYPE *yyvs;
1231 YYSTYPE *yyvsp;
1232
1233 YYSIZE_T yystacksize;
1234
1235 int yyn;
1236 int yyresult;
1237 /* Lookahead token as an internal (translated) token number. */
1238 int yytoken;
1239 /* The variables used to return semantic value and location from the
1240 action routines. */
1241 YYSTYPE yyval;
1242
1243#if YYERROR_VERBOSE
1244 /* Buffer for error messages, and its allocated size. */
1245 char yymsgbuf[128];
1246 char *yymsg = yymsgbuf;
1247 YYSIZE_T yymsg_alloc = sizeof yymsgbuf;
1248#endif
1249
1250#define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N))
1251
1252 /* The number of symbols on the RHS of the reduced rule.
1253 Keep to zero when no symbol should be popped. */
1254 int yylen = 0;
1255
1256 yytoken = 0;
1257 yyss = yyssa;
1258 yyvs = yyvsa;
1259 yystacksize = YYINITDEPTH;
1260
1261 YYDPRINTF ((stderr, "Starting parse\n"));
1262
1263 yystate = 0;
1264 yyerrstatus = 0;
1265 yynerrs = 0;
1266 yychar = YYEMPTY; /* Cause a token to be read. */
1267
1268 /* Initialize stack pointers.
1269 Waste one element of value and location stack
1270 so that they stay on the same level as the state stack.
1271 The wasted elements are never initialized. */
1272 yyssp = yyss;
1273 yyvsp = yyvs;
1274
1275 goto yysetstate;
1276
1277/*------------------------------------------------------------.
1278| yynewstate -- Push a new state, which is found in yystate. |
1279`------------------------------------------------------------*/
1280 yynewstate:
1281 /* In all cases, when you get here, the value and location stacks
1282 have just been pushed. So pushing a state here evens the stacks. */
1283 yyssp++;
1284
1285 yysetstate:
1286 *yyssp = yystate;
1287
1288 if (yyss + yystacksize - 1 <= yyssp)
1289 {
1290 /* Get the current used size of the three stacks, in elements. */
1291 YYSIZE_T yysize = yyssp - yyss + 1;
1292
1293#ifdef yyoverflow
1294 {
1295 /* Give user a chance to reallocate the stack. Use copies of
1296 these so that the &'s don't force the real ones into
1297 memory. */
1298 YYSTYPE *yyvs1 = yyvs;
1299 yytype_int16 *yyss1 = yyss;
1300
1301 /* Each stack pointer address is followed by the size of the
1302 data in use in that stack, in bytes. This used to be a
1303 conditional around just the two extra args, but that might
1304 be undefined if yyoverflow is a macro. */
1305 yyoverflow (YY_("memory exhausted"),
1306 &yyss1, yysize * sizeof (*yyssp),
1307 &yyvs1, yysize * sizeof (*yyvsp),
1308 &yystacksize);
1309
1310 yyss = yyss1;
1311 yyvs = yyvs1;
1312 }
1313#else /* no yyoverflow */
1314# ifndef YYSTACK_RELOCATE
1315 goto yyexhaustedlab;
1316# else
1317 /* Extend the stack our own way. */
1318 if (YYMAXDEPTH <= yystacksize)
1319 goto yyexhaustedlab;
1320 yystacksize *= 2;
1321 if (YYMAXDEPTH < yystacksize)
1322 yystacksize = YYMAXDEPTH;
1323
1324 {
1325 yytype_int16 *yyss1 = yyss;
1326 union yyalloc *yyptr =
1327 (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
1328 if (! yyptr)
1329 goto yyexhaustedlab;
1330 YYSTACK_RELOCATE (yyss_alloc, yyss);
1331 YYSTACK_RELOCATE (yyvs_alloc, yyvs);
1332# undef YYSTACK_RELOCATE
1333 if (yyss1 != yyssa)
1334 YYSTACK_FREE (yyss1);
1335 }
1336# endif
1337#endif /* no yyoverflow */
1338
1339 yyssp = yyss + yysize - 1;
1340 yyvsp = yyvs + yysize - 1;
1341
1342 YYDPRINTF ((stderr, "Stack size increased to %lu\n",
1343 (unsigned long int) yystacksize));
1344
1345 if (yyss + yystacksize - 1 <= yyssp)
1346 YYABORT;
1347 }
1348
1349 YYDPRINTF ((stderr, "Entering state %d\n", yystate));
1350
1351 if (yystate == YYFINAL)
1352 YYACCEPT;
1353
1354 goto yybackup;
1355
1356/*-----------.
1357| yybackup. |
1358`-----------*/
1359yybackup:
1360
1361 /* Do appropriate processing given the current state. Read a
1362 lookahead token if we need one and don't already have one. */
1363
1364 /* First try to decide what to do without reference to lookahead token. */
1365 yyn = yypact[yystate];
1366 if (yypact_value_is_default (yyn))
1367 goto yydefault;
1368
1369 /* Not known => get a lookahead token if don't already have one. */
1370
1371 /* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol. */
1372 if (yychar == YYEMPTY)
1373 {
1374 YYDPRINTF ((stderr, "Reading a token: "));
1375 yychar = YYLEX;
1376 }
1377
1378 if (yychar <= YYEOF)
1379 {
1380 yychar = yytoken = YYEOF;
1381 YYDPRINTF ((stderr, "Now at end of input.\n"));
1382 }
1383 else
1384 {
1385 yytoken = YYTRANSLATE (yychar);
1386 YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc);
1387 }
1388
1389 /* If the proper action on seeing token YYTOKEN is to reduce or to
1390 detect an error, take that action. */
1391 yyn += yytoken;
1392 if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken)
1393 goto yydefault;
1394 yyn = yytable[yyn];
1395 if (yyn <= 0)
1396 {
1397 if (yytable_value_is_error (yyn))
1398 goto yyerrlab;
1399 yyn = -yyn;
1400 goto yyreduce;
1401 }
1402
1403 /* Count tokens shifted since error; after three, turn off error
1404 status. */
1405 if (yyerrstatus)
1406 yyerrstatus--;
1407
1408 /* Shift the lookahead token. */
1409 YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc);
1410
1411 /* Discard the shifted token. */
1412 yychar = YYEMPTY;
1413
1414 yystate = yyn;
1415 *++yyvsp = yylval;
1416
1417 goto yynewstate;
1418
1419
1420/*-----------------------------------------------------------.
1421| yydefault -- do the default action for the current state. |
1422`-----------------------------------------------------------*/
1423yydefault:
1424 yyn = yydefact[yystate];
1425 if (yyn == 0)
1426 goto yyerrlab;
1427 goto yyreduce;
1428
1429
1430/*-----------------------------.
1431| yyreduce -- Do a reduction. |
1432`-----------------------------*/
1433yyreduce:
1434 /* yyn is the number of a rule to reduce with. */
1435 yylen = yyr2[yyn];
1436
1437 /* If YYLEN is nonzero, implement the default value of the action:
1438 `$$ = $1'.
1439
1440 Otherwise, the following line sets YYVAL to garbage.
1441 This behavior is undocumented and Bison
1442 users should not rely upon it. Assigning to YYVAL
1443 unconditionally makes the parser a bit smaller, and it avoids a
1444 GCC warning that YYVAL may be used uninitialized. */
1445 yyval = yyvsp[1-yylen];
1446
1447
1448 YY_REDUCE_PRINT (yyn);
1449 switch (yyn)
1450 {
1451 case 4:
1452
1453/* Line 1806 of yacc.c */
1454#line 59 "util/parse-events.y"
1455 {
1456 /*
1457 * Apply modifier on all events added by single event definition
1458 * (there could be more events added for multiple tracepoint
1459 * definitions via '*?'.
1460 */
1461 ABORT_ON(parse_events_modifier(list_event, (yyvsp[(2) - (2)].str)));
1462 parse_events_update_lists(list_event, list_all);
1463}
1464 break;
1465
1466 case 5:
1467
1468/* Line 1806 of yacc.c */
1469#line 70 "util/parse-events.y"
1470 {
1471 parse_events_update_lists(list_event, list_all);
1472}
1473 break;
1474
1475 case 13:
1476
1477/* Line 1806 of yacc.c */
1478#line 84 "util/parse-events.y"
1479 {
1480 ABORT_ON(parse_events_add_pmu(list_event, idx, (yyvsp[(1) - (4)].str), (yyvsp[(3) - (4)].head)));
1481 parse_events__free_terms((yyvsp[(3) - (4)].head));
1482}
1483 break;
1484
1485 case 14:
1486
1487/* Line 1806 of yacc.c */
1488#line 91 "util/parse-events.y"
1489 {
1490 int type = (yyvsp[(1) - (4)].num) >> 16;
1491 int config = (yyvsp[(1) - (4)].num) & 255;
1492
1493 ABORT_ON(parse_events_add_numeric(list_event, idx, type, config, (yyvsp[(3) - (4)].head)));
1494 parse_events__free_terms((yyvsp[(3) - (4)].head));
1495}
1496 break;
1497
1498 case 15:
1499
1500/* Line 1806 of yacc.c */
1501#line 100 "util/parse-events.y"
1502 {
1503 int type = (yyvsp[(1) - (2)].num) >> 16;
1504 int config = (yyvsp[(1) - (2)].num) & 255;
1505
1506 ABORT_ON(parse_events_add_numeric(list_event, idx, type, config, NULL));
1507}
1508 break;
1509
1510 case 16:
1511
1512/* Line 1806 of yacc.c */
1513#line 109 "util/parse-events.y"
1514 {
1515 ABORT_ON(parse_events_add_cache(list_event, idx, (yyvsp[(1) - (5)].str), (yyvsp[(3) - (5)].str), (yyvsp[(5) - (5)].str)));
1516}
1517 break;
1518
1519 case 17:
1520
1521/* Line 1806 of yacc.c */
1522#line 114 "util/parse-events.y"
1523 {
1524 ABORT_ON(parse_events_add_cache(list_event, idx, (yyvsp[(1) - (3)].str), (yyvsp[(3) - (3)].str), NULL));
1525}
1526 break;
1527
1528 case 18:
1529
1530/* Line 1806 of yacc.c */
1531#line 119 "util/parse-events.y"
1532 {
1533 ABORT_ON(parse_events_add_cache(list_event, idx, (yyvsp[(1) - (1)].str), NULL, NULL));
1534}
1535 break;
1536
1537 case 19:
1538
1539/* Line 1806 of yacc.c */
1540#line 125 "util/parse-events.y"
1541 {
1542 ABORT_ON(parse_events_add_breakpoint(list_event, idx, (void *) (yyvsp[(2) - (5)].num), (yyvsp[(4) - (5)].str)));
1543}
1544 break;
1545
1546 case 20:
1547
1548/* Line 1806 of yacc.c */
1549#line 130 "util/parse-events.y"
1550 {
1551 ABORT_ON(parse_events_add_breakpoint(list_event, idx, (void *) (yyvsp[(2) - (3)].num), NULL));
1552}
1553 break;
1554
1555 case 21:
1556
1557/* Line 1806 of yacc.c */
1558#line 136 "util/parse-events.y"
1559 {
1560 ABORT_ON(parse_events_add_tracepoint(list_event, idx, (yyvsp[(1) - (3)].str), (yyvsp[(3) - (3)].str)));
1561}
1562 break;
1563
1564 case 22:
1565
1566/* Line 1806 of yacc.c */
1567#line 142 "util/parse-events.y"
1568 {
1569 ABORT_ON(parse_events_add_numeric(list_event, idx, (yyvsp[(1) - (3)].num), (yyvsp[(3) - (3)].num), NULL));
1570}
1571 break;
1572
1573 case 23:
1574
1575/* Line 1806 of yacc.c */
1576#line 148 "util/parse-events.y"
1577 {
1578 ABORT_ON(parse_events_add_numeric(list_event, idx, PERF_TYPE_RAW, (yyvsp[(1) - (1)].num), NULL));
1579}
1580 break;
1581
1582 case 24:
1583
1584/* Line 1806 of yacc.c */
1585#line 154 "util/parse-events.y"
1586 {
1587 struct list_head *head = (yyvsp[(1) - (3)].head);
1588 struct parse_events__term *term = (yyvsp[(3) - (3)].term);
1589
1590 ABORT_ON(!head);
1591 list_add_tail(&term->list, head);
1592 (yyval.head) = (yyvsp[(1) - (3)].head);
1593}
1594 break;
1595
1596 case 25:
1597
1598/* Line 1806 of yacc.c */
1599#line 164 "util/parse-events.y"
1600 {
1601 struct list_head *head = malloc(sizeof(*head));
1602 struct parse_events__term *term = (yyvsp[(1) - (1)].term);
1603
1604 ABORT_ON(!head);
1605 INIT_LIST_HEAD(head);
1606 list_add_tail(&term->list, head);
1607 (yyval.head) = head;
1608}
1609 break;
1610
1611 case 26:
1612
1613/* Line 1806 of yacc.c */
1614#line 176 "util/parse-events.y"
1615 {
1616 struct parse_events__term *term;
1617
1618 ABORT_ON(parse_events__new_term(&term, PARSE_EVENTS__TERM_TYPE_STR,
1619 (yyvsp[(1) - (3)].str), (yyvsp[(3) - (3)].str), 0));
1620 (yyval.term) = term;
1621}
1622 break;
1623
1624 case 27:
1625
1626/* Line 1806 of yacc.c */
1627#line 185 "util/parse-events.y"
1628 {
1629 struct parse_events__term *term;
1630
1631 ABORT_ON(parse_events__new_term(&term, PARSE_EVENTS__TERM_TYPE_NUM,
1632 (yyvsp[(1) - (3)].str), NULL, (yyvsp[(3) - (3)].num)));
1633 (yyval.term) = term;
1634}
1635 break;
1636
1637 case 28:
1638
1639/* Line 1806 of yacc.c */
1640#line 194 "util/parse-events.y"
1641 {
1642 struct parse_events__term *term;
1643
1644 ABORT_ON(parse_events__new_term(&term, PARSE_EVENTS__TERM_TYPE_NUM,
1645 (yyvsp[(1) - (1)].str), NULL, 1));
1646 (yyval.term) = term;
1647}
1648 break;
1649
1650 case 29:
1651
1652/* Line 1806 of yacc.c */
1653#line 203 "util/parse-events.y"
1654 {
1655 struct parse_events__term *term;
1656
1657 ABORT_ON(parse_events__new_term(&term, (yyvsp[(1) - (3)].num), NULL, NULL, (yyvsp[(3) - (3)].num)));
1658 (yyval.term) = term;
1659}
1660 break;
1661
1662 case 30:
1663
1664/* Line 1806 of yacc.c */
1665#line 211 "util/parse-events.y"
1666 {
1667 struct parse_events__term *term;
1668
1669 ABORT_ON(parse_events__new_term(&term, (yyvsp[(1) - (1)].num), NULL, NULL, 1));
1670 (yyval.term) = term;
1671}
1672 break;
1673
1674
1675
1676/* Line 1806 of yacc.c */
1677#line 1678 "util/parse-events-bison.c"
1678 default: break;
1679 }
1680 /* User semantic actions sometimes alter yychar, and that requires
1681 that yytoken be updated with the new translation. We take the
1682 approach of translating immediately before every use of yytoken.
1683 One alternative is translating here after every semantic action,
1684 but that translation would be missed if the semantic action invokes
1685 YYABORT, YYACCEPT, or YYERROR immediately after altering yychar or
1686 if it invokes YYBACKUP. In the case of YYABORT or YYACCEPT, an
1687 incorrect destructor might then be invoked immediately. In the
1688 case of YYERROR or YYBACKUP, subsequent parser actions might lead
1689 to an incorrect destructor call or verbose syntax error message
1690 before the lookahead is translated. */
1691 YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc);
1692
1693 YYPOPSTACK (yylen);
1694 yylen = 0;
1695 YY_STACK_PRINT (yyss, yyssp);
1696
1697 *++yyvsp = yyval;
1698
1699 /* Now `shift' the result of the reduction. Determine what state
1700 that goes to, based on the state we popped back to and the rule
1701 number reduced by. */
1702
1703 yyn = yyr1[yyn];
1704
1705 yystate = yypgoto[yyn - YYNTOKENS] + *yyssp;
1706 if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp)
1707 yystate = yytable[yystate];
1708 else
1709 yystate = yydefgoto[yyn - YYNTOKENS];
1710
1711 goto yynewstate;
1712
1713
1714/*------------------------------------.
1715| yyerrlab -- here on detecting error |
1716`------------------------------------*/
1717yyerrlab:
1718 /* Make sure we have latest lookahead translation. See comments at
1719 user semantic actions for why this is necessary. */
1720 yytoken = yychar == YYEMPTY ? YYEMPTY : YYTRANSLATE (yychar);
1721
1722 /* If not already recovering from an error, report this error. */
1723 if (!yyerrstatus)
1724 {
1725 ++yynerrs;
1726#if ! YYERROR_VERBOSE
1727 yyerror (list_all, list_event, idx, YY_("syntax error"));
1728#else
1729# define YYSYNTAX_ERROR yysyntax_error (&yymsg_alloc, &yymsg, \
1730 yyssp, yytoken)
1731 {
1732 char const *yymsgp = YY_("syntax error");
1733 int yysyntax_error_status;
1734 yysyntax_error_status = YYSYNTAX_ERROR;
1735 if (yysyntax_error_status == 0)
1736 yymsgp = yymsg;
1737 else if (yysyntax_error_status == 1)
1738 {
1739 if (yymsg != yymsgbuf)
1740 YYSTACK_FREE (yymsg);
1741 yymsg = (char *) YYSTACK_ALLOC (yymsg_alloc);
1742 if (!yymsg)
1743 {
1744 yymsg = yymsgbuf;
1745 yymsg_alloc = sizeof yymsgbuf;
1746 yysyntax_error_status = 2;
1747 }
1748 else
1749 {
1750 yysyntax_error_status = YYSYNTAX_ERROR;
1751 yymsgp = yymsg;
1752 }
1753 }
1754 yyerror (list_all, list_event, idx, yymsgp);
1755 if (yysyntax_error_status == 2)
1756 goto yyexhaustedlab;
1757 }
1758# undef YYSYNTAX_ERROR
1759#endif
1760 }
1761
1762
1763
1764 if (yyerrstatus == 3)
1765 {
1766 /* If just tried and failed to reuse lookahead token after an
1767 error, discard it. */
1768
1769 if (yychar <= YYEOF)
1770 {
1771 /* Return failure if at end of input. */
1772 if (yychar == YYEOF)
1773 YYABORT;
1774 }
1775 else
1776 {
1777 yydestruct ("Error: discarding",
1778 yytoken, &yylval, list_all, list_event, idx);
1779 yychar = YYEMPTY;
1780 }
1781 }
1782
1783 /* Else will try to reuse lookahead token after shifting the error
1784 token. */
1785 goto yyerrlab1;
1786
1787
1788/*---------------------------------------------------.
1789| yyerrorlab -- error raised explicitly by YYERROR. |
1790`---------------------------------------------------*/
1791yyerrorlab:
1792
1793 /* Pacify compilers like GCC when the user code never invokes
1794 YYERROR and the label yyerrorlab therefore never appears in user
1795 code. */
1796 if (/*CONSTCOND*/ 0)
1797 goto yyerrorlab;
1798
1799 /* Do not reclaim the symbols of the rule which action triggered
1800 this YYERROR. */
1801 YYPOPSTACK (yylen);
1802 yylen = 0;
1803 YY_STACK_PRINT (yyss, yyssp);
1804 yystate = *yyssp;
1805 goto yyerrlab1;
1806
1807
1808/*-------------------------------------------------------------.
1809| yyerrlab1 -- common code for both syntax error and YYERROR. |
1810`-------------------------------------------------------------*/
1811yyerrlab1:
1812 yyerrstatus = 3; /* Each real token shifted decrements this. */
1813
1814 for (;;)
1815 {
1816 yyn = yypact[yystate];
1817 if (!yypact_value_is_default (yyn))
1818 {
1819 yyn += YYTERROR;
1820 if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR)
1821 {
1822 yyn = yytable[yyn];
1823 if (0 < yyn)
1824 break;
1825 }
1826 }
1827
1828 /* Pop the current state because it cannot handle the error token. */
1829 if (yyssp == yyss)
1830 YYABORT;
1831
1832
1833 yydestruct ("Error: popping",
1834 yystos[yystate], yyvsp, list_all, list_event, idx);
1835 YYPOPSTACK (1);
1836 yystate = *yyssp;
1837 YY_STACK_PRINT (yyss, yyssp);
1838 }
1839
1840 *++yyvsp = yylval;
1841
1842
1843 /* Shift the error token. */
1844 YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp);
1845
1846 yystate = yyn;
1847 goto yynewstate;
1848
1849
1850/*-------------------------------------.
1851| yyacceptlab -- YYACCEPT comes here. |
1852`-------------------------------------*/
1853yyacceptlab:
1854 yyresult = 0;
1855 goto yyreturn;
1856
1857/*-----------------------------------.
1858| yyabortlab -- YYABORT comes here. |
1859`-----------------------------------*/
1860yyabortlab:
1861 yyresult = 1;
1862 goto yyreturn;
1863
1864#if !defined(yyoverflow) || YYERROR_VERBOSE
1865/*-------------------------------------------------.
1866| yyexhaustedlab -- memory exhaustion comes here. |
1867`-------------------------------------------------*/
1868yyexhaustedlab:
1869 yyerror (list_all, list_event, idx, YY_("memory exhausted"));
1870 yyresult = 2;
1871 /* Fall through. */
1872#endif
1873
1874yyreturn:
1875 if (yychar != YYEMPTY)
1876 {
1877 /* Make sure we have latest lookahead translation. See comments at
1878 user semantic actions for why this is necessary. */
1879 yytoken = YYTRANSLATE (yychar);
1880 yydestruct ("Cleanup: discarding lookahead",
1881 yytoken, &yylval, list_all, list_event, idx);
1882 }
1883 /* Do not reclaim the symbols of the rule which action triggered
1884 this YYABORT or YYACCEPT. */
1885 YYPOPSTACK (yylen);
1886 YY_STACK_PRINT (yyss, yyssp);
1887 while (yyssp != yyss)
1888 {
1889 yydestruct ("Cleanup: popping",
1890 yystos[*yyssp], yyvsp, list_all, list_event, idx);
1891 YYPOPSTACK (1);
1892 }
1893#ifndef yyoverflow
1894 if (yyss != yyssa)
1895 YYSTACK_FREE (yyss);
1896#endif
1897#if YYERROR_VERBOSE
1898 if (yymsg != yymsgbuf)
1899 YYSTACK_FREE (yymsg);
1900#endif
1901 /* Make sure YYID is used. */
1902 return YYID (yyresult);
1903}
1904
1905
1906
1907/* Line 2067 of yacc.c */
1908#line 222 "util/parse-events.y"
1909
1910
1911void parse_events_error(struct list_head *list_all __used,
1912 struct list_head *list_event __used,
1913 int *idx __used,
1914 char const *msg __used)
1915{
1916}
1917
diff --git a/tools/perf/util/parse-events-bison.h b/tools/perf/util/parse-events-bison.h
new file mode 100644
index 000000000000..0be3e5ae2fed
--- /dev/null
+++ b/tools/perf/util/parse-events-bison.h
@@ -0,0 +1,81 @@
1/* A Bison parser, made by GNU Bison 2.5. */
2
3/* Bison interface for Yacc-like parsers in C
4
5 Copyright (C) 1984, 1989-1990, 2000-2011 Free Software Foundation, Inc.
6
7 This program is free software: you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation, either version 3 of the License, or
10 (at your option) any later version.
11
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with this program. If not, see <http://www.gnu.org/licenses/>. */
19
20/* As a special exception, you may create a larger work that contains
21 part or all of the Bison parser skeleton and distribute that work
22 under terms of your choice, so long as that work isn't itself a
23 parser generator using the skeleton or a modified version thereof
24 as a parser skeleton. Alternatively, if you modify or redistribute
25 the parser skeleton itself, you may (at your option) remove this
26 special exception, which will cause the skeleton and the resulting
27 Bison output files to be licensed under the GNU General Public
28 License without this special exception.
29
30 This special exception was added by the Free Software Foundation in
31 version 2.2 of Bison. */
32
33
34/* Tokens. */
35#ifndef YYTOKENTYPE
36# define YYTOKENTYPE
37 /* Put the tokens into the symbol table, so that GDB and other debuggers
38 know about them. */
39 enum yytokentype {
40 PE_VALUE = 258,
41 PE_VALUE_SYM = 259,
42 PE_RAW = 260,
43 PE_TERM = 261,
44 PE_NAME = 262,
45 PE_MODIFIER_EVENT = 263,
46 PE_MODIFIER_BP = 264,
47 PE_NAME_CACHE_TYPE = 265,
48 PE_NAME_CACHE_OP_RESULT = 266,
49 PE_PREFIX_MEM = 267,
50 PE_PREFIX_RAW = 268,
51 PE_ERROR = 269
52 };
53#endif
54
55
56
57#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
58typedef union YYSTYPE
59{
60
61/* Line 2068 of yacc.c */
62#line 46 "util/parse-events.y"
63
64 char *str;
65 unsigned long num;
66 struct list_head *head;
67 struct parse_events__term *term;
68
69
70
71/* Line 2068 of yacc.c */
72#line 73 "util/parse-events-bison.h"
73} YYSTYPE;
74# define YYSTYPE_IS_TRIVIAL 1
75# define yystype YYSTYPE /* obsolescent; will be withdrawn */
76# define YYSTYPE_IS_DECLARED 1
77#endif
78
79extern YYSTYPE parse_events_lval;
80
81
diff --git a/tools/perf/util/parse-events-flex.c b/tools/perf/util/parse-events-flex.c
new file mode 100644
index 000000000000..34cfc85c4f79
--- /dev/null
+++ b/tools/perf/util/parse-events-flex.c
@@ -0,0 +1,2272 @@
1
2#line 3 "<stdout>"
3
4#define YY_INT_ALIGNED short int
5
6/* A lexical scanner generated by flex */
7
8#define yy_create_buffer parse_events__create_buffer
9#define yy_delete_buffer parse_events__delete_buffer
10#define yy_flex_debug parse_events__flex_debug
11#define yy_init_buffer parse_events__init_buffer
12#define yy_flush_buffer parse_events__flush_buffer
13#define yy_load_buffer_state parse_events__load_buffer_state
14#define yy_switch_to_buffer parse_events__switch_to_buffer
15#define yyin parse_events_in
16#define yyleng parse_events_leng
17#define yylex parse_events_lex
18#define yylineno parse_events_lineno
19#define yyout parse_events_out
20#define yyrestart parse_events_restart
21#define yytext parse_events_text
22#define yywrap parse_events_wrap
23#define yyalloc parse_events_alloc
24#define yyrealloc parse_events_realloc
25#define yyfree parse_events_free
26
27#define FLEX_SCANNER
28#define YY_FLEX_MAJOR_VERSION 2
29#define YY_FLEX_MINOR_VERSION 5
30#define YY_FLEX_SUBMINOR_VERSION 35
31#if YY_FLEX_SUBMINOR_VERSION > 0
32#define FLEX_BETA
33#endif
34
35/* First, we deal with platform-specific or compiler-specific issues. */
36
37/* begin standard C headers. */
38#include <stdio.h>
39#include <string.h>
40#include <errno.h>
41#include <stdlib.h>
42
43/* end standard C headers. */
44
45/* flex integer type definitions */
46
47#ifndef FLEXINT_H
48#define FLEXINT_H
49
50/* C99 systems have <inttypes.h>. Non-C99 systems may or may not. */
51
52#if defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
53
54/* C99 says to define __STDC_LIMIT_MACROS before including stdint.h,
55 * if you want the limit (max/min) macros for int types.
56 */
57#ifndef __STDC_LIMIT_MACROS
58#define __STDC_LIMIT_MACROS 1
59#endif
60
61#include <inttypes.h>
62typedef int8_t flex_int8_t;
63typedef uint8_t flex_uint8_t;
64typedef int16_t flex_int16_t;
65typedef uint16_t flex_uint16_t;
66typedef int32_t flex_int32_t;
67typedef uint32_t flex_uint32_t;
68#else
69typedef signed char flex_int8_t;
70typedef short int flex_int16_t;
71typedef int flex_int32_t;
72typedef unsigned char flex_uint8_t;
73typedef unsigned short int flex_uint16_t;
74typedef unsigned int flex_uint32_t;
75#endif /* ! C99 */
76
77/* Limits of integral types. */
78#ifndef INT8_MIN
79#define INT8_MIN (-128)
80#endif
81#ifndef INT16_MIN
82#define INT16_MIN (-32767-1)
83#endif
84#ifndef INT32_MIN
85#define INT32_MIN (-2147483647-1)
86#endif
87#ifndef INT8_MAX
88#define INT8_MAX (127)
89#endif
90#ifndef INT16_MAX
91#define INT16_MAX (32767)
92#endif
93#ifndef INT32_MAX
94#define INT32_MAX (2147483647)
95#endif
96#ifndef UINT8_MAX
97#define UINT8_MAX (255U)
98#endif
99#ifndef UINT16_MAX
100#define UINT16_MAX (65535U)
101#endif
102#ifndef UINT32_MAX
103#define UINT32_MAX (4294967295U)
104#endif
105
106#endif /* ! FLEXINT_H */
107
108#ifdef __cplusplus
109
110/* The "const" storage-class-modifier is valid. */
111#define YY_USE_CONST
112
113#else /* ! __cplusplus */
114
115/* C99 requires __STDC__ to be defined as 1. */
116#if defined (__STDC__)
117
118#define YY_USE_CONST
119
120#endif /* defined (__STDC__) */
121#endif /* ! __cplusplus */
122
123#ifdef YY_USE_CONST
124#define yyconst const
125#else
126#define yyconst
127#endif
128
129/* Returned upon end-of-file. */
130#define YY_NULL 0
131
132/* Promotes a possibly negative, possibly signed char to an unsigned
133 * integer for use as an array index. If the signed char is negative,
134 * we want to instead treat it as an 8-bit unsigned char, hence the
135 * double cast.
136 */
137#define YY_SC_TO_UI(c) ((unsigned int) (unsigned char) c)
138
139/* Enter a start condition. This macro really ought to take a parameter,
140 * but we do it the disgusting crufty way forced on us by the ()-less
141 * definition of BEGIN.
142 */
143#define BEGIN (yy_start) = 1 + 2 *
144
145/* Translate the current start state into a value that can be later handed
146 * to BEGIN to return to the state. The YYSTATE alias is for lex
147 * compatibility.
148 */
149#define YY_START (((yy_start) - 1) / 2)
150#define YYSTATE YY_START
151
152/* Action number for EOF rule of a given start state. */
153#define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1)
154
155/* Special action meaning "start processing a new file". */
156#define YY_NEW_FILE parse_events_restart(parse_events_in )
157
158#define YY_END_OF_BUFFER_CHAR 0
159
160/* Size of default input buffer. */
161#ifndef YY_BUF_SIZE
162#define YY_BUF_SIZE 16384
163#endif
164
165/* The state buf must be large enough to hold one state per character in the main buffer.
166 */
167#define YY_STATE_BUF_SIZE ((YY_BUF_SIZE + 2) * sizeof(yy_state_type))
168
169#ifndef YY_TYPEDEF_YY_BUFFER_STATE
170#define YY_TYPEDEF_YY_BUFFER_STATE
171typedef struct yy_buffer_state *YY_BUFFER_STATE;
172#endif
173
174extern int parse_events_leng;
175
176extern FILE *parse_events_in, *parse_events_out;
177
178#define EOB_ACT_CONTINUE_SCAN 0
179#define EOB_ACT_END_OF_FILE 1
180#define EOB_ACT_LAST_MATCH 2
181
182 #define YY_LESS_LINENO(n)
183
184/* Return all but the first "n" matched characters back to the input stream. */
185#define yyless(n) \
186 do \
187 { \
188 /* Undo effects of setting up parse_events_text. */ \
189 int yyless_macro_arg = (n); \
190 YY_LESS_LINENO(yyless_macro_arg);\
191 *yy_cp = (yy_hold_char); \
192 YY_RESTORE_YY_MORE_OFFSET \
193 (yy_c_buf_p) = yy_cp = yy_bp + yyless_macro_arg - YY_MORE_ADJ; \
194 YY_DO_BEFORE_ACTION; /* set up parse_events_text again */ \
195 } \
196 while ( 0 )
197
198#define unput(c) yyunput( c, (yytext_ptr) )
199
200#ifndef YY_TYPEDEF_YY_SIZE_T
201#define YY_TYPEDEF_YY_SIZE_T
202typedef size_t yy_size_t;
203#endif
204
205#ifndef YY_STRUCT_YY_BUFFER_STATE
206#define YY_STRUCT_YY_BUFFER_STATE
207struct yy_buffer_state
208 {
209 FILE *yy_input_file;
210
211 char *yy_ch_buf; /* input buffer */
212 char *yy_buf_pos; /* current position in input buffer */
213
214 /* Size of input buffer in bytes, not including room for EOB
215 * characters.
216 */
217 yy_size_t yy_buf_size;
218
219 /* Number of characters read into yy_ch_buf, not including EOB
220 * characters.
221 */
222 int yy_n_chars;
223
224 /* Whether we "own" the buffer - i.e., we know we created it,
225 * and can realloc() it to grow it, and should free() it to
226 * delete it.
227 */
228 int yy_is_our_buffer;
229
230 /* Whether this is an "interactive" input source; if so, and
231 * if we're using stdio for input, then we want to use getc()
232 * instead of fread(), to make sure we stop fetching input after
233 * each newline.
234 */
235 int yy_is_interactive;
236
237 /* Whether we're considered to be at the beginning of a line.
238 * If so, '^' rules will be active on the next match, otherwise
239 * not.
240 */
241 int yy_at_bol;
242
243 int yy_bs_lineno; /**< The line count. */
244 int yy_bs_column; /**< The column count. */
245
246 /* Whether to try to fill the input buffer when we reach the
247 * end of it.
248 */
249 int yy_fill_buffer;
250
251 int yy_buffer_status;
252
253#define YY_BUFFER_NEW 0
254#define YY_BUFFER_NORMAL 1
255 /* When an EOF's been seen but there's still some text to process
256 * then we mark the buffer as YY_EOF_PENDING, to indicate that we
257 * shouldn't try reading from the input source any more. We might
258 * still have a bunch of tokens to match, though, because of
259 * possible backing-up.
260 *
261 * When we actually see the EOF, we change the status to "new"
262 * (via parse_events_restart()), so that the user can continue scanning by
263 * just pointing parse_events_in at a new input file.
264 */
265#define YY_BUFFER_EOF_PENDING 2
266
267 };
268#endif /* !YY_STRUCT_YY_BUFFER_STATE */
269
270/* Stack of input buffers. */
271static size_t yy_buffer_stack_top = 0; /**< index of top of stack. */
272static size_t yy_buffer_stack_max = 0; /**< capacity of stack. */
273static YY_BUFFER_STATE * yy_buffer_stack = 0; /**< Stack as an array. */
274
275/* We provide macros for accessing buffer states in case in the
276 * future we want to put the buffer states in a more general
277 * "scanner state".
278 *
279 * Returns the top of the stack, or NULL.
280 */
281#define YY_CURRENT_BUFFER ( (yy_buffer_stack) \
282 ? (yy_buffer_stack)[(yy_buffer_stack_top)] \
283 : NULL)
284
285/* Same as previous macro, but useful when we know that the buffer stack is not
286 * NULL or when we need an lvalue. For internal use only.
287 */
288#define YY_CURRENT_BUFFER_LVALUE (yy_buffer_stack)[(yy_buffer_stack_top)]
289
290/* yy_hold_char holds the character lost when parse_events_text is formed. */
291static char yy_hold_char;
292static int yy_n_chars; /* number of characters read into yy_ch_buf */
293int parse_events_leng;
294
295/* Points to current character in buffer. */
296static char *yy_c_buf_p = (char *) 0;
297static int yy_init = 0; /* whether we need to initialize */
298static int yy_start = 0; /* start state number */
299
300/* Flag which is used to allow parse_events_wrap()'s to do buffer switches
301 * instead of setting up a fresh parse_events_in. A bit of a hack ...
302 */
303static int yy_did_buffer_switch_on_eof;
304
305void parse_events_restart (FILE *input_file );
306void parse_events__switch_to_buffer (YY_BUFFER_STATE new_buffer );
307YY_BUFFER_STATE parse_events__create_buffer (FILE *file,int size );
308void parse_events__delete_buffer (YY_BUFFER_STATE b );
309void parse_events__flush_buffer (YY_BUFFER_STATE b );
310void parse_events_push_buffer_state (YY_BUFFER_STATE new_buffer );
311void parse_events_pop_buffer_state (void );
312
313static void parse_events_ensure_buffer_stack (void );
314static void parse_events__load_buffer_state (void );
315static void parse_events__init_buffer (YY_BUFFER_STATE b,FILE *file );
316
317#define YY_FLUSH_BUFFER parse_events__flush_buffer(YY_CURRENT_BUFFER )
318
319YY_BUFFER_STATE parse_events__scan_buffer (char *base,yy_size_t size );
320YY_BUFFER_STATE parse_events__scan_string (yyconst char *yy_str );
321YY_BUFFER_STATE parse_events__scan_bytes (yyconst char *bytes,int len );
322
323void *parse_events_alloc (yy_size_t );
324void *parse_events_realloc (void *,yy_size_t );
325void parse_events_free (void * );
326
327#define yy_new_buffer parse_events__create_buffer
328
329#define yy_set_interactive(is_interactive) \
330 { \
331 if ( ! YY_CURRENT_BUFFER ){ \
332 parse_events_ensure_buffer_stack (); \
333 YY_CURRENT_BUFFER_LVALUE = \
334 parse_events__create_buffer(parse_events_in,YY_BUF_SIZE ); \
335 } \
336 YY_CURRENT_BUFFER_LVALUE->yy_is_interactive = is_interactive; \
337 }
338
339#define yy_set_bol(at_bol) \
340 { \
341 if ( ! YY_CURRENT_BUFFER ){\
342 parse_events_ensure_buffer_stack (); \
343 YY_CURRENT_BUFFER_LVALUE = \
344 parse_events__create_buffer(parse_events_in,YY_BUF_SIZE ); \
345 } \
346 YY_CURRENT_BUFFER_LVALUE->yy_at_bol = at_bol; \
347 }
348
349#define YY_AT_BOL() (YY_CURRENT_BUFFER_LVALUE->yy_at_bol)
350
351/* Begin user sect3 */
352
353typedef unsigned char YY_CHAR;
354
355FILE *parse_events_in = (FILE *) 0, *parse_events_out = (FILE *) 0;
356
357typedef int yy_state_type;
358
359extern int parse_events_lineno;
360
361int parse_events_lineno = 1;
362
363extern char *parse_events_text;
364#define yytext_ptr parse_events_text
365
366static yy_state_type yy_get_previous_state (void );
367static yy_state_type yy_try_NUL_trans (yy_state_type current_state );
368static int yy_get_next_buffer (void );
369static void yy_fatal_error (yyconst char msg[] );
370
371/* Done after the current pattern has been matched and before the
372 * corresponding action - sets up parse_events_text.
373 */
374#define YY_DO_BEFORE_ACTION \
375 (yytext_ptr) = yy_bp; \
376 parse_events_leng = (size_t) (yy_cp - yy_bp); \
377 (yy_hold_char) = *yy_cp; \
378 *yy_cp = '\0'; \
379 (yy_c_buf_p) = yy_cp;
380
381#define YY_NUM_RULES 49
382#define YY_END_OF_BUFFER 50
383/* This struct is not used in this scanner,
384 but its presence is necessary. */
385struct yy_trans_info
386 {
387 flex_int32_t yy_verify;
388 flex_int32_t yy_nxt;
389 };
390static yyconst flex_int16_t yy_accept[440] =
391 { 0,
392 0, 0, 50, 49, 43, 46, 45, 44, 39, 39,
393 47, 48, 43, 43, 43, 43, 43, 43, 43, 43,
394 43, 43, 41, 43, 43, 43, 43, 43, 41, 42,
395 43, 43, 42, 42, 43, 39, 0, 43, 43, 43,
396 21, 43, 43, 43, 43, 43, 43, 43, 43, 43,
397 43, 43, 15, 43, 0, 43, 43, 43, 41, 0,
398 43, 43, 43, 43, 43, 43, 43, 43, 43, 43,
399 43, 43, 43, 38, 38, 43, 43, 43, 43, 40,
400 43, 43, 0, 43, 43, 43, 24, 43, 43, 43,
401 43, 43, 43, 0, 43, 43, 43, 41, 0, 43,
402
403 43, 43, 0, 19, 20, 43, 43, 43, 43, 43,
404 43, 43, 30, 43, 43, 43, 38, 38, 43, 43,
405 43, 43, 43, 43, 43, 0, 0, 43, 43, 43,
406 43, 0, 43, 43, 43, 0, 43, 0, 22, 43,
407 43, 41, 0, 23, 43, 43, 19, 20, 26, 43,
408 37, 43, 43, 31, 25, 43, 43, 43, 26, 43,
409 43, 43, 43, 43, 0, 43, 0, 0, 0, 0,
410 43, 43, 43, 43, 0, 43, 43, 43, 0, 0,
411 43, 22, 43, 43, 41, 23, 0, 43, 26, 43,
412 43, 43, 43, 0, 43, 43, 43, 43, 27, 0,
413
414 27, 0, 43, 0, 0, 0, 0, 43, 43, 24,
415 0, 0, 32, 43, 0, 0, 0, 1, 43, 12,
416 0, 43, 0, 43, 0, 31, 0, 35, 43, 43,
417 43, 0, 0, 43, 0, 0, 0, 43, 43, 0,
418 43, 43, 0, 0, 0, 33, 34, 43, 0, 0,
419 0, 43, 0, 43, 0, 43, 0, 0, 43, 43,
420 43, 0, 43, 0, 0, 0, 43, 43, 0, 0,
421 43, 7, 0, 0, 0, 0, 0, 0, 0, 43,
422 0, 43, 0, 43, 0, 0, 28, 43, 0, 0,
423 43, 0, 43, 0, 0, 43, 0, 0, 0, 0,
424
425 10, 0, 0, 43, 0, 43, 0, 43, 0, 0,
426 43, 43, 0, 0, 43, 0, 0, 0, 0, 43,
427 9, 0, 0, 0, 1, 0, 0, 0, 43, 0,
428 16, 0, 0, 28, 43, 0, 11, 43, 0, 0,
429 0, 0, 36, 0, 0, 0, 0, 0, 0, 43,
430 0, 0, 12, 43, 0, 0, 0, 0, 0, 0,
431 6, 0, 0, 0, 0, 0, 4, 14, 13, 0,
432 0, 0, 0, 0, 0, 8, 0, 0, 0, 0,
433 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
434 16, 0, 0, 0, 0, 0, 0, 0, 0, 0,
435
436 0, 0, 0, 0, 0, 0, 0, 17, 0, 5,
437 15, 18, 0, 0, 29, 0, 0, 0, 0, 0,
438 0, 0, 0, 0, 0, 0, 0, 7, 3, 0,
439 0, 0, 2, 0, 0, 0, 0, 0, 0
440 } ;
441
442static yyconst flex_int32_t yy_ec[256] =
443 { 0,
444 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
445 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
446 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
447 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
448 1, 2, 1, 3, 4, 1, 5, 6, 7, 8,
449 9, 9, 9, 9, 9, 9, 9, 10, 1, 1,
450 11, 1, 2, 1, 12, 13, 14, 15, 12, 12,
451 2, 2, 16, 2, 2, 17, 2, 2, 2, 2,
452 2, 18, 2, 19, 2, 2, 2, 2, 2, 2,
453 1, 1, 1, 1, 20, 1, 21, 22, 23, 24,
454
455 25, 26, 27, 28, 29, 30, 31, 32, 33, 34,
456 35, 36, 2, 37, 38, 39, 40, 41, 42, 43,
457 44, 2, 1, 1, 1, 1, 1, 1, 1, 1,
458 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
459 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
460 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
461 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
462 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
463 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
464 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
465
466 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
467 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
468 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
469 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
470 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
471 1, 1, 1, 1, 1
472 } ;
473
474static yyconst flex_int32_t yy_meta[45] =
475 { 0,
476 1, 2, 1, 1, 1, 3, 3, 3, 3, 1,
477 1, 3, 3, 3, 3, 2, 2, 2, 2, 2,
478 3, 3, 3, 3, 3, 3, 2, 2, 2, 2,
479 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
480 2, 2, 2, 2
481 } ;
482
483static yyconst flex_int16_t yy_base[442] =
484 { 0,
485 0, 0, 510, 511, 0, 511, 511, 511, 39, 43,
486 511, 511, 488, 474, 46, 482, 32, 20, 37, 57,
487 473, 484, 34, 64, 59, 64, 469, 467, 78, 113,
488 41, 481, 464, 0, 0, 104, 0, 461, 461, 494,
489 0, 483, 470, 472, 465, 44, 472, 470, 453, 467,
490 455, 448, 0, 464, 447, 468, 444, 443, 64, 443,
491 464, 448, 441, 67, 457, 447, 443, 52, 451, 436,
492 446, 435, 446, 445, 76, 444, 95, 430, 438, 0,
493 445, 426, 100, 439, 438, 435, 0, 427, 456, 431,
494 105, 454, 425, 424, 442, 422, 421, 112, 420, 438,
495
496 425, 410, 117, 0, 0, 424, 412, 436, 408, 409,
497 405, 417, 0, 416, 411, 413, 83, 107, 415, 405,
498 399, 404, 395, 429, 395, 126, 119, 394, 392, 395,
499 405, 404, 401, 396, 399, 100, 398, 400, 0, 400,
500 381, 123, 397, 0, 414, 380, 511, 511, 378, 378,
501 511, 393, 376, 387, 0, 407, 375, 384, 383, 367,
502 374, 380, 400, 378, 383, 361, 361, 378, 377, 359,
503 371, 357, 361, 365, 348, 387, 363, 346, 73, 359,
504 349, 511, 347, 347, 0, 511, 361, 343, 0, 378,
505 342, 376, 341, 352, 353, 337, 343, 349, 335, 349,
506
507 0, 354, 347, 348, 345, 344, 327, 331, 339, 146,
508 340, 123, 150, 323, 326, 337, 332, 0, 329, 0,
509 313, 333, 329, 325, 327, 0, 331, 0, 328, 329,
510 325, 316, 334, 307, 317, 316, 306, 319, 307, 132,
511 301, 301, 306, 308, 311, 0, 0, 331, 311, 301,
512 295, 296, 307, 290, 307, 292, 305, 285, 296, 284,
513 318, 286, 291, 294, 293, 277, 291, 276, 280, 284,
514 268, 0, 286, 272, 283, 270, 276, 281, 284, 270,
515 271, 273, 261, 266, 259, 266, 272, 267, 272, 271,
516 258, 269, 287, 252, 251, 252, 249, 248, 260, 242,
517
518 511, 245, 243, 277, 255, 244, 246, 239, 244, 236,
519 236, 232, 228, 240, 236, 230, 242, 228, 228, 240,
520 511, 239, 226, 233, 511, 232, 234, 221, 224, 218,
521 0, 217, 217, 0, 229, 230, 511, 248, 222, 229,
522 212, 223, 0, 209, 221, 206, 209, 222, 238, 203,
523 202, 201, 511, 234, 205, 217, 200, 194, 193, 194,
524 511, 197, 207, 195, 188, 142, 0, 511, 511, 130,
525 202, 209, 191, 192, 200, 511, 199, 193, 182, 187,
526 197, 180, 181, 190, 176, 200, 173, 172, 185, 184,
527 511, 169, 184, 171, 184, 183, 199, 164, 172, 162,
528
529 161, 160, 166, 162, 171, 170, 147, 511, 158, 511,
530 511, 511, 167, 152, 511, 169, 152, 154, 153, 161,
531 162, 149, 145, 158, 147, 149, 145, 511, 511, 154,
532 152, 137, 511, 138, 145, 131, 53, 54, 511, 172,
533 66
534 } ;
535
536static yyconst flex_int16_t yy_def[442] =
537 { 0,
538 439, 1, 439, 439, 440, 439, 439, 439, 439, 439,
539 439, 439, 440, 440, 440, 440, 440, 440, 440, 440,
540 440, 440, 440, 440, 440, 440, 440, 440, 440, 440,
541 440, 440, 440, 440, 440, 439, 441, 440, 440, 440,
542 440, 440, 440, 440, 440, 440, 440, 440, 440, 440,
543 440, 440, 440, 440, 439, 440, 440, 440, 440, 439,
544 440, 440, 440, 440, 440, 440, 440, 440, 440, 440,
545 440, 440, 440, 30, 30, 440, 440, 440, 440, 441,
546 440, 440, 439, 440, 440, 440, 440, 440, 440, 440,
547 440, 440, 440, 439, 440, 440, 440, 440, 439, 440,
548
549 440, 440, 439, 440, 440, 440, 440, 440, 440, 440,
550 440, 440, 440, 440, 440, 440, 30, 30, 440, 440,
551 440, 440, 440, 440, 440, 439, 439, 440, 440, 440,
552 440, 439, 440, 440, 440, 439, 440, 439, 440, 440,
553 440, 440, 439, 440, 440, 440, 439, 439, 440, 440,
554 439, 440, 440, 440, 440, 440, 440, 440, 30, 440,
555 440, 440, 440, 440, 439, 440, 439, 439, 439, 439,
556 440, 440, 440, 440, 439, 440, 440, 440, 439, 439,
557 440, 439, 440, 440, 440, 439, 439, 440, 440, 440,
558 440, 440, 440, 439, 440, 440, 440, 440, 440, 439,
559
560 440, 439, 440, 439, 439, 439, 439, 440, 440, 440,
561 439, 439, 440, 440, 439, 439, 439, 440, 440, 440,
562 439, 440, 439, 440, 439, 440, 439, 440, 440, 440,
563 440, 439, 439, 440, 439, 439, 439, 440, 440, 439,
564 440, 440, 439, 439, 439, 440, 440, 440, 439, 439,
565 439, 440, 439, 440, 439, 440, 439, 439, 440, 440,
566 440, 439, 440, 439, 439, 439, 440, 440, 439, 439,
567 440, 440, 439, 439, 439, 439, 439, 439, 439, 440,
568 439, 440, 439, 440, 439, 439, 440, 440, 439, 439,
569 440, 439, 440, 439, 439, 440, 439, 439, 439, 439,
570
571 439, 439, 439, 440, 439, 440, 439, 440, 439, 439,
572 440, 440, 439, 439, 440, 439, 439, 439, 439, 440,
573 439, 439, 439, 439, 439, 439, 439, 439, 440, 439,
574 440, 439, 439, 440, 440, 439, 439, 440, 439, 439,
575 439, 439, 440, 439, 439, 439, 439, 439, 439, 440,
576 439, 439, 439, 440, 439, 439, 439, 439, 439, 439,
577 439, 439, 439, 439, 439, 439, 440, 439, 439, 439,
578 439, 439, 439, 439, 439, 439, 439, 439, 439, 439,
579 439, 439, 439, 439, 439, 439, 439, 439, 439, 439,
580 439, 439, 439, 439, 439, 439, 439, 439, 439, 439,
581
582 439, 439, 439, 439, 439, 439, 439, 439, 439, 439,
583 439, 439, 439, 439, 439, 439, 439, 439, 439, 439,
584 439, 439, 439, 439, 439, 439, 439, 439, 439, 439,
585 439, 439, 439, 439, 439, 439, 439, 439, 0, 439,
586 439
587 } ;
588
589static yyconst flex_int16_t yy_nxt[556] =
590 { 0,
591 4, 5, 6, 7, 8, 9, 10, 10, 10, 11,
592 12, 5, 5, 5, 13, 14, 15, 16, 5, 5,
593 17, 18, 19, 20, 21, 22, 5, 23, 24, 5,
594 23, 25, 26, 27, 28, 29, 30, 31, 32, 23,
595 5, 33, 34, 5, 36, 36, 36, 36, 36, 36,
596 36, 36, 40, 41, 44, 46, 47, 50, 48, 49,
597 55, 59, 42, 45, 59, 64, 87, 60, 80, 59,
598 103, 51, 52, 59, 53, 56, 76, 433, 109, 77,
599 54, 37, 61, 87, 66, 110, 438, 62, 67, 111,
600 104, 98, 68, 65, 98, 105, 117, 63, 71, 98,
601
602 74, 118, 72, 98, 215, 59, 159, 74, 59, 36,
603 36, 36, 36, 59, 73, 120, 216, 59, 74, 74,
604 74, 74, 179, 126, 74, 74, 74, 74, 127, 121,
605 134, 74, 180, 74, 74, 74, 74, 75, 74, 142,
606 147, 169, 142, 135, 113, 148, 167, 142, 168, 240,
607 185, 142, 170, 185, 429, 244, 246, 247, 185, 245,
608 269, 383, 185, 381, 270, 241, 384, 382, 416, 437,
609 242, 436, 417, 35, 35, 435, 434, 433, 432, 431,
610 430, 429, 428, 427, 426, 425, 424, 423, 422, 421,
611 420, 419, 418, 415, 415, 414, 413, 412, 411, 410,
612
613 409, 408, 407, 406, 405, 404, 403, 402, 401, 400,
614 399, 398, 186, 397, 396, 395, 394, 393, 392, 391,
615 390, 389, 388, 387, 148, 386, 385, 380, 379, 378,
616 377, 376, 375, 374, 373, 372, 371, 370, 369, 368,
617 367, 366, 365, 364, 363, 362, 361, 360, 359, 358,
618 357, 356, 355, 354, 353, 352, 351, 350, 349, 348,
619 347, 346, 345, 344, 343, 342, 341, 340, 339, 338,
620 337, 336, 335, 334, 333, 332, 331, 330, 329, 328,
621 327, 326, 325, 324, 323, 322, 321, 320, 319, 318,
622 317, 316, 315, 314, 313, 312, 311, 310, 309, 308,
623
624 307, 306, 305, 304, 303, 302, 301, 300, 299, 298,
625 297, 296, 295, 294, 293, 113, 292, 148, 147, 291,
626 290, 289, 288, 287, 286, 285, 284, 283, 282, 281,
627 280, 279, 278, 277, 276, 275, 274, 273, 272, 271,
628 268, 267, 266, 265, 264, 263, 182, 262, 261, 260,
629 259, 258, 257, 256, 255, 254, 253, 252, 251, 250,
630 249, 248, 243, 239, 238, 237, 236, 235, 147, 234,
631 233, 232, 201, 231, 230, 229, 228, 227, 226, 225,
632 224, 223, 222, 221, 220, 219, 218, 217, 214, 213,
633 212, 211, 210, 209, 113, 208, 207, 206, 205, 204,
634
635 203, 202, 201, 200, 199, 198, 197, 74, 196, 195,
636 194, 193, 192, 191, 190, 189, 188, 187, 186, 184,
637 183, 182, 181, 178, 177, 176, 175, 174, 173, 172,
638 171, 166, 165, 164, 163, 162, 161, 160, 158, 157,
639 156, 155, 154, 153, 152, 151, 150, 149, 146, 145,
640 144, 143, 141, 140, 139, 138, 137, 136, 133, 132,
641 131, 130, 129, 128, 125, 124, 123, 122, 119, 74,
642 116, 115, 114, 113, 112, 108, 107, 106, 102, 101,
643 100, 99, 97, 96, 95, 94, 93, 92, 91, 90,
644 89, 87, 88, 86, 85, 84, 41, 83, 82, 81,
645
646 79, 78, 70, 69, 58, 57, 43, 39, 38, 439,
647 3, 439, 439, 439, 439, 439, 439, 439, 439, 439,
648 439, 439, 439, 439, 439, 439, 439, 439, 439, 439,
649 439, 439, 439, 439, 439, 439, 439, 439, 439, 439,
650 439, 439, 439, 439, 439, 439, 439, 439, 439, 439,
651 439, 439, 439, 439, 439
652 } ;
653
654static yyconst flex_int16_t yy_chk[556] =
655 { 0,
656 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
657 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
658 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
659 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
660 1, 1, 1, 1, 9, 9, 9, 9, 10, 10,
661 10, 10, 15, 15, 17, 18, 18, 19, 18, 18,
662 20, 23, 15, 17, 23, 25, 46, 24, 441, 23,
663 64, 19, 19, 23, 19, 20, 31, 438, 68, 31,
664 19, 9, 24, 46, 26, 68, 437, 24, 26, 68,
665 64, 59, 26, 25, 59, 64, 75, 24, 29, 59,
666
667 75, 75, 29, 59, 179, 29, 117, 117, 29, 36,
668 36, 36, 36, 29, 29, 77, 179, 29, 30, 30,
669 30, 30, 136, 83, 30, 30, 30, 30, 83, 77,
670 91, 118, 136, 30, 30, 30, 30, 30, 30, 98,
671 103, 127, 98, 91, 118, 103, 126, 98, 126, 210,
672 142, 98, 127, 142, 436, 212, 213, 213, 142, 212,
673 240, 370, 142, 366, 240, 210, 370, 366, 407, 435,
674 210, 434, 407, 440, 440, 432, 431, 430, 427, 426,
675 425, 424, 423, 422, 421, 420, 419, 418, 417, 416,
676 414, 413, 409, 406, 405, 404, 403, 402, 401, 400,
677
678 399, 398, 397, 396, 395, 394, 393, 392, 390, 389,
679 388, 387, 386, 385, 384, 383, 382, 381, 380, 379,
680 378, 377, 375, 374, 373, 372, 371, 365, 364, 363,
681 362, 360, 359, 358, 357, 356, 355, 354, 352, 351,
682 350, 349, 348, 347, 346, 345, 344, 342, 341, 340,
683 339, 338, 336, 335, 333, 332, 330, 329, 328, 327,
684 326, 324, 323, 322, 320, 319, 318, 317, 316, 315,
685 314, 313, 312, 311, 310, 309, 308, 307, 306, 305,
686 304, 303, 302, 300, 299, 298, 297, 296, 295, 294,
687 293, 292, 291, 290, 289, 288, 287, 286, 285, 284,
688
689 283, 282, 281, 280, 279, 278, 277, 276, 275, 274,
690 273, 271, 270, 269, 268, 267, 266, 265, 264, 263,
691 262, 261, 260, 259, 258, 257, 256, 255, 254, 253,
692 252, 251, 250, 249, 248, 245, 244, 243, 242, 241,
693 239, 238, 237, 236, 235, 234, 233, 232, 231, 230,
694 229, 227, 225, 224, 223, 222, 221, 219, 217, 216,
695 215, 214, 211, 209, 208, 207, 206, 205, 204, 203,
696 202, 200, 199, 198, 197, 196, 195, 194, 193, 192,
697 191, 190, 188, 187, 184, 183, 181, 180, 178, 177,
698 176, 175, 174, 173, 172, 171, 170, 169, 168, 167,
699
700 166, 165, 164, 163, 162, 161, 160, 159, 158, 157,
701 156, 154, 153, 152, 150, 149, 146, 145, 143, 141,
702 140, 138, 137, 135, 134, 133, 132, 131, 130, 129,
703 128, 125, 124, 123, 122, 121, 120, 119, 116, 115,
704 114, 112, 111, 110, 109, 108, 107, 106, 102, 101,
705 100, 99, 97, 96, 95, 94, 93, 92, 90, 89,
706 88, 86, 85, 84, 82, 81, 79, 78, 76, 74,
707 73, 72, 71, 70, 69, 67, 66, 65, 63, 62,
708 61, 60, 58, 57, 56, 55, 54, 52, 51, 50,
709 49, 48, 47, 45, 44, 43, 42, 40, 39, 38,
710
711 33, 32, 28, 27, 22, 21, 16, 14, 13, 3,
712 439, 439, 439, 439, 439, 439, 439, 439, 439, 439,
713 439, 439, 439, 439, 439, 439, 439, 439, 439, 439,
714 439, 439, 439, 439, 439, 439, 439, 439, 439, 439,
715 439, 439, 439, 439, 439, 439, 439, 439, 439, 439,
716 439, 439, 439, 439, 439
717 } ;
718
719static yy_state_type yy_last_accepting_state;
720static char *yy_last_accepting_cpos;
721
722extern int parse_events__flex_debug;
723int parse_events__flex_debug = 0;
724
725/* The intent behind this definition is that it'll catch
726 * any uses of REJECT which flex missed.
727 */
728#define REJECT reject_used_but_not_detected
729#define yymore() yymore_used_but_not_detected
730#define YY_MORE_ADJ 0
731#define YY_RESTORE_YY_MORE_OFFSET
732char *parse_events_text;
733#line 1 "util/parse-events.l"
734#line 5 "util/parse-events.l"
735#include <errno.h>
736#include "../perf.h"
737#include "parse-events-bison.h"
738#include "parse-events.h"
739
740static int __value(char *str, int base, int token)
741{
742 long num;
743
744 errno = 0;
745 num = strtoul(str, NULL, base);
746 if (errno)
747 return PE_ERROR;
748
749 parse_events_lval.num = num;
750 return token;
751}
752
753static int value(int base)
754{
755 return __value(parse_events_text, base, PE_VALUE);
756}
757
758static int raw(void)
759{
760 return __value(parse_events_text + 1, 16, PE_RAW);
761}
762
763static int str(int token)
764{
765 parse_events_lval.str = strdup(parse_events_text);
766 return token;
767}
768
769static int sym(int type, int config)
770{
771 parse_events_lval.num = (type << 16) + config;
772 return PE_VALUE_SYM;
773}
774
775static int term(int type)
776{
777 parse_events_lval.num = type;
778 return PE_TERM;
779}
780
781#line 782 "<stdout>"
782
783#define INITIAL 0
784
785#ifndef YY_NO_UNISTD_H
786/* Special case for "unistd.h", since it is non-ANSI. We include it way
787 * down here because we want the user's section 1 to have been scanned first.
788 * The user has a chance to override it with an option.
789 */
790#include <unistd.h>
791#endif
792
793#ifndef YY_EXTRA_TYPE
794#define YY_EXTRA_TYPE void *
795#endif
796
797static int yy_init_globals (void );
798
799/* Accessor methods to globals.
800 These are made visible to non-reentrant scanners for convenience. */
801
802int parse_events_lex_destroy (void );
803
804int parse_events_get_debug (void );
805
806void parse_events_set_debug (int debug_flag );
807
808YY_EXTRA_TYPE parse_events_get_extra (void );
809
810void parse_events_set_extra (YY_EXTRA_TYPE user_defined );
811
812FILE *parse_events_get_in (void );
813
814void parse_events_set_in (FILE * in_str );
815
816FILE *parse_events_get_out (void );
817
818void parse_events_set_out (FILE * out_str );
819
820int parse_events_get_leng (void );
821
822char *parse_events_get_text (void );
823
824int parse_events_get_lineno (void );
825
826void parse_events_set_lineno (int line_number );
827
828/* Macros after this point can all be overridden by user definitions in
829 * section 1.
830 */
831
832#ifndef YY_SKIP_YYWRAP
833#ifdef __cplusplus
834extern "C" int parse_events_wrap (void );
835#else
836extern int parse_events_wrap (void );
837#endif
838#endif
839
840 static void yyunput (int c,char *buf_ptr );
841
842#ifndef yytext_ptr
843static void yy_flex_strncpy (char *,yyconst char *,int );
844#endif
845
846#ifdef YY_NEED_STRLEN
847static int yy_flex_strlen (yyconst char * );
848#endif
849
850#ifndef YY_NO_INPUT
851
852#ifdef __cplusplus
853static int yyinput (void );
854#else
855static int input (void );
856#endif
857
858#endif
859
860/* Amount of stuff to slurp up with each read. */
861#ifndef YY_READ_BUF_SIZE
862#define YY_READ_BUF_SIZE 8192
863#endif
864
865/* Copy whatever the last rule matched to the standard output. */
866#ifndef ECHO
867/* This used to be an fputs(), but since the string might contain NUL's,
868 * we now use fwrite().
869 */
870#define ECHO do { if (fwrite( parse_events_text, parse_events_leng, 1, parse_events_out )) {} } while (0)
871#endif
872
873/* Gets input and stuffs it into "buf". number of characters read, or YY_NULL,
874 * is returned in "result".
875 */
876#ifndef YY_INPUT
877#define YY_INPUT(buf,result,max_size) \
878 if ( YY_CURRENT_BUFFER_LVALUE->yy_is_interactive ) \
879 { \
880 int c = '*'; \
881 unsigned n; \
882 for ( n = 0; n < max_size && \
883 (c = getc( parse_events_in )) != EOF && c != '\n'; ++n ) \
884 buf[n] = (char) c; \
885 if ( c == '\n' ) \
886 buf[n++] = (char) c; \
887 if ( c == EOF && ferror( parse_events_in ) ) \
888 YY_FATAL_ERROR( "input in flex scanner failed" ); \
889 result = n; \
890 } \
891 else \
892 { \
893 errno=0; \
894 while ( (result = fread(buf, 1, max_size, parse_events_in))==0 && ferror(parse_events_in)) \
895 { \
896 if( errno != EINTR) \
897 { \
898 YY_FATAL_ERROR( "input in flex scanner failed" ); \
899 break; \
900 } \
901 errno=0; \
902 clearerr(parse_events_in); \
903 } \
904 }\
905\
906
907#endif
908
909/* No semi-colon after return; correct usage is to write "yyterminate();" -
910 * we don't want an extra ';' after the "return" because that will cause
911 * some compilers to complain about unreachable statements.
912 */
913#ifndef yyterminate
914#define yyterminate() return YY_NULL
915#endif
916
917/* Number of entries by which start-condition stack grows. */
918#ifndef YY_START_STACK_INCR
919#define YY_START_STACK_INCR 25
920#endif
921
922/* Report a fatal error. */
923#ifndef YY_FATAL_ERROR
924#define YY_FATAL_ERROR(msg) yy_fatal_error( msg )
925#endif
926
927/* end tables serialization structures and prototypes */
928
929/* Default declaration of generated scanner - a define so the user can
930 * easily add parameters.
931 */
932#ifndef YY_DECL
933#define YY_DECL_IS_OURS 1
934
935extern int parse_events_lex (void);
936
937#define YY_DECL int parse_events_lex (void)
938#endif /* !YY_DECL */
939
940/* Code executed at the beginning of each rule, after parse_events_text and parse_events_leng
941 * have been set up.
942 */
943#ifndef YY_USER_ACTION
944#define YY_USER_ACTION
945#endif
946
947/* Code executed at the end of each rule. */
948#ifndef YY_BREAK
949#define YY_BREAK break;
950#endif
951
952#define YY_RULE_SETUP \
953 YY_USER_ACTION
954
955/** The main scanner function which does all the work.
956 */
957YY_DECL
958{
959 register yy_state_type yy_current_state;
960 register char *yy_cp, *yy_bp;
961 register int yy_act;
962
963#line 60 "util/parse-events.l"
964
965#line 966 "<stdout>"
966
967 if ( !(yy_init) )
968 {
969 (yy_init) = 1;
970
971#ifdef YY_USER_INIT
972 YY_USER_INIT;
973#endif
974
975 if ( ! (yy_start) )
976 (yy_start) = 1; /* first start state */
977
978 if ( ! parse_events_in )
979 parse_events_in = stdin;
980
981 if ( ! parse_events_out )
982 parse_events_out = stdout;
983
984 if ( ! YY_CURRENT_BUFFER ) {
985 parse_events_ensure_buffer_stack ();
986 YY_CURRENT_BUFFER_LVALUE =
987 parse_events__create_buffer(parse_events_in,YY_BUF_SIZE );
988 }
989
990 parse_events__load_buffer_state( );
991 }
992
993 while ( 1 ) /* loops until end-of-file is reached */
994 {
995 yy_cp = (yy_c_buf_p);
996
997 /* Support of parse_events_text. */
998 *yy_cp = (yy_hold_char);
999
1000 /* yy_bp points to the position in yy_ch_buf of the start of
1001 * the current run.
1002 */
1003 yy_bp = yy_cp;
1004
1005 yy_current_state = (yy_start);
1006yy_match:
1007 do
1008 {
1009 register YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)];
1010 if ( yy_accept[yy_current_state] )
1011 {
1012 (yy_last_accepting_state) = yy_current_state;
1013 (yy_last_accepting_cpos) = yy_cp;
1014 }
1015 while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
1016 {
1017 yy_current_state = (int) yy_def[yy_current_state];
1018 if ( yy_current_state >= 440 )
1019 yy_c = yy_meta[(unsigned int) yy_c];
1020 }
1021 yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
1022 ++yy_cp;
1023 }
1024 while ( yy_base[yy_current_state] != 511 );
1025
1026yy_find_action:
1027 yy_act = yy_accept[yy_current_state];
1028 if ( yy_act == 0 )
1029 { /* have to back up */
1030 yy_cp = (yy_last_accepting_cpos);
1031 yy_current_state = (yy_last_accepting_state);
1032 yy_act = yy_accept[yy_current_state];
1033 }
1034
1035 YY_DO_BEFORE_ACTION;
1036
1037do_action: /* This label is used only to access EOF actions. */
1038
1039 switch ( yy_act )
1040 { /* beginning of action switch */
1041 case 0: /* must back up */
1042 /* undo the effects of YY_DO_BEFORE_ACTION */
1043 *yy_cp = (yy_hold_char);
1044 yy_cp = (yy_last_accepting_cpos);
1045 yy_current_state = (yy_last_accepting_state);
1046 goto yy_find_action;
1047
1048case 1:
1049YY_RULE_SETUP
1050#line 61 "util/parse-events.l"
1051{ return sym(PERF_TYPE_HARDWARE, PERF_COUNT_HW_CPU_CYCLES); }
1052 YY_BREAK
1053case 2:
1054YY_RULE_SETUP
1055#line 62 "util/parse-events.l"
1056{ return sym(PERF_TYPE_HARDWARE, PERF_COUNT_HW_STALLED_CYCLES_FRONTEND); }
1057 YY_BREAK
1058case 3:
1059YY_RULE_SETUP
1060#line 63 "util/parse-events.l"
1061{ return sym(PERF_TYPE_HARDWARE, PERF_COUNT_HW_STALLED_CYCLES_BACKEND); }
1062 YY_BREAK
1063case 4:
1064YY_RULE_SETUP
1065#line 64 "util/parse-events.l"
1066{ return sym(PERF_TYPE_HARDWARE, PERF_COUNT_HW_INSTRUCTIONS); }
1067 YY_BREAK
1068case 5:
1069YY_RULE_SETUP
1070#line 65 "util/parse-events.l"
1071{ return sym(PERF_TYPE_HARDWARE, PERF_COUNT_HW_CACHE_REFERENCES); }
1072 YY_BREAK
1073case 6:
1074YY_RULE_SETUP
1075#line 66 "util/parse-events.l"
1076{ return sym(PERF_TYPE_HARDWARE, PERF_COUNT_HW_CACHE_MISSES); }
1077 YY_BREAK
1078case 7:
1079YY_RULE_SETUP
1080#line 67 "util/parse-events.l"
1081{ return sym(PERF_TYPE_HARDWARE, PERF_COUNT_HW_BRANCH_INSTRUCTIONS); }
1082 YY_BREAK
1083case 8:
1084YY_RULE_SETUP
1085#line 68 "util/parse-events.l"
1086{ return sym(PERF_TYPE_HARDWARE, PERF_COUNT_HW_BRANCH_MISSES); }
1087 YY_BREAK
1088case 9:
1089YY_RULE_SETUP
1090#line 69 "util/parse-events.l"
1091{ return sym(PERF_TYPE_HARDWARE, PERF_COUNT_HW_BUS_CYCLES); }
1092 YY_BREAK
1093case 10:
1094YY_RULE_SETUP
1095#line 70 "util/parse-events.l"
1096{ return sym(PERF_TYPE_SOFTWARE, PERF_COUNT_SW_CPU_CLOCK); }
1097 YY_BREAK
1098case 11:
1099YY_RULE_SETUP
1100#line 71 "util/parse-events.l"
1101{ return sym(PERF_TYPE_SOFTWARE, PERF_COUNT_SW_TASK_CLOCK); }
1102 YY_BREAK
1103case 12:
1104YY_RULE_SETUP
1105#line 72 "util/parse-events.l"
1106{ return sym(PERF_TYPE_SOFTWARE, PERF_COUNT_SW_PAGE_FAULTS); }
1107 YY_BREAK
1108case 13:
1109YY_RULE_SETUP
1110#line 73 "util/parse-events.l"
1111{ return sym(PERF_TYPE_SOFTWARE, PERF_COUNT_SW_PAGE_FAULTS_MIN); }
1112 YY_BREAK
1113case 14:
1114YY_RULE_SETUP
1115#line 74 "util/parse-events.l"
1116{ return sym(PERF_TYPE_SOFTWARE, PERF_COUNT_SW_PAGE_FAULTS_MAJ); }
1117 YY_BREAK
1118case 15:
1119YY_RULE_SETUP
1120#line 75 "util/parse-events.l"
1121{ return sym(PERF_TYPE_SOFTWARE, PERF_COUNT_SW_CONTEXT_SWITCHES); }
1122 YY_BREAK
1123case 16:
1124YY_RULE_SETUP
1125#line 76 "util/parse-events.l"
1126{ return sym(PERF_TYPE_SOFTWARE, PERF_COUNT_SW_CPU_MIGRATIONS); }
1127 YY_BREAK
1128case 17:
1129YY_RULE_SETUP
1130#line 77 "util/parse-events.l"
1131{ return sym(PERF_TYPE_SOFTWARE, PERF_COUNT_SW_ALIGNMENT_FAULTS); }
1132 YY_BREAK
1133case 18:
1134YY_RULE_SETUP
1135#line 78 "util/parse-events.l"
1136{ return sym(PERF_TYPE_SOFTWARE, PERF_COUNT_SW_EMULATION_FAULTS); }
1137 YY_BREAK
1138case 19:
1139#line 81 "util/parse-events.l"
1140case 20:
1141#line 82 "util/parse-events.l"
1142case 21:
1143#line 83 "util/parse-events.l"
1144case 22:
1145#line 84 "util/parse-events.l"
1146case 23:
1147#line 85 "util/parse-events.l"
1148case 24:
1149#line 86 "util/parse-events.l"
1150case 25:
1151YY_RULE_SETUP
1152#line 86 "util/parse-events.l"
1153{ return str(PE_NAME_CACHE_TYPE); }
1154 YY_BREAK
1155case 26:
1156#line 89 "util/parse-events.l"
1157case 27:
1158#line 90 "util/parse-events.l"
1159case 28:
1160#line 91 "util/parse-events.l"
1161case 29:
1162#line 92 "util/parse-events.l"
1163case 30:
1164#line 93 "util/parse-events.l"
1165case 31:
1166YY_RULE_SETUP
1167#line 93 "util/parse-events.l"
1168{ return str(PE_NAME_CACHE_OP_RESULT); }
1169 YY_BREAK
1170/*
1171 * These are event config hardcoded term names to be specified
1172 * within xxx/.../ syntax. So far we dont clash with other names,
1173 * so we can put them here directly. In case the we have a conflict
1174 * in future, this needs to go into '//' condition block.
1175 */
1176case 32:
1177YY_RULE_SETUP
1178#line 101 "util/parse-events.l"
1179{ return term(PARSE_EVENTS__TERM_TYPE_CONFIG); }
1180 YY_BREAK
1181case 33:
1182YY_RULE_SETUP
1183#line 102 "util/parse-events.l"
1184{ return term(PARSE_EVENTS__TERM_TYPE_CONFIG1); }
1185 YY_BREAK
1186case 34:
1187YY_RULE_SETUP
1188#line 103 "util/parse-events.l"
1189{ return term(PARSE_EVENTS__TERM_TYPE_CONFIG2); }
1190 YY_BREAK
1191case 35:
1192YY_RULE_SETUP
1193#line 104 "util/parse-events.l"
1194{ return term(PARSE_EVENTS__TERM_TYPE_SAMPLE_PERIOD); }
1195 YY_BREAK
1196case 36:
1197YY_RULE_SETUP
1198#line 105 "util/parse-events.l"
1199{ return term(PARSE_EVENTS__TERM_TYPE_BRANCH_SAMPLE_TYPE); }
1200 YY_BREAK
1201case 37:
1202YY_RULE_SETUP
1203#line 107 "util/parse-events.l"
1204{ return PE_PREFIX_MEM; }
1205 YY_BREAK
1206case 38:
1207YY_RULE_SETUP
1208#line 108 "util/parse-events.l"
1209{ return raw(); }
1210 YY_BREAK
1211case 39:
1212YY_RULE_SETUP
1213#line 109 "util/parse-events.l"
1214{ return value(10); }
1215 YY_BREAK
1216case 40:
1217YY_RULE_SETUP
1218#line 110 "util/parse-events.l"
1219{ return value(16); }
1220 YY_BREAK
1221case 41:
1222YY_RULE_SETUP
1223#line 112 "util/parse-events.l"
1224{ return str(PE_MODIFIER_EVENT); }
1225 YY_BREAK
1226case 42:
1227YY_RULE_SETUP
1228#line 113 "util/parse-events.l"
1229{ return str(PE_MODIFIER_BP); }
1230 YY_BREAK
1231case 43:
1232YY_RULE_SETUP
1233#line 114 "util/parse-events.l"
1234{ return str(PE_NAME); }
1235 YY_BREAK
1236case 44:
1237YY_RULE_SETUP
1238#line 115 "util/parse-events.l"
1239{ return '/'; }
1240 YY_BREAK
1241case 45:
1242YY_RULE_SETUP
1243#line 116 "util/parse-events.l"
1244{ return '-'; }
1245 YY_BREAK
1246case 46:
1247YY_RULE_SETUP
1248#line 117 "util/parse-events.l"
1249{ return ','; }
1250 YY_BREAK
1251case 47:
1252YY_RULE_SETUP
1253#line 118 "util/parse-events.l"
1254{ return ':'; }
1255 YY_BREAK
1256case 48:
1257YY_RULE_SETUP
1258#line 119 "util/parse-events.l"
1259{ return '='; }
1260 YY_BREAK
1261case 49:
1262YY_RULE_SETUP
1263#line 121 "util/parse-events.l"
1264ECHO;
1265 YY_BREAK
1266#line 1267 "<stdout>"
1267case YY_STATE_EOF(INITIAL):
1268 yyterminate();
1269
1270 case YY_END_OF_BUFFER:
1271 {
1272 /* Amount of text matched not including the EOB char. */
1273 int yy_amount_of_matched_text = (int) (yy_cp - (yytext_ptr)) - 1;
1274
1275 /* Undo the effects of YY_DO_BEFORE_ACTION. */
1276 *yy_cp = (yy_hold_char);
1277 YY_RESTORE_YY_MORE_OFFSET
1278
1279 if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_NEW )
1280 {
1281 /* We're scanning a new file or input source. It's
1282 * possible that this happened because the user
1283 * just pointed parse_events_in at a new source and called
1284 * parse_events_lex(). If so, then we have to assure
1285 * consistency between YY_CURRENT_BUFFER and our
1286 * globals. Here is the right place to do so, because
1287 * this is the first action (other than possibly a
1288 * back-up) that will match for the new input source.
1289 */
1290 (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_n_chars;
1291 YY_CURRENT_BUFFER_LVALUE->yy_input_file = parse_events_in;
1292 YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = YY_BUFFER_NORMAL;
1293 }
1294
1295 /* Note that here we test for yy_c_buf_p "<=" to the position
1296 * of the first EOB in the buffer, since yy_c_buf_p will
1297 * already have been incremented past the NUL character
1298 * (since all states make transitions on EOB to the
1299 * end-of-buffer state). Contrast this with the test
1300 * in input().
1301 */
1302 if ( (yy_c_buf_p) <= &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] )
1303 { /* This was really a NUL. */
1304 yy_state_type yy_next_state;
1305
1306 (yy_c_buf_p) = (yytext_ptr) + yy_amount_of_matched_text;
1307
1308 yy_current_state = yy_get_previous_state( );
1309
1310 /* Okay, we're now positioned to make the NUL
1311 * transition. We couldn't have
1312 * yy_get_previous_state() go ahead and do it
1313 * for us because it doesn't know how to deal
1314 * with the possibility of jamming (and we don't
1315 * want to build jamming into it because then it
1316 * will run more slowly).
1317 */
1318
1319 yy_next_state = yy_try_NUL_trans( yy_current_state );
1320
1321 yy_bp = (yytext_ptr) + YY_MORE_ADJ;
1322
1323 if ( yy_next_state )
1324 {
1325 /* Consume the NUL. */
1326 yy_cp = ++(yy_c_buf_p);
1327 yy_current_state = yy_next_state;
1328 goto yy_match;
1329 }
1330
1331 else
1332 {
1333 yy_cp = (yy_c_buf_p);
1334 goto yy_find_action;
1335 }
1336 }
1337
1338 else switch ( yy_get_next_buffer( ) )
1339 {
1340 case EOB_ACT_END_OF_FILE:
1341 {
1342 (yy_did_buffer_switch_on_eof) = 0;
1343
1344 if ( parse_events_wrap( ) )
1345 {
1346 /* Note: because we've taken care in
1347 * yy_get_next_buffer() to have set up
1348 * parse_events_text, we can now set up
1349 * yy_c_buf_p so that if some total
1350 * hoser (like flex itself) wants to
1351 * call the scanner after we return the
1352 * YY_NULL, it'll still work - another
1353 * YY_NULL will get returned.
1354 */
1355 (yy_c_buf_p) = (yytext_ptr) + YY_MORE_ADJ;
1356
1357 yy_act = YY_STATE_EOF(YY_START);
1358 goto do_action;
1359 }
1360
1361 else
1362 {
1363 if ( ! (yy_did_buffer_switch_on_eof) )
1364 YY_NEW_FILE;
1365 }
1366 break;
1367 }
1368
1369 case EOB_ACT_CONTINUE_SCAN:
1370 (yy_c_buf_p) =
1371 (yytext_ptr) + yy_amount_of_matched_text;
1372
1373 yy_current_state = yy_get_previous_state( );
1374
1375 yy_cp = (yy_c_buf_p);
1376 yy_bp = (yytext_ptr) + YY_MORE_ADJ;
1377 goto yy_match;
1378
1379 case EOB_ACT_LAST_MATCH:
1380 (yy_c_buf_p) =
1381 &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)];
1382
1383 yy_current_state = yy_get_previous_state( );
1384
1385 yy_cp = (yy_c_buf_p);
1386 yy_bp = (yytext_ptr) + YY_MORE_ADJ;
1387 goto yy_find_action;
1388 }
1389 break;
1390 }
1391
1392 default:
1393 YY_FATAL_ERROR(
1394 "fatal flex scanner internal error--no action found" );
1395 } /* end of action switch */
1396 } /* end of scanning one token */
1397} /* end of parse_events_lex */
1398
1399/* yy_get_next_buffer - try to read in a new buffer
1400 *
1401 * Returns a code representing an action:
1402 * EOB_ACT_LAST_MATCH -
1403 * EOB_ACT_CONTINUE_SCAN - continue scanning from current position
1404 * EOB_ACT_END_OF_FILE - end of file
1405 */
1406static int yy_get_next_buffer (void)
1407{
1408 register char *dest = YY_CURRENT_BUFFER_LVALUE->yy_ch_buf;
1409 register char *source = (yytext_ptr);
1410 register int number_to_move, i;
1411 int ret_val;
1412
1413 if ( (yy_c_buf_p) > &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars) + 1] )
1414 YY_FATAL_ERROR(
1415 "fatal flex scanner internal error--end of buffer missed" );
1416
1417 if ( YY_CURRENT_BUFFER_LVALUE->yy_fill_buffer == 0 )
1418 { /* Don't try to fill the buffer, so this is an EOF. */
1419 if ( (yy_c_buf_p) - (yytext_ptr) - YY_MORE_ADJ == 1 )
1420 {
1421 /* We matched a single character, the EOB, so
1422 * treat this as a final EOF.
1423 */
1424 return EOB_ACT_END_OF_FILE;
1425 }
1426
1427 else
1428 {
1429 /* We matched some text prior to the EOB, first
1430 * process it.
1431 */
1432 return EOB_ACT_LAST_MATCH;
1433 }
1434 }
1435
1436 /* Try to read more data. */
1437
1438 /* First move last chars to start of buffer. */
1439 number_to_move = (int) ((yy_c_buf_p) - (yytext_ptr)) - 1;
1440
1441 for ( i = 0; i < number_to_move; ++i )
1442 *(dest++) = *(source++);
1443
1444 if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_EOF_PENDING )
1445 /* don't do the read, it's not guaranteed to return an EOF,
1446 * just force an EOF
1447 */
1448 YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars) = 0;
1449
1450 else
1451 {
1452 int num_to_read =
1453 YY_CURRENT_BUFFER_LVALUE->yy_buf_size - number_to_move - 1;
1454
1455 while ( num_to_read <= 0 )
1456 { /* Not enough room in the buffer - grow it. */
1457
1458 /* just a shorter name for the current buffer */
1459 YY_BUFFER_STATE b = YY_CURRENT_BUFFER;
1460
1461 int yy_c_buf_p_offset =
1462 (int) ((yy_c_buf_p) - b->yy_ch_buf);
1463
1464 if ( b->yy_is_our_buffer )
1465 {
1466 int new_size = b->yy_buf_size * 2;
1467
1468 if ( new_size <= 0 )
1469 b->yy_buf_size += b->yy_buf_size / 8;
1470 else
1471 b->yy_buf_size *= 2;
1472
1473 b->yy_ch_buf = (char *)
1474 /* Include room in for 2 EOB chars. */
1475 parse_events_realloc((void *) b->yy_ch_buf,b->yy_buf_size + 2 );
1476 }
1477 else
1478 /* Can't grow it, we don't own it. */
1479 b->yy_ch_buf = 0;
1480
1481 if ( ! b->yy_ch_buf )
1482 YY_FATAL_ERROR(
1483 "fatal error - scanner input buffer overflow" );
1484
1485 (yy_c_buf_p) = &b->yy_ch_buf[yy_c_buf_p_offset];
1486
1487 num_to_read = YY_CURRENT_BUFFER_LVALUE->yy_buf_size -
1488 number_to_move - 1;
1489
1490 }
1491
1492 if ( num_to_read > YY_READ_BUF_SIZE )
1493 num_to_read = YY_READ_BUF_SIZE;
1494
1495 /* Read in more data. */
1496 YY_INPUT( (&YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]),
1497 (yy_n_chars), (size_t) num_to_read );
1498
1499 YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars);
1500 }
1501
1502 if ( (yy_n_chars) == 0 )
1503 {
1504 if ( number_to_move == YY_MORE_ADJ )
1505 {
1506 ret_val = EOB_ACT_END_OF_FILE;
1507 parse_events_restart(parse_events_in );
1508 }
1509
1510 else
1511 {
1512 ret_val = EOB_ACT_LAST_MATCH;
1513 YY_CURRENT_BUFFER_LVALUE->yy_buffer_status =
1514 YY_BUFFER_EOF_PENDING;
1515 }
1516 }
1517
1518 else
1519 ret_val = EOB_ACT_CONTINUE_SCAN;
1520
1521 if ((yy_size_t) ((yy_n_chars) + number_to_move) > YY_CURRENT_BUFFER_LVALUE->yy_buf_size) {
1522 /* Extend the array by 50%, plus the number we really need. */
1523 yy_size_t new_size = (yy_n_chars) + number_to_move + ((yy_n_chars) >> 1);
1524 YY_CURRENT_BUFFER_LVALUE->yy_ch_buf = (char *) parse_events_realloc((void *) YY_CURRENT_BUFFER_LVALUE->yy_ch_buf,new_size );
1525 if ( ! YY_CURRENT_BUFFER_LVALUE->yy_ch_buf )
1526 YY_FATAL_ERROR( "out of dynamic memory in yy_get_next_buffer()" );
1527 }
1528
1529 (yy_n_chars) += number_to_move;
1530 YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] = YY_END_OF_BUFFER_CHAR;
1531 YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars) + 1] = YY_END_OF_BUFFER_CHAR;
1532
1533 (yytext_ptr) = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[0];
1534
1535 return ret_val;
1536}
1537
1538/* yy_get_previous_state - get the state just before the EOB char was reached */
1539
1540 static yy_state_type yy_get_previous_state (void)
1541{
1542 register yy_state_type yy_current_state;
1543 register char *yy_cp;
1544
1545 yy_current_state = (yy_start);
1546
1547 for ( yy_cp = (yytext_ptr) + YY_MORE_ADJ; yy_cp < (yy_c_buf_p); ++yy_cp )
1548 {
1549 register YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1);
1550 if ( yy_accept[yy_current_state] )
1551 {
1552 (yy_last_accepting_state) = yy_current_state;
1553 (yy_last_accepting_cpos) = yy_cp;
1554 }
1555 while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
1556 {
1557 yy_current_state = (int) yy_def[yy_current_state];
1558 if ( yy_current_state >= 440 )
1559 yy_c = yy_meta[(unsigned int) yy_c];
1560 }
1561 yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
1562 }
1563
1564 return yy_current_state;
1565}
1566
1567/* yy_try_NUL_trans - try to make a transition on the NUL character
1568 *
1569 * synopsis
1570 * next_state = yy_try_NUL_trans( current_state );
1571 */
1572 static yy_state_type yy_try_NUL_trans (yy_state_type yy_current_state )
1573{
1574 register int yy_is_jam;
1575 register char *yy_cp = (yy_c_buf_p);
1576
1577 register YY_CHAR yy_c = 1;
1578 if ( yy_accept[yy_current_state] )
1579 {
1580 (yy_last_accepting_state) = yy_current_state;
1581 (yy_last_accepting_cpos) = yy_cp;
1582 }
1583 while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
1584 {
1585 yy_current_state = (int) yy_def[yy_current_state];
1586 if ( yy_current_state >= 440 )
1587 yy_c = yy_meta[(unsigned int) yy_c];
1588 }
1589 yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
1590 yy_is_jam = (yy_current_state == 439);
1591
1592 return yy_is_jam ? 0 : yy_current_state;
1593}
1594
1595 static void yyunput (int c, register char * yy_bp )
1596{
1597 register char *yy_cp;
1598
1599 yy_cp = (yy_c_buf_p);
1600
1601 /* undo effects of setting up parse_events_text */
1602 *yy_cp = (yy_hold_char);
1603
1604 if ( yy_cp < YY_CURRENT_BUFFER_LVALUE->yy_ch_buf + 2 )
1605 { /* need to shift things up to make room */
1606 /* +2 for EOB chars. */
1607 register int number_to_move = (yy_n_chars) + 2;
1608 register char *dest = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[
1609 YY_CURRENT_BUFFER_LVALUE->yy_buf_size + 2];
1610 register char *source =
1611 &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move];
1612
1613 while ( source > YY_CURRENT_BUFFER_LVALUE->yy_ch_buf )
1614 *--dest = *--source;
1615
1616 yy_cp += (int) (dest - source);
1617 yy_bp += (int) (dest - source);
1618 YY_CURRENT_BUFFER_LVALUE->yy_n_chars =
1619 (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_buf_size;
1620
1621 if ( yy_cp < YY_CURRENT_BUFFER_LVALUE->yy_ch_buf + 2 )
1622 YY_FATAL_ERROR( "flex scanner push-back overflow" );
1623 }
1624
1625 *--yy_cp = (char) c;
1626
1627 (yytext_ptr) = yy_bp;
1628 (yy_hold_char) = *yy_cp;
1629 (yy_c_buf_p) = yy_cp;
1630}
1631
1632#ifndef YY_NO_INPUT
1633#ifdef __cplusplus
1634 static int yyinput (void)
1635#else
1636 static int input (void)
1637#endif
1638
1639{
1640 int c;
1641
1642 *(yy_c_buf_p) = (yy_hold_char);
1643
1644 if ( *(yy_c_buf_p) == YY_END_OF_BUFFER_CHAR )
1645 {
1646 /* yy_c_buf_p now points to the character we want to return.
1647 * If this occurs *before* the EOB characters, then it's a
1648 * valid NUL; if not, then we've hit the end of the buffer.
1649 */
1650 if ( (yy_c_buf_p) < &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] )
1651 /* This was really a NUL. */
1652 *(yy_c_buf_p) = '\0';
1653
1654 else
1655 { /* need more input */
1656 int offset = (yy_c_buf_p) - (yytext_ptr);
1657 ++(yy_c_buf_p);
1658
1659 switch ( yy_get_next_buffer( ) )
1660 {
1661 case EOB_ACT_LAST_MATCH:
1662 /* This happens because yy_g_n_b()
1663 * sees that we've accumulated a
1664 * token and flags that we need to
1665 * try matching the token before
1666 * proceeding. But for input(),
1667 * there's no matching to consider.
1668 * So convert the EOB_ACT_LAST_MATCH
1669 * to EOB_ACT_END_OF_FILE.
1670 */
1671
1672 /* Reset buffer status. */
1673 parse_events_restart(parse_events_in );
1674
1675 /*FALLTHROUGH*/
1676
1677 case EOB_ACT_END_OF_FILE:
1678 {
1679 if ( parse_events_wrap( ) )
1680 return EOF;
1681
1682 if ( ! (yy_did_buffer_switch_on_eof) )
1683 YY_NEW_FILE;
1684#ifdef __cplusplus
1685 return yyinput();
1686#else
1687 return input();
1688#endif
1689 }
1690
1691 case EOB_ACT_CONTINUE_SCAN:
1692 (yy_c_buf_p) = (yytext_ptr) + offset;
1693 break;
1694 }
1695 }
1696 }
1697
1698 c = *(unsigned char *) (yy_c_buf_p); /* cast for 8-bit char's */
1699 *(yy_c_buf_p) = '\0'; /* preserve parse_events_text */
1700 (yy_hold_char) = *++(yy_c_buf_p);
1701
1702 return c;
1703}
1704#endif /* ifndef YY_NO_INPUT */
1705
1706/** Immediately switch to a different input stream.
1707 * @param input_file A readable stream.
1708 *
1709 * @note This function does not reset the start condition to @c INITIAL .
1710 */
1711 void parse_events_restart (FILE * input_file )
1712{
1713
1714 if ( ! YY_CURRENT_BUFFER ){
1715 parse_events_ensure_buffer_stack ();
1716 YY_CURRENT_BUFFER_LVALUE =
1717 parse_events__create_buffer(parse_events_in,YY_BUF_SIZE );
1718 }
1719
1720 parse_events__init_buffer(YY_CURRENT_BUFFER,input_file );
1721 parse_events__load_buffer_state( );
1722}
1723
1724/** Switch to a different input buffer.
1725 * @param new_buffer The new input buffer.
1726 *
1727 */
1728 void parse_events__switch_to_buffer (YY_BUFFER_STATE new_buffer )
1729{
1730
1731 /* TODO. We should be able to replace this entire function body
1732 * with
1733 * parse_events_pop_buffer_state();
1734 * parse_events_push_buffer_state(new_buffer);
1735 */
1736 parse_events_ensure_buffer_stack ();
1737 if ( YY_CURRENT_BUFFER == new_buffer )
1738 return;
1739
1740 if ( YY_CURRENT_BUFFER )
1741 {
1742 /* Flush out information for old buffer. */
1743 *(yy_c_buf_p) = (yy_hold_char);
1744 YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = (yy_c_buf_p);
1745 YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars);
1746 }
1747
1748 YY_CURRENT_BUFFER_LVALUE = new_buffer;
1749 parse_events__load_buffer_state( );
1750
1751 /* We don't actually know whether we did this switch during
1752 * EOF (parse_events_wrap()) processing, but the only time this flag
1753 * is looked at is after parse_events_wrap() is called, so it's safe
1754 * to go ahead and always set it.
1755 */
1756 (yy_did_buffer_switch_on_eof) = 1;
1757}
1758
1759static void parse_events__load_buffer_state (void)
1760{
1761 (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_n_chars;
1762 (yytext_ptr) = (yy_c_buf_p) = YY_CURRENT_BUFFER_LVALUE->yy_buf_pos;
1763 parse_events_in = YY_CURRENT_BUFFER_LVALUE->yy_input_file;
1764 (yy_hold_char) = *(yy_c_buf_p);
1765}
1766
1767/** Allocate and initialize an input buffer state.
1768 * @param file A readable stream.
1769 * @param size The character buffer size in bytes. When in doubt, use @c YY_BUF_SIZE.
1770 *
1771 * @return the allocated buffer state.
1772 */
1773 YY_BUFFER_STATE parse_events__create_buffer (FILE * file, int size )
1774{
1775 YY_BUFFER_STATE b;
1776
1777 b = (YY_BUFFER_STATE) parse_events_alloc(sizeof( struct yy_buffer_state ) );
1778 if ( ! b )
1779 YY_FATAL_ERROR( "out of dynamic memory in parse_events__create_buffer()" );
1780
1781 b->yy_buf_size = size;
1782
1783 /* yy_ch_buf has to be 2 characters longer than the size given because
1784 * we need to put in 2 end-of-buffer characters.
1785 */
1786 b->yy_ch_buf = (char *) parse_events_alloc(b->yy_buf_size + 2 );
1787 if ( ! b->yy_ch_buf )
1788 YY_FATAL_ERROR( "out of dynamic memory in parse_events__create_buffer()" );
1789
1790 b->yy_is_our_buffer = 1;
1791
1792 parse_events__init_buffer(b,file );
1793
1794 return b;
1795}
1796
1797/** Destroy the buffer.
1798 * @param b a buffer created with parse_events__create_buffer()
1799 *
1800 */
1801 void parse_events__delete_buffer (YY_BUFFER_STATE b )
1802{
1803
1804 if ( ! b )
1805 return;
1806
1807 if ( b == YY_CURRENT_BUFFER ) /* Not sure if we should pop here. */
1808 YY_CURRENT_BUFFER_LVALUE = (YY_BUFFER_STATE) 0;
1809
1810 if ( b->yy_is_our_buffer )
1811 parse_events_free((void *) b->yy_ch_buf );
1812
1813 parse_events_free((void *) b );
1814}
1815
1816#ifndef __cplusplus
1817extern int isatty (int );
1818#endif /* __cplusplus */
1819
1820/* Initializes or reinitializes a buffer.
1821 * This function is sometimes called more than once on the same buffer,
1822 * such as during a parse_events_restart() or at EOF.
1823 */
1824 static void parse_events__init_buffer (YY_BUFFER_STATE b, FILE * file )
1825
1826{
1827 int oerrno = errno;
1828
1829 parse_events__flush_buffer(b );
1830
1831 b->yy_input_file = file;
1832 b->yy_fill_buffer = 1;
1833
1834 /* If b is the current buffer, then parse_events__init_buffer was _probably_
1835 * called from parse_events_restart() or through yy_get_next_buffer.
1836 * In that case, we don't want to reset the lineno or column.
1837 */
1838 if (b != YY_CURRENT_BUFFER){
1839 b->yy_bs_lineno = 1;
1840 b->yy_bs_column = 0;
1841 }
1842
1843 b->yy_is_interactive = file ? (isatty( fileno(file) ) > 0) : 0;
1844
1845 errno = oerrno;
1846}
1847
1848/** Discard all buffered characters. On the next scan, YY_INPUT will be called.
1849 * @param b the buffer state to be flushed, usually @c YY_CURRENT_BUFFER.
1850 *
1851 */
1852 void parse_events__flush_buffer (YY_BUFFER_STATE b )
1853{
1854 if ( ! b )
1855 return;
1856
1857 b->yy_n_chars = 0;
1858
1859 /* We always need two end-of-buffer characters. The first causes
1860 * a transition to the end-of-buffer state. The second causes
1861 * a jam in that state.
1862 */
1863 b->yy_ch_buf[0] = YY_END_OF_BUFFER_CHAR;
1864 b->yy_ch_buf[1] = YY_END_OF_BUFFER_CHAR;
1865
1866 b->yy_buf_pos = &b->yy_ch_buf[0];
1867
1868 b->yy_at_bol = 1;
1869 b->yy_buffer_status = YY_BUFFER_NEW;
1870
1871 if ( b == YY_CURRENT_BUFFER )
1872 parse_events__load_buffer_state( );
1873}
1874
1875/** Pushes the new state onto the stack. The new state becomes
1876 * the current state. This function will allocate the stack
1877 * if necessary.
1878 * @param new_buffer The new state.
1879 *
1880 */
1881void parse_events_push_buffer_state (YY_BUFFER_STATE new_buffer )
1882{
1883 if (new_buffer == NULL)
1884 return;
1885
1886 parse_events_ensure_buffer_stack();
1887
1888 /* This block is copied from parse_events__switch_to_buffer. */
1889 if ( YY_CURRENT_BUFFER )
1890 {
1891 /* Flush out information for old buffer. */
1892 *(yy_c_buf_p) = (yy_hold_char);
1893 YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = (yy_c_buf_p);
1894 YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars);
1895 }
1896
1897 /* Only push if top exists. Otherwise, replace top. */
1898 if (YY_CURRENT_BUFFER)
1899 (yy_buffer_stack_top)++;
1900 YY_CURRENT_BUFFER_LVALUE = new_buffer;
1901
1902 /* copied from parse_events__switch_to_buffer. */
1903 parse_events__load_buffer_state( );
1904 (yy_did_buffer_switch_on_eof) = 1;
1905}
1906
1907/** Removes and deletes the top of the stack, if present.
1908 * The next element becomes the new top.
1909 *
1910 */
1911void parse_events_pop_buffer_state (void)
1912{
1913 if (!YY_CURRENT_BUFFER)
1914 return;
1915
1916 parse_events__delete_buffer(YY_CURRENT_BUFFER );
1917 YY_CURRENT_BUFFER_LVALUE = NULL;
1918 if ((yy_buffer_stack_top) > 0)
1919 --(yy_buffer_stack_top);
1920
1921 if (YY_CURRENT_BUFFER) {
1922 parse_events__load_buffer_state( );
1923 (yy_did_buffer_switch_on_eof) = 1;
1924 }
1925}
1926
1927/* Allocates the stack if it does not exist.
1928 * Guarantees space for at least one push.
1929 */
1930static void parse_events_ensure_buffer_stack (void)
1931{
1932 int num_to_alloc;
1933
1934 if (!(yy_buffer_stack)) {
1935
1936 /* First allocation is just for 2 elements, since we don't know if this
1937 * scanner will even need a stack. We use 2 instead of 1 to avoid an
1938 * immediate realloc on the next call.
1939 */
1940 num_to_alloc = 1;
1941 (yy_buffer_stack) = (struct yy_buffer_state**)parse_events_alloc
1942 (num_to_alloc * sizeof(struct yy_buffer_state*)
1943 );
1944 if ( ! (yy_buffer_stack) )
1945 YY_FATAL_ERROR( "out of dynamic memory in parse_events_ensure_buffer_stack()" );
1946
1947 memset((yy_buffer_stack), 0, num_to_alloc * sizeof(struct yy_buffer_state*));
1948
1949 (yy_buffer_stack_max) = num_to_alloc;
1950 (yy_buffer_stack_top) = 0;
1951 return;
1952 }
1953
1954 if ((yy_buffer_stack_top) >= ((yy_buffer_stack_max)) - 1){
1955
1956 /* Increase the buffer to prepare for a possible push. */
1957 int grow_size = 8 /* arbitrary grow size */;
1958
1959 num_to_alloc = (yy_buffer_stack_max) + grow_size;
1960 (yy_buffer_stack) = (struct yy_buffer_state**)parse_events_realloc
1961 ((yy_buffer_stack),
1962 num_to_alloc * sizeof(struct yy_buffer_state*)
1963 );
1964 if ( ! (yy_buffer_stack) )
1965 YY_FATAL_ERROR( "out of dynamic memory in parse_events_ensure_buffer_stack()" );
1966
1967 /* zero only the new slots.*/
1968 memset((yy_buffer_stack) + (yy_buffer_stack_max), 0, grow_size * sizeof(struct yy_buffer_state*));
1969 (yy_buffer_stack_max) = num_to_alloc;
1970 }
1971}
1972
1973/** Setup the input buffer state to scan directly from a user-specified character buffer.
1974 * @param base the character buffer
1975 * @param size the size in bytes of the character buffer
1976 *
1977 * @return the newly allocated buffer state object.
1978 */
1979YY_BUFFER_STATE parse_events__scan_buffer (char * base, yy_size_t size )
1980{
1981 YY_BUFFER_STATE b;
1982
1983 if ( size < 2 ||
1984 base[size-2] != YY_END_OF_BUFFER_CHAR ||
1985 base[size-1] != YY_END_OF_BUFFER_CHAR )
1986 /* They forgot to leave room for the EOB's. */
1987 return 0;
1988
1989 b = (YY_BUFFER_STATE) parse_events_alloc(sizeof( struct yy_buffer_state ) );
1990 if ( ! b )
1991 YY_FATAL_ERROR( "out of dynamic memory in parse_events__scan_buffer()" );
1992
1993 b->yy_buf_size = size - 2; /* "- 2" to take care of EOB's */
1994 b->yy_buf_pos = b->yy_ch_buf = base;
1995 b->yy_is_our_buffer = 0;
1996 b->yy_input_file = 0;
1997 b->yy_n_chars = b->yy_buf_size;
1998 b->yy_is_interactive = 0;
1999 b->yy_at_bol = 1;
2000 b->yy_fill_buffer = 0;
2001 b->yy_buffer_status = YY_BUFFER_NEW;
2002
2003 parse_events__switch_to_buffer(b );
2004
2005 return b;
2006}
2007
2008/** Setup the input buffer state to scan a string. The next call to parse_events_lex() will
2009 * scan from a @e copy of @a str.
2010 * @param yystr a NUL-terminated string to scan
2011 *
2012 * @return the newly allocated buffer state object.
2013 * @note If you want to scan bytes that may contain NUL values, then use
2014 * parse_events__scan_bytes() instead.
2015 */
2016YY_BUFFER_STATE parse_events__scan_string (yyconst char * yystr )
2017{
2018
2019 return parse_events__scan_bytes(yystr,strlen(yystr) );
2020}
2021
2022/** Setup the input buffer state to scan the given bytes. The next call to parse_events_lex() will
2023 * scan from a @e copy of @a bytes.
2024 * @param bytes the byte buffer to scan
2025 * @param len the number of bytes in the buffer pointed to by @a bytes.
2026 *
2027 * @return the newly allocated buffer state object.
2028 */
2029YY_BUFFER_STATE parse_events__scan_bytes (yyconst char * yybytes, int _yybytes_len )
2030{
2031 YY_BUFFER_STATE b;
2032 char *buf;
2033 yy_size_t n;
2034 int i;
2035
2036 /* Get memory for full buffer, including space for trailing EOB's. */
2037 n = _yybytes_len + 2;
2038 buf = (char *) parse_events_alloc(n );
2039 if ( ! buf )
2040 YY_FATAL_ERROR( "out of dynamic memory in parse_events__scan_bytes()" );
2041
2042 for ( i = 0; i < _yybytes_len; ++i )
2043 buf[i] = yybytes[i];
2044
2045 buf[_yybytes_len] = buf[_yybytes_len+1] = YY_END_OF_BUFFER_CHAR;
2046
2047 b = parse_events__scan_buffer(buf,n );
2048 if ( ! b )
2049 YY_FATAL_ERROR( "bad buffer in parse_events__scan_bytes()" );
2050
2051 /* It's okay to grow etc. this buffer, and we should throw it
2052 * away when we're done.
2053 */
2054 b->yy_is_our_buffer = 1;
2055
2056 return b;
2057}
2058
2059#ifndef YY_EXIT_FAILURE
2060#define YY_EXIT_FAILURE 2
2061#endif
2062
2063static void yy_fatal_error (yyconst char* msg )
2064{
2065 (void) fprintf( stderr, "%s\n", msg );
2066 exit( YY_EXIT_FAILURE );
2067}
2068
2069/* Redefine yyless() so it works in section 3 code. */
2070
2071#undef yyless
2072#define yyless(n) \
2073 do \
2074 { \
2075 /* Undo effects of setting up parse_events_text. */ \
2076 int yyless_macro_arg = (n); \
2077 YY_LESS_LINENO(yyless_macro_arg);\
2078 parse_events_text[parse_events_leng] = (yy_hold_char); \
2079 (yy_c_buf_p) = parse_events_text + yyless_macro_arg; \
2080 (yy_hold_char) = *(yy_c_buf_p); \
2081 *(yy_c_buf_p) = '\0'; \
2082 parse_events_leng = yyless_macro_arg; \
2083 } \
2084 while ( 0 )
2085
2086/* Accessor methods (get/set functions) to struct members. */
2087
2088/** Get the current line number.
2089 *
2090 */
2091int parse_events_get_lineno (void)
2092{
2093
2094 return parse_events_lineno;
2095}
2096
2097/** Get the input stream.
2098 *
2099 */
2100FILE *parse_events_get_in (void)
2101{
2102 return parse_events_in;
2103}
2104
2105/** Get the output stream.
2106 *
2107 */
2108FILE *parse_events_get_out (void)
2109{
2110 return parse_events_out;
2111}
2112
2113/** Get the length of the current token.
2114 *
2115 */
2116int parse_events_get_leng (void)
2117{
2118 return parse_events_leng;
2119}
2120
2121/** Get the current token.
2122 *
2123 */
2124
2125char *parse_events_get_text (void)
2126{
2127 return parse_events_text;
2128}
2129
2130/** Set the current line number.
2131 * @param line_number
2132 *
2133 */
2134void parse_events_set_lineno (int line_number )
2135{
2136
2137 parse_events_lineno = line_number;
2138}
2139
2140/** Set the input stream. This does not discard the current
2141 * input buffer.
2142 * @param in_str A readable stream.
2143 *
2144 * @see parse_events__switch_to_buffer
2145 */
2146void parse_events_set_in (FILE * in_str )
2147{
2148 parse_events_in = in_str ;
2149}
2150
2151void parse_events_set_out (FILE * out_str )
2152{
2153 parse_events_out = out_str ;
2154}
2155
2156int parse_events_get_debug (void)
2157{
2158 return parse_events__flex_debug;
2159}
2160
2161void parse_events_set_debug (int bdebug )
2162{
2163 parse_events__flex_debug = bdebug ;
2164}
2165
2166static int yy_init_globals (void)
2167{
2168 /* Initialization is the same as for the non-reentrant scanner.
2169 * This function is called from parse_events_lex_destroy(), so don't allocate here.
2170 */
2171
2172 (yy_buffer_stack) = 0;
2173 (yy_buffer_stack_top) = 0;
2174 (yy_buffer_stack_max) = 0;
2175 (yy_c_buf_p) = (char *) 0;
2176 (yy_init) = 0;
2177 (yy_start) = 0;
2178
2179/* Defined in main.c */
2180#ifdef YY_STDINIT
2181 parse_events_in = stdin;
2182 parse_events_out = stdout;
2183#else
2184 parse_events_in = (FILE *) 0;
2185 parse_events_out = (FILE *) 0;
2186#endif
2187
2188 /* For future reference: Set errno on error, since we are called by
2189 * parse_events_lex_init()
2190 */
2191 return 0;
2192}
2193
2194/* parse_events_lex_destroy is for both reentrant and non-reentrant scanners. */
2195int parse_events_lex_destroy (void)
2196{
2197
2198 /* Pop the buffer stack, destroying each element. */
2199 while(YY_CURRENT_BUFFER){
2200 parse_events__delete_buffer(YY_CURRENT_BUFFER );
2201 YY_CURRENT_BUFFER_LVALUE = NULL;
2202 parse_events_pop_buffer_state();
2203 }
2204
2205 /* Destroy the stack itself. */
2206 parse_events_free((yy_buffer_stack) );
2207 (yy_buffer_stack) = NULL;
2208
2209 /* Reset the globals. This is important in a non-reentrant scanner so the next time
2210 * parse_events_lex() is called, initialization will occur. */
2211 yy_init_globals( );
2212
2213 return 0;
2214}
2215
2216/*
2217 * Internal utility routines.
2218 */
2219
2220#ifndef yytext_ptr
2221static void yy_flex_strncpy (char* s1, yyconst char * s2, int n )
2222{
2223 register int i;
2224 for ( i = 0; i < n; ++i )
2225 s1[i] = s2[i];
2226}
2227#endif
2228
2229#ifdef YY_NEED_STRLEN
2230static int yy_flex_strlen (yyconst char * s )
2231{
2232 register int n;
2233 for ( n = 0; s[n]; ++n )
2234 ;
2235
2236 return n;
2237}
2238#endif
2239
2240void *parse_events_alloc (yy_size_t size )
2241{
2242 return (void *) malloc( size );
2243}
2244
2245void *parse_events_realloc (void * ptr, yy_size_t size )
2246{
2247 /* The cast to (char *) in the following accommodates both
2248 * implementations that use char* generic pointers, and those
2249 * that use void* generic pointers. It works with the latter
2250 * because both ANSI C and C++ allow castless assignment from
2251 * any pointer type to void*, and deal with argument conversions
2252 * as though doing an assignment.
2253 */
2254 return (void *) realloc( (char *) ptr, size );
2255}
2256
2257void parse_events_free (void * ptr )
2258{
2259 free( (char *) ptr ); /* see parse_events_realloc() for (char *) cast */
2260}
2261
2262#define YYTABLES_NAME "yytables"
2263
2264#line 121 "util/parse-events.l"
2265
2266
2267
2268int parse_events_wrap(void)
2269{
2270 return 1;
2271}
2272
diff --git a/tools/perf/util/parse-events-flex.h b/tools/perf/util/parse-events-flex.h
new file mode 100644
index 000000000000..ceb9b20d732c
--- /dev/null
+++ b/tools/perf/util/parse-events-flex.h
@@ -0,0 +1,316 @@
1#ifndef parse_events_HEADER_H
2#define parse_events_HEADER_H 1
3#define parse_events_IN_HEADER 1
4
5#line 6 "util/parse-events-flex.h"
6
7#define YY_INT_ALIGNED short int
8
9/* A lexical scanner generated by flex */
10
11#define FLEX_SCANNER
12#define YY_FLEX_MAJOR_VERSION 2
13#define YY_FLEX_MINOR_VERSION 5
14#define YY_FLEX_SUBMINOR_VERSION 35
15#if YY_FLEX_SUBMINOR_VERSION > 0
16#define FLEX_BETA
17#endif
18
19/* First, we deal with platform-specific or compiler-specific issues. */
20
21/* begin standard C headers. */
22#include <stdio.h>
23#include <string.h>
24#include <errno.h>
25#include <stdlib.h>
26
27/* end standard C headers. */
28
29/* flex integer type definitions */
30
31#ifndef FLEXINT_H
32#define FLEXINT_H
33
34/* C99 systems have <inttypes.h>. Non-C99 systems may or may not. */
35
36#if defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
37
38/* C99 says to define __STDC_LIMIT_MACROS before including stdint.h,
39 * if you want the limit (max/min) macros for int types.
40 */
41#ifndef __STDC_LIMIT_MACROS
42#define __STDC_LIMIT_MACROS 1
43#endif
44
45#include <inttypes.h>
46typedef int8_t flex_int8_t;
47typedef uint8_t flex_uint8_t;
48typedef int16_t flex_int16_t;
49typedef uint16_t flex_uint16_t;
50typedef int32_t flex_int32_t;
51typedef uint32_t flex_uint32_t;
52#else
53typedef signed char flex_int8_t;
54typedef short int flex_int16_t;
55typedef int flex_int32_t;
56typedef unsigned char flex_uint8_t;
57typedef unsigned short int flex_uint16_t;
58typedef unsigned int flex_uint32_t;
59#endif /* ! C99 */
60
61/* Limits of integral types. */
62#ifndef INT8_MIN
63#define INT8_MIN (-128)
64#endif
65#ifndef INT16_MIN
66#define INT16_MIN (-32767-1)
67#endif
68#ifndef INT32_MIN
69#define INT32_MIN (-2147483647-1)
70#endif
71#ifndef INT8_MAX
72#define INT8_MAX (127)
73#endif
74#ifndef INT16_MAX
75#define INT16_MAX (32767)
76#endif
77#ifndef INT32_MAX
78#define INT32_MAX (2147483647)
79#endif
80#ifndef UINT8_MAX
81#define UINT8_MAX (255U)
82#endif
83#ifndef UINT16_MAX
84#define UINT16_MAX (65535U)
85#endif
86#ifndef UINT32_MAX
87#define UINT32_MAX (4294967295U)
88#endif
89
90#endif /* ! FLEXINT_H */
91
92#ifdef __cplusplus
93
94/* The "const" storage-class-modifier is valid. */
95#define YY_USE_CONST
96
97#else /* ! __cplusplus */
98
99/* C99 requires __STDC__ to be defined as 1. */
100#if defined (__STDC__)
101
102#define YY_USE_CONST
103
104#endif /* defined (__STDC__) */
105#endif /* ! __cplusplus */
106
107#ifdef YY_USE_CONST
108#define yyconst const
109#else
110#define yyconst
111#endif
112
113/* Size of default input buffer. */
114#ifndef YY_BUF_SIZE
115#define YY_BUF_SIZE 16384
116#endif
117
118#ifndef YY_TYPEDEF_YY_BUFFER_STATE
119#define YY_TYPEDEF_YY_BUFFER_STATE
120typedef struct yy_buffer_state *YY_BUFFER_STATE;
121#endif
122
123extern int parse_events_leng;
124
125extern FILE *parse_events_in, *parse_events_out;
126
127#ifndef YY_TYPEDEF_YY_SIZE_T
128#define YY_TYPEDEF_YY_SIZE_T
129typedef size_t yy_size_t;
130#endif
131
132#ifndef YY_STRUCT_YY_BUFFER_STATE
133#define YY_STRUCT_YY_BUFFER_STATE
134struct yy_buffer_state
135 {
136 FILE *yy_input_file;
137
138 char *yy_ch_buf; /* input buffer */
139 char *yy_buf_pos; /* current position in input buffer */
140
141 /* Size of input buffer in bytes, not including room for EOB
142 * characters.
143 */
144 yy_size_t yy_buf_size;
145
146 /* Number of characters read into yy_ch_buf, not including EOB
147 * characters.
148 */
149 int yy_n_chars;
150
151 /* Whether we "own" the buffer - i.e., we know we created it,
152 * and can realloc() it to grow it, and should free() it to
153 * delete it.
154 */
155 int yy_is_our_buffer;
156
157 /* Whether this is an "interactive" input source; if so, and
158 * if we're using stdio for input, then we want to use getc()
159 * instead of fread(), to make sure we stop fetching input after
160 * each newline.
161 */
162 int yy_is_interactive;
163
164 /* Whether we're considered to be at the beginning of a line.
165 * If so, '^' rules will be active on the next match, otherwise
166 * not.
167 */
168 int yy_at_bol;
169
170 int yy_bs_lineno; /**< The line count. */
171 int yy_bs_column; /**< The column count. */
172
173 /* Whether to try to fill the input buffer when we reach the
174 * end of it.
175 */
176 int yy_fill_buffer;
177
178 int yy_buffer_status;
179
180 };
181#endif /* !YY_STRUCT_YY_BUFFER_STATE */
182
183void parse_events_restart (FILE *input_file );
184void parse_events__switch_to_buffer (YY_BUFFER_STATE new_buffer );
185YY_BUFFER_STATE parse_events__create_buffer (FILE *file,int size );
186void parse_events__delete_buffer (YY_BUFFER_STATE b );
187void parse_events__flush_buffer (YY_BUFFER_STATE b );
188void parse_events_push_buffer_state (YY_BUFFER_STATE new_buffer );
189void parse_events_pop_buffer_state (void );
190
191YY_BUFFER_STATE parse_events__scan_buffer (char *base,yy_size_t size );
192YY_BUFFER_STATE parse_events__scan_string (yyconst char *yy_str );
193YY_BUFFER_STATE parse_events__scan_bytes (yyconst char *bytes,int len );
194
195void *parse_events_alloc (yy_size_t );
196void *parse_events_realloc (void *,yy_size_t );
197void parse_events_free (void * );
198
199/* Begin user sect3 */
200
201extern int parse_events_lineno;
202
203extern char *parse_events_text;
204#define yytext_ptr parse_events_text
205
206#ifdef YY_HEADER_EXPORT_START_CONDITIONS
207#define INITIAL 0
208
209#endif
210
211#ifndef YY_NO_UNISTD_H
212/* Special case for "unistd.h", since it is non-ANSI. We include it way
213 * down here because we want the user's section 1 to have been scanned first.
214 * The user has a chance to override it with an option.
215 */
216#include <unistd.h>
217#endif
218
219#ifndef YY_EXTRA_TYPE
220#define YY_EXTRA_TYPE void *
221#endif
222
223/* Accessor methods to globals.
224 These are made visible to non-reentrant scanners for convenience. */
225
226int parse_events_lex_destroy (void );
227
228int parse_events_get_debug (void );
229
230void parse_events_set_debug (int debug_flag );
231
232YY_EXTRA_TYPE parse_events_get_extra (void );
233
234void parse_events_set_extra (YY_EXTRA_TYPE user_defined );
235
236FILE *parse_events_get_in (void );
237
238void parse_events_set_in (FILE * in_str );
239
240FILE *parse_events_get_out (void );
241
242void parse_events_set_out (FILE * out_str );
243
244int parse_events_get_leng (void );
245
246char *parse_events_get_text (void );
247
248int parse_events_get_lineno (void );
249
250void parse_events_set_lineno (int line_number );
251
252/* Macros after this point can all be overridden by user definitions in
253 * section 1.
254 */
255
256#ifndef YY_SKIP_YYWRAP
257#ifdef __cplusplus
258extern "C" int parse_events_wrap (void );
259#else
260extern int parse_events_wrap (void );
261#endif
262#endif
263
264#ifndef yytext_ptr
265static void yy_flex_strncpy (char *,yyconst char *,int );
266#endif
267
268#ifdef YY_NEED_STRLEN
269static int yy_flex_strlen (yyconst char * );
270#endif
271
272#ifndef YY_NO_INPUT
273
274#endif
275
276/* Amount of stuff to slurp up with each read. */
277#ifndef YY_READ_BUF_SIZE
278#define YY_READ_BUF_SIZE 8192
279#endif
280
281/* Number of entries by which start-condition stack grows. */
282#ifndef YY_START_STACK_INCR
283#define YY_START_STACK_INCR 25
284#endif
285
286/* Default declaration of generated scanner - a define so the user can
287 * easily add parameters.
288 */
289#ifndef YY_DECL
290#define YY_DECL_IS_OURS 1
291
292extern int parse_events_lex (void);
293
294#define YY_DECL int parse_events_lex (void)
295#endif /* !YY_DECL */
296
297/* yy_get_previous_state - get the state just before the EOB char was reached */
298
299#undef YY_NEW_FILE
300#undef YY_FLUSH_BUFFER
301#undef yy_set_bol
302#undef yy_new_buffer
303#undef yy_set_interactive
304#undef YY_DO_BEFORE_ACTION
305
306#ifdef YY_DECL_IS_OURS
307#undef YY_DECL_IS_OURS
308#undef YY_DECL
309#endif
310
311#line 121 "util/parse-events.l"
312
313
314#line 315 "util/parse-events-flex.h"
315#undef parse_events_IN_HEADER
316#endif /* parse_events_HEADER_H */
diff --git a/tools/perf/util/parse-events.c b/tools/perf/util/parse-events.c
index c7a6f6faf91e..5b3a0ef4e232 100644
--- a/tools/perf/util/parse-events.c
+++ b/tools/perf/util/parse-events.c
@@ -11,6 +11,10 @@
11#include "cache.h" 11#include "cache.h"
12#include "header.h" 12#include "header.h"
13#include "debugfs.h" 13#include "debugfs.h"
14#include "parse-events-flex.h"
15#include "pmu.h"
16
17#define MAX_NAME_LEN 100
14 18
15struct event_symbol { 19struct event_symbol {
16 u8 type; 20 u8 type;
@@ -19,11 +23,8 @@ struct event_symbol {
19 const char *alias; 23 const char *alias;
20}; 24};
21 25
22enum event_result { 26int parse_events_parse(struct list_head *list, struct list_head *list_tmp,
23 EVT_FAILED, 27 int *idx);
24 EVT_HANDLED,
25 EVT_HANDLED_ALL
26};
27 28
28#define CHW(x) .type = PERF_TYPE_HARDWARE, .config = PERF_COUNT_HW_##x 29#define CHW(x) .type = PERF_TYPE_HARDWARE, .config = PERF_COUNT_HW_##x
29#define CSW(x) .type = PERF_TYPE_SOFTWARE, .config = PERF_COUNT_SW_##x 30#define CSW(x) .type = PERF_TYPE_SOFTWARE, .config = PERF_COUNT_SW_##x
@@ -354,7 +355,24 @@ const char *__event_name(int type, u64 config)
354 return "unknown"; 355 return "unknown";
355} 356}
356 357
357static int parse_aliases(const char **str, const char *names[][MAX_ALIASES], int size) 358static int add_event(struct list_head *list, int *idx,
359 struct perf_event_attr *attr, char *name)
360{
361 struct perf_evsel *evsel;
362
363 event_attr_init(attr);
364
365 evsel = perf_evsel__new(attr, (*idx)++);
366 if (!evsel)
367 return -ENOMEM;
368
369 list_add_tail(&evsel->node, list);
370
371 evsel->name = strdup(name);
372 return 0;
373}
374
375static int parse_aliases(char *str, const char *names[][MAX_ALIASES], int size)
358{ 376{
359 int i, j; 377 int i, j;
360 int n, longest = -1; 378 int n, longest = -1;
@@ -362,58 +380,57 @@ static int parse_aliases(const char **str, const char *names[][MAX_ALIASES], int
362 for (i = 0; i < size; i++) { 380 for (i = 0; i < size; i++) {
363 for (j = 0; j < MAX_ALIASES && names[i][j]; j++) { 381 for (j = 0; j < MAX_ALIASES && names[i][j]; j++) {
364 n = strlen(names[i][j]); 382 n = strlen(names[i][j]);
365 if (n > longest && !strncasecmp(*str, names[i][j], n)) 383 if (n > longest && !strncasecmp(str, names[i][j], n))
366 longest = n; 384 longest = n;
367 } 385 }
368 if (longest > 0) { 386 if (longest > 0)
369 *str += longest;
370 return i; 387 return i;
371 }
372 } 388 }
373 389
374 return -1; 390 return -1;
375} 391}
376 392
377static enum event_result 393int parse_events_add_cache(struct list_head *list, int *idx,
378parse_generic_hw_event(const char **str, struct perf_event_attr *attr) 394 char *type, char *op_result1, char *op_result2)
379{ 395{
380 const char *s = *str; 396 struct perf_event_attr attr;
397 char name[MAX_NAME_LEN];
381 int cache_type = -1, cache_op = -1, cache_result = -1; 398 int cache_type = -1, cache_op = -1, cache_result = -1;
399 char *op_result[2] = { op_result1, op_result2 };
400 int i, n;
382 401
383 cache_type = parse_aliases(&s, hw_cache, PERF_COUNT_HW_CACHE_MAX);
384 /* 402 /*
385 * No fallback - if we cannot get a clear cache type 403 * No fallback - if we cannot get a clear cache type
386 * then bail out: 404 * then bail out:
387 */ 405 */
406 cache_type = parse_aliases(type, hw_cache,
407 PERF_COUNT_HW_CACHE_MAX);
388 if (cache_type == -1) 408 if (cache_type == -1)
389 return EVT_FAILED; 409 return -EINVAL;
390 410
391 while ((cache_op == -1 || cache_result == -1) && *s == '-') { 411 n = snprintf(name, MAX_NAME_LEN, "%s", type);
392 ++s; 412
413 for (i = 0; (i < 2) && (op_result[i]); i++) {
414 char *str = op_result[i];
415
416 snprintf(name + n, MAX_NAME_LEN - n, "-%s\n", str);
393 417
394 if (cache_op == -1) { 418 if (cache_op == -1) {
395 cache_op = parse_aliases(&s, hw_cache_op, 419 cache_op = parse_aliases(str, hw_cache_op,
396 PERF_COUNT_HW_CACHE_OP_MAX); 420 PERF_COUNT_HW_CACHE_OP_MAX);
397 if (cache_op >= 0) { 421 if (cache_op >= 0) {
398 if (!is_cache_op_valid(cache_type, cache_op)) 422 if (!is_cache_op_valid(cache_type, cache_op))
399 return EVT_FAILED; 423 return -EINVAL;
400 continue; 424 continue;
401 } 425 }
402 } 426 }
403 427
404 if (cache_result == -1) { 428 if (cache_result == -1) {
405 cache_result = parse_aliases(&s, hw_cache_result, 429 cache_result = parse_aliases(str, hw_cache_result,
406 PERF_COUNT_HW_CACHE_RESULT_MAX); 430 PERF_COUNT_HW_CACHE_RESULT_MAX);
407 if (cache_result >= 0) 431 if (cache_result >= 0)
408 continue; 432 continue;
409 } 433 }
410
411 /*
412 * Can't parse this as a cache op or result, so back up
413 * to the '-'.
414 */
415 --s;
416 break;
417 } 434 }
418 435
419 /* 436 /*
@@ -428,20 +445,17 @@ parse_generic_hw_event(const char **str, struct perf_event_attr *attr)
428 if (cache_result == -1) 445 if (cache_result == -1)
429 cache_result = PERF_COUNT_HW_CACHE_RESULT_ACCESS; 446 cache_result = PERF_COUNT_HW_CACHE_RESULT_ACCESS;
430 447
431 attr->config = cache_type | (cache_op << 8) | (cache_result << 16); 448 memset(&attr, 0, sizeof(attr));
432 attr->type = PERF_TYPE_HW_CACHE; 449 attr.config = cache_type | (cache_op << 8) | (cache_result << 16);
433 450 attr.type = PERF_TYPE_HW_CACHE;
434 *str = s; 451 return add_event(list, idx, &attr, name);
435 return EVT_HANDLED;
436} 452}
437 453
438static enum event_result 454static int add_tracepoint(struct list_head *list, int *idx,
439parse_single_tracepoint_event(char *sys_name, 455 char *sys_name, char *evt_name)
440 const char *evt_name,
441 unsigned int evt_length,
442 struct perf_event_attr *attr,
443 const char **strp)
444{ 456{
457 struct perf_event_attr attr;
458 char name[MAX_NAME_LEN];
445 char evt_path[MAXPATHLEN]; 459 char evt_path[MAXPATHLEN];
446 char id_buf[4]; 460 char id_buf[4];
447 u64 id; 461 u64 id;
@@ -452,130 +466,80 @@ parse_single_tracepoint_event(char *sys_name,
452 466
453 fd = open(evt_path, O_RDONLY); 467 fd = open(evt_path, O_RDONLY);
454 if (fd < 0) 468 if (fd < 0)
455 return EVT_FAILED; 469 return -1;
456 470
457 if (read(fd, id_buf, sizeof(id_buf)) < 0) { 471 if (read(fd, id_buf, sizeof(id_buf)) < 0) {
458 close(fd); 472 close(fd);
459 return EVT_FAILED; 473 return -1;
460 } 474 }
461 475
462 close(fd); 476 close(fd);
463 id = atoll(id_buf); 477 id = atoll(id_buf);
464 attr->config = id;
465 attr->type = PERF_TYPE_TRACEPOINT;
466 *strp += strlen(sys_name) + evt_length + 1; /* + 1 for the ':' */
467
468 attr->sample_type |= PERF_SAMPLE_RAW;
469 attr->sample_type |= PERF_SAMPLE_TIME;
470 attr->sample_type |= PERF_SAMPLE_CPU;
471
472 attr->sample_period = 1;
473 478
479 memset(&attr, 0, sizeof(attr));
480 attr.config = id;
481 attr.type = PERF_TYPE_TRACEPOINT;
482 attr.sample_type |= PERF_SAMPLE_RAW;
483 attr.sample_type |= PERF_SAMPLE_TIME;
484 attr.sample_type |= PERF_SAMPLE_CPU;
485 attr.sample_period = 1;
474 486
475 return EVT_HANDLED; 487 snprintf(name, MAX_NAME_LEN, "%s:%s", sys_name, evt_name);
488 return add_event(list, idx, &attr, name);
476} 489}
477 490
478/* sys + ':' + event + ':' + flags*/ 491static int add_tracepoint_multi(struct list_head *list, int *idx,
479#define MAX_EVOPT_LEN (MAX_EVENT_LENGTH * 2 + 2 + 128) 492 char *sys_name, char *evt_name)
480static enum event_result
481parse_multiple_tracepoint_event(struct perf_evlist *evlist, char *sys_name,
482 const char *evt_exp, char *flags)
483{ 493{
484 char evt_path[MAXPATHLEN]; 494 char evt_path[MAXPATHLEN];
485 struct dirent *evt_ent; 495 struct dirent *evt_ent;
486 DIR *evt_dir; 496 DIR *evt_dir;
497 int ret = 0;
487 498
488 snprintf(evt_path, MAXPATHLEN, "%s/%s", tracing_events_path, sys_name); 499 snprintf(evt_path, MAXPATHLEN, "%s/%s", tracing_events_path, sys_name);
489 evt_dir = opendir(evt_path); 500 evt_dir = opendir(evt_path);
490
491 if (!evt_dir) { 501 if (!evt_dir) {
492 perror("Can't open event dir"); 502 perror("Can't open event dir");
493 return EVT_FAILED; 503 return -1;
494 } 504 }
495 505
496 while ((evt_ent = readdir(evt_dir))) { 506 while (!ret && (evt_ent = readdir(evt_dir))) {
497 char event_opt[MAX_EVOPT_LEN + 1];
498 int len;
499
500 if (!strcmp(evt_ent->d_name, ".") 507 if (!strcmp(evt_ent->d_name, ".")
501 || !strcmp(evt_ent->d_name, "..") 508 || !strcmp(evt_ent->d_name, "..")
502 || !strcmp(evt_ent->d_name, "enable") 509 || !strcmp(evt_ent->d_name, "enable")
503 || !strcmp(evt_ent->d_name, "filter")) 510 || !strcmp(evt_ent->d_name, "filter"))
504 continue; 511 continue;
505 512
506 if (!strglobmatch(evt_ent->d_name, evt_exp)) 513 if (!strglobmatch(evt_ent->d_name, evt_name))
507 continue; 514 continue;
508 515
509 len = snprintf(event_opt, MAX_EVOPT_LEN, "%s:%s%s%s", sys_name, 516 ret = add_tracepoint(list, idx, sys_name, evt_ent->d_name);
510 evt_ent->d_name, flags ? ":" : "",
511 flags ?: "");
512 if (len < 0)
513 return EVT_FAILED;
514
515 if (parse_events(evlist, event_opt, 0))
516 return EVT_FAILED;
517 } 517 }
518 518
519 return EVT_HANDLED_ALL; 519 return ret;
520} 520}
521 521
522static enum event_result 522int parse_events_add_tracepoint(struct list_head *list, int *idx,
523parse_tracepoint_event(struct perf_evlist *evlist, const char **strp, 523 char *sys, char *event)
524 struct perf_event_attr *attr)
525{ 524{
526 const char *evt_name; 525 int ret;
527 char *flags = NULL, *comma_loc;
528 char sys_name[MAX_EVENT_LENGTH];
529 unsigned int sys_length, evt_length;
530
531 if (debugfs_valid_mountpoint(tracing_events_path))
532 return 0;
533
534 evt_name = strchr(*strp, ':');
535 if (!evt_name)
536 return EVT_FAILED;
537
538 sys_length = evt_name - *strp;
539 if (sys_length >= MAX_EVENT_LENGTH)
540 return 0;
541 526
542 strncpy(sys_name, *strp, sys_length); 527 ret = debugfs_valid_mountpoint(tracing_events_path);
543 sys_name[sys_length] = '\0'; 528 if (ret)
544 evt_name = evt_name + 1; 529 return ret;
545 530
546 comma_loc = strchr(evt_name, ','); 531 return strpbrk(event, "*?") ?
547 if (comma_loc) { 532 add_tracepoint_multi(list, idx, sys, event) :
548 /* take the event name up to the comma */ 533 add_tracepoint(list, idx, sys, event);
549 evt_name = strndup(evt_name, comma_loc - evt_name);
550 }
551 flags = strchr(evt_name, ':');
552 if (flags) {
553 /* split it out: */
554 evt_name = strndup(evt_name, flags - evt_name);
555 flags++;
556 }
557
558 evt_length = strlen(evt_name);
559 if (evt_length >= MAX_EVENT_LENGTH)
560 return EVT_FAILED;
561 if (strpbrk(evt_name, "*?")) {
562 *strp += strlen(sys_name) + evt_length + 1; /* 1 == the ':' */
563 return parse_multiple_tracepoint_event(evlist, sys_name,
564 evt_name, flags);
565 } else {
566 return parse_single_tracepoint_event(sys_name, evt_name,
567 evt_length, attr, strp);
568 }
569} 534}
570 535
571static enum event_result 536static int
572parse_breakpoint_type(const char *type, const char **strp, 537parse_breakpoint_type(const char *type, struct perf_event_attr *attr)
573 struct perf_event_attr *attr)
574{ 538{
575 int i; 539 int i;
576 540
577 for (i = 0; i < 3; i++) { 541 for (i = 0; i < 3; i++) {
578 if (!type[i]) 542 if (!type || !type[i])
579 break; 543 break;
580 544
581 switch (type[i]) { 545 switch (type[i]) {
@@ -589,164 +553,146 @@ parse_breakpoint_type(const char *type, const char **strp,
589 attr->bp_type |= HW_BREAKPOINT_X; 553 attr->bp_type |= HW_BREAKPOINT_X;
590 break; 554 break;
591 default: 555 default:
592 return EVT_FAILED; 556 return -EINVAL;
593 } 557 }
594 } 558 }
559
595 if (!attr->bp_type) /* Default */ 560 if (!attr->bp_type) /* Default */
596 attr->bp_type = HW_BREAKPOINT_R | HW_BREAKPOINT_W; 561 attr->bp_type = HW_BREAKPOINT_R | HW_BREAKPOINT_W;
597 562
598 *strp = type + i; 563 return 0;
599
600 return EVT_HANDLED;
601} 564}
602 565
603static enum event_result 566int parse_events_add_breakpoint(struct list_head *list, int *idx,
604parse_breakpoint_event(const char **strp, struct perf_event_attr *attr) 567 void *ptr, char *type)
605{ 568{
606 const char *target; 569 struct perf_event_attr attr;
607 const char *type; 570 char name[MAX_NAME_LEN];
608 char *endaddr;
609 u64 addr;
610 enum event_result err;
611
612 target = strchr(*strp, ':');
613 if (!target)
614 return EVT_FAILED;
615
616 if (strncmp(*strp, "mem", target - *strp) != 0)
617 return EVT_FAILED;
618
619 target++;
620
621 addr = strtoull(target, &endaddr, 0);
622 if (target == endaddr)
623 return EVT_FAILED;
624
625 attr->bp_addr = addr;
626 *strp = endaddr;
627 571
628 type = strchr(target, ':'); 572 memset(&attr, 0, sizeof(attr));
573 attr.bp_addr = (unsigned long) ptr;
629 574
630 /* If no type is defined, just rw as default */ 575 if (parse_breakpoint_type(type, &attr))
631 if (!type) { 576 return -EINVAL;
632 attr->bp_type = HW_BREAKPOINT_R | HW_BREAKPOINT_W;
633 } else {
634 err = parse_breakpoint_type(++type, strp, attr);
635 if (err == EVT_FAILED)
636 return EVT_FAILED;
637 }
638 577
639 /* 578 /*
640 * We should find a nice way to override the access length 579 * We should find a nice way to override the access length
641 * Provide some defaults for now 580 * Provide some defaults for now
642 */ 581 */
643 if (attr->bp_type == HW_BREAKPOINT_X) 582 if (attr.bp_type == HW_BREAKPOINT_X)
644 attr->bp_len = sizeof(long); 583 attr.bp_len = sizeof(long);
645 else 584 else
646 attr->bp_len = HW_BREAKPOINT_LEN_4; 585 attr.bp_len = HW_BREAKPOINT_LEN_4;
647 586
648 attr->type = PERF_TYPE_BREAKPOINT; 587 attr.type = PERF_TYPE_BREAKPOINT;
649 588
650 return EVT_HANDLED; 589 snprintf(name, MAX_NAME_LEN, "mem:%p:%s", ptr, type ? type : "rw");
590 return add_event(list, idx, &attr, name);
651} 591}
652 592
653static int check_events(const char *str, unsigned int i) 593static int config_term(struct perf_event_attr *attr,
594 struct parse_events__term *term)
654{ 595{
655 int n; 596 switch (term->type) {
597 case PARSE_EVENTS__TERM_TYPE_CONFIG:
598 attr->config = term->val.num;
599 break;
600 case PARSE_EVENTS__TERM_TYPE_CONFIG1:
601 attr->config1 = term->val.num;
602 break;
603 case PARSE_EVENTS__TERM_TYPE_CONFIG2:
604 attr->config2 = term->val.num;
605 break;
606 case PARSE_EVENTS__TERM_TYPE_SAMPLE_PERIOD:
607 attr->sample_period = term->val.num;
608 break;
609 case PARSE_EVENTS__TERM_TYPE_BRANCH_SAMPLE_TYPE:
610 /*
611 * TODO uncomment when the field is available
612 * attr->branch_sample_type = term->val.num;
613 */
614 break;
615 default:
616 return -EINVAL;
617 }
618 return 0;
619}
656 620
657 n = strlen(event_symbols[i].symbol); 621static int config_attr(struct perf_event_attr *attr,
658 if (!strncasecmp(str, event_symbols[i].symbol, n)) 622 struct list_head *head, int fail)
659 return n; 623{
624 struct parse_events__term *term;
660 625
661 n = strlen(event_symbols[i].alias); 626 list_for_each_entry(term, head, list)
662 if (n) { 627 if (config_term(attr, term) && fail)
663 if (!strncasecmp(str, event_symbols[i].alias, n)) 628 return -EINVAL;
664 return n;
665 }
666 629
667 return 0; 630 return 0;
668} 631}
669 632
670static enum event_result 633int parse_events_add_numeric(struct list_head *list, int *idx,
671parse_symbolic_event(const char **strp, struct perf_event_attr *attr) 634 unsigned long type, unsigned long config,
635 struct list_head *head_config)
672{ 636{
673 const char *str = *strp; 637 struct perf_event_attr attr;
674 unsigned int i; 638
675 int n; 639 memset(&attr, 0, sizeof(attr));
676 640 attr.type = type;
677 for (i = 0; i < ARRAY_SIZE(event_symbols); i++) { 641 attr.config = config;
678 n = check_events(str, i); 642
679 if (n > 0) { 643 if (head_config &&
680 attr->type = event_symbols[i].type; 644 config_attr(&attr, head_config, 1))
681 attr->config = event_symbols[i].config; 645 return -EINVAL;
682 *strp = str + n; 646
683 return EVT_HANDLED; 647 return add_event(list, idx, &attr,
684 } 648 (char *) __event_name(type, config));
685 }
686 return EVT_FAILED;
687} 649}
688 650
689static enum event_result 651int parse_events_add_pmu(struct list_head *list, int *idx,
690parse_raw_event(const char **strp, struct perf_event_attr *attr) 652 char *name, struct list_head *head_config)
691{ 653{
692 const char *str = *strp; 654 struct perf_event_attr attr;
693 u64 config; 655 struct perf_pmu *pmu;
694 int n; 656
695 657 pmu = perf_pmu__find(name);
696 if (*str != 'r') 658 if (!pmu)
697 return EVT_FAILED; 659 return -EINVAL;
698 n = hex2u64(str + 1, &config); 660
699 if (n > 0) { 661 memset(&attr, 0, sizeof(attr));
700 const char *end = str + n + 1; 662
701 if (*end != '\0' && *end != ',' && *end != ':') 663 /*
702 return EVT_FAILED; 664 * Configure hardcoded terms first, no need to check
703 665 * return value when called with fail == 0 ;)
704 *strp = end; 666 */
705 attr->type = PERF_TYPE_RAW; 667 config_attr(&attr, head_config, 0);
706 attr->config = config; 668
707 return EVT_HANDLED; 669 if (perf_pmu__config(pmu, &attr, head_config))
708 } 670 return -EINVAL;
709 return EVT_FAILED; 671
672 return add_event(list, idx, &attr, (char *) "pmu");
710} 673}
711 674
712static enum event_result 675void parse_events_update_lists(struct list_head *list_event,
713parse_numeric_event(const char **strp, struct perf_event_attr *attr) 676 struct list_head *list_all)
714{ 677{
715 const char *str = *strp; 678 /*
716 char *endp; 679 * Called for single event definition. Update the
717 unsigned long type; 680 * 'all event' list, and reinit the 'signle event'
718 u64 config; 681 * list, for next event definition.
719 682 */
720 type = strtoul(str, &endp, 0); 683 list_splice_tail(list_event, list_all);
721 if (endp > str && type < PERF_TYPE_MAX && *endp == ':') { 684 INIT_LIST_HEAD(list_event);
722 str = endp + 1;
723 config = strtoul(str, &endp, 0);
724 if (endp > str) {
725 attr->type = type;
726 attr->config = config;
727 *strp = endp;
728 return EVT_HANDLED;
729 }
730 }
731 return EVT_FAILED;
732} 685}
733 686
734static int 687int parse_events_modifier(struct list_head *list, char *str)
735parse_event_modifier(const char **strp, struct perf_event_attr *attr)
736{ 688{
737 const char *str = *strp; 689 struct perf_evsel *evsel;
738 int exclude = 0, exclude_GH = 0; 690 int exclude = 0, exclude_GH = 0;
739 int eu = 0, ek = 0, eh = 0, eH = 0, eG = 0, precise = 0; 691 int eu = 0, ek = 0, eh = 0, eH = 0, eG = 0, precise = 0;
740 692
741 if (!*str) 693 if (str == NULL)
742 return 0; 694 return 0;
743 695
744 if (*str == ',')
745 return 0;
746
747 if (*str++ != ':')
748 return -1;
749
750 while (*str) { 696 while (*str) {
751 if (*str == 'u') { 697 if (*str == 'u') {
752 if (!exclude) 698 if (!exclude)
@@ -775,111 +721,62 @@ parse_event_modifier(const char **strp, struct perf_event_attr *attr)
775 721
776 ++str; 722 ++str;
777 } 723 }
778 if (str < *strp + 2)
779 return -1;
780 724
781 *strp = str; 725 /*
726 * precise ip:
727 *
728 * 0 - SAMPLE_IP can have arbitrary skid
729 * 1 - SAMPLE_IP must have constant skid
730 * 2 - SAMPLE_IP requested to have 0 skid
731 * 3 - SAMPLE_IP must have 0 skid
732 *
733 * See also PERF_RECORD_MISC_EXACT_IP
734 */
735 if (precise > 3)
736 return -EINVAL;
782 737
783 attr->exclude_user = eu; 738 list_for_each_entry(evsel, list, node) {
784 attr->exclude_kernel = ek; 739 evsel->attr.exclude_user = eu;
785 attr->exclude_hv = eh; 740 evsel->attr.exclude_kernel = ek;
786 attr->precise_ip = precise; 741 evsel->attr.exclude_hv = eh;
787 attr->exclude_host = eH; 742 evsel->attr.precise_ip = precise;
788 attr->exclude_guest = eG; 743 evsel->attr.exclude_host = eH;
744 evsel->attr.exclude_guest = eG;
745 }
789 746
790 return 0; 747 return 0;
791} 748}
792 749
793/* 750int parse_events(struct perf_evlist *evlist, const char *str, int unset __used)
794 * Each event can have multiple symbolic names.
795 * Symbolic names are (almost) exactly matched.
796 */
797static enum event_result
798parse_event_symbols(struct perf_evlist *evlist, const char **str,
799 struct perf_event_attr *attr)
800{ 751{
801 enum event_result ret; 752 LIST_HEAD(list);
802 753 LIST_HEAD(list_tmp);
803 ret = parse_tracepoint_event(evlist, str, attr); 754 YY_BUFFER_STATE buffer;
804 if (ret != EVT_FAILED) 755 int ret, idx = evlist->nr_entries;
805 goto modifier;
806
807 ret = parse_raw_event(str, attr);
808 if (ret != EVT_FAILED)
809 goto modifier;
810 756
811 ret = parse_numeric_event(str, attr); 757 buffer = parse_events__scan_string(str);
812 if (ret != EVT_FAILED)
813 goto modifier;
814 758
815 ret = parse_symbolic_event(str, attr); 759 ret = parse_events_parse(&list, &list_tmp, &idx);
816 if (ret != EVT_FAILED)
817 goto modifier;
818 760
819 ret = parse_generic_hw_event(str, attr); 761 parse_events__flush_buffer(buffer);
820 if (ret != EVT_FAILED) 762 parse_events__delete_buffer(buffer);
821 goto modifier;
822 763
823 ret = parse_breakpoint_event(str, attr); 764 if (!ret) {
824 if (ret != EVT_FAILED) 765 int entries = idx - evlist->nr_entries;
825 goto modifier; 766 perf_evlist__splice_list_tail(evlist, &list, entries);
826 767 return 0;
827 fprintf(stderr, "invalid or unsupported event: '%s'\n", *str);
828 fprintf(stderr, "Run 'perf list' for a list of valid events\n");
829 return EVT_FAILED;
830
831modifier:
832 if (parse_event_modifier(str, attr) < 0) {
833 fprintf(stderr, "invalid event modifier: '%s'\n", *str);
834 fprintf(stderr, "Run 'perf list' for a list of valid events and modifiers\n");
835
836 return EVT_FAILED;
837 } 768 }
838 769
770 /*
771 * There are 2 users - builtin-record and builtin-test objects.
772 * Both call perf_evlist__delete in case of error, so we dont
773 * need to bother.
774 */
775 fprintf(stderr, "invalid or unsupported event: '%s'\n", str);
776 fprintf(stderr, "Run 'perf list' for a list of valid events\n");
839 return ret; 777 return ret;
840} 778}
841 779
842int parse_events(struct perf_evlist *evlist , const char *str, int unset __used)
843{
844 struct perf_event_attr attr;
845 enum event_result ret;
846 const char *ostr;
847
848 for (;;) {
849 ostr = str;
850 memset(&attr, 0, sizeof(attr));
851 event_attr_init(&attr);
852 ret = parse_event_symbols(evlist, &str, &attr);
853 if (ret == EVT_FAILED)
854 return -1;
855
856 if (!(*str == 0 || *str == ',' || isspace(*str)))
857 return -1;
858
859 if (ret != EVT_HANDLED_ALL) {
860 struct perf_evsel *evsel;
861 evsel = perf_evsel__new(&attr, evlist->nr_entries);
862 if (evsel == NULL)
863 return -1;
864 perf_evlist__add(evlist, evsel);
865
866 evsel->name = calloc(str - ostr + 1, 1);
867 if (!evsel->name)
868 return -1;
869 strncpy(evsel->name, ostr, str - ostr);
870 }
871
872 if (*str == 0)
873 break;
874 if (*str == ',')
875 ++str;
876 while (isspace(*str))
877 ++str;
878 }
879
880 return 0;
881}
882
883int parse_events_option(const struct option *opt, const char *str, 780int parse_events_option(const struct option *opt, const char *str,
884 int unset __used) 781 int unset __used)
885{ 782{
@@ -1052,8 +949,6 @@ int print_hwcache_events(const char *event_glob)
1052 return printed; 949 return printed;
1053} 950}
1054 951
1055#define MAX_NAME_LEN 100
1056
1057/* 952/*
1058 * Print the help text for the event symbols: 953 * Print the help text for the event symbols:
1059 */ 954 */
@@ -1102,8 +997,12 @@ void print_events(const char *event_glob)
1102 997
1103 printf("\n"); 998 printf("\n");
1104 printf(" %-50s [%s]\n", 999 printf(" %-50s [%s]\n",
1105 "rNNN (see 'perf list --help' on how to encode it)", 1000 "rNNN",
1106 event_type_descriptors[PERF_TYPE_RAW]); 1001 event_type_descriptors[PERF_TYPE_RAW]);
1002 printf(" %-50s [%s]\n",
1003 "cpu/t1=v1[,t2=v2,t3 ...]/modifier",
1004 event_type_descriptors[PERF_TYPE_RAW]);
1005 printf(" (see 'perf list --help' on how to encode it)\n");
1107 printf("\n"); 1006 printf("\n");
1108 1007
1109 printf(" %-50s [%s]\n", 1008 printf(" %-50s [%s]\n",
@@ -1113,3 +1012,51 @@ void print_events(const char *event_glob)
1113 1012
1114 print_tracepoint_events(NULL, NULL); 1013 print_tracepoint_events(NULL, NULL);
1115} 1014}
1015
1016int parse_events__is_hardcoded_term(struct parse_events__term *term)
1017{
1018 return term->type <= PARSE_EVENTS__TERM_TYPE_HARDCODED_MAX;
1019}
1020
1021int parse_events__new_term(struct parse_events__term **_term, int type,
1022 char *config, char *str, long num)
1023{
1024 struct parse_events__term *term;
1025
1026 term = zalloc(sizeof(*term));
1027 if (!term)
1028 return -ENOMEM;
1029
1030 INIT_LIST_HEAD(&term->list);
1031 term->type = type;
1032 term->config = config;
1033
1034 switch (type) {
1035 case PARSE_EVENTS__TERM_TYPE_CONFIG:
1036 case PARSE_EVENTS__TERM_TYPE_CONFIG1:
1037 case PARSE_EVENTS__TERM_TYPE_CONFIG2:
1038 case PARSE_EVENTS__TERM_TYPE_SAMPLE_PERIOD:
1039 case PARSE_EVENTS__TERM_TYPE_BRANCH_SAMPLE_TYPE:
1040 case PARSE_EVENTS__TERM_TYPE_NUM:
1041 term->val.num = num;
1042 break;
1043 case PARSE_EVENTS__TERM_TYPE_STR:
1044 term->val.str = str;
1045 break;
1046 default:
1047 return -EINVAL;
1048 }
1049
1050 *_term = term;
1051 return 0;
1052}
1053
1054void parse_events__free_terms(struct list_head *terms)
1055{
1056 struct parse_events__term *term, *h;
1057
1058 list_for_each_entry_safe(term, h, terms, list)
1059 free(term);
1060
1061 free(terms);
1062}
diff --git a/tools/perf/util/parse-events.h b/tools/perf/util/parse-events.h
index 7e0cbe75d5f1..ca069f893381 100644
--- a/tools/perf/util/parse-events.h
+++ b/tools/perf/util/parse-events.h
@@ -33,6 +33,55 @@ extern int parse_filter(const struct option *opt, const char *str, int unset);
33 33
34#define EVENTS_HELP_MAX (128*1024) 34#define EVENTS_HELP_MAX (128*1024)
35 35
36enum {
37 PARSE_EVENTS__TERM_TYPE_CONFIG,
38 PARSE_EVENTS__TERM_TYPE_CONFIG1,
39 PARSE_EVENTS__TERM_TYPE_CONFIG2,
40 PARSE_EVENTS__TERM_TYPE_SAMPLE_PERIOD,
41 PARSE_EVENTS__TERM_TYPE_BRANCH_SAMPLE_TYPE,
42 PARSE_EVENTS__TERM_TYPE_NUM,
43 PARSE_EVENTS__TERM_TYPE_STR,
44
45 PARSE_EVENTS__TERM_TYPE_HARDCODED_MAX =
46 PARSE_EVENTS__TERM_TYPE_BRANCH_SAMPLE_TYPE,
47};
48
49struct parse_events__term {
50 char *config;
51 union {
52 char *str;
53 long num;
54 } val;
55 int type;
56
57 struct list_head list;
58};
59
60int parse_events__is_hardcoded_term(struct parse_events__term *term);
61int parse_events__new_term(struct parse_events__term **term, int type,
62 char *config, char *str, long num);
63void parse_events__free_terms(struct list_head *terms);
64int parse_events_modifier(struct list_head *list __used, char *str __used);
65int parse_events_add_tracepoint(struct list_head *list, int *idx,
66 char *sys, char *event);
67int parse_events_add_raw(struct perf_evlist *evlist, unsigned long config,
68 unsigned long config1, unsigned long config2,
69 char *mod);
70int parse_events_add_numeric(struct list_head *list, int *idx,
71 unsigned long type, unsigned long config,
72 struct list_head *head_config);
73int parse_events_add_cache(struct list_head *list, int *idx,
74 char *type, char *op_result1, char *op_result2);
75int parse_events_add_breakpoint(struct list_head *list, int *idx,
76 void *ptr, char *type);
77int parse_events_add_pmu(struct list_head *list, int *idx,
78 char *pmu , struct list_head *head_config);
79void parse_events_update_lists(struct list_head *list_event,
80 struct list_head *list_all);
81void parse_events_error(struct list_head *list_all,
82 struct list_head *list_event,
83 int *idx, char const *msg);
84
36void print_events(const char *event_glob); 85void print_events(const char *event_glob);
37void print_events_type(u8 type); 86void print_events_type(u8 type);
38void print_tracepoint_events(const char *subsys_glob, const char *event_glob); 87void print_tracepoint_events(const char *subsys_glob, const char *event_glob);
diff --git a/tools/perf/util/parse-events.l b/tools/perf/util/parse-events.l
new file mode 100644
index 000000000000..ab9eca120feb
--- /dev/null
+++ b/tools/perf/util/parse-events.l
@@ -0,0 +1,126 @@
1
2%option prefix="parse_events_"
3
4%{
5#include <errno.h>
6#include "../perf.h"
7#include "parse-events-bison.h"
8#include "parse-events.h"
9
10static int __value(char *str, int base, int token)
11{
12 long num;
13
14 errno = 0;
15 num = strtoul(str, NULL, base);
16 if (errno)
17 return PE_ERROR;
18
19 parse_events_lval.num = num;
20 return token;
21}
22
23static int value(int base)
24{
25 return __value(parse_events_text, base, PE_VALUE);
26}
27
28static int raw(void)
29{
30 return __value(parse_events_text + 1, 16, PE_RAW);
31}
32
33static int str(int token)
34{
35 parse_events_lval.str = strdup(parse_events_text);
36 return token;
37}
38
39static int sym(int type, int config)
40{
41 parse_events_lval.num = (type << 16) + config;
42 return PE_VALUE_SYM;
43}
44
45static int term(int type)
46{
47 parse_events_lval.num = type;
48 return PE_TERM;
49}
50
51%}
52
53num_dec [0-9]+
54num_hex 0x[a-fA-F0-9]+
55num_raw_hex [a-fA-F0-9]+
56name [a-zA-Z_*?][a-zA-Z0-9_*?]*
57modifier_event [ukhp]{1,5}
58modifier_bp [rwx]
59
60%%
61cpu-cycles|cycles { return sym(PERF_TYPE_HARDWARE, PERF_COUNT_HW_CPU_CYCLES); }
62stalled-cycles-frontend|idle-cycles-frontend { return sym(PERF_TYPE_HARDWARE, PERF_COUNT_HW_STALLED_CYCLES_FRONTEND); }
63stalled-cycles-backend|idle-cycles-backend { return sym(PERF_TYPE_HARDWARE, PERF_COUNT_HW_STALLED_CYCLES_BACKEND); }
64instructions { return sym(PERF_TYPE_HARDWARE, PERF_COUNT_HW_INSTRUCTIONS); }
65cache-references { return sym(PERF_TYPE_HARDWARE, PERF_COUNT_HW_CACHE_REFERENCES); }
66cache-misses { return sym(PERF_TYPE_HARDWARE, PERF_COUNT_HW_CACHE_MISSES); }
67branch-instructions|branches { return sym(PERF_TYPE_HARDWARE, PERF_COUNT_HW_BRANCH_INSTRUCTIONS); }
68branch-misses { return sym(PERF_TYPE_HARDWARE, PERF_COUNT_HW_BRANCH_MISSES); }
69bus-cycles { return sym(PERF_TYPE_HARDWARE, PERF_COUNT_HW_BUS_CYCLES); }
70cpu-clock { return sym(PERF_TYPE_SOFTWARE, PERF_COUNT_SW_CPU_CLOCK); }
71task-clock { return sym(PERF_TYPE_SOFTWARE, PERF_COUNT_SW_TASK_CLOCK); }
72page-faults|faults { return sym(PERF_TYPE_SOFTWARE, PERF_COUNT_SW_PAGE_FAULTS); }
73minor-faults { return sym(PERF_TYPE_SOFTWARE, PERF_COUNT_SW_PAGE_FAULTS_MIN); }
74major-faults { return sym(PERF_TYPE_SOFTWARE, PERF_COUNT_SW_PAGE_FAULTS_MAJ); }
75context-switches|cs { return sym(PERF_TYPE_SOFTWARE, PERF_COUNT_SW_CONTEXT_SWITCHES); }
76cpu-migrations|migrations { return sym(PERF_TYPE_SOFTWARE, PERF_COUNT_SW_CPU_MIGRATIONS); }
77alignment-faults { return sym(PERF_TYPE_SOFTWARE, PERF_COUNT_SW_ALIGNMENT_FAULTS); }
78emulation-faults { return sym(PERF_TYPE_SOFTWARE, PERF_COUNT_SW_EMULATION_FAULTS); }
79
80L1-dcache|l1-d|l1d|L1-data |
81L1-icache|l1-i|l1i|L1-instruction |
82LLC|L2 |
83dTLB|d-tlb|Data-TLB |
84iTLB|i-tlb|Instruction-TLB |
85branch|branches|bpu|btb|bpc |
86node { return str(PE_NAME_CACHE_TYPE); }
87
88load|loads|read |
89store|stores|write |
90prefetch|prefetches |
91speculative-read|speculative-load |
92refs|Reference|ops|access |
93misses|miss { return str(PE_NAME_CACHE_OP_RESULT); }
94
95 /*
96 * These are event config hardcoded term names to be specified
97 * within xxx/.../ syntax. So far we dont clash with other names,
98 * so we can put them here directly. In case the we have a conflict
99 * in future, this needs to go into '//' condition block.
100 */
101config { return term(PARSE_EVENTS__TERM_TYPE_CONFIG); }
102config1 { return term(PARSE_EVENTS__TERM_TYPE_CONFIG1); }
103config2 { return term(PARSE_EVENTS__TERM_TYPE_CONFIG2); }
104period { return term(PARSE_EVENTS__TERM_TYPE_SAMPLE_PERIOD); }
105branch_type { return term(PARSE_EVENTS__TERM_TYPE_BRANCH_SAMPLE_TYPE); }
106
107mem: { return PE_PREFIX_MEM; }
108r{num_raw_hex} { return raw(); }
109{num_dec} { return value(10); }
110{num_hex} { return value(16); }
111
112{modifier_event} { return str(PE_MODIFIER_EVENT); }
113{modifier_bp} { return str(PE_MODIFIER_BP); }
114{name} { return str(PE_NAME); }
115"/" { return '/'; }
116- { return '-'; }
117, { return ','; }
118: { return ':'; }
119= { return '='; }
120
121%%
122
123int parse_events_wrap(void)
124{
125 return 1;
126}
diff --git a/tools/perf/util/parse-events.y b/tools/perf/util/parse-events.y
new file mode 100644
index 000000000000..d9637da7333c
--- /dev/null
+++ b/tools/perf/util/parse-events.y
@@ -0,0 +1,229 @@
1
2%name-prefix "parse_events_"
3%parse-param {struct list_head *list_all}
4%parse-param {struct list_head *list_event}
5%parse-param {int *idx}
6
7%{
8
9#define YYDEBUG 1
10
11#include <linux/compiler.h>
12#include <linux/list.h>
13#include "types.h"
14#include "util.h"
15#include "parse-events.h"
16
17extern int parse_events_lex (void);
18
19#define ABORT_ON(val) \
20do { \
21 if (val) \
22 YYABORT; \
23} while (0)
24
25%}
26
27%token PE_VALUE PE_VALUE_SYM PE_RAW PE_TERM
28%token PE_NAME
29%token PE_MODIFIER_EVENT PE_MODIFIER_BP
30%token PE_NAME_CACHE_TYPE PE_NAME_CACHE_OP_RESULT
31%token PE_PREFIX_MEM PE_PREFIX_RAW
32%token PE_ERROR
33%type <num> PE_VALUE
34%type <num> PE_VALUE_SYM
35%type <num> PE_RAW
36%type <num> PE_TERM
37%type <str> PE_NAME
38%type <str> PE_NAME_CACHE_TYPE
39%type <str> PE_NAME_CACHE_OP_RESULT
40%type <str> PE_MODIFIER_EVENT
41%type <str> PE_MODIFIER_BP
42%type <head> event_config
43%type <term> event_term
44
45%union
46{
47 char *str;
48 unsigned long num;
49 struct list_head *head;
50 struct parse_events__term *term;
51}
52%%
53
54events:
55events ',' event | event
56
57event:
58event_def PE_MODIFIER_EVENT
59{
60 /*
61 * Apply modifier on all events added by single event definition
62 * (there could be more events added for multiple tracepoint
63 * definitions via '*?'.
64 */
65 ABORT_ON(parse_events_modifier(list_event, $2));
66 parse_events_update_lists(list_event, list_all);
67}
68|
69event_def
70{
71 parse_events_update_lists(list_event, list_all);
72}
73
74event_def: event_pmu |
75 event_legacy_symbol |
76 event_legacy_cache sep_dc |
77 event_legacy_mem |
78 event_legacy_tracepoint sep_dc |
79 event_legacy_numeric sep_dc |
80 event_legacy_raw sep_dc
81
82event_pmu:
83PE_NAME '/' event_config '/'
84{
85 ABORT_ON(parse_events_add_pmu(list_event, idx, $1, $3));
86 parse_events__free_terms($3);
87}
88
89event_legacy_symbol:
90PE_VALUE_SYM '/' event_config '/'
91{
92 int type = $1 >> 16;
93 int config = $1 & 255;
94
95 ABORT_ON(parse_events_add_numeric(list_event, idx, type, config, $3));
96 parse_events__free_terms($3);
97}
98|
99PE_VALUE_SYM sep_slash_dc
100{
101 int type = $1 >> 16;
102 int config = $1 & 255;
103
104 ABORT_ON(parse_events_add_numeric(list_event, idx, type, config, NULL));
105}
106
107event_legacy_cache:
108PE_NAME_CACHE_TYPE '-' PE_NAME_CACHE_OP_RESULT '-' PE_NAME_CACHE_OP_RESULT
109{
110 ABORT_ON(parse_events_add_cache(list_event, idx, $1, $3, $5));
111}
112|
113PE_NAME_CACHE_TYPE '-' PE_NAME_CACHE_OP_RESULT
114{
115 ABORT_ON(parse_events_add_cache(list_event, idx, $1, $3, NULL));
116}
117|
118PE_NAME_CACHE_TYPE
119{
120 ABORT_ON(parse_events_add_cache(list_event, idx, $1, NULL, NULL));
121}
122
123event_legacy_mem:
124PE_PREFIX_MEM PE_VALUE ':' PE_MODIFIER_BP sep_dc
125{
126 ABORT_ON(parse_events_add_breakpoint(list_event, idx, (void *) $2, $4));
127}
128|
129PE_PREFIX_MEM PE_VALUE sep_dc
130{
131 ABORT_ON(parse_events_add_breakpoint(list_event, idx, (void *) $2, NULL));
132}
133
134event_legacy_tracepoint:
135PE_NAME ':' PE_NAME
136{
137 ABORT_ON(parse_events_add_tracepoint(list_event, idx, $1, $3));
138}
139
140event_legacy_numeric:
141PE_VALUE ':' PE_VALUE
142{
143 ABORT_ON(parse_events_add_numeric(list_event, idx, $1, $3, NULL));
144}
145
146event_legacy_raw:
147PE_RAW
148{
149 ABORT_ON(parse_events_add_numeric(list_event, idx, PERF_TYPE_RAW, $1, NULL));
150}
151
152event_config:
153event_config ',' event_term
154{
155 struct list_head *head = $1;
156 struct parse_events__term *term = $3;
157
158 ABORT_ON(!head);
159 list_add_tail(&term->list, head);
160 $$ = $1;
161}
162|
163event_term
164{
165 struct list_head *head = malloc(sizeof(*head));
166 struct parse_events__term *term = $1;
167
168 ABORT_ON(!head);
169 INIT_LIST_HEAD(head);
170 list_add_tail(&term->list, head);
171 $$ = head;
172}
173
174event_term:
175PE_NAME '=' PE_NAME
176{
177 struct parse_events__term *term;
178
179 ABORT_ON(parse_events__new_term(&term, PARSE_EVENTS__TERM_TYPE_STR,
180 $1, $3, 0));
181 $$ = term;
182}
183|
184PE_NAME '=' PE_VALUE
185{
186 struct parse_events__term *term;
187
188 ABORT_ON(parse_events__new_term(&term, PARSE_EVENTS__TERM_TYPE_NUM,
189 $1, NULL, $3));
190 $$ = term;
191}
192|
193PE_NAME
194{
195 struct parse_events__term *term;
196
197 ABORT_ON(parse_events__new_term(&term, PARSE_EVENTS__TERM_TYPE_NUM,
198 $1, NULL, 1));
199 $$ = term;
200}
201|
202PE_TERM '=' PE_VALUE
203{
204 struct parse_events__term *term;
205
206 ABORT_ON(parse_events__new_term(&term, $1, NULL, NULL, $3));
207 $$ = term;
208}
209|
210PE_TERM
211{
212 struct parse_events__term *term;
213
214 ABORT_ON(parse_events__new_term(&term, $1, NULL, NULL, 1));
215 $$ = term;
216}
217
218sep_dc: ':' |
219
220sep_slash_dc: '/' | ':' |
221
222%%
223
224void parse_events_error(struct list_head *list_all __used,
225 struct list_head *list_event __used,
226 int *idx __used,
227 char const *msg __used)
228{
229}
diff --git a/tools/perf/util/pmu-bison.c b/tools/perf/util/pmu-bison.c
new file mode 100644
index 000000000000..343521ec589f
--- /dev/null
+++ b/tools/perf/util/pmu-bison.c
@@ -0,0 +1,1663 @@
1/* A Bison parser, made by GNU Bison 2.4.3. */
2
3/* Skeleton implementation for Bison's Yacc-like parsers in C
4
5 Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006,
6 2009, 2010 Free Software Foundation, Inc.
7
8 This program is free software: you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation, either version 3 of the License, or
11 (at your option) any later version.
12
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
17
18 You should have received a copy of the GNU General Public License
19 along with this program. If not, see <http://www.gnu.org/licenses/>. */
20
21/* As a special exception, you may create a larger work that contains
22 part or all of the Bison parser skeleton and distribute that work
23 under terms of your choice, so long as that work isn't itself a
24 parser generator using the skeleton or a modified version thereof
25 as a parser skeleton. Alternatively, if you modify or redistribute
26 the parser skeleton itself, you may (at your option) remove this
27 special exception, which will cause the skeleton and the resulting
28 Bison output files to be licensed under the GNU General Public
29 License without this special exception.
30
31 This special exception was added by the Free Software Foundation in
32 version 2.2 of Bison. */
33
34/* C LALR(1) parser skeleton written by Richard Stallman, by
35 simplifying the original so-called "semantic" parser. */
36
37/* All symbols defined below should begin with yy or YY, to avoid
38 infringing on user name space. This should be done even for local
39 variables, as they might otherwise be expanded by user macros.
40 There are some unavoidable exceptions within include files to
41 define necessary library symbols; they are noted "INFRINGES ON
42 USER NAME SPACE" below. */
43
44/* Identify Bison output. */
45#define YYBISON 1
46
47/* Bison version. */
48#define YYBISON_VERSION "2.4.3"
49
50/* Skeleton name. */
51#define YYSKELETON_NAME "yacc.c"
52
53/* Pure parsers. */
54#define YYPURE 0
55
56/* Push parsers. */
57#define YYPUSH 0
58
59/* Pull parsers. */
60#define YYPULL 1
61
62/* Using locations. */
63#define YYLSP_NEEDED 0
64
65/* Substitute the variable and function names. */
66#define yyparse perf_pmu_parse
67#define yylex perf_pmu_lex
68#define yyerror perf_pmu_error
69#define yylval perf_pmu_lval
70#define yychar perf_pmu_char
71#define yydebug perf_pmu_debug
72#define yynerrs perf_pmu_nerrs
73
74
75/* Copy the first part of user declarations. */
76
77/* Line 189 of yacc.c */
78#line 6 "util/pmu.y"
79
80
81#include <linux/compiler.h>
82#include <linux/list.h>
83#include <linux/bitmap.h>
84#include <string.h>
85#include "pmu.h"
86
87extern int perf_pmu_lex (void);
88
89#define ABORT_ON(val) \
90do { \
91 if (val) \
92 YYABORT; \
93} while (0)
94
95
96
97/* Line 189 of yacc.c */
98#line 99 "util/pmu-bison.c"
99
100/* Enabling traces. */
101#ifndef YYDEBUG
102# define YYDEBUG 0
103#endif
104
105/* Enabling verbose error messages. */
106#ifdef YYERROR_VERBOSE
107# undef YYERROR_VERBOSE
108# define YYERROR_VERBOSE 1
109#else
110# define YYERROR_VERBOSE 0
111#endif
112
113/* Enabling the token table. */
114#ifndef YYTOKEN_TABLE
115# define YYTOKEN_TABLE 0
116#endif
117
118
119/* Tokens. */
120#ifndef YYTOKENTYPE
121# define YYTOKENTYPE
122 /* Put the tokens into the symbol table, so that GDB and other debuggers
123 know about them. */
124 enum yytokentype {
125 PP_CONFIG = 258,
126 PP_CONFIG1 = 259,
127 PP_CONFIG2 = 260,
128 PP_VALUE = 261,
129 PP_ERROR = 262
130 };
131#endif
132
133
134
135#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
136typedef union YYSTYPE
137{
138
139/* Line 214 of yacc.c */
140#line 31 "util/pmu.y"
141
142 unsigned long num;
143 DECLARE_BITMAP(bits, PERF_PMU_FORMAT_BITS);
144
145
146
147/* Line 214 of yacc.c */
148#line 149 "util/pmu-bison.c"
149} YYSTYPE;
150# define YYSTYPE_IS_TRIVIAL 1
151# define yystype YYSTYPE /* obsolescent; will be withdrawn */
152# define YYSTYPE_IS_DECLARED 1
153#endif
154
155
156/* Copy the second part of user declarations. */
157
158
159/* Line 264 of yacc.c */
160#line 161 "util/pmu-bison.c"
161
162#ifdef short
163# undef short
164#endif
165
166#ifdef YYTYPE_UINT8
167typedef YYTYPE_UINT8 yytype_uint8;
168#else
169typedef unsigned char yytype_uint8;
170#endif
171
172#ifdef YYTYPE_INT8
173typedef YYTYPE_INT8 yytype_int8;
174#elif (defined __STDC__ || defined __C99__FUNC__ \
175 || defined __cplusplus || defined _MSC_VER)
176typedef signed char yytype_int8;
177#else
178typedef short int yytype_int8;
179#endif
180
181#ifdef YYTYPE_UINT16
182typedef YYTYPE_UINT16 yytype_uint16;
183#else
184typedef unsigned short int yytype_uint16;
185#endif
186
187#ifdef YYTYPE_INT16
188typedef YYTYPE_INT16 yytype_int16;
189#else
190typedef short int yytype_int16;
191#endif
192
193#ifndef YYSIZE_T
194# ifdef __SIZE_TYPE__
195# define YYSIZE_T __SIZE_TYPE__
196# elif defined size_t
197# define YYSIZE_T size_t
198# elif ! defined YYSIZE_T && (defined __STDC__ || defined __C99__FUNC__ \
199 || defined __cplusplus || defined _MSC_VER)
200# include <stddef.h> /* INFRINGES ON USER NAME SPACE */
201# define YYSIZE_T size_t
202# else
203# define YYSIZE_T unsigned int
204# endif
205#endif
206
207#define YYSIZE_MAXIMUM ((YYSIZE_T) -1)
208
209#ifndef YY_
210# if defined YYENABLE_NLS && YYENABLE_NLS
211# if ENABLE_NLS
212# include <libintl.h> /* INFRINGES ON USER NAME SPACE */
213# define YY_(msgid) dgettext ("bison-runtime", msgid)
214# endif
215# endif
216# ifndef YY_
217# define YY_(msgid) msgid
218# endif
219#endif
220
221/* Suppress unused-variable warnings by "using" E. */
222#if ! defined lint || defined __GNUC__
223# define YYUSE(e) ((void) (e))
224#else
225# define YYUSE(e) /* empty */
226#endif
227
228/* Identity function, used to suppress warnings about constant conditions. */
229#ifndef lint
230# define YYID(n) (n)
231#else
232#if (defined __STDC__ || defined __C99__FUNC__ \
233 || defined __cplusplus || defined _MSC_VER)
234static int
235YYID (int yyi)
236#else
237static int
238YYID (yyi)
239 int yyi;
240#endif
241{
242 return yyi;
243}
244#endif
245
246#if ! defined yyoverflow || YYERROR_VERBOSE
247
248/* The parser invokes alloca or malloc; define the necessary symbols. */
249
250# ifdef YYSTACK_USE_ALLOCA
251# if YYSTACK_USE_ALLOCA
252# ifdef __GNUC__
253# define YYSTACK_ALLOC __builtin_alloca
254# elif defined __BUILTIN_VA_ARG_INCR
255# include <alloca.h> /* INFRINGES ON USER NAME SPACE */
256# elif defined _AIX
257# define YYSTACK_ALLOC __alloca
258# elif defined _MSC_VER
259# include <malloc.h> /* INFRINGES ON USER NAME SPACE */
260# define alloca _alloca
261# else
262# define YYSTACK_ALLOC alloca
263# if ! defined _ALLOCA_H && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
264 || defined __cplusplus || defined _MSC_VER)
265# include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
266# ifndef _STDLIB_H
267# define _STDLIB_H 1
268# endif
269# endif
270# endif
271# endif
272# endif
273
274# ifdef YYSTACK_ALLOC
275 /* Pacify GCC's `empty if-body' warning. */
276# define YYSTACK_FREE(Ptr) do { /* empty */; } while (YYID (0))
277# ifndef YYSTACK_ALLOC_MAXIMUM
278 /* The OS might guarantee only one guard page at the bottom of the stack,
279 and a page size can be as small as 4096 bytes. So we cannot safely
280 invoke alloca (N) if N exceeds 4096. Use a slightly smaller number
281 to allow for a few compiler-allocated temporary stack slots. */
282# define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */
283# endif
284# else
285# define YYSTACK_ALLOC YYMALLOC
286# define YYSTACK_FREE YYFREE
287# ifndef YYSTACK_ALLOC_MAXIMUM
288# define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM
289# endif
290# if (defined __cplusplus && ! defined _STDLIB_H \
291 && ! ((defined YYMALLOC || defined malloc) \
292 && (defined YYFREE || defined free)))
293# include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
294# ifndef _STDLIB_H
295# define _STDLIB_H 1
296# endif
297# endif
298# ifndef YYMALLOC
299# define YYMALLOC malloc
300# if ! defined malloc && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
301 || defined __cplusplus || defined _MSC_VER)
302void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */
303# endif
304# endif
305# ifndef YYFREE
306# define YYFREE free
307# if ! defined free && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
308 || defined __cplusplus || defined _MSC_VER)
309void free (void *); /* INFRINGES ON USER NAME SPACE */
310# endif
311# endif
312# endif
313#endif /* ! defined yyoverflow || YYERROR_VERBOSE */
314
315
316#if (! defined yyoverflow \
317 && (! defined __cplusplus \
318 || (defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL)))
319
320/* A type that is properly aligned for any stack member. */
321union yyalloc
322{
323 yytype_int16 yyss_alloc;
324 YYSTYPE yyvs_alloc;
325};
326
327/* The size of the maximum gap between one aligned stack and the next. */
328# define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1)
329
330/* The size of an array large to enough to hold all stacks, each with
331 N elements. */
332# define YYSTACK_BYTES(N) \
333 ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE)) \
334 + YYSTACK_GAP_MAXIMUM)
335
336/* Copy COUNT objects from FROM to TO. The source and destination do
337 not overlap. */
338# ifndef YYCOPY
339# if defined __GNUC__ && 1 < __GNUC__
340# define YYCOPY(To, From, Count) \
341 __builtin_memcpy (To, From, (Count) * sizeof (*(From)))
342# else
343# define YYCOPY(To, From, Count) \
344 do \
345 { \
346 YYSIZE_T yyi; \
347 for (yyi = 0; yyi < (Count); yyi++) \
348 (To)[yyi] = (From)[yyi]; \
349 } \
350 while (YYID (0))
351# endif
352# endif
353
354/* Relocate STACK from its old location to the new one. The
355 local variables YYSIZE and YYSTACKSIZE give the old and new number of
356 elements in the stack, and YYPTR gives the new location of the
357 stack. Advance YYPTR to a properly aligned location for the next
358 stack. */
359# define YYSTACK_RELOCATE(Stack_alloc, Stack) \
360 do \
361 { \
362 YYSIZE_T yynewbytes; \
363 YYCOPY (&yyptr->Stack_alloc, Stack, yysize); \
364 Stack = &yyptr->Stack_alloc; \
365 yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \
366 yyptr += yynewbytes / sizeof (*yyptr); \
367 } \
368 while (YYID (0))
369
370#endif
371
372/* YYFINAL -- State number of the termination state. */
373#define YYFINAL 9
374/* YYLAST -- Last index in YYTABLE. */
375#define YYLAST 17
376
377/* YYNTOKENS -- Number of terminals. */
378#define YYNTOKENS 11
379/* YYNNTS -- Number of nonterminals. */
380#define YYNNTS 5
381/* YYNRULES -- Number of rules. */
382#define YYNRULES 10
383/* YYNRULES -- Number of states. */
384#define YYNSTATES 20
385
386/* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */
387#define YYUNDEFTOK 2
388#define YYMAXUTOK 262
389
390#define YYTRANSLATE(YYX) \
391 ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
392
393/* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */
394static const yytype_uint8 yytranslate[] =
395{
396 0, 2, 2, 2, 2, 2, 2, 2, 2, 2,
397 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
398 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
399 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
400 2, 2, 2, 2, 9, 10, 2, 2, 2, 2,
401 2, 2, 2, 2, 2, 2, 2, 2, 8, 2,
402 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
403 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
404 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
405 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
406 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
407 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
408 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
409 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
410 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
411 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
412 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
413 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
414 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
415 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
416 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
417 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
418 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
419 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
420 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
421 2, 2, 2, 2, 2, 2, 1, 2, 3, 4,
422 5, 6, 7
423};
424
425#if YYDEBUG
426/* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in
427 YYRHS. */
428static const yytype_uint8 yyprhs[] =
429{
430 0, 0, 3, 6, 8, 12, 16, 20, 24, 26,
431 30
432};
433
434/* YYRHS -- A `-1'-separated list of the rules' RHS. */
435static const yytype_int8 yyrhs[] =
436{
437 12, 0, -1, 12, 13, -1, 13, -1, 3, 8,
438 14, -1, 4, 8, 14, -1, 5, 8, 14, -1,
439 14, 9, 15, -1, 15, -1, 6, 10, 6, -1,
440 6, -1
441};
442
443/* YYRLINE[YYN] -- source line where rule number YYN was defined. */
444static const yytype_uint8 yyrline[] =
445{
446 0, 39, 39, 41, 44, 51, 58, 66, 71, 77,
447 82
448};
449#endif
450
451#if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE
452/* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
453 First, the terminals, then, starting at YYNTOKENS, nonterminals. */
454static const char *const yytname[] =
455{
456 "$end", "error", "$undefined", "PP_CONFIG", "PP_CONFIG1", "PP_CONFIG2",
457 "PP_VALUE", "PP_ERROR", "':'", "','", "'-'", "$accept", "format",
458 "format_term", "bits", "bit_term", 0
459};
460#endif
461
462# ifdef YYPRINT
463/* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to
464 token YYLEX-NUM. */
465static const yytype_uint16 yytoknum[] =
466{
467 0, 256, 257, 258, 259, 260, 261, 262, 58, 44,
468 45
469};
470# endif
471
472/* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
473static const yytype_uint8 yyr1[] =
474{
475 0, 11, 12, 12, 13, 13, 13, 14, 14, 15,
476 15
477};
478
479/* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */
480static const yytype_uint8 yyr2[] =
481{
482 0, 2, 2, 1, 3, 3, 3, 3, 1, 3,
483 1
484};
485
486/* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state
487 STATE-NUM when YYTABLE doesn't specify something else to do. Zero
488 means the default is an error. */
489static const yytype_uint8 yydefact[] =
490{
491 0, 0, 0, 0, 0, 3, 0, 0, 0, 1,
492 2, 10, 4, 8, 5, 6, 0, 0, 9, 7
493};
494
495/* YYDEFGOTO[NTERM-NUM]. */
496static const yytype_int8 yydefgoto[] =
497{
498 -1, 4, 5, 12, 13
499};
500
501/* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
502 STATE-NUM. */
503#define YYPACT_NINF -7
504static const yytype_int8 yypact[] =
505{
506 3, 1, 2, 4, 0, -7, 5, 5, 5, -7,
507 -7, 6, 8, -7, 8, 8, 7, 5, -7, -7
508};
509
510/* YYPGOTO[NTERM-NUM]. */
511static const yytype_int8 yypgoto[] =
512{
513 -7, -7, 10, -6, -2
514};
515
516/* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If
517 positive, shift that token. If negative, reduce the rule which
518 number is the opposite. If zero, do what YYDEFACT says.
519 If YYTABLE_NINF, syntax error. */
520#define YYTABLE_NINF -1
521static const yytype_uint8 yytable[] =
522{
523 9, 14, 15, 1, 2, 3, 1, 2, 3, 6,
524 7, 11, 8, 18, 10, 19, 16, 17
525};
526
527static const yytype_uint8 yycheck[] =
528{
529 0, 7, 8, 3, 4, 5, 3, 4, 5, 8,
530 8, 6, 8, 6, 4, 17, 10, 9
531};
532
533/* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
534 symbol of state STATE-NUM. */
535static const yytype_uint8 yystos[] =
536{
537 0, 3, 4, 5, 12, 13, 8, 8, 8, 0,
538 13, 6, 14, 15, 14, 14, 10, 9, 6, 15
539};
540
541#define yyerrok (yyerrstatus = 0)
542#define yyclearin (yychar = YYEMPTY)
543#define YYEMPTY (-2)
544#define YYEOF 0
545
546#define YYACCEPT goto yyacceptlab
547#define YYABORT goto yyabortlab
548#define YYERROR goto yyerrorlab
549
550
551/* Like YYERROR except do call yyerror. This remains here temporarily
552 to ease the transition to the new meaning of YYERROR, for GCC.
553 Once GCC version 2 has supplanted version 1, this can go. However,
554 YYFAIL appears to be in use. Nevertheless, it is formally deprecated
555 in Bison 2.4.2's NEWS entry, where a plan to phase it out is
556 discussed. */
557
558#define YYFAIL goto yyerrlab
559#if defined YYFAIL
560 /* This is here to suppress warnings from the GCC cpp's
561 -Wunused-macros. Normally we don't worry about that warning, but
562 some users do, and we want to make it easy for users to remove
563 YYFAIL uses, which will produce warnings from Bison 2.5. */
564#endif
565
566#define YYRECOVERING() (!!yyerrstatus)
567
568#define YYBACKUP(Token, Value) \
569do \
570 if (yychar == YYEMPTY && yylen == 1) \
571 { \
572 yychar = (Token); \
573 yylval = (Value); \
574 yytoken = YYTRANSLATE (yychar); \
575 YYPOPSTACK (1); \
576 goto yybackup; \
577 } \
578 else \
579 { \
580 yyerror (format, name, YY_("syntax error: cannot back up")); \
581 YYERROR; \
582 } \
583while (YYID (0))
584
585
586#define YYTERROR 1
587#define YYERRCODE 256
588
589
590/* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N].
591 If N is 0, then set CURRENT to the empty location which ends
592 the previous symbol: RHS[0] (always defined). */
593
594#define YYRHSLOC(Rhs, K) ((Rhs)[K])
595#ifndef YYLLOC_DEFAULT
596# define YYLLOC_DEFAULT(Current, Rhs, N) \
597 do \
598 if (YYID (N)) \
599 { \
600 (Current).first_line = YYRHSLOC (Rhs, 1).first_line; \
601 (Current).first_column = YYRHSLOC (Rhs, 1).first_column; \
602 (Current).last_line = YYRHSLOC (Rhs, N).last_line; \
603 (Current).last_column = YYRHSLOC (Rhs, N).last_column; \
604 } \
605 else \
606 { \
607 (Current).first_line = (Current).last_line = \
608 YYRHSLOC (Rhs, 0).last_line; \
609 (Current).first_column = (Current).last_column = \
610 YYRHSLOC (Rhs, 0).last_column; \
611 } \
612 while (YYID (0))
613#endif
614
615
616/* YY_LOCATION_PRINT -- Print the location on the stream.
617 This macro was not mandated originally: define only if we know
618 we won't break user code: when these are the locations we know. */
619
620#ifndef YY_LOCATION_PRINT
621# if defined YYLTYPE_IS_TRIVIAL && YYLTYPE_IS_TRIVIAL
622# define YY_LOCATION_PRINT(File, Loc) \
623 fprintf (File, "%d.%d-%d.%d", \
624 (Loc).first_line, (Loc).first_column, \
625 (Loc).last_line, (Loc).last_column)
626# else
627# define YY_LOCATION_PRINT(File, Loc) ((void) 0)
628# endif
629#endif
630
631
632/* YYLEX -- calling `yylex' with the right arguments. */
633
634#ifdef YYLEX_PARAM
635# define YYLEX yylex (YYLEX_PARAM)
636#else
637# define YYLEX yylex ()
638#endif
639
640/* Enable debugging if requested. */
641#if YYDEBUG
642
643# ifndef YYFPRINTF
644# include <stdio.h> /* INFRINGES ON USER NAME SPACE */
645# define YYFPRINTF fprintf
646# endif
647
648# define YYDPRINTF(Args) \
649do { \
650 if (yydebug) \
651 YYFPRINTF Args; \
652} while (YYID (0))
653
654# define YY_SYMBOL_PRINT(Title, Type, Value, Location) \
655do { \
656 if (yydebug) \
657 { \
658 YYFPRINTF (stderr, "%s ", Title); \
659 yy_symbol_print (stderr, \
660 Type, Value, format, name); \
661 YYFPRINTF (stderr, "\n"); \
662 } \
663} while (YYID (0))
664
665
666/*--------------------------------.
667| Print this symbol on YYOUTPUT. |
668`--------------------------------*/
669
670/*ARGSUSED*/
671#if (defined __STDC__ || defined __C99__FUNC__ \
672 || defined __cplusplus || defined _MSC_VER)
673static void
674yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep, struct list_head *format, char *name)
675#else
676static void
677yy_symbol_value_print (yyoutput, yytype, yyvaluep, format, name)
678 FILE *yyoutput;
679 int yytype;
680 YYSTYPE const * const yyvaluep;
681 struct list_head *format;
682 char *name;
683#endif
684{
685 if (!yyvaluep)
686 return;
687 YYUSE (format);
688 YYUSE (name);
689# ifdef YYPRINT
690 if (yytype < YYNTOKENS)
691 YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep);
692# else
693 YYUSE (yyoutput);
694# endif
695 switch (yytype)
696 {
697 default:
698 break;
699 }
700}
701
702
703/*--------------------------------.
704| Print this symbol on YYOUTPUT. |
705`--------------------------------*/
706
707#if (defined __STDC__ || defined __C99__FUNC__ \
708 || defined __cplusplus || defined _MSC_VER)
709static void
710yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep, struct list_head *format, char *name)
711#else
712static void
713yy_symbol_print (yyoutput, yytype, yyvaluep, format, name)
714 FILE *yyoutput;
715 int yytype;
716 YYSTYPE const * const yyvaluep;
717 struct list_head *format;
718 char *name;
719#endif
720{
721 if (yytype < YYNTOKENS)
722 YYFPRINTF (yyoutput, "token %s (", yytname[yytype]);
723 else
724 YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]);
725
726 yy_symbol_value_print (yyoutput, yytype, yyvaluep, format, name);
727 YYFPRINTF (yyoutput, ")");
728}
729
730/*------------------------------------------------------------------.
731| yy_stack_print -- Print the state stack from its BOTTOM up to its |
732| TOP (included). |
733`------------------------------------------------------------------*/
734
735#if (defined __STDC__ || defined __C99__FUNC__ \
736 || defined __cplusplus || defined _MSC_VER)
737static void
738yy_stack_print (yytype_int16 *yybottom, yytype_int16 *yytop)
739#else
740static void
741yy_stack_print (yybottom, yytop)
742 yytype_int16 *yybottom;
743 yytype_int16 *yytop;
744#endif
745{
746 YYFPRINTF (stderr, "Stack now");
747 for (; yybottom <= yytop; yybottom++)
748 {
749 int yybot = *yybottom;
750 YYFPRINTF (stderr, " %d", yybot);
751 }
752 YYFPRINTF (stderr, "\n");
753}
754
755# define YY_STACK_PRINT(Bottom, Top) \
756do { \
757 if (yydebug) \
758 yy_stack_print ((Bottom), (Top)); \
759} while (YYID (0))
760
761
762/*------------------------------------------------.
763| Report that the YYRULE is going to be reduced. |
764`------------------------------------------------*/
765
766#if (defined __STDC__ || defined __C99__FUNC__ \
767 || defined __cplusplus || defined _MSC_VER)
768static void
769yy_reduce_print (YYSTYPE *yyvsp, int yyrule, struct list_head *format, char *name)
770#else
771static void
772yy_reduce_print (yyvsp, yyrule, format, name)
773 YYSTYPE *yyvsp;
774 int yyrule;
775 struct list_head *format;
776 char *name;
777#endif
778{
779 int yynrhs = yyr2[yyrule];
780 int yyi;
781 unsigned long int yylno = yyrline[yyrule];
782 YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n",
783 yyrule - 1, yylno);
784 /* The symbols being reduced. */
785 for (yyi = 0; yyi < yynrhs; yyi++)
786 {
787 YYFPRINTF (stderr, " $%d = ", yyi + 1);
788 yy_symbol_print (stderr, yyrhs[yyprhs[yyrule] + yyi],
789 &(yyvsp[(yyi + 1) - (yynrhs)])
790 , format, name);
791 YYFPRINTF (stderr, "\n");
792 }
793}
794
795# define YY_REDUCE_PRINT(Rule) \
796do { \
797 if (yydebug) \
798 yy_reduce_print (yyvsp, Rule, format, name); \
799} while (YYID (0))
800
801/* Nonzero means print parse trace. It is left uninitialized so that
802 multiple parsers can coexist. */
803int yydebug;
804#else /* !YYDEBUG */
805# define YYDPRINTF(Args)
806# define YY_SYMBOL_PRINT(Title, Type, Value, Location)
807# define YY_STACK_PRINT(Bottom, Top)
808# define YY_REDUCE_PRINT(Rule)
809#endif /* !YYDEBUG */
810
811
812/* YYINITDEPTH -- initial size of the parser's stacks. */
813#ifndef YYINITDEPTH
814# define YYINITDEPTH 200
815#endif
816
817/* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
818 if the built-in stack extension method is used).
819
820 Do not make this value too large; the results are undefined if
821 YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH)
822 evaluated with infinite-precision integer arithmetic. */
823
824#ifndef YYMAXDEPTH
825# define YYMAXDEPTH 10000
826#endif
827
828
829
830#if YYERROR_VERBOSE
831
832# ifndef yystrlen
833# if defined __GLIBC__ && defined _STRING_H
834# define yystrlen strlen
835# else
836/* Return the length of YYSTR. */
837#if (defined __STDC__ || defined __C99__FUNC__ \
838 || defined __cplusplus || defined _MSC_VER)
839static YYSIZE_T
840yystrlen (const char *yystr)
841#else
842static YYSIZE_T
843yystrlen (yystr)
844 const char *yystr;
845#endif
846{
847 YYSIZE_T yylen;
848 for (yylen = 0; yystr[yylen]; yylen++)
849 continue;
850 return yylen;
851}
852# endif
853# endif
854
855# ifndef yystpcpy
856# if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE
857# define yystpcpy stpcpy
858# else
859/* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
860 YYDEST. */
861#if (defined __STDC__ || defined __C99__FUNC__ \
862 || defined __cplusplus || defined _MSC_VER)
863static char *
864yystpcpy (char *yydest, const char *yysrc)
865#else
866static char *
867yystpcpy (yydest, yysrc)
868 char *yydest;
869 const char *yysrc;
870#endif
871{
872 char *yyd = yydest;
873 const char *yys = yysrc;
874
875 while ((*yyd++ = *yys++) != '\0')
876 continue;
877
878 return yyd - 1;
879}
880# endif
881# endif
882
883# ifndef yytnamerr
884/* Copy to YYRES the contents of YYSTR after stripping away unnecessary
885 quotes and backslashes, so that it's suitable for yyerror. The
886 heuristic is that double-quoting is unnecessary unless the string
887 contains an apostrophe, a comma, or backslash (other than
888 backslash-backslash). YYSTR is taken from yytname. If YYRES is
889 null, do not copy; instead, return the length of what the result
890 would have been. */
891static YYSIZE_T
892yytnamerr (char *yyres, const char *yystr)
893{
894 if (*yystr == '"')
895 {
896 YYSIZE_T yyn = 0;
897 char const *yyp = yystr;
898
899 for (;;)
900 switch (*++yyp)
901 {
902 case '\'':
903 case ',':
904 goto do_not_strip_quotes;
905
906 case '\\':
907 if (*++yyp != '\\')
908 goto do_not_strip_quotes;
909 /* Fall through. */
910 default:
911 if (yyres)
912 yyres[yyn] = *yyp;
913 yyn++;
914 break;
915
916 case '"':
917 if (yyres)
918 yyres[yyn] = '\0';
919 return yyn;
920 }
921 do_not_strip_quotes: ;
922 }
923
924 if (! yyres)
925 return yystrlen (yystr);
926
927 return yystpcpy (yyres, yystr) - yyres;
928}
929# endif
930
931/* Copy into YYRESULT an error message about the unexpected token
932 YYCHAR while in state YYSTATE. Return the number of bytes copied,
933 including the terminating null byte. If YYRESULT is null, do not
934 copy anything; just return the number of bytes that would be
935 copied. As a special case, return 0 if an ordinary "syntax error"
936 message will do. Return YYSIZE_MAXIMUM if overflow occurs during
937 size calculation. */
938static YYSIZE_T
939yysyntax_error (char *yyresult, int yystate, int yychar)
940{
941 int yyn = yypact[yystate];
942
943 if (! (YYPACT_NINF < yyn && yyn <= YYLAST))
944 return 0;
945 else
946 {
947 int yytype = YYTRANSLATE (yychar);
948 YYSIZE_T yysize0 = yytnamerr (0, yytname[yytype]);
949 YYSIZE_T yysize = yysize0;
950 YYSIZE_T yysize1;
951 int yysize_overflow = 0;
952 enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 };
953 char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM];
954 int yyx;
955
956# if 0
957 /* This is so xgettext sees the translatable formats that are
958 constructed on the fly. */
959 YY_("syntax error, unexpected %s");
960 YY_("syntax error, unexpected %s, expecting %s");
961 YY_("syntax error, unexpected %s, expecting %s or %s");
962 YY_("syntax error, unexpected %s, expecting %s or %s or %s");
963 YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s");
964# endif
965 char *yyfmt;
966 char const *yyf;
967 static char const yyunexpected[] = "syntax error, unexpected %s";
968 static char const yyexpecting[] = ", expecting %s";
969 static char const yyor[] = " or %s";
970 char yyformat[sizeof yyunexpected
971 + sizeof yyexpecting - 1
972 + ((YYERROR_VERBOSE_ARGS_MAXIMUM - 2)
973 * (sizeof yyor - 1))];
974 char const *yyprefix = yyexpecting;
975
976 /* Start YYX at -YYN if negative to avoid negative indexes in
977 YYCHECK. */
978 int yyxbegin = yyn < 0 ? -yyn : 0;
979
980 /* Stay within bounds of both yycheck and yytname. */
981 int yychecklim = YYLAST - yyn + 1;
982 int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS;
983 int yycount = 1;
984
985 yyarg[0] = yytname[yytype];
986 yyfmt = yystpcpy (yyformat, yyunexpected);
987
988 for (yyx = yyxbegin; yyx < yyxend; ++yyx)
989 if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR)
990 {
991 if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM)
992 {
993 yycount = 1;
994 yysize = yysize0;
995 yyformat[sizeof yyunexpected - 1] = '\0';
996 break;
997 }
998 yyarg[yycount++] = yytname[yyx];
999 yysize1 = yysize + yytnamerr (0, yytname[yyx]);
1000 yysize_overflow |= (yysize1 < yysize);
1001 yysize = yysize1;
1002 yyfmt = yystpcpy (yyfmt, yyprefix);
1003 yyprefix = yyor;
1004 }
1005
1006 yyf = YY_(yyformat);
1007 yysize1 = yysize + yystrlen (yyf);
1008 yysize_overflow |= (yysize1 < yysize);
1009 yysize = yysize1;
1010
1011 if (yysize_overflow)
1012 return YYSIZE_MAXIMUM;
1013
1014 if (yyresult)
1015 {
1016 /* Avoid sprintf, as that infringes on the user's name space.
1017 Don't have undefined behavior even if the translation
1018 produced a string with the wrong number of "%s"s. */
1019 char *yyp = yyresult;
1020 int yyi = 0;
1021 while ((*yyp = *yyf) != '\0')
1022 {
1023 if (*yyp == '%' && yyf[1] == 's' && yyi < yycount)
1024 {
1025 yyp += yytnamerr (yyp, yyarg[yyi++]);
1026 yyf += 2;
1027 }
1028 else
1029 {
1030 yyp++;
1031 yyf++;
1032 }
1033 }
1034 }
1035 return yysize;
1036 }
1037}
1038#endif /* YYERROR_VERBOSE */
1039
1040
1041/*-----------------------------------------------.
1042| Release the memory associated to this symbol. |
1043`-----------------------------------------------*/
1044
1045/*ARGSUSED*/
1046#if (defined __STDC__ || defined __C99__FUNC__ \
1047 || defined __cplusplus || defined _MSC_VER)
1048static void
1049yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep, struct list_head *format, char *name)
1050#else
1051static void
1052yydestruct (yymsg, yytype, yyvaluep, format, name)
1053 const char *yymsg;
1054 int yytype;
1055 YYSTYPE *yyvaluep;
1056 struct list_head *format;
1057 char *name;
1058#endif
1059{
1060 YYUSE (yyvaluep);
1061 YYUSE (format);
1062 YYUSE (name);
1063
1064 if (!yymsg)
1065 yymsg = "Deleting";
1066 YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp);
1067
1068 switch (yytype)
1069 {
1070
1071 default:
1072 break;
1073 }
1074}
1075
1076/* Prevent warnings from -Wmissing-prototypes. */
1077#ifdef YYPARSE_PARAM
1078#if defined __STDC__ || defined __cplusplus
1079int yyparse (void *YYPARSE_PARAM);
1080#else
1081int yyparse ();
1082#endif
1083#else /* ! YYPARSE_PARAM */
1084#if defined __STDC__ || defined __cplusplus
1085int yyparse (struct list_head *format, char *name);
1086#else
1087int yyparse ();
1088#endif
1089#endif /* ! YYPARSE_PARAM */
1090
1091
1092/* The lookahead symbol. */
1093int yychar;
1094
1095/* The semantic value of the lookahead symbol. */
1096YYSTYPE yylval;
1097
1098/* Number of syntax errors so far. */
1099int yynerrs;
1100
1101
1102
1103/*-------------------------.
1104| yyparse or yypush_parse. |
1105`-------------------------*/
1106
1107#ifdef YYPARSE_PARAM
1108#if (defined __STDC__ || defined __C99__FUNC__ \
1109 || defined __cplusplus || defined _MSC_VER)
1110int
1111yyparse (void *YYPARSE_PARAM)
1112#else
1113int
1114yyparse (YYPARSE_PARAM)
1115 void *YYPARSE_PARAM;
1116#endif
1117#else /* ! YYPARSE_PARAM */
1118#if (defined __STDC__ || defined __C99__FUNC__ \
1119 || defined __cplusplus || defined _MSC_VER)
1120int
1121yyparse (struct list_head *format, char *name)
1122#else
1123int
1124yyparse (format, name)
1125 struct list_head *format;
1126 char *name;
1127#endif
1128#endif
1129{
1130
1131
1132 int yystate;
1133 /* Number of tokens to shift before error messages enabled. */
1134 int yyerrstatus;
1135
1136 /* The stacks and their tools:
1137 `yyss': related to states.
1138 `yyvs': related to semantic values.
1139
1140 Refer to the stacks thru separate pointers, to allow yyoverflow
1141 to reallocate them elsewhere. */
1142
1143 /* The state stack. */
1144 yytype_int16 yyssa[YYINITDEPTH];
1145 yytype_int16 *yyss;
1146 yytype_int16 *yyssp;
1147
1148 /* The semantic value stack. */
1149 YYSTYPE yyvsa[YYINITDEPTH];
1150 YYSTYPE *yyvs;
1151 YYSTYPE *yyvsp;
1152
1153 YYSIZE_T yystacksize;
1154
1155 int yyn;
1156 int yyresult;
1157 /* Lookahead token as an internal (translated) token number. */
1158 int yytoken;
1159 /* The variables used to return semantic value and location from the
1160 action routines. */
1161 YYSTYPE yyval;
1162
1163#if YYERROR_VERBOSE
1164 /* Buffer for error messages, and its allocated size. */
1165 char yymsgbuf[128];
1166 char *yymsg = yymsgbuf;
1167 YYSIZE_T yymsg_alloc = sizeof yymsgbuf;
1168#endif
1169
1170#define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N))
1171
1172 /* The number of symbols on the RHS of the reduced rule.
1173 Keep to zero when no symbol should be popped. */
1174 int yylen = 0;
1175
1176 yytoken = 0;
1177 yyss = yyssa;
1178 yyvs = yyvsa;
1179 yystacksize = YYINITDEPTH;
1180
1181 YYDPRINTF ((stderr, "Starting parse\n"));
1182
1183 yystate = 0;
1184 yyerrstatus = 0;
1185 yynerrs = 0;
1186 yychar = YYEMPTY; /* Cause a token to be read. */
1187
1188 /* Initialize stack pointers.
1189 Waste one element of value and location stack
1190 so that they stay on the same level as the state stack.
1191 The wasted elements are never initialized. */
1192 yyssp = yyss;
1193 yyvsp = yyvs;
1194
1195 goto yysetstate;
1196
1197/*------------------------------------------------------------.
1198| yynewstate -- Push a new state, which is found in yystate. |
1199`------------------------------------------------------------*/
1200 yynewstate:
1201 /* In all cases, when you get here, the value and location stacks
1202 have just been pushed. So pushing a state here evens the stacks. */
1203 yyssp++;
1204
1205 yysetstate:
1206 *yyssp = yystate;
1207
1208 if (yyss + yystacksize - 1 <= yyssp)
1209 {
1210 /* Get the current used size of the three stacks, in elements. */
1211 YYSIZE_T yysize = yyssp - yyss + 1;
1212
1213#ifdef yyoverflow
1214 {
1215 /* Give user a chance to reallocate the stack. Use copies of
1216 these so that the &'s don't force the real ones into
1217 memory. */
1218 YYSTYPE *yyvs1 = yyvs;
1219 yytype_int16 *yyss1 = yyss;
1220
1221 /* Each stack pointer address is followed by the size of the
1222 data in use in that stack, in bytes. This used to be a
1223 conditional around just the two extra args, but that might
1224 be undefined if yyoverflow is a macro. */
1225 yyoverflow (YY_("memory exhausted"),
1226 &yyss1, yysize * sizeof (*yyssp),
1227 &yyvs1, yysize * sizeof (*yyvsp),
1228 &yystacksize);
1229
1230 yyss = yyss1;
1231 yyvs = yyvs1;
1232 }
1233#else /* no yyoverflow */
1234# ifndef YYSTACK_RELOCATE
1235 goto yyexhaustedlab;
1236# else
1237 /* Extend the stack our own way. */
1238 if (YYMAXDEPTH <= yystacksize)
1239 goto yyexhaustedlab;
1240 yystacksize *= 2;
1241 if (YYMAXDEPTH < yystacksize)
1242 yystacksize = YYMAXDEPTH;
1243
1244 {
1245 yytype_int16 *yyss1 = yyss;
1246 union yyalloc *yyptr =
1247 (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
1248 if (! yyptr)
1249 goto yyexhaustedlab;
1250 YYSTACK_RELOCATE (yyss_alloc, yyss);
1251 YYSTACK_RELOCATE (yyvs_alloc, yyvs);
1252# undef YYSTACK_RELOCATE
1253 if (yyss1 != yyssa)
1254 YYSTACK_FREE (yyss1);
1255 }
1256# endif
1257#endif /* no yyoverflow */
1258
1259 yyssp = yyss + yysize - 1;
1260 yyvsp = yyvs + yysize - 1;
1261
1262 YYDPRINTF ((stderr, "Stack size increased to %lu\n",
1263 (unsigned long int) yystacksize));
1264
1265 if (yyss + yystacksize - 1 <= yyssp)
1266 YYABORT;
1267 }
1268
1269 YYDPRINTF ((stderr, "Entering state %d\n", yystate));
1270
1271 if (yystate == YYFINAL)
1272 YYACCEPT;
1273
1274 goto yybackup;
1275
1276/*-----------.
1277| yybackup. |
1278`-----------*/
1279yybackup:
1280
1281 /* Do appropriate processing given the current state. Read a
1282 lookahead token if we need one and don't already have one. */
1283
1284 /* First try to decide what to do without reference to lookahead token. */
1285 yyn = yypact[yystate];
1286 if (yyn == YYPACT_NINF)
1287 goto yydefault;
1288
1289 /* Not known => get a lookahead token if don't already have one. */
1290
1291 /* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol. */
1292 if (yychar == YYEMPTY)
1293 {
1294 YYDPRINTF ((stderr, "Reading a token: "));
1295 yychar = YYLEX;
1296 }
1297
1298 if (yychar <= YYEOF)
1299 {
1300 yychar = yytoken = YYEOF;
1301 YYDPRINTF ((stderr, "Now at end of input.\n"));
1302 }
1303 else
1304 {
1305 yytoken = YYTRANSLATE (yychar);
1306 YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc);
1307 }
1308
1309 /* If the proper action on seeing token YYTOKEN is to reduce or to
1310 detect an error, take that action. */
1311 yyn += yytoken;
1312 if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken)
1313 goto yydefault;
1314 yyn = yytable[yyn];
1315 if (yyn <= 0)
1316 {
1317 if (yyn == 0 || yyn == YYTABLE_NINF)
1318 goto yyerrlab;
1319 yyn = -yyn;
1320 goto yyreduce;
1321 }
1322
1323 /* Count tokens shifted since error; after three, turn off error
1324 status. */
1325 if (yyerrstatus)
1326 yyerrstatus--;
1327
1328 /* Shift the lookahead token. */
1329 YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc);
1330
1331 /* Discard the shifted token. */
1332 yychar = YYEMPTY;
1333
1334 yystate = yyn;
1335 *++yyvsp = yylval;
1336
1337 goto yynewstate;
1338
1339
1340/*-----------------------------------------------------------.
1341| yydefault -- do the default action for the current state. |
1342`-----------------------------------------------------------*/
1343yydefault:
1344 yyn = yydefact[yystate];
1345 if (yyn == 0)
1346 goto yyerrlab;
1347 goto yyreduce;
1348
1349
1350/*-----------------------------.
1351| yyreduce -- Do a reduction. |
1352`-----------------------------*/
1353yyreduce:
1354 /* yyn is the number of a rule to reduce with. */
1355 yylen = yyr2[yyn];
1356
1357 /* If YYLEN is nonzero, implement the default value of the action:
1358 `$$ = $1'.
1359
1360 Otherwise, the following line sets YYVAL to garbage.
1361 This behavior is undocumented and Bison
1362 users should not rely upon it. Assigning to YYVAL
1363 unconditionally makes the parser a bit smaller, and it avoids a
1364 GCC warning that YYVAL may be used uninitialized. */
1365 yyval = yyvsp[1-yylen];
1366
1367
1368 YY_REDUCE_PRINT (yyn);
1369 switch (yyn)
1370 {
1371 case 4:
1372
1373/* Line 1464 of yacc.c */
1374#line 45 "util/pmu.y"
1375 {
1376 ABORT_ON(perf_pmu__new_format(format, name,
1377 PERF_PMU_FORMAT_VALUE_CONFIG,
1378 (yyvsp[(3) - (3)].bits)));
1379;}
1380 break;
1381
1382 case 5:
1383
1384/* Line 1464 of yacc.c */
1385#line 52 "util/pmu.y"
1386 {
1387 ABORT_ON(perf_pmu__new_format(format, name,
1388 PERF_PMU_FORMAT_VALUE_CONFIG1,
1389 (yyvsp[(3) - (3)].bits)));
1390;}
1391 break;
1392
1393 case 6:
1394
1395/* Line 1464 of yacc.c */
1396#line 59 "util/pmu.y"
1397 {
1398 ABORT_ON(perf_pmu__new_format(format, name,
1399 PERF_PMU_FORMAT_VALUE_CONFIG2,
1400 (yyvsp[(3) - (3)].bits)));
1401;}
1402 break;
1403
1404 case 7:
1405
1406/* Line 1464 of yacc.c */
1407#line 67 "util/pmu.y"
1408 {
1409 bitmap_or((yyval.bits), (yyvsp[(1) - (3)].bits), (yyvsp[(3) - (3)].bits), 64);
1410;}
1411 break;
1412
1413 case 8:
1414
1415/* Line 1464 of yacc.c */
1416#line 72 "util/pmu.y"
1417 {
1418 memcpy((yyval.bits), (yyvsp[(1) - (1)].bits), sizeof((yyvsp[(1) - (1)].bits)));
1419;}
1420 break;
1421
1422 case 9:
1423
1424/* Line 1464 of yacc.c */
1425#line 78 "util/pmu.y"
1426 {
1427 perf_pmu__set_format((yyval.bits), (yyvsp[(1) - (3)].num), (yyvsp[(3) - (3)].num));
1428;}
1429 break;
1430
1431 case 10:
1432
1433/* Line 1464 of yacc.c */
1434#line 83 "util/pmu.y"
1435 {
1436 perf_pmu__set_format((yyval.bits), (yyvsp[(1) - (1)].num), 0);
1437;}
1438 break;
1439
1440
1441
1442/* Line 1464 of yacc.c */
1443#line 1444 "util/pmu-bison.c"
1444 default: break;
1445 }
1446 YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc);
1447
1448 YYPOPSTACK (yylen);
1449 yylen = 0;
1450 YY_STACK_PRINT (yyss, yyssp);
1451
1452 *++yyvsp = yyval;
1453
1454 /* Now `shift' the result of the reduction. Determine what state
1455 that goes to, based on the state we popped back to and the rule
1456 number reduced by. */
1457
1458 yyn = yyr1[yyn];
1459
1460 yystate = yypgoto[yyn - YYNTOKENS] + *yyssp;
1461 if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp)
1462 yystate = yytable[yystate];
1463 else
1464 yystate = yydefgoto[yyn - YYNTOKENS];
1465
1466 goto yynewstate;
1467
1468
1469/*------------------------------------.
1470| yyerrlab -- here on detecting error |
1471`------------------------------------*/
1472yyerrlab:
1473 /* If not already recovering from an error, report this error. */
1474 if (!yyerrstatus)
1475 {
1476 ++yynerrs;
1477#if ! YYERROR_VERBOSE
1478 yyerror (format, name, YY_("syntax error"));
1479#else
1480 {
1481 YYSIZE_T yysize = yysyntax_error (0, yystate, yychar);
1482 if (yymsg_alloc < yysize && yymsg_alloc < YYSTACK_ALLOC_MAXIMUM)
1483 {
1484 YYSIZE_T yyalloc = 2 * yysize;
1485 if (! (yysize <= yyalloc && yyalloc <= YYSTACK_ALLOC_MAXIMUM))
1486 yyalloc = YYSTACK_ALLOC_MAXIMUM;
1487 if (yymsg != yymsgbuf)
1488 YYSTACK_FREE (yymsg);
1489 yymsg = (char *) YYSTACK_ALLOC (yyalloc);
1490 if (yymsg)
1491 yymsg_alloc = yyalloc;
1492 else
1493 {
1494 yymsg = yymsgbuf;
1495 yymsg_alloc = sizeof yymsgbuf;
1496 }
1497 }
1498
1499 if (0 < yysize && yysize <= yymsg_alloc)
1500 {
1501 (void) yysyntax_error (yymsg, yystate, yychar);
1502 yyerror (format, name, yymsg);
1503 }
1504 else
1505 {
1506 yyerror (format, name, YY_("syntax error"));
1507 if (yysize != 0)
1508 goto yyexhaustedlab;
1509 }
1510 }
1511#endif
1512 }
1513
1514
1515
1516 if (yyerrstatus == 3)
1517 {
1518 /* If just tried and failed to reuse lookahead token after an
1519 error, discard it. */
1520
1521 if (yychar <= YYEOF)
1522 {
1523 /* Return failure if at end of input. */
1524 if (yychar == YYEOF)
1525 YYABORT;
1526 }
1527 else
1528 {
1529 yydestruct ("Error: discarding",
1530 yytoken, &yylval, format, name);
1531 yychar = YYEMPTY;
1532 }
1533 }
1534
1535 /* Else will try to reuse lookahead token after shifting the error
1536 token. */
1537 goto yyerrlab1;
1538
1539
1540/*---------------------------------------------------.
1541| yyerrorlab -- error raised explicitly by YYERROR. |
1542`---------------------------------------------------*/
1543yyerrorlab:
1544
1545 /* Pacify compilers like GCC when the user code never invokes
1546 YYERROR and the label yyerrorlab therefore never appears in user
1547 code. */
1548 if (/*CONSTCOND*/ 0)
1549 goto yyerrorlab;
1550
1551 /* Do not reclaim the symbols of the rule which action triggered
1552 this YYERROR. */
1553 YYPOPSTACK (yylen);
1554 yylen = 0;
1555 YY_STACK_PRINT (yyss, yyssp);
1556 yystate = *yyssp;
1557 goto yyerrlab1;
1558
1559
1560/*-------------------------------------------------------------.
1561| yyerrlab1 -- common code for both syntax error and YYERROR. |
1562`-------------------------------------------------------------*/
1563yyerrlab1:
1564 yyerrstatus = 3; /* Each real token shifted decrements this. */
1565
1566 for (;;)
1567 {
1568 yyn = yypact[yystate];
1569 if (yyn != YYPACT_NINF)
1570 {
1571 yyn += YYTERROR;
1572 if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR)
1573 {
1574 yyn = yytable[yyn];
1575 if (0 < yyn)
1576 break;
1577 }
1578 }
1579
1580 /* Pop the current state because it cannot handle the error token. */
1581 if (yyssp == yyss)
1582 YYABORT;
1583
1584
1585 yydestruct ("Error: popping",
1586 yystos[yystate], yyvsp, format, name);
1587 YYPOPSTACK (1);
1588 yystate = *yyssp;
1589 YY_STACK_PRINT (yyss, yyssp);
1590 }
1591
1592 *++yyvsp = yylval;
1593
1594
1595 /* Shift the error token. */
1596 YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp);
1597
1598 yystate = yyn;
1599 goto yynewstate;
1600
1601
1602/*-------------------------------------.
1603| yyacceptlab -- YYACCEPT comes here. |
1604`-------------------------------------*/
1605yyacceptlab:
1606 yyresult = 0;
1607 goto yyreturn;
1608
1609/*-----------------------------------.
1610| yyabortlab -- YYABORT comes here. |
1611`-----------------------------------*/
1612yyabortlab:
1613 yyresult = 1;
1614 goto yyreturn;
1615
1616#if !defined(yyoverflow) || YYERROR_VERBOSE
1617/*-------------------------------------------------.
1618| yyexhaustedlab -- memory exhaustion comes here. |
1619`-------------------------------------------------*/
1620yyexhaustedlab:
1621 yyerror (format, name, YY_("memory exhausted"));
1622 yyresult = 2;
1623 /* Fall through. */
1624#endif
1625
1626yyreturn:
1627 if (yychar != YYEMPTY)
1628 yydestruct ("Cleanup: discarding lookahead",
1629 yytoken, &yylval, format, name);
1630 /* Do not reclaim the symbols of the rule which action triggered
1631 this YYABORT or YYACCEPT. */
1632 YYPOPSTACK (yylen);
1633 YY_STACK_PRINT (yyss, yyssp);
1634 while (yyssp != yyss)
1635 {
1636 yydestruct ("Cleanup: popping",
1637 yystos[*yyssp], yyvsp, format, name);
1638 YYPOPSTACK (1);
1639 }
1640#ifndef yyoverflow
1641 if (yyss != yyssa)
1642 YYSTACK_FREE (yyss);
1643#endif
1644#if YYERROR_VERBOSE
1645 if (yymsg != yymsgbuf)
1646 YYSTACK_FREE (yymsg);
1647#endif
1648 /* Make sure YYID is used. */
1649 return YYID (yyresult);
1650}
1651
1652
1653
1654/* Line 1684 of yacc.c */
1655#line 87 "util/pmu.y"
1656
1657
1658void perf_pmu_error(struct list_head *list __used,
1659 char *name __used,
1660 char const *msg __used)
1661{
1662}
1663
diff --git a/tools/perf/util/pmu-bison.h b/tools/perf/util/pmu-bison.h
new file mode 100644
index 000000000000..54f4a0d7829b
--- /dev/null
+++ b/tools/perf/util/pmu-bison.h
@@ -0,0 +1,73 @@
1/* A Bison parser, made by GNU Bison 2.4.3. */
2
3/* Skeleton interface for Bison's Yacc-like parsers in C
4
5 Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006,
6 2009, 2010 Free Software Foundation, Inc.
7
8 This program is free software: you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation, either version 3 of the License, or
11 (at your option) any later version.
12
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
17
18 You should have received a copy of the GNU General Public License
19 along with this program. If not, see <http://www.gnu.org/licenses/>. */
20
21/* As a special exception, you may create a larger work that contains
22 part or all of the Bison parser skeleton and distribute that work
23 under terms of your choice, so long as that work isn't itself a
24 parser generator using the skeleton or a modified version thereof
25 as a parser skeleton. Alternatively, if you modify or redistribute
26 the parser skeleton itself, you may (at your option) remove this
27 special exception, which will cause the skeleton and the resulting
28 Bison output files to be licensed under the GNU General Public
29 License without this special exception.
30
31 This special exception was added by the Free Software Foundation in
32 version 2.2 of Bison. */
33
34
35/* Tokens. */
36#ifndef YYTOKENTYPE
37# define YYTOKENTYPE
38 /* Put the tokens into the symbol table, so that GDB and other debuggers
39 know about them. */
40 enum yytokentype {
41 PP_CONFIG = 258,
42 PP_CONFIG1 = 259,
43 PP_CONFIG2 = 260,
44 PP_VALUE = 261,
45 PP_ERROR = 262
46 };
47#endif
48
49
50
51#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
52typedef union YYSTYPE
53{
54
55/* Line 1685 of yacc.c */
56#line 31 "util/pmu.y"
57
58 unsigned long num;
59 DECLARE_BITMAP(bits, PERF_PMU_FORMAT_BITS);
60
61
62
63/* Line 1685 of yacc.c */
64#line 65 "util/pmu-bison.h"
65} YYSTYPE;
66# define YYSTYPE_IS_TRIVIAL 1
67# define yystype YYSTYPE /* obsolescent; will be withdrawn */
68# define YYSTYPE_IS_DECLARED 1
69#endif
70
71extern YYSTYPE perf_pmu_lval;
72
73
diff --git a/tools/perf/util/pmu-flex.c b/tools/perf/util/pmu-flex.c
new file mode 100644
index 000000000000..5a8c15966d5c
--- /dev/null
+++ b/tools/perf/util/pmu-flex.c
@@ -0,0 +1,1821 @@
1
2#line 3 "<stdout>"
3
4#define YY_INT_ALIGNED short int
5
6/* A lexical scanner generated by flex */
7
8#define yy_create_buffer perf_pmu__create_buffer
9#define yy_delete_buffer perf_pmu__delete_buffer
10#define yy_flex_debug perf_pmu__flex_debug
11#define yy_init_buffer perf_pmu__init_buffer
12#define yy_flush_buffer perf_pmu__flush_buffer
13#define yy_load_buffer_state perf_pmu__load_buffer_state
14#define yy_switch_to_buffer perf_pmu__switch_to_buffer
15#define yyin perf_pmu_in
16#define yyleng perf_pmu_leng
17#define yylex perf_pmu_lex
18#define yylineno perf_pmu_lineno
19#define yyout perf_pmu_out
20#define yyrestart perf_pmu_restart
21#define yytext perf_pmu_text
22#define yywrap perf_pmu_wrap
23#define yyalloc perf_pmu_alloc
24#define yyrealloc perf_pmu_realloc
25#define yyfree perf_pmu_free
26
27#define FLEX_SCANNER
28#define YY_FLEX_MAJOR_VERSION 2
29#define YY_FLEX_MINOR_VERSION 5
30#define YY_FLEX_SUBMINOR_VERSION 35
31#if YY_FLEX_SUBMINOR_VERSION > 0
32#define FLEX_BETA
33#endif
34
35/* First, we deal with platform-specific or compiler-specific issues. */
36
37/* begin standard C headers. */
38#include <stdio.h>
39#include <string.h>
40#include <errno.h>
41#include <stdlib.h>
42
43/* end standard C headers. */
44
45/* flex integer type definitions */
46
47#ifndef FLEXINT_H
48#define FLEXINT_H
49
50/* C99 systems have <inttypes.h>. Non-C99 systems may or may not. */
51
52#if defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
53
54/* C99 says to define __STDC_LIMIT_MACROS before including stdint.h,
55 * if you want the limit (max/min) macros for int types.
56 */
57#ifndef __STDC_LIMIT_MACROS
58#define __STDC_LIMIT_MACROS 1
59#endif
60
61#include <inttypes.h>
62typedef int8_t flex_int8_t;
63typedef uint8_t flex_uint8_t;
64typedef int16_t flex_int16_t;
65typedef uint16_t flex_uint16_t;
66typedef int32_t flex_int32_t;
67typedef uint32_t flex_uint32_t;
68#else
69typedef signed char flex_int8_t;
70typedef short int flex_int16_t;
71typedef int flex_int32_t;
72typedef unsigned char flex_uint8_t;
73typedef unsigned short int flex_uint16_t;
74typedef unsigned int flex_uint32_t;
75#endif /* ! C99 */
76
77/* Limits of integral types. */
78#ifndef INT8_MIN
79#define INT8_MIN (-128)
80#endif
81#ifndef INT16_MIN
82#define INT16_MIN (-32767-1)
83#endif
84#ifndef INT32_MIN
85#define INT32_MIN (-2147483647-1)
86#endif
87#ifndef INT8_MAX
88#define INT8_MAX (127)
89#endif
90#ifndef INT16_MAX
91#define INT16_MAX (32767)
92#endif
93#ifndef INT32_MAX
94#define INT32_MAX (2147483647)
95#endif
96#ifndef UINT8_MAX
97#define UINT8_MAX (255U)
98#endif
99#ifndef UINT16_MAX
100#define UINT16_MAX (65535U)
101#endif
102#ifndef UINT32_MAX
103#define UINT32_MAX (4294967295U)
104#endif
105
106#endif /* ! FLEXINT_H */
107
108#ifdef __cplusplus
109
110/* The "const" storage-class-modifier is valid. */
111#define YY_USE_CONST
112
113#else /* ! __cplusplus */
114
115/* C99 requires __STDC__ to be defined as 1. */
116#if defined (__STDC__)
117
118#define YY_USE_CONST
119
120#endif /* defined (__STDC__) */
121#endif /* ! __cplusplus */
122
123#ifdef YY_USE_CONST
124#define yyconst const
125#else
126#define yyconst
127#endif
128
129/* Returned upon end-of-file. */
130#define YY_NULL 0
131
132/* Promotes a possibly negative, possibly signed char to an unsigned
133 * integer for use as an array index. If the signed char is negative,
134 * we want to instead treat it as an 8-bit unsigned char, hence the
135 * double cast.
136 */
137#define YY_SC_TO_UI(c) ((unsigned int) (unsigned char) c)
138
139/* Enter a start condition. This macro really ought to take a parameter,
140 * but we do it the disgusting crufty way forced on us by the ()-less
141 * definition of BEGIN.
142 */
143#define BEGIN (yy_start) = 1 + 2 *
144
145/* Translate the current start state into a value that can be later handed
146 * to BEGIN to return to the state. The YYSTATE alias is for lex
147 * compatibility.
148 */
149#define YY_START (((yy_start) - 1) / 2)
150#define YYSTATE YY_START
151
152/* Action number for EOF rule of a given start state. */
153#define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1)
154
155/* Special action meaning "start processing a new file". */
156#define YY_NEW_FILE perf_pmu_restart(perf_pmu_in )
157
158#define YY_END_OF_BUFFER_CHAR 0
159
160/* Size of default input buffer. */
161#ifndef YY_BUF_SIZE
162#define YY_BUF_SIZE 16384
163#endif
164
165/* The state buf must be large enough to hold one state per character in the main buffer.
166 */
167#define YY_STATE_BUF_SIZE ((YY_BUF_SIZE + 2) * sizeof(yy_state_type))
168
169#ifndef YY_TYPEDEF_YY_BUFFER_STATE
170#define YY_TYPEDEF_YY_BUFFER_STATE
171typedef struct yy_buffer_state *YY_BUFFER_STATE;
172#endif
173
174extern int perf_pmu_leng;
175
176extern FILE *perf_pmu_in, *perf_pmu_out;
177
178#define EOB_ACT_CONTINUE_SCAN 0
179#define EOB_ACT_END_OF_FILE 1
180#define EOB_ACT_LAST_MATCH 2
181
182 #define YY_LESS_LINENO(n)
183
184/* Return all but the first "n" matched characters back to the input stream. */
185#define yyless(n) \
186 do \
187 { \
188 /* Undo effects of setting up perf_pmu_text. */ \
189 int yyless_macro_arg = (n); \
190 YY_LESS_LINENO(yyless_macro_arg);\
191 *yy_cp = (yy_hold_char); \
192 YY_RESTORE_YY_MORE_OFFSET \
193 (yy_c_buf_p) = yy_cp = yy_bp + yyless_macro_arg - YY_MORE_ADJ; \
194 YY_DO_BEFORE_ACTION; /* set up perf_pmu_text again */ \
195 } \
196 while ( 0 )
197
198#define unput(c) yyunput( c, (yytext_ptr) )
199
200#ifndef YY_TYPEDEF_YY_SIZE_T
201#define YY_TYPEDEF_YY_SIZE_T
202typedef size_t yy_size_t;
203#endif
204
205#ifndef YY_STRUCT_YY_BUFFER_STATE
206#define YY_STRUCT_YY_BUFFER_STATE
207struct yy_buffer_state
208 {
209 FILE *yy_input_file;
210
211 char *yy_ch_buf; /* input buffer */
212 char *yy_buf_pos; /* current position in input buffer */
213
214 /* Size of input buffer in bytes, not including room for EOB
215 * characters.
216 */
217 yy_size_t yy_buf_size;
218
219 /* Number of characters read into yy_ch_buf, not including EOB
220 * characters.
221 */
222 int yy_n_chars;
223
224 /* Whether we "own" the buffer - i.e., we know we created it,
225 * and can realloc() it to grow it, and should free() it to
226 * delete it.
227 */
228 int yy_is_our_buffer;
229
230 /* Whether this is an "interactive" input source; if so, and
231 * if we're using stdio for input, then we want to use getc()
232 * instead of fread(), to make sure we stop fetching input after
233 * each newline.
234 */
235 int yy_is_interactive;
236
237 /* Whether we're considered to be at the beginning of a line.
238 * If so, '^' rules will be active on the next match, otherwise
239 * not.
240 */
241 int yy_at_bol;
242
243 int yy_bs_lineno; /**< The line count. */
244 int yy_bs_column; /**< The column count. */
245
246 /* Whether to try to fill the input buffer when we reach the
247 * end of it.
248 */
249 int yy_fill_buffer;
250
251 int yy_buffer_status;
252
253#define YY_BUFFER_NEW 0
254#define YY_BUFFER_NORMAL 1
255 /* When an EOF's been seen but there's still some text to process
256 * then we mark the buffer as YY_EOF_PENDING, to indicate that we
257 * shouldn't try reading from the input source any more. We might
258 * still have a bunch of tokens to match, though, because of
259 * possible backing-up.
260 *
261 * When we actually see the EOF, we change the status to "new"
262 * (via perf_pmu_restart()), so that the user can continue scanning by
263 * just pointing perf_pmu_in at a new input file.
264 */
265#define YY_BUFFER_EOF_PENDING 2
266
267 };
268#endif /* !YY_STRUCT_YY_BUFFER_STATE */
269
270/* Stack of input buffers. */
271static size_t yy_buffer_stack_top = 0; /**< index of top of stack. */
272static size_t yy_buffer_stack_max = 0; /**< capacity of stack. */
273static YY_BUFFER_STATE * yy_buffer_stack = 0; /**< Stack as an array. */
274
275/* We provide macros for accessing buffer states in case in the
276 * future we want to put the buffer states in a more general
277 * "scanner state".
278 *
279 * Returns the top of the stack, or NULL.
280 */
281#define YY_CURRENT_BUFFER ( (yy_buffer_stack) \
282 ? (yy_buffer_stack)[(yy_buffer_stack_top)] \
283 : NULL)
284
285/* Same as previous macro, but useful when we know that the buffer stack is not
286 * NULL or when we need an lvalue. For internal use only.
287 */
288#define YY_CURRENT_BUFFER_LVALUE (yy_buffer_stack)[(yy_buffer_stack_top)]
289
290/* yy_hold_char holds the character lost when perf_pmu_text is formed. */
291static char yy_hold_char;
292static int yy_n_chars; /* number of characters read into yy_ch_buf */
293int perf_pmu_leng;
294
295/* Points to current character in buffer. */
296static char *yy_c_buf_p = (char *) 0;
297static int yy_init = 0; /* whether we need to initialize */
298static int yy_start = 0; /* start state number */
299
300/* Flag which is used to allow perf_pmu_wrap()'s to do buffer switches
301 * instead of setting up a fresh perf_pmu_in. A bit of a hack ...
302 */
303static int yy_did_buffer_switch_on_eof;
304
305void perf_pmu_restart (FILE *input_file );
306void perf_pmu__switch_to_buffer (YY_BUFFER_STATE new_buffer );
307YY_BUFFER_STATE perf_pmu__create_buffer (FILE *file,int size );
308void perf_pmu__delete_buffer (YY_BUFFER_STATE b );
309void perf_pmu__flush_buffer (YY_BUFFER_STATE b );
310void perf_pmu_push_buffer_state (YY_BUFFER_STATE new_buffer );
311void perf_pmu_pop_buffer_state (void );
312
313static void perf_pmu_ensure_buffer_stack (void );
314static void perf_pmu__load_buffer_state (void );
315static void perf_pmu__init_buffer (YY_BUFFER_STATE b,FILE *file );
316
317#define YY_FLUSH_BUFFER perf_pmu__flush_buffer(YY_CURRENT_BUFFER )
318
319YY_BUFFER_STATE perf_pmu__scan_buffer (char *base,yy_size_t size );
320YY_BUFFER_STATE perf_pmu__scan_string (yyconst char *yy_str );
321YY_BUFFER_STATE perf_pmu__scan_bytes (yyconst char *bytes,int len );
322
323void *perf_pmu_alloc (yy_size_t );
324void *perf_pmu_realloc (void *,yy_size_t );
325void perf_pmu_free (void * );
326
327#define yy_new_buffer perf_pmu__create_buffer
328
329#define yy_set_interactive(is_interactive) \
330 { \
331 if ( ! YY_CURRENT_BUFFER ){ \
332 perf_pmu_ensure_buffer_stack (); \
333 YY_CURRENT_BUFFER_LVALUE = \
334 perf_pmu__create_buffer(perf_pmu_in,YY_BUF_SIZE ); \
335 } \
336 YY_CURRENT_BUFFER_LVALUE->yy_is_interactive = is_interactive; \
337 }
338
339#define yy_set_bol(at_bol) \
340 { \
341 if ( ! YY_CURRENT_BUFFER ){\
342 perf_pmu_ensure_buffer_stack (); \
343 YY_CURRENT_BUFFER_LVALUE = \
344 perf_pmu__create_buffer(perf_pmu_in,YY_BUF_SIZE ); \
345 } \
346 YY_CURRENT_BUFFER_LVALUE->yy_at_bol = at_bol; \
347 }
348
349#define YY_AT_BOL() (YY_CURRENT_BUFFER_LVALUE->yy_at_bol)
350
351/* Begin user sect3 */
352
353typedef unsigned char YY_CHAR;
354
355FILE *perf_pmu_in = (FILE *) 0, *perf_pmu_out = (FILE *) 0;
356
357typedef int yy_state_type;
358
359extern int perf_pmu_lineno;
360
361int perf_pmu_lineno = 1;
362
363extern char *perf_pmu_text;
364#define yytext_ptr perf_pmu_text
365
366static yy_state_type yy_get_previous_state (void );
367static yy_state_type yy_try_NUL_trans (yy_state_type current_state );
368static int yy_get_next_buffer (void );
369static void yy_fatal_error (yyconst char msg[] );
370
371/* Done after the current pattern has been matched and before the
372 * corresponding action - sets up perf_pmu_text.
373 */
374#define YY_DO_BEFORE_ACTION \
375 (yytext_ptr) = yy_bp; \
376 perf_pmu_leng = (size_t) (yy_cp - yy_bp); \
377 (yy_hold_char) = *yy_cp; \
378 *yy_cp = '\0'; \
379 (yy_c_buf_p) = yy_cp;
380
381#define YY_NUM_RULES 10
382#define YY_END_OF_BUFFER 11
383/* This struct is not used in this scanner,
384 but its presence is necessary. */
385struct yy_trans_info
386 {
387 flex_int32_t yy_verify;
388 flex_int32_t yy_nxt;
389 };
390static yyconst flex_int16_t yy_accept[20] =
391 { 0,
392 0, 0, 11, 8, 9, 7, 5, 1, 6, 8,
393 1, 0, 0, 0, 0, 2, 3, 4, 0
394 } ;
395
396static yyconst flex_int32_t yy_ec[256] =
397 { 0,
398 1, 1, 1, 1, 1, 1, 1, 1, 1, 2,
399 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
400 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
401 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
402 1, 1, 1, 3, 4, 1, 1, 5, 6, 7,
403 5, 5, 5, 5, 5, 5, 5, 8, 1, 1,
404 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
405 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
406 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
407 1, 1, 1, 1, 1, 1, 1, 1, 9, 1,
408
409 1, 10, 11, 1, 12, 1, 1, 1, 1, 13,
410 14, 1, 1, 1, 1, 1, 1, 1, 1, 1,
411 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
412 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
413 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
414 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
415 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
416 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
417 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
418 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
419
420 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
421 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
422 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
423 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
424 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
425 1, 1, 1, 1, 1
426 } ;
427
428static yyconst flex_int32_t yy_meta[15] =
429 { 0,
430 1, 1, 1, 1, 2, 2, 2, 1, 1, 1,
431 1, 1, 1, 1
432 } ;
433
434static yyconst flex_int16_t yy_base[21] =
435 { 0,
436 0, 0, 23, 24, 24, 24, 24, 0, 24, 8,
437 0, 8, 10, 7, 7, 9, 24, 24, 24, 15
438 } ;
439
440static yyconst flex_int16_t yy_def[21] =
441 { 0,
442 19, 1, 19, 19, 19, 19, 19, 20, 19, 19,
443 20, 19, 19, 19, 19, 19, 19, 19, 0, 19
444 } ;
445
446static yyconst flex_int16_t yy_nxt[39] =
447 { 0,
448 4, 5, 6, 7, 8, 8, 8, 9, 10, 4,
449 4, 4, 4, 4, 17, 18, 11, 16, 15, 14,
450 13, 12, 19, 3, 19, 19, 19, 19, 19, 19,
451 19, 19, 19, 19, 19, 19, 19, 19
452 } ;
453
454static yyconst flex_int16_t yy_chk[39] =
455 { 0,
456 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
457 1, 1, 1, 1, 16, 16, 20, 15, 14, 13,
458 12, 10, 3, 19, 19, 19, 19, 19, 19, 19,
459 19, 19, 19, 19, 19, 19, 19, 19
460 } ;
461
462static yy_state_type yy_last_accepting_state;
463static char *yy_last_accepting_cpos;
464
465extern int perf_pmu__flex_debug;
466int perf_pmu__flex_debug = 0;
467
468/* The intent behind this definition is that it'll catch
469 * any uses of REJECT which flex missed.
470 */
471#define REJECT reject_used_but_not_detected
472#define yymore() yymore_used_but_not_detected
473#define YY_MORE_ADJ 0
474#define YY_RESTORE_YY_MORE_OFFSET
475char *perf_pmu_text;
476#line 1 "util/pmu.l"
477#line 4 "util/pmu.l"
478#include <stdlib.h>
479#include <linux/bitops.h>
480#include "pmu.h"
481#include "pmu-bison.h"
482
483static int value(int base)
484{
485 long num;
486
487 errno = 0;
488 num = strtoul(perf_pmu_text, NULL, base);
489 if (errno)
490 return PP_ERROR;
491
492 perf_pmu_lval.num = num;
493 return PP_VALUE;
494}
495
496#line 497 "<stdout>"
497
498#define INITIAL 0
499
500#ifndef YY_NO_UNISTD_H
501/* Special case for "unistd.h", since it is non-ANSI. We include it way
502 * down here because we want the user's section 1 to have been scanned first.
503 * The user has a chance to override it with an option.
504 */
505#include <unistd.h>
506#endif
507
508#ifndef YY_EXTRA_TYPE
509#define YY_EXTRA_TYPE void *
510#endif
511
512static int yy_init_globals (void );
513
514/* Accessor methods to globals.
515 These are made visible to non-reentrant scanners for convenience. */
516
517int perf_pmu_lex_destroy (void );
518
519int perf_pmu_get_debug (void );
520
521void perf_pmu_set_debug (int debug_flag );
522
523YY_EXTRA_TYPE perf_pmu_get_extra (void );
524
525void perf_pmu_set_extra (YY_EXTRA_TYPE user_defined );
526
527FILE *perf_pmu_get_in (void );
528
529void perf_pmu_set_in (FILE * in_str );
530
531FILE *perf_pmu_get_out (void );
532
533void perf_pmu_set_out (FILE * out_str );
534
535int perf_pmu_get_leng (void );
536
537char *perf_pmu_get_text (void );
538
539int perf_pmu_get_lineno (void );
540
541void perf_pmu_set_lineno (int line_number );
542
543/* Macros after this point can all be overridden by user definitions in
544 * section 1.
545 */
546
547#ifndef YY_SKIP_YYWRAP
548#ifdef __cplusplus
549extern "C" int perf_pmu_wrap (void );
550#else
551extern int perf_pmu_wrap (void );
552#endif
553#endif
554
555 static void yyunput (int c,char *buf_ptr );
556
557#ifndef yytext_ptr
558static void yy_flex_strncpy (char *,yyconst char *,int );
559#endif
560
561#ifdef YY_NEED_STRLEN
562static int yy_flex_strlen (yyconst char * );
563#endif
564
565#ifndef YY_NO_INPUT
566
567#ifdef __cplusplus
568static int yyinput (void );
569#else
570static int input (void );
571#endif
572
573#endif
574
575/* Amount of stuff to slurp up with each read. */
576#ifndef YY_READ_BUF_SIZE
577#define YY_READ_BUF_SIZE 8192
578#endif
579
580/* Copy whatever the last rule matched to the standard output. */
581#ifndef ECHO
582/* This used to be an fputs(), but since the string might contain NUL's,
583 * we now use fwrite().
584 */
585#define ECHO do { if (fwrite( perf_pmu_text, perf_pmu_leng, 1, perf_pmu_out )) {} } while (0)
586#endif
587
588/* Gets input and stuffs it into "buf". number of characters read, or YY_NULL,
589 * is returned in "result".
590 */
591#ifndef YY_INPUT
592#define YY_INPUT(buf,result,max_size) \
593 if ( YY_CURRENT_BUFFER_LVALUE->yy_is_interactive ) \
594 { \
595 int c = '*'; \
596 unsigned n; \
597 for ( n = 0; n < max_size && \
598 (c = getc( perf_pmu_in )) != EOF && c != '\n'; ++n ) \
599 buf[n] = (char) c; \
600 if ( c == '\n' ) \
601 buf[n++] = (char) c; \
602 if ( c == EOF && ferror( perf_pmu_in ) ) \
603 YY_FATAL_ERROR( "input in flex scanner failed" ); \
604 result = n; \
605 } \
606 else \
607 { \
608 errno=0; \
609 while ( (result = fread(buf, 1, max_size, perf_pmu_in))==0 && ferror(perf_pmu_in)) \
610 { \
611 if( errno != EINTR) \
612 { \
613 YY_FATAL_ERROR( "input in flex scanner failed" ); \
614 break; \
615 } \
616 errno=0; \
617 clearerr(perf_pmu_in); \
618 } \
619 }\
620\
621
622#endif
623
624/* No semi-colon after return; correct usage is to write "yyterminate();" -
625 * we don't want an extra ';' after the "return" because that will cause
626 * some compilers to complain about unreachable statements.
627 */
628#ifndef yyterminate
629#define yyterminate() return YY_NULL
630#endif
631
632/* Number of entries by which start-condition stack grows. */
633#ifndef YY_START_STACK_INCR
634#define YY_START_STACK_INCR 25
635#endif
636
637/* Report a fatal error. */
638#ifndef YY_FATAL_ERROR
639#define YY_FATAL_ERROR(msg) yy_fatal_error( msg )
640#endif
641
642/* end tables serialization structures and prototypes */
643
644/* Default declaration of generated scanner - a define so the user can
645 * easily add parameters.
646 */
647#ifndef YY_DECL
648#define YY_DECL_IS_OURS 1
649
650extern int perf_pmu_lex (void);
651
652#define YY_DECL int perf_pmu_lex (void)
653#endif /* !YY_DECL */
654
655/* Code executed at the beginning of each rule, after perf_pmu_text and perf_pmu_leng
656 * have been set up.
657 */
658#ifndef YY_USER_ACTION
659#define YY_USER_ACTION
660#endif
661
662/* Code executed at the end of each rule. */
663#ifndef YY_BREAK
664#define YY_BREAK break;
665#endif
666
667#define YY_RULE_SETUP \
668 YY_USER_ACTION
669
670/** The main scanner function which does all the work.
671 */
672YY_DECL
673{
674 register yy_state_type yy_current_state;
675 register char *yy_cp, *yy_bp;
676 register int yy_act;
677
678#line 26 "util/pmu.l"
679
680
681#line 682 "<stdout>"
682
683 if ( !(yy_init) )
684 {
685 (yy_init) = 1;
686
687#ifdef YY_USER_INIT
688 YY_USER_INIT;
689#endif
690
691 if ( ! (yy_start) )
692 (yy_start) = 1; /* first start state */
693
694 if ( ! perf_pmu_in )
695 perf_pmu_in = stdin;
696
697 if ( ! perf_pmu_out )
698 perf_pmu_out = stdout;
699
700 if ( ! YY_CURRENT_BUFFER ) {
701 perf_pmu_ensure_buffer_stack ();
702 YY_CURRENT_BUFFER_LVALUE =
703 perf_pmu__create_buffer(perf_pmu_in,YY_BUF_SIZE );
704 }
705
706 perf_pmu__load_buffer_state( );
707 }
708
709 while ( 1 ) /* loops until end-of-file is reached */
710 {
711 yy_cp = (yy_c_buf_p);
712
713 /* Support of perf_pmu_text. */
714 *yy_cp = (yy_hold_char);
715
716 /* yy_bp points to the position in yy_ch_buf of the start of
717 * the current run.
718 */
719 yy_bp = yy_cp;
720
721 yy_current_state = (yy_start);
722yy_match:
723 do
724 {
725 register YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)];
726 if ( yy_accept[yy_current_state] )
727 {
728 (yy_last_accepting_state) = yy_current_state;
729 (yy_last_accepting_cpos) = yy_cp;
730 }
731 while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
732 {
733 yy_current_state = (int) yy_def[yy_current_state];
734 if ( yy_current_state >= 20 )
735 yy_c = yy_meta[(unsigned int) yy_c];
736 }
737 yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
738 ++yy_cp;
739 }
740 while ( yy_base[yy_current_state] != 24 );
741
742yy_find_action:
743 yy_act = yy_accept[yy_current_state];
744 if ( yy_act == 0 )
745 { /* have to back up */
746 yy_cp = (yy_last_accepting_cpos);
747 yy_current_state = (yy_last_accepting_state);
748 yy_act = yy_accept[yy_current_state];
749 }
750
751 YY_DO_BEFORE_ACTION;
752
753do_action: /* This label is used only to access EOF actions. */
754
755 switch ( yy_act )
756 { /* beginning of action switch */
757 case 0: /* must back up */
758 /* undo the effects of YY_DO_BEFORE_ACTION */
759 *yy_cp = (yy_hold_char);
760 yy_cp = (yy_last_accepting_cpos);
761 yy_current_state = (yy_last_accepting_state);
762 goto yy_find_action;
763
764case 1:
765YY_RULE_SETUP
766#line 28 "util/pmu.l"
767{ return value(10); }
768 YY_BREAK
769case 2:
770YY_RULE_SETUP
771#line 29 "util/pmu.l"
772{ return PP_CONFIG; }
773 YY_BREAK
774case 3:
775YY_RULE_SETUP
776#line 30 "util/pmu.l"
777{ return PP_CONFIG1; }
778 YY_BREAK
779case 4:
780YY_RULE_SETUP
781#line 31 "util/pmu.l"
782{ return PP_CONFIG2; }
783 YY_BREAK
784case 5:
785YY_RULE_SETUP
786#line 32 "util/pmu.l"
787{ return '-'; }
788 YY_BREAK
789case 6:
790YY_RULE_SETUP
791#line 33 "util/pmu.l"
792{ return ':'; }
793 YY_BREAK
794case 7:
795YY_RULE_SETUP
796#line 34 "util/pmu.l"
797{ return ','; }
798 YY_BREAK
799case 8:
800YY_RULE_SETUP
801#line 35 "util/pmu.l"
802{ ; }
803 YY_BREAK
804case 9:
805/* rule 9 can match eol */
806YY_RULE_SETUP
807#line 36 "util/pmu.l"
808{ ; }
809 YY_BREAK
810case 10:
811YY_RULE_SETUP
812#line 38 "util/pmu.l"
813ECHO;
814 YY_BREAK
815#line 816 "<stdout>"
816case YY_STATE_EOF(INITIAL):
817 yyterminate();
818
819 case YY_END_OF_BUFFER:
820 {
821 /* Amount of text matched not including the EOB char. */
822 int yy_amount_of_matched_text = (int) (yy_cp - (yytext_ptr)) - 1;
823
824 /* Undo the effects of YY_DO_BEFORE_ACTION. */
825 *yy_cp = (yy_hold_char);
826 YY_RESTORE_YY_MORE_OFFSET
827
828 if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_NEW )
829 {
830 /* We're scanning a new file or input source. It's
831 * possible that this happened because the user
832 * just pointed perf_pmu_in at a new source and called
833 * perf_pmu_lex(). If so, then we have to assure
834 * consistency between YY_CURRENT_BUFFER and our
835 * globals. Here is the right place to do so, because
836 * this is the first action (other than possibly a
837 * back-up) that will match for the new input source.
838 */
839 (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_n_chars;
840 YY_CURRENT_BUFFER_LVALUE->yy_input_file = perf_pmu_in;
841 YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = YY_BUFFER_NORMAL;
842 }
843
844 /* Note that here we test for yy_c_buf_p "<=" to the position
845 * of the first EOB in the buffer, since yy_c_buf_p will
846 * already have been incremented past the NUL character
847 * (since all states make transitions on EOB to the
848 * end-of-buffer state). Contrast this with the test
849 * in input().
850 */
851 if ( (yy_c_buf_p) <= &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] )
852 { /* This was really a NUL. */
853 yy_state_type yy_next_state;
854
855 (yy_c_buf_p) = (yytext_ptr) + yy_amount_of_matched_text;
856
857 yy_current_state = yy_get_previous_state( );
858
859 /* Okay, we're now positioned to make the NUL
860 * transition. We couldn't have
861 * yy_get_previous_state() go ahead and do it
862 * for us because it doesn't know how to deal
863 * with the possibility of jamming (and we don't
864 * want to build jamming into it because then it
865 * will run more slowly).
866 */
867
868 yy_next_state = yy_try_NUL_trans( yy_current_state );
869
870 yy_bp = (yytext_ptr) + YY_MORE_ADJ;
871
872 if ( yy_next_state )
873 {
874 /* Consume the NUL. */
875 yy_cp = ++(yy_c_buf_p);
876 yy_current_state = yy_next_state;
877 goto yy_match;
878 }
879
880 else
881 {
882 yy_cp = (yy_c_buf_p);
883 goto yy_find_action;
884 }
885 }
886
887 else switch ( yy_get_next_buffer( ) )
888 {
889 case EOB_ACT_END_OF_FILE:
890 {
891 (yy_did_buffer_switch_on_eof) = 0;
892
893 if ( perf_pmu_wrap( ) )
894 {
895 /* Note: because we've taken care in
896 * yy_get_next_buffer() to have set up
897 * perf_pmu_text, we can now set up
898 * yy_c_buf_p so that if some total
899 * hoser (like flex itself) wants to
900 * call the scanner after we return the
901 * YY_NULL, it'll still work - another
902 * YY_NULL will get returned.
903 */
904 (yy_c_buf_p) = (yytext_ptr) + YY_MORE_ADJ;
905
906 yy_act = YY_STATE_EOF(YY_START);
907 goto do_action;
908 }
909
910 else
911 {
912 if ( ! (yy_did_buffer_switch_on_eof) )
913 YY_NEW_FILE;
914 }
915 break;
916 }
917
918 case EOB_ACT_CONTINUE_SCAN:
919 (yy_c_buf_p) =
920 (yytext_ptr) + yy_amount_of_matched_text;
921
922 yy_current_state = yy_get_previous_state( );
923
924 yy_cp = (yy_c_buf_p);
925 yy_bp = (yytext_ptr) + YY_MORE_ADJ;
926 goto yy_match;
927
928 case EOB_ACT_LAST_MATCH:
929 (yy_c_buf_p) =
930 &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)];
931
932 yy_current_state = yy_get_previous_state( );
933
934 yy_cp = (yy_c_buf_p);
935 yy_bp = (yytext_ptr) + YY_MORE_ADJ;
936 goto yy_find_action;
937 }
938 break;
939 }
940
941 default:
942 YY_FATAL_ERROR(
943 "fatal flex scanner internal error--no action found" );
944 } /* end of action switch */
945 } /* end of scanning one token */
946} /* end of perf_pmu_lex */
947
948/* yy_get_next_buffer - try to read in a new buffer
949 *
950 * Returns a code representing an action:
951 * EOB_ACT_LAST_MATCH -
952 * EOB_ACT_CONTINUE_SCAN - continue scanning from current position
953 * EOB_ACT_END_OF_FILE - end of file
954 */
955static int yy_get_next_buffer (void)
956{
957 register char *dest = YY_CURRENT_BUFFER_LVALUE->yy_ch_buf;
958 register char *source = (yytext_ptr);
959 register int number_to_move, i;
960 int ret_val;
961
962 if ( (yy_c_buf_p) > &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars) + 1] )
963 YY_FATAL_ERROR(
964 "fatal flex scanner internal error--end of buffer missed" );
965
966 if ( YY_CURRENT_BUFFER_LVALUE->yy_fill_buffer == 0 )
967 { /* Don't try to fill the buffer, so this is an EOF. */
968 if ( (yy_c_buf_p) - (yytext_ptr) - YY_MORE_ADJ == 1 )
969 {
970 /* We matched a single character, the EOB, so
971 * treat this as a final EOF.
972 */
973 return EOB_ACT_END_OF_FILE;
974 }
975
976 else
977 {
978 /* We matched some text prior to the EOB, first
979 * process it.
980 */
981 return EOB_ACT_LAST_MATCH;
982 }
983 }
984
985 /* Try to read more data. */
986
987 /* First move last chars to start of buffer. */
988 number_to_move = (int) ((yy_c_buf_p) - (yytext_ptr)) - 1;
989
990 for ( i = 0; i < number_to_move; ++i )
991 *(dest++) = *(source++);
992
993 if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_EOF_PENDING )
994 /* don't do the read, it's not guaranteed to return an EOF,
995 * just force an EOF
996 */
997 YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars) = 0;
998
999 else
1000 {
1001 int num_to_read =
1002 YY_CURRENT_BUFFER_LVALUE->yy_buf_size - number_to_move - 1;
1003
1004 while ( num_to_read <= 0 )
1005 { /* Not enough room in the buffer - grow it. */
1006
1007 /* just a shorter name for the current buffer */
1008 YY_BUFFER_STATE b = YY_CURRENT_BUFFER;
1009
1010 int yy_c_buf_p_offset =
1011 (int) ((yy_c_buf_p) - b->yy_ch_buf);
1012
1013 if ( b->yy_is_our_buffer )
1014 {
1015 int new_size = b->yy_buf_size * 2;
1016
1017 if ( new_size <= 0 )
1018 b->yy_buf_size += b->yy_buf_size / 8;
1019 else
1020 b->yy_buf_size *= 2;
1021
1022 b->yy_ch_buf = (char *)
1023 /* Include room in for 2 EOB chars. */
1024 perf_pmu_realloc((void *) b->yy_ch_buf,b->yy_buf_size + 2 );
1025 }
1026 else
1027 /* Can't grow it, we don't own it. */
1028 b->yy_ch_buf = 0;
1029
1030 if ( ! b->yy_ch_buf )
1031 YY_FATAL_ERROR(
1032 "fatal error - scanner input buffer overflow" );
1033
1034 (yy_c_buf_p) = &b->yy_ch_buf[yy_c_buf_p_offset];
1035
1036 num_to_read = YY_CURRENT_BUFFER_LVALUE->yy_buf_size -
1037 number_to_move - 1;
1038
1039 }
1040
1041 if ( num_to_read > YY_READ_BUF_SIZE )
1042 num_to_read = YY_READ_BUF_SIZE;
1043
1044 /* Read in more data. */
1045 YY_INPUT( (&YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]),
1046 (yy_n_chars), (size_t) num_to_read );
1047
1048 YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars);
1049 }
1050
1051 if ( (yy_n_chars) == 0 )
1052 {
1053 if ( number_to_move == YY_MORE_ADJ )
1054 {
1055 ret_val = EOB_ACT_END_OF_FILE;
1056 perf_pmu_restart(perf_pmu_in );
1057 }
1058
1059 else
1060 {
1061 ret_val = EOB_ACT_LAST_MATCH;
1062 YY_CURRENT_BUFFER_LVALUE->yy_buffer_status =
1063 YY_BUFFER_EOF_PENDING;
1064 }
1065 }
1066
1067 else
1068 ret_val = EOB_ACT_CONTINUE_SCAN;
1069
1070 if ((yy_size_t) ((yy_n_chars) + number_to_move) > YY_CURRENT_BUFFER_LVALUE->yy_buf_size) {
1071 /* Extend the array by 50%, plus the number we really need. */
1072 yy_size_t new_size = (yy_n_chars) + number_to_move + ((yy_n_chars) >> 1);
1073 YY_CURRENT_BUFFER_LVALUE->yy_ch_buf = (char *) perf_pmu_realloc((void *) YY_CURRENT_BUFFER_LVALUE->yy_ch_buf,new_size );
1074 if ( ! YY_CURRENT_BUFFER_LVALUE->yy_ch_buf )
1075 YY_FATAL_ERROR( "out of dynamic memory in yy_get_next_buffer()" );
1076 }
1077
1078 (yy_n_chars) += number_to_move;
1079 YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] = YY_END_OF_BUFFER_CHAR;
1080 YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars) + 1] = YY_END_OF_BUFFER_CHAR;
1081
1082 (yytext_ptr) = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[0];
1083
1084 return ret_val;
1085}
1086
1087/* yy_get_previous_state - get the state just before the EOB char was reached */
1088
1089 static yy_state_type yy_get_previous_state (void)
1090{
1091 register yy_state_type yy_current_state;
1092 register char *yy_cp;
1093
1094 yy_current_state = (yy_start);
1095
1096 for ( yy_cp = (yytext_ptr) + YY_MORE_ADJ; yy_cp < (yy_c_buf_p); ++yy_cp )
1097 {
1098 register YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1);
1099 if ( yy_accept[yy_current_state] )
1100 {
1101 (yy_last_accepting_state) = yy_current_state;
1102 (yy_last_accepting_cpos) = yy_cp;
1103 }
1104 while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
1105 {
1106 yy_current_state = (int) yy_def[yy_current_state];
1107 if ( yy_current_state >= 20 )
1108 yy_c = yy_meta[(unsigned int) yy_c];
1109 }
1110 yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
1111 }
1112
1113 return yy_current_state;
1114}
1115
1116/* yy_try_NUL_trans - try to make a transition on the NUL character
1117 *
1118 * synopsis
1119 * next_state = yy_try_NUL_trans( current_state );
1120 */
1121 static yy_state_type yy_try_NUL_trans (yy_state_type yy_current_state )
1122{
1123 register int yy_is_jam;
1124 register char *yy_cp = (yy_c_buf_p);
1125
1126 register YY_CHAR yy_c = 1;
1127 if ( yy_accept[yy_current_state] )
1128 {
1129 (yy_last_accepting_state) = yy_current_state;
1130 (yy_last_accepting_cpos) = yy_cp;
1131 }
1132 while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
1133 {
1134 yy_current_state = (int) yy_def[yy_current_state];
1135 if ( yy_current_state >= 20 )
1136 yy_c = yy_meta[(unsigned int) yy_c];
1137 }
1138 yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
1139 yy_is_jam = (yy_current_state == 19);
1140
1141 return yy_is_jam ? 0 : yy_current_state;
1142}
1143
1144 static void yyunput (int c, register char * yy_bp )
1145{
1146 register char *yy_cp;
1147
1148 yy_cp = (yy_c_buf_p);
1149
1150 /* undo effects of setting up perf_pmu_text */
1151 *yy_cp = (yy_hold_char);
1152
1153 if ( yy_cp < YY_CURRENT_BUFFER_LVALUE->yy_ch_buf + 2 )
1154 { /* need to shift things up to make room */
1155 /* +2 for EOB chars. */
1156 register int number_to_move = (yy_n_chars) + 2;
1157 register char *dest = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[
1158 YY_CURRENT_BUFFER_LVALUE->yy_buf_size + 2];
1159 register char *source =
1160 &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move];
1161
1162 while ( source > YY_CURRENT_BUFFER_LVALUE->yy_ch_buf )
1163 *--dest = *--source;
1164
1165 yy_cp += (int) (dest - source);
1166 yy_bp += (int) (dest - source);
1167 YY_CURRENT_BUFFER_LVALUE->yy_n_chars =
1168 (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_buf_size;
1169
1170 if ( yy_cp < YY_CURRENT_BUFFER_LVALUE->yy_ch_buf + 2 )
1171 YY_FATAL_ERROR( "flex scanner push-back overflow" );
1172 }
1173
1174 *--yy_cp = (char) c;
1175
1176 (yytext_ptr) = yy_bp;
1177 (yy_hold_char) = *yy_cp;
1178 (yy_c_buf_p) = yy_cp;
1179}
1180
1181#ifndef YY_NO_INPUT
1182#ifdef __cplusplus
1183 static int yyinput (void)
1184#else
1185 static int input (void)
1186#endif
1187
1188{
1189 int c;
1190
1191 *(yy_c_buf_p) = (yy_hold_char);
1192
1193 if ( *(yy_c_buf_p) == YY_END_OF_BUFFER_CHAR )
1194 {
1195 /* yy_c_buf_p now points to the character we want to return.
1196 * If this occurs *before* the EOB characters, then it's a
1197 * valid NUL; if not, then we've hit the end of the buffer.
1198 */
1199 if ( (yy_c_buf_p) < &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] )
1200 /* This was really a NUL. */
1201 *(yy_c_buf_p) = '\0';
1202
1203 else
1204 { /* need more input */
1205 int offset = (yy_c_buf_p) - (yytext_ptr);
1206 ++(yy_c_buf_p);
1207
1208 switch ( yy_get_next_buffer( ) )
1209 {
1210 case EOB_ACT_LAST_MATCH:
1211 /* This happens because yy_g_n_b()
1212 * sees that we've accumulated a
1213 * token and flags that we need to
1214 * try matching the token before
1215 * proceeding. But for input(),
1216 * there's no matching to consider.
1217 * So convert the EOB_ACT_LAST_MATCH
1218 * to EOB_ACT_END_OF_FILE.
1219 */
1220
1221 /* Reset buffer status. */
1222 perf_pmu_restart(perf_pmu_in );
1223
1224 /*FALLTHROUGH*/
1225
1226 case EOB_ACT_END_OF_FILE:
1227 {
1228 if ( perf_pmu_wrap( ) )
1229 return EOF;
1230
1231 if ( ! (yy_did_buffer_switch_on_eof) )
1232 YY_NEW_FILE;
1233#ifdef __cplusplus
1234 return yyinput();
1235#else
1236 return input();
1237#endif
1238 }
1239
1240 case EOB_ACT_CONTINUE_SCAN:
1241 (yy_c_buf_p) = (yytext_ptr) + offset;
1242 break;
1243 }
1244 }
1245 }
1246
1247 c = *(unsigned char *) (yy_c_buf_p); /* cast for 8-bit char's */
1248 *(yy_c_buf_p) = '\0'; /* preserve perf_pmu_text */
1249 (yy_hold_char) = *++(yy_c_buf_p);
1250
1251 return c;
1252}
1253#endif /* ifndef YY_NO_INPUT */
1254
1255/** Immediately switch to a different input stream.
1256 * @param input_file A readable stream.
1257 *
1258 * @note This function does not reset the start condition to @c INITIAL .
1259 */
1260 void perf_pmu_restart (FILE * input_file )
1261{
1262
1263 if ( ! YY_CURRENT_BUFFER ){
1264 perf_pmu_ensure_buffer_stack ();
1265 YY_CURRENT_BUFFER_LVALUE =
1266 perf_pmu__create_buffer(perf_pmu_in,YY_BUF_SIZE );
1267 }
1268
1269 perf_pmu__init_buffer(YY_CURRENT_BUFFER,input_file );
1270 perf_pmu__load_buffer_state( );
1271}
1272
1273/** Switch to a different input buffer.
1274 * @param new_buffer The new input buffer.
1275 *
1276 */
1277 void perf_pmu__switch_to_buffer (YY_BUFFER_STATE new_buffer )
1278{
1279
1280 /* TODO. We should be able to replace this entire function body
1281 * with
1282 * perf_pmu_pop_buffer_state();
1283 * perf_pmu_push_buffer_state(new_buffer);
1284 */
1285 perf_pmu_ensure_buffer_stack ();
1286 if ( YY_CURRENT_BUFFER == new_buffer )
1287 return;
1288
1289 if ( YY_CURRENT_BUFFER )
1290 {
1291 /* Flush out information for old buffer. */
1292 *(yy_c_buf_p) = (yy_hold_char);
1293 YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = (yy_c_buf_p);
1294 YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars);
1295 }
1296
1297 YY_CURRENT_BUFFER_LVALUE = new_buffer;
1298 perf_pmu__load_buffer_state( );
1299
1300 /* We don't actually know whether we did this switch during
1301 * EOF (perf_pmu_wrap()) processing, but the only time this flag
1302 * is looked at is after perf_pmu_wrap() is called, so it's safe
1303 * to go ahead and always set it.
1304 */
1305 (yy_did_buffer_switch_on_eof) = 1;
1306}
1307
1308static void perf_pmu__load_buffer_state (void)
1309{
1310 (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_n_chars;
1311 (yytext_ptr) = (yy_c_buf_p) = YY_CURRENT_BUFFER_LVALUE->yy_buf_pos;
1312 perf_pmu_in = YY_CURRENT_BUFFER_LVALUE->yy_input_file;
1313 (yy_hold_char) = *(yy_c_buf_p);
1314}
1315
1316/** Allocate and initialize an input buffer state.
1317 * @param file A readable stream.
1318 * @param size The character buffer size in bytes. When in doubt, use @c YY_BUF_SIZE.
1319 *
1320 * @return the allocated buffer state.
1321 */
1322 YY_BUFFER_STATE perf_pmu__create_buffer (FILE * file, int size )
1323{
1324 YY_BUFFER_STATE b;
1325
1326 b = (YY_BUFFER_STATE) perf_pmu_alloc(sizeof( struct yy_buffer_state ) );
1327 if ( ! b )
1328 YY_FATAL_ERROR( "out of dynamic memory in perf_pmu__create_buffer()" );
1329
1330 b->yy_buf_size = size;
1331
1332 /* yy_ch_buf has to be 2 characters longer than the size given because
1333 * we need to put in 2 end-of-buffer characters.
1334 */
1335 b->yy_ch_buf = (char *) perf_pmu_alloc(b->yy_buf_size + 2 );
1336 if ( ! b->yy_ch_buf )
1337 YY_FATAL_ERROR( "out of dynamic memory in perf_pmu__create_buffer()" );
1338
1339 b->yy_is_our_buffer = 1;
1340
1341 perf_pmu__init_buffer(b,file );
1342
1343 return b;
1344}
1345
1346/** Destroy the buffer.
1347 * @param b a buffer created with perf_pmu__create_buffer()
1348 *
1349 */
1350 void perf_pmu__delete_buffer (YY_BUFFER_STATE b )
1351{
1352
1353 if ( ! b )
1354 return;
1355
1356 if ( b == YY_CURRENT_BUFFER ) /* Not sure if we should pop here. */
1357 YY_CURRENT_BUFFER_LVALUE = (YY_BUFFER_STATE) 0;
1358
1359 if ( b->yy_is_our_buffer )
1360 perf_pmu_free((void *) b->yy_ch_buf );
1361
1362 perf_pmu_free((void *) b );
1363}
1364
1365#ifndef __cplusplus
1366extern int isatty (int );
1367#endif /* __cplusplus */
1368
1369/* Initializes or reinitializes a buffer.
1370 * This function is sometimes called more than once on the same buffer,
1371 * such as during a perf_pmu_restart() or at EOF.
1372 */
1373 static void perf_pmu__init_buffer (YY_BUFFER_STATE b, FILE * file )
1374
1375{
1376 int oerrno = errno;
1377
1378 perf_pmu__flush_buffer(b );
1379
1380 b->yy_input_file = file;
1381 b->yy_fill_buffer = 1;
1382
1383 /* If b is the current buffer, then perf_pmu__init_buffer was _probably_
1384 * called from perf_pmu_restart() or through yy_get_next_buffer.
1385 * In that case, we don't want to reset the lineno or column.
1386 */
1387 if (b != YY_CURRENT_BUFFER){
1388 b->yy_bs_lineno = 1;
1389 b->yy_bs_column = 0;
1390 }
1391
1392 b->yy_is_interactive = file ? (isatty( fileno(file) ) > 0) : 0;
1393
1394 errno = oerrno;
1395}
1396
1397/** Discard all buffered characters. On the next scan, YY_INPUT will be called.
1398 * @param b the buffer state to be flushed, usually @c YY_CURRENT_BUFFER.
1399 *
1400 */
1401 void perf_pmu__flush_buffer (YY_BUFFER_STATE b )
1402{
1403 if ( ! b )
1404 return;
1405
1406 b->yy_n_chars = 0;
1407
1408 /* We always need two end-of-buffer characters. The first causes
1409 * a transition to the end-of-buffer state. The second causes
1410 * a jam in that state.
1411 */
1412 b->yy_ch_buf[0] = YY_END_OF_BUFFER_CHAR;
1413 b->yy_ch_buf[1] = YY_END_OF_BUFFER_CHAR;
1414
1415 b->yy_buf_pos = &b->yy_ch_buf[0];
1416
1417 b->yy_at_bol = 1;
1418 b->yy_buffer_status = YY_BUFFER_NEW;
1419
1420 if ( b == YY_CURRENT_BUFFER )
1421 perf_pmu__load_buffer_state( );
1422}
1423
1424/** Pushes the new state onto the stack. The new state becomes
1425 * the current state. This function will allocate the stack
1426 * if necessary.
1427 * @param new_buffer The new state.
1428 *
1429 */
1430void perf_pmu_push_buffer_state (YY_BUFFER_STATE new_buffer )
1431{
1432 if (new_buffer == NULL)
1433 return;
1434
1435 perf_pmu_ensure_buffer_stack();
1436
1437 /* This block is copied from perf_pmu__switch_to_buffer. */
1438 if ( YY_CURRENT_BUFFER )
1439 {
1440 /* Flush out information for old buffer. */
1441 *(yy_c_buf_p) = (yy_hold_char);
1442 YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = (yy_c_buf_p);
1443 YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars);
1444 }
1445
1446 /* Only push if top exists. Otherwise, replace top. */
1447 if (YY_CURRENT_BUFFER)
1448 (yy_buffer_stack_top)++;
1449 YY_CURRENT_BUFFER_LVALUE = new_buffer;
1450
1451 /* copied from perf_pmu__switch_to_buffer. */
1452 perf_pmu__load_buffer_state( );
1453 (yy_did_buffer_switch_on_eof) = 1;
1454}
1455
1456/** Removes and deletes the top of the stack, if present.
1457 * The next element becomes the new top.
1458 *
1459 */
1460void perf_pmu_pop_buffer_state (void)
1461{
1462 if (!YY_CURRENT_BUFFER)
1463 return;
1464
1465 perf_pmu__delete_buffer(YY_CURRENT_BUFFER );
1466 YY_CURRENT_BUFFER_LVALUE = NULL;
1467 if ((yy_buffer_stack_top) > 0)
1468 --(yy_buffer_stack_top);
1469
1470 if (YY_CURRENT_BUFFER) {
1471 perf_pmu__load_buffer_state( );
1472 (yy_did_buffer_switch_on_eof) = 1;
1473 }
1474}
1475
1476/* Allocates the stack if it does not exist.
1477 * Guarantees space for at least one push.
1478 */
1479static void perf_pmu_ensure_buffer_stack (void)
1480{
1481 int num_to_alloc;
1482
1483 if (!(yy_buffer_stack)) {
1484
1485 /* First allocation is just for 2 elements, since we don't know if this
1486 * scanner will even need a stack. We use 2 instead of 1 to avoid an
1487 * immediate realloc on the next call.
1488 */
1489 num_to_alloc = 1;
1490 (yy_buffer_stack) = (struct yy_buffer_state**)perf_pmu_alloc
1491 (num_to_alloc * sizeof(struct yy_buffer_state*)
1492 );
1493 if ( ! (yy_buffer_stack) )
1494 YY_FATAL_ERROR( "out of dynamic memory in perf_pmu_ensure_buffer_stack()" );
1495
1496 memset((yy_buffer_stack), 0, num_to_alloc * sizeof(struct yy_buffer_state*));
1497
1498 (yy_buffer_stack_max) = num_to_alloc;
1499 (yy_buffer_stack_top) = 0;
1500 return;
1501 }
1502
1503 if ((yy_buffer_stack_top) >= ((yy_buffer_stack_max)) - 1){
1504
1505 /* Increase the buffer to prepare for a possible push. */
1506 int grow_size = 8 /* arbitrary grow size */;
1507
1508 num_to_alloc = (yy_buffer_stack_max) + grow_size;
1509 (yy_buffer_stack) = (struct yy_buffer_state**)perf_pmu_realloc
1510 ((yy_buffer_stack),
1511 num_to_alloc * sizeof(struct yy_buffer_state*)
1512 );
1513 if ( ! (yy_buffer_stack) )
1514 YY_FATAL_ERROR( "out of dynamic memory in perf_pmu_ensure_buffer_stack()" );
1515
1516 /* zero only the new slots.*/
1517 memset((yy_buffer_stack) + (yy_buffer_stack_max), 0, grow_size * sizeof(struct yy_buffer_state*));
1518 (yy_buffer_stack_max) = num_to_alloc;
1519 }
1520}
1521
1522/** Setup the input buffer state to scan directly from a user-specified character buffer.
1523 * @param base the character buffer
1524 * @param size the size in bytes of the character buffer
1525 *
1526 * @return the newly allocated buffer state object.
1527 */
1528YY_BUFFER_STATE perf_pmu__scan_buffer (char * base, yy_size_t size )
1529{
1530 YY_BUFFER_STATE b;
1531
1532 if ( size < 2 ||
1533 base[size-2] != YY_END_OF_BUFFER_CHAR ||
1534 base[size-1] != YY_END_OF_BUFFER_CHAR )
1535 /* They forgot to leave room for the EOB's. */
1536 return 0;
1537
1538 b = (YY_BUFFER_STATE) perf_pmu_alloc(sizeof( struct yy_buffer_state ) );
1539 if ( ! b )
1540 YY_FATAL_ERROR( "out of dynamic memory in perf_pmu__scan_buffer()" );
1541
1542 b->yy_buf_size = size - 2; /* "- 2" to take care of EOB's */
1543 b->yy_buf_pos = b->yy_ch_buf = base;
1544 b->yy_is_our_buffer = 0;
1545 b->yy_input_file = 0;
1546 b->yy_n_chars = b->yy_buf_size;
1547 b->yy_is_interactive = 0;
1548 b->yy_at_bol = 1;
1549 b->yy_fill_buffer = 0;
1550 b->yy_buffer_status = YY_BUFFER_NEW;
1551
1552 perf_pmu__switch_to_buffer(b );
1553
1554 return b;
1555}
1556
1557/** Setup the input buffer state to scan a string. The next call to perf_pmu_lex() will
1558 * scan from a @e copy of @a str.
1559 * @param yystr a NUL-terminated string to scan
1560 *
1561 * @return the newly allocated buffer state object.
1562 * @note If you want to scan bytes that may contain NUL values, then use
1563 * perf_pmu__scan_bytes() instead.
1564 */
1565YY_BUFFER_STATE perf_pmu__scan_string (yyconst char * yystr )
1566{
1567
1568 return perf_pmu__scan_bytes(yystr,strlen(yystr) );
1569}
1570
1571/** Setup the input buffer state to scan the given bytes. The next call to perf_pmu_lex() will
1572 * scan from a @e copy of @a bytes.
1573 * @param bytes the byte buffer to scan
1574 * @param len the number of bytes in the buffer pointed to by @a bytes.
1575 *
1576 * @return the newly allocated buffer state object.
1577 */
1578YY_BUFFER_STATE perf_pmu__scan_bytes (yyconst char * yybytes, int _yybytes_len )
1579{
1580 YY_BUFFER_STATE b;
1581 char *buf;
1582 yy_size_t n;
1583 int i;
1584
1585 /* Get memory for full buffer, including space for trailing EOB's. */
1586 n = _yybytes_len + 2;
1587 buf = (char *) perf_pmu_alloc(n );
1588 if ( ! buf )
1589 YY_FATAL_ERROR( "out of dynamic memory in perf_pmu__scan_bytes()" );
1590
1591 for ( i = 0; i < _yybytes_len; ++i )
1592 buf[i] = yybytes[i];
1593
1594 buf[_yybytes_len] = buf[_yybytes_len+1] = YY_END_OF_BUFFER_CHAR;
1595
1596 b = perf_pmu__scan_buffer(buf,n );
1597 if ( ! b )
1598 YY_FATAL_ERROR( "bad buffer in perf_pmu__scan_bytes()" );
1599
1600 /* It's okay to grow etc. this buffer, and we should throw it
1601 * away when we're done.
1602 */
1603 b->yy_is_our_buffer = 1;
1604
1605 return b;
1606}
1607
1608#ifndef YY_EXIT_FAILURE
1609#define YY_EXIT_FAILURE 2
1610#endif
1611
1612static void yy_fatal_error (yyconst char* msg )
1613{
1614 (void) fprintf( stderr, "%s\n", msg );
1615 exit( YY_EXIT_FAILURE );
1616}
1617
1618/* Redefine yyless() so it works in section 3 code. */
1619
1620#undef yyless
1621#define yyless(n) \
1622 do \
1623 { \
1624 /* Undo effects of setting up perf_pmu_text. */ \
1625 int yyless_macro_arg = (n); \
1626 YY_LESS_LINENO(yyless_macro_arg);\
1627 perf_pmu_text[perf_pmu_leng] = (yy_hold_char); \
1628 (yy_c_buf_p) = perf_pmu_text + yyless_macro_arg; \
1629 (yy_hold_char) = *(yy_c_buf_p); \
1630 *(yy_c_buf_p) = '\0'; \
1631 perf_pmu_leng = yyless_macro_arg; \
1632 } \
1633 while ( 0 )
1634
1635/* Accessor methods (get/set functions) to struct members. */
1636
1637/** Get the current line number.
1638 *
1639 */
1640int perf_pmu_get_lineno (void)
1641{
1642
1643 return perf_pmu_lineno;
1644}
1645
1646/** Get the input stream.
1647 *
1648 */
1649FILE *perf_pmu_get_in (void)
1650{
1651 return perf_pmu_in;
1652}
1653
1654/** Get the output stream.
1655 *
1656 */
1657FILE *perf_pmu_get_out (void)
1658{
1659 return perf_pmu_out;
1660}
1661
1662/** Get the length of the current token.
1663 *
1664 */
1665int perf_pmu_get_leng (void)
1666{
1667 return perf_pmu_leng;
1668}
1669
1670/** Get the current token.
1671 *
1672 */
1673
1674char *perf_pmu_get_text (void)
1675{
1676 return perf_pmu_text;
1677}
1678
1679/** Set the current line number.
1680 * @param line_number
1681 *
1682 */
1683void perf_pmu_set_lineno (int line_number )
1684{
1685
1686 perf_pmu_lineno = line_number;
1687}
1688
1689/** Set the input stream. This does not discard the current
1690 * input buffer.
1691 * @param in_str A readable stream.
1692 *
1693 * @see perf_pmu__switch_to_buffer
1694 */
1695void perf_pmu_set_in (FILE * in_str )
1696{
1697 perf_pmu_in = in_str ;
1698}
1699
1700void perf_pmu_set_out (FILE * out_str )
1701{
1702 perf_pmu_out = out_str ;
1703}
1704
1705int perf_pmu_get_debug (void)
1706{
1707 return perf_pmu__flex_debug;
1708}
1709
1710void perf_pmu_set_debug (int bdebug )
1711{
1712 perf_pmu__flex_debug = bdebug ;
1713}
1714
1715static int yy_init_globals (void)
1716{
1717 /* Initialization is the same as for the non-reentrant scanner.
1718 * This function is called from perf_pmu_lex_destroy(), so don't allocate here.
1719 */
1720
1721 (yy_buffer_stack) = 0;
1722 (yy_buffer_stack_top) = 0;
1723 (yy_buffer_stack_max) = 0;
1724 (yy_c_buf_p) = (char *) 0;
1725 (yy_init) = 0;
1726 (yy_start) = 0;
1727
1728/* Defined in main.c */
1729#ifdef YY_STDINIT
1730 perf_pmu_in = stdin;
1731 perf_pmu_out = stdout;
1732#else
1733 perf_pmu_in = (FILE *) 0;
1734 perf_pmu_out = (FILE *) 0;
1735#endif
1736
1737 /* For future reference: Set errno on error, since we are called by
1738 * perf_pmu_lex_init()
1739 */
1740 return 0;
1741}
1742
1743/* perf_pmu_lex_destroy is for both reentrant and non-reentrant scanners. */
1744int perf_pmu_lex_destroy (void)
1745{
1746
1747 /* Pop the buffer stack, destroying each element. */
1748 while(YY_CURRENT_BUFFER){
1749 perf_pmu__delete_buffer(YY_CURRENT_BUFFER );
1750 YY_CURRENT_BUFFER_LVALUE = NULL;
1751 perf_pmu_pop_buffer_state();
1752 }
1753
1754 /* Destroy the stack itself. */
1755 perf_pmu_free((yy_buffer_stack) );
1756 (yy_buffer_stack) = NULL;
1757
1758 /* Reset the globals. This is important in a non-reentrant scanner so the next time
1759 * perf_pmu_lex() is called, initialization will occur. */
1760 yy_init_globals( );
1761
1762 return 0;
1763}
1764
1765/*
1766 * Internal utility routines.
1767 */
1768
1769#ifndef yytext_ptr
1770static void yy_flex_strncpy (char* s1, yyconst char * s2, int n )
1771{
1772 register int i;
1773 for ( i = 0; i < n; ++i )
1774 s1[i] = s2[i];
1775}
1776#endif
1777
1778#ifdef YY_NEED_STRLEN
1779static int yy_flex_strlen (yyconst char * s )
1780{
1781 register int n;
1782 for ( n = 0; s[n]; ++n )
1783 ;
1784
1785 return n;
1786}
1787#endif
1788
1789void *perf_pmu_alloc (yy_size_t size )
1790{
1791 return (void *) malloc( size );
1792}
1793
1794void *perf_pmu_realloc (void * ptr, yy_size_t size )
1795{
1796 /* The cast to (char *) in the following accommodates both
1797 * implementations that use char* generic pointers, and those
1798 * that use void* generic pointers. It works with the latter
1799 * because both ANSI C and C++ allow castless assignment from
1800 * any pointer type to void*, and deal with argument conversions
1801 * as though doing an assignment.
1802 */
1803 return (void *) realloc( (char *) ptr, size );
1804}
1805
1806void perf_pmu_free (void * ptr )
1807{
1808 free( (char *) ptr ); /* see perf_pmu_realloc() for (char *) cast */
1809}
1810
1811#define YYTABLES_NAME "yytables"
1812
1813#line 38 "util/pmu.l"
1814
1815
1816
1817int perf_pmu_wrap(void)
1818{
1819 return 1;
1820}
1821
diff --git a/tools/perf/util/pmu-flex.h b/tools/perf/util/pmu-flex.h
new file mode 100644
index 000000000000..0a29c8a0da4e
--- /dev/null
+++ b/tools/perf/util/pmu-flex.h
@@ -0,0 +1,316 @@
1#ifndef perf_pmu_HEADER_H
2#define perf_pmu_HEADER_H 1
3#define perf_pmu_IN_HEADER 1
4
5#line 6 "util/pmu-flex.h"
6
7#define YY_INT_ALIGNED short int
8
9/* A lexical scanner generated by flex */
10
11#define FLEX_SCANNER
12#define YY_FLEX_MAJOR_VERSION 2
13#define YY_FLEX_MINOR_VERSION 5
14#define YY_FLEX_SUBMINOR_VERSION 35
15#if YY_FLEX_SUBMINOR_VERSION > 0
16#define FLEX_BETA
17#endif
18
19/* First, we deal with platform-specific or compiler-specific issues. */
20
21/* begin standard C headers. */
22#include <stdio.h>
23#include <string.h>
24#include <errno.h>
25#include <stdlib.h>
26
27/* end standard C headers. */
28
29/* flex integer type definitions */
30
31#ifndef FLEXINT_H
32#define FLEXINT_H
33
34/* C99 systems have <inttypes.h>. Non-C99 systems may or may not. */
35
36#if defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
37
38/* C99 says to define __STDC_LIMIT_MACROS before including stdint.h,
39 * if you want the limit (max/min) macros for int types.
40 */
41#ifndef __STDC_LIMIT_MACROS
42#define __STDC_LIMIT_MACROS 1
43#endif
44
45#include <inttypes.h>
46typedef int8_t flex_int8_t;
47typedef uint8_t flex_uint8_t;
48typedef int16_t flex_int16_t;
49typedef uint16_t flex_uint16_t;
50typedef int32_t flex_int32_t;
51typedef uint32_t flex_uint32_t;
52#else
53typedef signed char flex_int8_t;
54typedef short int flex_int16_t;
55typedef int flex_int32_t;
56typedef unsigned char flex_uint8_t;
57typedef unsigned short int flex_uint16_t;
58typedef unsigned int flex_uint32_t;
59#endif /* ! C99 */
60
61/* Limits of integral types. */
62#ifndef INT8_MIN
63#define INT8_MIN (-128)
64#endif
65#ifndef INT16_MIN
66#define INT16_MIN (-32767-1)
67#endif
68#ifndef INT32_MIN
69#define INT32_MIN (-2147483647-1)
70#endif
71#ifndef INT8_MAX
72#define INT8_MAX (127)
73#endif
74#ifndef INT16_MAX
75#define INT16_MAX (32767)
76#endif
77#ifndef INT32_MAX
78#define INT32_MAX (2147483647)
79#endif
80#ifndef UINT8_MAX
81#define UINT8_MAX (255U)
82#endif
83#ifndef UINT16_MAX
84#define UINT16_MAX (65535U)
85#endif
86#ifndef UINT32_MAX
87#define UINT32_MAX (4294967295U)
88#endif
89
90#endif /* ! FLEXINT_H */
91
92#ifdef __cplusplus
93
94/* The "const" storage-class-modifier is valid. */
95#define YY_USE_CONST
96
97#else /* ! __cplusplus */
98
99/* C99 requires __STDC__ to be defined as 1. */
100#if defined (__STDC__)
101
102#define YY_USE_CONST
103
104#endif /* defined (__STDC__) */
105#endif /* ! __cplusplus */
106
107#ifdef YY_USE_CONST
108#define yyconst const
109#else
110#define yyconst
111#endif
112
113/* Size of default input buffer. */
114#ifndef YY_BUF_SIZE
115#define YY_BUF_SIZE 16384
116#endif
117
118#ifndef YY_TYPEDEF_YY_BUFFER_STATE
119#define YY_TYPEDEF_YY_BUFFER_STATE
120typedef struct yy_buffer_state *YY_BUFFER_STATE;
121#endif
122
123extern int perf_pmu_leng;
124
125extern FILE *perf_pmu_in, *perf_pmu_out;
126
127#ifndef YY_TYPEDEF_YY_SIZE_T
128#define YY_TYPEDEF_YY_SIZE_T
129typedef size_t yy_size_t;
130#endif
131
132#ifndef YY_STRUCT_YY_BUFFER_STATE
133#define YY_STRUCT_YY_BUFFER_STATE
134struct yy_buffer_state
135 {
136 FILE *yy_input_file;
137
138 char *yy_ch_buf; /* input buffer */
139 char *yy_buf_pos; /* current position in input buffer */
140
141 /* Size of input buffer in bytes, not including room for EOB
142 * characters.
143 */
144 yy_size_t yy_buf_size;
145
146 /* Number of characters read into yy_ch_buf, not including EOB
147 * characters.
148 */
149 int yy_n_chars;
150
151 /* Whether we "own" the buffer - i.e., we know we created it,
152 * and can realloc() it to grow it, and should free() it to
153 * delete it.
154 */
155 int yy_is_our_buffer;
156
157 /* Whether this is an "interactive" input source; if so, and
158 * if we're using stdio for input, then we want to use getc()
159 * instead of fread(), to make sure we stop fetching input after
160 * each newline.
161 */
162 int yy_is_interactive;
163
164 /* Whether we're considered to be at the beginning of a line.
165 * If so, '^' rules will be active on the next match, otherwise
166 * not.
167 */
168 int yy_at_bol;
169
170 int yy_bs_lineno; /**< The line count. */
171 int yy_bs_column; /**< The column count. */
172
173 /* Whether to try to fill the input buffer when we reach the
174 * end of it.
175 */
176 int yy_fill_buffer;
177
178 int yy_buffer_status;
179
180 };
181#endif /* !YY_STRUCT_YY_BUFFER_STATE */
182
183void perf_pmu_restart (FILE *input_file );
184void perf_pmu__switch_to_buffer (YY_BUFFER_STATE new_buffer );
185YY_BUFFER_STATE perf_pmu__create_buffer (FILE *file,int size );
186void perf_pmu__delete_buffer (YY_BUFFER_STATE b );
187void perf_pmu__flush_buffer (YY_BUFFER_STATE b );
188void perf_pmu_push_buffer_state (YY_BUFFER_STATE new_buffer );
189void perf_pmu_pop_buffer_state (void );
190
191YY_BUFFER_STATE perf_pmu__scan_buffer (char *base,yy_size_t size );
192YY_BUFFER_STATE perf_pmu__scan_string (yyconst char *yy_str );
193YY_BUFFER_STATE perf_pmu__scan_bytes (yyconst char *bytes,int len );
194
195void *perf_pmu_alloc (yy_size_t );
196void *perf_pmu_realloc (void *,yy_size_t );
197void perf_pmu_free (void * );
198
199/* Begin user sect3 */
200
201extern int perf_pmu_lineno;
202
203extern char *perf_pmu_text;
204#define yytext_ptr perf_pmu_text
205
206#ifdef YY_HEADER_EXPORT_START_CONDITIONS
207#define INITIAL 0
208
209#endif
210
211#ifndef YY_NO_UNISTD_H
212/* Special case for "unistd.h", since it is non-ANSI. We include it way
213 * down here because we want the user's section 1 to have been scanned first.
214 * The user has a chance to override it with an option.
215 */
216#include <unistd.h>
217#endif
218
219#ifndef YY_EXTRA_TYPE
220#define YY_EXTRA_TYPE void *
221#endif
222
223/* Accessor methods to globals.
224 These are made visible to non-reentrant scanners for convenience. */
225
226int perf_pmu_lex_destroy (void );
227
228int perf_pmu_get_debug (void );
229
230void perf_pmu_set_debug (int debug_flag );
231
232YY_EXTRA_TYPE perf_pmu_get_extra (void );
233
234void perf_pmu_set_extra (YY_EXTRA_TYPE user_defined );
235
236FILE *perf_pmu_get_in (void );
237
238void perf_pmu_set_in (FILE * in_str );
239
240FILE *perf_pmu_get_out (void );
241
242void perf_pmu_set_out (FILE * out_str );
243
244int perf_pmu_get_leng (void );
245
246char *perf_pmu_get_text (void );
247
248int perf_pmu_get_lineno (void );
249
250void perf_pmu_set_lineno (int line_number );
251
252/* Macros after this point can all be overridden by user definitions in
253 * section 1.
254 */
255
256#ifndef YY_SKIP_YYWRAP
257#ifdef __cplusplus
258extern "C" int perf_pmu_wrap (void );
259#else
260extern int perf_pmu_wrap (void );
261#endif
262#endif
263
264#ifndef yytext_ptr
265static void yy_flex_strncpy (char *,yyconst char *,int );
266#endif
267
268#ifdef YY_NEED_STRLEN
269static int yy_flex_strlen (yyconst char * );
270#endif
271
272#ifndef YY_NO_INPUT
273
274#endif
275
276/* Amount of stuff to slurp up with each read. */
277#ifndef YY_READ_BUF_SIZE
278#define YY_READ_BUF_SIZE 8192
279#endif
280
281/* Number of entries by which start-condition stack grows. */
282#ifndef YY_START_STACK_INCR
283#define YY_START_STACK_INCR 25
284#endif
285
286/* Default declaration of generated scanner - a define so the user can
287 * easily add parameters.
288 */
289#ifndef YY_DECL
290#define YY_DECL_IS_OURS 1
291
292extern int perf_pmu_lex (void);
293
294#define YY_DECL int perf_pmu_lex (void)
295#endif /* !YY_DECL */
296
297/* yy_get_previous_state - get the state just before the EOB char was reached */
298
299#undef YY_NEW_FILE
300#undef YY_FLUSH_BUFFER
301#undef yy_set_bol
302#undef yy_new_buffer
303#undef yy_set_interactive
304#undef YY_DO_BEFORE_ACTION
305
306#ifdef YY_DECL_IS_OURS
307#undef YY_DECL_IS_OURS
308#undef YY_DECL
309#endif
310
311#line 38 "util/pmu.l"
312
313
314#line 315 "util/pmu-flex.h"
315#undef perf_pmu_IN_HEADER
316#endif /* perf_pmu_HEADER_H */
diff --git a/tools/perf/util/pmu.c b/tools/perf/util/pmu.c
new file mode 100644
index 000000000000..cb08a118e811
--- /dev/null
+++ b/tools/perf/util/pmu.c
@@ -0,0 +1,469 @@
1
2#include <linux/list.h>
3#include <sys/types.h>
4#include <sys/stat.h>
5#include <unistd.h>
6#include <stdio.h>
7#include <dirent.h>
8#include "sysfs.h"
9#include "util.h"
10#include "pmu.h"
11#include "parse-events.h"
12
13int perf_pmu_parse(struct list_head *list, char *name);
14extern FILE *perf_pmu_in;
15
16static LIST_HEAD(pmus);
17
18/*
19 * Parse & process all the sysfs attributes located under
20 * the directory specified in 'dir' parameter.
21 */
22static int pmu_format_parse(char *dir, struct list_head *head)
23{
24 struct dirent *evt_ent;
25 DIR *format_dir;
26 int ret = 0;
27
28 format_dir = opendir(dir);
29 if (!format_dir)
30 return -EINVAL;
31
32 while (!ret && (evt_ent = readdir(format_dir))) {
33 char path[PATH_MAX];
34 char *name = evt_ent->d_name;
35 FILE *file;
36
37 if (!strcmp(name, ".") || !strcmp(name, ".."))
38 continue;
39
40 snprintf(path, PATH_MAX, "%s/%s", dir, name);
41
42 ret = -EINVAL;
43 file = fopen(path, "r");
44 if (!file)
45 break;
46
47 perf_pmu_in = file;
48 ret = perf_pmu_parse(head, name);
49 fclose(file);
50 }
51
52 closedir(format_dir);
53 return ret;
54}
55
56/*
57 * Reading/parsing the default pmu format definition, which should be
58 * located at:
59 * /sys/bus/event_source/devices/<dev>/format as sysfs group attributes.
60 */
61static int pmu_format(char *name, struct list_head *format)
62{
63 struct stat st;
64 char path[PATH_MAX];
65 const char *sysfs;
66
67 sysfs = sysfs_find_mountpoint();
68 if (!sysfs)
69 return -1;
70
71 snprintf(path, PATH_MAX,
72 "%s/bus/event_source/devices/%s/format", sysfs, name);
73
74 if (stat(path, &st) < 0)
75 return -1;
76
77 if (pmu_format_parse(path, format))
78 return -1;
79
80 return 0;
81}
82
83/*
84 * Reading/parsing the default pmu type value, which should be
85 * located at:
86 * /sys/bus/event_source/devices/<dev>/type as sysfs attribute.
87 */
88static int pmu_type(char *name, __u32 *type)
89{
90 struct stat st;
91 char path[PATH_MAX];
92 const char *sysfs;
93 FILE *file;
94 int ret = 0;
95
96 sysfs = sysfs_find_mountpoint();
97 if (!sysfs)
98 return -1;
99
100 snprintf(path, PATH_MAX,
101 "%s/bus/event_source/devices/%s/type", sysfs, name);
102
103 if (stat(path, &st) < 0)
104 return -1;
105
106 file = fopen(path, "r");
107 if (!file)
108 return -EINVAL;
109
110 if (1 != fscanf(file, "%u", type))
111 ret = -1;
112
113 fclose(file);
114 return ret;
115}
116
117static struct perf_pmu *pmu_lookup(char *name)
118{
119 struct perf_pmu *pmu;
120 LIST_HEAD(format);
121 __u32 type;
122
123 /*
124 * The pmu data we store & need consists of the pmu
125 * type value and format definitions. Load both right
126 * now.
127 */
128 if (pmu_format(name, &format))
129 return NULL;
130
131 if (pmu_type(name, &type))
132 return NULL;
133
134 pmu = zalloc(sizeof(*pmu));
135 if (!pmu)
136 return NULL;
137
138 INIT_LIST_HEAD(&pmu->format);
139 list_splice(&format, &pmu->format);
140 pmu->name = strdup(name);
141 pmu->type = type;
142 return pmu;
143}
144
145static struct perf_pmu *pmu_find(char *name)
146{
147 struct perf_pmu *pmu;
148
149 list_for_each_entry(pmu, &pmus, list)
150 if (!strcmp(pmu->name, name))
151 return pmu;
152
153 return NULL;
154}
155
156struct perf_pmu *perf_pmu__find(char *name)
157{
158 struct perf_pmu *pmu;
159
160 /*
161 * Once PMU is loaded it stays in the list,
162 * so we keep us from multiple reading/parsing
163 * the pmu format definitions.
164 */
165 pmu = pmu_find(name);
166 if (pmu)
167 return pmu;
168
169 return pmu_lookup(name);
170}
171
172static struct perf_pmu__format*
173pmu_find_format(struct list_head *formats, char *name)
174{
175 struct perf_pmu__format *format;
176
177 list_for_each_entry(format, formats, list)
178 if (!strcmp(format->name, name))
179 return format;
180
181 return NULL;
182}
183
184/*
185 * Returns value based on the format definition (format parameter)
186 * and unformated value (value parameter).
187 *
188 * TODO maybe optimize a little ;)
189 */
190static __u64 pmu_format_value(unsigned long *format, __u64 value)
191{
192 unsigned long fbit, vbit;
193 __u64 v = 0;
194
195 for (fbit = 0, vbit = 0; fbit < PERF_PMU_FORMAT_BITS; fbit++) {
196
197 if (!test_bit(fbit, format))
198 continue;
199
200 if (!(value & (1llu << vbit++)))
201 continue;
202
203 v |= (1llu << fbit);
204 }
205
206 return v;
207}
208
209/*
210 * Setup one of config[12] attr members based on the
211 * user input data - temr parameter.
212 */
213static int pmu_config_term(struct list_head *formats,
214 struct perf_event_attr *attr,
215 struct parse_events__term *term)
216{
217 struct perf_pmu__format *format;
218 __u64 *vp;
219
220 /*
221 * Support only for hardcoded and numnerial terms.
222 * Hardcoded terms should be already in, so nothing
223 * to be done for them.
224 */
225 if (parse_events__is_hardcoded_term(term))
226 return 0;
227
228 if (term->type != PARSE_EVENTS__TERM_TYPE_NUM)
229 return -EINVAL;
230
231 format = pmu_find_format(formats, term->config);
232 if (!format)
233 return -EINVAL;
234
235 switch (format->value) {
236 case PERF_PMU_FORMAT_VALUE_CONFIG:
237 vp = &attr->config;
238 break;
239 case PERF_PMU_FORMAT_VALUE_CONFIG1:
240 vp = &attr->config1;
241 break;
242 case PERF_PMU_FORMAT_VALUE_CONFIG2:
243 vp = &attr->config2;
244 break;
245 default:
246 return -EINVAL;
247 }
248
249 *vp |= pmu_format_value(format->bits, term->val.num);
250 return 0;
251}
252
253static int pmu_config(struct list_head *formats, struct perf_event_attr *attr,
254 struct list_head *head_terms)
255{
256 struct parse_events__term *term, *h;
257
258 list_for_each_entry_safe(term, h, head_terms, list)
259 if (pmu_config_term(formats, attr, term))
260 return -EINVAL;
261
262 return 0;
263}
264
265/*
266 * Configures event's 'attr' parameter based on the:
267 * 1) users input - specified in terms parameter
268 * 2) pmu format definitions - specified by pmu parameter
269 */
270int perf_pmu__config(struct perf_pmu *pmu, struct perf_event_attr *attr,
271 struct list_head *head_terms)
272{
273 attr->type = pmu->type;
274 return pmu_config(&pmu->format, attr, head_terms);
275}
276
277int perf_pmu__new_format(struct list_head *list, char *name,
278 int config, unsigned long *bits)
279{
280 struct perf_pmu__format *format;
281
282 format = zalloc(sizeof(*format));
283 if (!format)
284 return -ENOMEM;
285
286 format->name = strdup(name);
287 format->value = config;
288 memcpy(format->bits, bits, sizeof(format->bits));
289
290 list_add_tail(&format->list, list);
291 return 0;
292}
293
294void perf_pmu__set_format(unsigned long *bits, long from, long to)
295{
296 long b;
297
298 if (!to)
299 to = from;
300
301 memset(bits, 0, BITS_TO_LONGS(PERF_PMU_FORMAT_BITS));
302 for (b = from; b <= to; b++)
303 set_bit(b, bits);
304}
305
306/* Simulated format definitions. */
307static struct test_format {
308 const char *name;
309 const char *value;
310} test_formats[] = {
311 { "krava01", "config:0-1,62-63\n", },
312 { "krava02", "config:10-17\n", },
313 { "krava03", "config:5\n", },
314 { "krava11", "config1:0,2,4,6,8,20-28\n", },
315 { "krava12", "config1:63\n", },
316 { "krava13", "config1:45-47\n", },
317 { "krava21", "config2:0-3,10-13,20-23,30-33,40-43,50-53,60-63\n", },
318 { "krava22", "config2:8,18,48,58\n", },
319 { "krava23", "config2:28-29,38\n", },
320};
321
322#define TEST_FORMATS_CNT (sizeof(test_formats) / sizeof(struct test_format))
323
324/* Simulated users input. */
325static struct parse_events__term test_terms[] = {
326 {
327 .config = (char *) "krava01",
328 .val.num = 15,
329 .type = PARSE_EVENTS__TERM_TYPE_NUM,
330 },
331 {
332 .config = (char *) "krava02",
333 .val.num = 170,
334 .type = PARSE_EVENTS__TERM_TYPE_NUM,
335 },
336 {
337 .config = (char *) "krava03",
338 .val.num = 1,
339 .type = PARSE_EVENTS__TERM_TYPE_NUM,
340 },
341 {
342 .config = (char *) "krava11",
343 .val.num = 27,
344 .type = PARSE_EVENTS__TERM_TYPE_NUM,
345 },
346 {
347 .config = (char *) "krava12",
348 .val.num = 1,
349 .type = PARSE_EVENTS__TERM_TYPE_NUM,
350 },
351 {
352 .config = (char *) "krava13",
353 .val.num = 2,
354 .type = PARSE_EVENTS__TERM_TYPE_NUM,
355 },
356 {
357 .config = (char *) "krava21",
358 .val.num = 119,
359 .type = PARSE_EVENTS__TERM_TYPE_NUM,
360 },
361 {
362 .config = (char *) "krava22",
363 .val.num = 11,
364 .type = PARSE_EVENTS__TERM_TYPE_NUM,
365 },
366 {
367 .config = (char *) "krava23",
368 .val.num = 2,
369 .type = PARSE_EVENTS__TERM_TYPE_NUM,
370 },
371};
372#define TERMS_CNT (sizeof(test_terms) / sizeof(struct parse_events__term))
373
374/*
375 * Prepare format directory data, exported by kernel
376 * at /sys/bus/event_source/devices/<dev>/format.
377 */
378static char *test_format_dir_get(void)
379{
380 static char dir[PATH_MAX];
381 unsigned int i;
382
383 snprintf(dir, PATH_MAX, "/tmp/perf-pmu-test-format-XXXXXX");
384 if (!mkdtemp(dir))
385 return NULL;
386
387 for (i = 0; i < TEST_FORMATS_CNT; i++) {
388 static char name[PATH_MAX];
389 struct test_format *format = &test_formats[i];
390 FILE *file;
391
392 snprintf(name, PATH_MAX, "%s/%s", dir, format->name);
393
394 file = fopen(name, "w");
395 if (!file)
396 return NULL;
397
398 if (1 != fwrite(format->value, strlen(format->value), 1, file))
399 break;
400
401 fclose(file);
402 }
403
404 return dir;
405}
406
407/* Cleanup format directory. */
408static int test_format_dir_put(char *dir)
409{
410 char buf[PATH_MAX];
411 snprintf(buf, PATH_MAX, "rm -f %s/*\n", dir);
412 if (system(buf))
413 return -1;
414
415 snprintf(buf, PATH_MAX, "rmdir %s\n", dir);
416 return system(buf);
417}
418
419static struct list_head *test_terms_list(void)
420{
421 static LIST_HEAD(terms);
422 unsigned int i;
423
424 for (i = 0; i < TERMS_CNT; i++)
425 list_add_tail(&test_terms[i].list, &terms);
426
427 return &terms;
428}
429
430#undef TERMS_CNT
431
432int perf_pmu__test(void)
433{
434 char *format = test_format_dir_get();
435 LIST_HEAD(formats);
436 struct list_head *terms = test_terms_list();
437 int ret;
438
439 if (!format)
440 return -EINVAL;
441
442 do {
443 struct perf_event_attr attr;
444
445 memset(&attr, 0, sizeof(attr));
446
447 ret = pmu_format_parse(format, &formats);
448 if (ret)
449 break;
450
451 ret = pmu_config(&formats, &attr, terms);
452 if (ret)
453 break;
454
455 ret = -EINVAL;
456
457 if (attr.config != 0xc00000000002a823)
458 break;
459 if (attr.config1 != 0x8000400000000145)
460 break;
461 if (attr.config2 != 0x0400000020041d07)
462 break;
463
464 ret = 0;
465 } while (0);
466
467 test_format_dir_put(format);
468 return ret;
469}
diff --git a/tools/perf/util/pmu.h b/tools/perf/util/pmu.h
new file mode 100644
index 000000000000..68c0db965e1f
--- /dev/null
+++ b/tools/perf/util/pmu.h
@@ -0,0 +1,41 @@
1#ifndef __PMU_H
2#define __PMU_H
3
4#include <linux/bitops.h>
5#include "../../../include/linux/perf_event.h"
6
7enum {
8 PERF_PMU_FORMAT_VALUE_CONFIG,
9 PERF_PMU_FORMAT_VALUE_CONFIG1,
10 PERF_PMU_FORMAT_VALUE_CONFIG2,
11};
12
13#define PERF_PMU_FORMAT_BITS 64
14
15struct perf_pmu__format {
16 char *name;
17 int value;
18 DECLARE_BITMAP(bits, PERF_PMU_FORMAT_BITS);
19 struct list_head list;
20};
21
22struct perf_pmu {
23 char *name;
24 __u32 type;
25 struct list_head format;
26 struct list_head list;
27};
28
29struct perf_pmu *perf_pmu__find(char *name);
30int perf_pmu__config(struct perf_pmu *pmu, struct perf_event_attr *attr,
31 struct list_head *head_terms);
32
33int perf_pmu_wrap(void);
34void perf_pmu_error(struct list_head *list, char *name, char const *msg);
35
36int perf_pmu__new_format(struct list_head *list, char *name,
37 int config, unsigned long *bits);
38void perf_pmu__set_format(unsigned long *bits, long from, long to);
39
40int perf_pmu__test(void);
41#endif /* __PMU_H */
diff --git a/tools/perf/util/pmu.l b/tools/perf/util/pmu.l
new file mode 100644
index 000000000000..a15d9fbd7c0e
--- /dev/null
+++ b/tools/perf/util/pmu.l
@@ -0,0 +1,43 @@
1%option prefix="perf_pmu_"
2
3%{
4#include <stdlib.h>
5#include <linux/bitops.h>
6#include "pmu.h"
7#include "pmu-bison.h"
8
9static int value(int base)
10{
11 long num;
12
13 errno = 0;
14 num = strtoul(perf_pmu_text, NULL, base);
15 if (errno)
16 return PP_ERROR;
17
18 perf_pmu_lval.num = num;
19 return PP_VALUE;
20}
21
22%}
23
24num_dec [0-9]+
25
26%%
27
28{num_dec} { return value(10); }
29config { return PP_CONFIG; }
30config1 { return PP_CONFIG1; }
31config2 { return PP_CONFIG2; }
32- { return '-'; }
33: { return ':'; }
34, { return ','; }
35. { ; }
36\n { ; }
37
38%%
39
40int perf_pmu_wrap(void)
41{
42 return 1;
43}
diff --git a/tools/perf/util/pmu.y b/tools/perf/util/pmu.y
new file mode 100644
index 000000000000..20ea77e93169
--- /dev/null
+++ b/tools/perf/util/pmu.y
@@ -0,0 +1,93 @@
1
2%name-prefix "perf_pmu_"
3%parse-param {struct list_head *format}
4%parse-param {char *name}
5
6%{
7
8#include <linux/compiler.h>
9#include <linux/list.h>
10#include <linux/bitmap.h>
11#include <string.h>
12#include "pmu.h"
13
14extern int perf_pmu_lex (void);
15
16#define ABORT_ON(val) \
17do { \
18 if (val) \
19 YYABORT; \
20} while (0)
21
22%}
23
24%token PP_CONFIG PP_CONFIG1 PP_CONFIG2
25%token PP_VALUE PP_ERROR
26%type <num> PP_VALUE
27%type <bits> bit_term
28%type <bits> bits
29
30%union
31{
32 unsigned long num;
33 DECLARE_BITMAP(bits, PERF_PMU_FORMAT_BITS);
34}
35
36%%
37
38format:
39format format_term
40|
41format_term
42
43format_term:
44PP_CONFIG ':' bits
45{
46 ABORT_ON(perf_pmu__new_format(format, name,
47 PERF_PMU_FORMAT_VALUE_CONFIG,
48 $3));
49}
50|
51PP_CONFIG1 ':' bits
52{
53 ABORT_ON(perf_pmu__new_format(format, name,
54 PERF_PMU_FORMAT_VALUE_CONFIG1,
55 $3));
56}
57|
58PP_CONFIG2 ':' bits
59{
60 ABORT_ON(perf_pmu__new_format(format, name,
61 PERF_PMU_FORMAT_VALUE_CONFIG2,
62 $3));
63}
64
65bits:
66bits ',' bit_term
67{
68 bitmap_or($$, $1, $3, 64);
69}
70|
71bit_term
72{
73 memcpy($$, $1, sizeof($1));
74}
75
76bit_term:
77PP_VALUE '-' PP_VALUE
78{
79 perf_pmu__set_format($$, $1, $3);
80}
81|
82PP_VALUE
83{
84 perf_pmu__set_format($$, $1, 0);
85}
86
87%%
88
89void perf_pmu_error(struct list_head *list __used,
90 char *name __used,
91 char const *msg __used)
92{
93}
diff --git a/tools/perf/util/probe-event.c b/tools/perf/util/probe-event.c
index e33554a562b3..8a8ee64e72d1 100644
--- a/tools/perf/util/probe-event.c
+++ b/tools/perf/util/probe-event.c
@@ -34,7 +34,6 @@
34 34
35#include "util.h" 35#include "util.h"
36#include "event.h" 36#include "event.h"
37#include "string.h"
38#include "strlist.h" 37#include "strlist.h"
39#include "debug.h" 38#include "debug.h"
40#include "cache.h" 39#include "cache.h"
@@ -273,10 +272,10 @@ static int add_module_to_probe_trace_events(struct probe_trace_event *tevs,
273/* Try to find perf_probe_event with debuginfo */ 272/* Try to find perf_probe_event with debuginfo */
274static int try_to_find_probe_trace_events(struct perf_probe_event *pev, 273static int try_to_find_probe_trace_events(struct perf_probe_event *pev,
275 struct probe_trace_event **tevs, 274 struct probe_trace_event **tevs,
276 int max_tevs, const char *module) 275 int max_tevs, const char *target)
277{ 276{
278 bool need_dwarf = perf_probe_event_need_dwarf(pev); 277 bool need_dwarf = perf_probe_event_need_dwarf(pev);
279 struct debuginfo *dinfo = open_debuginfo(module); 278 struct debuginfo *dinfo = open_debuginfo(target);
280 int ntevs, ret = 0; 279 int ntevs, ret = 0;
281 280
282 if (!dinfo) { 281 if (!dinfo) {
@@ -295,9 +294,9 @@ static int try_to_find_probe_trace_events(struct perf_probe_event *pev,
295 294
296 if (ntevs > 0) { /* Succeeded to find trace events */ 295 if (ntevs > 0) { /* Succeeded to find trace events */
297 pr_debug("find %d probe_trace_events.\n", ntevs); 296 pr_debug("find %d probe_trace_events.\n", ntevs);
298 if (module) 297 if (target)
299 ret = add_module_to_probe_trace_events(*tevs, ntevs, 298 ret = add_module_to_probe_trace_events(*tevs, ntevs,
300 module); 299 target);
301 return ret < 0 ? ret : ntevs; 300 return ret < 0 ? ret : ntevs;
302 } 301 }
303 302
@@ -1729,7 +1728,7 @@ static int __add_probe_trace_events(struct perf_probe_event *pev,
1729 } 1728 }
1730 1729
1731 ret = 0; 1730 ret = 0;
1732 printf("Add new event%s\n", (ntevs > 1) ? "s:" : ":"); 1731 printf("Added new event%s\n", (ntevs > 1) ? "s:" : ":");
1733 for (i = 0; i < ntevs; i++) { 1732 for (i = 0; i < ntevs; i++) {
1734 tev = &tevs[i]; 1733 tev = &tevs[i];
1735 if (pev->event) 1734 if (pev->event)
@@ -1784,7 +1783,7 @@ static int __add_probe_trace_events(struct perf_probe_event *pev,
1784 1783
1785 if (ret >= 0) { 1784 if (ret >= 0) {
1786 /* Show how to use the event. */ 1785 /* Show how to use the event. */
1787 printf("\nYou can now use it on all perf tools, such as:\n\n"); 1786 printf("\nYou can now use it in all perf tools, such as:\n\n");
1788 printf("\tperf record -e %s:%s -aR sleep 1\n\n", tev->group, 1787 printf("\tperf record -e %s:%s -aR sleep 1\n\n", tev->group,
1789 tev->event); 1788 tev->event);
1790 } 1789 }
@@ -1796,14 +1795,14 @@ static int __add_probe_trace_events(struct perf_probe_event *pev,
1796 1795
1797static int convert_to_probe_trace_events(struct perf_probe_event *pev, 1796static int convert_to_probe_trace_events(struct perf_probe_event *pev,
1798 struct probe_trace_event **tevs, 1797 struct probe_trace_event **tevs,
1799 int max_tevs, const char *module) 1798 int max_tevs, const char *target)
1800{ 1799{
1801 struct symbol *sym; 1800 struct symbol *sym;
1802 int ret = 0, i; 1801 int ret = 0, i;
1803 struct probe_trace_event *tev; 1802 struct probe_trace_event *tev;
1804 1803
1805 /* Convert perf_probe_event with debuginfo */ 1804 /* Convert perf_probe_event with debuginfo */
1806 ret = try_to_find_probe_trace_events(pev, tevs, max_tevs, module); 1805 ret = try_to_find_probe_trace_events(pev, tevs, max_tevs, target);
1807 if (ret != 0) 1806 if (ret != 0)
1808 return ret; /* Found in debuginfo or got an error */ 1807 return ret; /* Found in debuginfo or got an error */
1809 1808
@@ -1819,8 +1818,8 @@ static int convert_to_probe_trace_events(struct perf_probe_event *pev,
1819 goto error; 1818 goto error;
1820 } 1819 }
1821 1820
1822 if (module) { 1821 if (target) {
1823 tev->point.module = strdup(module); 1822 tev->point.module = strdup(target);
1824 if (tev->point.module == NULL) { 1823 if (tev->point.module == NULL) {
1825 ret = -ENOMEM; 1824 ret = -ENOMEM;
1826 goto error; 1825 goto error;
@@ -1890,7 +1889,7 @@ struct __event_package {
1890}; 1889};
1891 1890
1892int add_perf_probe_events(struct perf_probe_event *pevs, int npevs, 1891int add_perf_probe_events(struct perf_probe_event *pevs, int npevs,
1893 int max_tevs, const char *module, bool force_add) 1892 int max_tevs, const char *target, bool force_add)
1894{ 1893{
1895 int i, j, ret; 1894 int i, j, ret;
1896 struct __event_package *pkgs; 1895 struct __event_package *pkgs;
@@ -1913,7 +1912,7 @@ int add_perf_probe_events(struct perf_probe_event *pevs, int npevs,
1913 ret = convert_to_probe_trace_events(pkgs[i].pev, 1912 ret = convert_to_probe_trace_events(pkgs[i].pev,
1914 &pkgs[i].tevs, 1913 &pkgs[i].tevs,
1915 max_tevs, 1914 max_tevs,
1916 module); 1915 target);
1917 if (ret < 0) 1916 if (ret < 0)
1918 goto end; 1917 goto end;
1919 pkgs[i].ntevs = ret; 1918 pkgs[i].ntevs = ret;
@@ -1965,7 +1964,7 @@ static int __del_trace_probe_event(int fd, struct str_node *ent)
1965 goto error; 1964 goto error;
1966 } 1965 }
1967 1966
1968 printf("Remove event: %s\n", ent->s); 1967 printf("Removed event: %s\n", ent->s);
1969 return 0; 1968 return 0;
1970error: 1969error:
1971 pr_warning("Failed to delete event: %s\n", strerror(-ret)); 1970 pr_warning("Failed to delete event: %s\n", strerror(-ret));
@@ -2069,7 +2068,7 @@ static int filter_available_functions(struct map *map __unused,
2069 return 1; 2068 return 1;
2070} 2069}
2071 2070
2072int show_available_funcs(const char *module, struct strfilter *_filter) 2071int show_available_funcs(const char *target, struct strfilter *_filter)
2073{ 2072{
2074 struct map *map; 2073 struct map *map;
2075 int ret; 2074 int ret;
@@ -2080,9 +2079,9 @@ int show_available_funcs(const char *module, struct strfilter *_filter)
2080 if (ret < 0) 2079 if (ret < 0)
2081 return ret; 2080 return ret;
2082 2081
2083 map = kernel_get_module_map(module); 2082 map = kernel_get_module_map(target);
2084 if (!map) { 2083 if (!map) {
2085 pr_err("Failed to find %s map.\n", (module) ? : "kernel"); 2084 pr_err("Failed to find %s map.\n", (target) ? : "kernel");
2086 return -EINVAL; 2085 return -EINVAL;
2087 } 2086 }
2088 available_func_filter = _filter; 2087 available_func_filter = _filter;
diff --git a/tools/perf/util/probe-finder.c b/tools/perf/util/probe-finder.c
index 74bd2e63c4b4..2cc162d3b78c 100644
--- a/tools/perf/util/probe-finder.c
+++ b/tools/perf/util/probe-finder.c
@@ -30,7 +30,6 @@
30#include <stdlib.h> 30#include <stdlib.h>
31#include <string.h> 31#include <string.h>
32#include <stdarg.h> 32#include <stdarg.h>
33#include <ctype.h>
34#include <dwarf-regs.h> 33#include <dwarf-regs.h>
35 34
36#include <linux/bitops.h> 35#include <linux/bitops.h>
diff --git a/tools/perf/util/python-ext-sources b/tools/perf/util/python-ext-sources
new file mode 100644
index 000000000000..2884e67ee625
--- /dev/null
+++ b/tools/perf/util/python-ext-sources
@@ -0,0 +1,19 @@
1#
2# List of files needed by perf python extention
3#
4# Each source file must be placed on its own line so that it can be
5# processed by Makefile and util/setup.py accordingly.
6#
7
8util/python.c
9util/ctype.c
10util/evlist.c
11util/evsel.c
12util/cpumap.c
13util/thread_map.c
14util/util.c
15util/xyarray.c
16util/cgroup.c
17util/debugfs.c
18util/strlist.c
19../../lib/rbtree.c
diff --git a/tools/perf/util/python.c b/tools/perf/util/python.c
index 9dd47a4f2596..e03b58a48424 100644
--- a/tools/perf/util/python.c
+++ b/tools/perf/util/python.c
@@ -425,14 +425,14 @@ struct pyrf_thread_map {
425static int pyrf_thread_map__init(struct pyrf_thread_map *pthreads, 425static int pyrf_thread_map__init(struct pyrf_thread_map *pthreads,
426 PyObject *args, PyObject *kwargs) 426 PyObject *args, PyObject *kwargs)
427{ 427{
428 static char *kwlist[] = { "pid", "tid", NULL }; 428 static char *kwlist[] = { "pid", "tid", "uid", NULL };
429 int pid = -1, tid = -1; 429 int pid = -1, tid = -1, uid = UINT_MAX;
430 430
431 if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|ii", 431 if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|iii",
432 kwlist, &pid, &tid)) 432 kwlist, &pid, &tid, &uid))
433 return -1; 433 return -1;
434 434
435 pthreads->threads = thread_map__new(pid, tid); 435 pthreads->threads = thread_map__new(pid, tid, uid);
436 if (pthreads->threads == NULL) 436 if (pthreads->threads == NULL)
437 return -1; 437 return -1;
438 return 0; 438 return 0;
diff --git a/tools/perf/util/scripting-engines/trace-event-python.c b/tools/perf/util/scripting-engines/trace-event-python.c
index 0b2a48783172..c2623c6f9b51 100644
--- a/tools/perf/util/scripting-engines/trace-event-python.c
+++ b/tools/perf/util/scripting-engines/trace-event-python.c
@@ -24,7 +24,6 @@
24#include <stdio.h> 24#include <stdio.h>
25#include <stdlib.h> 25#include <stdlib.h>
26#include <string.h> 26#include <string.h>
27#include <ctype.h>
28#include <errno.h> 27#include <errno.h>
29 28
30#include "../../perf.h" 29#include "../../perf.h"
diff --git a/tools/perf/util/session.c b/tools/perf/util/session.c
index b5ca2558c7bb..9412e3b05f68 100644
--- a/tools/perf/util/session.c
+++ b/tools/perf/util/session.c
@@ -24,7 +24,7 @@ static int perf_session__open(struct perf_session *self, bool force)
24 self->fd = STDIN_FILENO; 24 self->fd = STDIN_FILENO;
25 25
26 if (perf_session__read_header(self, self->fd) < 0) 26 if (perf_session__read_header(self, self->fd) < 0)
27 pr_err("incompatible file format"); 27 pr_err("incompatible file format (rerun with -v to learn more)");
28 28
29 return 0; 29 return 0;
30 } 30 }
@@ -56,7 +56,7 @@ static int perf_session__open(struct perf_session *self, bool force)
56 } 56 }
57 57
58 if (perf_session__read_header(self, self->fd) < 0) { 58 if (perf_session__read_header(self, self->fd) < 0) {
59 pr_err("incompatible file format"); 59 pr_err("incompatible file format (rerun with -v to learn more)");
60 goto out_close; 60 goto out_close;
61 } 61 }
62 62
@@ -140,6 +140,7 @@ struct perf_session *perf_session__new(const char *filename, int mode,
140 INIT_LIST_HEAD(&self->ordered_samples.sample_cache); 140 INIT_LIST_HEAD(&self->ordered_samples.sample_cache);
141 INIT_LIST_HEAD(&self->ordered_samples.to_free); 141 INIT_LIST_HEAD(&self->ordered_samples.to_free);
142 machine__init(&self->host_machine, "", HOST_KERNEL_ID); 142 machine__init(&self->host_machine, "", HOST_KERNEL_ID);
143 hists__init(&self->hists);
143 144
144 if (mode == O_RDONLY) { 145 if (mode == O_RDONLY) {
145 if (perf_session__open(self, force) < 0) 146 if (perf_session__open(self, force) < 0)
@@ -229,6 +230,64 @@ static bool symbol__match_parent_regex(struct symbol *sym)
229 return 0; 230 return 0;
230} 231}
231 232
233static const u8 cpumodes[] = {
234 PERF_RECORD_MISC_USER,
235 PERF_RECORD_MISC_KERNEL,
236 PERF_RECORD_MISC_GUEST_USER,
237 PERF_RECORD_MISC_GUEST_KERNEL
238};
239#define NCPUMODES (sizeof(cpumodes)/sizeof(u8))
240
241static void ip__resolve_ams(struct machine *self, struct thread *thread,
242 struct addr_map_symbol *ams,
243 u64 ip)
244{
245 struct addr_location al;
246 size_t i;
247 u8 m;
248
249 memset(&al, 0, sizeof(al));
250
251 for (i = 0; i < NCPUMODES; i++) {
252 m = cpumodes[i];
253 /*
254 * We cannot use the header.misc hint to determine whether a
255 * branch stack address is user, kernel, guest, hypervisor.
256 * Branches may straddle the kernel/user/hypervisor boundaries.
257 * Thus, we have to try consecutively until we find a match
258 * or else, the symbol is unknown
259 */
260 thread__find_addr_location(thread, self, m, MAP__FUNCTION,
261 ip, &al, NULL);
262 if (al.sym)
263 goto found;
264 }
265found:
266 ams->addr = ip;
267 ams->al_addr = al.addr;
268 ams->sym = al.sym;
269 ams->map = al.map;
270}
271
272struct branch_info *machine__resolve_bstack(struct machine *self,
273 struct thread *thr,
274 struct branch_stack *bs)
275{
276 struct branch_info *bi;
277 unsigned int i;
278
279 bi = calloc(bs->nr, sizeof(struct branch_info));
280 if (!bi)
281 return NULL;
282
283 for (i = 0; i < bs->nr; i++) {
284 ip__resolve_ams(self, thr, &bi[i].to, bs->entries[i].to);
285 ip__resolve_ams(self, thr, &bi[i].from, bs->entries[i].from);
286 bi[i].flags = bs->entries[i].flags;
287 }
288 return bi;
289}
290
232int machine__resolve_callchain(struct machine *self, struct perf_evsel *evsel, 291int machine__resolve_callchain(struct machine *self, struct perf_evsel *evsel,
233 struct thread *thread, 292 struct thread *thread,
234 struct ip_callchain *chain, 293 struct ip_callchain *chain,
@@ -697,6 +756,18 @@ static void callchain__printf(struct perf_sample *sample)
697 i, sample->callchain->ips[i]); 756 i, sample->callchain->ips[i]);
698} 757}
699 758
759static void branch_stack__printf(struct perf_sample *sample)
760{
761 uint64_t i;
762
763 printf("... branch stack: nr:%" PRIu64 "\n", sample->branch_stack->nr);
764
765 for (i = 0; i < sample->branch_stack->nr; i++)
766 printf("..... %2"PRIu64": %016" PRIx64 " -> %016" PRIx64 "\n",
767 i, sample->branch_stack->entries[i].from,
768 sample->branch_stack->entries[i].to);
769}
770
700static void perf_session__print_tstamp(struct perf_session *session, 771static void perf_session__print_tstamp(struct perf_session *session,
701 union perf_event *event, 772 union perf_event *event,
702 struct perf_sample *sample) 773 struct perf_sample *sample)
@@ -744,6 +815,9 @@ static void dump_sample(struct perf_session *session, union perf_event *event,
744 815
745 if (session->sample_type & PERF_SAMPLE_CALLCHAIN) 816 if (session->sample_type & PERF_SAMPLE_CALLCHAIN)
746 callchain__printf(sample); 817 callchain__printf(sample);
818
819 if (session->sample_type & PERF_SAMPLE_BRANCH_STACK)
820 branch_stack__printf(sample);
747} 821}
748 822
749static struct machine * 823static struct machine *
@@ -796,6 +870,10 @@ static int perf_session_deliver_event(struct perf_session *session,
796 ++session->hists.stats.nr_unknown_id; 870 ++session->hists.stats.nr_unknown_id;
797 return -1; 871 return -1;
798 } 872 }
873 if (machine == NULL) {
874 ++session->hists.stats.nr_unprocessable_samples;
875 return -1;
876 }
799 return tool->sample(tool, event, sample, evsel, machine); 877 return tool->sample(tool, event, sample, evsel, machine);
800 case PERF_RECORD_MMAP: 878 case PERF_RECORD_MMAP:
801 return tool->mmap(tool, event, sample, machine); 879 return tool->mmap(tool, event, sample, machine);
@@ -964,6 +1042,12 @@ static void perf_session__warn_about_errors(const struct perf_session *session,
964 session->hists.stats.nr_invalid_chains, 1042 session->hists.stats.nr_invalid_chains,
965 session->hists.stats.nr_events[PERF_RECORD_SAMPLE]); 1043 session->hists.stats.nr_events[PERF_RECORD_SAMPLE]);
966 } 1044 }
1045
1046 if (session->hists.stats.nr_unprocessable_samples != 0) {
1047 ui__warning("%u unprocessable samples recorded.\n"
1048 "Do you have a KVM guest running and not using 'perf kvm'?\n",
1049 session->hists.stats.nr_unprocessable_samples);
1050 }
967} 1051}
968 1052
969#define session_done() (*(volatile int *)(&session_done)) 1053#define session_done() (*(volatile int *)(&session_done))
@@ -1293,10 +1377,9 @@ struct perf_evsel *perf_session__find_first_evtype(struct perf_session *session,
1293 1377
1294void perf_event__print_ip(union perf_event *event, struct perf_sample *sample, 1378void perf_event__print_ip(union perf_event *event, struct perf_sample *sample,
1295 struct machine *machine, struct perf_evsel *evsel, 1379 struct machine *machine, struct perf_evsel *evsel,
1296 int print_sym, int print_dso) 1380 int print_sym, int print_dso, int print_symoffset)
1297{ 1381{
1298 struct addr_location al; 1382 struct addr_location al;
1299 const char *symname, *dsoname;
1300 struct callchain_cursor *cursor = &evsel->hists.callchain_cursor; 1383 struct callchain_cursor *cursor = &evsel->hists.callchain_cursor;
1301 struct callchain_cursor_node *node; 1384 struct callchain_cursor_node *node;
1302 1385
@@ -1324,20 +1407,13 @@ void perf_event__print_ip(union perf_event *event, struct perf_sample *sample,
1324 1407
1325 printf("\t%16" PRIx64, node->ip); 1408 printf("\t%16" PRIx64, node->ip);
1326 if (print_sym) { 1409 if (print_sym) {
1327 if (node->sym && node->sym->name) 1410 printf(" ");
1328 symname = node->sym->name; 1411 symbol__fprintf_symname(node->sym, stdout);
1329 else
1330 symname = "";
1331
1332 printf(" %s", symname);
1333 } 1412 }
1334 if (print_dso) { 1413 if (print_dso) {
1335 if (node->map && node->map->dso && node->map->dso->name) 1414 printf(" (");
1336 dsoname = node->map->dso->name; 1415 map__fprintf_dsoname(al.map, stdout);
1337 else 1416 printf(")");
1338 dsoname = "";
1339
1340 printf(" (%s)", dsoname);
1341 } 1417 }
1342 printf("\n"); 1418 printf("\n");
1343 1419
@@ -1347,21 +1423,18 @@ void perf_event__print_ip(union perf_event *event, struct perf_sample *sample,
1347 } else { 1423 } else {
1348 printf("%16" PRIx64, sample->ip); 1424 printf("%16" PRIx64, sample->ip);
1349 if (print_sym) { 1425 if (print_sym) {
1350 if (al.sym && al.sym->name) 1426 printf(" ");
1351 symname = al.sym->name; 1427 if (print_symoffset)
1428 symbol__fprintf_symname_offs(al.sym, &al,
1429 stdout);
1352 else 1430 else
1353 symname = ""; 1431 symbol__fprintf_symname(al.sym, stdout);
1354
1355 printf(" %s", symname);
1356 } 1432 }
1357 1433
1358 if (print_dso) { 1434 if (print_dso) {
1359 if (al.map && al.map->dso && al.map->dso->name) 1435 printf(" (");
1360 dsoname = al.map->dso->name; 1436 map__fprintf_dsoname(al.map, stdout);
1361 else 1437 printf(")");
1362 dsoname = "";
1363
1364 printf(" (%s)", dsoname);
1365 } 1438 }
1366 } 1439 }
1367} 1440}
diff --git a/tools/perf/util/session.h b/tools/perf/util/session.h
index 37bc38381fb6..7a5434c00565 100644
--- a/tools/perf/util/session.h
+++ b/tools/perf/util/session.h
@@ -73,6 +73,10 @@ int perf_session__resolve_callchain(struct perf_session *self, struct perf_evsel
73 struct ip_callchain *chain, 73 struct ip_callchain *chain,
74 struct symbol **parent); 74 struct symbol **parent);
75 75
76struct branch_info *machine__resolve_bstack(struct machine *self,
77 struct thread *thread,
78 struct branch_stack *bs);
79
76bool perf_session__has_traces(struct perf_session *self, const char *msg); 80bool perf_session__has_traces(struct perf_session *self, const char *msg);
77 81
78void mem_bswap_64(void *src, int byte_size); 82void mem_bswap_64(void *src, int byte_size);
@@ -147,7 +151,7 @@ struct perf_evsel *perf_session__find_first_evtype(struct perf_session *session,
147 151
148void perf_event__print_ip(union perf_event *event, struct perf_sample *sample, 152void perf_event__print_ip(union perf_event *event, struct perf_sample *sample,
149 struct machine *machine, struct perf_evsel *evsel, 153 struct machine *machine, struct perf_evsel *evsel,
150 int print_sym, int print_dso); 154 int print_sym, int print_dso, int print_symoffset);
151 155
152int perf_session__cpu_bitmap(struct perf_session *session, 156int perf_session__cpu_bitmap(struct perf_session *session,
153 const char *cpu_list, unsigned long *cpu_bitmap); 157 const char *cpu_list, unsigned long *cpu_bitmap);
diff --git a/tools/perf/util/setup.py b/tools/perf/util/setup.py
index 36d4c5619575..d0f9f29cf181 100644
--- a/tools/perf/util/setup.py
+++ b/tools/perf/util/setup.py
@@ -24,11 +24,11 @@ cflags += getenv('CFLAGS', '').split()
24build_lib = getenv('PYTHON_EXTBUILD_LIB') 24build_lib = getenv('PYTHON_EXTBUILD_LIB')
25build_tmp = getenv('PYTHON_EXTBUILD_TMP') 25build_tmp = getenv('PYTHON_EXTBUILD_TMP')
26 26
27ext_sources = [f.strip() for f in file('util/python-ext-sources')
28 if len(f.strip()) > 0 and f[0] != '#']
29
27perf = Extension('perf', 30perf = Extension('perf',
28 sources = ['util/python.c', 'util/ctype.c', 'util/evlist.c', 31 sources = ext_sources,
29 'util/evsel.c', 'util/cpumap.c', 'util/thread_map.c',
30 'util/util.c', 'util/xyarray.c', 'util/cgroup.c',
31 'util/debugfs.c'],
32 include_dirs = ['util/include'], 32 include_dirs = ['util/include'],
33 extra_compile_args = cflags, 33 extra_compile_args = cflags,
34 ) 34 )
diff --git a/tools/perf/util/sort.c b/tools/perf/util/sort.c
index 076c9d4e1ea4..a27237430c5f 100644
--- a/tools/perf/util/sort.c
+++ b/tools/perf/util/sort.c
@@ -8,6 +8,7 @@ const char default_sort_order[] = "comm,dso,symbol";
8const char *sort_order = default_sort_order; 8const char *sort_order = default_sort_order;
9int sort__need_collapse = 0; 9int sort__need_collapse = 0;
10int sort__has_parent = 0; 10int sort__has_parent = 0;
11int sort__branch_mode = -1; /* -1 = means not set */
11 12
12enum sort_type sort__first_dimension; 13enum sort_type sort__first_dimension;
13 14
@@ -97,6 +98,26 @@ static int hist_entry__comm_snprintf(struct hist_entry *self, char *bf,
97 return repsep_snprintf(bf, size, "%*s", width, self->thread->comm); 98 return repsep_snprintf(bf, size, "%*s", width, self->thread->comm);
98} 99}
99 100
101static int64_t _sort__dso_cmp(struct map *map_l, struct map *map_r)
102{
103 struct dso *dso_l = map_l ? map_l->dso : NULL;
104 struct dso *dso_r = map_r ? map_r->dso : NULL;
105 const char *dso_name_l, *dso_name_r;
106
107 if (!dso_l || !dso_r)
108 return cmp_null(dso_l, dso_r);
109
110 if (verbose) {
111 dso_name_l = dso_l->long_name;
112 dso_name_r = dso_r->long_name;
113 } else {
114 dso_name_l = dso_l->short_name;
115 dso_name_r = dso_r->short_name;
116 }
117
118 return strcmp(dso_name_l, dso_name_r);
119}
120
100struct sort_entry sort_comm = { 121struct sort_entry sort_comm = {
101 .se_header = "Command", 122 .se_header = "Command",
102 .se_cmp = sort__comm_cmp, 123 .se_cmp = sort__comm_cmp,
@@ -110,36 +131,74 @@ struct sort_entry sort_comm = {
110static int64_t 131static int64_t
111sort__dso_cmp(struct hist_entry *left, struct hist_entry *right) 132sort__dso_cmp(struct hist_entry *left, struct hist_entry *right)
112{ 133{
113 struct dso *dso_l = left->ms.map ? left->ms.map->dso : NULL; 134 return _sort__dso_cmp(left->ms.map, right->ms.map);
114 struct dso *dso_r = right->ms.map ? right->ms.map->dso : NULL; 135}
115 const char *dso_name_l, *dso_name_r;
116 136
117 if (!dso_l || !dso_r)
118 return cmp_null(dso_l, dso_r);
119 137
120 if (verbose) { 138static int64_t _sort__sym_cmp(struct symbol *sym_l, struct symbol *sym_r,
121 dso_name_l = dso_l->long_name; 139 u64 ip_l, u64 ip_r)
122 dso_name_r = dso_r->long_name; 140{
123 } else { 141 if (!sym_l || !sym_r)
124 dso_name_l = dso_l->short_name; 142 return cmp_null(sym_l, sym_r);
125 dso_name_r = dso_r->short_name; 143
144 if (sym_l == sym_r)
145 return 0;
146
147 if (sym_l)
148 ip_l = sym_l->start;
149 if (sym_r)
150 ip_r = sym_r->start;
151
152 return (int64_t)(ip_r - ip_l);
153}
154
155static int _hist_entry__dso_snprintf(struct map *map, char *bf,
156 size_t size, unsigned int width)
157{
158 if (map && map->dso) {
159 const char *dso_name = !verbose ? map->dso->short_name :
160 map->dso->long_name;
161 return repsep_snprintf(bf, size, "%-*s", width, dso_name);
126 } 162 }
127 163
128 return strcmp(dso_name_l, dso_name_r); 164 return repsep_snprintf(bf, size, "%-*s", width, "[unknown]");
129} 165}
130 166
131static int hist_entry__dso_snprintf(struct hist_entry *self, char *bf, 167static int hist_entry__dso_snprintf(struct hist_entry *self, char *bf,
132 size_t size, unsigned int width) 168 size_t size, unsigned int width)
133{ 169{
134 if (self->ms.map && self->ms.map->dso) { 170 return _hist_entry__dso_snprintf(self->ms.map, bf, size, width);
135 const char *dso_name = !verbose ? self->ms.map->dso->short_name : 171}
136 self->ms.map->dso->long_name; 172
137 return repsep_snprintf(bf, size, "%-*s", width, dso_name); 173static int _hist_entry__sym_snprintf(struct map *map, struct symbol *sym,
174 u64 ip, char level, char *bf, size_t size,
175 unsigned int width __used)
176{
177 size_t ret = 0;
178
179 if (verbose) {
180 char o = map ? dso__symtab_origin(map->dso) : '!';
181 ret += repsep_snprintf(bf, size, "%-#*llx %c ",
182 BITS_PER_LONG / 4, ip, o);
138 } 183 }
139 184
140 return repsep_snprintf(bf, size, "%-*s", width, "[unknown]"); 185 ret += repsep_snprintf(bf + ret, size - ret, "[%c] ", level);
186 if (sym)
187 ret += repsep_snprintf(bf + ret, size - ret, "%-*s",
188 width - ret,
189 sym->name);
190 else {
191 size_t len = BITS_PER_LONG / 4;
192 ret += repsep_snprintf(bf + ret, size - ret, "%-#.*llx",
193 len, ip);
194 ret += repsep_snprintf(bf + ret, size - ret, "%-*s",
195 width - ret, "");
196 }
197
198 return ret;
141} 199}
142 200
201
143struct sort_entry sort_dso = { 202struct sort_entry sort_dso = {
144 .se_header = "Shared Object", 203 .se_header = "Shared Object",
145 .se_cmp = sort__dso_cmp, 204 .se_cmp = sort__dso_cmp,
@@ -147,8 +206,14 @@ struct sort_entry sort_dso = {
147 .se_width_idx = HISTC_DSO, 206 .se_width_idx = HISTC_DSO,
148}; 207};
149 208
150/* --sort symbol */ 209static int hist_entry__sym_snprintf(struct hist_entry *self, char *bf,
210 size_t size, unsigned int width __used)
211{
212 return _hist_entry__sym_snprintf(self->ms.map, self->ms.sym, self->ip,
213 self->level, bf, size, width);
214}
151 215
216/* --sort symbol */
152static int64_t 217static int64_t
153sort__sym_cmp(struct hist_entry *left, struct hist_entry *right) 218sort__sym_cmp(struct hist_entry *left, struct hist_entry *right)
154{ 219{
@@ -166,31 +231,7 @@ sort__sym_cmp(struct hist_entry *left, struct hist_entry *right)
166 ip_l = left->ms.sym->start; 231 ip_l = left->ms.sym->start;
167 ip_r = right->ms.sym->start; 232 ip_r = right->ms.sym->start;
168 233
169 return (int64_t)(ip_r - ip_l); 234 return _sort__sym_cmp(left->ms.sym, right->ms.sym, ip_l, ip_r);
170}
171
172static int hist_entry__sym_snprintf(struct hist_entry *self, char *bf,
173 size_t size, unsigned int width __used)
174{
175 size_t ret = 0;
176
177 if (verbose) {
178 char o = self->ms.map ? dso__symtab_origin(self->ms.map->dso) : '!';
179 ret += repsep_snprintf(bf, size, "%-#*llx %c ",
180 BITS_PER_LONG / 4, self->ip, o);
181 }
182
183 if (!sort_dso.elide)
184 ret += repsep_snprintf(bf + ret, size - ret, "[%c] ", self->level);
185
186 if (self->ms.sym)
187 ret += repsep_snprintf(bf + ret, size - ret, "%s",
188 self->ms.sym->name);
189 else
190 ret += repsep_snprintf(bf + ret, size - ret, "%-#*llx",
191 BITS_PER_LONG / 4, self->ip);
192
193 return ret;
194} 235}
195 236
196struct sort_entry sort_sym = { 237struct sort_entry sort_sym = {
@@ -249,19 +290,155 @@ struct sort_entry sort_cpu = {
249 .se_width_idx = HISTC_CPU, 290 .se_width_idx = HISTC_CPU,
250}; 291};
251 292
293static int64_t
294sort__dso_from_cmp(struct hist_entry *left, struct hist_entry *right)
295{
296 return _sort__dso_cmp(left->branch_info->from.map,
297 right->branch_info->from.map);
298}
299
300static int hist_entry__dso_from_snprintf(struct hist_entry *self, char *bf,
301 size_t size, unsigned int width)
302{
303 return _hist_entry__dso_snprintf(self->branch_info->from.map,
304 bf, size, width);
305}
306
307struct sort_entry sort_dso_from = {
308 .se_header = "Source Shared Object",
309 .se_cmp = sort__dso_from_cmp,
310 .se_snprintf = hist_entry__dso_from_snprintf,
311 .se_width_idx = HISTC_DSO_FROM,
312};
313
314static int64_t
315sort__dso_to_cmp(struct hist_entry *left, struct hist_entry *right)
316{
317 return _sort__dso_cmp(left->branch_info->to.map,
318 right->branch_info->to.map);
319}
320
321static int hist_entry__dso_to_snprintf(struct hist_entry *self, char *bf,
322 size_t size, unsigned int width)
323{
324 return _hist_entry__dso_snprintf(self->branch_info->to.map,
325 bf, size, width);
326}
327
328static int64_t
329sort__sym_from_cmp(struct hist_entry *left, struct hist_entry *right)
330{
331 struct addr_map_symbol *from_l = &left->branch_info->from;
332 struct addr_map_symbol *from_r = &right->branch_info->from;
333
334 if (!from_l->sym && !from_r->sym)
335 return right->level - left->level;
336
337 return _sort__sym_cmp(from_l->sym, from_r->sym, from_l->addr,
338 from_r->addr);
339}
340
341static int64_t
342sort__sym_to_cmp(struct hist_entry *left, struct hist_entry *right)
343{
344 struct addr_map_symbol *to_l = &left->branch_info->to;
345 struct addr_map_symbol *to_r = &right->branch_info->to;
346
347 if (!to_l->sym && !to_r->sym)
348 return right->level - left->level;
349
350 return _sort__sym_cmp(to_l->sym, to_r->sym, to_l->addr, to_r->addr);
351}
352
353static int hist_entry__sym_from_snprintf(struct hist_entry *self, char *bf,
354 size_t size, unsigned int width __used)
355{
356 struct addr_map_symbol *from = &self->branch_info->from;
357 return _hist_entry__sym_snprintf(from->map, from->sym, from->addr,
358 self->level, bf, size, width);
359
360}
361
362static int hist_entry__sym_to_snprintf(struct hist_entry *self, char *bf,
363 size_t size, unsigned int width __used)
364{
365 struct addr_map_symbol *to = &self->branch_info->to;
366 return _hist_entry__sym_snprintf(to->map, to->sym, to->addr,
367 self->level, bf, size, width);
368
369}
370
371struct sort_entry sort_dso_to = {
372 .se_header = "Target Shared Object",
373 .se_cmp = sort__dso_to_cmp,
374 .se_snprintf = hist_entry__dso_to_snprintf,
375 .se_width_idx = HISTC_DSO_TO,
376};
377
378struct sort_entry sort_sym_from = {
379 .se_header = "Source Symbol",
380 .se_cmp = sort__sym_from_cmp,
381 .se_snprintf = hist_entry__sym_from_snprintf,
382 .se_width_idx = HISTC_SYMBOL_FROM,
383};
384
385struct sort_entry sort_sym_to = {
386 .se_header = "Target Symbol",
387 .se_cmp = sort__sym_to_cmp,
388 .se_snprintf = hist_entry__sym_to_snprintf,
389 .se_width_idx = HISTC_SYMBOL_TO,
390};
391
392static int64_t
393sort__mispredict_cmp(struct hist_entry *left, struct hist_entry *right)
394{
395 const unsigned char mp = left->branch_info->flags.mispred !=
396 right->branch_info->flags.mispred;
397 const unsigned char p = left->branch_info->flags.predicted !=
398 right->branch_info->flags.predicted;
399
400 return mp || p;
401}
402
403static int hist_entry__mispredict_snprintf(struct hist_entry *self, char *bf,
404 size_t size, unsigned int width){
405 static const char *out = "N/A";
406
407 if (self->branch_info->flags.predicted)
408 out = "N";
409 else if (self->branch_info->flags.mispred)
410 out = "Y";
411
412 return repsep_snprintf(bf, size, "%-*s", width, out);
413}
414
415struct sort_entry sort_mispredict = {
416 .se_header = "Branch Mispredicted",
417 .se_cmp = sort__mispredict_cmp,
418 .se_snprintf = hist_entry__mispredict_snprintf,
419 .se_width_idx = HISTC_MISPREDICT,
420};
421
252struct sort_dimension { 422struct sort_dimension {
253 const char *name; 423 const char *name;
254 struct sort_entry *entry; 424 struct sort_entry *entry;
255 int taken; 425 int taken;
256}; 426};
257 427
428#define DIM(d, n, func) [d] = { .name = n, .entry = &(func) }
429
258static struct sort_dimension sort_dimensions[] = { 430static struct sort_dimension sort_dimensions[] = {
259 { .name = "pid", .entry = &sort_thread, }, 431 DIM(SORT_PID, "pid", sort_thread),
260 { .name = "comm", .entry = &sort_comm, }, 432 DIM(SORT_COMM, "comm", sort_comm),
261 { .name = "dso", .entry = &sort_dso, }, 433 DIM(SORT_DSO, "dso", sort_dso),
262 { .name = "symbol", .entry = &sort_sym, }, 434 DIM(SORT_DSO_FROM, "dso_from", sort_dso_from),
263 { .name = "parent", .entry = &sort_parent, }, 435 DIM(SORT_DSO_TO, "dso_to", sort_dso_to),
264 { .name = "cpu", .entry = &sort_cpu, }, 436 DIM(SORT_SYM, "symbol", sort_sym),
437 DIM(SORT_SYM_TO, "symbol_from", sort_sym_from),
438 DIM(SORT_SYM_FROM, "symbol_to", sort_sym_to),
439 DIM(SORT_PARENT, "parent", sort_parent),
440 DIM(SORT_CPU, "cpu", sort_cpu),
441 DIM(SORT_MISPREDICT, "mispredict", sort_mispredict),
265}; 442};
266 443
267int sort_dimension__add(const char *tok) 444int sort_dimension__add(const char *tok)
@@ -273,7 +450,6 @@ int sort_dimension__add(const char *tok)
273 450
274 if (strncasecmp(tok, sd->name, strlen(tok))) 451 if (strncasecmp(tok, sd->name, strlen(tok)))
275 continue; 452 continue;
276
277 if (sd->entry == &sort_parent) { 453 if (sd->entry == &sort_parent) {
278 int ret = regcomp(&parent_regex, parent_pattern, REG_EXTENDED); 454 int ret = regcomp(&parent_regex, parent_pattern, REG_EXTENDED);
279 if (ret) { 455 if (ret) {
@@ -305,6 +481,16 @@ int sort_dimension__add(const char *tok)
305 sort__first_dimension = SORT_PARENT; 481 sort__first_dimension = SORT_PARENT;
306 else if (!strcmp(sd->name, "cpu")) 482 else if (!strcmp(sd->name, "cpu"))
307 sort__first_dimension = SORT_CPU; 483 sort__first_dimension = SORT_CPU;
484 else if (!strcmp(sd->name, "symbol_from"))
485 sort__first_dimension = SORT_SYM_FROM;
486 else if (!strcmp(sd->name, "symbol_to"))
487 sort__first_dimension = SORT_SYM_TO;
488 else if (!strcmp(sd->name, "dso_from"))
489 sort__first_dimension = SORT_DSO_FROM;
490 else if (!strcmp(sd->name, "dso_to"))
491 sort__first_dimension = SORT_DSO_TO;
492 else if (!strcmp(sd->name, "mispredict"))
493 sort__first_dimension = SORT_MISPREDICT;
308 } 494 }
309 495
310 list_add_tail(&sd->entry->list, &hist_entry__sort_list); 496 list_add_tail(&sd->entry->list, &hist_entry__sort_list);
@@ -312,7 +498,6 @@ int sort_dimension__add(const char *tok)
312 498
313 return 0; 499 return 0;
314 } 500 }
315
316 return -ESRCH; 501 return -ESRCH;
317} 502}
318 503
diff --git a/tools/perf/util/sort.h b/tools/perf/util/sort.h
index 3f67ae395752..472aa5a63a58 100644
--- a/tools/perf/util/sort.h
+++ b/tools/perf/util/sort.h
@@ -31,11 +31,16 @@ extern const char *parent_pattern;
31extern const char default_sort_order[]; 31extern const char default_sort_order[];
32extern int sort__need_collapse; 32extern int sort__need_collapse;
33extern int sort__has_parent; 33extern int sort__has_parent;
34extern int sort__branch_mode;
34extern char *field_sep; 35extern char *field_sep;
35extern struct sort_entry sort_comm; 36extern struct sort_entry sort_comm;
36extern struct sort_entry sort_dso; 37extern struct sort_entry sort_dso;
37extern struct sort_entry sort_sym; 38extern struct sort_entry sort_sym;
38extern struct sort_entry sort_parent; 39extern struct sort_entry sort_parent;
40extern struct sort_entry sort_dso_from;
41extern struct sort_entry sort_dso_to;
42extern struct sort_entry sort_sym_from;
43extern struct sort_entry sort_sym_to;
39extern enum sort_type sort__first_dimension; 44extern enum sort_type sort__first_dimension;
40 45
41/** 46/**
@@ -72,6 +77,7 @@ struct hist_entry {
72 struct hist_entry *pair; 77 struct hist_entry *pair;
73 struct rb_root sorted_chain; 78 struct rb_root sorted_chain;
74 }; 79 };
80 struct branch_info *branch_info;
75 struct callchain_root callchain[0]; 81 struct callchain_root callchain[0];
76}; 82};
77 83
@@ -82,6 +88,11 @@ enum sort_type {
82 SORT_SYM, 88 SORT_SYM,
83 SORT_PARENT, 89 SORT_PARENT,
84 SORT_CPU, 90 SORT_CPU,
91 SORT_DSO_FROM,
92 SORT_DSO_TO,
93 SORT_SYM_FROM,
94 SORT_SYM_TO,
95 SORT_MISPREDICT,
85}; 96};
86 97
87/* 98/*
diff --git a/tools/perf/util/symbol.c b/tools/perf/util/symbol.c
index 0975438c3e72..5dd83c3e2c0c 100644
--- a/tools/perf/util/symbol.c
+++ b/tools/perf/util/symbol.c
@@ -1,4 +1,3 @@
1#include <ctype.h>
2#include <dirent.h> 1#include <dirent.h>
3#include <errno.h> 2#include <errno.h>
4#include <libgen.h> 3#include <libgen.h>
@@ -12,6 +11,7 @@
12#include <unistd.h> 11#include <unistd.h>
13#include <inttypes.h> 12#include <inttypes.h>
14#include "build-id.h" 13#include "build-id.h"
14#include "util.h"
15#include "debug.h" 15#include "debug.h"
16#include "symbol.h" 16#include "symbol.h"
17#include "strlist.h" 17#include "strlist.h"
@@ -263,6 +263,28 @@ static size_t symbol__fprintf(struct symbol *sym, FILE *fp)
263 sym->name); 263 sym->name);
264} 264}
265 265
266size_t symbol__fprintf_symname_offs(const struct symbol *sym,
267 const struct addr_location *al, FILE *fp)
268{
269 unsigned long offset;
270 size_t length;
271
272 if (sym && sym->name) {
273 length = fprintf(fp, "%s", sym->name);
274 if (al) {
275 offset = al->addr - sym->start;
276 length += fprintf(fp, "+0x%lx", offset);
277 }
278 return length;
279 } else
280 return fprintf(fp, "[unknown]");
281}
282
283size_t symbol__fprintf_symname(const struct symbol *sym, FILE *fp)
284{
285 return symbol__fprintf_symname_offs(sym, NULL, fp);
286}
287
266void dso__set_long_name(struct dso *dso, char *name) 288void dso__set_long_name(struct dso *dso, char *name)
267{ 289{
268 if (name == NULL) 290 if (name == NULL)
diff --git a/tools/perf/util/symbol.h b/tools/perf/util/symbol.h
index 123c2e14353e..ac49ef208a5f 100644
--- a/tools/perf/util/symbol.h
+++ b/tools/perf/util/symbol.h
@@ -5,6 +5,7 @@
5#include <stdbool.h> 5#include <stdbool.h>
6#include <stdint.h> 6#include <stdint.h>
7#include "map.h" 7#include "map.h"
8#include "../perf.h"
8#include <linux/list.h> 9#include <linux/list.h>
9#include <linux/rbtree.h> 10#include <linux/rbtree.h>
10#include <stdio.h> 11#include <stdio.h>
@@ -70,6 +71,7 @@ struct symbol_conf {
70 unsigned short priv_size; 71 unsigned short priv_size;
71 unsigned short nr_events; 72 unsigned short nr_events;
72 bool try_vmlinux_path, 73 bool try_vmlinux_path,
74 show_kernel_path,
73 use_modules, 75 use_modules,
74 sort_by_name, 76 sort_by_name,
75 show_nr_samples, 77 show_nr_samples,
@@ -95,7 +97,11 @@ struct symbol_conf {
95 *col_width_list_str; 97 *col_width_list_str;
96 struct strlist *dso_list, 98 struct strlist *dso_list,
97 *comm_list, 99 *comm_list,
98 *sym_list; 100 *sym_list,
101 *dso_from_list,
102 *dso_to_list,
103 *sym_from_list,
104 *sym_to_list;
99 const char *symfs; 105 const char *symfs;
100}; 106};
101 107
@@ -119,6 +125,19 @@ struct map_symbol {
119 bool has_children; 125 bool has_children;
120}; 126};
121 127
128struct addr_map_symbol {
129 struct map *map;
130 struct symbol *sym;
131 u64 addr;
132 u64 al_addr;
133};
134
135struct branch_info {
136 struct addr_map_symbol from;
137 struct addr_map_symbol to;
138 struct branch_flags flags;
139};
140
122struct addr_location { 141struct addr_location {
123 struct thread *thread; 142 struct thread *thread;
124 struct map *map; 143 struct map *map;
@@ -241,6 +260,9 @@ void machines__destroy_guest_kernel_maps(struct rb_root *machines);
241 260
242int symbol__init(void); 261int symbol__init(void);
243void symbol__exit(void); 262void symbol__exit(void);
263size_t symbol__fprintf_symname_offs(const struct symbol *sym,
264 const struct addr_location *al, FILE *fp);
265size_t symbol__fprintf_symname(const struct symbol *sym, FILE *fp);
244bool symbol_type__is_a(char symbol_type, enum map_type map_type); 266bool symbol_type__is_a(char symbol_type, enum map_type map_type);
245 267
246size_t machine__fprintf_vmlinux_path(struct machine *machine, FILE *fp); 268size_t machine__fprintf_vmlinux_path(struct machine *machine, FILE *fp);
diff --git a/tools/perf/util/sysfs.c b/tools/perf/util/sysfs.c
new file mode 100644
index 000000000000..48c6902e749f
--- /dev/null
+++ b/tools/perf/util/sysfs.c
@@ -0,0 +1,60 @@
1
2#include "util.h"
3#include "sysfs.h"
4
5static const char * const sysfs_known_mountpoints[] = {
6 "/sys",
7 0,
8};
9
10static int sysfs_found;
11char sysfs_mountpoint[PATH_MAX];
12
13static int sysfs_valid_mountpoint(const char *sysfs)
14{
15 struct statfs st_fs;
16
17 if (statfs(sysfs, &st_fs) < 0)
18 return -ENOENT;
19 else if (st_fs.f_type != (long) SYSFS_MAGIC)
20 return -ENOENT;
21
22 return 0;
23}
24
25const char *sysfs_find_mountpoint(void)
26{
27 const char * const *ptr;
28 char type[100];
29 FILE *fp;
30
31 if (sysfs_found)
32 return (const char *) sysfs_mountpoint;
33
34 ptr = sysfs_known_mountpoints;
35 while (*ptr) {
36 if (sysfs_valid_mountpoint(*ptr) == 0) {
37 sysfs_found = 1;
38 strcpy(sysfs_mountpoint, *ptr);
39 return sysfs_mountpoint;
40 }
41 ptr++;
42 }
43
44 /* give up and parse /proc/mounts */
45 fp = fopen("/proc/mounts", "r");
46 if (fp == NULL)
47 return NULL;
48
49 while (!sysfs_found &&
50 fscanf(fp, "%*s %" STR(PATH_MAX) "s %99s %*s %*d %*d\n",
51 sysfs_mountpoint, type) == 2) {
52
53 if (strcmp(type, "sysfs") == 0)
54 sysfs_found = 1;
55 }
56
57 fclose(fp);
58
59 return sysfs_found ? sysfs_mountpoint : NULL;
60}
diff --git a/tools/perf/util/sysfs.h b/tools/perf/util/sysfs.h
new file mode 100644
index 000000000000..a813b7203938
--- /dev/null
+++ b/tools/perf/util/sysfs.h
@@ -0,0 +1,6 @@
1#ifndef __SYSFS_H__
2#define __SYSFS_H__
3
4const char *sysfs_find_mountpoint(void);
5
6#endif /* __DEBUGFS_H__ */
diff --git a/tools/perf/util/thread_map.c b/tools/perf/util/thread_map.c
index a5df131b77c3..84d9bd782004 100644
--- a/tools/perf/util/thread_map.c
+++ b/tools/perf/util/thread_map.c
@@ -1,6 +1,13 @@
1#include <dirent.h> 1#include <dirent.h>
2#include <limits.h>
3#include <stdbool.h>
2#include <stdlib.h> 4#include <stdlib.h>
3#include <stdio.h> 5#include <stdio.h>
6#include <sys/types.h>
7#include <sys/stat.h>
8#include <unistd.h>
9#include "strlist.h"
10#include <string.h>
4#include "thread_map.h" 11#include "thread_map.h"
5 12
6/* Skip "." and ".." directories */ 13/* Skip "." and ".." directories */
@@ -23,7 +30,7 @@ struct thread_map *thread_map__new_by_pid(pid_t pid)
23 sprintf(name, "/proc/%d/task", pid); 30 sprintf(name, "/proc/%d/task", pid);
24 items = scandir(name, &namelist, filter, NULL); 31 items = scandir(name, &namelist, filter, NULL);
25 if (items <= 0) 32 if (items <= 0)
26 return NULL; 33 return NULL;
27 34
28 threads = malloc(sizeof(*threads) + sizeof(pid_t) * items); 35 threads = malloc(sizeof(*threads) + sizeof(pid_t) * items);
29 if (threads != NULL) { 36 if (threads != NULL) {
@@ -51,14 +58,240 @@ struct thread_map *thread_map__new_by_tid(pid_t tid)
51 return threads; 58 return threads;
52} 59}
53 60
54struct thread_map *thread_map__new(pid_t pid, pid_t tid) 61struct thread_map *thread_map__new_by_uid(uid_t uid)
62{
63 DIR *proc;
64 int max_threads = 32, items, i;
65 char path[256];
66 struct dirent dirent, *next, **namelist = NULL;
67 struct thread_map *threads = malloc(sizeof(*threads) +
68 max_threads * sizeof(pid_t));
69 if (threads == NULL)
70 goto out;
71
72 proc = opendir("/proc");
73 if (proc == NULL)
74 goto out_free_threads;
75
76 threads->nr = 0;
77
78 while (!readdir_r(proc, &dirent, &next) && next) {
79 char *end;
80 bool grow = false;
81 struct stat st;
82 pid_t pid = strtol(dirent.d_name, &end, 10);
83
84 if (*end) /* only interested in proper numerical dirents */
85 continue;
86
87 snprintf(path, sizeof(path), "/proc/%s", dirent.d_name);
88
89 if (stat(path, &st) != 0)
90 continue;
91
92 if (st.st_uid != uid)
93 continue;
94
95 snprintf(path, sizeof(path), "/proc/%d/task", pid);
96 items = scandir(path, &namelist, filter, NULL);
97 if (items <= 0)
98 goto out_free_closedir;
99
100 while (threads->nr + items >= max_threads) {
101 max_threads *= 2;
102 grow = true;
103 }
104
105 if (grow) {
106 struct thread_map *tmp;
107
108 tmp = realloc(threads, (sizeof(*threads) +
109 max_threads * sizeof(pid_t)));
110 if (tmp == NULL)
111 goto out_free_namelist;
112
113 threads = tmp;
114 }
115
116 for (i = 0; i < items; i++)
117 threads->map[threads->nr + i] = atoi(namelist[i]->d_name);
118
119 for (i = 0; i < items; i++)
120 free(namelist[i]);
121 free(namelist);
122
123 threads->nr += items;
124 }
125
126out_closedir:
127 closedir(proc);
128out:
129 return threads;
130
131out_free_threads:
132 free(threads);
133 return NULL;
134
135out_free_namelist:
136 for (i = 0; i < items; i++)
137 free(namelist[i]);
138 free(namelist);
139
140out_free_closedir:
141 free(threads);
142 threads = NULL;
143 goto out_closedir;
144}
145
146struct thread_map *thread_map__new(pid_t pid, pid_t tid, uid_t uid)
55{ 147{
56 if (pid != -1) 148 if (pid != -1)
57 return thread_map__new_by_pid(pid); 149 return thread_map__new_by_pid(pid);
150
151 if (tid == -1 && uid != UINT_MAX)
152 return thread_map__new_by_uid(uid);
153
58 return thread_map__new_by_tid(tid); 154 return thread_map__new_by_tid(tid);
59} 155}
60 156
157static struct thread_map *thread_map__new_by_pid_str(const char *pid_str)
158{
159 struct thread_map *threads = NULL, *nt;
160 char name[256];
161 int items, total_tasks = 0;
162 struct dirent **namelist = NULL;
163 int i, j = 0;
164 pid_t pid, prev_pid = INT_MAX;
165 char *end_ptr;
166 struct str_node *pos;
167 struct strlist *slist = strlist__new(false, pid_str);
168
169 if (!slist)
170 return NULL;
171
172 strlist__for_each(pos, slist) {
173 pid = strtol(pos->s, &end_ptr, 10);
174
175 if (pid == INT_MIN || pid == INT_MAX ||
176 (*end_ptr != '\0' && *end_ptr != ','))
177 goto out_free_threads;
178
179 if (pid == prev_pid)
180 continue;
181
182 sprintf(name, "/proc/%d/task", pid);
183 items = scandir(name, &namelist, filter, NULL);
184 if (items <= 0)
185 goto out_free_threads;
186
187 total_tasks += items;
188 nt = realloc(threads, (sizeof(*threads) +
189 sizeof(pid_t) * total_tasks));
190 if (nt == NULL)
191 goto out_free_threads;
192
193 threads = nt;
194
195 if (threads) {
196 for (i = 0; i < items; i++)
197 threads->map[j++] = atoi(namelist[i]->d_name);
198 threads->nr = total_tasks;
199 }
200
201 for (i = 0; i < items; i++)
202 free(namelist[i]);
203 free(namelist);
204
205 if (!threads)
206 break;
207 }
208
209out:
210 strlist__delete(slist);
211 return threads;
212
213out_free_threads:
214 free(threads);
215 threads = NULL;
216 goto out;
217}
218
219static struct thread_map *thread_map__new_by_tid_str(const char *tid_str)
220{
221 struct thread_map *threads = NULL, *nt;
222 int ntasks = 0;
223 pid_t tid, prev_tid = INT_MAX;
224 char *end_ptr;
225 struct str_node *pos;
226 struct strlist *slist;
227
228 /* perf-stat expects threads to be generated even if tid not given */
229 if (!tid_str) {
230 threads = malloc(sizeof(*threads) + sizeof(pid_t));
231 if (threads != NULL) {
232 threads->map[0] = -1;
233 threads->nr = 1;
234 }
235 return threads;
236 }
237
238 slist = strlist__new(false, tid_str);
239 if (!slist)
240 return NULL;
241
242 strlist__for_each(pos, slist) {
243 tid = strtol(pos->s, &end_ptr, 10);
244
245 if (tid == INT_MIN || tid == INT_MAX ||
246 (*end_ptr != '\0' && *end_ptr != ','))
247 goto out_free_threads;
248
249 if (tid == prev_tid)
250 continue;
251
252 ntasks++;
253 nt = realloc(threads, sizeof(*threads) + sizeof(pid_t) * ntasks);
254
255 if (nt == NULL)
256 goto out_free_threads;
257
258 threads = nt;
259 threads->map[ntasks - 1] = tid;
260 threads->nr = ntasks;
261 }
262out:
263 return threads;
264
265out_free_threads:
266 free(threads);
267 threads = NULL;
268 goto out;
269}
270
271struct thread_map *thread_map__new_str(const char *pid, const char *tid,
272 uid_t uid)
273{
274 if (pid)
275 return thread_map__new_by_pid_str(pid);
276
277 if (!tid && uid != UINT_MAX)
278 return thread_map__new_by_uid(uid);
279
280 return thread_map__new_by_tid_str(tid);
281}
282
61void thread_map__delete(struct thread_map *threads) 283void thread_map__delete(struct thread_map *threads)
62{ 284{
63 free(threads); 285 free(threads);
64} 286}
287
288size_t thread_map__fprintf(struct thread_map *threads, FILE *fp)
289{
290 int i;
291 size_t printed = fprintf(fp, "%d thread%s: ",
292 threads->nr, threads->nr > 1 ? "s" : "");
293 for (i = 0; i < threads->nr; ++i)
294 printed += fprintf(fp, "%s%d", i ? ", " : "", threads->map[i]);
295
296 return printed + fprintf(fp, "\n");
297}
diff --git a/tools/perf/util/thread_map.h b/tools/perf/util/thread_map.h
index 3cb907311409..7da80f14418b 100644
--- a/tools/perf/util/thread_map.h
+++ b/tools/perf/util/thread_map.h
@@ -2,6 +2,7 @@
2#define __PERF_THREAD_MAP_H 2#define __PERF_THREAD_MAP_H
3 3
4#include <sys/types.h> 4#include <sys/types.h>
5#include <stdio.h>
5 6
6struct thread_map { 7struct thread_map {
7 int nr; 8 int nr;
@@ -10,6 +11,14 @@ struct thread_map {
10 11
11struct thread_map *thread_map__new_by_pid(pid_t pid); 12struct thread_map *thread_map__new_by_pid(pid_t pid);
12struct thread_map *thread_map__new_by_tid(pid_t tid); 13struct thread_map *thread_map__new_by_tid(pid_t tid);
13struct thread_map *thread_map__new(pid_t pid, pid_t tid); 14struct thread_map *thread_map__new_by_uid(uid_t uid);
15struct thread_map *thread_map__new(pid_t pid, pid_t tid, uid_t uid);
16
17struct thread_map *thread_map__new_str(const char *pid,
18 const char *tid, uid_t uid);
19
14void thread_map__delete(struct thread_map *threads); 20void thread_map__delete(struct thread_map *threads);
21
22size_t thread_map__fprintf(struct thread_map *threads, FILE *fp);
23
15#endif /* __PERF_THREAD_MAP_H */ 24#endif /* __PERF_THREAD_MAP_H */
diff --git a/tools/perf/util/top.c b/tools/perf/util/top.c
index 500471dffa4f..09fe579ccafb 100644
--- a/tools/perf/util/top.c
+++ b/tools/perf/util/top.c
@@ -69,12 +69,15 @@ size_t perf_top__header_snprintf(struct perf_top *top, char *bf, size_t size)
69 69
70 ret += SNPRINTF(bf + ret, size - ret, "], "); 70 ret += SNPRINTF(bf + ret, size - ret, "], ");
71 71
72 if (top->target_pid != -1) 72 if (top->target_pid)
73 ret += SNPRINTF(bf + ret, size - ret, " (target_pid: %d", 73 ret += SNPRINTF(bf + ret, size - ret, " (target_pid: %s",
74 top->target_pid); 74 top->target_pid);
75 else if (top->target_tid != -1) 75 else if (top->target_tid)
76 ret += SNPRINTF(bf + ret, size - ret, " (target_tid: %d", 76 ret += SNPRINTF(bf + ret, size - ret, " (target_tid: %s",
77 top->target_tid); 77 top->target_tid);
78 else if (top->uid_str != NULL)
79 ret += SNPRINTF(bf + ret, size - ret, " (uid: %s",
80 top->uid_str);
78 else 81 else
79 ret += SNPRINTF(bf + ret, size - ret, " (all"); 82 ret += SNPRINTF(bf + ret, size - ret, " (all");
80 83
@@ -82,7 +85,7 @@ size_t perf_top__header_snprintf(struct perf_top *top, char *bf, size_t size)
82 ret += SNPRINTF(bf + ret, size - ret, ", CPU%s: %s)", 85 ret += SNPRINTF(bf + ret, size - ret, ", CPU%s: %s)",
83 top->evlist->cpus->nr > 1 ? "s" : "", top->cpu_list); 86 top->evlist->cpus->nr > 1 ? "s" : "", top->cpu_list);
84 else { 87 else {
85 if (top->target_tid != -1) 88 if (top->target_tid)
86 ret += SNPRINTF(bf + ret, size - ret, ")"); 89 ret += SNPRINTF(bf + ret, size - ret, ")");
87 else 90 else
88 ret += SNPRINTF(bf + ret, size - ret, ", %d CPU%s)", 91 ret += SNPRINTF(bf + ret, size - ret, ", %d CPU%s)",
diff --git a/tools/perf/util/top.h b/tools/perf/util/top.h
index f2eab81435ae..ce61cb2d1acf 100644
--- a/tools/perf/util/top.h
+++ b/tools/perf/util/top.h
@@ -23,7 +23,8 @@ struct perf_top {
23 u64 guest_us_samples, guest_kernel_samples; 23 u64 guest_us_samples, guest_kernel_samples;
24 int print_entries, count_filter, delay_secs; 24 int print_entries, count_filter, delay_secs;
25 int freq; 25 int freq;
26 pid_t target_pid, target_tid; 26 const char *target_pid, *target_tid;
27 uid_t uid;
27 bool hide_kernel_symbols, hide_user_symbols, zero; 28 bool hide_kernel_symbols, hide_user_symbols, zero;
28 bool system_wide; 29 bool system_wide;
29 bool use_tui, use_stdio; 30 bool use_tui, use_stdio;
@@ -33,7 +34,7 @@ struct perf_top {
33 bool vmlinux_warned; 34 bool vmlinux_warned;
34 bool inherit; 35 bool inherit;
35 bool group; 36 bool group;
36 bool sample_id_all_avail; 37 bool sample_id_all_missing;
37 bool exclude_guest_missing; 38 bool exclude_guest_missing;
38 bool dump_symtab; 39 bool dump_symtab;
39 const char *cpu_list; 40 const char *cpu_list;
@@ -46,6 +47,7 @@ struct perf_top {
46 int realtime_prio; 47 int realtime_prio;
47 int sym_pcnt_filter; 48 int sym_pcnt_filter;
48 const char *sym_filter; 49 const char *sym_filter;
50 const char *uid_str;
49}; 51};
50 52
51size_t perf_top__header_snprintf(struct perf_top *top, char *bf, size_t size); 53size_t perf_top__header_snprintf(struct perf_top *top, char *bf, size_t size);
diff --git a/tools/perf/util/trace-event-parse.c b/tools/perf/util/trace-event-parse.c
index 1a8d4dc4f386..dfd1bd8371a4 100644
--- a/tools/perf/util/trace-event-parse.c
+++ b/tools/perf/util/trace-event-parse.c
@@ -25,7 +25,6 @@
25#include <stdio.h> 25#include <stdio.h>
26#include <stdlib.h> 26#include <stdlib.h>
27#include <string.h> 27#include <string.h>
28#include <ctype.h>
29#include <errno.h> 28#include <errno.h>
30 29
31#include "../perf.h" 30#include "../perf.h"
@@ -723,7 +722,7 @@ static char *event_read_name(void)
723static int event_read_id(void) 722static int event_read_id(void)
724{ 723{
725 char *token; 724 char *token;
726 int id; 725 int id = -1;
727 726
728 if (read_expected_item(EVENT_ITEM, "ID") < 0) 727 if (read_expected_item(EVENT_ITEM, "ID") < 0)
729 return -1; 728 return -1;
@@ -732,15 +731,13 @@ static int event_read_id(void)
732 return -1; 731 return -1;
733 732
734 if (read_expect_type(EVENT_ITEM, &token) < 0) 733 if (read_expect_type(EVENT_ITEM, &token) < 0)
735 goto fail; 734 goto free;
736 735
737 id = strtoul(token, NULL, 0); 736 id = strtoul(token, NULL, 0);
738 free_token(token);
739 return id;
740 737
741 fail: 738 free:
742 free_token(token); 739 free_token(token);
743 return -1; 740 return id;
744} 741}
745 742
746static int field_is_string(struct format_field *field) 743static int field_is_string(struct format_field *field)
@@ -1424,6 +1421,11 @@ static long long arg_num_eval(struct print_arg *arg)
1424 die("unknown op '%s'", arg->op.op); 1421 die("unknown op '%s'", arg->op.op);
1425 } 1422 }
1426 break; 1423 break;
1424 case '+':
1425 left = arg_num_eval(arg->op.left);
1426 right = arg_num_eval(arg->op.right);
1427 val = left + right;
1428 break;
1427 default: 1429 default:
1428 die("unknown op '%s'", arg->op.op); 1430 die("unknown op '%s'", arg->op.op);
1429 } 1431 }
@@ -1484,6 +1486,13 @@ process_fields(struct event *event, struct print_flag_sym **list, char **tok)
1484 1486
1485 free_token(token); 1487 free_token(token);
1486 type = process_arg(event, arg, &token); 1488 type = process_arg(event, arg, &token);
1489
1490 if (type == EVENT_OP)
1491 type = process_op(event, arg, &token);
1492
1493 if (type == EVENT_ERROR)
1494 goto out_free;
1495
1487 if (test_type_token(type, token, EVENT_DELIM, ",")) 1496 if (test_type_token(type, token, EVENT_DELIM, ","))
1488 goto out_free; 1497 goto out_free;
1489 1498
diff --git a/tools/perf/util/trace-event-read.c b/tools/perf/util/trace-event-read.c
index f55cc3a765a1..b9592e0de8d7 100644
--- a/tools/perf/util/trace-event-read.c
+++ b/tools/perf/util/trace-event-read.c
@@ -33,7 +33,6 @@
33#include <pthread.h> 33#include <pthread.h>
34#include <fcntl.h> 34#include <fcntl.h>
35#include <unistd.h> 35#include <unistd.h>
36#include <ctype.h>
37#include <errno.h> 36#include <errno.h>
38 37
39#include "../perf.h" 38#include "../perf.h"
diff --git a/tools/perf/util/trace-event-scripting.c b/tools/perf/util/trace-event-scripting.c
index a3fdf55f317b..18ae6c1831d3 100644
--- a/tools/perf/util/trace-event-scripting.c
+++ b/tools/perf/util/trace-event-scripting.c
@@ -22,7 +22,6 @@
22#include <stdio.h> 22#include <stdio.h>
23#include <stdlib.h> 23#include <stdlib.h>
24#include <string.h> 24#include <string.h>
25#include <ctype.h>
26#include <errno.h> 25#include <errno.h>
27 26
28#include "../perf.h" 27#include "../perf.h"
diff --git a/tools/perf/util/ui/browser.h b/tools/perf/util/ui/browser.h
index 84d761b730c1..6ee82f60feaf 100644
--- a/tools/perf/util/ui/browser.h
+++ b/tools/perf/util/ui/browser.h
@@ -49,6 +49,8 @@ int ui_browser__warning(struct ui_browser *browser, int timeout,
49 const char *format, ...); 49 const char *format, ...);
50int ui_browser__help_window(struct ui_browser *browser, const char *text); 50int ui_browser__help_window(struct ui_browser *browser, const char *text);
51bool ui_browser__dialog_yesno(struct ui_browser *browser, const char *text); 51bool ui_browser__dialog_yesno(struct ui_browser *browser, const char *text);
52int ui_browser__input_window(const char *title, const char *text, char *input,
53 const char *exit_msg, int delay_sec);
52 54
53void ui_browser__argv_seek(struct ui_browser *browser, off_t offset, int whence); 55void ui_browser__argv_seek(struct ui_browser *browser, off_t offset, int whence);
54unsigned int ui_browser__argv_refresh(struct ui_browser *browser); 56unsigned int ui_browser__argv_refresh(struct ui_browser *browser);
diff --git a/tools/perf/util/ui/browsers/annotate.c b/tools/perf/util/ui/browsers/annotate.c
index 295a9c93f945..57a4c6ef3fd2 100644
--- a/tools/perf/util/ui/browsers/annotate.c
+++ b/tools/perf/util/ui/browsers/annotate.c
@@ -69,14 +69,17 @@ static void annotate_browser__write(struct ui_browser *self, void *entry, int ro
69 if (!self->navkeypressed) 69 if (!self->navkeypressed)
70 width += 1; 70 width += 1;
71 71
72 if (!ab->hide_src_code && ol->offset != -1)
73 if (!current_entry || (self->use_navkeypressed &&
74 !self->navkeypressed))
75 ui_browser__set_color(self, HE_COLORSET_CODE);
76
72 if (!*ol->line) 77 if (!*ol->line)
73 slsmg_write_nstring(" ", width - 18); 78 slsmg_write_nstring(" ", width - 18);
74 else 79 else
75 slsmg_write_nstring(ol->line, width - 18); 80 slsmg_write_nstring(ol->line, width - 18);
76 81
77 if (!current_entry) 82 if (current_entry)
78 ui_browser__set_color(self, HE_COLORSET_CODE);
79 else
80 ab->selection = ol; 83 ab->selection = ol;
81} 84}
82 85
@@ -230,9 +233,9 @@ static int annotate_browser__run(struct annotate_browser *self, int evidx,
230 struct rb_node *nd = NULL; 233 struct rb_node *nd = NULL;
231 struct map_symbol *ms = self->b.priv; 234 struct map_symbol *ms = self->b.priv;
232 struct symbol *sym = ms->sym; 235 struct symbol *sym = ms->sym;
233 const char *help = "<-, ESC: exit, TAB/shift+TAB: cycle hottest lines, " 236 const char *help = "<-/ESC: Exit, TAB/shift+TAB: Cycle hot lines, "
234 "H: Hottest, -> Line action, S -> Toggle source " 237 "H: Go to hottest line, ->/ENTER: Line action, "
235 "code view"; 238 "S: Toggle source code view";
236 int key; 239 int key;
237 240
238 if (ui_browser__show(&self->b, sym->name, help) < 0) 241 if (ui_browser__show(&self->b, sym->name, help) < 0)
@@ -284,9 +287,11 @@ static int annotate_browser__run(struct annotate_browser *self, int evidx,
284 nd = self->curr_hot; 287 nd = self->curr_hot;
285 break; 288 break;
286 case 'H': 289 case 'H':
290 case 'h':
287 nd = self->curr_hot; 291 nd = self->curr_hot;
288 break; 292 break;
289 case 'S': 293 case 'S':
294 case 's':
290 if (annotate_browser__toggle_source(self)) 295 if (annotate_browser__toggle_source(self))
291 ui_helpline__puts(help); 296 ui_helpline__puts(help);
292 continue; 297 continue;
@@ -338,6 +343,7 @@ static int annotate_browser__run(struct annotate_browser *self, int evidx,
338 pthread_mutex_unlock(&notes->lock); 343 pthread_mutex_unlock(&notes->lock);
339 symbol__tui_annotate(target, ms->map, evidx, 344 symbol__tui_annotate(target, ms->map, evidx,
340 timer, arg, delay_secs); 345 timer, arg, delay_secs);
346 ui_browser__show_title(&self->b, sym->name);
341 } 347 }
342 continue; 348 continue;
343 case K_LEFT: 349 case K_LEFT:
diff --git a/tools/perf/util/ui/browsers/hists.c b/tools/perf/util/ui/browsers/hists.c
index bb9197c9c4a4..d7a1c4afe28b 100644
--- a/tools/perf/util/ui/browsers/hists.c
+++ b/tools/perf/util/ui/browsers/hists.c
@@ -805,8 +805,11 @@ static struct hist_browser *hist_browser__new(struct hists *hists)
805 self->hists = hists; 805 self->hists = hists;
806 self->b.refresh = hist_browser__refresh; 806 self->b.refresh = hist_browser__refresh;
807 self->b.seek = ui_browser__hists_seek; 807 self->b.seek = ui_browser__hists_seek;
808 self->b.use_navkeypressed = true, 808 self->b.use_navkeypressed = true;
809 self->has_symbols = sort_sym.list.next != NULL; 809 if (sort__branch_mode == 1)
810 self->has_symbols = sort_sym_from.list.next != NULL;
811 else
812 self->has_symbols = sort_sym.list.next != NULL;
810 } 813 }
811 814
812 return self; 815 return self;
@@ -839,6 +842,9 @@ static int hists__browser_title(struct hists *self, char *bf, size_t size,
839 nr_events = convert_unit(nr_events, &unit); 842 nr_events = convert_unit(nr_events, &unit);
840 printed = scnprintf(bf, size, "Events: %lu%c %s", nr_events, unit, ev_name); 843 printed = scnprintf(bf, size, "Events: %lu%c %s", nr_events, unit, ev_name);
841 844
845 if (self->uid_filter_str)
846 printed += snprintf(bf + printed, size - printed,
847 ", UID: %s", self->uid_filter_str);
842 if (thread) 848 if (thread)
843 printed += scnprintf(bf + printed, size - printed, 849 printed += scnprintf(bf + printed, size - printed,
844 ", Thread: %s(%d)", 850 ", Thread: %s(%d)",
@@ -850,6 +856,16 @@ static int hists__browser_title(struct hists *self, char *bf, size_t size,
850 return printed; 856 return printed;
851} 857}
852 858
859static inline void free_popup_options(char **options, int n)
860{
861 int i;
862
863 for (i = 0; i < n; ++i) {
864 free(options[i]);
865 options[i] = NULL;
866 }
867}
868
853static int perf_evsel__hists_browse(struct perf_evsel *evsel, int nr_events, 869static int perf_evsel__hists_browse(struct perf_evsel *evsel, int nr_events,
854 const char *helpline, const char *ev_name, 870 const char *helpline, const char *ev_name,
855 bool left_exits, 871 bool left_exits,
@@ -858,8 +874,12 @@ static int perf_evsel__hists_browse(struct perf_evsel *evsel, int nr_events,
858{ 874{
859 struct hists *self = &evsel->hists; 875 struct hists *self = &evsel->hists;
860 struct hist_browser *browser = hist_browser__new(self); 876 struct hist_browser *browser = hist_browser__new(self);
877 struct branch_info *bi;
861 struct pstack *fstack; 878 struct pstack *fstack;
879 char *options[16];
880 int nr_options = 0;
862 int key = -1; 881 int key = -1;
882 char buf[64];
863 883
864 if (browser == NULL) 884 if (browser == NULL)
865 return -1; 885 return -1;
@@ -870,13 +890,16 @@ static int perf_evsel__hists_browse(struct perf_evsel *evsel, int nr_events,
870 890
871 ui_helpline__push(helpline); 891 ui_helpline__push(helpline);
872 892
893 memset(options, 0, sizeof(options));
894
873 while (1) { 895 while (1) {
874 const struct thread *thread = NULL; 896 const struct thread *thread = NULL;
875 const struct dso *dso = NULL; 897 const struct dso *dso = NULL;
876 char *options[16]; 898 int choice = 0,
877 int nr_options = 0, choice = 0, i,
878 annotate = -2, zoom_dso = -2, zoom_thread = -2, 899 annotate = -2, zoom_dso = -2, zoom_thread = -2,
879 browse_map = -2; 900 annotate_f = -2, annotate_t = -2, browse_map = -2;
901
902 nr_options = 0;
880 903
881 key = hist_browser__run(browser, ev_name, timer, arg, delay_secs); 904 key = hist_browser__run(browser, ev_name, timer, arg, delay_secs);
882 905
@@ -884,7 +907,6 @@ static int perf_evsel__hists_browse(struct perf_evsel *evsel, int nr_events,
884 thread = hist_browser__selected_thread(browser); 907 thread = hist_browser__selected_thread(browser);
885 dso = browser->selection->map ? browser->selection->map->dso : NULL; 908 dso = browser->selection->map ? browser->selection->map->dso : NULL;
886 } 909 }
887
888 switch (key) { 910 switch (key) {
889 case K_TAB: 911 case K_TAB:
890 case K_UNTAB: 912 case K_UNTAB:
@@ -899,7 +921,7 @@ static int perf_evsel__hists_browse(struct perf_evsel *evsel, int nr_events,
899 if (!browser->has_symbols) { 921 if (!browser->has_symbols) {
900 ui_browser__warning(&browser->b, delay_secs * 2, 922 ui_browser__warning(&browser->b, delay_secs * 2,
901 "Annotation is only available for symbolic views, " 923 "Annotation is only available for symbolic views, "
902 "include \"sym\" in --sort to use it."); 924 "include \"sym*\" in --sort to use it.");
903 continue; 925 continue;
904 } 926 }
905 927
@@ -912,6 +934,16 @@ static int perf_evsel__hists_browse(struct perf_evsel *evsel, int nr_events,
912 goto zoom_dso; 934 goto zoom_dso;
913 case 't': 935 case 't':
914 goto zoom_thread; 936 goto zoom_thread;
937 case 's':
938 if (ui_browser__input_window("Symbol to show",
939 "Please enter the name of symbol you want to see",
940 buf, "ENTER: OK, ESC: Cancel",
941 delay_secs * 2) == K_ENTER) {
942 self->symbol_filter_str = *buf ? buf : NULL;
943 hists__filter_by_symbol(self);
944 hist_browser__reset(browser);
945 }
946 continue;
915 case K_F1: 947 case K_F1:
916 case 'h': 948 case 'h':
917 case '?': 949 case '?':
@@ -929,7 +961,8 @@ static int perf_evsel__hists_browse(struct perf_evsel *evsel, int nr_events,
929 "C Collapse all callchains\n" 961 "C Collapse all callchains\n"
930 "E Expand all callchains\n" 962 "E Expand all callchains\n"
931 "d Zoom into current DSO\n" 963 "d Zoom into current DSO\n"
932 "t Zoom into current Thread"); 964 "t Zoom into current Thread\n"
965 "s Filter symbol by name");
933 continue; 966 continue;
934 case K_ENTER: 967 case K_ENTER:
935 case K_RIGHT: 968 case K_RIGHT:
@@ -969,12 +1002,34 @@ static int perf_evsel__hists_browse(struct perf_evsel *evsel, int nr_events,
969 if (!browser->has_symbols) 1002 if (!browser->has_symbols)
970 goto add_exit_option; 1003 goto add_exit_option;
971 1004
972 if (browser->selection != NULL && 1005 if (sort__branch_mode == 1) {
973 browser->selection->sym != NULL && 1006 bi = browser->he_selection->branch_info;
974 !browser->selection->map->dso->annotate_warned && 1007 if (browser->selection != NULL &&
975 asprintf(&options[nr_options], "Annotate %s", 1008 bi &&
976 browser->selection->sym->name) > 0) 1009 bi->from.sym != NULL &&
977 annotate = nr_options++; 1010 !bi->from.map->dso->annotate_warned &&
1011 asprintf(&options[nr_options], "Annotate %s",
1012 bi->from.sym->name) > 0)
1013 annotate_f = nr_options++;
1014
1015 if (browser->selection != NULL &&
1016 bi &&
1017 bi->to.sym != NULL &&
1018 !bi->to.map->dso->annotate_warned &&
1019 (bi->to.sym != bi->from.sym ||
1020 bi->to.map->dso != bi->from.map->dso) &&
1021 asprintf(&options[nr_options], "Annotate %s",
1022 bi->to.sym->name) > 0)
1023 annotate_t = nr_options++;
1024 } else {
1025
1026 if (browser->selection != NULL &&
1027 browser->selection->sym != NULL &&
1028 !browser->selection->map->dso->annotate_warned &&
1029 asprintf(&options[nr_options], "Annotate %s",
1030 browser->selection->sym->name) > 0)
1031 annotate = nr_options++;
1032 }
978 1033
979 if (thread != NULL && 1034 if (thread != NULL &&
980 asprintf(&options[nr_options], "Zoom %s %s(%d) thread", 1035 asprintf(&options[nr_options], "Zoom %s %s(%d) thread",
@@ -995,25 +1050,39 @@ static int perf_evsel__hists_browse(struct perf_evsel *evsel, int nr_events,
995 browse_map = nr_options++; 1050 browse_map = nr_options++;
996add_exit_option: 1051add_exit_option:
997 options[nr_options++] = (char *)"Exit"; 1052 options[nr_options++] = (char *)"Exit";
998 1053retry_popup_menu:
999 choice = ui__popup_menu(nr_options, options); 1054 choice = ui__popup_menu(nr_options, options);
1000 1055
1001 for (i = 0; i < nr_options - 1; ++i)
1002 free(options[i]);
1003
1004 if (choice == nr_options - 1) 1056 if (choice == nr_options - 1)
1005 break; 1057 break;
1006 1058
1007 if (choice == -1) 1059 if (choice == -1) {
1060 free_popup_options(options, nr_options - 1);
1008 continue; 1061 continue;
1062 }
1009 1063
1010 if (choice == annotate) { 1064 if (choice == annotate || choice == annotate_t || choice == annotate_f) {
1011 struct hist_entry *he; 1065 struct hist_entry *he;
1012 int err; 1066 int err;
1013do_annotate: 1067do_annotate:
1014 he = hist_browser__selected_entry(browser); 1068 he = hist_browser__selected_entry(browser);
1015 if (he == NULL) 1069 if (he == NULL)
1016 continue; 1070 continue;
1071
1072 /*
1073 * we stash the branch_info symbol + map into the
1074 * the ms so we don't have to rewrite all the annotation
1075 * code to use branch_info.
1076 * in branch mode, the ms struct is not used
1077 */
1078 if (choice == annotate_f) {
1079 he->ms.sym = he->branch_info->from.sym;
1080 he->ms.map = he->branch_info->from.map;
1081 } else if (choice == annotate_t) {
1082 he->ms.sym = he->branch_info->to.sym;
1083 he->ms.map = he->branch_info->to.map;
1084 }
1085
1017 /* 1086 /*
1018 * Don't let this be freed, say, by hists__decay_entry. 1087 * Don't let this be freed, say, by hists__decay_entry.
1019 */ 1088 */
@@ -1021,9 +1090,18 @@ do_annotate:
1021 err = hist_entry__tui_annotate(he, evsel->idx, 1090 err = hist_entry__tui_annotate(he, evsel->idx,
1022 timer, arg, delay_secs); 1091 timer, arg, delay_secs);
1023 he->used = false; 1092 he->used = false;
1093 /*
1094 * offer option to annotate the other branch source or target
1095 * (if they exists) when returning from annotate
1096 */
1097 if ((err == 'q' || err == CTRL('c'))
1098 && annotate_t != -2 && annotate_f != -2)
1099 goto retry_popup_menu;
1100
1024 ui_browser__update_nr_entries(&browser->b, browser->hists->nr_entries); 1101 ui_browser__update_nr_entries(&browser->b, browser->hists->nr_entries);
1025 if (err) 1102 if (err)
1026 ui_browser__handle_resize(&browser->b); 1103 ui_browser__handle_resize(&browser->b);
1104
1027 } else if (choice == browse_map) 1105 } else if (choice == browse_map)
1028 map__browse(browser->selection->map); 1106 map__browse(browser->selection->map);
1029 else if (choice == zoom_dso) { 1107 else if (choice == zoom_dso) {
@@ -1069,6 +1147,7 @@ out_free_stack:
1069 pstack__delete(fstack); 1147 pstack__delete(fstack);
1070out: 1148out:
1071 hist_browser__delete(browser); 1149 hist_browser__delete(browser);
1150 free_popup_options(options, nr_options - 1);
1072 return key; 1151 return key;
1073} 1152}
1074 1153
diff --git a/tools/perf/util/ui/browsers/map.c b/tools/perf/util/ui/browsers/map.c
index 6905bcc8be2d..eca6575abfd0 100644
--- a/tools/perf/util/ui/browsers/map.c
+++ b/tools/perf/util/ui/browsers/map.c
@@ -3,9 +3,9 @@
3#include <newt.h> 3#include <newt.h>
4#include <inttypes.h> 4#include <inttypes.h>
5#include <sys/ttydefaults.h> 5#include <sys/ttydefaults.h>
6#include <ctype.h>
7#include <string.h> 6#include <string.h>
8#include <linux/bitops.h> 7#include <linux/bitops.h>
8#include "../../util.h"
9#include "../../debug.h" 9#include "../../debug.h"
10#include "../../symbol.h" 10#include "../../symbol.h"
11#include "../browser.h" 11#include "../browser.h"
diff --git a/tools/perf/util/ui/keysyms.h b/tools/perf/util/ui/keysyms.h
index 3458b1985761..809eca5707fa 100644
--- a/tools/perf/util/ui/keysyms.h
+++ b/tools/perf/util/ui/keysyms.h
@@ -16,6 +16,8 @@
16#define K_TAB '\t' 16#define K_TAB '\t'
17#define K_UNTAB SL_KEY_UNTAB 17#define K_UNTAB SL_KEY_UNTAB
18#define K_UP SL_KEY_UP 18#define K_UP SL_KEY_UP
19#define K_BKSPC 0x7f
20#define K_DEL SL_KEY_DELETE
19 21
20/* Not really keys */ 22/* Not really keys */
21#define K_TIMER -1 23#define K_TIMER -1
diff --git a/tools/perf/util/ui/util.c b/tools/perf/util/ui/util.c
index 45daa7c41dad..ad4374a16bb0 100644
--- a/tools/perf/util/ui/util.c
+++ b/tools/perf/util/ui/util.c
@@ -69,6 +69,88 @@ int ui__popup_menu(int argc, char * const argv[])
69 return popup_menu__run(&menu); 69 return popup_menu__run(&menu);
70} 70}
71 71
72int ui_browser__input_window(const char *title, const char *text, char *input,
73 const char *exit_msg, int delay_secs)
74{
75 int x, y, len, key;
76 int max_len = 60, nr_lines = 0;
77 static char buf[50];
78 const char *t;
79
80 t = text;
81 while (1) {
82 const char *sep = strchr(t, '\n');
83
84 if (sep == NULL)
85 sep = strchr(t, '\0');
86 len = sep - t;
87 if (max_len < len)
88 max_len = len;
89 ++nr_lines;
90 if (*sep == '\0')
91 break;
92 t = sep + 1;
93 }
94
95 max_len += 2;
96 nr_lines += 8;
97 y = SLtt_Screen_Rows / 2 - nr_lines / 2;
98 x = SLtt_Screen_Cols / 2 - max_len / 2;
99
100 SLsmg_set_color(0);
101 SLsmg_draw_box(y, x++, nr_lines, max_len);
102 if (title) {
103 SLsmg_gotorc(y, x + 1);
104 SLsmg_write_string((char *)title);
105 }
106 SLsmg_gotorc(++y, x);
107 nr_lines -= 7;
108 max_len -= 2;
109 SLsmg_write_wrapped_string((unsigned char *)text, y, x,
110 nr_lines, max_len, 1);
111 y += nr_lines;
112 len = 5;
113 while (len--) {
114 SLsmg_gotorc(y + len - 1, x);
115 SLsmg_write_nstring((char *)" ", max_len);
116 }
117 SLsmg_draw_box(y++, x + 1, 3, max_len - 2);
118
119 SLsmg_gotorc(y + 3, x);
120 SLsmg_write_nstring((char *)exit_msg, max_len);
121 SLsmg_refresh();
122
123 x += 2;
124 len = 0;
125 key = ui__getch(delay_secs);
126 while (key != K_TIMER && key != K_ENTER && key != K_ESC) {
127 if (key == K_BKSPC) {
128 if (len == 0)
129 goto next_key;
130 SLsmg_gotorc(y, x + --len);
131 SLsmg_write_char(' ');
132 } else {
133 buf[len] = key;
134 SLsmg_gotorc(y, x + len++);
135 SLsmg_write_char(key);
136 }
137 SLsmg_refresh();
138
139 /* XXX more graceful overflow handling needed */
140 if (len == sizeof(buf) - 1) {
141 ui_helpline__push("maximum size of symbol name reached!");
142 key = K_ENTER;
143 break;
144 }
145next_key:
146 key = ui__getch(delay_secs);
147 }
148
149 buf[len] = '\0';
150 strncpy(input, buf, len+1);
151 return key;
152}
153
72int ui__question_window(const char *title, const char *text, 154int ui__question_window(const char *title, const char *text,
73 const char *exit_msg, int delay_secs) 155 const char *exit_msg, int delay_secs)
74{ 156{
diff --git a/tools/perf/util/usage.c b/tools/perf/util/usage.c
index d76d1c0ff98f..52bb07c6442a 100644
--- a/tools/perf/util/usage.c
+++ b/tools/perf/util/usage.c
@@ -7,6 +7,7 @@
7 * Copyright (C) Linus Torvalds, 2005 7 * Copyright (C) Linus Torvalds, 2005
8 */ 8 */
9#include "util.h" 9#include "util.h"
10#include "debug.h"
10 11
11static void report(const char *prefix, const char *err, va_list params) 12static void report(const char *prefix, const char *err, va_list params)
12{ 13{
@@ -81,3 +82,41 @@ void warning(const char *warn, ...)
81 warn_routine(warn, params); 82 warn_routine(warn, params);
82 va_end(params); 83 va_end(params);
83} 84}
85
86uid_t parse_target_uid(const char *str, const char *tid, const char *pid)
87{
88 struct passwd pwd, *result;
89 char buf[1024];
90
91 if (str == NULL)
92 return UINT_MAX;
93
94 /* UID and PID are mutually exclusive */
95 if (tid || pid) {
96 ui__warning("PID/TID switch overriding UID\n");
97 sleep(1);
98 return UINT_MAX;
99 }
100
101 getpwnam_r(str, &pwd, buf, sizeof(buf), &result);
102
103 if (result == NULL) {
104 char *endptr;
105 int uid = strtol(str, &endptr, 10);
106
107 if (*endptr != '\0') {
108 ui__error("Invalid user %s\n", str);
109 return UINT_MAX - 1;
110 }
111
112 getpwuid_r(uid, &pwd, buf, sizeof(buf), &result);
113
114 if (result == NULL) {
115 ui__error("Problems obtaining information for user %s\n",
116 str);
117 return UINT_MAX - 1;
118 }
119 }
120
121 return result->pw_uid;
122}
diff --git a/tools/perf/util/util.c b/tools/perf/util/util.c
index fb25d1329218..8109a907841e 100644
--- a/tools/perf/util/util.c
+++ b/tools/perf/util/util.c
@@ -14,6 +14,8 @@ void event_attr_init(struct perf_event_attr *attr)
14 attr->exclude_host = 1; 14 attr->exclude_host = 1;
15 if (!perf_guest) 15 if (!perf_guest)
16 attr->exclude_guest = 1; 16 attr->exclude_guest = 1;
17 /* to capture ABI version */
18 attr->size = sizeof(*attr);
17} 19}
18 20
19int mkdir_p(char *path, mode_t mode) 21int mkdir_p(char *path, mode_t mode)
diff --git a/tools/perf/util/util.h b/tools/perf/util/util.h
index ecf9898169c8..0f99f394d8e0 100644
--- a/tools/perf/util/util.h
+++ b/tools/perf/util/util.h
@@ -199,6 +199,8 @@ static inline int has_extension(const char *filename, const char *ext)
199#undef isalpha 199#undef isalpha
200#undef isprint 200#undef isprint
201#undef isalnum 201#undef isalnum
202#undef islower
203#undef isupper
202#undef tolower 204#undef tolower
203#undef toupper 205#undef toupper
204 206
@@ -219,6 +221,8 @@ extern unsigned char sane_ctype[256];
219#define isalpha(x) sane_istest(x,GIT_ALPHA) 221#define isalpha(x) sane_istest(x,GIT_ALPHA)
220#define isalnum(x) sane_istest(x,GIT_ALPHA | GIT_DIGIT) 222#define isalnum(x) sane_istest(x,GIT_ALPHA | GIT_DIGIT)
221#define isprint(x) sane_istest(x,GIT_PRINT) 223#define isprint(x) sane_istest(x,GIT_PRINT)
224#define islower(x) (sane_istest(x,GIT_ALPHA) && sane_istest(x,0x20))
225#define isupper(x) (sane_istest(x,GIT_ALPHA) && !sane_istest(x,0x20))
222#define tolower(x) sane_case((unsigned char)(x), 0x20) 226#define tolower(x) sane_case((unsigned char)(x), 0x20)
223#define toupper(x) sane_case((unsigned char)(x), 0) 227#define toupper(x) sane_case((unsigned char)(x), 0)
224 228
@@ -245,6 +249,8 @@ struct perf_event_attr;
245 249
246void event_attr_init(struct perf_event_attr *attr); 250void event_attr_init(struct perf_event_attr *attr);
247 251
252uid_t parse_target_uid(const char *str, const char *tid, const char *pid);
253
248#define _STR(x) #x 254#define _STR(x) #x
249#define STR(x) _STR(x) 255#define STR(x) _STR(x)
250 256