aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Documentation/ftrace.txt46
-rw-r--r--Documentation/kernel-parameters.txt19
-rw-r--r--Documentation/markers.txt14
-rw-r--r--Documentation/networking/phy.txt2
-rw-r--r--Documentation/tracepoints.txt92
-rw-r--r--MAINTAINERS2
-rw-r--r--Makefile2
-rw-r--r--arch/arm/mach-pxa/include/mach/pxafb.h1
-rw-r--r--arch/arm/mach-pxa/reset.c7
-rw-r--r--arch/arm/mach-pxa/spitz.c4
-rw-r--r--arch/ia64/include/asm/intrinsics.h2
-rw-r--r--arch/ia64/include/asm/paravirt_privop.h13
-rw-r--r--arch/ia64/kernel/entry.S1
-rw-r--r--arch/ia64/kernel/head.S2
-rw-r--r--arch/ia64/kernel/mca.c2
-rw-r--r--arch/ia64/kernel/paravirt.c2
-rw-r--r--arch/ia64/kernel/pci-dma.c1
-rw-r--r--arch/ia64/xen/hypercall.S2
-rw-r--r--arch/mips/include/asm/mach-rc32434/gpio.h2
-rw-r--r--arch/mips/include/asm/mach-rc32434/rb.h14
-rw-r--r--arch/mips/include/asm/time.h2
-rw-r--r--arch/mips/kernel/csrc-r4k.c2
-rw-r--r--arch/mips/mm/sc-ip22.c2
-rw-r--r--arch/mips/mti-malta/malta-amon.c6
-rw-r--r--arch/mips/rb532/devices.c2
-rw-r--r--arch/mips/rb532/gpio.c193
-rw-r--r--arch/parisc/kernel/ptrace.c10
-rw-r--r--arch/sparc/include/asm/unistd_32.h3
-rw-r--r--arch/sparc/include/asm/unistd_64.h3
-rw-r--r--arch/sparc/kernel/systbls.S2
-rw-r--r--arch/sparc64/kernel/sys32.S13
-rw-r--r--arch/sparc64/kernel/systbls.S4
-rw-r--r--arch/x86/Kconfig9
-rw-r--r--arch/x86/Kconfig.debug4
-rw-r--r--arch/x86/include/asm/ftrace.h35
-rw-r--r--arch/x86/include/asm/iomap.h (renamed from include/asm-x86/iomap.h)0
-rw-r--r--arch/x86/include/asm/mmzone_32.h4
-rw-r--r--arch/x86/include/asm/thread_info.h31
-rw-r--r--arch/x86/include/asm/uaccess_64.h2
-rw-r--r--arch/x86/include/asm/unistd_64.h4
-rw-r--r--arch/x86/kernel/Makefile6
-rw-r--r--arch/x86/kernel/amd_iommu.c2
-rw-r--r--arch/x86/kernel/amd_iommu_init.c6
-rw-r--r--arch/x86/kernel/ds.c25
-rw-r--r--arch/x86/kernel/entry_32.S42
-rw-r--r--arch/x86/kernel/entry_64.S5
-rw-r--r--arch/x86/kernel/es7000_32.c9
-rw-r--r--arch/x86/kernel/ftrace.c311
-rw-r--r--arch/x86/kernel/io_apic.c14
-rw-r--r--arch/x86/kernel/reboot.c9
-rw-r--r--arch/x86/kernel/setup.c2
-rw-r--r--arch/x86/kernel/tsc_sync.c4
-rw-r--r--arch/x86/kernel/vsyscall_64.c3
-rw-r--r--arch/x86/mach-voyager/voyager_smp.c16
-rw-r--r--arch/x86/mm/Makefile3
-rw-r--r--arch/x86/mm/fault.c2
-rw-r--r--arch/x86/mm/numa_32.c35
-rw-r--r--arch/x86/power/hibernate_32.c4
-rw-r--r--arch/x86/vdso/vclock_gettime.c3
-rw-r--r--drivers/block/cciss.c9
-rw-r--r--drivers/char/sysrq.c18
-rw-r--r--drivers/gpio/gpiolib.c2
-rw-r--r--drivers/hwmon/applesmc.c13
-rw-r--r--drivers/misc/sgi-gru/Makefile4
-rw-r--r--drivers/net/atlx/atl2.c8
-rw-r--r--drivers/net/ipg.c8
-rw-r--r--drivers/net/ixgbe/ixgbe_main.c58
-rw-r--r--drivers/net/jme.c21
-rw-r--r--drivers/net/mv643xx_eth.c5
-rw-r--r--drivers/net/phy/phy_device.c34
-rw-r--r--drivers/net/sh_eth.c4
-rw-r--r--drivers/net/smc911x.c2
-rw-r--r--drivers/net/usb/asix.c4
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-agn.c7
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-dev.h3
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-rx.c26
-rw-r--r--drivers/net/wireless/iwlwifi/iwl3945-base.c1
-rw-r--r--drivers/net/wireless/libertas_tf/if_usb.c2
-rw-r--r--drivers/parport/Kconfig2
-rw-r--r--drivers/pci/intel-iommu.c6
-rw-r--r--drivers/pci/pci.c4
-rw-r--r--drivers/spi/pxa2xx_spi.c24
-rw-r--r--drivers/spi/spi_imx.c45
-rw-r--r--drivers/usb/gadget/f_rndis.c3
-rw-r--r--drivers/usb/host/ehci-pci.c21
-rw-r--r--drivers/usb/mon/mon_bin.c5
-rw-r--r--drivers/usb/musb/musb_host.c2
-rw-r--r--drivers/usb/serial/cp2101.c1
-rw-r--r--drivers/usb/storage/unusual_devs.h11
-rw-r--r--drivers/video/atmel_lcdfb.c2
-rw-r--r--drivers/video/backlight/da903x.c2
-rw-r--r--drivers/video/backlight/lcd.c11
-rw-r--r--drivers/video/cirrusfb.c3
-rw-r--r--drivers/video/fbmem.c2
-rw-r--r--drivers/video/pxafb.c5
-rw-r--r--drivers/video/tmiofb.c10
-rw-r--r--drivers/video/via/viafbdev.c17
-rw-r--r--drivers/w1/masters/omap_hdq.c10
-rw-r--r--drivers/xen/balloon.c9
-rw-r--r--fs/cifs/CHANGES6
-rw-r--r--fs/cifs/cifsglob.h10
-rw-r--r--fs/cifs/cifssmb.c2
-rw-r--r--fs/cifs/file.c21
-rw-r--r--fs/cifs/misc.c3
-rw-r--r--fs/cifs/readdir.c5
-rw-r--r--fs/ecryptfs/keystore.c31
-rw-r--r--fs/hostfs/hostfs.h2
-rw-r--r--fs/hostfs/hostfs_kern.c4
-rw-r--r--fs/hostfs/hostfs_user.c2
-rw-r--r--fs/namei.c2
-rw-r--r--include/asm-generic/vmlinux.lds.h15
-rw-r--r--include/linux/compiler.h66
-rw-r--r--include/linux/cpuset.h4
-rw-r--r--include/linux/ftrace.h138
-rw-r--r--include/linux/ftrace_irq.h13
-rw-r--r--include/linux/hardirq.h15
-rw-r--r--include/linux/marker.h69
-rw-r--r--include/linux/net.h6
-rw-r--r--include/linux/rcupdate.h2
-rw-r--r--include/linux/sched.h12
-rw-r--r--include/linux/syscalls.h3
-rw-r--r--include/linux/tracepoint.h57
-rw-r--r--include/net/mac80211.h20
-rw-r--r--include/trace/boot.h56
-rw-r--r--include/trace/sched.h24
-rw-r--r--init/Kconfig1
-rw-r--r--init/main.c35
-rw-r--r--ipc/util.c14
-rw-r--r--kernel/Makefile4
-rw-r--r--kernel/cgroup.c21
-rw-r--r--kernel/cpuset.c19
-rw-r--r--kernel/exit.c4
-rw-r--r--kernel/fork.c2
-rw-r--r--kernel/kallsyms.c17
-rw-r--r--kernel/kthread.c3
-rw-r--r--kernel/marker.c192
-rw-r--r--kernel/module.c11
-rw-r--r--kernel/sched.c6
-rw-r--r--kernel/signal.c2
-rw-r--r--kernel/sys_ni.c2
-rw-r--r--kernel/sysctl.c10
-rw-r--r--kernel/trace/Kconfig58
-rw-r--r--kernel/trace/Makefile7
-rw-r--r--kernel/trace/ftrace.c341
-rw-r--r--kernel/trace/ring_buffer.c299
-rw-r--r--kernel/trace/trace.c612
-rw-r--r--kernel/trace/trace.h182
-rw-r--r--kernel/trace/trace_boot.c166
-rw-r--r--kernel/trace/trace_branch.c321
-rw-r--r--kernel/trace/trace_functions.c18
-rw-r--r--kernel/trace/trace_functions_return.c98
-rw-r--r--kernel/trace/trace_irqsoff.c61
-rw-r--r--kernel/trace/trace_mmiotrace.c25
-rw-r--r--kernel/trace/trace_nop.c65
-rw-r--r--kernel/trace/trace_sched_switch.c106
-rw-r--r--kernel/trace/trace_sched_wakeup.c70
-rw-r--r--kernel/trace/trace_selftest.c173
-rw-r--r--kernel/trace/trace_stack.c32
-rw-r--r--kernel/trace/trace_sysprof.c19
-rw-r--r--kernel/tracepoint.c295
-rw-r--r--lib/scatterlist.c2
-rw-r--r--mm/memory_hotplug.c3
-rw-r--r--mm/migrate.c5
-rw-r--r--mm/vmalloc.c21
-rw-r--r--mm/vmscan.c9
-rw-r--r--net/compat.c50
-rw-r--r--net/core/pktgen.c9
-rw-r--r--net/ipv4/af_inet.c1
-rw-r--r--net/ipv4/ipmr.c9
-rw-r--r--net/ipv4/udp.c1
-rw-r--r--net/ipv6/ip6mr.c4
-rw-r--r--net/ipv6/proc.c6
-rw-r--r--net/mac80211/mlme.c22
-rw-r--r--net/phonet/af_phonet.c52
-rw-r--r--net/sched/sch_api.c2
-rw-r--r--net/sched/sch_generic.c7
-rw-r--r--net/socket.c80
-rw-r--r--net/sunrpc/auth_generic.c20
-rw-r--r--samples/tracepoints/tp-samples-trace.h4
-rw-r--r--samples/tracepoints/tracepoint-probe-sample.c1
-rw-r--r--samples/tracepoints/tracepoint-probe-sample2.c1
-rw-r--r--samples/tracepoints/tracepoint-sample.c3
-rw-r--r--scripts/Makefile.build12
-rw-r--r--scripts/bootgraph.pl16
-rwxr-xr-xscripts/recordmcount.pl4
-rw-r--r--scripts/tracing/draw_functrace.py130
186 files changed, 4209 insertions, 1630 deletions
diff --git a/Documentation/ftrace.txt b/Documentation/ftrace.txt
index 9cc4d685dde5..753f4de4b175 100644
--- a/Documentation/ftrace.txt
+++ b/Documentation/ftrace.txt
@@ -82,7 +82,7 @@ of ftrace. Here is a list of some of the key files:
82 tracer is not adding more data, they will display 82 tracer is not adding more data, they will display
83 the same information every time they are read. 83 the same information every time they are read.
84 84
85 iter_ctrl: This file lets the user control the amount of data 85 trace_options: This file lets the user control the amount of data
86 that is displayed in one of the above output 86 that is displayed in one of the above output
87 files. 87 files.
88 88
@@ -94,10 +94,10 @@ of ftrace. Here is a list of some of the key files:
94 only be recorded if the latency is greater than 94 only be recorded if the latency is greater than
95 the value in this file. (in microseconds) 95 the value in this file. (in microseconds)
96 96
97 trace_entries: This sets or displays the number of bytes each CPU 97 buffer_size_kb: This sets or displays the number of kilobytes each CPU
98 buffer can hold. The tracer buffers are the same size 98 buffer can hold. The tracer buffers are the same size
99 for each CPU. The displayed number is the size of the 99 for each CPU. The displayed number is the size of the
100 CPU buffer and not total size of all buffers. The 100 CPU buffer and not total size of all buffers. The
101 trace buffers are allocated in pages (blocks of memory 101 trace buffers are allocated in pages (blocks of memory
102 that the kernel uses for allocation, usually 4 KB in size). 102 that the kernel uses for allocation, usually 4 KB in size).
103 If the last page allocated has room for more bytes 103 If the last page allocated has room for more bytes
@@ -316,23 +316,23 @@ The above is mostly meaningful for kernel developers.
316 The rest is the same as the 'trace' file. 316 The rest is the same as the 'trace' file.
317 317
318 318
319iter_ctrl 319trace_options
320--------- 320-------------
321 321
322The iter_ctrl file is used to control what gets printed in the trace 322The trace_options file is used to control what gets printed in the trace
323output. To see what is available, simply cat the file: 323output. To see what is available, simply cat the file:
324 324
325 cat /debug/tracing/iter_ctrl 325 cat /debug/tracing/trace_options
326 print-parent nosym-offset nosym-addr noverbose noraw nohex nobin \ 326 print-parent nosym-offset nosym-addr noverbose noraw nohex nobin \
327 noblock nostacktrace nosched-tree 327 noblock nostacktrace nosched-tree
328 328
329To disable one of the options, echo in the option prepended with "no". 329To disable one of the options, echo in the option prepended with "no".
330 330
331 echo noprint-parent > /debug/tracing/iter_ctrl 331 echo noprint-parent > /debug/tracing/trace_options
332 332
333To enable an option, leave off the "no". 333To enable an option, leave off the "no".
334 334
335 echo sym-offset > /debug/tracing/iter_ctrl 335 echo sym-offset > /debug/tracing/trace_options
336 336
337Here are the available options: 337Here are the available options:
338 338
@@ -1299,41 +1299,29 @@ trace entries
1299------------- 1299-------------
1300 1300
1301Having too much or not enough data can be troublesome in diagnosing 1301Having too much or not enough data can be troublesome in diagnosing
1302an issue in the kernel. The file trace_entries is used to modify 1302an issue in the kernel. The file buffer_size_kb is used to modify
1303the size of the internal trace buffers. The number listed 1303the size of the internal trace buffers. The number listed
1304is the number of entries that can be recorded per CPU. To know 1304is the number of entries that can be recorded per CPU. To know
1305the full size, multiply the number of possible CPUS with the 1305the full size, multiply the number of possible CPUS with the
1306number of entries. 1306number of entries.
1307 1307
1308 # cat /debug/tracing/trace_entries 1308 # cat /debug/tracing/buffer_size_kb
130965620 13091408 (units kilobytes)
1310 1310
1311Note, to modify this, you must have tracing completely disabled. To do that, 1311Note, to modify this, you must have tracing completely disabled. To do that,
1312echo "nop" into the current_tracer. If the current_tracer is not set 1312echo "nop" into the current_tracer. If the current_tracer is not set
1313to "nop", an EINVAL error will be returned. 1313to "nop", an EINVAL error will be returned.
1314 1314
1315 # echo nop > /debug/tracing/current_tracer 1315 # echo nop > /debug/tracing/current_tracer
1316 # echo 100000 > /debug/tracing/trace_entries 1316 # echo 10000 > /debug/tracing/buffer_size_kb
1317 # cat /debug/tracing/trace_entries 1317 # cat /debug/tracing/buffer_size_kb
1318100045 131810000 (units kilobytes)
1319
1320
1321Notice that we echoed in 100,000 but the size is 100,045. The entries
1322are held in individual pages. It allocates the number of pages it takes
1323to fulfill the request. If more entries may fit on the last page
1324then they will be added.
1325
1326 # echo 1 > /debug/tracing/trace_entries
1327 # cat /debug/tracing/trace_entries
132885
1329
1330This shows us that 85 entries can fit in a single page.
1331 1319
1332The number of pages which will be allocated is limited to a percentage 1320The number of pages which will be allocated is limited to a percentage
1333of available memory. Allocating too much will produce an error. 1321of available memory. Allocating too much will produce an error.
1334 1322
1335 # echo 1000000000000 > /debug/tracing/trace_entries 1323 # echo 1000000000000 > /debug/tracing/buffer_size_kb
1336-bash: echo: write error: Cannot allocate memory 1324-bash: echo: write error: Cannot allocate memory
1337 # cat /debug/tracing/trace_entries 1325 # cat /debug/tracing/buffer_size_kb
133885 132685
1339 1327
diff --git a/Documentation/kernel-parameters.txt b/Documentation/kernel-parameters.txt
index 9fa6508892c2..2919a2e91938 100644
--- a/Documentation/kernel-parameters.txt
+++ b/Documentation/kernel-parameters.txt
@@ -294,7 +294,9 @@ and is between 256 and 4096 characters. It is defined in the file
294 Possible values are: 294 Possible values are:
295 isolate - enable device isolation (each device, as far 295 isolate - enable device isolation (each device, as far
296 as possible, will get its own protection 296 as possible, will get its own protection
297 domain) 297 domain) [default]
298 share - put every device behind one IOMMU into the
299 same protection domain
298 fullflush - enable flushing of IO/TLB entries when 300 fullflush - enable flushing of IO/TLB entries when
299 they are unmapped. Otherwise they are 301 they are unmapped. Otherwise they are
300 flushed before they will be reused, which 302 flushed before they will be reused, which
@@ -748,6 +750,14 @@ and is between 256 and 4096 characters. It is defined in the file
748 parameter will force ia64_sal_cache_flush to call 750 parameter will force ia64_sal_cache_flush to call
749 ia64_pal_cache_flush instead of SAL_CACHE_FLUSH. 751 ia64_pal_cache_flush instead of SAL_CACHE_FLUSH.
750 752
753 ftrace=[tracer]
754 [ftrace] will set and start the specified tracer
755 as early as possible in order to facilitate early
756 boot debugging.
757
758 ftrace_dump_on_oops
759 [ftrace] will dump the trace buffers on oops.
760
751 gamecon.map[2|3]= 761 gamecon.map[2|3]=
752 [HW,JOY] Multisystem joystick and NES/SNES/PSX pad 762 [HW,JOY] Multisystem joystick and NES/SNES/PSX pad
753 support via parallel port (up to 5 devices per port) 763 support via parallel port (up to 5 devices per port)
@@ -1193,8 +1203,8 @@ and is between 256 and 4096 characters. It is defined in the file
1193 it is equivalent to "nosmp", which also disables 1203 it is equivalent to "nosmp", which also disables
1194 the IO APIC. 1204 the IO APIC.
1195 1205
1196 max_addr=[KMG] [KNL,BOOT,ia64] All physical memory greater than or 1206 max_addr=nn[KMG] [KNL,BOOT,ia64] All physical memory greater than
1197 equal to this physical address is ignored. 1207 or equal to this physical address is ignored.
1198 1208
1199 max_luns= [SCSI] Maximum number of LUNs to probe. 1209 max_luns= [SCSI] Maximum number of LUNs to probe.
1200 Should be between 1 and 2^32-1. 1210 Should be between 1 and 2^32-1.
@@ -1294,6 +1304,9 @@ and is between 256 and 4096 characters. It is defined in the file
1294 1304
1295 mga= [HW,DRM] 1305 mga= [HW,DRM]
1296 1306
1307 min_addr=nn[KMG] [KNL,BOOT,ia64] All physical memory below this
1308 physical address is ignored.
1309
1297 mminit_loglevel= 1310 mminit_loglevel=
1298 [KNL] When CONFIG_DEBUG_MEMORY_INIT is set, this 1311 [KNL] When CONFIG_DEBUG_MEMORY_INIT is set, this
1299 parameter allows control of the logging verbosity for 1312 parameter allows control of the logging verbosity for
diff --git a/Documentation/markers.txt b/Documentation/markers.txt
index 089f6138fcd9..6d275e4ef385 100644
--- a/Documentation/markers.txt
+++ b/Documentation/markers.txt
@@ -70,6 +70,20 @@ a printk warning which identifies the inconsistency:
70 70
71"Format mismatch for probe probe_name (format), marker (format)" 71"Format mismatch for probe probe_name (format), marker (format)"
72 72
73Another way to use markers is to simply define the marker without generating any
74function call to actually call into the marker. This is useful in combination
75with tracepoint probes in a scheme like this :
76
77void probe_tracepoint_name(unsigned int arg1, struct task_struct *tsk);
78
79DEFINE_MARKER_TP(marker_eventname, tracepoint_name, probe_tracepoint_name,
80 "arg1 %u pid %d");
81
82notrace void probe_tracepoint_name(unsigned int arg1, struct task_struct *tsk)
83{
84 struct marker *marker = &GET_MARKER(kernel_irq_entry);
85 /* write data to trace buffers ... */
86}
73 87
74* Probe / marker example 88* Probe / marker example
75 89
diff --git a/Documentation/networking/phy.txt b/Documentation/networking/phy.txt
index 8df6a7b0e66c..88bb71b46da4 100644
--- a/Documentation/networking/phy.txt
+++ b/Documentation/networking/phy.txt
@@ -96,7 +96,7 @@ Letting the PHY Abstraction Layer do Everything
96 static void adjust_link(struct net_device *dev); 96 static void adjust_link(struct net_device *dev);
97 97
98 Next, you need to know the device name of the PHY connected to this device. 98 Next, you need to know the device name of the PHY connected to this device.
99 The name will look something like, "phy0:0", where the first number is the 99 The name will look something like, "0:00", where the first number is the
100 bus id, and the second is the PHY's address on that bus. Typically, 100 bus id, and the second is the PHY's address on that bus. Typically,
101 the bus is responsible for making its ID unique. 101 the bus is responsible for making its ID unique.
102 102
diff --git a/Documentation/tracepoints.txt b/Documentation/tracepoints.txt
index 5d354e167494..2d42241a25c3 100644
--- a/Documentation/tracepoints.txt
+++ b/Documentation/tracepoints.txt
@@ -3,28 +3,30 @@
3 Mathieu Desnoyers 3 Mathieu Desnoyers
4 4
5 5
6This document introduces Linux Kernel Tracepoints and their use. It provides 6This document introduces Linux Kernel Tracepoints and their use. It
7examples of how to insert tracepoints in the kernel and connect probe functions 7provides examples of how to insert tracepoints in the kernel and
8to them and provides some examples of probe functions. 8connect probe functions to them and provides some examples of probe
9functions.
9 10
10 11
11* Purpose of tracepoints 12* Purpose of tracepoints
12 13
13A tracepoint placed in code provides a hook to call a function (probe) that you 14A tracepoint placed in code provides a hook to call a function (probe)
14can provide at runtime. A tracepoint can be "on" (a probe is connected to it) or 15that you can provide at runtime. A tracepoint can be "on" (a probe is
15"off" (no probe is attached). When a tracepoint is "off" it has no effect, 16connected to it) or "off" (no probe is attached). When a tracepoint is
16except for adding a tiny time penalty (checking a condition for a branch) and 17"off" it has no effect, except for adding a tiny time penalty
17space penalty (adding a few bytes for the function call at the end of the 18(checking a condition for a branch) and space penalty (adding a few
18instrumented function and adds a data structure in a separate section). When a 19bytes for the function call at the end of the instrumented function
19tracepoint is "on", the function you provide is called each time the tracepoint 20and adds a data structure in a separate section). When a tracepoint
20is executed, in the execution context of the caller. When the function provided 21is "on", the function you provide is called each time the tracepoint
21ends its execution, it returns to the caller (continuing from the tracepoint 22is executed, in the execution context of the caller. When the function
22site). 23provided ends its execution, it returns to the caller (continuing from
24the tracepoint site).
23 25
24You can put tracepoints at important locations in the code. They are 26You can put tracepoints at important locations in the code. They are
25lightweight hooks that can pass an arbitrary number of parameters, 27lightweight hooks that can pass an arbitrary number of parameters,
26which prototypes are described in a tracepoint declaration placed in a header 28which prototypes are described in a tracepoint declaration placed in a
27file. 29header file.
28 30
29They can be used for tracing and performance accounting. 31They can be used for tracing and performance accounting.
30 32
@@ -42,7 +44,7 @@ In include/trace/subsys.h :
42 44
43#include <linux/tracepoint.h> 45#include <linux/tracepoint.h>
44 46
45DEFINE_TRACE(subsys_eventname, 47DECLARE_TRACE(subsys_eventname,
46 TPPTOTO(int firstarg, struct task_struct *p), 48 TPPTOTO(int firstarg, struct task_struct *p),
47 TPARGS(firstarg, p)); 49 TPARGS(firstarg, p));
48 50
@@ -50,6 +52,8 @@ In subsys/file.c (where the tracing statement must be added) :
50 52
51#include <trace/subsys.h> 53#include <trace/subsys.h>
52 54
55DEFINE_TRACE(subsys_eventname);
56
53void somefct(void) 57void somefct(void)
54{ 58{
55 ... 59 ...
@@ -61,31 +65,41 @@ Where :
61- subsys_eventname is an identifier unique to your event 65- subsys_eventname is an identifier unique to your event
62 - subsys is the name of your subsystem. 66 - subsys is the name of your subsystem.
63 - eventname is the name of the event to trace. 67 - eventname is the name of the event to trace.
64- TPPTOTO(int firstarg, struct task_struct *p) is the prototype of the function
65 called by this tracepoint.
66- TPARGS(firstarg, p) are the parameters names, same as found in the prototype.
67 68
68Connecting a function (probe) to a tracepoint is done by providing a probe 69- TPPTOTO(int firstarg, struct task_struct *p) is the prototype of the
69(function to call) for the specific tracepoint through 70 function called by this tracepoint.
70register_trace_subsys_eventname(). Removing a probe is done through
71unregister_trace_subsys_eventname(); it will remove the probe sure there is no
72caller left using the probe when it returns. Probe removal is preempt-safe
73because preemption is disabled around the probe call. See the "Probe example"
74section below for a sample probe module.
75
76The tracepoint mechanism supports inserting multiple instances of the same
77tracepoint, but a single definition must be made of a given tracepoint name over
78all the kernel to make sure no type conflict will occur. Name mangling of the
79tracepoints is done using the prototypes to make sure typing is correct.
80Verification of probe type correctness is done at the registration site by the
81compiler. Tracepoints can be put in inline functions, inlined static functions,
82and unrolled loops as well as regular functions.
83
84The naming scheme "subsys_event" is suggested here as a convention intended
85to limit collisions. Tracepoint names are global to the kernel: they are
86considered as being the same whether they are in the core kernel image or in
87modules.
88 71
72- TPARGS(firstarg, p) are the parameters names, same as found in the
73 prototype.
74
75Connecting a function (probe) to a tracepoint is done by providing a
76probe (function to call) for the specific tracepoint through
77register_trace_subsys_eventname(). Removing a probe is done through
78unregister_trace_subsys_eventname(); it will remove the probe.
79
80tracepoint_synchronize_unregister() must be called before the end of
81the module exit function to make sure there is no caller left using
82the probe. This, and the fact that preemption is disabled around the
83probe call, make sure that probe removal and module unload are safe.
84See the "Probe example" section below for a sample probe module.
85
86The tracepoint mechanism supports inserting multiple instances of the
87same tracepoint, but a single definition must be made of a given
88tracepoint name over all the kernel to make sure no type conflict will
89occur. Name mangling of the tracepoints is done using the prototypes
90to make sure typing is correct. Verification of probe type correctness
91is done at the registration site by the compiler. Tracepoints can be
92put in inline functions, inlined static functions, and unrolled loops
93as well as regular functions.
94
95The naming scheme "subsys_event" is suggested here as a convention
96intended to limit collisions. Tracepoint names are global to the
97kernel: they are considered as being the same whether they are in the
98core kernel image or in modules.
99
100If the tracepoint has to be used in kernel modules, an
101EXPORT_TRACEPOINT_SYMBOL_GPL() or EXPORT_TRACEPOINT_SYMBOL() can be
102used to export the defined tracepoints.
89 103
90* Probe / tracepoint example 104* Probe / tracepoint example
91 105
diff --git a/MAINTAINERS b/MAINTAINERS
index 627e4c89328e..618c1ef4a397 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -1809,7 +1809,7 @@ S: Maintained
1809 1809
1810FTRACE 1810FTRACE
1811P: Steven Rostedt 1811P: Steven Rostedt
1812M: srostedt@redhat.com 1812M: rostedt@goodmis.org
1813S: Maintained 1813S: Maintained
1814 1814
1815FUJITSU FR-V (FRV) PORT 1815FUJITSU FR-V (FRV) PORT
diff --git a/Makefile b/Makefile
index a9ae5dc0aa16..7b1f2384094f 100644
--- a/Makefile
+++ b/Makefile
@@ -1,7 +1,7 @@
1VERSION = 2 1VERSION = 2
2PATCHLEVEL = 6 2PATCHLEVEL = 6
3SUBLEVEL = 28 3SUBLEVEL = 28
4EXTRAVERSION = -rc5 4EXTRAVERSION = -rc6
5NAME = Killer Bat of Doom 5NAME = Killer Bat of Doom
6 6
7# *DOCUMENTATION* 7# *DOCUMENTATION*
diff --git a/arch/arm/mach-pxa/include/mach/pxafb.h b/arch/arm/mach-pxa/include/mach/pxafb.h
index 8e591118371e..cbda4d35c421 100644
--- a/arch/arm/mach-pxa/include/mach/pxafb.h
+++ b/arch/arm/mach-pxa/include/mach/pxafb.h
@@ -33,6 +33,7 @@
33#define LCD_CONN_TYPE(_x) ((_x) & 0x0f) 33#define LCD_CONN_TYPE(_x) ((_x) & 0x0f)
34#define LCD_CONN_WIDTH(_x) (((_x) >> 4) & 0x1f) 34#define LCD_CONN_WIDTH(_x) (((_x) >> 4) & 0x1f)
35 35
36#define LCD_TYPE_MASK 0xf
36#define LCD_TYPE_UNKNOWN 0 37#define LCD_TYPE_UNKNOWN 0
37#define LCD_TYPE_MONO_STN 1 38#define LCD_TYPE_MONO_STN 1
38#define LCD_TYPE_MONO_DSTN 2 39#define LCD_TYPE_MONO_DSTN 2
diff --git a/arch/arm/mach-pxa/reset.c b/arch/arm/mach-pxa/reset.c
index 1b2af575c40f..00b2dc2a1074 100644
--- a/arch/arm/mach-pxa/reset.c
+++ b/arch/arm/mach-pxa/reset.c
@@ -90,12 +90,13 @@ void arch_reset(char mode)
90 /* Jump into ROM at address 0 */ 90 /* Jump into ROM at address 0 */
91 cpu_reset(0); 91 cpu_reset(0);
92 break; 92 break;
93 case 'h':
94 do_hw_reset();
95 break;
96 case 'g': 93 case 'g':
97 do_gpio_reset(); 94 do_gpio_reset();
98 break; 95 break;
96 case 'h':
97 default:
98 do_hw_reset();
99 break;
99 } 100 }
100} 101}
101 102
diff --git a/arch/arm/mach-pxa/spitz.c b/arch/arm/mach-pxa/spitz.c
index f0a5bbae0b45..3be76ee2bdbf 100644
--- a/arch/arm/mach-pxa/spitz.c
+++ b/arch/arm/mach-pxa/spitz.c
@@ -67,6 +67,7 @@
67static unsigned long spitz_pin_config[] __initdata = { 67static unsigned long spitz_pin_config[] __initdata = {
68 /* Chip Selects */ 68 /* Chip Selects */
69 GPIO78_nCS_2, /* SCOOP #2 */ 69 GPIO78_nCS_2, /* SCOOP #2 */
70 GPIO79_nCS_3, /* NAND */
70 GPIO80_nCS_4, /* SCOOP #1 */ 71 GPIO80_nCS_4, /* SCOOP #1 */
71 72
72 /* LCD - 16bpp Active TFT */ 73 /* LCD - 16bpp Active TFT */
@@ -97,10 +98,10 @@ static unsigned long spitz_pin_config[] __initdata = {
97 GPIO51_nPIOW, 98 GPIO51_nPIOW,
98 GPIO85_nPCE_1, 99 GPIO85_nPCE_1,
99 GPIO54_nPCE_2, 100 GPIO54_nPCE_2,
100 GPIO79_PSKTSEL,
101 GPIO55_nPREG, 101 GPIO55_nPREG,
102 GPIO56_nPWAIT, 102 GPIO56_nPWAIT,
103 GPIO57_nIOIS16, 103 GPIO57_nIOIS16,
104 GPIO104_PSKTSEL,
104 105
105 /* MMC */ 106 /* MMC */
106 GPIO32_MMC_CLK, 107 GPIO32_MMC_CLK,
@@ -686,7 +687,6 @@ static void __init akita_init(void)
686 spitz_pcmcia_config.num_devs = 1; 687 spitz_pcmcia_config.num_devs = 1;
687 platform_scoop_config = &spitz_pcmcia_config; 688 platform_scoop_config = &spitz_pcmcia_config;
688 689
689 pxa_set_i2c_info(NULL);
690 i2c_register_board_info(0, ARRAY_AND_SIZE(akita_i2c_board_info)); 690 i2c_register_board_info(0, ARRAY_AND_SIZE(akita_i2c_board_info));
691 691
692 common_init(); 692 common_init();
diff --git a/arch/ia64/include/asm/intrinsics.h b/arch/ia64/include/asm/intrinsics.h
index 47d686dba1eb..a3e44a5ed497 100644
--- a/arch/ia64/include/asm/intrinsics.h
+++ b/arch/ia64/include/asm/intrinsics.h
@@ -226,7 +226,7 @@ extern long ia64_cmpxchg_called_with_bad_pointer (void);
226/************************************************/ 226/************************************************/
227#define ia64_ssm IA64_INTRINSIC_MACRO(ssm) 227#define ia64_ssm IA64_INTRINSIC_MACRO(ssm)
228#define ia64_rsm IA64_INTRINSIC_MACRO(rsm) 228#define ia64_rsm IA64_INTRINSIC_MACRO(rsm)
229#define ia64_getreg IA64_INTRINSIC_API(getreg) 229#define ia64_getreg IA64_INTRINSIC_MACRO(getreg)
230#define ia64_setreg IA64_INTRINSIC_API(setreg) 230#define ia64_setreg IA64_INTRINSIC_API(setreg)
231#define ia64_set_rr IA64_INTRINSIC_API(set_rr) 231#define ia64_set_rr IA64_INTRINSIC_API(set_rr)
232#define ia64_get_rr IA64_INTRINSIC_API(get_rr) 232#define ia64_get_rr IA64_INTRINSIC_API(get_rr)
diff --git a/arch/ia64/include/asm/paravirt_privop.h b/arch/ia64/include/asm/paravirt_privop.h
index d577aac11835..0b597424fcfc 100644
--- a/arch/ia64/include/asm/paravirt_privop.h
+++ b/arch/ia64/include/asm/paravirt_privop.h
@@ -78,6 +78,19 @@ extern unsigned long ia64_native_getreg_func(int regnum);
78 ia64_native_rsm(mask); \ 78 ia64_native_rsm(mask); \
79 } while (0) 79 } while (0)
80 80
81/* returned ip value should be the one in the caller,
82 * not in __paravirt_getreg() */
83#define paravirt_getreg(reg) \
84 ({ \
85 unsigned long res; \
86 BUILD_BUG_ON(!__builtin_constant_p(reg)); \
87 if ((reg) == _IA64_REG_IP) \
88 res = ia64_native_getreg(_IA64_REG_IP); \
89 else \
90 res = pv_cpu_ops.getreg(reg); \
91 res; \
92 })
93
81/****************************************************************************** 94/******************************************************************************
82 * replacement of hand written assembly codes. 95 * replacement of hand written assembly codes.
83 */ 96 */
diff --git a/arch/ia64/kernel/entry.S b/arch/ia64/kernel/entry.S
index 7ef0c594f5ed..d435f4a7a96c 100644
--- a/arch/ia64/kernel/entry.S
+++ b/arch/ia64/kernel/entry.S
@@ -499,6 +499,7 @@ GLOBAL_ENTRY(prefetch_stack)
499END(prefetch_stack) 499END(prefetch_stack)
500 500
501GLOBAL_ENTRY(kernel_execve) 501GLOBAL_ENTRY(kernel_execve)
502 rum psr.ac
502 mov r15=__NR_execve // put syscall number in place 503 mov r15=__NR_execve // put syscall number in place
503 break __BREAK_SYSCALL 504 break __BREAK_SYSCALL
504 br.ret.sptk.many rp 505 br.ret.sptk.many rp
diff --git a/arch/ia64/kernel/head.S b/arch/ia64/kernel/head.S
index 66e491d8baac..59301c472800 100644
--- a/arch/ia64/kernel/head.S
+++ b/arch/ia64/kernel/head.S
@@ -260,7 +260,7 @@ start_ap:
260 * Switch into virtual mode: 260 * Switch into virtual mode:
261 */ 261 */
262 movl r16=(IA64_PSR_IT|IA64_PSR_IC|IA64_PSR_DT|IA64_PSR_RT|IA64_PSR_DFH|IA64_PSR_BN \ 262 movl r16=(IA64_PSR_IT|IA64_PSR_IC|IA64_PSR_DT|IA64_PSR_RT|IA64_PSR_DFH|IA64_PSR_BN \
263 |IA64_PSR_DI) 263 |IA64_PSR_DI|IA64_PSR_AC)
264 ;; 264 ;;
265 mov cr.ipsr=r16 265 mov cr.ipsr=r16
266 movl r17=1f 266 movl r17=1f
diff --git a/arch/ia64/kernel/mca.c b/arch/ia64/kernel/mca.c
index 7dd96c127177..bab1de2d2f6a 100644
--- a/arch/ia64/kernel/mca.c
+++ b/arch/ia64/kernel/mca.c
@@ -1139,7 +1139,7 @@ ia64_mca_modify_original_stack(struct pt_regs *regs,
1139 return previous_current; 1139 return previous_current;
1140 1140
1141no_mod: 1141no_mod:
1142 printk(KERN_INFO "cpu %d, %s %s, original stack not modified\n", 1142 mprintk(KERN_INFO "cpu %d, %s %s, original stack not modified\n",
1143 smp_processor_id(), type, msg); 1143 smp_processor_id(), type, msg);
1144 return previous_current; 1144 return previous_current;
1145} 1145}
diff --git a/arch/ia64/kernel/paravirt.c b/arch/ia64/kernel/paravirt.c
index de35d8e8b7d2..9f14c16f6369 100644
--- a/arch/ia64/kernel/paravirt.c
+++ b/arch/ia64/kernel/paravirt.c
@@ -130,7 +130,7 @@ ia64_native_getreg_func(int regnum)
130 unsigned long res = -1; 130 unsigned long res = -1;
131 switch (regnum) { 131 switch (regnum) {
132 CASE_GET_REG(GP); 132 CASE_GET_REG(GP);
133 CASE_GET_REG(IP); 133 /*CASE_GET_REG(IP);*/ /* returned ip value shouldn't be constant */
134 CASE_GET_REG(PSR); 134 CASE_GET_REG(PSR);
135 CASE_GET_REG(TP); 135 CASE_GET_REG(TP);
136 CASE_GET_REG(SP); 136 CASE_GET_REG(SP);
diff --git a/arch/ia64/kernel/pci-dma.c b/arch/ia64/kernel/pci-dma.c
index dbdb778efa05..2a92f637431d 100644
--- a/arch/ia64/kernel/pci-dma.c
+++ b/arch/ia64/kernel/pci-dma.c
@@ -19,7 +19,6 @@
19#include <linux/kernel.h> 19#include <linux/kernel.h>
20 20
21#include <asm/page.h> 21#include <asm/page.h>
22#include <asm/iommu.h>
23 22
24dma_addr_t bad_dma_address __read_mostly; 23dma_addr_t bad_dma_address __read_mostly;
25EXPORT_SYMBOL(bad_dma_address); 24EXPORT_SYMBOL(bad_dma_address);
diff --git a/arch/ia64/xen/hypercall.S b/arch/ia64/xen/hypercall.S
index d4ff0b9e79f1..45e02bb64a92 100644
--- a/arch/ia64/xen/hypercall.S
+++ b/arch/ia64/xen/hypercall.S
@@ -58,7 +58,7 @@ __HCALL2(xen_set_rr, HYPERPRIVOP_SET_RR)
58__HCALL2(xen_set_kr, HYPERPRIVOP_SET_KR) 58__HCALL2(xen_set_kr, HYPERPRIVOP_SET_KR)
59 59
60#ifdef CONFIG_IA32_SUPPORT 60#ifdef CONFIG_IA32_SUPPORT
61__HCALL1(xen_get_eflag, HYPERPRIVOP_GET_EFLAG) 61__HCALL0(xen_get_eflag, HYPERPRIVOP_GET_EFLAG)
62__HCALL1(xen_set_eflag, HYPERPRIVOP_SET_EFLAG) // refer SDM vol1 3.1.8 62__HCALL1(xen_set_eflag, HYPERPRIVOP_SET_EFLAG) // refer SDM vol1 3.1.8
63#endif /* CONFIG_IA32_SUPPORT */ 63#endif /* CONFIG_IA32_SUPPORT */
64 64
diff --git a/arch/mips/include/asm/mach-rc32434/gpio.h b/arch/mips/include/asm/mach-rc32434/gpio.h
index c8e554eafce3..b5cf6457305a 100644
--- a/arch/mips/include/asm/mach-rc32434/gpio.h
+++ b/arch/mips/include/asm/mach-rc32434/gpio.h
@@ -84,5 +84,7 @@ extern void set_434_reg(unsigned reg_offs, unsigned bit, unsigned len, unsigned
84extern unsigned get_434_reg(unsigned reg_offs); 84extern unsigned get_434_reg(unsigned reg_offs);
85extern void set_latch_u5(unsigned char or_mask, unsigned char nand_mask); 85extern void set_latch_u5(unsigned char or_mask, unsigned char nand_mask);
86extern unsigned char get_latch_u5(void); 86extern unsigned char get_latch_u5(void);
87extern void rb532_gpio_set_ilevel(int bit, unsigned gpio);
88extern void rb532_gpio_set_istat(int bit, unsigned gpio);
87 89
88#endif /* _RC32434_GPIO_H_ */ 90#endif /* _RC32434_GPIO_H_ */
diff --git a/arch/mips/include/asm/mach-rc32434/rb.h b/arch/mips/include/asm/mach-rc32434/rb.h
index 79e8ef67d0d3..f25a84916703 100644
--- a/arch/mips/include/asm/mach-rc32434/rb.h
+++ b/arch/mips/include/asm/mach-rc32434/rb.h
@@ -40,12 +40,14 @@
40#define BTCS 0x010040 40#define BTCS 0x010040
41#define BTCOMPARE 0x010044 41#define BTCOMPARE 0x010044
42#define GPIOBASE 0x050000 42#define GPIOBASE 0x050000
43#define GPIOCFG 0x050004 43/* Offsets relative to GPIOBASE */
44#define GPIOD 0x050008 44#define GPIOFUNC 0x00
45#define GPIOILEVEL 0x05000C 45#define GPIOCFG 0x04
46#define GPIOISTAT 0x050010 46#define GPIOD 0x08
47#define GPIONMIEN 0x050014 47#define GPIOILEVEL 0x0C
48#define IMASK6 0x038038 48#define GPIOISTAT 0x10
49#define GPIONMIEN 0x14
50#define IMASK6 0x38
49#define LO_WPX (1 << 0) 51#define LO_WPX (1 << 0)
50#define LO_ALE (1 << 1) 52#define LO_ALE (1 << 1)
51#define LO_CLE (1 << 2) 53#define LO_CLE (1 << 2)
diff --git a/arch/mips/include/asm/time.h b/arch/mips/include/asm/time.h
index d3bd5c5aa2ec..9601ea950542 100644
--- a/arch/mips/include/asm/time.h
+++ b/arch/mips/include/asm/time.h
@@ -63,7 +63,7 @@ static inline int mips_clockevent_init(void)
63/* 63/*
64 * Initialize the count register as a clocksource 64 * Initialize the count register as a clocksource
65 */ 65 */
66#ifdef CONFIG_CEVT_R4K 66#ifdef CONFIG_CSRC_R4K
67extern int init_mips_clocksource(void); 67extern int init_mips_clocksource(void);
68#else 68#else
69static inline int init_mips_clocksource(void) 69static inline int init_mips_clocksource(void)
diff --git a/arch/mips/kernel/csrc-r4k.c b/arch/mips/kernel/csrc-r4k.c
index 86e026f067bc..74fb74583b4e 100644
--- a/arch/mips/kernel/csrc-r4k.c
+++ b/arch/mips/kernel/csrc-r4k.c
@@ -27,7 +27,7 @@ int __init init_mips_clocksource(void)
27 if (!cpu_has_counter || !mips_hpt_frequency) 27 if (!cpu_has_counter || !mips_hpt_frequency)
28 return -ENXIO; 28 return -ENXIO;
29 29
30 /* Calclate a somewhat reasonable rating value */ 30 /* Calculate a somewhat reasonable rating value */
31 clocksource_mips.rating = 200 + mips_hpt_frequency / 10000000; 31 clocksource_mips.rating = 200 + mips_hpt_frequency / 10000000;
32 32
33 clocksource_set_clock(&clocksource_mips, mips_hpt_frequency); 33 clocksource_set_clock(&clocksource_mips, mips_hpt_frequency);
diff --git a/arch/mips/mm/sc-ip22.c b/arch/mips/mm/sc-ip22.c
index 1f602a110e10..13adb5782110 100644
--- a/arch/mips/mm/sc-ip22.c
+++ b/arch/mips/mm/sc-ip22.c
@@ -161,7 +161,7 @@ static inline int __init indy_sc_probe(void)
161 161
162/* XXX Check with wje if the Indy caches can differenciate between 162/* XXX Check with wje if the Indy caches can differenciate between
163 writeback + invalidate and just invalidate. */ 163 writeback + invalidate and just invalidate. */
164struct bcache_ops indy_sc_ops = { 164static struct bcache_ops indy_sc_ops = {
165 .bc_enable = indy_sc_enable, 165 .bc_enable = indy_sc_enable,
166 .bc_disable = indy_sc_disable, 166 .bc_disable = indy_sc_disable,
167 .bc_wback_inv = indy_sc_wback_invalidate, 167 .bc_wback_inv = indy_sc_wback_invalidate,
diff --git a/arch/mips/mti-malta/malta-amon.c b/arch/mips/mti-malta/malta-amon.c
index 96236bf33838..df9e526312a2 100644
--- a/arch/mips/mti-malta/malta-amon.c
+++ b/arch/mips/mti-malta/malta-amon.c
@@ -22,9 +22,9 @@
22#include <linux/init.h> 22#include <linux/init.h>
23#include <linux/smp.h> 23#include <linux/smp.h>
24 24
25#include <asm-mips/addrspace.h> 25#include <asm/addrspace.h>
26#include <asm-mips/mips-boards/launch.h> 26#include <asm/mips-boards/launch.h>
27#include <asm-mips/mipsmtregs.h> 27#include <asm/mipsmtregs.h>
28 28
29int amon_cpu_avail(int cpu) 29int amon_cpu_avail(int cpu)
30{ 30{
diff --git a/arch/mips/rb532/devices.c b/arch/mips/rb532/devices.c
index 2f22d714d5b0..c1c29181bd46 100644
--- a/arch/mips/rb532/devices.c
+++ b/arch/mips/rb532/devices.c
@@ -118,7 +118,7 @@ static struct platform_device cf_slot0 = {
118/* Resources and device for NAND */ 118/* Resources and device for NAND */
119static int rb532_dev_ready(struct mtd_info *mtd) 119static int rb532_dev_ready(struct mtd_info *mtd)
120{ 120{
121 return readl(IDT434_REG_BASE + GPIOD) & GPIO_RDY; 121 return gpio_get_value(GPIO_RDY);
122} 122}
123 123
124static void rb532_cmd_ctrl(struct mtd_info *mtd, int cmd, unsigned int ctrl) 124static void rb532_cmd_ctrl(struct mtd_info *mtd, int cmd, unsigned int ctrl)
diff --git a/arch/mips/rb532/gpio.c b/arch/mips/rb532/gpio.c
index 70c4a6726377..0e84c8ab6a39 100644
--- a/arch/mips/rb532/gpio.c
+++ b/arch/mips/rb532/gpio.c
@@ -39,10 +39,6 @@
39struct rb532_gpio_chip { 39struct rb532_gpio_chip {
40 struct gpio_chip chip; 40 struct gpio_chip chip;
41 void __iomem *regbase; 41 void __iomem *regbase;
42 void (*set_int_level)(struct gpio_chip *chip, unsigned offset, int value);
43 int (*get_int_level)(struct gpio_chip *chip, unsigned offset);
44 void (*set_int_status)(struct gpio_chip *chip, unsigned offset, int value);
45 int (*get_int_status)(struct gpio_chip *chip, unsigned offset);
46}; 42};
47 43
48struct mpmc_device dev3; 44struct mpmc_device dev3;
@@ -111,15 +107,47 @@ unsigned char get_latch_u5(void)
111} 107}
112EXPORT_SYMBOL(get_latch_u5); 108EXPORT_SYMBOL(get_latch_u5);
113 109
110/* rb532_set_bit - sanely set a bit
111 *
112 * bitval: new value for the bit
113 * offset: bit index in the 4 byte address range
114 * ioaddr: 4 byte aligned address being altered
115 */
116static inline void rb532_set_bit(unsigned bitval,
117 unsigned offset, void __iomem *ioaddr)
118{
119 unsigned long flags;
120 u32 val;
121
122 bitval = !!bitval; /* map parameter to {0,1} */
123
124 local_irq_save(flags);
125
126 val = readl(ioaddr);
127 val &= ~( ~bitval << offset ); /* unset bit if bitval == 0 */
128 val |= ( bitval << offset ); /* set bit if bitval == 1 */
129 writel(val, ioaddr);
130
131 local_irq_restore(flags);
132}
133
134/* rb532_get_bit - read a bit
135 *
136 * returns the boolean state of the bit, which may be > 1
137 */
138static inline int rb532_get_bit(unsigned offset, void __iomem *ioaddr)
139{
140 return (readl(ioaddr) & (1 << offset));
141}
142
114/* 143/*
115 * Return GPIO level */ 144 * Return GPIO level */
116static int rb532_gpio_get(struct gpio_chip *chip, unsigned offset) 145static int rb532_gpio_get(struct gpio_chip *chip, unsigned offset)
117{ 146{
118 u32 mask = 1 << offset;
119 struct rb532_gpio_chip *gpch; 147 struct rb532_gpio_chip *gpch;
120 148
121 gpch = container_of(chip, struct rb532_gpio_chip, chip); 149 gpch = container_of(chip, struct rb532_gpio_chip, chip);
122 return readl(gpch->regbase + GPIOD) & mask; 150 return rb532_get_bit(offset, gpch->regbase + GPIOD);
123} 151}
124 152
125/* 153/*
@@ -128,23 +156,10 @@ static int rb532_gpio_get(struct gpio_chip *chip, unsigned offset)
128static void rb532_gpio_set(struct gpio_chip *chip, 156static void rb532_gpio_set(struct gpio_chip *chip,
129 unsigned offset, int value) 157 unsigned offset, int value)
130{ 158{
131 unsigned long flags;
132 u32 mask = 1 << offset;
133 u32 tmp;
134 struct rb532_gpio_chip *gpch; 159 struct rb532_gpio_chip *gpch;
135 void __iomem *gpvr;
136 160
137 gpch = container_of(chip, struct rb532_gpio_chip, chip); 161 gpch = container_of(chip, struct rb532_gpio_chip, chip);
138 gpvr = gpch->regbase + GPIOD; 162 rb532_set_bit(value, offset, gpch->regbase + GPIOD);
139
140 local_irq_save(flags);
141 tmp = readl(gpvr);
142 if (value)
143 tmp |= mask;
144 else
145 tmp &= ~mask;
146 writel(tmp, gpvr);
147 local_irq_restore(flags);
148} 163}
149 164
150/* 165/*
@@ -152,21 +167,14 @@ static void rb532_gpio_set(struct gpio_chip *chip,
152 */ 167 */
153static int rb532_gpio_direction_input(struct gpio_chip *chip, unsigned offset) 168static int rb532_gpio_direction_input(struct gpio_chip *chip, unsigned offset)
154{ 169{
155 unsigned long flags;
156 u32 mask = 1 << offset;
157 u32 value;
158 struct rb532_gpio_chip *gpch; 170 struct rb532_gpio_chip *gpch;
159 void __iomem *gpdr;
160 171
161 gpch = container_of(chip, struct rb532_gpio_chip, chip); 172 gpch = container_of(chip, struct rb532_gpio_chip, chip);
162 gpdr = gpch->regbase + GPIOCFG;
163 173
164 local_irq_save(flags); 174 if (rb532_get_bit(offset, gpch->regbase + GPIOFUNC))
165 value = readl(gpdr); 175 return 1; /* alternate function, GPIOCFG is ignored */
166 value &= ~mask;
167 writel(value, gpdr);
168 local_irq_restore(flags);
169 176
177 rb532_set_bit(0, offset, gpch->regbase + GPIOCFG);
170 return 0; 178 return 0;
171} 179}
172 180
@@ -176,117 +184,60 @@ static int rb532_gpio_direction_input(struct gpio_chip *chip, unsigned offset)
176static int rb532_gpio_direction_output(struct gpio_chip *chip, 184static int rb532_gpio_direction_output(struct gpio_chip *chip,
177 unsigned offset, int value) 185 unsigned offset, int value)
178{ 186{
179 unsigned long flags;
180 u32 mask = 1 << offset;
181 u32 tmp;
182 struct rb532_gpio_chip *gpch; 187 struct rb532_gpio_chip *gpch;
183 void __iomem *gpdr;
184 188
185 gpch = container_of(chip, struct rb532_gpio_chip, chip); 189 gpch = container_of(chip, struct rb532_gpio_chip, chip);
186 writel(mask, gpch->regbase + GPIOD);
187 gpdr = gpch->regbase + GPIOCFG;
188 190
189 local_irq_save(flags); 191 if (rb532_get_bit(offset, gpch->regbase + GPIOFUNC))
190 tmp = readl(gpdr); 192 return 1; /* alternate function, GPIOCFG is ignored */
191 tmp |= mask;
192 writel(tmp, gpdr);
193 local_irq_restore(flags);
194 193
194 /* set the initial output value */
195 rb532_set_bit(value, offset, gpch->regbase + GPIOD);
196
197 rb532_set_bit(1, offset, gpch->regbase + GPIOCFG);
195 return 0; 198 return 0;
196} 199}
197 200
198/* 201static struct rb532_gpio_chip rb532_gpio_chip[] = {
199 * Set the GPIO interrupt level 202 [0] = {
200 */ 203 .chip = {
201static void rb532_gpio_set_int_level(struct gpio_chip *chip, 204 .label = "gpio0",
202 unsigned offset, int value) 205 .direction_input = rb532_gpio_direction_input,
203{ 206 .direction_output = rb532_gpio_direction_output,
204 unsigned long flags; 207 .get = rb532_gpio_get,
205 u32 mask = 1 << offset; 208 .set = rb532_gpio_set,
206 u32 tmp; 209 .base = 0,
207 struct rb532_gpio_chip *gpch; 210 .ngpio = 32,
208 void __iomem *gpil; 211 },
209 212 },
210 gpch = container_of(chip, struct rb532_gpio_chip, chip); 213};
211 gpil = gpch->regbase + GPIOILEVEL;
212
213 local_irq_save(flags);
214 tmp = readl(gpil);
215 if (value)
216 tmp |= mask;
217 else
218 tmp &= ~mask;
219 writel(tmp, gpil);
220 local_irq_restore(flags);
221}
222 214
223/* 215/*
224 * Get the GPIO interrupt level 216 * Set GPIO interrupt level
225 */ 217 */
226static int rb532_gpio_get_int_level(struct gpio_chip *chip, unsigned offset) 218void rb532_gpio_set_ilevel(int bit, unsigned gpio)
227{ 219{
228 u32 mask = 1 << offset; 220 rb532_set_bit(bit, gpio, rb532_gpio_chip->regbase + GPIOILEVEL);
229 struct rb532_gpio_chip *gpch;
230
231 gpch = container_of(chip, struct rb532_gpio_chip, chip);
232 return readl(gpch->regbase + GPIOILEVEL) & mask;
233} 221}
222EXPORT_SYMBOL(rb532_gpio_set_ilevel);
234 223
235/* 224/*
236 * Set the GPIO interrupt status 225 * Set GPIO interrupt status
237 */ 226 */
238static void rb532_gpio_set_int_status(struct gpio_chip *chip, 227void rb532_gpio_set_istat(int bit, unsigned gpio)
239 unsigned offset, int value)
240{ 228{
241 unsigned long flags; 229 rb532_set_bit(bit, gpio, rb532_gpio_chip->regbase + GPIOISTAT);
242 u32 mask = 1 << offset;
243 u32 tmp;
244 struct rb532_gpio_chip *gpch;
245 void __iomem *gpis;
246
247 gpch = container_of(chip, struct rb532_gpio_chip, chip);
248 gpis = gpch->regbase + GPIOISTAT;
249
250 local_irq_save(flags);
251 tmp = readl(gpis);
252 if (value)
253 tmp |= mask;
254 else
255 tmp &= ~mask;
256 writel(tmp, gpis);
257 local_irq_restore(flags);
258} 230}
231EXPORT_SYMBOL(rb532_gpio_set_istat);
259 232
260/* 233/*
261 * Get the GPIO interrupt status 234 * Configure GPIO alternate function
262 */ 235 */
263static int rb532_gpio_get_int_status(struct gpio_chip *chip, unsigned offset) 236static void rb532_gpio_set_func(int bit, unsigned gpio)
264{ 237{
265 u32 mask = 1 << offset; 238 rb532_set_bit(bit, gpio, rb532_gpio_chip->regbase + GPIOFUNC);
266 struct rb532_gpio_chip *gpch;
267
268 gpch = container_of(chip, struct rb532_gpio_chip, chip);
269 return readl(gpch->regbase + GPIOISTAT) & mask;
270} 239}
271 240
272static struct rb532_gpio_chip rb532_gpio_chip[] = {
273 [0] = {
274 .chip = {
275 .label = "gpio0",
276 .direction_input = rb532_gpio_direction_input,
277 .direction_output = rb532_gpio_direction_output,
278 .get = rb532_gpio_get,
279 .set = rb532_gpio_set,
280 .base = 0,
281 .ngpio = 32,
282 },
283 .get_int_level = rb532_gpio_get_int_level,
284 .set_int_level = rb532_gpio_set_int_level,
285 .get_int_status = rb532_gpio_get_int_status,
286 .set_int_status = rb532_gpio_set_int_status,
287 },
288};
289
290int __init rb532_gpio_init(void) 241int __init rb532_gpio_init(void)
291{ 242{
292 struct resource *r; 243 struct resource *r;
@@ -310,9 +261,11 @@ int __init rb532_gpio_init(void)
310 return -ENXIO; 261 return -ENXIO;
311 } 262 }
312 263
313 /* Set the interrupt status and level for the CF pin */ 264 /* configure CF_GPIO_NUM as CFRDY IRQ source */
314 rb532_gpio_set_int_level(&rb532_gpio_chip->chip, CF_GPIO_NUM, 1); 265 rb532_gpio_set_func(0, CF_GPIO_NUM);
315 rb532_gpio_set_int_status(&rb532_gpio_chip->chip, CF_GPIO_NUM, 0); 266 rb532_gpio_direction_input(&rb532_gpio_chip->chip, CF_GPIO_NUM);
267 rb532_gpio_set_ilevel(1, CF_GPIO_NUM);
268 rb532_gpio_set_istat(0, CF_GPIO_NUM);
316 269
317 return 0; 270 return 0;
318} 271}
diff --git a/arch/parisc/kernel/ptrace.c b/arch/parisc/kernel/ptrace.c
index 90904f9dfc50..927db3668b6f 100644
--- a/arch/parisc/kernel/ptrace.c
+++ b/arch/parisc/kernel/ptrace.c
@@ -183,10 +183,10 @@ long arch_ptrace(struct task_struct *child, long request, long addr, long data)
183 * being 64 bit in both cases. 183 * being 64 bit in both cases.
184 */ 184 */
185 185
186static long translate_usr_offset(long offset) 186static compat_ulong_t translate_usr_offset(compat_ulong_t offset)
187{ 187{
188 if (offset < 0) 188 if (offset < 0)
189 return -1; 189 return sizeof(struct pt_regs);
190 else if (offset <= 32*4) /* gr[0..31] */ 190 else if (offset <= 32*4) /* gr[0..31] */
191 return offset * 2 + 4; 191 return offset * 2 + 4;
192 else if (offset <= 32*4+32*8) /* gr[0..31] + fr[0..31] */ 192 else if (offset <= 32*4+32*8) /* gr[0..31] + fr[0..31] */
@@ -194,7 +194,7 @@ static long translate_usr_offset(long offset)
194 else if (offset < sizeof(struct pt_regs)/2 + 32*4) 194 else if (offset < sizeof(struct pt_regs)/2 + 32*4)
195 return offset * 2 + 4 - 32*8; 195 return offset * 2 + 4 - 32*8;
196 else 196 else
197 return -1; 197 return sizeof(struct pt_regs);
198} 198}
199 199
200long compat_arch_ptrace(struct task_struct *child, compat_long_t request, 200long compat_arch_ptrace(struct task_struct *child, compat_long_t request,
@@ -209,7 +209,7 @@ long compat_arch_ptrace(struct task_struct *child, compat_long_t request,
209 if (addr & (sizeof(compat_uint_t)-1)) 209 if (addr & (sizeof(compat_uint_t)-1))
210 break; 210 break;
211 addr = translate_usr_offset(addr); 211 addr = translate_usr_offset(addr);
212 if (addr < 0) 212 if (addr >= sizeof(struct pt_regs))
213 break; 213 break;
214 214
215 tmp = *(compat_uint_t *) ((char *) task_regs(child) + addr); 215 tmp = *(compat_uint_t *) ((char *) task_regs(child) + addr);
@@ -236,7 +236,7 @@ long compat_arch_ptrace(struct task_struct *child, compat_long_t request,
236 if (addr & (sizeof(compat_uint_t)-1)) 236 if (addr & (sizeof(compat_uint_t)-1))
237 break; 237 break;
238 addr = translate_usr_offset(addr); 238 addr = translate_usr_offset(addr);
239 if (addr < 0) 239 if (addr >= sizeof(struct pt_regs))
240 break; 240 break;
241 if (addr >= PT_FR0 && addr <= PT_FR31 + 4) { 241 if (addr >= PT_FR0 && addr <= PT_FR31 + 4) {
242 /* Special case, fp regs are 64 bits anyway */ 242 /* Special case, fp regs are 64 bits anyway */
diff --git a/arch/sparc/include/asm/unistd_32.h b/arch/sparc/include/asm/unistd_32.h
index 648643a9f139..0d13d2a4c76f 100644
--- a/arch/sparc/include/asm/unistd_32.h
+++ b/arch/sparc/include/asm/unistd_32.h
@@ -338,8 +338,9 @@
338#define __NR_dup3 320 338#define __NR_dup3 320
339#define __NR_pipe2 321 339#define __NR_pipe2 321
340#define __NR_inotify_init1 322 340#define __NR_inotify_init1 322
341#define __NR_accept4 323
341 342
342#define NR_SYSCALLS 323 343#define NR_SYSCALLS 324
343 344
344/* Sparc 32-bit only has the "setresuid32", "getresuid32" variants, 345/* Sparc 32-bit only has the "setresuid32", "getresuid32" variants,
345 * it never had the plain ones and there is no value to adding those 346 * it never had the plain ones and there is no value to adding those
diff --git a/arch/sparc/include/asm/unistd_64.h b/arch/sparc/include/asm/unistd_64.h
index c5cc0e052321..fa5d3c0343c7 100644
--- a/arch/sparc/include/asm/unistd_64.h
+++ b/arch/sparc/include/asm/unistd_64.h
@@ -340,8 +340,9 @@
340#define __NR_dup3 320 340#define __NR_dup3 320
341#define __NR_pipe2 321 341#define __NR_pipe2 321
342#define __NR_inotify_init1 322 342#define __NR_inotify_init1 322
343#define __NR_accept4 323
343 344
344#define NR_SYSCALLS 323 345#define NR_SYSCALLS 324
345 346
346#ifdef __KERNEL__ 347#ifdef __KERNEL__
347#define __ARCH_WANT_IPC_PARSE_VERSION 348#define __ARCH_WANT_IPC_PARSE_VERSION
diff --git a/arch/sparc/kernel/systbls.S b/arch/sparc/kernel/systbls.S
index e1b9233b90ab..7d0807586442 100644
--- a/arch/sparc/kernel/systbls.S
+++ b/arch/sparc/kernel/systbls.S
@@ -81,4 +81,4 @@ sys_call_table:
81/*305*/ .long sys_set_mempolicy, sys_kexec_load, sys_move_pages, sys_getcpu, sys_epoll_pwait 81/*305*/ .long sys_set_mempolicy, sys_kexec_load, sys_move_pages, sys_getcpu, sys_epoll_pwait
82/*310*/ .long sys_utimensat, sys_signalfd, sys_timerfd_create, sys_eventfd, sys_fallocate 82/*310*/ .long sys_utimensat, sys_signalfd, sys_timerfd_create, sys_eventfd, sys_fallocate
83/*315*/ .long sys_timerfd_settime, sys_timerfd_gettime, sys_signalfd4, sys_eventfd2, sys_epoll_create1 83/*315*/ .long sys_timerfd_settime, sys_timerfd_gettime, sys_signalfd4, sys_eventfd2, sys_epoll_create1
84/*320*/ .long sys_dup3, sys_pipe2, sys_inotify_init1 84/*320*/ .long sys_dup3, sys_pipe2, sys_inotify_init1, sys_accept4
diff --git a/arch/sparc64/kernel/sys32.S b/arch/sparc64/kernel/sys32.S
index ade18ba0c686..f061c4dda9ef 100644
--- a/arch/sparc64/kernel/sys32.S
+++ b/arch/sparc64/kernel/sys32.S
@@ -150,7 +150,7 @@ sys32_mmap2:
150sys32_socketcall: /* %o0=call, %o1=args */ 150sys32_socketcall: /* %o0=call, %o1=args */
151 cmp %o0, 1 151 cmp %o0, 1
152 bl,pn %xcc, do_einval 152 bl,pn %xcc, do_einval
153 cmp %o0, 17 153 cmp %o0, 18
154 bg,pn %xcc, do_einval 154 bg,pn %xcc, do_einval
155 sub %o0, 1, %o0 155 sub %o0, 1, %o0
156 sllx %o0, 5, %o0 156 sllx %o0, 5, %o0
@@ -319,6 +319,15 @@ do_sys_recvmsg: /* compat_sys_recvmsg(int, struct compat_msghdr *, unsigned int)
319 nop 319 nop
320 nop 320 nop
321 nop 321 nop
322do_sys_accept4: /* sys_accept4(int, struct sockaddr *, int *, int) */
32363: ldswa [%o1 + 0x0] %asi, %o0
324 sethi %hi(sys_accept4), %g1
32564: lduwa [%o1 + 0x8] %asi, %o2
32665: ldswa [%o1 + 0xc] %asi, %o3
327 jmpl %g1 + %lo(sys_accept4), %g0
32866: lduwa [%o1 + 0x4] %asi, %o1
329 nop
330 nop
322 331
323 .section __ex_table,"a" 332 .section __ex_table,"a"
324 .align 4 333 .align 4
@@ -353,4 +362,6 @@ do_sys_recvmsg: /* compat_sys_recvmsg(int, struct compat_msghdr *, unsigned int)
353 .word 57b, __retl_efault, 58b, __retl_efault 362 .word 57b, __retl_efault, 58b, __retl_efault
354 .word 59b, __retl_efault, 60b, __retl_efault 363 .word 59b, __retl_efault, 60b, __retl_efault
355 .word 61b, __retl_efault, 62b, __retl_efault 364 .word 61b, __retl_efault, 62b, __retl_efault
365 .word 63b, __retl_efault, 64b, __retl_efault
366 .word 65b, __retl_efault, 66b, __retl_efault
356 .previous 367 .previous
diff --git a/arch/sparc64/kernel/systbls.S b/arch/sparc64/kernel/systbls.S
index b2fa4c163638..9fc78cf354bd 100644
--- a/arch/sparc64/kernel/systbls.S
+++ b/arch/sparc64/kernel/systbls.S
@@ -82,7 +82,7 @@ sys_call_table32:
82 .word compat_sys_set_mempolicy, compat_sys_kexec_load, compat_sys_move_pages, sys_getcpu, compat_sys_epoll_pwait 82 .word compat_sys_set_mempolicy, compat_sys_kexec_load, compat_sys_move_pages, sys_getcpu, compat_sys_epoll_pwait
83/*310*/ .word compat_sys_utimensat, compat_sys_signalfd, sys_timerfd_create, sys_eventfd, compat_sys_fallocate 83/*310*/ .word compat_sys_utimensat, compat_sys_signalfd, sys_timerfd_create, sys_eventfd, compat_sys_fallocate
84 .word compat_sys_timerfd_settime, compat_sys_timerfd_gettime, compat_sys_signalfd4, sys_eventfd2, sys_epoll_create1 84 .word compat_sys_timerfd_settime, compat_sys_timerfd_gettime, compat_sys_signalfd4, sys_eventfd2, sys_epoll_create1
85/*320*/ .word sys_dup3, sys_pipe2, sys_inotify_init1 85/*320*/ .word sys_dup3, sys_pipe2, sys_inotify_init1, sys_accept4
86 86
87#endif /* CONFIG_COMPAT */ 87#endif /* CONFIG_COMPAT */
88 88
@@ -156,4 +156,4 @@ sys_call_table:
156 .word sys_set_mempolicy, sys_kexec_load, sys_move_pages, sys_getcpu, sys_epoll_pwait 156 .word sys_set_mempolicy, sys_kexec_load, sys_move_pages, sys_getcpu, sys_epoll_pwait
157/*310*/ .word sys_utimensat, sys_signalfd, sys_timerfd_create, sys_eventfd, sys_fallocate 157/*310*/ .word sys_utimensat, sys_signalfd, sys_timerfd_create, sys_eventfd, sys_fallocate
158 .word sys_timerfd_settime, sys_timerfd_gettime, sys_signalfd4, sys_eventfd2, sys_epoll_create1 158 .word sys_timerfd_settime, sys_timerfd_gettime, sys_signalfd4, sys_eventfd2, sys_epoll_create1
159/*320*/ .word sys_dup3, sys_pipe2, sys_inotify_init1 159/*320*/ .word sys_dup3, sys_pipe2, sys_inotify_init1, sys_accept4
diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
index 93224b569187..7a146baaa990 100644
--- a/arch/x86/Kconfig
+++ b/arch/x86/Kconfig
@@ -29,6 +29,8 @@ config X86
29 select HAVE_FTRACE_MCOUNT_RECORD 29 select HAVE_FTRACE_MCOUNT_RECORD
30 select HAVE_DYNAMIC_FTRACE 30 select HAVE_DYNAMIC_FTRACE
31 select HAVE_FUNCTION_TRACER 31 select HAVE_FUNCTION_TRACER
32 select HAVE_FUNCTION_RET_TRACER if X86_32
33 select HAVE_FUNCTION_TRACE_MCOUNT_TEST
32 select HAVE_KVM if ((X86_32 && !X86_VOYAGER && !X86_VISWS && !X86_NUMAQ) || X86_64) 34 select HAVE_KVM if ((X86_32 && !X86_VOYAGER && !X86_VISWS && !X86_NUMAQ) || X86_64)
33 select HAVE_ARCH_KGDB if !X86_VOYAGER 35 select HAVE_ARCH_KGDB if !X86_VOYAGER
34 select HAVE_ARCH_TRACEHOOK 36 select HAVE_ARCH_TRACEHOOK
@@ -167,9 +169,12 @@ config GENERIC_PENDING_IRQ
167config X86_SMP 169config X86_SMP
168 bool 170 bool
169 depends on SMP && ((X86_32 && !X86_VOYAGER) || X86_64) 171 depends on SMP && ((X86_32 && !X86_VOYAGER) || X86_64)
170 select USE_GENERIC_SMP_HELPERS
171 default y 172 default y
172 173
174config USE_GENERIC_SMP_HELPERS
175 def_bool y
176 depends on SMP
177
173config X86_32_SMP 178config X86_32_SMP
174 def_bool y 179 def_bool y
175 depends on X86_32 && SMP 180 depends on X86_32 && SMP
@@ -957,7 +962,7 @@ config ARCH_PHYS_ADDR_T_64BIT
957config NUMA 962config NUMA
958 bool "Numa Memory Allocation and Scheduler Support (EXPERIMENTAL)" 963 bool "Numa Memory Allocation and Scheduler Support (EXPERIMENTAL)"
959 depends on SMP 964 depends on SMP
960 depends on X86_64 || (X86_32 && HIGHMEM64G && (X86_NUMAQ || X86_BIGSMP || X86_SUMMIT && ACPI) && BROKEN) 965 depends on X86_64 || (X86_32 && HIGHMEM64G && (X86_NUMAQ || X86_BIGSMP || X86_SUMMIT && ACPI) && EXPERIMENTAL)
961 default n if X86_PC 966 default n if X86_PC
962 default y if (X86_NUMAQ || X86_SUMMIT || X86_BIGSMP) 967 default y if (X86_NUMAQ || X86_SUMMIT || X86_BIGSMP)
963 help 968 help
diff --git a/arch/x86/Kconfig.debug b/arch/x86/Kconfig.debug
index 2a3dfbd5e677..fa013f529b74 100644
--- a/arch/x86/Kconfig.debug
+++ b/arch/x86/Kconfig.debug
@@ -186,14 +186,10 @@ config IOMMU_LEAK
186 Add a simple leak tracer to the IOMMU code. This is useful when you 186 Add a simple leak tracer to the IOMMU code. This is useful when you
187 are debugging a buggy device driver that leaks IOMMU mappings. 187 are debugging a buggy device driver that leaks IOMMU mappings.
188 188
189config MMIOTRACE_HOOKS
190 bool
191
192config MMIOTRACE 189config MMIOTRACE
193 bool "Memory mapped IO tracing" 190 bool "Memory mapped IO tracing"
194 depends on DEBUG_KERNEL && PCI 191 depends on DEBUG_KERNEL && PCI
195 select TRACING 192 select TRACING
196 select MMIOTRACE_HOOKS
197 help 193 help
198 Mmiotrace traces Memory Mapped I/O access and is meant for 194 Mmiotrace traces Memory Mapped I/O access and is meant for
199 debugging and reverse engineering. It is called from the ioremap 195 debugging and reverse engineering. It is called from the ioremap
diff --git a/arch/x86/include/asm/ftrace.h b/arch/x86/include/asm/ftrace.h
index 9e8bc29b8b17..2bb43b433e07 100644
--- a/arch/x86/include/asm/ftrace.h
+++ b/arch/x86/include/asm/ftrace.h
@@ -17,8 +17,41 @@ static inline unsigned long ftrace_call_adjust(unsigned long addr)
17 */ 17 */
18 return addr - 1; 18 return addr - 1;
19} 19}
20#endif
21 20
21#ifdef CONFIG_DYNAMIC_FTRACE
22
23struct dyn_arch_ftrace {
24 /* No extra data needed for x86 */
25};
26
27#endif /* CONFIG_DYNAMIC_FTRACE */
28#endif /* __ASSEMBLY__ */
22#endif /* CONFIG_FUNCTION_TRACER */ 29#endif /* CONFIG_FUNCTION_TRACER */
23 30
31#ifdef CONFIG_FUNCTION_RET_TRACER
32#define FTRACE_RET_STACK_SIZE 20
33
34#ifndef __ASSEMBLY__
35
36/*
37 * Stack of return addresses for functions
38 * of a thread.
39 * Used in struct thread_info
40 */
41struct ftrace_ret_stack {
42 unsigned long ret;
43 unsigned long func;
44 unsigned long long calltime;
45};
46
47/*
48 * Primary handler of a function return.
49 * It relays on ftrace_return_to_handler.
50 * Defined in entry32.S
51 */
52extern void return_to_handler(void);
53
54#endif /* __ASSEMBLY__ */
55#endif /* CONFIG_FUNCTION_RET_TRACER */
56
24#endif /* _ASM_X86_FTRACE_H */ 57#endif /* _ASM_X86_FTRACE_H */
diff --git a/include/asm-x86/iomap.h b/arch/x86/include/asm/iomap.h
index c1f06289b14b..c1f06289b14b 100644
--- a/include/asm-x86/iomap.h
+++ b/arch/x86/include/asm/iomap.h
diff --git a/arch/x86/include/asm/mmzone_32.h b/arch/x86/include/asm/mmzone_32.h
index 485bdf059ffb..07f1af494ca5 100644
--- a/arch/x86/include/asm/mmzone_32.h
+++ b/arch/x86/include/asm/mmzone_32.h
@@ -34,10 +34,14 @@ static inline void get_memcfg_numa(void)
34 34
35extern int early_pfn_to_nid(unsigned long pfn); 35extern int early_pfn_to_nid(unsigned long pfn);
36 36
37extern void resume_map_numa_kva(pgd_t *pgd);
38
37#else /* !CONFIG_NUMA */ 39#else /* !CONFIG_NUMA */
38 40
39#define get_memcfg_numa get_memcfg_numa_flat 41#define get_memcfg_numa get_memcfg_numa_flat
40 42
43static inline void resume_map_numa_kva(pgd_t *pgd) {}
44
41#endif /* CONFIG_NUMA */ 45#endif /* CONFIG_NUMA */
42 46
43#ifdef CONFIG_DISCONTIGMEM 47#ifdef CONFIG_DISCONTIGMEM
diff --git a/arch/x86/include/asm/thread_info.h b/arch/x86/include/asm/thread_info.h
index e44d379faad2..e90e81ef6ab9 100644
--- a/arch/x86/include/asm/thread_info.h
+++ b/arch/x86/include/asm/thread_info.h
@@ -20,6 +20,8 @@
20struct task_struct; 20struct task_struct;
21struct exec_domain; 21struct exec_domain;
22#include <asm/processor.h> 22#include <asm/processor.h>
23#include <asm/ftrace.h>
24#include <asm/atomic.h>
23 25
24struct thread_info { 26struct thread_info {
25 struct task_struct *task; /* main task structure */ 27 struct task_struct *task; /* main task structure */
@@ -38,8 +40,36 @@ struct thread_info {
38 */ 40 */
39 __u8 supervisor_stack[0]; 41 __u8 supervisor_stack[0];
40#endif 42#endif
43
44#ifdef CONFIG_FUNCTION_RET_TRACER
45 /* Index of current stored adress in ret_stack */
46 int curr_ret_stack;
47 /* Stack of return addresses for return function tracing */
48 struct ftrace_ret_stack ret_stack[FTRACE_RET_STACK_SIZE];
49 /*
50 * Number of functions that haven't been traced
51 * because of depth overrun.
52 */
53 atomic_t trace_overrun;
54#endif
41}; 55};
42 56
57#ifdef CONFIG_FUNCTION_RET_TRACER
58#define INIT_THREAD_INFO(tsk) \
59{ \
60 .task = &tsk, \
61 .exec_domain = &default_exec_domain, \
62 .flags = 0, \
63 .cpu = 0, \
64 .preempt_count = 1, \
65 .addr_limit = KERNEL_DS, \
66 .restart_block = { \
67 .fn = do_no_restart_syscall, \
68 }, \
69 .curr_ret_stack = -1,\
70 .trace_overrun = ATOMIC_INIT(0) \
71}
72#else
43#define INIT_THREAD_INFO(tsk) \ 73#define INIT_THREAD_INFO(tsk) \
44{ \ 74{ \
45 .task = &tsk, \ 75 .task = &tsk, \
@@ -52,6 +82,7 @@ struct thread_info {
52 .fn = do_no_restart_syscall, \ 82 .fn = do_no_restart_syscall, \
53 }, \ 83 }, \
54} 84}
85#endif
55 86
56#define init_thread_info (init_thread_union.thread_info) 87#define init_thread_info (init_thread_union.thread_info)
57#define init_stack (init_thread_union.stack) 88#define init_stack (init_thread_union.stack)
diff --git a/arch/x86/include/asm/uaccess_64.h b/arch/x86/include/asm/uaccess_64.h
index 664f15280f14..f8cfd00db450 100644
--- a/arch/x86/include/asm/uaccess_64.h
+++ b/arch/x86/include/asm/uaccess_64.h
@@ -46,7 +46,7 @@ int __copy_from_user(void *dst, const void __user *src, unsigned size)
46 return ret; 46 return ret;
47 case 10: 47 case 10:
48 __get_user_asm(*(u64 *)dst, (u64 __user *)src, 48 __get_user_asm(*(u64 *)dst, (u64 __user *)src,
49 ret, "q", "", "=r", 16); 49 ret, "q", "", "=r", 10);
50 if (unlikely(ret)) 50 if (unlikely(ret))
51 return ret; 51 return ret;
52 __get_user_asm(*(u16 *)(8 + (char *)dst), 52 __get_user_asm(*(u16 *)(8 + (char *)dst),
diff --git a/arch/x86/include/asm/unistd_64.h b/arch/x86/include/asm/unistd_64.h
index 834b2c1d89fb..d2e415e6666f 100644
--- a/arch/x86/include/asm/unistd_64.h
+++ b/arch/x86/include/asm/unistd_64.h
@@ -639,8 +639,8 @@ __SYSCALL(__NR_fallocate, sys_fallocate)
639__SYSCALL(__NR_timerfd_settime, sys_timerfd_settime) 639__SYSCALL(__NR_timerfd_settime, sys_timerfd_settime)
640#define __NR_timerfd_gettime 287 640#define __NR_timerfd_gettime 287
641__SYSCALL(__NR_timerfd_gettime, sys_timerfd_gettime) 641__SYSCALL(__NR_timerfd_gettime, sys_timerfd_gettime)
642#define __NR_paccept 288 642#define __NR_accept4 288
643__SYSCALL(__NR_paccept, sys_paccept) 643__SYSCALL(__NR_accept4, sys_accept4)
644#define __NR_signalfd4 289 644#define __NR_signalfd4 289
645__SYSCALL(__NR_signalfd4, sys_signalfd4) 645__SYSCALL(__NR_signalfd4, sys_signalfd4)
646#define __NR_eventfd2 290 646#define __NR_eventfd2 290
diff --git a/arch/x86/kernel/Makefile b/arch/x86/kernel/Makefile
index e489ff9cb3e2..1d8ed95da846 100644
--- a/arch/x86/kernel/Makefile
+++ b/arch/x86/kernel/Makefile
@@ -14,6 +14,11 @@ CFLAGS_REMOVE_paravirt-spinlocks.o = -pg
14CFLAGS_REMOVE_ftrace.o = -pg 14CFLAGS_REMOVE_ftrace.o = -pg
15endif 15endif
16 16
17ifdef CONFIG_FUNCTION_RET_TRACER
18# Don't trace __switch_to() but let it for function tracer
19CFLAGS_REMOVE_process_32.o = -pg
20endif
21
17# 22#
18# vsyscalls (which work on the user stack) should have 23# vsyscalls (which work on the user stack) should have
19# no stack-protector checks: 24# no stack-protector checks:
@@ -65,6 +70,7 @@ obj-$(CONFIG_X86_LOCAL_APIC) += apic.o nmi.o
65obj-$(CONFIG_X86_IO_APIC) += io_apic.o 70obj-$(CONFIG_X86_IO_APIC) += io_apic.o
66obj-$(CONFIG_X86_REBOOTFIXUPS) += reboot_fixups_32.o 71obj-$(CONFIG_X86_REBOOTFIXUPS) += reboot_fixups_32.o
67obj-$(CONFIG_DYNAMIC_FTRACE) += ftrace.o 72obj-$(CONFIG_DYNAMIC_FTRACE) += ftrace.o
73obj-$(CONFIG_FUNCTION_RET_TRACER) += ftrace.o
68obj-$(CONFIG_KEXEC) += machine_kexec_$(BITS).o 74obj-$(CONFIG_KEXEC) += machine_kexec_$(BITS).o
69obj-$(CONFIG_KEXEC) += relocate_kernel_$(BITS).o crash.o 75obj-$(CONFIG_KEXEC) += relocate_kernel_$(BITS).o crash.o
70obj-$(CONFIG_CRASH_DUMP) += crash_dump_$(BITS).o 76obj-$(CONFIG_CRASH_DUMP) += crash_dump_$(BITS).o
diff --git a/arch/x86/kernel/amd_iommu.c b/arch/x86/kernel/amd_iommu.c
index 331b318304eb..e4899e0e8787 100644
--- a/arch/x86/kernel/amd_iommu.c
+++ b/arch/x86/kernel/amd_iommu.c
@@ -537,7 +537,7 @@ static void dma_ops_free_addresses(struct dma_ops_domain *dom,
537 address >>= PAGE_SHIFT; 537 address >>= PAGE_SHIFT;
538 iommu_area_free(dom->bitmap, address, pages); 538 iommu_area_free(dom->bitmap, address, pages);
539 539
540 if (address + pages >= dom->next_bit) 540 if (address >= dom->next_bit)
541 dom->need_flush = true; 541 dom->need_flush = true;
542} 542}
543 543
diff --git a/arch/x86/kernel/amd_iommu_init.c b/arch/x86/kernel/amd_iommu_init.c
index 0cdcda35a05f..30ae2701b3df 100644
--- a/arch/x86/kernel/amd_iommu_init.c
+++ b/arch/x86/kernel/amd_iommu_init.c
@@ -121,7 +121,7 @@ u16 amd_iommu_last_bdf; /* largest PCI device id we have
121LIST_HEAD(amd_iommu_unity_map); /* a list of required unity mappings 121LIST_HEAD(amd_iommu_unity_map); /* a list of required unity mappings
122 we find in ACPI */ 122 we find in ACPI */
123unsigned amd_iommu_aperture_order = 26; /* size of aperture in power of 2 */ 123unsigned amd_iommu_aperture_order = 26; /* size of aperture in power of 2 */
124int amd_iommu_isolate; /* if 1, device isolation is enabled */ 124int amd_iommu_isolate = 1; /* if 1, device isolation is enabled */
125bool amd_iommu_unmap_flush; /* if true, flush on every unmap */ 125bool amd_iommu_unmap_flush; /* if true, flush on every unmap */
126 126
127LIST_HEAD(amd_iommu_list); /* list of all AMD IOMMUs in the 127LIST_HEAD(amd_iommu_list); /* list of all AMD IOMMUs in the
@@ -1213,7 +1213,9 @@ static int __init parse_amd_iommu_options(char *str)
1213 for (; *str; ++str) { 1213 for (; *str; ++str) {
1214 if (strncmp(str, "isolate", 7) == 0) 1214 if (strncmp(str, "isolate", 7) == 0)
1215 amd_iommu_isolate = 1; 1215 amd_iommu_isolate = 1;
1216 if (strncmp(str, "fullflush", 11) == 0) 1216 if (strncmp(str, "share", 5) == 0)
1217 amd_iommu_isolate = 0;
1218 if (strncmp(str, "fullflush", 9) == 0)
1217 amd_iommu_unmap_flush = true; 1219 amd_iommu_unmap_flush = true;
1218 } 1220 }
1219 1221
diff --git a/arch/x86/kernel/ds.c b/arch/x86/kernel/ds.c
index 2b69994fd3a8..d1a121443bde 100644
--- a/arch/x86/kernel/ds.c
+++ b/arch/x86/kernel/ds.c
@@ -236,17 +236,33 @@ static inline struct ds_context *ds_alloc_context(struct task_struct *task)
236 struct ds_context *context = *p_context; 236 struct ds_context *context = *p_context;
237 237
238 if (!context) { 238 if (!context) {
239 spin_unlock(&ds_lock);
240
239 context = kzalloc(sizeof(*context), GFP_KERNEL); 241 context = kzalloc(sizeof(*context), GFP_KERNEL);
240 242
241 if (!context) 243 if (!context) {
244 spin_lock(&ds_lock);
242 return NULL; 245 return NULL;
246 }
243 247
244 context->ds = kzalloc(ds_cfg.sizeof_ds, GFP_KERNEL); 248 context->ds = kzalloc(ds_cfg.sizeof_ds, GFP_KERNEL);
245 if (!context->ds) { 249 if (!context->ds) {
246 kfree(context); 250 kfree(context);
251 spin_lock(&ds_lock);
247 return NULL; 252 return NULL;
248 } 253 }
249 254
255 spin_lock(&ds_lock);
256 /*
257 * Check for race - another CPU could have allocated
258 * it meanwhile:
259 */
260 if (*p_context) {
261 kfree(context->ds);
262 kfree(context);
263 return *p_context;
264 }
265
250 *p_context = context; 266 *p_context = context;
251 267
252 context->this = p_context; 268 context->this = p_context;
@@ -384,14 +400,15 @@ static int ds_request(struct task_struct *task, void *base, size_t size,
384 400
385 spin_lock(&ds_lock); 401 spin_lock(&ds_lock);
386 402
387 if (!check_tracer(task))
388 return -EPERM;
389
390 error = -ENOMEM; 403 error = -ENOMEM;
391 context = ds_alloc_context(task); 404 context = ds_alloc_context(task);
392 if (!context) 405 if (!context)
393 goto out_unlock; 406 goto out_unlock;
394 407
408 error = -EPERM;
409 if (!check_tracer(task))
410 goto out_unlock;
411
395 error = -EALREADY; 412 error = -EALREADY;
396 if (context->owner[qual] == current) 413 if (context->owner[qual] == current)
397 goto out_unlock; 414 goto out_unlock;
diff --git a/arch/x86/kernel/entry_32.S b/arch/x86/kernel/entry_32.S
index 28b597ef9ca1..74defe21ba42 100644
--- a/arch/x86/kernel/entry_32.S
+++ b/arch/x86/kernel/entry_32.S
@@ -1157,6 +1157,9 @@ ENTRY(mcount)
1157END(mcount) 1157END(mcount)
1158 1158
1159ENTRY(ftrace_caller) 1159ENTRY(ftrace_caller)
1160 cmpl $0, function_trace_stop
1161 jne ftrace_stub
1162
1160 pushl %eax 1163 pushl %eax
1161 pushl %ecx 1164 pushl %ecx
1162 pushl %edx 1165 pushl %edx
@@ -1180,8 +1183,15 @@ END(ftrace_caller)
1180#else /* ! CONFIG_DYNAMIC_FTRACE */ 1183#else /* ! CONFIG_DYNAMIC_FTRACE */
1181 1184
1182ENTRY(mcount) 1185ENTRY(mcount)
1186 cmpl $0, function_trace_stop
1187 jne ftrace_stub
1188
1183 cmpl $ftrace_stub, ftrace_trace_function 1189 cmpl $ftrace_stub, ftrace_trace_function
1184 jnz trace 1190 jnz trace
1191#ifdef CONFIG_FUNCTION_RET_TRACER
1192 cmpl $ftrace_stub, ftrace_function_return
1193 jnz ftrace_return_caller
1194#endif
1185.globl ftrace_stub 1195.globl ftrace_stub
1186ftrace_stub: 1196ftrace_stub:
1187 ret 1197 ret
@@ -1200,12 +1210,42 @@ trace:
1200 popl %edx 1210 popl %edx
1201 popl %ecx 1211 popl %ecx
1202 popl %eax 1212 popl %eax
1203
1204 jmp ftrace_stub 1213 jmp ftrace_stub
1205END(mcount) 1214END(mcount)
1206#endif /* CONFIG_DYNAMIC_FTRACE */ 1215#endif /* CONFIG_DYNAMIC_FTRACE */
1207#endif /* CONFIG_FUNCTION_TRACER */ 1216#endif /* CONFIG_FUNCTION_TRACER */
1208 1217
1218#ifdef CONFIG_FUNCTION_RET_TRACER
1219ENTRY(ftrace_return_caller)
1220 cmpl $0, function_trace_stop
1221 jne ftrace_stub
1222
1223 pushl %eax
1224 pushl %ecx
1225 pushl %edx
1226 movl 0xc(%esp), %edx
1227 lea 0x4(%ebp), %eax
1228 call prepare_ftrace_return
1229 popl %edx
1230 popl %ecx
1231 popl %eax
1232 ret
1233END(ftrace_return_caller)
1234
1235.globl return_to_handler
1236return_to_handler:
1237 pushl $0
1238 pushl %eax
1239 pushl %ecx
1240 pushl %edx
1241 call ftrace_return_to_handler
1242 movl %eax, 0xc(%esp)
1243 popl %edx
1244 popl %ecx
1245 popl %eax
1246 ret
1247#endif
1248
1209.section .rodata,"a" 1249.section .rodata,"a"
1210#include "syscall_table_32.S" 1250#include "syscall_table_32.S"
1211 1251
diff --git a/arch/x86/kernel/entry_64.S b/arch/x86/kernel/entry_64.S
index b86f332c96a6..08aa6b10933c 100644
--- a/arch/x86/kernel/entry_64.S
+++ b/arch/x86/kernel/entry_64.S
@@ -68,6 +68,8 @@ ENTRY(mcount)
68END(mcount) 68END(mcount)
69 69
70ENTRY(ftrace_caller) 70ENTRY(ftrace_caller)
71 cmpl $0, function_trace_stop
72 jne ftrace_stub
71 73
72 /* taken from glibc */ 74 /* taken from glibc */
73 subq $0x38, %rsp 75 subq $0x38, %rsp
@@ -103,6 +105,9 @@ END(ftrace_caller)
103 105
104#else /* ! CONFIG_DYNAMIC_FTRACE */ 106#else /* ! CONFIG_DYNAMIC_FTRACE */
105ENTRY(mcount) 107ENTRY(mcount)
108 cmpl $0, function_trace_stop
109 jne ftrace_stub
110
106 cmpq $ftrace_stub, ftrace_trace_function 111 cmpq $ftrace_stub, ftrace_trace_function
107 jnz trace 112 jnz trace
108.globl ftrace_stub 113.globl ftrace_stub
diff --git a/arch/x86/kernel/es7000_32.c b/arch/x86/kernel/es7000_32.c
index f454c78fcef6..0aa2c443d600 100644
--- a/arch/x86/kernel/es7000_32.c
+++ b/arch/x86/kernel/es7000_32.c
@@ -250,31 +250,24 @@ int __init find_unisys_acpi_oem_table(unsigned long *oem_addr)
250{ 250{
251 struct acpi_table_header *header = NULL; 251 struct acpi_table_header *header = NULL;
252 int i = 0; 252 int i = 0;
253 acpi_size tbl_size;
254 253
255 while (ACPI_SUCCESS(acpi_get_table_with_size("OEM1", i++, &header, &tbl_size))) { 254 while (ACPI_SUCCESS(acpi_get_table("OEM1", i++, &header))) {
256 if (!memcmp((char *) &header->oem_id, "UNISYS", 6)) { 255 if (!memcmp((char *) &header->oem_id, "UNISYS", 6)) {
257 struct oem_table *t = (struct oem_table *)header; 256 struct oem_table *t = (struct oem_table *)header;
258 257
259 oem_addrX = t->OEMTableAddr; 258 oem_addrX = t->OEMTableAddr;
260 oem_size = t->OEMTableSize; 259 oem_size = t->OEMTableSize;
261 early_acpi_os_unmap_memory(header, tbl_size);
262 260
263 *oem_addr = (unsigned long)__acpi_map_table(oem_addrX, 261 *oem_addr = (unsigned long)__acpi_map_table(oem_addrX,
264 oem_size); 262 oem_size);
265 return 0; 263 return 0;
266 } 264 }
267 early_acpi_os_unmap_memory(header, tbl_size);
268 } 265 }
269 return -1; 266 return -1;
270} 267}
271 268
272void __init unmap_unisys_acpi_oem_table(unsigned long oem_addr) 269void __init unmap_unisys_acpi_oem_table(unsigned long oem_addr)
273{ 270{
274 if (!oem_addr)
275 return;
276
277 __acpi_unmap_table((char *)oem_addr, oem_size);
278} 271}
279#endif 272#endif
280 273
diff --git a/arch/x86/kernel/ftrace.c b/arch/x86/kernel/ftrace.c
index 50ea0ac8c9bf..356bb1eb6e9a 100644
--- a/arch/x86/kernel/ftrace.c
+++ b/arch/x86/kernel/ftrace.c
@@ -14,14 +14,17 @@
14#include <linux/uaccess.h> 14#include <linux/uaccess.h>
15#include <linux/ftrace.h> 15#include <linux/ftrace.h>
16#include <linux/percpu.h> 16#include <linux/percpu.h>
17#include <linux/sched.h>
17#include <linux/init.h> 18#include <linux/init.h>
18#include <linux/list.h> 19#include <linux/list.h>
19 20
20#include <asm/ftrace.h> 21#include <asm/ftrace.h>
22#include <linux/ftrace.h>
21#include <asm/nops.h> 23#include <asm/nops.h>
24#include <asm/nmi.h>
22 25
23 26
24static unsigned char ftrace_nop[MCOUNT_INSN_SIZE]; 27#ifdef CONFIG_DYNAMIC_FTRACE
25 28
26union ftrace_code_union { 29union ftrace_code_union {
27 char code[MCOUNT_INSN_SIZE]; 30 char code[MCOUNT_INSN_SIZE];
@@ -31,18 +34,12 @@ union ftrace_code_union {
31 } __attribute__((packed)); 34 } __attribute__((packed));
32}; 35};
33 36
34
35static int ftrace_calc_offset(long ip, long addr) 37static int ftrace_calc_offset(long ip, long addr)
36{ 38{
37 return (int)(addr - ip); 39 return (int)(addr - ip);
38} 40}
39 41
40unsigned char *ftrace_nop_replace(void) 42static unsigned char *ftrace_call_replace(unsigned long ip, unsigned long addr)
41{
42 return ftrace_nop;
43}
44
45unsigned char *ftrace_call_replace(unsigned long ip, unsigned long addr)
46{ 43{
47 static union ftrace_code_union calc; 44 static union ftrace_code_union calc;
48 45
@@ -56,7 +53,143 @@ unsigned char *ftrace_call_replace(unsigned long ip, unsigned long addr)
56 return calc.code; 53 return calc.code;
57} 54}
58 55
59int 56/*
57 * Modifying code must take extra care. On an SMP machine, if
58 * the code being modified is also being executed on another CPU
59 * that CPU will have undefined results and possibly take a GPF.
60 * We use kstop_machine to stop other CPUS from exectuing code.
61 * But this does not stop NMIs from happening. We still need
62 * to protect against that. We separate out the modification of
63 * the code to take care of this.
64 *
65 * Two buffers are added: An IP buffer and a "code" buffer.
66 *
67 * 1) Put the instruction pointer into the IP buffer
68 * and the new code into the "code" buffer.
69 * 2) Set a flag that says we are modifying code
70 * 3) Wait for any running NMIs to finish.
71 * 4) Write the code
72 * 5) clear the flag.
73 * 6) Wait for any running NMIs to finish.
74 *
75 * If an NMI is executed, the first thing it does is to call
76 * "ftrace_nmi_enter". This will check if the flag is set to write
77 * and if it is, it will write what is in the IP and "code" buffers.
78 *
79 * The trick is, it does not matter if everyone is writing the same
80 * content to the code location. Also, if a CPU is executing code
81 * it is OK to write to that code location if the contents being written
82 * are the same as what exists.
83 */
84
85static atomic_t in_nmi = ATOMIC_INIT(0);
86static int mod_code_status; /* holds return value of text write */
87static int mod_code_write; /* set when NMI should do the write */
88static void *mod_code_ip; /* holds the IP to write to */
89static void *mod_code_newcode; /* holds the text to write to the IP */
90
91static unsigned nmi_wait_count;
92static atomic_t nmi_update_count = ATOMIC_INIT(0);
93
94int ftrace_arch_read_dyn_info(char *buf, int size)
95{
96 int r;
97
98 r = snprintf(buf, size, "%u %u",
99 nmi_wait_count,
100 atomic_read(&nmi_update_count));
101 return r;
102}
103
104static void ftrace_mod_code(void)
105{
106 /*
107 * Yes, more than one CPU process can be writing to mod_code_status.
108 * (and the code itself)
109 * But if one were to fail, then they all should, and if one were
110 * to succeed, then they all should.
111 */
112 mod_code_status = probe_kernel_write(mod_code_ip, mod_code_newcode,
113 MCOUNT_INSN_SIZE);
114
115}
116
117void ftrace_nmi_enter(void)
118{
119 atomic_inc(&in_nmi);
120 /* Must have in_nmi seen before reading write flag */
121 smp_mb();
122 if (mod_code_write) {
123 ftrace_mod_code();
124 atomic_inc(&nmi_update_count);
125 }
126}
127
128void ftrace_nmi_exit(void)
129{
130 /* Finish all executions before clearing in_nmi */
131 smp_wmb();
132 atomic_dec(&in_nmi);
133}
134
135static void wait_for_nmi(void)
136{
137 int waited = 0;
138
139 while (atomic_read(&in_nmi)) {
140 waited = 1;
141 cpu_relax();
142 }
143
144 if (waited)
145 nmi_wait_count++;
146}
147
148static int
149do_ftrace_mod_code(unsigned long ip, void *new_code)
150{
151 mod_code_ip = (void *)ip;
152 mod_code_newcode = new_code;
153
154 /* The buffers need to be visible before we let NMIs write them */
155 smp_wmb();
156
157 mod_code_write = 1;
158
159 /* Make sure write bit is visible before we wait on NMIs */
160 smp_mb();
161
162 wait_for_nmi();
163
164 /* Make sure all running NMIs have finished before we write the code */
165 smp_mb();
166
167 ftrace_mod_code();
168
169 /* Make sure the write happens before clearing the bit */
170 smp_wmb();
171
172 mod_code_write = 0;
173
174 /* make sure NMIs see the cleared bit */
175 smp_mb();
176
177 wait_for_nmi();
178
179 return mod_code_status;
180}
181
182
183
184
185static unsigned char ftrace_nop[MCOUNT_INSN_SIZE];
186
187static unsigned char *ftrace_nop_replace(void)
188{
189 return ftrace_nop;
190}
191
192static int
60ftrace_modify_code(unsigned long ip, unsigned char *old_code, 193ftrace_modify_code(unsigned long ip, unsigned char *old_code,
61 unsigned char *new_code) 194 unsigned char *new_code)
62{ 195{
@@ -81,7 +214,7 @@ ftrace_modify_code(unsigned long ip, unsigned char *old_code,
81 return -EINVAL; 214 return -EINVAL;
82 215
83 /* replace the text with the new text */ 216 /* replace the text with the new text */
84 if (probe_kernel_write((void *)ip, new_code, MCOUNT_INSN_SIZE)) 217 if (do_ftrace_mod_code(ip, new_code))
85 return -EPERM; 218 return -EPERM;
86 219
87 sync_core(); 220 sync_core();
@@ -89,6 +222,29 @@ ftrace_modify_code(unsigned long ip, unsigned char *old_code,
89 return 0; 222 return 0;
90} 223}
91 224
225int ftrace_make_nop(struct module *mod,
226 struct dyn_ftrace *rec, unsigned long addr)
227{
228 unsigned char *new, *old;
229 unsigned long ip = rec->ip;
230
231 old = ftrace_call_replace(ip, addr);
232 new = ftrace_nop_replace();
233
234 return ftrace_modify_code(rec->ip, old, new);
235}
236
237int ftrace_make_call(struct dyn_ftrace *rec, unsigned long addr)
238{
239 unsigned char *new, *old;
240 unsigned long ip = rec->ip;
241
242 old = ftrace_nop_replace();
243 new = ftrace_call_replace(ip, addr);
244
245 return ftrace_modify_code(rec->ip, old, new);
246}
247
92int ftrace_update_ftrace_func(ftrace_func_t func) 248int ftrace_update_ftrace_func(ftrace_func_t func)
93{ 249{
94 unsigned long ip = (unsigned long)(&ftrace_call); 250 unsigned long ip = (unsigned long)(&ftrace_call);
@@ -165,3 +321,138 @@ int __init ftrace_dyn_arch_init(void *data)
165 321
166 return 0; 322 return 0;
167} 323}
324#endif
325
326#ifdef CONFIG_FUNCTION_RET_TRACER
327
328#ifndef CONFIG_DYNAMIC_FTRACE
329
330/*
331 * These functions are picked from those used on
332 * this page for dynamic ftrace. They have been
333 * simplified to ignore all traces in NMI context.
334 */
335static atomic_t in_nmi;
336
337void ftrace_nmi_enter(void)
338{
339 atomic_inc(&in_nmi);
340}
341
342void ftrace_nmi_exit(void)
343{
344 atomic_dec(&in_nmi);
345}
346#endif /* !CONFIG_DYNAMIC_FTRACE */
347
348/* Add a function return address to the trace stack on thread info.*/
349static int push_return_trace(unsigned long ret, unsigned long long time,
350 unsigned long func)
351{
352 int index;
353 struct thread_info *ti = current_thread_info();
354
355 /* The return trace stack is full */
356 if (ti->curr_ret_stack == FTRACE_RET_STACK_SIZE - 1) {
357 atomic_inc(&ti->trace_overrun);
358 return -EBUSY;
359 }
360
361 index = ++ti->curr_ret_stack;
362 barrier();
363 ti->ret_stack[index].ret = ret;
364 ti->ret_stack[index].func = func;
365 ti->ret_stack[index].calltime = time;
366
367 return 0;
368}
369
370/* Retrieve a function return address to the trace stack on thread info.*/
371static void pop_return_trace(unsigned long *ret, unsigned long long *time,
372 unsigned long *func, unsigned long *overrun)
373{
374 int index;
375
376 struct thread_info *ti = current_thread_info();
377 index = ti->curr_ret_stack;
378 *ret = ti->ret_stack[index].ret;
379 *func = ti->ret_stack[index].func;
380 *time = ti->ret_stack[index].calltime;
381 *overrun = atomic_read(&ti->trace_overrun);
382 ti->curr_ret_stack--;
383}
384
385/*
386 * Send the trace to the ring-buffer.
387 * @return the original return address.
388 */
389unsigned long ftrace_return_to_handler(void)
390{
391 struct ftrace_retfunc trace;
392 pop_return_trace(&trace.ret, &trace.calltime, &trace.func,
393 &trace.overrun);
394 trace.rettime = cpu_clock(raw_smp_processor_id());
395 ftrace_function_return(&trace);
396
397 return trace.ret;
398}
399
400/*
401 * Hook the return address and push it in the stack of return addrs
402 * in current thread info.
403 */
404void prepare_ftrace_return(unsigned long *parent, unsigned long self_addr)
405{
406 unsigned long old;
407 unsigned long long calltime;
408 int faulted;
409 unsigned long return_hooker = (unsigned long)
410 &return_to_handler;
411
412 /* Nmi's are currently unsupported */
413 if (atomic_read(&in_nmi))
414 return;
415
416 /*
417 * Protect against fault, even if it shouldn't
418 * happen. This tool is too much intrusive to
419 * ignore such a protection.
420 */
421 asm volatile(
422 "1: movl (%[parent_old]), %[old]\n"
423 "2: movl %[return_hooker], (%[parent_replaced])\n"
424 " movl $0, %[faulted]\n"
425
426 ".section .fixup, \"ax\"\n"
427 "3: movl $1, %[faulted]\n"
428 ".previous\n"
429
430 ".section __ex_table, \"a\"\n"
431 " .long 1b, 3b\n"
432 " .long 2b, 3b\n"
433 ".previous\n"
434
435 : [parent_replaced] "=r" (parent), [old] "=r" (old),
436 [faulted] "=r" (faulted)
437 : [parent_old] "0" (parent), [return_hooker] "r" (return_hooker)
438 : "memory"
439 );
440
441 if (WARN_ON(faulted)) {
442 unregister_ftrace_return();
443 return;
444 }
445
446 if (WARN_ON(!__kernel_text_address(old))) {
447 unregister_ftrace_return();
448 *parent = old;
449 return;
450 }
451
452 calltime = cpu_clock(raw_smp_processor_id());
453
454 if (push_return_trace(old, calltime, self_addr) == -EBUSY)
455 *parent = old;
456}
457
458#endif /* CONFIG_FUNCTION_RET_TRACER */
diff --git a/arch/x86/kernel/io_apic.c b/arch/x86/kernel/io_apic.c
index 7a3f2028e2eb..c9513e1ff28d 100644
--- a/arch/x86/kernel/io_apic.c
+++ b/arch/x86/kernel/io_apic.c
@@ -1140,6 +1140,20 @@ static void __clear_irq_vector(int irq)
1140 1140
1141 cfg->vector = 0; 1141 cfg->vector = 0;
1142 cpus_clear(cfg->domain); 1142 cpus_clear(cfg->domain);
1143
1144 if (likely(!cfg->move_in_progress))
1145 return;
1146 cpus_and(mask, cfg->old_domain, cpu_online_map);
1147 for_each_cpu_mask_nr(cpu, mask) {
1148 for (vector = FIRST_EXTERNAL_VECTOR; vector < NR_VECTORS;
1149 vector++) {
1150 if (per_cpu(vector_irq, cpu)[vector] != irq)
1151 continue;
1152 per_cpu(vector_irq, cpu)[vector] = -1;
1153 break;
1154 }
1155 }
1156 cfg->move_in_progress = 0;
1143} 1157}
1144 1158
1145void __setup_vector_irq(int cpu) 1159void __setup_vector_irq(int cpu)
diff --git a/arch/x86/kernel/reboot.c b/arch/x86/kernel/reboot.c
index 724adfc63cb9..cc5a2545dd41 100644
--- a/arch/x86/kernel/reboot.c
+++ b/arch/x86/kernel/reboot.c
@@ -169,6 +169,15 @@ static struct dmi_system_id __initdata reboot_dmi_table[] = {
169 DMI_MATCH(DMI_BOARD_NAME, "0KW626"), 169 DMI_MATCH(DMI_BOARD_NAME, "0KW626"),
170 }, 170 },
171 }, 171 },
172 { /* Handle problems with rebooting on Dell Optiplex 330 with 0KP561 */
173 .callback = set_bios_reboot,
174 .ident = "Dell OptiPlex 330",
175 .matches = {
176 DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."),
177 DMI_MATCH(DMI_PRODUCT_NAME, "OptiPlex 330"),
178 DMI_MATCH(DMI_BOARD_NAME, "0KP561"),
179 },
180 },
172 { /* Handle problems with rebooting on Dell 2400's */ 181 { /* Handle problems with rebooting on Dell 2400's */
173 .callback = set_bios_reboot, 182 .callback = set_bios_reboot,
174 .ident = "Dell PowerEdge 2400", 183 .ident = "Dell PowerEdge 2400",
diff --git a/arch/x86/kernel/setup.c b/arch/x86/kernel/setup.c
index 0fa6790c1dd3..9d5674f7b6cc 100644
--- a/arch/x86/kernel/setup.c
+++ b/arch/x86/kernel/setup.c
@@ -764,7 +764,7 @@ static struct dmi_system_id __initdata bad_bios_dmi_table[] = {
764 .callback = dmi_low_memory_corruption, 764 .callback = dmi_low_memory_corruption,
765 .ident = "Phoenix BIOS", 765 .ident = "Phoenix BIOS",
766 .matches = { 766 .matches = {
767 DMI_MATCH(DMI_BIOS_VENDOR, "Phoenix Technologies, LTD"), 767 DMI_MATCH(DMI_BIOS_VENDOR, "Phoenix Technologies"),
768 }, 768 },
769 }, 769 },
770#endif 770#endif
diff --git a/arch/x86/kernel/tsc_sync.c b/arch/x86/kernel/tsc_sync.c
index 9ffb01c31c40..1c0dfbca87c1 100644
--- a/arch/x86/kernel/tsc_sync.c
+++ b/arch/x86/kernel/tsc_sync.c
@@ -46,7 +46,9 @@ static __cpuinit void check_tsc_warp(void)
46 cycles_t start, now, prev, end; 46 cycles_t start, now, prev, end;
47 int i; 47 int i;
48 48
49 rdtsc_barrier();
49 start = get_cycles(); 50 start = get_cycles();
51 rdtsc_barrier();
50 /* 52 /*
51 * The measurement runs for 20 msecs: 53 * The measurement runs for 20 msecs:
52 */ 54 */
@@ -61,7 +63,9 @@ static __cpuinit void check_tsc_warp(void)
61 */ 63 */
62 __raw_spin_lock(&sync_lock); 64 __raw_spin_lock(&sync_lock);
63 prev = last_tsc; 65 prev = last_tsc;
66 rdtsc_barrier();
64 now = get_cycles(); 67 now = get_cycles();
68 rdtsc_barrier();
65 last_tsc = now; 69 last_tsc = now;
66 __raw_spin_unlock(&sync_lock); 70 __raw_spin_unlock(&sync_lock);
67 71
diff --git a/arch/x86/kernel/vsyscall_64.c b/arch/x86/kernel/vsyscall_64.c
index 0b8b6690a86d..6f3d3d4cd973 100644
--- a/arch/x86/kernel/vsyscall_64.c
+++ b/arch/x86/kernel/vsyscall_64.c
@@ -17,6 +17,9 @@
17 * want per guest time just set the kernel.vsyscall64 sysctl to 0. 17 * want per guest time just set the kernel.vsyscall64 sysctl to 0.
18 */ 18 */
19 19
20/* Disable profiling for userspace code: */
21#define DISABLE_BRANCH_PROFILING
22
20#include <linux/time.h> 23#include <linux/time.h>
21#include <linux/init.h> 24#include <linux/init.h>
22#include <linux/kernel.h> 25#include <linux/kernel.h>
diff --git a/arch/x86/mach-voyager/voyager_smp.c b/arch/x86/mach-voyager/voyager_smp.c
index 0e331652681e..52145007bd7e 100644
--- a/arch/x86/mach-voyager/voyager_smp.c
+++ b/arch/x86/mach-voyager/voyager_smp.c
@@ -7,6 +7,7 @@
7 * This file provides all the same external entries as smp.c but uses 7 * This file provides all the same external entries as smp.c but uses
8 * the voyager hal to provide the functionality 8 * the voyager hal to provide the functionality
9 */ 9 */
10#include <linux/cpu.h>
10#include <linux/module.h> 11#include <linux/module.h>
11#include <linux/mm.h> 12#include <linux/mm.h>
12#include <linux/kernel_stat.h> 13#include <linux/kernel_stat.h>
@@ -1790,6 +1791,17 @@ void __init smp_setup_processor_id(void)
1790 x86_write_percpu(cpu_number, hard_smp_processor_id()); 1791 x86_write_percpu(cpu_number, hard_smp_processor_id());
1791} 1792}
1792 1793
1794static void voyager_send_call_func(cpumask_t callmask)
1795{
1796 __u32 mask = cpus_addr(callmask)[0] & ~(1 << smp_processor_id());
1797 send_CPI(mask, VIC_CALL_FUNCTION_CPI);
1798}
1799
1800static void voyager_send_call_func_single(int cpu)
1801{
1802 send_CPI(1 << cpu, VIC_CALL_FUNCTION_SINGLE_CPI);
1803}
1804
1793struct smp_ops smp_ops = { 1805struct smp_ops smp_ops = {
1794 .smp_prepare_boot_cpu = voyager_smp_prepare_boot_cpu, 1806 .smp_prepare_boot_cpu = voyager_smp_prepare_boot_cpu,
1795 .smp_prepare_cpus = voyager_smp_prepare_cpus, 1807 .smp_prepare_cpus = voyager_smp_prepare_cpus,
@@ -1799,6 +1811,6 @@ struct smp_ops smp_ops = {
1799 .smp_send_stop = voyager_smp_send_stop, 1811 .smp_send_stop = voyager_smp_send_stop,
1800 .smp_send_reschedule = voyager_smp_send_reschedule, 1812 .smp_send_reschedule = voyager_smp_send_reschedule,
1801 1813
1802 .send_call_func_ipi = native_send_call_func_ipi, 1814 .send_call_func_ipi = voyager_send_call_func,
1803 .send_call_func_single_ipi = native_send_call_func_single_ipi, 1815 .send_call_func_single_ipi = voyager_send_call_func_single,
1804}; 1816};
diff --git a/arch/x86/mm/Makefile b/arch/x86/mm/Makefile
index fea4565ff576..d8cc96a2738f 100644
--- a/arch/x86/mm/Makefile
+++ b/arch/x86/mm/Makefile
@@ -8,9 +8,8 @@ obj-$(CONFIG_X86_PTDUMP) += dump_pagetables.o
8 8
9obj-$(CONFIG_HIGHMEM) += highmem_32.o 9obj-$(CONFIG_HIGHMEM) += highmem_32.o
10 10
11obj-$(CONFIG_MMIOTRACE_HOOKS) += kmmio.o
12obj-$(CONFIG_MMIOTRACE) += mmiotrace.o 11obj-$(CONFIG_MMIOTRACE) += mmiotrace.o
13mmiotrace-y := pf_in.o mmio-mod.o 12mmiotrace-y := kmmio.o pf_in.o mmio-mod.o
14obj-$(CONFIG_MMIOTRACE_TEST) += testmmiotrace.o 13obj-$(CONFIG_MMIOTRACE_TEST) += testmmiotrace.o
15 14
16obj-$(CONFIG_NUMA) += numa_$(BITS).o 15obj-$(CONFIG_NUMA) += numa_$(BITS).o
diff --git a/arch/x86/mm/fault.c b/arch/x86/mm/fault.c
index 31e8730fa246..4152d3c3b138 100644
--- a/arch/x86/mm/fault.c
+++ b/arch/x86/mm/fault.c
@@ -53,7 +53,7 @@
53 53
54static inline int kmmio_fault(struct pt_regs *regs, unsigned long addr) 54static inline int kmmio_fault(struct pt_regs *regs, unsigned long addr)
55{ 55{
56#ifdef CONFIG_MMIOTRACE_HOOKS 56#ifdef CONFIG_MMIOTRACE
57 if (unlikely(is_kmmio_active())) 57 if (unlikely(is_kmmio_active()))
58 if (kmmio_handler(regs, addr) == 1) 58 if (kmmio_handler(regs, addr) == 1)
59 return -1; 59 return -1;
diff --git a/arch/x86/mm/numa_32.c b/arch/x86/mm/numa_32.c
index 847c164725f4..8518c678d83f 100644
--- a/arch/x86/mm/numa_32.c
+++ b/arch/x86/mm/numa_32.c
@@ -222,6 +222,41 @@ static void __init remap_numa_kva(void)
222 } 222 }
223} 223}
224 224
225#ifdef CONFIG_HIBERNATION
226/**
227 * resume_map_numa_kva - add KVA mapping to the temporary page tables created
228 * during resume from hibernation
229 * @pgd_base - temporary resume page directory
230 */
231void resume_map_numa_kva(pgd_t *pgd_base)
232{
233 int node;
234
235 for_each_online_node(node) {
236 unsigned long start_va, start_pfn, size, pfn;
237
238 start_va = (unsigned long)node_remap_start_vaddr[node];
239 start_pfn = node_remap_start_pfn[node];
240 size = node_remap_size[node];
241
242 printk(KERN_DEBUG "%s: node %d\n", __FUNCTION__, node);
243
244 for (pfn = 0; pfn < size; pfn += PTRS_PER_PTE) {
245 unsigned long vaddr = start_va + (pfn << PAGE_SHIFT);
246 pgd_t *pgd = pgd_base + pgd_index(vaddr);
247 pud_t *pud = pud_offset(pgd, vaddr);
248 pmd_t *pmd = pmd_offset(pud, vaddr);
249
250 set_pmd(pmd, pfn_pmd(start_pfn + pfn,
251 PAGE_KERNEL_LARGE_EXEC));
252
253 printk(KERN_DEBUG "%s: %08lx -> pfn %08lx\n",
254 __FUNCTION__, vaddr, start_pfn + pfn);
255 }
256 }
257}
258#endif
259
225static unsigned long calculate_numa_remap_pages(void) 260static unsigned long calculate_numa_remap_pages(void)
226{ 261{
227 int nid; 262 int nid;
diff --git a/arch/x86/power/hibernate_32.c b/arch/x86/power/hibernate_32.c
index f2b6e3f11bfc..81197c62d5b3 100644
--- a/arch/x86/power/hibernate_32.c
+++ b/arch/x86/power/hibernate_32.c
@@ -12,6 +12,7 @@
12#include <asm/system.h> 12#include <asm/system.h>
13#include <asm/page.h> 13#include <asm/page.h>
14#include <asm/pgtable.h> 14#include <asm/pgtable.h>
15#include <asm/mmzone.h>
15 16
16/* Defined in hibernate_asm_32.S */ 17/* Defined in hibernate_asm_32.S */
17extern int restore_image(void); 18extern int restore_image(void);
@@ -127,6 +128,9 @@ static int resume_physical_mapping_init(pgd_t *pgd_base)
127 } 128 }
128 } 129 }
129 } 130 }
131
132 resume_map_numa_kva(pgd_base);
133
130 return 0; 134 return 0;
131} 135}
132 136
diff --git a/arch/x86/vdso/vclock_gettime.c b/arch/x86/vdso/vclock_gettime.c
index 1ef0f90813d6..d9d35824c56f 100644
--- a/arch/x86/vdso/vclock_gettime.c
+++ b/arch/x86/vdso/vclock_gettime.c
@@ -9,6 +9,9 @@
9 * Also alternative() doesn't work. 9 * Also alternative() doesn't work.
10 */ 10 */
11 11
12/* Disable profiling for userspace code: */
13#define DISABLE_BRANCH_PROFILING
14
12#include <linux/kernel.h> 15#include <linux/kernel.h>
13#include <linux/posix-timers.h> 16#include <linux/posix-timers.h>
14#include <linux/time.h> 17#include <linux/time.h>
diff --git a/drivers/block/cciss.c b/drivers/block/cciss.c
index 12de1fdaa6c6..9364dc554257 100644
--- a/drivers/block/cciss.c
+++ b/drivers/block/cciss.c
@@ -2847,7 +2847,7 @@ static void do_cciss_request(struct request_queue *q)
2847 h->maxSG = seg; 2847 h->maxSG = seg;
2848 2848
2849#ifdef CCISS_DEBUG 2849#ifdef CCISS_DEBUG
2850 printk(KERN_DEBUG "cciss: Submitting %d sectors in %d segments\n", 2850 printk(KERN_DEBUG "cciss: Submitting %lu sectors in %d segments\n",
2851 creq->nr_sectors, seg); 2851 creq->nr_sectors, seg);
2852#endif /* CCISS_DEBUG */ 2852#endif /* CCISS_DEBUG */
2853 2853
@@ -3197,7 +3197,7 @@ static int __devinit cciss_pci_init(ctlr_info_t *c, struct pci_dev *pdev)
3197 3197
3198 c->paddr = pci_resource_start(pdev, 0); /* addressing mode bits already removed */ 3198 c->paddr = pci_resource_start(pdev, 0); /* addressing mode bits already removed */
3199#ifdef CCISS_DEBUG 3199#ifdef CCISS_DEBUG
3200 printk("address 0 = %x\n", c->paddr); 3200 printk("address 0 = %lx\n", c->paddr);
3201#endif /* CCISS_DEBUG */ 3201#endif /* CCISS_DEBUG */
3202 c->vaddr = remap_pci_mem(c->paddr, 0x250); 3202 c->vaddr = remap_pci_mem(c->paddr, 0x250);
3203 3203
@@ -3224,7 +3224,8 @@ static int __devinit cciss_pci_init(ctlr_info_t *c, struct pci_dev *pdev)
3224#endif /* CCISS_DEBUG */ 3224#endif /* CCISS_DEBUG */
3225 cfg_base_addr_index = find_PCI_BAR_index(pdev, cfg_base_addr); 3225 cfg_base_addr_index = find_PCI_BAR_index(pdev, cfg_base_addr);
3226#ifdef CCISS_DEBUG 3226#ifdef CCISS_DEBUG
3227 printk("cfg base address index = %x\n", cfg_base_addr_index); 3227 printk("cfg base address index = %llx\n",
3228 (unsigned long long)cfg_base_addr_index);
3228#endif /* CCISS_DEBUG */ 3229#endif /* CCISS_DEBUG */
3229 if (cfg_base_addr_index == -1) { 3230 if (cfg_base_addr_index == -1) {
3230 printk(KERN_WARNING "cciss: Cannot find cfg_base_addr_index\n"); 3231 printk(KERN_WARNING "cciss: Cannot find cfg_base_addr_index\n");
@@ -3234,7 +3235,7 @@ static int __devinit cciss_pci_init(ctlr_info_t *c, struct pci_dev *pdev)
3234 3235
3235 cfg_offset = readl(c->vaddr + SA5_CTMEM_OFFSET); 3236 cfg_offset = readl(c->vaddr + SA5_CTMEM_OFFSET);
3236#ifdef CCISS_DEBUG 3237#ifdef CCISS_DEBUG
3237 printk("cfg offset = %x\n", cfg_offset); 3238 printk("cfg offset = %llx\n", (unsigned long long)cfg_offset);
3238#endif /* CCISS_DEBUG */ 3239#endif /* CCISS_DEBUG */
3239 c->cfgtable = remap_pci_mem(pci_resource_start(pdev, 3240 c->cfgtable = remap_pci_mem(pci_resource_start(pdev,
3240 cfg_base_addr_index) + 3241 cfg_base_addr_index) +
diff --git a/drivers/char/sysrq.c b/drivers/char/sysrq.c
index ce0d9da52a8a..94966edfb44d 100644
--- a/drivers/char/sysrq.c
+++ b/drivers/char/sysrq.c
@@ -274,6 +274,22 @@ static struct sysrq_key_op sysrq_showstate_blocked_op = {
274 .enable_mask = SYSRQ_ENABLE_DUMP, 274 .enable_mask = SYSRQ_ENABLE_DUMP,
275}; 275};
276 276
277#ifdef CONFIG_TRACING
278#include <linux/ftrace.h>
279
280static void sysrq_ftrace_dump(int key, struct tty_struct *tty)
281{
282 ftrace_dump();
283}
284static struct sysrq_key_op sysrq_ftrace_dump_op = {
285 .handler = sysrq_ftrace_dump,
286 .help_msg = "dumpZ-ftrace-buffer",
287 .action_msg = "Dump ftrace buffer",
288 .enable_mask = SYSRQ_ENABLE_DUMP,
289};
290#else
291#define sysrq_ftrace_dump_op (*(struct sysrq_key_op *)0)
292#endif
277 293
278static void sysrq_handle_showmem(int key, struct tty_struct *tty) 294static void sysrq_handle_showmem(int key, struct tty_struct *tty)
279{ 295{
@@ -406,7 +422,7 @@ static struct sysrq_key_op *sysrq_key_table[36] = {
406 NULL, /* x */ 422 NULL, /* x */
407 /* y: May be registered on sparc64 for global register dump */ 423 /* y: May be registered on sparc64 for global register dump */
408 NULL, /* y */ 424 NULL, /* y */
409 NULL /* z */ 425 &sysrq_ftrace_dump_op, /* z */
410}; 426};
411 427
412/* key2index calculation, -1 on invalid index */ 428/* key2index calculation, -1 on invalid index */
diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c
index faa1cc66e9cf..82020abc329e 100644
--- a/drivers/gpio/gpiolib.c
+++ b/drivers/gpio/gpiolib.c
@@ -1134,7 +1134,7 @@ static void gpiolib_dbg_show(struct seq_file *s, struct gpio_chip *chip)
1134 continue; 1134 continue;
1135 1135
1136 is_out = test_bit(FLAG_IS_OUT, &gdesc->flags); 1136 is_out = test_bit(FLAG_IS_OUT, &gdesc->flags);
1137 seq_printf(s, " gpio-%-3d (%-12s) %s %s", 1137 seq_printf(s, " gpio-%-3d (%-20.20s) %s %s",
1138 gpio, gdesc->label, 1138 gpio, gdesc->label,
1139 is_out ? "out" : "in ", 1139 is_out ? "out" : "in ",
1140 chip->get 1140 chip->get
diff --git a/drivers/hwmon/applesmc.c b/drivers/hwmon/applesmc.c
index 488e45cd43d7..f7dce8b9f64b 100644
--- a/drivers/hwmon/applesmc.c
+++ b/drivers/hwmon/applesmc.c
@@ -128,6 +128,9 @@ static const char* temperature_sensors_sets[][36] = {
128/* Set 13: iMac 8,1 */ 128/* Set 13: iMac 8,1 */
129 { "TA0P", "TC0D", "TC0H", "TC0P", "TG0D", "TG0H", "TG0P", "TH0P", 129 { "TA0P", "TC0D", "TC0H", "TC0P", "TG0D", "TG0H", "TG0P", "TH0P",
130 "TL0P", "TO0P", "TW0P", "Tm0P", "Tp0P", NULL }, 130 "TL0P", "TO0P", "TW0P", "Tm0P", "Tp0P", NULL },
131/* Set 14: iMac 6,1 */
132 { "TA0P", "TC0D", "TC0H", "TC0P", "TG0D", "TG0H", "TG0P", "TH0P",
133 "TO0P", "Tp0P", NULL },
131}; 134};
132 135
133/* List of keys used to read/write fan speeds */ 136/* List of keys used to read/write fan speeds */
@@ -1296,6 +1299,8 @@ static __initdata struct dmi_match_data applesmc_dmi_data[] = {
1296 { .accelerometer = 1, .light = 1, .temperature_set = 12 }, 1299 { .accelerometer = 1, .light = 1, .temperature_set = 12 },
1297/* iMac 8: light sensor only, temperature set 13 */ 1300/* iMac 8: light sensor only, temperature set 13 */
1298 { .accelerometer = 0, .light = 0, .temperature_set = 13 }, 1301 { .accelerometer = 0, .light = 0, .temperature_set = 13 },
1302/* iMac 6: light sensor only, temperature set 14 */
1303 { .accelerometer = 0, .light = 0, .temperature_set = 14 },
1299}; 1304};
1300 1305
1301/* Note that DMI_MATCH(...,"MacBook") will match "MacBookPro1,1". 1306/* Note that DMI_MATCH(...,"MacBook") will match "MacBookPro1,1".
@@ -1349,10 +1354,18 @@ static __initdata struct dmi_system_id applesmc_whitelist[] = {
1349 DMI_MATCH(DMI_BOARD_VENDOR,"Apple"), 1354 DMI_MATCH(DMI_BOARD_VENDOR,"Apple"),
1350 DMI_MATCH(DMI_PRODUCT_NAME,"MacPro2") }, 1355 DMI_MATCH(DMI_PRODUCT_NAME,"MacPro2") },
1351 &applesmc_dmi_data[4]}, 1356 &applesmc_dmi_data[4]},
1357 { applesmc_dmi_match, "Apple MacPro", {
1358 DMI_MATCH(DMI_BOARD_VENDOR, "Apple"),
1359 DMI_MATCH(DMI_PRODUCT_NAME, "MacPro") },
1360 &applesmc_dmi_data[4]},
1352 { applesmc_dmi_match, "Apple iMac 8", { 1361 { applesmc_dmi_match, "Apple iMac 8", {
1353 DMI_MATCH(DMI_BOARD_VENDOR, "Apple"), 1362 DMI_MATCH(DMI_BOARD_VENDOR, "Apple"),
1354 DMI_MATCH(DMI_PRODUCT_NAME, "iMac8") }, 1363 DMI_MATCH(DMI_PRODUCT_NAME, "iMac8") },
1355 &applesmc_dmi_data[13]}, 1364 &applesmc_dmi_data[13]},
1365 { applesmc_dmi_match, "Apple iMac 6", {
1366 DMI_MATCH(DMI_BOARD_VENDOR, "Apple"),
1367 DMI_MATCH(DMI_PRODUCT_NAME, "iMac6") },
1368 &applesmc_dmi_data[14]},
1356 { applesmc_dmi_match, "Apple iMac 5", { 1369 { applesmc_dmi_match, "Apple iMac 5", {
1357 DMI_MATCH(DMI_BOARD_VENDOR, "Apple"), 1370 DMI_MATCH(DMI_BOARD_VENDOR, "Apple"),
1358 DMI_MATCH(DMI_PRODUCT_NAME, "iMac5") }, 1371 DMI_MATCH(DMI_PRODUCT_NAME, "iMac5") },
diff --git a/drivers/misc/sgi-gru/Makefile b/drivers/misc/sgi-gru/Makefile
index d03597a521b0..9e9170b3599a 100644
--- a/drivers/misc/sgi-gru/Makefile
+++ b/drivers/misc/sgi-gru/Makefile
@@ -1,3 +1,7 @@
1ifdef CONFIG_SGI_GRU_DEBUG
2 EXTRA_CFLAGS += -DDEBUG
3endif
4
1obj-$(CONFIG_SGI_GRU) := gru.o 5obj-$(CONFIG_SGI_GRU) := gru.o
2gru-y := grufile.o grumain.o grufault.o grutlbpurge.o gruprocfs.o grukservices.o 6gru-y := grufile.o grumain.o grufault.o grutlbpurge.o gruprocfs.o grukservices.o
3 7
diff --git a/drivers/net/atlx/atl2.c b/drivers/net/atlx/atl2.c
index f5bdc92c1a65..8571e8c0bc67 100644
--- a/drivers/net/atlx/atl2.c
+++ b/drivers/net/atlx/atl2.c
@@ -1690,9 +1690,11 @@ static int atl2_resume(struct pci_dev *pdev)
1690 1690
1691 ATL2_WRITE_REG(&adapter->hw, REG_WOL_CTRL, 0); 1691 ATL2_WRITE_REG(&adapter->hw, REG_WOL_CTRL, 0);
1692 1692
1693 err = atl2_request_irq(adapter); 1693 if (netif_running(netdev)) {
1694 if (netif_running(netdev) && err) 1694 err = atl2_request_irq(adapter);
1695 return err; 1695 if (err)
1696 return err;
1697 }
1696 1698
1697 atl2_reset_hw(&adapter->hw); 1699 atl2_reset_hw(&adapter->hw);
1698 1700
diff --git a/drivers/net/ipg.c b/drivers/net/ipg.c
index 7373dafbb3f7..059369885be1 100644
--- a/drivers/net/ipg.c
+++ b/drivers/net/ipg.c
@@ -1112,7 +1112,7 @@ static void ipg_nic_rx_free_skb(struct net_device *dev)
1112 struct ipg_rx *rxfd = sp->rxd + entry; 1112 struct ipg_rx *rxfd = sp->rxd + entry;
1113 1113
1114 pci_unmap_single(sp->pdev, 1114 pci_unmap_single(sp->pdev,
1115 le64_to_cpu(rxfd->frag_info & ~IPG_RFI_FRAGLEN), 1115 le64_to_cpu(rxfd->frag_info) & ~IPG_RFI_FRAGLEN,
1116 sp->rx_buf_sz, PCI_DMA_FROMDEVICE); 1116 sp->rx_buf_sz, PCI_DMA_FROMDEVICE);
1117 dev_kfree_skb_irq(sp->rx_buff[entry]); 1117 dev_kfree_skb_irq(sp->rx_buff[entry]);
1118 sp->rx_buff[entry] = NULL; 1118 sp->rx_buff[entry] = NULL;
@@ -1179,7 +1179,7 @@ static int ipg_nic_rx_check_error(struct net_device *dev)
1179 */ 1179 */
1180 if (sp->rx_buff[entry]) { 1180 if (sp->rx_buff[entry]) {
1181 pci_unmap_single(sp->pdev, 1181 pci_unmap_single(sp->pdev,
1182 le64_to_cpu(rxfd->frag_info & ~IPG_RFI_FRAGLEN), 1182 le64_to_cpu(rxfd->frag_info) & ~IPG_RFI_FRAGLEN,
1183 sp->rx_buf_sz, PCI_DMA_FROMDEVICE); 1183 sp->rx_buf_sz, PCI_DMA_FROMDEVICE);
1184 1184
1185 dev_kfree_skb_irq(sp->rx_buff[entry]); 1185 dev_kfree_skb_irq(sp->rx_buff[entry]);
@@ -1246,7 +1246,7 @@ static void ipg_nic_rx_with_start(struct net_device *dev,
1246 if (jumbo->found_start) 1246 if (jumbo->found_start)
1247 dev_kfree_skb_irq(jumbo->skb); 1247 dev_kfree_skb_irq(jumbo->skb);
1248 1248
1249 pci_unmap_single(pdev, le64_to_cpu(rxfd->frag_info & ~IPG_RFI_FRAGLEN), 1249 pci_unmap_single(pdev, le64_to_cpu(rxfd->frag_info) & ~IPG_RFI_FRAGLEN,
1250 sp->rx_buf_sz, PCI_DMA_FROMDEVICE); 1250 sp->rx_buf_sz, PCI_DMA_FROMDEVICE);
1251 1251
1252 skb_put(skb, sp->rxfrag_size); 1252 skb_put(skb, sp->rxfrag_size);
@@ -1349,7 +1349,7 @@ static int ipg_nic_rx_jumbo(struct net_device *dev)
1349 unsigned int entry = curr % IPG_RFDLIST_LENGTH; 1349 unsigned int entry = curr % IPG_RFDLIST_LENGTH;
1350 struct ipg_rx *rxfd = sp->rxd + entry; 1350 struct ipg_rx *rxfd = sp->rxd + entry;
1351 1351
1352 if (!(rxfd->rfs & le64_to_cpu(IPG_RFS_RFDDONE))) 1352 if (!(rxfd->rfs & cpu_to_le64(IPG_RFS_RFDDONE)))
1353 break; 1353 break;
1354 1354
1355 switch (ipg_nic_rx_check_frame_type(dev)) { 1355 switch (ipg_nic_rx_check_frame_type(dev)) {
diff --git a/drivers/net/ixgbe/ixgbe_main.c b/drivers/net/ixgbe/ixgbe_main.c
index 7548fb7360d9..36f2bb666bf7 100644
--- a/drivers/net/ixgbe/ixgbe_main.c
+++ b/drivers/net/ixgbe/ixgbe_main.c
@@ -1287,7 +1287,34 @@ static void ixgbe_set_itr(struct ixgbe_adapter *adapter)
1287 return; 1287 return;
1288} 1288}
1289 1289
1290static inline void ixgbe_irq_enable(struct ixgbe_adapter *adapter); 1290/**
1291 * ixgbe_irq_disable - Mask off interrupt generation on the NIC
1292 * @adapter: board private structure
1293 **/
1294static inline void ixgbe_irq_disable(struct ixgbe_adapter *adapter)
1295{
1296 IXGBE_WRITE_REG(&adapter->hw, IXGBE_EIMC, ~0);
1297 IXGBE_WRITE_FLUSH(&adapter->hw);
1298 if (adapter->flags & IXGBE_FLAG_MSIX_ENABLED) {
1299 int i;
1300 for (i = 0; i < adapter->num_msix_vectors; i++)
1301 synchronize_irq(adapter->msix_entries[i].vector);
1302 } else {
1303 synchronize_irq(adapter->pdev->irq);
1304 }
1305}
1306
1307/**
1308 * ixgbe_irq_enable - Enable default interrupt generation settings
1309 * @adapter: board private structure
1310 **/
1311static inline void ixgbe_irq_enable(struct ixgbe_adapter *adapter)
1312{
1313 u32 mask;
1314 mask = IXGBE_EIMS_ENABLE_MASK;
1315 IXGBE_WRITE_REG(&adapter->hw, IXGBE_EIMS, mask);
1316 IXGBE_WRITE_FLUSH(&adapter->hw);
1317}
1291 1318
1292/** 1319/**
1293 * ixgbe_intr - legacy mode Interrupt Handler 1320 * ixgbe_intr - legacy mode Interrupt Handler
@@ -1394,35 +1421,6 @@ static void ixgbe_free_irq(struct ixgbe_adapter *adapter)
1394} 1421}
1395 1422
1396/** 1423/**
1397 * ixgbe_irq_disable - Mask off interrupt generation on the NIC
1398 * @adapter: board private structure
1399 **/
1400static inline void ixgbe_irq_disable(struct ixgbe_adapter *adapter)
1401{
1402 IXGBE_WRITE_REG(&adapter->hw, IXGBE_EIMC, ~0);
1403 IXGBE_WRITE_FLUSH(&adapter->hw);
1404 if (adapter->flags & IXGBE_FLAG_MSIX_ENABLED) {
1405 int i;
1406 for (i = 0; i < adapter->num_msix_vectors; i++)
1407 synchronize_irq(adapter->msix_entries[i].vector);
1408 } else {
1409 synchronize_irq(adapter->pdev->irq);
1410 }
1411}
1412
1413/**
1414 * ixgbe_irq_enable - Enable default interrupt generation settings
1415 * @adapter: board private structure
1416 **/
1417static inline void ixgbe_irq_enable(struct ixgbe_adapter *adapter)
1418{
1419 u32 mask;
1420 mask = IXGBE_EIMS_ENABLE_MASK;
1421 IXGBE_WRITE_REG(&adapter->hw, IXGBE_EIMS, mask);
1422 IXGBE_WRITE_FLUSH(&adapter->hw);
1423}
1424
1425/**
1426 * ixgbe_configure_msi_and_legacy - Initialize PIN (INTA...) and MSI interrupts 1424 * ixgbe_configure_msi_and_legacy - Initialize PIN (INTA...) and MSI interrupts
1427 * 1425 *
1428 **/ 1426 **/
diff --git a/drivers/net/jme.c b/drivers/net/jme.c
index 81c6cdc3851f..665e70d620fc 100644
--- a/drivers/net/jme.c
+++ b/drivers/net/jme.c
@@ -912,23 +912,23 @@ jme_alloc_and_feed_skb(struct jme_adapter *jme, int idx)
912 skb_put(skb, framesize); 912 skb_put(skb, framesize);
913 skb->protocol = eth_type_trans(skb, jme->dev); 913 skb->protocol = eth_type_trans(skb, jme->dev);
914 914
915 if (jme_rxsum_ok(jme, rxdesc->descwb.flags)) 915 if (jme_rxsum_ok(jme, le16_to_cpu(rxdesc->descwb.flags)))
916 skb->ip_summed = CHECKSUM_UNNECESSARY; 916 skb->ip_summed = CHECKSUM_UNNECESSARY;
917 else 917 else
918 skb->ip_summed = CHECKSUM_NONE; 918 skb->ip_summed = CHECKSUM_NONE;
919 919
920 if (rxdesc->descwb.flags & RXWBFLAG_TAGON) { 920 if (rxdesc->descwb.flags & cpu_to_le16(RXWBFLAG_TAGON)) {
921 if (jme->vlgrp) { 921 if (jme->vlgrp) {
922 jme->jme_vlan_rx(skb, jme->vlgrp, 922 jme->jme_vlan_rx(skb, jme->vlgrp,
923 le32_to_cpu(rxdesc->descwb.vlan)); 923 le16_to_cpu(rxdesc->descwb.vlan));
924 NET_STAT(jme).rx_bytes += 4; 924 NET_STAT(jme).rx_bytes += 4;
925 } 925 }
926 } else { 926 } else {
927 jme->jme_rx(skb); 927 jme->jme_rx(skb);
928 } 928 }
929 929
930 if ((le16_to_cpu(rxdesc->descwb.flags) & RXWBFLAG_DEST) == 930 if ((rxdesc->descwb.flags & cpu_to_le16(RXWBFLAG_DEST)) ==
931 RXWBFLAG_DEST_MUL) 931 cpu_to_le16(RXWBFLAG_DEST_MUL))
932 ++(NET_STAT(jme).multicast); 932 ++(NET_STAT(jme).multicast);
933 933
934 jme->dev->last_rx = jiffies; 934 jme->dev->last_rx = jiffies;
@@ -961,7 +961,7 @@ jme_process_receive(struct jme_adapter *jme, int limit)
961 rxdesc = rxring->desc; 961 rxdesc = rxring->desc;
962 rxdesc += i; 962 rxdesc += i;
963 963
964 if ((rxdesc->descwb.flags & RXWBFLAG_OWN) || 964 if ((rxdesc->descwb.flags & cpu_to_le16(RXWBFLAG_OWN)) ||
965 !(rxdesc->descwb.desccnt & RXWBDCNT_WBCPL)) 965 !(rxdesc->descwb.desccnt & RXWBDCNT_WBCPL))
966 goto out; 966 goto out;
967 967
@@ -1763,10 +1763,9 @@ jme_expand_header(struct jme_adapter *jme, struct sk_buff *skb)
1763} 1763}
1764 1764
1765static int 1765static int
1766jme_tx_tso(struct sk_buff *skb, 1766jme_tx_tso(struct sk_buff *skb, __le16 *mss, u8 *flags)
1767 u16 *mss, u8 *flags)
1768{ 1767{
1769 *mss = skb_shinfo(skb)->gso_size << TXDESC_MSS_SHIFT; 1768 *mss = cpu_to_le16(skb_shinfo(skb)->gso_size << TXDESC_MSS_SHIFT);
1770 if (*mss) { 1769 if (*mss) {
1771 *flags |= TXFLAG_LSEN; 1770 *flags |= TXFLAG_LSEN;
1772 1771
@@ -1826,11 +1825,11 @@ jme_tx_csum(struct jme_adapter *jme, struct sk_buff *skb, u8 *flags)
1826} 1825}
1827 1826
1828static inline void 1827static inline void
1829jme_tx_vlan(struct sk_buff *skb, u16 *vlan, u8 *flags) 1828jme_tx_vlan(struct sk_buff *skb, __le16 *vlan, u8 *flags)
1830{ 1829{
1831 if (vlan_tx_tag_present(skb)) { 1830 if (vlan_tx_tag_present(skb)) {
1832 *flags |= TXFLAG_TAGON; 1831 *flags |= TXFLAG_TAGON;
1833 *vlan = vlan_tx_tag_get(skb); 1832 *vlan = cpu_to_le16(vlan_tx_tag_get(skb));
1834 } 1833 }
1835} 1834}
1836 1835
diff --git a/drivers/net/mv643xx_eth.c b/drivers/net/mv643xx_eth.c
index b9dcdbd369f8..e513f76f2a9f 100644
--- a/drivers/net/mv643xx_eth.c
+++ b/drivers/net/mv643xx_eth.c
@@ -899,7 +899,8 @@ static int txq_reclaim(struct tx_queue *txq, int budget, int force)
899 if (skb != NULL) { 899 if (skb != NULL) {
900 if (skb_queue_len(&mp->rx_recycle) < 900 if (skb_queue_len(&mp->rx_recycle) <
901 mp->default_rx_ring_size && 901 mp->default_rx_ring_size &&
902 skb_recycle_check(skb, mp->skb_size)) 902 skb_recycle_check(skb, mp->skb_size +
903 dma_get_cache_alignment() - 1))
903 __skb_queue_head(&mp->rx_recycle, skb); 904 __skb_queue_head(&mp->rx_recycle, skb);
904 else 905 else
905 dev_kfree_skb(skb); 906 dev_kfree_skb(skb);
@@ -2435,8 +2436,8 @@ static int mv643xx_eth_shared_remove(struct platform_device *pdev)
2435 struct mv643xx_eth_shared_platform_data *pd = pdev->dev.platform_data; 2436 struct mv643xx_eth_shared_platform_data *pd = pdev->dev.platform_data;
2436 2437
2437 if (pd == NULL || pd->shared_smi == NULL) { 2438 if (pd == NULL || pd->shared_smi == NULL) {
2438 mdiobus_free(msp->smi_bus);
2439 mdiobus_unregister(msp->smi_bus); 2439 mdiobus_unregister(msp->smi_bus);
2440 mdiobus_free(msp->smi_bus);
2440 } 2441 }
2441 if (msp->err_interrupt != NO_IRQ) 2442 if (msp->err_interrupt != NO_IRQ)
2442 free_irq(msp->err_interrupt, msp); 2443 free_irq(msp->err_interrupt, msp);
diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c
index 8fb1faca883a..55bc24b234e3 100644
--- a/drivers/net/phy/phy_device.c
+++ b/drivers/net/phy/phy_device.c
@@ -564,20 +564,32 @@ EXPORT_SYMBOL(genphy_restart_aneg);
564 */ 564 */
565int genphy_config_aneg(struct phy_device *phydev) 565int genphy_config_aneg(struct phy_device *phydev)
566{ 566{
567 int result = 0; 567 int result;
568 568
569 if (AUTONEG_ENABLE == phydev->autoneg) { 569 if (AUTONEG_ENABLE != phydev->autoneg)
570 int result = genphy_config_advert(phydev); 570 return genphy_setup_forced(phydev);
571
572 result = genphy_config_advert(phydev);
573
574 if (result < 0) /* error */
575 return result;
571 576
572 if (result < 0) /* error */ 577 if (result == 0) {
573 return result; 578 /* Advertisment hasn't changed, but maybe aneg was never on to
579 * begin with? Or maybe phy was isolated? */
580 int ctl = phy_read(phydev, MII_BMCR);
581
582 if (ctl < 0)
583 return ctl;
584
585 if (!(ctl & BMCR_ANENABLE) || (ctl & BMCR_ISOLATE))
586 result = 1; /* do restart aneg */
587 }
574 588
575 /* Only restart aneg if we are advertising something different 589 /* Only restart aneg if we are advertising something different
576 * than we were before. */ 590 * than we were before. */
577 if (result > 0) 591 if (result > 0)
578 result = genphy_restart_aneg(phydev); 592 result = genphy_restart_aneg(phydev);
579 } else
580 result = genphy_setup_forced(phydev);
581 593
582 return result; 594 return result;
583} 595}
diff --git a/drivers/net/sh_eth.c b/drivers/net/sh_eth.c
index a24bb68887ab..59f242a67714 100644
--- a/drivers/net/sh_eth.c
+++ b/drivers/net/sh_eth.c
@@ -927,7 +927,7 @@ static int sh_eth_start_xmit(struct sk_buff *skb, struct net_device *ndev)
927 struct sh_eth_private *mdp = netdev_priv(ndev); 927 struct sh_eth_private *mdp = netdev_priv(ndev);
928 struct sh_eth_txdesc *txdesc; 928 struct sh_eth_txdesc *txdesc;
929 u32 entry; 929 u32 entry;
930 int flags; 930 unsigned long flags;
931 931
932 spin_lock_irqsave(&mdp->lock, flags); 932 spin_lock_irqsave(&mdp->lock, flags);
933 if ((mdp->cur_tx - mdp->dirty_tx) >= (TX_RING_SIZE - 4)) { 933 if ((mdp->cur_tx - mdp->dirty_tx) >= (TX_RING_SIZE - 4)) {
@@ -1141,7 +1141,7 @@ static int sh_mdio_init(struct net_device *ndev, int id)
1141 /* Hook up MII support for ethtool */ 1141 /* Hook up MII support for ethtool */
1142 mdp->mii_bus->name = "sh_mii"; 1142 mdp->mii_bus->name = "sh_mii";
1143 mdp->mii_bus->parent = &ndev->dev; 1143 mdp->mii_bus->parent = &ndev->dev;
1144 mdp->mii_bus->id[0] = id; 1144 snprintf(mdp->mii_bus->id, MII_BUS_ID_SIZE, "%x", id);
1145 1145
1146 /* PHY IRQ */ 1146 /* PHY IRQ */
1147 mdp->mii_bus->irq = kmalloc(sizeof(int)*PHY_MAX_ADDR, GFP_KERNEL); 1147 mdp->mii_bus->irq = kmalloc(sizeof(int)*PHY_MAX_ADDR, GFP_KERNEL);
diff --git a/drivers/net/smc911x.c b/drivers/net/smc911x.c
index 1f26ab0e7986..b185cd12269c 100644
--- a/drivers/net/smc911x.c
+++ b/drivers/net/smc911x.c
@@ -1813,7 +1813,7 @@ static int __init smc911x_probe(struct net_device *dev)
1813 val = SMC_GET_BYTE_TEST(lp); 1813 val = SMC_GET_BYTE_TEST(lp);
1814 DBG(SMC_DEBUG_MISC, "%s: endian probe returned 0x%04x\n", CARDNAME, val); 1814 DBG(SMC_DEBUG_MISC, "%s: endian probe returned 0x%04x\n", CARDNAME, val);
1815 if (val != 0x87654321) { 1815 if (val != 0x87654321) {
1816 printk(KERN_ERR "Invalid chip endian 0x08%x\n",val); 1816 printk(KERN_ERR "Invalid chip endian 0x%08x\n",val);
1817 retval = -ENODEV; 1817 retval = -ENODEV;
1818 goto err_out; 1818 goto err_out;
1819 } 1819 }
diff --git a/drivers/net/usb/asix.c b/drivers/net/usb/asix.c
index e12cdb4543b4..de57490103fc 100644
--- a/drivers/net/usb/asix.c
+++ b/drivers/net/usb/asix.c
@@ -1102,12 +1102,14 @@ static int ax88178_link_reset(struct usbnet *dev)
1102 mode = AX88178_MEDIUM_DEFAULT; 1102 mode = AX88178_MEDIUM_DEFAULT;
1103 1103
1104 if (ecmd.speed == SPEED_1000) 1104 if (ecmd.speed == SPEED_1000)
1105 mode |= AX_MEDIUM_GM | AX_MEDIUM_ENCK; 1105 mode |= AX_MEDIUM_GM;
1106 else if (ecmd.speed == SPEED_100) 1106 else if (ecmd.speed == SPEED_100)
1107 mode |= AX_MEDIUM_PS; 1107 mode |= AX_MEDIUM_PS;
1108 else 1108 else
1109 mode &= ~(AX_MEDIUM_PS | AX_MEDIUM_GM); 1109 mode &= ~(AX_MEDIUM_PS | AX_MEDIUM_GM);
1110 1110
1111 mode |= AX_MEDIUM_ENCK;
1112
1111 if (ecmd.duplex == DUPLEX_FULL) 1113 if (ecmd.duplex == DUPLEX_FULL)
1112 mode |= AX_MEDIUM_FD; 1114 mode |= AX_MEDIUM_FD;
1113 else 1115 else
diff --git a/drivers/net/wireless/iwlwifi/iwl-agn.c b/drivers/net/wireless/iwlwifi/iwl-agn.c
index 8d690a0eb1a9..444c5cc05f03 100644
--- a/drivers/net/wireless/iwlwifi/iwl-agn.c
+++ b/drivers/net/wireless/iwlwifi/iwl-agn.c
@@ -1384,7 +1384,7 @@ void iwl_rx_handle(struct iwl_priv *priv)
1384 1384
1385 rxq->queue[i] = NULL; 1385 rxq->queue[i] = NULL;
1386 1386
1387 pci_dma_sync_single_for_cpu(priv->pci_dev, rxb->dma_addr, 1387 pci_dma_sync_single_for_cpu(priv->pci_dev, rxb->aligned_dma_addr,
1388 priv->hw_params.rx_buf_size, 1388 priv->hw_params.rx_buf_size,
1389 PCI_DMA_FROMDEVICE); 1389 PCI_DMA_FROMDEVICE);
1390 pkt = (struct iwl_rx_packet *)rxb->skb->data; 1390 pkt = (struct iwl_rx_packet *)rxb->skb->data;
@@ -1436,8 +1436,8 @@ void iwl_rx_handle(struct iwl_priv *priv)
1436 rxb->skb = NULL; 1436 rxb->skb = NULL;
1437 } 1437 }
1438 1438
1439 pci_unmap_single(priv->pci_dev, rxb->dma_addr, 1439 pci_unmap_single(priv->pci_dev, rxb->real_dma_addr,
1440 priv->hw_params.rx_buf_size, 1440 priv->hw_params.rx_buf_size + 256,
1441 PCI_DMA_FROMDEVICE); 1441 PCI_DMA_FROMDEVICE);
1442 spin_lock_irqsave(&rxq->lock, flags); 1442 spin_lock_irqsave(&rxq->lock, flags);
1443 list_add_tail(&rxb->list, &priv->rxq.rx_used); 1443 list_add_tail(&rxb->list, &priv->rxq.rx_used);
@@ -2341,7 +2341,6 @@ static void iwl_bg_alive_start(struct work_struct *data)
2341 mutex_lock(&priv->mutex); 2341 mutex_lock(&priv->mutex);
2342 iwl_alive_start(priv); 2342 iwl_alive_start(priv);
2343 mutex_unlock(&priv->mutex); 2343 mutex_unlock(&priv->mutex);
2344 ieee80211_notify_mac(priv->hw, IEEE80211_NOTIFY_RE_ASSOC);
2345} 2344}
2346 2345
2347static void iwl4965_bg_rf_kill(struct work_struct *work) 2346static void iwl4965_bg_rf_kill(struct work_struct *work)
diff --git a/drivers/net/wireless/iwlwifi/iwl-dev.h b/drivers/net/wireless/iwlwifi/iwl-dev.h
index c018121085e9..9966d4e384ce 100644
--- a/drivers/net/wireless/iwlwifi/iwl-dev.h
+++ b/drivers/net/wireless/iwlwifi/iwl-dev.h
@@ -89,7 +89,8 @@ extern struct iwl_cfg iwl5100_abg_cfg;
89#define DEFAULT_LONG_RETRY_LIMIT 4U 89#define DEFAULT_LONG_RETRY_LIMIT 4U
90 90
91struct iwl_rx_mem_buffer { 91struct iwl_rx_mem_buffer {
92 dma_addr_t dma_addr; 92 dma_addr_t real_dma_addr;
93 dma_addr_t aligned_dma_addr;
93 struct sk_buff *skb; 94 struct sk_buff *skb;
94 struct list_head list; 95 struct list_head list;
95}; 96};
diff --git a/drivers/net/wireless/iwlwifi/iwl-rx.c b/drivers/net/wireless/iwlwifi/iwl-rx.c
index 7cde9d76ff5d..0509c16dbe75 100644
--- a/drivers/net/wireless/iwlwifi/iwl-rx.c
+++ b/drivers/net/wireless/iwlwifi/iwl-rx.c
@@ -204,7 +204,7 @@ int iwl_rx_queue_restock(struct iwl_priv *priv)
204 list_del(element); 204 list_del(element);
205 205
206 /* Point to Rx buffer via next RBD in circular buffer */ 206 /* Point to Rx buffer via next RBD in circular buffer */
207 rxq->bd[rxq->write] = iwl_dma_addr2rbd_ptr(priv, rxb->dma_addr); 207 rxq->bd[rxq->write] = iwl_dma_addr2rbd_ptr(priv, rxb->aligned_dma_addr);
208 rxq->queue[rxq->write] = rxb; 208 rxq->queue[rxq->write] = rxb;
209 rxq->write = (rxq->write + 1) & RX_QUEUE_MASK; 209 rxq->write = (rxq->write + 1) & RX_QUEUE_MASK;
210 rxq->free_count--; 210 rxq->free_count--;
@@ -251,7 +251,7 @@ void iwl_rx_allocate(struct iwl_priv *priv)
251 rxb = list_entry(element, struct iwl_rx_mem_buffer, list); 251 rxb = list_entry(element, struct iwl_rx_mem_buffer, list);
252 252
253 /* Alloc a new receive buffer */ 253 /* Alloc a new receive buffer */
254 rxb->skb = alloc_skb(priv->hw_params.rx_buf_size, 254 rxb->skb = alloc_skb(priv->hw_params.rx_buf_size + 256,
255 __GFP_NOWARN | GFP_ATOMIC); 255 __GFP_NOWARN | GFP_ATOMIC);
256 if (!rxb->skb) { 256 if (!rxb->skb) {
257 if (net_ratelimit()) 257 if (net_ratelimit())
@@ -266,9 +266,17 @@ void iwl_rx_allocate(struct iwl_priv *priv)
266 list_del(element); 266 list_del(element);
267 267
268 /* Get physical address of RB/SKB */ 268 /* Get physical address of RB/SKB */
269 rxb->dma_addr = 269 rxb->real_dma_addr = pci_map_single(
270 pci_map_single(priv->pci_dev, rxb->skb->data, 270 priv->pci_dev,
271 priv->hw_params.rx_buf_size, PCI_DMA_FROMDEVICE); 271 rxb->skb->data,
272 priv->hw_params.rx_buf_size + 256,
273 PCI_DMA_FROMDEVICE);
274 /* dma address must be no more than 36 bits */
275 BUG_ON(rxb->real_dma_addr & ~DMA_BIT_MASK(36));
276 /* and also 256 byte aligned! */
277 rxb->aligned_dma_addr = ALIGN(rxb->real_dma_addr, 256);
278 skb_reserve(rxb->skb, rxb->aligned_dma_addr - rxb->real_dma_addr);
279
272 list_add_tail(&rxb->list, &rxq->rx_free); 280 list_add_tail(&rxb->list, &rxq->rx_free);
273 rxq->free_count++; 281 rxq->free_count++;
274 } 282 }
@@ -300,8 +308,8 @@ void iwl_rx_queue_free(struct iwl_priv *priv, struct iwl_rx_queue *rxq)
300 for (i = 0; i < RX_QUEUE_SIZE + RX_FREE_BUFFERS; i++) { 308 for (i = 0; i < RX_QUEUE_SIZE + RX_FREE_BUFFERS; i++) {
301 if (rxq->pool[i].skb != NULL) { 309 if (rxq->pool[i].skb != NULL) {
302 pci_unmap_single(priv->pci_dev, 310 pci_unmap_single(priv->pci_dev,
303 rxq->pool[i].dma_addr, 311 rxq->pool[i].real_dma_addr,
304 priv->hw_params.rx_buf_size, 312 priv->hw_params.rx_buf_size + 256,
305 PCI_DMA_FROMDEVICE); 313 PCI_DMA_FROMDEVICE);
306 dev_kfree_skb(rxq->pool[i].skb); 314 dev_kfree_skb(rxq->pool[i].skb);
307 } 315 }
@@ -354,8 +362,8 @@ void iwl_rx_queue_reset(struct iwl_priv *priv, struct iwl_rx_queue *rxq)
354 * to an SKB, so we need to unmap and free potential storage */ 362 * to an SKB, so we need to unmap and free potential storage */
355 if (rxq->pool[i].skb != NULL) { 363 if (rxq->pool[i].skb != NULL) {
356 pci_unmap_single(priv->pci_dev, 364 pci_unmap_single(priv->pci_dev,
357 rxq->pool[i].dma_addr, 365 rxq->pool[i].real_dma_addr,
358 priv->hw_params.rx_buf_size, 366 priv->hw_params.rx_buf_size + 256,
359 PCI_DMA_FROMDEVICE); 367 PCI_DMA_FROMDEVICE);
360 priv->alloc_rxb_skb--; 368 priv->alloc_rxb_skb--;
361 dev_kfree_skb(rxq->pool[i].skb); 369 dev_kfree_skb(rxq->pool[i].skb);
diff --git a/drivers/net/wireless/iwlwifi/iwl3945-base.c b/drivers/net/wireless/iwlwifi/iwl3945-base.c
index 285b53e7e261..45a6b0c35695 100644
--- a/drivers/net/wireless/iwlwifi/iwl3945-base.c
+++ b/drivers/net/wireless/iwlwifi/iwl3945-base.c
@@ -6012,7 +6012,6 @@ static void iwl3945_bg_alive_start(struct work_struct *data)
6012 mutex_lock(&priv->mutex); 6012 mutex_lock(&priv->mutex);
6013 iwl3945_alive_start(priv); 6013 iwl3945_alive_start(priv);
6014 mutex_unlock(&priv->mutex); 6014 mutex_unlock(&priv->mutex);
6015 ieee80211_notify_mac(priv->hw, IEEE80211_NOTIFY_RE_ASSOC);
6016} 6015}
6017 6016
6018static void iwl3945_bg_rf_kill(struct work_struct *work) 6017static void iwl3945_bg_rf_kill(struct work_struct *work)
diff --git a/drivers/net/wireless/libertas_tf/if_usb.c b/drivers/net/wireless/libertas_tf/if_usb.c
index 1cc03a8dd67a..59634c33b1f9 100644
--- a/drivers/net/wireless/libertas_tf/if_usb.c
+++ b/drivers/net/wireless/libertas_tf/if_usb.c
@@ -331,7 +331,7 @@ static int __if_usb_submit_rx_urb(struct if_usb_card *cardp,
331 /* Fill the receive configuration URB and initialise the Rx call back */ 331 /* Fill the receive configuration URB and initialise the Rx call back */
332 usb_fill_bulk_urb(cardp->rx_urb, cardp->udev, 332 usb_fill_bulk_urb(cardp->rx_urb, cardp->udev,
333 usb_rcvbulkpipe(cardp->udev, cardp->ep_in), 333 usb_rcvbulkpipe(cardp->udev, cardp->ep_in),
334 (void *) (skb->tail), 334 skb_tail_pointer(skb),
335 MRVDRV_ETH_RX_PACKET_BUFFER_SIZE, callbackfn, cardp); 335 MRVDRV_ETH_RX_PACKET_BUFFER_SIZE, callbackfn, cardp);
336 336
337 cardp->rx_urb->transfer_flags |= URB_ZERO_PACKET; 337 cardp->rx_urb->transfer_flags |= URB_ZERO_PACKET;
diff --git a/drivers/parport/Kconfig b/drivers/parport/Kconfig
index 209b4a464bcf..855f389eea40 100644
--- a/drivers/parport/Kconfig
+++ b/drivers/parport/Kconfig
@@ -36,7 +36,7 @@ if PARPORT
36config PARPORT_PC 36config PARPORT_PC
37 tristate "PC-style hardware" 37 tristate "PC-style hardware"
38 depends on (!SPARC64 || PCI) && !SPARC32 && !M32R && !FRV && \ 38 depends on (!SPARC64 || PCI) && !SPARC32 && !M32R && !FRV && \
39 (!M68K || ISA) && !MN10300 && !AVR32 39 (!M68K || ISA) && !MN10300 && !AVR32 && !BLACKFIN
40 ---help--- 40 ---help---
41 You should say Y here if you have a PC-style parallel port. All 41 You should say Y here if you have a PC-style parallel port. All
42 IBM PC compatible computers and some Alphas have PC-style 42 IBM PC compatible computers and some Alphas have PC-style
diff --git a/drivers/pci/intel-iommu.c b/drivers/pci/intel-iommu.c
index a2692724b68f..5c8baa43ac9c 100644
--- a/drivers/pci/intel-iommu.c
+++ b/drivers/pci/intel-iommu.c
@@ -1655,12 +1655,14 @@ int __init init_dmars(void)
1655 iommu->flush.flush_context = __iommu_flush_context; 1655 iommu->flush.flush_context = __iommu_flush_context;
1656 iommu->flush.flush_iotlb = __iommu_flush_iotlb; 1656 iommu->flush.flush_iotlb = __iommu_flush_iotlb;
1657 printk(KERN_INFO "IOMMU 0x%Lx: using Register based " 1657 printk(KERN_INFO "IOMMU 0x%Lx: using Register based "
1658 "invalidation\n", drhd->reg_base_addr); 1658 "invalidation\n",
1659 (unsigned long long)drhd->reg_base_addr);
1659 } else { 1660 } else {
1660 iommu->flush.flush_context = qi_flush_context; 1661 iommu->flush.flush_context = qi_flush_context;
1661 iommu->flush.flush_iotlb = qi_flush_iotlb; 1662 iommu->flush.flush_iotlb = qi_flush_iotlb;
1662 printk(KERN_INFO "IOMMU 0x%Lx: using Queued " 1663 printk(KERN_INFO "IOMMU 0x%Lx: using Queued "
1663 "invalidation\n", drhd->reg_base_addr); 1664 "invalidation\n",
1665 (unsigned long long)drhd->reg_base_addr);
1664 } 1666 }
1665 } 1667 }
1666 1668
diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
index 21f2ac639cab..28af496b441e 100644
--- a/drivers/pci/pci.c
+++ b/drivers/pci/pci.c
@@ -1832,7 +1832,7 @@ int pci_reset_function(struct pci_dev *dev)
1832 if (!(cap & PCI_EXP_DEVCAP_FLR)) 1832 if (!(cap & PCI_EXP_DEVCAP_FLR))
1833 return -ENOTTY; 1833 return -ENOTTY;
1834 1834
1835 if (!dev->msi_enabled && !dev->msix_enabled) 1835 if (!dev->msi_enabled && !dev->msix_enabled && dev->irq != 0)
1836 disable_irq(dev->irq); 1836 disable_irq(dev->irq);
1837 pci_save_state(dev); 1837 pci_save_state(dev);
1838 1838
@@ -1841,7 +1841,7 @@ int pci_reset_function(struct pci_dev *dev)
1841 r = pci_execute_reset_function(dev); 1841 r = pci_execute_reset_function(dev);
1842 1842
1843 pci_restore_state(dev); 1843 pci_restore_state(dev);
1844 if (!dev->msi_enabled && !dev->msix_enabled) 1844 if (!dev->msi_enabled && !dev->msix_enabled && dev->irq != 0)
1845 enable_irq(dev->irq); 1845 enable_irq(dev->irq);
1846 1846
1847 return r; 1847 return r;
diff --git a/drivers/spi/pxa2xx_spi.c b/drivers/spi/pxa2xx_spi.c
index dae87b1a4c6e..cf12f2d84be2 100644
--- a/drivers/spi/pxa2xx_spi.c
+++ b/drivers/spi/pxa2xx_spi.c
@@ -352,21 +352,21 @@ static int map_dma_buffers(struct driver_data *drv_data)
352 } else 352 } else
353 drv_data->tx_map_len = drv_data->len; 353 drv_data->tx_map_len = drv_data->len;
354 354
355 /* Stream map the rx buffer */ 355 /* Stream map the tx buffer. Always do DMA_TO_DEVICE first
356 drv_data->rx_dma = dma_map_single(dev, drv_data->rx, 356 * so we flush the cache *before* invalidating it, in case
357 drv_data->rx_map_len, 357 * the tx and rx buffers overlap.
358 DMA_FROM_DEVICE); 358 */
359 if (dma_mapping_error(dev, drv_data->rx_dma))
360 return 0;
361
362 /* Stream map the tx buffer */
363 drv_data->tx_dma = dma_map_single(dev, drv_data->tx, 359 drv_data->tx_dma = dma_map_single(dev, drv_data->tx,
364 drv_data->tx_map_len, 360 drv_data->tx_map_len, DMA_TO_DEVICE);
365 DMA_TO_DEVICE); 361 if (dma_mapping_error(dev, drv_data->tx_dma))
362 return 0;
366 363
367 if (dma_mapping_error(dev, drv_data->tx_dma)) { 364 /* Stream map the rx buffer */
368 dma_unmap_single(dev, drv_data->rx_dma, 365 drv_data->rx_dma = dma_map_single(dev, drv_data->rx,
369 drv_data->rx_map_len, DMA_FROM_DEVICE); 366 drv_data->rx_map_len, DMA_FROM_DEVICE);
367 if (dma_mapping_error(dev, drv_data->rx_dma)) {
368 dma_unmap_single(dev, drv_data->tx_dma,
369 drv_data->tx_map_len, DMA_TO_DEVICE);
370 return 0; 370 return 0;
371 } 371 }
372 372
diff --git a/drivers/spi/spi_imx.c b/drivers/spi/spi_imx.c
index 61ba147e384d..0b4db0ce78d6 100644
--- a/drivers/spi/spi_imx.c
+++ b/drivers/spi/spi_imx.c
@@ -506,20 +506,6 @@ static int map_dma_buffers(struct driver_data *drv_data)
506 if (!IS_DMA_ALIGNED(drv_data->rx) || !IS_DMA_ALIGNED(drv_data->tx)) 506 if (!IS_DMA_ALIGNED(drv_data->rx) || !IS_DMA_ALIGNED(drv_data->tx))
507 return -1; 507 return -1;
508 508
509 /* NULL rx means write-only transfer and no map needed
510 since rx DMA will not be used */
511 if (drv_data->rx) {
512 buf = drv_data->rx;
513 drv_data->rx_dma = dma_map_single(
514 dev,
515 buf,
516 drv_data->len,
517 DMA_FROM_DEVICE);
518 if (dma_mapping_error(dev, drv_data->rx_dma))
519 return -1;
520 drv_data->rx_dma_needs_unmap = 1;
521 }
522
523 if (drv_data->tx == NULL) { 509 if (drv_data->tx == NULL) {
524 /* Read only message --> use drv_data->dummy_dma_buf for dummy 510 /* Read only message --> use drv_data->dummy_dma_buf for dummy
525 writes to achive reads */ 511 writes to achive reads */
@@ -533,18 +519,31 @@ static int map_dma_buffers(struct driver_data *drv_data)
533 buf, 519 buf,
534 drv_data->tx_map_len, 520 drv_data->tx_map_len,
535 DMA_TO_DEVICE); 521 DMA_TO_DEVICE);
536 if (dma_mapping_error(dev, drv_data->tx_dma)) { 522 if (dma_mapping_error(dev, drv_data->tx_dma))
537 if (drv_data->rx_dma) {
538 dma_unmap_single(dev,
539 drv_data->rx_dma,
540 drv_data->len,
541 DMA_FROM_DEVICE);
542 drv_data->rx_dma_needs_unmap = 0;
543 }
544 return -1; 523 return -1;
545 }
546 drv_data->tx_dma_needs_unmap = 1; 524 drv_data->tx_dma_needs_unmap = 1;
547 525
526 /* NULL rx means write-only transfer and no map needed
527 * since rx DMA will not be used */
528 if (drv_data->rx) {
529 buf = drv_data->rx;
530 drv_data->rx_dma = dma_map_single(dev,
531 buf,
532 drv_data->len,
533 DMA_FROM_DEVICE);
534 if (dma_mapping_error(dev, drv_data->rx_dma)) {
535 if (drv_data->tx_dma) {
536 dma_unmap_single(dev,
537 drv_data->tx_dma,
538 drv_data->tx_map_len,
539 DMA_TO_DEVICE);
540 drv_data->tx_dma_needs_unmap = 0;
541 }
542 return -1;
543 }
544 drv_data->rx_dma_needs_unmap = 1;
545 }
546
548 return 0; 547 return 0;
549} 548}
550 549
diff --git a/drivers/usb/gadget/f_rndis.c b/drivers/usb/gadget/f_rndis.c
index 659b3d9671c4..428b5993575a 100644
--- a/drivers/usb/gadget/f_rndis.c
+++ b/drivers/usb/gadget/f_rndis.c
@@ -172,7 +172,6 @@ static struct usb_interface_descriptor rndis_data_intf __initdata = {
172 .bDescriptorType = USB_DT_INTERFACE, 172 .bDescriptorType = USB_DT_INTERFACE,
173 173
174 /* .bInterfaceNumber = DYNAMIC */ 174 /* .bInterfaceNumber = DYNAMIC */
175 .bAlternateSetting = 1,
176 .bNumEndpoints = 2, 175 .bNumEndpoints = 2,
177 .bInterfaceClass = USB_CLASS_CDC_DATA, 176 .bInterfaceClass = USB_CLASS_CDC_DATA,
178 .bInterfaceSubClass = 0, 177 .bInterfaceSubClass = 0,
@@ -303,7 +302,7 @@ static void rndis_response_available(void *_rndis)
303 __le32 *data = req->buf; 302 __le32 *data = req->buf;
304 int status; 303 int status;
305 304
306 if (atomic_inc_return(&rndis->notify_count)) 305 if (atomic_inc_return(&rndis->notify_count) != 1)
307 return; 306 return;
308 307
309 /* Send RNDIS RESPONSE_AVAILABLE notification; a 308 /* Send RNDIS RESPONSE_AVAILABLE notification; a
diff --git a/drivers/usb/host/ehci-pci.c b/drivers/usb/host/ehci-pci.c
index c46a58f9181d..9d0ea573aef6 100644
--- a/drivers/usb/host/ehci-pci.c
+++ b/drivers/usb/host/ehci-pci.c
@@ -66,6 +66,8 @@ static int ehci_pci_setup(struct usb_hcd *hcd)
66{ 66{
67 struct ehci_hcd *ehci = hcd_to_ehci(hcd); 67 struct ehci_hcd *ehci = hcd_to_ehci(hcd);
68 struct pci_dev *pdev = to_pci_dev(hcd->self.controller); 68 struct pci_dev *pdev = to_pci_dev(hcd->self.controller);
69 struct pci_dev *p_smbus;
70 u8 rev;
69 u32 temp; 71 u32 temp;
70 int retval; 72 int retval;
71 73
@@ -166,6 +168,25 @@ static int ehci_pci_setup(struct usb_hcd *hcd)
166 pci_write_config_byte(pdev, 0x4b, tmp | 0x20); 168 pci_write_config_byte(pdev, 0x4b, tmp | 0x20);
167 } 169 }
168 break; 170 break;
171 case PCI_VENDOR_ID_ATI:
172 /* SB700 old version has a bug in EHCI controller,
173 * which causes usb devices lose response in some cases.
174 */
175 if (pdev->device == 0x4396) {
176 p_smbus = pci_get_device(PCI_VENDOR_ID_ATI,
177 PCI_DEVICE_ID_ATI_SBX00_SMBUS,
178 NULL);
179 if (!p_smbus)
180 break;
181 rev = p_smbus->revision;
182 if ((rev == 0x3a) || (rev == 0x3b)) {
183 u8 tmp;
184 pci_read_config_byte(pdev, 0x53, &tmp);
185 pci_write_config_byte(pdev, 0x53, tmp | (1<<3));
186 }
187 pci_dev_put(p_smbus);
188 }
189 break;
169 } 190 }
170 191
171 ehci_reset(ehci); 192 ehci_reset(ehci);
diff --git a/drivers/usb/mon/mon_bin.c b/drivers/usb/mon/mon_bin.c
index c9de3f027aab..e06810aef2df 100644
--- a/drivers/usb/mon/mon_bin.c
+++ b/drivers/usb/mon/mon_bin.c
@@ -687,7 +687,10 @@ static ssize_t mon_bin_read(struct file *file, char __user *buf,
687 } 687 }
688 688
689 if (rp->b_read >= sizeof(struct mon_bin_hdr)) { 689 if (rp->b_read >= sizeof(struct mon_bin_hdr)) {
690 step_len = min(nbytes, (size_t)ep->len_cap); 690 step_len = ep->len_cap;
691 step_len -= rp->b_read - sizeof(struct mon_bin_hdr);
692 if (step_len > nbytes)
693 step_len = nbytes;
691 offset = rp->b_out + PKT_SIZE; 694 offset = rp->b_out + PKT_SIZE;
692 offset += rp->b_read - sizeof(struct mon_bin_hdr); 695 offset += rp->b_read - sizeof(struct mon_bin_hdr);
693 if (offset >= rp->b_size) 696 if (offset >= rp->b_size)
diff --git a/drivers/usb/musb/musb_host.c b/drivers/usb/musb/musb_host.c
index e45e70bcc5e2..cc64462d4c4e 100644
--- a/drivers/usb/musb/musb_host.c
+++ b/drivers/usb/musb/musb_host.c
@@ -1757,7 +1757,7 @@ static int musb_schedule(
1757 } 1757 }
1758 } 1758 }
1759 /* use bulk reserved ep1 if no other ep is free */ 1759 /* use bulk reserved ep1 if no other ep is free */
1760 if (best_end > 0 && qh->type == USB_ENDPOINT_XFER_BULK) { 1760 if (best_end < 0 && qh->type == USB_ENDPOINT_XFER_BULK) {
1761 hw_ep = musb->bulk_ep; 1761 hw_ep = musb->bulk_ep;
1762 if (is_in) 1762 if (is_in)
1763 head = &musb->in_bulk; 1763 head = &musb->in_bulk;
diff --git a/drivers/usb/serial/cp2101.c b/drivers/usb/serial/cp2101.c
index 9035d7256b03..cfaf1f085535 100644
--- a/drivers/usb/serial/cp2101.c
+++ b/drivers/usb/serial/cp2101.c
@@ -56,6 +56,7 @@ static void cp2101_shutdown(struct usb_serial *);
56static int debug; 56static int debug;
57 57
58static struct usb_device_id id_table [] = { 58static struct usb_device_id id_table [] = {
59 { USB_DEVICE(0x0471, 0x066A) }, /* AKTAKOM ACE-1001 cable */
59 { USB_DEVICE(0x0489, 0xE000) }, /* Pirelli Broadband S.p.A, DP-L10 SIP/GSM Mobile */ 60 { USB_DEVICE(0x0489, 0xE000) }, /* Pirelli Broadband S.p.A, DP-L10 SIP/GSM Mobile */
60 { USB_DEVICE(0x08e6, 0x5501) }, /* Gemalto Prox-PU/CU contactless smartcard reader */ 61 { USB_DEVICE(0x08e6, 0x5501) }, /* Gemalto Prox-PU/CU contactless smartcard reader */
61 { USB_DEVICE(0x0FCF, 0x1003) }, /* Dynastream ANT development board */ 62 { USB_DEVICE(0x0FCF, 0x1003) }, /* Dynastream ANT development board */
diff --git a/drivers/usb/storage/unusual_devs.h b/drivers/usb/storage/unusual_devs.h
index d4e5fc86e43c..6da9a7a962a8 100644
--- a/drivers/usb/storage/unusual_devs.h
+++ b/drivers/usb/storage/unusual_devs.h
@@ -167,6 +167,13 @@ UNUSUAL_DEV( 0x0421, 0x005d, 0x0001, 0x0600,
167 US_SC_DEVICE, US_PR_DEVICE, NULL, 167 US_SC_DEVICE, US_PR_DEVICE, NULL,
168 US_FL_FIX_CAPACITY ), 168 US_FL_FIX_CAPACITY ),
169 169
170/* Patch for Nokia 5310 capacity */
171UNUSUAL_DEV( 0x0421, 0x006a, 0x0000, 0x0591,
172 "Nokia",
173 "5310",
174 US_SC_DEVICE, US_PR_DEVICE, NULL,
175 US_FL_FIX_CAPACITY ),
176
170/* Reported by Mario Rettig <mariorettig@web.de> */ 177/* Reported by Mario Rettig <mariorettig@web.de> */
171UNUSUAL_DEV( 0x0421, 0x042e, 0x0100, 0x0100, 178UNUSUAL_DEV( 0x0421, 0x042e, 0x0100, 0x0100,
172 "Nokia", 179 "Nokia",
@@ -233,14 +240,14 @@ UNUSUAL_DEV( 0x0421, 0x0495, 0x0370, 0x0370,
233 US_FL_MAX_SECTORS_64 ), 240 US_FL_MAX_SECTORS_64 ),
234 241
235/* Reported by Cedric Godin <cedric@belbone.be> */ 242/* Reported by Cedric Godin <cedric@belbone.be> */
236UNUSUAL_DEV( 0x0421, 0x04b9, 0x0551, 0x0551, 243UNUSUAL_DEV( 0x0421, 0x04b9, 0x0500, 0x0551,
237 "Nokia", 244 "Nokia",
238 "5300", 245 "5300",
239 US_SC_DEVICE, US_PR_DEVICE, NULL, 246 US_SC_DEVICE, US_PR_DEVICE, NULL,
240 US_FL_FIX_CAPACITY ), 247 US_FL_FIX_CAPACITY ),
241 248
242/* Reported by Richard Nauber <RichardNauber@web.de> */ 249/* Reported by Richard Nauber <RichardNauber@web.de> */
243UNUSUAL_DEV( 0x0421, 0x04fa, 0x0601, 0x0601, 250UNUSUAL_DEV( 0x0421, 0x04fa, 0x0550, 0x0660,
244 "Nokia", 251 "Nokia",
245 "6300", 252 "6300",
246 US_SC_DEVICE, US_PR_DEVICE, NULL, 253 US_SC_DEVICE, US_PR_DEVICE, NULL,
diff --git a/drivers/video/atmel_lcdfb.c b/drivers/video/atmel_lcdfb.c
index f8d0a57a07cb..9a577a800db5 100644
--- a/drivers/video/atmel_lcdfb.c
+++ b/drivers/video/atmel_lcdfb.c
@@ -132,7 +132,7 @@ static void init_backlight(struct atmel_lcdfb_info *sinfo)
132 132
133 bl = backlight_device_register("backlight", &sinfo->pdev->dev, 133 bl = backlight_device_register("backlight", &sinfo->pdev->dev,
134 sinfo, &atmel_lcdc_bl_ops); 134 sinfo, &atmel_lcdc_bl_ops);
135 if (IS_ERR(sinfo->backlight)) { 135 if (IS_ERR(bl)) {
136 dev_err(&sinfo->pdev->dev, "error %ld on backlight register\n", 136 dev_err(&sinfo->pdev->dev, "error %ld on backlight register\n",
137 PTR_ERR(bl)); 137 PTR_ERR(bl));
138 return; 138 return;
diff --git a/drivers/video/backlight/da903x.c b/drivers/video/backlight/da903x.c
index 242c38250166..93bb4340cc64 100644
--- a/drivers/video/backlight/da903x.c
+++ b/drivers/video/backlight/da903x.c
@@ -119,6 +119,7 @@ static int da903x_backlight_probe(struct platform_device *pdev)
119 default: 119 default:
120 dev_err(&pdev->dev, "invalid backlight device ID(%d)\n", 120 dev_err(&pdev->dev, "invalid backlight device ID(%d)\n",
121 pdev->id); 121 pdev->id);
122 kfree(data);
122 return -EINVAL; 123 return -EINVAL;
123 } 124 }
124 125
@@ -130,6 +131,7 @@ static int da903x_backlight_probe(struct platform_device *pdev)
130 data, &da903x_backlight_ops); 131 data, &da903x_backlight_ops);
131 if (IS_ERR(bl)) { 132 if (IS_ERR(bl)) {
132 dev_err(&pdev->dev, "failed to register backlight\n"); 133 dev_err(&pdev->dev, "failed to register backlight\n");
134 kfree(data);
133 return PTR_ERR(bl); 135 return PTR_ERR(bl);
134 } 136 }
135 137
diff --git a/drivers/video/backlight/lcd.c b/drivers/video/backlight/lcd.c
index 8e1731d3b228..680e57b616cd 100644
--- a/drivers/video/backlight/lcd.c
+++ b/drivers/video/backlight/lcd.c
@@ -42,10 +42,13 @@ static int fb_notifier_callback(struct notifier_block *self,
42 42
43 mutex_lock(&ld->ops_lock); 43 mutex_lock(&ld->ops_lock);
44 if (!ld->ops->check_fb || ld->ops->check_fb(ld, evdata->info)) { 44 if (!ld->ops->check_fb || ld->ops->check_fb(ld, evdata->info)) {
45 if (event == FB_EVENT_BLANK) 45 if (event == FB_EVENT_BLANK) {
46 ld->ops->set_power(ld, *(int *)evdata->data); 46 if (ld->ops->set_power)
47 else 47 ld->ops->set_power(ld, *(int *)evdata->data);
48 ld->ops->set_mode(ld, evdata->data); 48 } else {
49 if (ld->ops->set_mode)
50 ld->ops->set_mode(ld, evdata->data);
51 }
49 } 52 }
50 mutex_unlock(&ld->ops_lock); 53 mutex_unlock(&ld->ops_lock);
51 return 0; 54 return 0;
diff --git a/drivers/video/cirrusfb.c b/drivers/video/cirrusfb.c
index 8a8760230bc7..a2aa6ddffbe2 100644
--- a/drivers/video/cirrusfb.c
+++ b/drivers/video/cirrusfb.c
@@ -2462,8 +2462,7 @@ static int __init cirrusfb_init(void)
2462 2462
2463#ifndef MODULE 2463#ifndef MODULE
2464static int __init cirrusfb_setup(char *options) { 2464static int __init cirrusfb_setup(char *options) {
2465 char *this_opt, s[32]; 2465 char *this_opt;
2466 int i;
2467 2466
2468 DPRINTK("ENTER\n"); 2467 DPRINTK("ENTER\n");
2469 2468
diff --git a/drivers/video/fbmem.c b/drivers/video/fbmem.c
index 1d5ae39cb271..3c65b0d67617 100644
--- a/drivers/video/fbmem.c
+++ b/drivers/video/fbmem.c
@@ -230,7 +230,7 @@ static void fb_set_logo_directpalette(struct fb_info *info,
230 greenshift = info->var.green.offset; 230 greenshift = info->var.green.offset;
231 blueshift = info->var.blue.offset; 231 blueshift = info->var.blue.offset;
232 232
233 for (i = 32; i < logo->clutsize; i++) 233 for (i = 32; i < 32 + logo->clutsize; i++)
234 palette[i] = i << redshift | i << greenshift | i << blueshift; 234 palette[i] = i << redshift | i << greenshift | i << blueshift;
235} 235}
236 236
diff --git a/drivers/video/pxafb.c b/drivers/video/pxafb.c
index 97204497d9f7..cc59c52e1103 100644
--- a/drivers/video/pxafb.c
+++ b/drivers/video/pxafb.c
@@ -804,6 +804,9 @@ static int pxafb_smart_thread(void *arg)
804 804
805static int pxafb_smart_init(struct pxafb_info *fbi) 805static int pxafb_smart_init(struct pxafb_info *fbi)
806{ 806{
807 if (!(fbi->lccr0 | LCCR0_LCDT))
808 return 0;
809
807 fbi->smart_thread = kthread_run(pxafb_smart_thread, fbi, 810 fbi->smart_thread = kthread_run(pxafb_smart_thread, fbi,
808 "lcd_refresh"); 811 "lcd_refresh");
809 if (IS_ERR(fbi->smart_thread)) { 812 if (IS_ERR(fbi->smart_thread)) {
@@ -1372,7 +1375,7 @@ static void pxafb_decode_mach_info(struct pxafb_info *fbi,
1372 fbi->cmap_inverse = inf->cmap_inverse; 1375 fbi->cmap_inverse = inf->cmap_inverse;
1373 fbi->cmap_static = inf->cmap_static; 1376 fbi->cmap_static = inf->cmap_static;
1374 1377
1375 switch (lcd_conn & 0xf) { 1378 switch (lcd_conn & LCD_TYPE_MASK) {
1376 case LCD_TYPE_MONO_STN: 1379 case LCD_TYPE_MONO_STN:
1377 fbi->lccr0 = LCCR0_CMS; 1380 fbi->lccr0 = LCCR0_CMS;
1378 break; 1381 break;
diff --git a/drivers/video/tmiofb.c b/drivers/video/tmiofb.c
index 2a380011e9ba..7baf2dd12d50 100644
--- a/drivers/video/tmiofb.c
+++ b/drivers/video/tmiofb.c
@@ -222,6 +222,9 @@ static irqreturn_t tmiofb_irq(int irq, void *__info)
222 unsigned int bbisc = tmio_ioread16(par->lcr + LCR_BBISC); 222 unsigned int bbisc = tmio_ioread16(par->lcr + LCR_BBISC);
223 223
224 224
225 tmio_iowrite16(bbisc, par->lcr + LCR_BBISC);
226
227#ifdef CONFIG_FB_TMIO_ACCELL
225 /* 228 /*
226 * We were in polling mode and now we got correct irq. 229 * We were in polling mode and now we got correct irq.
227 * Switch back to IRQ-based sync of command FIFO 230 * Switch back to IRQ-based sync of command FIFO
@@ -231,9 +234,6 @@ static irqreturn_t tmiofb_irq(int irq, void *__info)
231 par->use_polling = false; 234 par->use_polling = false;
232 } 235 }
233 236
234 tmio_iowrite16(bbisc, par->lcr + LCR_BBISC);
235
236#ifdef CONFIG_FB_TMIO_ACCELL
237 if (bbisc & 1) 237 if (bbisc & 1)
238 wake_up(&par->wait_acc); 238 wake_up(&par->wait_acc);
239#endif 239#endif
@@ -938,7 +938,9 @@ static void tmiofb_dump_regs(struct platform_device *dev)
938static int tmiofb_suspend(struct platform_device *dev, pm_message_t state) 938static int tmiofb_suspend(struct platform_device *dev, pm_message_t state)
939{ 939{
940 struct fb_info *info = platform_get_drvdata(dev); 940 struct fb_info *info = platform_get_drvdata(dev);
941#ifdef CONFIG_FB_TMIO_ACCELL
941 struct tmiofb_par *par = info->par; 942 struct tmiofb_par *par = info->par;
943#endif
942 struct mfd_cell *cell = dev->dev.platform_data; 944 struct mfd_cell *cell = dev->dev.platform_data;
943 int retval = 0; 945 int retval = 0;
944 946
@@ -950,12 +952,14 @@ static int tmiofb_suspend(struct platform_device *dev, pm_message_t state)
950 info->fbops->fb_sync(info); 952 info->fbops->fb_sync(info);
951 953
952 954
955#ifdef CONFIG_FB_TMIO_ACCELL
953 /* 956 /*
954 * The fb should be usable even if interrupts are disabled (and they are 957 * The fb should be usable even if interrupts are disabled (and they are
955 * during suspend/resume). Switch temporary to forced polling. 958 * during suspend/resume). Switch temporary to forced polling.
956 */ 959 */
957 printk(KERN_INFO "tmiofb: switching to polling\n"); 960 printk(KERN_INFO "tmiofb: switching to polling\n");
958 par->use_polling = true; 961 par->use_polling = true;
962#endif
959 tmiofb_hw_stop(dev); 963 tmiofb_hw_stop(dev);
960 964
961 if (cell->suspend) 965 if (cell->suspend)
diff --git a/drivers/video/via/viafbdev.c b/drivers/video/via/viafbdev.c
index 0132eae06f55..73ac754ad801 100644
--- a/drivers/video/via/viafbdev.c
+++ b/drivers/video/via/viafbdev.c
@@ -2036,30 +2036,30 @@ static int viafb_vt1636_proc_write(struct file *file,
2036 return count; 2036 return count;
2037} 2037}
2038 2038
2039static void viafb_init_proc(struct proc_dir_entry *viafb_entry) 2039static void viafb_init_proc(struct proc_dir_entry **viafb_entry)
2040{ 2040{
2041 struct proc_dir_entry *entry; 2041 struct proc_dir_entry *entry;
2042 viafb_entry = proc_mkdir("viafb", NULL); 2042 *viafb_entry = proc_mkdir("viafb", NULL);
2043 if (viafb_entry) { 2043 if (viafb_entry) {
2044 entry = create_proc_entry("dvp0", 0, viafb_entry); 2044 entry = create_proc_entry("dvp0", 0, *viafb_entry);
2045 if (entry) { 2045 if (entry) {
2046 entry->owner = THIS_MODULE; 2046 entry->owner = THIS_MODULE;
2047 entry->read_proc = viafb_dvp0_proc_read; 2047 entry->read_proc = viafb_dvp0_proc_read;
2048 entry->write_proc = viafb_dvp0_proc_write; 2048 entry->write_proc = viafb_dvp0_proc_write;
2049 } 2049 }
2050 entry = create_proc_entry("dvp1", 0, viafb_entry); 2050 entry = create_proc_entry("dvp1", 0, *viafb_entry);
2051 if (entry) { 2051 if (entry) {
2052 entry->owner = THIS_MODULE; 2052 entry->owner = THIS_MODULE;
2053 entry->read_proc = viafb_dvp1_proc_read; 2053 entry->read_proc = viafb_dvp1_proc_read;
2054 entry->write_proc = viafb_dvp1_proc_write; 2054 entry->write_proc = viafb_dvp1_proc_write;
2055 } 2055 }
2056 entry = create_proc_entry("dfph", 0, viafb_entry); 2056 entry = create_proc_entry("dfph", 0, *viafb_entry);
2057 if (entry) { 2057 if (entry) {
2058 entry->owner = THIS_MODULE; 2058 entry->owner = THIS_MODULE;
2059 entry->read_proc = viafb_dfph_proc_read; 2059 entry->read_proc = viafb_dfph_proc_read;
2060 entry->write_proc = viafb_dfph_proc_write; 2060 entry->write_proc = viafb_dfph_proc_write;
2061 } 2061 }
2062 entry = create_proc_entry("dfpl", 0, viafb_entry); 2062 entry = create_proc_entry("dfpl", 0, *viafb_entry);
2063 if (entry) { 2063 if (entry) {
2064 entry->owner = THIS_MODULE; 2064 entry->owner = THIS_MODULE;
2065 entry->read_proc = viafb_dfpl_proc_read; 2065 entry->read_proc = viafb_dfpl_proc_read;
@@ -2068,7 +2068,7 @@ static void viafb_init_proc(struct proc_dir_entry *viafb_entry)
2068 if (VT1636_LVDS == viaparinfo->chip_info->lvds_chip_info. 2068 if (VT1636_LVDS == viaparinfo->chip_info->lvds_chip_info.
2069 lvds_chip_name || VT1636_LVDS == 2069 lvds_chip_name || VT1636_LVDS ==
2070 viaparinfo->chip_info->lvds_chip_info2.lvds_chip_name) { 2070 viaparinfo->chip_info->lvds_chip_info2.lvds_chip_name) {
2071 entry = create_proc_entry("vt1636", 0, viafb_entry); 2071 entry = create_proc_entry("vt1636", 0, *viafb_entry);
2072 if (entry) { 2072 if (entry) {
2073 entry->owner = THIS_MODULE; 2073 entry->owner = THIS_MODULE;
2074 entry->read_proc = viafb_vt1636_proc_read; 2074 entry->read_proc = viafb_vt1636_proc_read;
@@ -2087,6 +2087,7 @@ static void viafb_remove_proc(struct proc_dir_entry *viafb_entry)
2087 remove_proc_entry("dfpl", viafb_entry); 2087 remove_proc_entry("dfpl", viafb_entry);
2088 remove_proc_entry("vt1636", viafb_entry); 2088 remove_proc_entry("vt1636", viafb_entry);
2089 remove_proc_entry("vt1625", viafb_entry); 2089 remove_proc_entry("vt1625", viafb_entry);
2090 remove_proc_entry("viafb", NULL);
2090} 2091}
2091 2092
2092static int __devinit via_pci_probe(void) 2093static int __devinit via_pci_probe(void)
@@ -2348,7 +2349,7 @@ static int __devinit via_pci_probe(void)
2348 viafbinfo->node, viafbinfo->fix.id, default_var.xres, 2349 viafbinfo->node, viafbinfo->fix.id, default_var.xres,
2349 default_var.yres, default_var.bits_per_pixel); 2350 default_var.yres, default_var.bits_per_pixel);
2350 2351
2351 viafb_init_proc(viaparinfo->proc_entry); 2352 viafb_init_proc(&viaparinfo->proc_entry);
2352 viafb_init_dac(IGA2); 2353 viafb_init_dac(IGA2);
2353 return 0; 2354 return 0;
2354} 2355}
diff --git a/drivers/w1/masters/omap_hdq.c b/drivers/w1/masters/omap_hdq.c
index 1295625c4825..c973889110c8 100644
--- a/drivers/w1/masters/omap_hdq.c
+++ b/drivers/w1/masters/omap_hdq.c
@@ -86,8 +86,8 @@ static struct platform_driver omap_hdq_driver = {
86static u8 omap_w1_read_byte(void *_hdq); 86static u8 omap_w1_read_byte(void *_hdq);
87static void omap_w1_write_byte(void *_hdq, u8 byte); 87static void omap_w1_write_byte(void *_hdq, u8 byte);
88static u8 omap_w1_reset_bus(void *_hdq); 88static u8 omap_w1_reset_bus(void *_hdq);
89static void omap_w1_search_bus(void *_hdq, u8 search_type, 89static void omap_w1_search_bus(void *_hdq, struct w1_master *master_dev,
90 w1_slave_found_callback slave_found); 90 u8 search_type, w1_slave_found_callback slave_found);
91 91
92 92
93static struct w1_bus_master omap_w1_master = { 93static struct w1_bus_master omap_w1_master = {
@@ -231,8 +231,8 @@ static u8 omap_w1_reset_bus(void *_hdq)
231} 231}
232 232
233/* W1 search callback function */ 233/* W1 search callback function */
234static void omap_w1_search_bus(void *_hdq, u8 search_type, 234static void omap_w1_search_bus(void *_hdq, struct w1_master *master_dev,
235 w1_slave_found_callback slave_found) 235 u8 search_type, w1_slave_found_callback slave_found)
236{ 236{
237 u64 module_id, rn_le, cs, id; 237 u64 module_id, rn_le, cs, id;
238 238
@@ -249,7 +249,7 @@ static void omap_w1_search_bus(void *_hdq, u8 search_type,
249 cs = w1_calc_crc8((u8 *)&rn_le, 7); 249 cs = w1_calc_crc8((u8 *)&rn_le, 7);
250 id = (cs << 56) | module_id; 250 id = (cs << 56) | module_id;
251 251
252 slave_found(_hdq, id); 252 slave_found(master_dev, id);
253} 253}
254 254
255static int _omap_hdq_reset(struct hdq_data *hdq_data) 255static int _omap_hdq_reset(struct hdq_data *hdq_data)
diff --git a/drivers/xen/balloon.c b/drivers/xen/balloon.c
index a0fb5eac407c..526c191e84ea 100644
--- a/drivers/xen/balloon.c
+++ b/drivers/xen/balloon.c
@@ -122,14 +122,7 @@ static struct timer_list balloon_timer;
122static void scrub_page(struct page *page) 122static void scrub_page(struct page *page)
123{ 123{
124#ifdef CONFIG_XEN_SCRUB_PAGES 124#ifdef CONFIG_XEN_SCRUB_PAGES
125 if (PageHighMem(page)) { 125 clear_highpage(page);
126 void *v = kmap(page);
127 clear_page(v);
128 kunmap(v);
129 } else {
130 void *v = page_address(page);
131 clear_page(v);
132 }
133#endif 126#endif
134} 127}
135 128
diff --git a/fs/cifs/CHANGES b/fs/cifs/CHANGES
index 8855331b2fba..e078b7aea143 100644
--- a/fs/cifs/CHANGES
+++ b/fs/cifs/CHANGES
@@ -8,7 +8,11 @@ handling fcntl(F_SETLEASE). Convert cifs to using blocking tcp
8sends, and also let tcp autotune the socket send and receive buffers. 8sends, and also let tcp autotune the socket send and receive buffers.
9This reduces the number of EAGAIN errors returned by TCP/IP in 9This reduces the number of EAGAIN errors returned by TCP/IP in
10high stress workloads (and the number of retries on socket writes 10high stress workloads (and the number of retries on socket writes
11when sending large SMBWriteX requests). 11when sending large SMBWriteX requests). Fix case in which a portion of
12data can in some cases not get written to the file on the server before the
13file is closed. Fix DFS parsing to properly handle path consumed field,
14and to handle certain codepage conversions better. Fix mount and
15umount race that can cause oops in mount or umount or reconnect.
12 16
13Version 1.54 17Version 1.54
14------------ 18------------
diff --git a/fs/cifs/cifsglob.h b/fs/cifs/cifsglob.h
index f1ae1f57c30d..c57c0565547f 100644
--- a/fs/cifs/cifsglob.h
+++ b/fs/cifs/cifsglob.h
@@ -606,7 +606,15 @@ GLOBAL_EXTERN struct list_head cifs_tcp_ses_list;
606 * changes to the tcon->tidStatus should be done while holding this lock. 606 * changes to the tcon->tidStatus should be done while holding this lock.
607 */ 607 */
608GLOBAL_EXTERN rwlock_t cifs_tcp_ses_lock; 608GLOBAL_EXTERN rwlock_t cifs_tcp_ses_lock;
609GLOBAL_EXTERN rwlock_t GlobalSMBSeslock; /* protects list inserts on 3 above */ 609
610/*
611 * This lock protects the cifs_file->llist and cifs_file->flist
612 * list operations, and updates to some flags (cifs_file->invalidHandle)
613 * It will be moved to either use the tcon->stat_lock or equivalent later.
614 * If cifs_tcp_ses_lock and the lock below are both needed to be held, then
615 * the cifs_tcp_ses_lock must be grabbed first and released last.
616 */
617GLOBAL_EXTERN rwlock_t GlobalSMBSeslock;
610 618
611GLOBAL_EXTERN struct list_head GlobalOplock_Q; 619GLOBAL_EXTERN struct list_head GlobalOplock_Q;
612 620
diff --git a/fs/cifs/cifssmb.c b/fs/cifs/cifssmb.c
index bdda46dd435a..2af8626ced43 100644
--- a/fs/cifs/cifssmb.c
+++ b/fs/cifs/cifssmb.c
@@ -295,7 +295,7 @@ smb_init(int smb_command, int wct, struct cifsTconInfo *tcon,
295 check for tcp and smb session status done differently 295 check for tcp and smb session status done differently
296 for those three - in the calling routine */ 296 for those three - in the calling routine */
297 if (tcon) { 297 if (tcon) {
298 if (tcon->need_reconnect) { 298 if (tcon->tidStatus == CifsExiting) {
299 /* only tree disconnect, open, and write, 299 /* only tree disconnect, open, and write,
300 (and ulogoff which does not have tcon) 300 (and ulogoff which does not have tcon)
301 are allowed as we start force umount */ 301 are allowed as we start force umount */
diff --git a/fs/cifs/file.c b/fs/cifs/file.c
index 6449e1aae621..b691b893a848 100644
--- a/fs/cifs/file.c
+++ b/fs/cifs/file.c
@@ -488,12 +488,13 @@ int cifs_close(struct inode *inode, struct file *file)
488 pTcon = cifs_sb->tcon; 488 pTcon = cifs_sb->tcon;
489 if (pSMBFile) { 489 if (pSMBFile) {
490 struct cifsLockInfo *li, *tmp; 490 struct cifsLockInfo *li, *tmp;
491 491 write_lock(&GlobalSMBSeslock);
492 pSMBFile->closePend = true; 492 pSMBFile->closePend = true;
493 if (pTcon) { 493 if (pTcon) {
494 /* no sense reconnecting to close a file that is 494 /* no sense reconnecting to close a file that is
495 already closed */ 495 already closed */
496 if (!pTcon->need_reconnect) { 496 if (!pTcon->need_reconnect) {
497 write_unlock(&GlobalSMBSeslock);
497 timeout = 2; 498 timeout = 2;
498 while ((atomic_read(&pSMBFile->wrtPending) != 0) 499 while ((atomic_read(&pSMBFile->wrtPending) != 0)
499 && (timeout <= 2048)) { 500 && (timeout <= 2048)) {
@@ -510,12 +511,15 @@ int cifs_close(struct inode *inode, struct file *file)
510 timeout *= 4; 511 timeout *= 4;
511 } 512 }
512 if (atomic_read(&pSMBFile->wrtPending)) 513 if (atomic_read(&pSMBFile->wrtPending))
513 cERROR(1, 514 cERROR(1, ("close with pending write"));
514 ("close with pending writes")); 515 if (!pTcon->need_reconnect &&
515 rc = CIFSSMBClose(xid, pTcon, 516 !pSMBFile->invalidHandle)
517 rc = CIFSSMBClose(xid, pTcon,
516 pSMBFile->netfid); 518 pSMBFile->netfid);
517 } 519 } else
518 } 520 write_unlock(&GlobalSMBSeslock);
521 } else
522 write_unlock(&GlobalSMBSeslock);
519 523
520 /* Delete any outstanding lock records. 524 /* Delete any outstanding lock records.
521 We'll lose them when the file is closed anyway. */ 525 We'll lose them when the file is closed anyway. */
@@ -587,15 +591,18 @@ int cifs_closedir(struct inode *inode, struct file *file)
587 pTcon = cifs_sb->tcon; 591 pTcon = cifs_sb->tcon;
588 592
589 cFYI(1, ("Freeing private data in close dir")); 593 cFYI(1, ("Freeing private data in close dir"));
594 write_lock(&GlobalSMBSeslock);
590 if (!pCFileStruct->srch_inf.endOfSearch && 595 if (!pCFileStruct->srch_inf.endOfSearch &&
591 !pCFileStruct->invalidHandle) { 596 !pCFileStruct->invalidHandle) {
592 pCFileStruct->invalidHandle = true; 597 pCFileStruct->invalidHandle = true;
598 write_unlock(&GlobalSMBSeslock);
593 rc = CIFSFindClose(xid, pTcon, pCFileStruct->netfid); 599 rc = CIFSFindClose(xid, pTcon, pCFileStruct->netfid);
594 cFYI(1, ("Closing uncompleted readdir with rc %d", 600 cFYI(1, ("Closing uncompleted readdir with rc %d",
595 rc)); 601 rc));
596 /* not much we can do if it fails anyway, ignore rc */ 602 /* not much we can do if it fails anyway, ignore rc */
597 rc = 0; 603 rc = 0;
598 } 604 } else
605 write_unlock(&GlobalSMBSeslock);
599 ptmp = pCFileStruct->srch_inf.ntwrk_buf_start; 606 ptmp = pCFileStruct->srch_inf.ntwrk_buf_start;
600 if (ptmp) { 607 if (ptmp) {
601 cFYI(1, ("closedir free smb buf in srch struct")); 608 cFYI(1, ("closedir free smb buf in srch struct"));
diff --git a/fs/cifs/misc.c b/fs/cifs/misc.c
index addd1dcc2d79..9ee3f689c2b0 100644
--- a/fs/cifs/misc.c
+++ b/fs/cifs/misc.c
@@ -555,12 +555,14 @@ is_valid_oplock_break(struct smb_hdr *buf, struct TCP_Server_Info *srv)
555 continue; 555 continue;
556 556
557 cifs_stats_inc(&tcon->num_oplock_brks); 557 cifs_stats_inc(&tcon->num_oplock_brks);
558 write_lock(&GlobalSMBSeslock);
558 list_for_each(tmp2, &tcon->openFileList) { 559 list_for_each(tmp2, &tcon->openFileList) {
559 netfile = list_entry(tmp2, struct cifsFileInfo, 560 netfile = list_entry(tmp2, struct cifsFileInfo,
560 tlist); 561 tlist);
561 if (pSMB->Fid != netfile->netfid) 562 if (pSMB->Fid != netfile->netfid)
562 continue; 563 continue;
563 564
565 write_unlock(&GlobalSMBSeslock);
564 read_unlock(&cifs_tcp_ses_lock); 566 read_unlock(&cifs_tcp_ses_lock);
565 cFYI(1, ("file id match, oplock break")); 567 cFYI(1, ("file id match, oplock break"));
566 pCifsInode = CIFS_I(netfile->pInode); 568 pCifsInode = CIFS_I(netfile->pInode);
@@ -576,6 +578,7 @@ is_valid_oplock_break(struct smb_hdr *buf, struct TCP_Server_Info *srv)
576 578
577 return true; 579 return true;
578 } 580 }
581 write_unlock(&GlobalSMBSeslock);
579 read_unlock(&cifs_tcp_ses_lock); 582 read_unlock(&cifs_tcp_ses_lock);
580 cFYI(1, ("No matching file for oplock break")); 583 cFYI(1, ("No matching file for oplock break"));
581 return true; 584 return true;
diff --git a/fs/cifs/readdir.c b/fs/cifs/readdir.c
index 58d57299f2a0..9f51f9bf0292 100644
--- a/fs/cifs/readdir.c
+++ b/fs/cifs/readdir.c
@@ -741,11 +741,14 @@ static int find_cifs_entry(const int xid, struct cifsTconInfo *pTcon,
741 (index_to_find < first_entry_in_buffer)) { 741 (index_to_find < first_entry_in_buffer)) {
742 /* close and restart search */ 742 /* close and restart search */
743 cFYI(1, ("search backing up - close and restart search")); 743 cFYI(1, ("search backing up - close and restart search"));
744 write_lock(&GlobalSMBSeslock);
744 if (!cifsFile->srch_inf.endOfSearch && 745 if (!cifsFile->srch_inf.endOfSearch &&
745 !cifsFile->invalidHandle) { 746 !cifsFile->invalidHandle) {
746 cifsFile->invalidHandle = true; 747 cifsFile->invalidHandle = true;
748 write_unlock(&GlobalSMBSeslock);
747 CIFSFindClose(xid, pTcon, cifsFile->netfid); 749 CIFSFindClose(xid, pTcon, cifsFile->netfid);
748 } 750 } else
751 write_unlock(&GlobalSMBSeslock);
749 if (cifsFile->srch_inf.ntwrk_buf_start) { 752 if (cifsFile->srch_inf.ntwrk_buf_start) {
750 cFYI(1, ("freeing SMB ff cache buf on search rewind")); 753 cFYI(1, ("freeing SMB ff cache buf on search rewind"));
751 if (cifsFile->srch_inf.smallBuf) 754 if (cifsFile->srch_inf.smallBuf)
diff --git a/fs/ecryptfs/keystore.c b/fs/ecryptfs/keystore.c
index e22bc3961345..0d713b691941 100644
--- a/fs/ecryptfs/keystore.c
+++ b/fs/ecryptfs/keystore.c
@@ -1037,17 +1037,14 @@ static int
1037decrypt_passphrase_encrypted_session_key(struct ecryptfs_auth_tok *auth_tok, 1037decrypt_passphrase_encrypted_session_key(struct ecryptfs_auth_tok *auth_tok,
1038 struct ecryptfs_crypt_stat *crypt_stat) 1038 struct ecryptfs_crypt_stat *crypt_stat)
1039{ 1039{
1040 struct scatterlist dst_sg; 1040 struct scatterlist dst_sg[2];
1041 struct scatterlist src_sg; 1041 struct scatterlist src_sg[2];
1042 struct mutex *tfm_mutex; 1042 struct mutex *tfm_mutex;
1043 struct blkcipher_desc desc = { 1043 struct blkcipher_desc desc = {
1044 .flags = CRYPTO_TFM_REQ_MAY_SLEEP 1044 .flags = CRYPTO_TFM_REQ_MAY_SLEEP
1045 }; 1045 };
1046 int rc = 0; 1046 int rc = 0;
1047 1047
1048 sg_init_table(&dst_sg, 1);
1049 sg_init_table(&src_sg, 1);
1050
1051 if (unlikely(ecryptfs_verbosity > 0)) { 1048 if (unlikely(ecryptfs_verbosity > 0)) {
1052 ecryptfs_printk( 1049 ecryptfs_printk(
1053 KERN_DEBUG, "Session key encryption key (size [%d]):\n", 1050 KERN_DEBUG, "Session key encryption key (size [%d]):\n",
@@ -1066,8 +1063,8 @@ decrypt_passphrase_encrypted_session_key(struct ecryptfs_auth_tok *auth_tok,
1066 } 1063 }
1067 rc = virt_to_scatterlist(auth_tok->session_key.encrypted_key, 1064 rc = virt_to_scatterlist(auth_tok->session_key.encrypted_key,
1068 auth_tok->session_key.encrypted_key_size, 1065 auth_tok->session_key.encrypted_key_size,
1069 &src_sg, 1); 1066 src_sg, 2);
1070 if (rc != 1) { 1067 if (rc < 1 || rc > 2) {
1071 printk(KERN_ERR "Internal error whilst attempting to convert " 1068 printk(KERN_ERR "Internal error whilst attempting to convert "
1072 "auth_tok->session_key.encrypted_key to scatterlist; " 1069 "auth_tok->session_key.encrypted_key to scatterlist; "
1073 "expected rc = 1; got rc = [%d]. " 1070 "expected rc = 1; got rc = [%d]. "
@@ -1079,8 +1076,8 @@ decrypt_passphrase_encrypted_session_key(struct ecryptfs_auth_tok *auth_tok,
1079 auth_tok->session_key.encrypted_key_size; 1076 auth_tok->session_key.encrypted_key_size;
1080 rc = virt_to_scatterlist(auth_tok->session_key.decrypted_key, 1077 rc = virt_to_scatterlist(auth_tok->session_key.decrypted_key,
1081 auth_tok->session_key.decrypted_key_size, 1078 auth_tok->session_key.decrypted_key_size,
1082 &dst_sg, 1); 1079 dst_sg, 2);
1083 if (rc != 1) { 1080 if (rc < 1 || rc > 2) {
1084 printk(KERN_ERR "Internal error whilst attempting to convert " 1081 printk(KERN_ERR "Internal error whilst attempting to convert "
1085 "auth_tok->session_key.decrypted_key to scatterlist; " 1082 "auth_tok->session_key.decrypted_key to scatterlist; "
1086 "expected rc = 1; got rc = [%d]\n", rc); 1083 "expected rc = 1; got rc = [%d]\n", rc);
@@ -1096,7 +1093,7 @@ decrypt_passphrase_encrypted_session_key(struct ecryptfs_auth_tok *auth_tok,
1096 rc = -EINVAL; 1093 rc = -EINVAL;
1097 goto out; 1094 goto out;
1098 } 1095 }
1099 rc = crypto_blkcipher_decrypt(&desc, &dst_sg, &src_sg, 1096 rc = crypto_blkcipher_decrypt(&desc, dst_sg, src_sg,
1100 auth_tok->session_key.encrypted_key_size); 1097 auth_tok->session_key.encrypted_key_size);
1101 mutex_unlock(tfm_mutex); 1098 mutex_unlock(tfm_mutex);
1102 if (unlikely(rc)) { 1099 if (unlikely(rc)) {
@@ -1539,8 +1536,8 @@ write_tag_3_packet(char *dest, size_t *remaining_bytes,
1539 size_t i; 1536 size_t i;
1540 size_t encrypted_session_key_valid = 0; 1537 size_t encrypted_session_key_valid = 0;
1541 char session_key_encryption_key[ECRYPTFS_MAX_KEY_BYTES]; 1538 char session_key_encryption_key[ECRYPTFS_MAX_KEY_BYTES];
1542 struct scatterlist dst_sg; 1539 struct scatterlist dst_sg[2];
1543 struct scatterlist src_sg; 1540 struct scatterlist src_sg[2];
1544 struct mutex *tfm_mutex = NULL; 1541 struct mutex *tfm_mutex = NULL;
1545 u8 cipher_code; 1542 u8 cipher_code;
1546 size_t packet_size_length; 1543 size_t packet_size_length;
@@ -1619,8 +1616,8 @@ write_tag_3_packet(char *dest, size_t *remaining_bytes,
1619 ecryptfs_dump_hex(session_key_encryption_key, 16); 1616 ecryptfs_dump_hex(session_key_encryption_key, 16);
1620 } 1617 }
1621 rc = virt_to_scatterlist(crypt_stat->key, key_rec->enc_key_size, 1618 rc = virt_to_scatterlist(crypt_stat->key, key_rec->enc_key_size,
1622 &src_sg, 1); 1619 src_sg, 2);
1623 if (rc != 1) { 1620 if (rc < 1 || rc > 2) {
1624 ecryptfs_printk(KERN_ERR, "Error generating scatterlist " 1621 ecryptfs_printk(KERN_ERR, "Error generating scatterlist "
1625 "for crypt_stat session key; expected rc = 1; " 1622 "for crypt_stat session key; expected rc = 1; "
1626 "got rc = [%d]. key_rec->enc_key_size = [%d]\n", 1623 "got rc = [%d]. key_rec->enc_key_size = [%d]\n",
@@ -1629,8 +1626,8 @@ write_tag_3_packet(char *dest, size_t *remaining_bytes,
1629 goto out; 1626 goto out;
1630 } 1627 }
1631 rc = virt_to_scatterlist(key_rec->enc_key, key_rec->enc_key_size, 1628 rc = virt_to_scatterlist(key_rec->enc_key, key_rec->enc_key_size,
1632 &dst_sg, 1); 1629 dst_sg, 2);
1633 if (rc != 1) { 1630 if (rc < 1 || rc > 2) {
1634 ecryptfs_printk(KERN_ERR, "Error generating scatterlist " 1631 ecryptfs_printk(KERN_ERR, "Error generating scatterlist "
1635 "for crypt_stat encrypted session key; " 1632 "for crypt_stat encrypted session key; "
1636 "expected rc = 1; got rc = [%d]. " 1633 "expected rc = 1; got rc = [%d]. "
@@ -1651,7 +1648,7 @@ write_tag_3_packet(char *dest, size_t *remaining_bytes,
1651 rc = 0; 1648 rc = 0;
1652 ecryptfs_printk(KERN_DEBUG, "Encrypting [%d] bytes of the key\n", 1649 ecryptfs_printk(KERN_DEBUG, "Encrypting [%d] bytes of the key\n",
1653 crypt_stat->key_size); 1650 crypt_stat->key_size);
1654 rc = crypto_blkcipher_encrypt(&desc, &dst_sg, &src_sg, 1651 rc = crypto_blkcipher_encrypt(&desc, dst_sg, src_sg,
1655 (*key_rec).enc_key_size); 1652 (*key_rec).enc_key_size);
1656 mutex_unlock(tfm_mutex); 1653 mutex_unlock(tfm_mutex);
1657 if (rc) { 1654 if (rc) {
diff --git a/fs/hostfs/hostfs.h b/fs/hostfs/hostfs.h
index 6ae9011b95eb..2f34f8f2134b 100644
--- a/fs/hostfs/hostfs.h
+++ b/fs/hostfs/hostfs.h
@@ -81,7 +81,7 @@ extern int do_rmdir(const char *file);
81extern int do_mknod(const char *file, int mode, unsigned int major, 81extern int do_mknod(const char *file, int mode, unsigned int major,
82 unsigned int minor); 82 unsigned int minor);
83extern int link_file(const char *from, const char *to); 83extern int link_file(const char *from, const char *to);
84extern int do_readlink(char *file, char *buf, int size); 84extern int hostfs_do_readlink(char *file, char *buf, int size);
85extern int rename_file(char *from, char *to); 85extern int rename_file(char *from, char *to);
86extern int do_statfs(char *root, long *bsize_out, long long *blocks_out, 86extern int do_statfs(char *root, long *bsize_out, long long *blocks_out,
87 long long *bfree_out, long long *bavail_out, 87 long long *bfree_out, long long *bavail_out,
diff --git a/fs/hostfs/hostfs_kern.c b/fs/hostfs/hostfs_kern.c
index 7f34f4385de0..3a31451ac170 100644
--- a/fs/hostfs/hostfs_kern.c
+++ b/fs/hostfs/hostfs_kern.c
@@ -168,7 +168,7 @@ static char *follow_link(char *link)
168 if (name == NULL) 168 if (name == NULL)
169 goto out; 169 goto out;
170 170
171 n = do_readlink(link, name, len); 171 n = hostfs_do_readlink(link, name, len);
172 if (n < len) 172 if (n < len)
173 break; 173 break;
174 len *= 2; 174 len *= 2;
@@ -943,7 +943,7 @@ int hostfs_link_readpage(struct file *file, struct page *page)
943 name = inode_name(page->mapping->host, 0); 943 name = inode_name(page->mapping->host, 0);
944 if (name == NULL) 944 if (name == NULL)
945 return -ENOMEM; 945 return -ENOMEM;
946 err = do_readlink(name, buffer, PAGE_CACHE_SIZE); 946 err = hostfs_do_readlink(name, buffer, PAGE_CACHE_SIZE);
947 kfree(name); 947 kfree(name);
948 if (err == PAGE_CACHE_SIZE) 948 if (err == PAGE_CACHE_SIZE)
949 err = -E2BIG; 949 err = -E2BIG;
diff --git a/fs/hostfs/hostfs_user.c b/fs/hostfs/hostfs_user.c
index 53fd0a67c11a..b79424f93282 100644
--- a/fs/hostfs/hostfs_user.c
+++ b/fs/hostfs/hostfs_user.c
@@ -377,7 +377,7 @@ int link_file(const char *to, const char *from)
377 return 0; 377 return 0;
378} 378}
379 379
380int do_readlink(char *file, char *buf, int size) 380int hostfs_do_readlink(char *file, char *buf, int size)
381{ 381{
382 int n; 382 int n;
383 383
diff --git a/fs/namei.c b/fs/namei.c
index 09ce58e49e72..d34e0f9681c6 100644
--- a/fs/namei.c
+++ b/fs/namei.c
@@ -1378,7 +1378,7 @@ static int may_delete(struct inode *dir,struct dentry *victim,int isdir)
1378 if (IS_APPEND(dir)) 1378 if (IS_APPEND(dir))
1379 return -EPERM; 1379 return -EPERM;
1380 if (check_sticky(dir, victim->d_inode)||IS_APPEND(victim->d_inode)|| 1380 if (check_sticky(dir, victim->d_inode)||IS_APPEND(victim->d_inode)||
1381 IS_IMMUTABLE(victim->d_inode)) 1381 IS_IMMUTABLE(victim->d_inode) || IS_SWAPFILE(victim->d_inode))
1382 return -EPERM; 1382 return -EPERM;
1383 if (isdir) { 1383 if (isdir) {
1384 if (!S_ISDIR(victim->d_inode->i_mode)) 1384 if (!S_ISDIR(victim->d_inode->i_mode))
diff --git a/include/asm-generic/vmlinux.lds.h b/include/asm-generic/vmlinux.lds.h
index 80744606bad1..3b46ae464933 100644
--- a/include/asm-generic/vmlinux.lds.h
+++ b/include/asm-generic/vmlinux.lds.h
@@ -45,6 +45,17 @@
45#define MCOUNT_REC() 45#define MCOUNT_REC()
46#endif 46#endif
47 47
48#ifdef CONFIG_TRACE_BRANCH_PROFILING
49#define LIKELY_PROFILE() VMLINUX_SYMBOL(__start_likely_profile) = .; \
50 *(_ftrace_likely) \
51 VMLINUX_SYMBOL(__stop_likely_profile) = .; \
52 VMLINUX_SYMBOL(__start_unlikely_profile) = .; \
53 *(_ftrace_unlikely) \
54 VMLINUX_SYMBOL(__stop_unlikely_profile) = .;
55#else
56#define LIKELY_PROFILE()
57#endif
58
48/* .data section */ 59/* .data section */
49#define DATA_DATA \ 60#define DATA_DATA \
50 *(.data) \ 61 *(.data) \
@@ -60,9 +71,11 @@
60 VMLINUX_SYMBOL(__start___markers) = .; \ 71 VMLINUX_SYMBOL(__start___markers) = .; \
61 *(__markers) \ 72 *(__markers) \
62 VMLINUX_SYMBOL(__stop___markers) = .; \ 73 VMLINUX_SYMBOL(__stop___markers) = .; \
74 . = ALIGN(32); \
63 VMLINUX_SYMBOL(__start___tracepoints) = .; \ 75 VMLINUX_SYMBOL(__start___tracepoints) = .; \
64 *(__tracepoints) \ 76 *(__tracepoints) \
65 VMLINUX_SYMBOL(__stop___tracepoints) = .; 77 VMLINUX_SYMBOL(__stop___tracepoints) = .; \
78 LIKELY_PROFILE()
66 79
67#define RO_DATA(align) \ 80#define RO_DATA(align) \
68 . = ALIGN((align)); \ 81 . = ALIGN((align)); \
diff --git a/include/linux/compiler.h b/include/linux/compiler.h
index 98115d9d04da..c7d804a7a4d6 100644
--- a/include/linux/compiler.h
+++ b/include/linux/compiler.h
@@ -59,8 +59,70 @@ extern void __chk_io_ptr(const volatile void __iomem *);
59 * specific implementations come from the above header files 59 * specific implementations come from the above header files
60 */ 60 */
61 61
62#define likely(x) __builtin_expect(!!(x), 1) 62struct ftrace_branch_data {
63#define unlikely(x) __builtin_expect(!!(x), 0) 63 const char *func;
64 const char *file;
65 unsigned line;
66 unsigned long correct;
67 unsigned long incorrect;
68};
69
70/*
71 * Note: DISABLE_BRANCH_PROFILING can be used by special lowlevel code
72 * to disable branch tracing on a per file basis.
73 */
74#if defined(CONFIG_TRACE_BRANCH_PROFILING) && !defined(DISABLE_BRANCH_PROFILING)
75void ftrace_likely_update(struct ftrace_branch_data *f, int val, int expect);
76
77#define likely_notrace(x) __builtin_expect(!!(x), 1)
78#define unlikely_notrace(x) __builtin_expect(!!(x), 0)
79
80#define likely_check(x) ({ \
81 int ______r; \
82 static struct ftrace_branch_data \
83 __attribute__((__aligned__(4))) \
84 __attribute__((section("_ftrace_likely"))) \
85 ______f = { \
86 .func = __func__, \
87 .file = __FILE__, \
88 .line = __LINE__, \
89 }; \
90 ______f.line = __LINE__; \
91 ______r = likely_notrace(x); \
92 ftrace_likely_update(&______f, ______r, 1); \
93 ______r; \
94 })
95#define unlikely_check(x) ({ \
96 int ______r; \
97 static struct ftrace_branch_data \
98 __attribute__((__aligned__(4))) \
99 __attribute__((section("_ftrace_unlikely"))) \
100 ______f = { \
101 .func = __func__, \
102 .file = __FILE__, \
103 .line = __LINE__, \
104 }; \
105 ______f.line = __LINE__; \
106 ______r = unlikely_notrace(x); \
107 ftrace_likely_update(&______f, ______r, 0); \
108 ______r; \
109 })
110
111/*
112 * Using __builtin_constant_p(x) to ignore cases where the return
113 * value is always the same. This idea is taken from a similar patch
114 * written by Daniel Walker.
115 */
116# ifndef likely
117# define likely(x) (__builtin_constant_p(x) ? !!(x) : likely_check(x))
118# endif
119# ifndef unlikely
120# define unlikely(x) (__builtin_constant_p(x) ? !!(x) : unlikely_check(x))
121# endif
122#else
123# define likely(x) __builtin_expect(!!(x), 1)
124# define unlikely(x) __builtin_expect(!!(x), 0)
125#endif
64 126
65/* Optimization barrier */ 127/* Optimization barrier */
66#ifndef barrier 128#ifndef barrier
diff --git a/include/linux/cpuset.h b/include/linux/cpuset.h
index 2691926fb506..8e540d32c9fe 100644
--- a/include/linux/cpuset.h
+++ b/include/linux/cpuset.h
@@ -74,8 +74,6 @@ static inline int cpuset_do_slab_mem_spread(void)
74 return current->flags & PF_SPREAD_SLAB; 74 return current->flags & PF_SPREAD_SLAB;
75} 75}
76 76
77extern void cpuset_track_online_nodes(void);
78
79extern int current_cpuset_is_being_rebound(void); 77extern int current_cpuset_is_being_rebound(void);
80 78
81extern void rebuild_sched_domains(void); 79extern void rebuild_sched_domains(void);
@@ -151,8 +149,6 @@ static inline int cpuset_do_slab_mem_spread(void)
151 return 0; 149 return 0;
152} 150}
153 151
154static inline void cpuset_track_online_nodes(void) {}
155
156static inline int current_cpuset_is_being_rebound(void) 152static inline int current_cpuset_is_being_rebound(void)
157{ 153{
158 return 0; 154 return 0;
diff --git a/include/linux/ftrace.h b/include/linux/ftrace.h
index 703eb53cfa2b..f7ba4ea5e128 100644
--- a/include/linux/ftrace.h
+++ b/include/linux/ftrace.h
@@ -23,6 +23,45 @@ struct ftrace_ops {
23 struct ftrace_ops *next; 23 struct ftrace_ops *next;
24}; 24};
25 25
26extern int function_trace_stop;
27
28/*
29 * Type of the current tracing.
30 */
31enum ftrace_tracing_type_t {
32 FTRACE_TYPE_ENTER = 0, /* Hook the call of the function */
33 FTRACE_TYPE_RETURN, /* Hook the return of the function */
34};
35
36/* Current tracing type, default is FTRACE_TYPE_ENTER */
37extern enum ftrace_tracing_type_t ftrace_tracing_type;
38
39/**
40 * ftrace_stop - stop function tracer.
41 *
42 * A quick way to stop the function tracer. Note this an on off switch,
43 * it is not something that is recursive like preempt_disable.
44 * This does not disable the calling of mcount, it only stops the
45 * calling of functions from mcount.
46 */
47static inline void ftrace_stop(void)
48{
49 function_trace_stop = 1;
50}
51
52/**
53 * ftrace_start - start the function tracer.
54 *
55 * This function is the inverse of ftrace_stop. This does not enable
56 * the function tracing if the function tracer is disabled. This only
57 * sets the function tracer flag to continue calling the functions
58 * from mcount.
59 */
60static inline void ftrace_start(void)
61{
62 function_trace_stop = 0;
63}
64
26/* 65/*
27 * The ftrace_ops must be a static and should also 66 * The ftrace_ops must be a static and should also
28 * be read_mostly. These functions do modify read_mostly variables 67 * be read_mostly. These functions do modify read_mostly variables
@@ -41,9 +80,13 @@ extern void ftrace_stub(unsigned long a0, unsigned long a1);
41# define unregister_ftrace_function(ops) do { } while (0) 80# define unregister_ftrace_function(ops) do { } while (0)
42# define clear_ftrace_function(ops) do { } while (0) 81# define clear_ftrace_function(ops) do { } while (0)
43static inline void ftrace_kill(void) { } 82static inline void ftrace_kill(void) { }
83static inline void ftrace_stop(void) { }
84static inline void ftrace_start(void) { }
44#endif /* CONFIG_FUNCTION_TRACER */ 85#endif /* CONFIG_FUNCTION_TRACER */
45 86
46#ifdef CONFIG_DYNAMIC_FTRACE 87#ifdef CONFIG_DYNAMIC_FTRACE
88/* asm/ftrace.h must be defined for archs supporting dynamic ftrace */
89#include <asm/ftrace.h>
47 90
48enum { 91enum {
49 FTRACE_FL_FREE = (1 << 0), 92 FTRACE_FL_FREE = (1 << 0),
@@ -59,6 +102,7 @@ struct dyn_ftrace {
59 struct list_head list; 102 struct list_head list;
60 unsigned long ip; /* address of mcount call-site */ 103 unsigned long ip; /* address of mcount call-site */
61 unsigned long flags; 104 unsigned long flags;
105 struct dyn_arch_ftrace arch;
62}; 106};
63 107
64int ftrace_force_update(void); 108int ftrace_force_update(void);
@@ -66,19 +110,43 @@ void ftrace_set_filter(unsigned char *buf, int len, int reset);
66 110
67/* defined in arch */ 111/* defined in arch */
68extern int ftrace_ip_converted(unsigned long ip); 112extern int ftrace_ip_converted(unsigned long ip);
69extern unsigned char *ftrace_nop_replace(void);
70extern unsigned char *ftrace_call_replace(unsigned long ip, unsigned long addr);
71extern int ftrace_dyn_arch_init(void *data); 113extern int ftrace_dyn_arch_init(void *data);
72extern int ftrace_update_ftrace_func(ftrace_func_t func); 114extern int ftrace_update_ftrace_func(ftrace_func_t func);
73extern void ftrace_caller(void); 115extern void ftrace_caller(void);
74extern void ftrace_call(void); 116extern void ftrace_call(void);
75extern void mcount_call(void); 117extern void mcount_call(void);
118#ifdef CONFIG_FUNCTION_RET_TRACER
119extern void ftrace_return_caller(void);
120#endif
121
122/**
123 * ftrace_make_nop - convert code into top
124 * @mod: module structure if called by module load initialization
125 * @rec: the mcount call site record
126 * @addr: the address that the call site should be calling
127 *
128 * This is a very sensitive operation and great care needs
129 * to be taken by the arch. The operation should carefully
130 * read the location, check to see if what is read is indeed
131 * what we expect it to be, and then on success of the compare,
132 * it should write to the location.
133 *
134 * The code segment at @rec->ip should be a caller to @addr
135 *
136 * Return must be:
137 * 0 on success
138 * -EFAULT on error reading the location
139 * -EINVAL on a failed compare of the contents
140 * -EPERM on error writing to the location
141 * Any other value will be considered a failure.
142 */
143extern int ftrace_make_nop(struct module *mod,
144 struct dyn_ftrace *rec, unsigned long addr);
76 145
77/** 146/**
78 * ftrace_modify_code - modify code segment 147 * ftrace_make_call - convert a nop call site into a call to addr
79 * @ip: the address of the code segment 148 * @rec: the mcount call site record
80 * @old_code: the contents of what is expected to be there 149 * @addr: the address that the call site should call
81 * @new_code: the code to patch in
82 * 150 *
83 * This is a very sensitive operation and great care needs 151 * This is a very sensitive operation and great care needs
84 * to be taken by the arch. The operation should carefully 152 * to be taken by the arch. The operation should carefully
@@ -86,6 +154,8 @@ extern void mcount_call(void);
86 * what we expect it to be, and then on success of the compare, 154 * what we expect it to be, and then on success of the compare,
87 * it should write to the location. 155 * it should write to the location.
88 * 156 *
157 * The code segment at @rec->ip should be a nop
158 *
89 * Return must be: 159 * Return must be:
90 * 0 on success 160 * 0 on success
91 * -EFAULT on error reading the location 161 * -EFAULT on error reading the location
@@ -93,8 +163,11 @@ extern void mcount_call(void);
93 * -EPERM on error writing to the location 163 * -EPERM on error writing to the location
94 * Any other value will be considered a failure. 164 * Any other value will be considered a failure.
95 */ 165 */
96extern int ftrace_modify_code(unsigned long ip, unsigned char *old_code, 166extern int ftrace_make_call(struct dyn_ftrace *rec, unsigned long addr);
97 unsigned char *new_code); 167
168
169/* May be defined in arch */
170extern int ftrace_arch_read_dyn_info(char *buf, int size);
98 171
99extern int skip_trace(unsigned long ip); 172extern int skip_trace(unsigned long ip);
100 173
@@ -102,7 +175,6 @@ extern void ftrace_release(void *start, unsigned long size);
102 175
103extern void ftrace_disable_daemon(void); 176extern void ftrace_disable_daemon(void);
104extern void ftrace_enable_daemon(void); 177extern void ftrace_enable_daemon(void);
105
106#else 178#else
107# define skip_trace(ip) ({ 0; }) 179# define skip_trace(ip) ({ 0; })
108# define ftrace_force_update() ({ 0; }) 180# define ftrace_force_update() ({ 0; })
@@ -181,6 +253,11 @@ static inline void __ftrace_enabled_restore(int enabled)
181#endif 253#endif
182 254
183#ifdef CONFIG_TRACING 255#ifdef CONFIG_TRACING
256extern int ftrace_dump_on_oops;
257
258extern void tracing_start(void);
259extern void tracing_stop(void);
260
184extern void 261extern void
185ftrace_special(unsigned long arg1, unsigned long arg2, unsigned long arg3); 262ftrace_special(unsigned long arg1, unsigned long arg2, unsigned long arg3);
186 263
@@ -211,6 +288,8 @@ ftrace_special(unsigned long arg1, unsigned long arg2, unsigned long arg3) { }
211static inline int 288static inline int
212ftrace_printk(const char *fmt, ...) __attribute__ ((format (printf, 1, 0))); 289ftrace_printk(const char *fmt, ...) __attribute__ ((format (printf, 1, 0)));
213 290
291static inline void tracing_start(void) { }
292static inline void tracing_stop(void) { }
214static inline int 293static inline int
215ftrace_printk(const char *fmt, ...) 294ftrace_printk(const char *fmt, ...)
216{ 295{
@@ -221,33 +300,36 @@ static inline void ftrace_dump(void) { }
221 300
222#ifdef CONFIG_FTRACE_MCOUNT_RECORD 301#ifdef CONFIG_FTRACE_MCOUNT_RECORD
223extern void ftrace_init(void); 302extern void ftrace_init(void);
224extern void ftrace_init_module(unsigned long *start, unsigned long *end); 303extern void ftrace_init_module(struct module *mod,
304 unsigned long *start, unsigned long *end);
225#else 305#else
226static inline void ftrace_init(void) { } 306static inline void ftrace_init(void) { }
227static inline void 307static inline void
228ftrace_init_module(unsigned long *start, unsigned long *end) { } 308ftrace_init_module(struct module *mod,
309 unsigned long *start, unsigned long *end) { }
229#endif 310#endif
230 311
231 312
232struct boot_trace { 313/*
233 pid_t caller; 314 * Structure that defines a return function trace.
234 char func[KSYM_NAME_LEN]; 315 */
235 int result; 316struct ftrace_retfunc {
236 unsigned long long duration; /* usecs */ 317 unsigned long ret; /* Return address */
237 ktime_t calltime; 318 unsigned long func; /* Current function */
238 ktime_t rettime; 319 unsigned long long calltime;
320 unsigned long long rettime;
321 /* Number of functions that overran the depth limit for current task */
322 unsigned long overrun;
239}; 323};
240 324
241#ifdef CONFIG_BOOT_TRACER 325#ifdef CONFIG_FUNCTION_RET_TRACER
242extern void trace_boot(struct boot_trace *it, initcall_t fn); 326/* Type of a callback handler of tracing return function */
243extern void start_boot_trace(void); 327typedef void (*trace_function_return_t)(struct ftrace_retfunc *);
244extern void stop_boot_trace(void);
245#else
246static inline void trace_boot(struct boot_trace *it, initcall_t fn) { }
247static inline void start_boot_trace(void) { }
248static inline void stop_boot_trace(void) { }
249#endif
250
251 328
329extern int register_ftrace_return(trace_function_return_t func);
330/* The current handler in use */
331extern trace_function_return_t ftrace_function_return;
332extern void unregister_ftrace_return(void);
333#endif
252 334
253#endif /* _LINUX_FTRACE_H */ 335#endif /* _LINUX_FTRACE_H */
diff --git a/include/linux/ftrace_irq.h b/include/linux/ftrace_irq.h
new file mode 100644
index 000000000000..0b4df55d7a74
--- /dev/null
+++ b/include/linux/ftrace_irq.h
@@ -0,0 +1,13 @@
1#ifndef _LINUX_FTRACE_IRQ_H
2#define _LINUX_FTRACE_IRQ_H
3
4
5#if defined(CONFIG_DYNAMIC_FTRACE) || defined(CONFIG_FUNCTION_RET_TRACER)
6extern void ftrace_nmi_enter(void);
7extern void ftrace_nmi_exit(void);
8#else
9static inline void ftrace_nmi_enter(void) { }
10static inline void ftrace_nmi_exit(void) { }
11#endif
12
13#endif /* _LINUX_FTRACE_IRQ_H */
diff --git a/include/linux/hardirq.h b/include/linux/hardirq.h
index 181006cc94a0..89a56d79e4c6 100644
--- a/include/linux/hardirq.h
+++ b/include/linux/hardirq.h
@@ -4,6 +4,7 @@
4#include <linux/preempt.h> 4#include <linux/preempt.h>
5#include <linux/smp_lock.h> 5#include <linux/smp_lock.h>
6#include <linux/lockdep.h> 6#include <linux/lockdep.h>
7#include <linux/ftrace_irq.h>
7#include <asm/hardirq.h> 8#include <asm/hardirq.h>
8#include <asm/system.h> 9#include <asm/system.h>
9 10
@@ -161,7 +162,17 @@ extern void irq_enter(void);
161 */ 162 */
162extern void irq_exit(void); 163extern void irq_exit(void);
163 164
164#define nmi_enter() do { lockdep_off(); __irq_enter(); } while (0) 165#define nmi_enter() \
165#define nmi_exit() do { __irq_exit(); lockdep_on(); } while (0) 166 do { \
167 ftrace_nmi_enter(); \
168 lockdep_off(); \
169 __irq_enter(); \
170 } while (0)
171#define nmi_exit() \
172 do { \
173 __irq_exit(); \
174 lockdep_on(); \
175 ftrace_nmi_exit(); \
176 } while (0)
166 177
167#endif /* LINUX_HARDIRQ_H */ 178#endif /* LINUX_HARDIRQ_H */
diff --git a/include/linux/marker.h b/include/linux/marker.h
index 889196c7fbb1..34c14bc957f5 100644
--- a/include/linux/marker.h
+++ b/include/linux/marker.h
@@ -12,6 +12,7 @@
12 * See the file COPYING for more details. 12 * See the file COPYING for more details.
13 */ 13 */
14 14
15#include <stdarg.h>
15#include <linux/types.h> 16#include <linux/types.h>
16 17
17struct module; 18struct module;
@@ -48,10 +49,28 @@ struct marker {
48 void (*call)(const struct marker *mdata, void *call_private, ...); 49 void (*call)(const struct marker *mdata, void *call_private, ...);
49 struct marker_probe_closure single; 50 struct marker_probe_closure single;
50 struct marker_probe_closure *multi; 51 struct marker_probe_closure *multi;
52 const char *tp_name; /* Optional tracepoint name */
53 void *tp_cb; /* Optional tracepoint callback */
51} __attribute__((aligned(8))); 54} __attribute__((aligned(8)));
52 55
53#ifdef CONFIG_MARKERS 56#ifdef CONFIG_MARKERS
54 57
58#define _DEFINE_MARKER(name, tp_name_str, tp_cb, format) \
59 static const char __mstrtab_##name[] \
60 __attribute__((section("__markers_strings"))) \
61 = #name "\0" format; \
62 static struct marker __mark_##name \
63 __attribute__((section("__markers"), aligned(8))) = \
64 { __mstrtab_##name, &__mstrtab_##name[sizeof(#name)], \
65 0, 0, marker_probe_cb, { __mark_empty_function, NULL},\
66 NULL, tp_name_str, tp_cb }
67
68#define DEFINE_MARKER(name, format) \
69 _DEFINE_MARKER(name, NULL, NULL, format)
70
71#define DEFINE_MARKER_TP(name, tp_name, tp_cb, format) \
72 _DEFINE_MARKER(name, #tp_name, tp_cb, format)
73
55/* 74/*
56 * Note : the empty asm volatile with read constraint is used here instead of a 75 * Note : the empty asm volatile with read constraint is used here instead of a
57 * "used" attribute to fix a gcc 4.1.x bug. 76 * "used" attribute to fix a gcc 4.1.x bug.
@@ -65,14 +84,7 @@ struct marker {
65 */ 84 */
66#define __trace_mark(generic, name, call_private, format, args...) \ 85#define __trace_mark(generic, name, call_private, format, args...) \
67 do { \ 86 do { \
68 static const char __mstrtab_##name[] \ 87 DEFINE_MARKER(name, format); \
69 __attribute__((section("__markers_strings"))) \
70 = #name "\0" format; \
71 static struct marker __mark_##name \
72 __attribute__((section("__markers"), aligned(8))) = \
73 { __mstrtab_##name, &__mstrtab_##name[sizeof(#name)], \
74 0, 0, marker_probe_cb, \
75 { __mark_empty_function, NULL}, NULL }; \
76 __mark_check_format(format, ## args); \ 88 __mark_check_format(format, ## args); \
77 if (unlikely(__mark_##name.state)) { \ 89 if (unlikely(__mark_##name.state)) { \
78 (*__mark_##name.call) \ 90 (*__mark_##name.call) \
@@ -80,14 +92,39 @@ struct marker {
80 } \ 92 } \
81 } while (0) 93 } while (0)
82 94
95#define __trace_mark_tp(name, call_private, tp_name, tp_cb, format, args...) \
96 do { \
97 void __check_tp_type(void) \
98 { \
99 register_trace_##tp_name(tp_cb); \
100 } \
101 DEFINE_MARKER_TP(name, tp_name, tp_cb, format); \
102 __mark_check_format(format, ## args); \
103 (*__mark_##name.call)(&__mark_##name, call_private, \
104 ## args); \
105 } while (0)
106
83extern void marker_update_probe_range(struct marker *begin, 107extern void marker_update_probe_range(struct marker *begin,
84 struct marker *end); 108 struct marker *end);
109
110#define GET_MARKER(name) (__mark_##name)
111
85#else /* !CONFIG_MARKERS */ 112#else /* !CONFIG_MARKERS */
113#define DEFINE_MARKER(name, tp_name, tp_cb, format)
86#define __trace_mark(generic, name, call_private, format, args...) \ 114#define __trace_mark(generic, name, call_private, format, args...) \
87 __mark_check_format(format, ## args) 115 __mark_check_format(format, ## args)
116#define __trace_mark_tp(name, call_private, tp_name, tp_cb, format, args...) \
117 do { \
118 void __check_tp_type(void) \
119 { \
120 register_trace_##tp_name(tp_cb); \
121 } \
122 __mark_check_format(format, ## args); \
123 } while (0)
88static inline void marker_update_probe_range(struct marker *begin, 124static inline void marker_update_probe_range(struct marker *begin,
89 struct marker *end) 125 struct marker *end)
90{ } 126{ }
127#define GET_MARKER(name)
91#endif /* CONFIG_MARKERS */ 128#endif /* CONFIG_MARKERS */
92 129
93/** 130/**
@@ -117,6 +154,20 @@ static inline void marker_update_probe_range(struct marker *begin,
117 __trace_mark(1, name, NULL, format, ## args) 154 __trace_mark(1, name, NULL, format, ## args)
118 155
119/** 156/**
157 * trace_mark_tp - Marker in a tracepoint callback
158 * @name: marker name, not quoted.
159 * @tp_name: tracepoint name, not quoted.
160 * @tp_cb: tracepoint callback. Should have an associated global symbol so it
161 * is not optimized away by the compiler (should not be static).
162 * @format: format string
163 * @args...: variable argument list
164 *
165 * Places a marker in a tracepoint callback.
166 */
167#define trace_mark_tp(name, tp_name, tp_cb, format, args...) \
168 __trace_mark_tp(name, NULL, tp_name, tp_cb, format, ## args)
169
170/**
120 * MARK_NOARGS - Format string for a marker with no argument. 171 * MARK_NOARGS - Format string for a marker with no argument.
121 */ 172 */
122#define MARK_NOARGS " " 173#define MARK_NOARGS " "
@@ -136,8 +187,6 @@ extern marker_probe_func __mark_empty_function;
136 187
137extern void marker_probe_cb(const struct marker *mdata, 188extern void marker_probe_cb(const struct marker *mdata,
138 void *call_private, ...); 189 void *call_private, ...);
139extern void marker_probe_cb_noarg(const struct marker *mdata,
140 void *call_private, ...);
141 190
142/* 191/*
143 * Connect a probe to a marker. 192 * Connect a probe to a marker.
diff --git a/include/linux/net.h b/include/linux/net.h
index 6dc14a240042..4515efae4c39 100644
--- a/include/linux/net.h
+++ b/include/linux/net.h
@@ -40,7 +40,7 @@
40#define SYS_GETSOCKOPT 15 /* sys_getsockopt(2) */ 40#define SYS_GETSOCKOPT 15 /* sys_getsockopt(2) */
41#define SYS_SENDMSG 16 /* sys_sendmsg(2) */ 41#define SYS_SENDMSG 16 /* sys_sendmsg(2) */
42#define SYS_RECVMSG 17 /* sys_recvmsg(2) */ 42#define SYS_RECVMSG 17 /* sys_recvmsg(2) */
43#define SYS_PACCEPT 18 /* sys_paccept(2) */ 43#define SYS_ACCEPT4 18 /* sys_accept4(2) */
44 44
45typedef enum { 45typedef enum {
46 SS_FREE = 0, /* not allocated */ 46 SS_FREE = 0, /* not allocated */
@@ -100,7 +100,7 @@ enum sock_type {
100 * remaining bits are used as flags. */ 100 * remaining bits are used as flags. */
101#define SOCK_TYPE_MASK 0xf 101#define SOCK_TYPE_MASK 0xf
102 102
103/* Flags for socket, socketpair, paccept */ 103/* Flags for socket, socketpair, accept4 */
104#define SOCK_CLOEXEC O_CLOEXEC 104#define SOCK_CLOEXEC O_CLOEXEC
105#ifndef SOCK_NONBLOCK 105#ifndef SOCK_NONBLOCK
106#define SOCK_NONBLOCK O_NONBLOCK 106#define SOCK_NONBLOCK O_NONBLOCK
@@ -223,8 +223,6 @@ extern int sock_map_fd(struct socket *sock, int flags);
223extern struct socket *sockfd_lookup(int fd, int *err); 223extern struct socket *sockfd_lookup(int fd, int *err);
224#define sockfd_put(sock) fput(sock->file) 224#define sockfd_put(sock) fput(sock->file)
225extern int net_ratelimit(void); 225extern int net_ratelimit(void);
226extern long do_accept(int fd, struct sockaddr __user *upeer_sockaddr,
227 int __user *upeer_addrlen, int flags);
228 226
229#define net_random() random32() 227#define net_random() random32()
230#define net_srandom(seed) srandom32((__force u32)seed) 228#define net_srandom(seed) srandom32((__force u32)seed)
diff --git a/include/linux/rcupdate.h b/include/linux/rcupdate.h
index 86f1f5e43e33..895dc9c1088c 100644
--- a/include/linux/rcupdate.h
+++ b/include/linux/rcupdate.h
@@ -142,6 +142,7 @@ struct rcu_head {
142 * on the write-side to insure proper synchronization. 142 * on the write-side to insure proper synchronization.
143 */ 143 */
144#define rcu_read_lock_sched() preempt_disable() 144#define rcu_read_lock_sched() preempt_disable()
145#define rcu_read_lock_sched_notrace() preempt_disable_notrace()
145 146
146/* 147/*
147 * rcu_read_unlock_sched - marks the end of a RCU-classic critical section 148 * rcu_read_unlock_sched - marks the end of a RCU-classic critical section
@@ -149,6 +150,7 @@ struct rcu_head {
149 * See rcu_read_lock_sched for more information. 150 * See rcu_read_lock_sched for more information.
150 */ 151 */
151#define rcu_read_unlock_sched() preempt_enable() 152#define rcu_read_unlock_sched() preempt_enable()
153#define rcu_read_unlock_sched_notrace() preempt_enable_notrace()
152 154
153 155
154 156
diff --git a/include/linux/sched.h b/include/linux/sched.h
index 644ffbda17ca..c8e0db464206 100644
--- a/include/linux/sched.h
+++ b/include/linux/sched.h
@@ -2006,6 +2006,18 @@ static inline void setup_thread_stack(struct task_struct *p, struct task_struct
2006{ 2006{
2007 *task_thread_info(p) = *task_thread_info(org); 2007 *task_thread_info(p) = *task_thread_info(org);
2008 task_thread_info(p)->task = p; 2008 task_thread_info(p)->task = p;
2009
2010#ifdef CONFIG_FUNCTION_RET_TRACER
2011 /*
2012 * When fork() creates a child process, this function is called.
2013 * But the child task may not inherit the return adresses traced
2014 * by the return function tracer because it will directly execute
2015 * in userspace and will not return to kernel functions its parent
2016 * used.
2017 */
2018 task_thread_info(p)->curr_ret_stack = -1;
2019 atomic_set(&task_thread_info(p)->trace_overrun, 0);
2020#endif
2009} 2021}
2010 2022
2011static inline unsigned long *end_of_stack(struct task_struct *p) 2023static inline unsigned long *end_of_stack(struct task_struct *p)
diff --git a/include/linux/syscalls.h b/include/linux/syscalls.h
index d6ff145919ca..04fb47bfb920 100644
--- a/include/linux/syscalls.h
+++ b/include/linux/syscalls.h
@@ -410,8 +410,7 @@ asmlinkage long sys_getsockopt(int fd, int level, int optname,
410asmlinkage long sys_bind(int, struct sockaddr __user *, int); 410asmlinkage long sys_bind(int, struct sockaddr __user *, int);
411asmlinkage long sys_connect(int, struct sockaddr __user *, int); 411asmlinkage long sys_connect(int, struct sockaddr __user *, int);
412asmlinkage long sys_accept(int, struct sockaddr __user *, int __user *); 412asmlinkage long sys_accept(int, struct sockaddr __user *, int __user *);
413asmlinkage long sys_paccept(int, struct sockaddr __user *, int __user *, 413asmlinkage long sys_accept4(int, struct sockaddr __user *, int __user *, int);
414 const __user sigset_t *, size_t, int);
415asmlinkage long sys_getsockname(int, struct sockaddr __user *, int __user *); 414asmlinkage long sys_getsockname(int, struct sockaddr __user *, int __user *);
416asmlinkage long sys_getpeername(int, struct sockaddr __user *, int __user *); 415asmlinkage long sys_getpeername(int, struct sockaddr __user *, int __user *);
417asmlinkage long sys_send(int, void __user *, size_t, unsigned); 416asmlinkage long sys_send(int, void __user *, size_t, unsigned);
diff --git a/include/linux/tracepoint.h b/include/linux/tracepoint.h
index c5bb39c7a770..757005458366 100644
--- a/include/linux/tracepoint.h
+++ b/include/linux/tracepoint.h
@@ -24,8 +24,12 @@ struct tracepoint {
24 const char *name; /* Tracepoint name */ 24 const char *name; /* Tracepoint name */
25 int state; /* State. */ 25 int state; /* State. */
26 void **funcs; 26 void **funcs;
27} __attribute__((aligned(8))); 27} __attribute__((aligned(32))); /*
28 28 * Aligned on 32 bytes because it is
29 * globally visible and gcc happily
30 * align these on the structure size.
31 * Keep in sync with vmlinux.lds.h.
32 */
29 33
30#define TPPROTO(args...) args 34#define TPPROTO(args...) args
31#define TPARGS(args...) args 35#define TPARGS(args...) args
@@ -40,14 +44,14 @@ struct tracepoint {
40 do { \ 44 do { \
41 void **it_func; \ 45 void **it_func; \
42 \ 46 \
43 rcu_read_lock_sched(); \ 47 rcu_read_lock_sched_notrace(); \
44 it_func = rcu_dereference((tp)->funcs); \ 48 it_func = rcu_dereference((tp)->funcs); \
45 if (it_func) { \ 49 if (it_func) { \
46 do { \ 50 do { \
47 ((void(*)(proto))(*it_func))(args); \ 51 ((void(*)(proto))(*it_func))(args); \
48 } while (*(++it_func)); \ 52 } while (*(++it_func)); \
49 } \ 53 } \
50 rcu_read_unlock_sched(); \ 54 rcu_read_unlock_sched_notrace(); \
51 } while (0) 55 } while (0)
52 56
53/* 57/*
@@ -55,35 +59,40 @@ struct tracepoint {
55 * not add unwanted padding between the beginning of the section and the 59 * not add unwanted padding between the beginning of the section and the
56 * structure. Force alignment to the same alignment as the section start. 60 * structure. Force alignment to the same alignment as the section start.
57 */ 61 */
58#define DEFINE_TRACE(name, proto, args) \ 62#define DECLARE_TRACE(name, proto, args) \
63 extern struct tracepoint __tracepoint_##name; \
59 static inline void trace_##name(proto) \ 64 static inline void trace_##name(proto) \
60 { \ 65 { \
61 static const char __tpstrtab_##name[] \
62 __attribute__((section("__tracepoints_strings"))) \
63 = #name ":" #proto; \
64 static struct tracepoint __tracepoint_##name \
65 __attribute__((section("__tracepoints"), aligned(8))) = \
66 { __tpstrtab_##name, 0, NULL }; \
67 if (unlikely(__tracepoint_##name.state)) \ 66 if (unlikely(__tracepoint_##name.state)) \
68 __DO_TRACE(&__tracepoint_##name, \ 67 __DO_TRACE(&__tracepoint_##name, \
69 TPPROTO(proto), TPARGS(args)); \ 68 TPPROTO(proto), TPARGS(args)); \
70 } \ 69 } \
71 static inline int register_trace_##name(void (*probe)(proto)) \ 70 static inline int register_trace_##name(void (*probe)(proto)) \
72 { \ 71 { \
73 return tracepoint_probe_register(#name ":" #proto, \ 72 return tracepoint_probe_register(#name, (void *)probe); \
74 (void *)probe); \
75 } \ 73 } \
76 static inline void unregister_trace_##name(void (*probe)(proto))\ 74 static inline int unregister_trace_##name(void (*probe)(proto)) \
77 { \ 75 { \
78 tracepoint_probe_unregister(#name ":" #proto, \ 76 return tracepoint_probe_unregister(#name, (void *)probe);\
79 (void *)probe); \
80 } 77 }
81 78
79#define DEFINE_TRACE(name) \
80 static const char __tpstrtab_##name[] \
81 __attribute__((section("__tracepoints_strings"))) = #name; \
82 struct tracepoint __tracepoint_##name \
83 __attribute__((section("__tracepoints"), aligned(32))) = \
84 { __tpstrtab_##name, 0, NULL }
85
86#define EXPORT_TRACEPOINT_SYMBOL_GPL(name) \
87 EXPORT_SYMBOL_GPL(__tracepoint_##name)
88#define EXPORT_TRACEPOINT_SYMBOL(name) \
89 EXPORT_SYMBOL(__tracepoint_##name)
90
82extern void tracepoint_update_probe_range(struct tracepoint *begin, 91extern void tracepoint_update_probe_range(struct tracepoint *begin,
83 struct tracepoint *end); 92 struct tracepoint *end);
84 93
85#else /* !CONFIG_TRACEPOINTS */ 94#else /* !CONFIG_TRACEPOINTS */
86#define DEFINE_TRACE(name, proto, args) \ 95#define DECLARE_TRACE(name, proto, args) \
87 static inline void _do_trace_##name(struct tracepoint *tp, proto) \ 96 static inline void _do_trace_##name(struct tracepoint *tp, proto) \
88 { } \ 97 { } \
89 static inline void trace_##name(proto) \ 98 static inline void trace_##name(proto) \
@@ -92,8 +101,14 @@ extern void tracepoint_update_probe_range(struct tracepoint *begin,
92 { \ 101 { \
93 return -ENOSYS; \ 102 return -ENOSYS; \
94 } \ 103 } \
95 static inline void unregister_trace_##name(void (*probe)(proto))\ 104 static inline int unregister_trace_##name(void (*probe)(proto)) \
96 { } 105 { \
106 return -ENOSYS; \
107 }
108
109#define DEFINE_TRACE(name)
110#define EXPORT_TRACEPOINT_SYMBOL_GPL(name)
111#define EXPORT_TRACEPOINT_SYMBOL(name)
97 112
98static inline void tracepoint_update_probe_range(struct tracepoint *begin, 113static inline void tracepoint_update_probe_range(struct tracepoint *begin,
99 struct tracepoint *end) 114 struct tracepoint *end)
@@ -112,6 +127,10 @@ extern int tracepoint_probe_register(const char *name, void *probe);
112 */ 127 */
113extern int tracepoint_probe_unregister(const char *name, void *probe); 128extern int tracepoint_probe_unregister(const char *name, void *probe);
114 129
130extern int tracepoint_probe_register_noupdate(const char *name, void *probe);
131extern int tracepoint_probe_unregister_noupdate(const char *name, void *probe);
132extern void tracepoint_probe_update_all(void);
133
115struct tracepoint_iter { 134struct tracepoint_iter {
116 struct module *module; 135 struct module *module;
117 struct tracepoint *tracepoint; 136 struct tracepoint *tracepoint;
diff --git a/include/net/mac80211.h b/include/net/mac80211.h
index 8856e2d60e9f..73d81bc6aa75 100644
--- a/include/net/mac80211.h
+++ b/include/net/mac80211.h
@@ -74,14 +74,6 @@
74 */ 74 */
75 75
76/** 76/**
77 * enum ieee80211_notification_type - Low level driver notification
78 * @IEEE80211_NOTIFY_RE_ASSOC: start the re-association sequence
79 */
80enum ieee80211_notification_types {
81 IEEE80211_NOTIFY_RE_ASSOC,
82};
83
84/**
85 * struct ieee80211_ht_bss_info - describing BSS's HT characteristics 77 * struct ieee80211_ht_bss_info - describing BSS's HT characteristics
86 * 78 *
87 * This structure describes most essential parameters needed 79 * This structure describes most essential parameters needed
@@ -1798,18 +1790,6 @@ void ieee80211_stop_tx_ba_cb_irqsafe(struct ieee80211_hw *hw, const u8 *ra,
1798 u16 tid); 1790 u16 tid);
1799 1791
1800/** 1792/**
1801 * ieee80211_notify_mac - low level driver notification
1802 * @hw: pointer as obtained from ieee80211_alloc_hw().
1803 * @notif_type: enum ieee80211_notification_types
1804 *
1805 * This function must be called by low level driver to inform mac80211 of
1806 * low level driver status change or force mac80211 to re-assoc for low
1807 * level driver internal error that require re-assoc.
1808 */
1809void ieee80211_notify_mac(struct ieee80211_hw *hw,
1810 enum ieee80211_notification_types notif_type);
1811
1812/**
1813 * ieee80211_find_sta - find a station 1793 * ieee80211_find_sta - find a station
1814 * 1794 *
1815 * @hw: pointer as obtained from ieee80211_alloc_hw() 1795 * @hw: pointer as obtained from ieee80211_alloc_hw()
diff --git a/include/trace/boot.h b/include/trace/boot.h
new file mode 100644
index 000000000000..6b54537eab02
--- /dev/null
+++ b/include/trace/boot.h
@@ -0,0 +1,56 @@
1#ifndef _LINUX_TRACE_BOOT_H
2#define _LINUX_TRACE_BOOT_H
3
4/*
5 * Structure which defines the trace of an initcall
6 * while it is called.
7 * You don't have to fill the func field since it is
8 * only used internally by the tracer.
9 */
10struct boot_trace_call {
11 pid_t caller;
12 char func[KSYM_NAME_LEN];
13};
14
15/*
16 * Structure which defines the trace of an initcall
17 * while it returns.
18 */
19struct boot_trace_ret {
20 char func[KSYM_NAME_LEN];
21 int result;
22 unsigned long long duration; /* nsecs */
23};
24
25#ifdef CONFIG_BOOT_TRACER
26/* Append the traces on the ring-buffer */
27extern void trace_boot_call(struct boot_trace_call *bt, initcall_t fn);
28extern void trace_boot_ret(struct boot_trace_ret *bt, initcall_t fn);
29
30/* Tells the tracer that smp_pre_initcall is finished.
31 * So we can start the tracing
32 */
33extern void start_boot_trace(void);
34
35/* Resume the tracing of other necessary events
36 * such as sched switches
37 */
38extern void enable_boot_trace(void);
39
40/* Suspend this tracing. Actually, only sched_switches tracing have
41 * to be suspended. Initcalls doesn't need it.)
42 */
43extern void disable_boot_trace(void);
44#else
45static inline
46void trace_boot_call(struct boot_trace_call *bt, initcall_t fn) { }
47
48static inline
49void trace_boot_ret(struct boot_trace_ret *bt, initcall_t fn) { }
50
51static inline void start_boot_trace(void) { }
52static inline void enable_boot_trace(void) { }
53static inline void disable_boot_trace(void) { }
54#endif /* CONFIG_BOOT_TRACER */
55
56#endif /* __LINUX_TRACE_BOOT_H */
diff --git a/include/trace/sched.h b/include/trace/sched.h
index ad47369d01b5..9b2854abf7e2 100644
--- a/include/trace/sched.h
+++ b/include/trace/sched.h
@@ -4,52 +4,52 @@
4#include <linux/sched.h> 4#include <linux/sched.h>
5#include <linux/tracepoint.h> 5#include <linux/tracepoint.h>
6 6
7DEFINE_TRACE(sched_kthread_stop, 7DECLARE_TRACE(sched_kthread_stop,
8 TPPROTO(struct task_struct *t), 8 TPPROTO(struct task_struct *t),
9 TPARGS(t)); 9 TPARGS(t));
10 10
11DEFINE_TRACE(sched_kthread_stop_ret, 11DECLARE_TRACE(sched_kthread_stop_ret,
12 TPPROTO(int ret), 12 TPPROTO(int ret),
13 TPARGS(ret)); 13 TPARGS(ret));
14 14
15DEFINE_TRACE(sched_wait_task, 15DECLARE_TRACE(sched_wait_task,
16 TPPROTO(struct rq *rq, struct task_struct *p), 16 TPPROTO(struct rq *rq, struct task_struct *p),
17 TPARGS(rq, p)); 17 TPARGS(rq, p));
18 18
19DEFINE_TRACE(sched_wakeup, 19DECLARE_TRACE(sched_wakeup,
20 TPPROTO(struct rq *rq, struct task_struct *p), 20 TPPROTO(struct rq *rq, struct task_struct *p),
21 TPARGS(rq, p)); 21 TPARGS(rq, p));
22 22
23DEFINE_TRACE(sched_wakeup_new, 23DECLARE_TRACE(sched_wakeup_new,
24 TPPROTO(struct rq *rq, struct task_struct *p), 24 TPPROTO(struct rq *rq, struct task_struct *p),
25 TPARGS(rq, p)); 25 TPARGS(rq, p));
26 26
27DEFINE_TRACE(sched_switch, 27DECLARE_TRACE(sched_switch,
28 TPPROTO(struct rq *rq, struct task_struct *prev, 28 TPPROTO(struct rq *rq, struct task_struct *prev,
29 struct task_struct *next), 29 struct task_struct *next),
30 TPARGS(rq, prev, next)); 30 TPARGS(rq, prev, next));
31 31
32DEFINE_TRACE(sched_migrate_task, 32DECLARE_TRACE(sched_migrate_task,
33 TPPROTO(struct rq *rq, struct task_struct *p, int dest_cpu), 33 TPPROTO(struct rq *rq, struct task_struct *p, int dest_cpu),
34 TPARGS(rq, p, dest_cpu)); 34 TPARGS(rq, p, dest_cpu));
35 35
36DEFINE_TRACE(sched_process_free, 36DECLARE_TRACE(sched_process_free,
37 TPPROTO(struct task_struct *p), 37 TPPROTO(struct task_struct *p),
38 TPARGS(p)); 38 TPARGS(p));
39 39
40DEFINE_TRACE(sched_process_exit, 40DECLARE_TRACE(sched_process_exit,
41 TPPROTO(struct task_struct *p), 41 TPPROTO(struct task_struct *p),
42 TPARGS(p)); 42 TPARGS(p));
43 43
44DEFINE_TRACE(sched_process_wait, 44DECLARE_TRACE(sched_process_wait,
45 TPPROTO(struct pid *pid), 45 TPPROTO(struct pid *pid),
46 TPARGS(pid)); 46 TPARGS(pid));
47 47
48DEFINE_TRACE(sched_process_fork, 48DECLARE_TRACE(sched_process_fork,
49 TPPROTO(struct task_struct *parent, struct task_struct *child), 49 TPPROTO(struct task_struct *parent, struct task_struct *child),
50 TPARGS(parent, child)); 50 TPARGS(parent, child));
51 51
52DEFINE_TRACE(sched_signal_send, 52DECLARE_TRACE(sched_signal_send,
53 TPPROTO(int sig, struct task_struct *p), 53 TPPROTO(int sig, struct task_struct *p),
54 TPARGS(sig, p)); 54 TPARGS(sig, p));
55 55
diff --git a/init/Kconfig b/init/Kconfig
index f763762d544a..f291f086caa1 100644
--- a/init/Kconfig
+++ b/init/Kconfig
@@ -808,6 +808,7 @@ config TRACEPOINTS
808 808
809config MARKERS 809config MARKERS
810 bool "Activate markers" 810 bool "Activate markers"
811 depends on TRACEPOINTS
811 help 812 help
812 Place an empty function call at each marker site. Can be 813 Place an empty function call at each marker site. Can be
813 dynamically changed for a probe function. 814 dynamically changed for a probe function.
diff --git a/init/main.c b/init/main.c
index 7e117a231af1..e810196bf2f2 100644
--- a/init/main.c
+++ b/init/main.c
@@ -63,6 +63,7 @@
63#include <linux/signal.h> 63#include <linux/signal.h>
64#include <linux/idr.h> 64#include <linux/idr.h>
65#include <linux/ftrace.h> 65#include <linux/ftrace.h>
66#include <trace/boot.h>
66 67
67#include <asm/io.h> 68#include <asm/io.h>
68#include <asm/bugs.h> 69#include <asm/bugs.h>
@@ -703,31 +704,35 @@ core_param(initcall_debug, initcall_debug, bool, 0644);
703int do_one_initcall(initcall_t fn) 704int do_one_initcall(initcall_t fn)
704{ 705{
705 int count = preempt_count(); 706 int count = preempt_count();
706 ktime_t delta; 707 ktime_t calltime, delta, rettime;
707 char msgbuf[64]; 708 char msgbuf[64];
708 struct boot_trace it; 709 struct boot_trace_call call;
710 struct boot_trace_ret ret;
709 711
710 if (initcall_debug) { 712 if (initcall_debug) {
711 it.caller = task_pid_nr(current); 713 call.caller = task_pid_nr(current);
712 printk("calling %pF @ %i\n", fn, it.caller); 714 printk("calling %pF @ %i\n", fn, call.caller);
713 it.calltime = ktime_get(); 715 calltime = ktime_get();
716 trace_boot_call(&call, fn);
717 enable_boot_trace();
714 } 718 }
715 719
716 it.result = fn(); 720 ret.result = fn();
717 721
718 if (initcall_debug) { 722 if (initcall_debug) {
719 it.rettime = ktime_get(); 723 disable_boot_trace();
720 delta = ktime_sub(it.rettime, it.calltime); 724 rettime = ktime_get();
721 it.duration = (unsigned long long) delta.tv64 >> 10; 725 delta = ktime_sub(rettime, calltime);
726 ret.duration = (unsigned long long) delta.tv64 >> 10;
727 trace_boot_ret(&ret, fn);
722 printk("initcall %pF returned %d after %Ld usecs\n", fn, 728 printk("initcall %pF returned %d after %Ld usecs\n", fn,
723 it.result, it.duration); 729 ret.result, ret.duration);
724 trace_boot(&it, fn);
725 } 730 }
726 731
727 msgbuf[0] = 0; 732 msgbuf[0] = 0;
728 733
729 if (it.result && it.result != -ENODEV && initcall_debug) 734 if (ret.result && ret.result != -ENODEV && initcall_debug)
730 sprintf(msgbuf, "error code %d ", it.result); 735 sprintf(msgbuf, "error code %d ", ret.result);
731 736
732 if (preempt_count() != count) { 737 if (preempt_count() != count) {
733 strlcat(msgbuf, "preemption imbalance ", sizeof(msgbuf)); 738 strlcat(msgbuf, "preemption imbalance ", sizeof(msgbuf));
@@ -741,7 +746,7 @@ int do_one_initcall(initcall_t fn)
741 printk("initcall %pF returned with %s\n", fn, msgbuf); 746 printk("initcall %pF returned with %s\n", fn, msgbuf);
742 } 747 }
743 748
744 return it.result; 749 return ret.result;
745} 750}
746 751
747 752
@@ -882,7 +887,7 @@ static int __init kernel_init(void * unused)
882 * we're essentially up and running. Get rid of the 887 * we're essentially up and running. Get rid of the
883 * initmem segments and start the user-mode stuff.. 888 * initmem segments and start the user-mode stuff..
884 */ 889 */
885 stop_boot_trace(); 890
886 init_post(); 891 init_post();
887 return 0; 892 return 0;
888} 893}
diff --git a/ipc/util.c b/ipc/util.c
index 49b3ea615dc5..361fd1c96fcf 100644
--- a/ipc/util.c
+++ b/ipc/util.c
@@ -266,9 +266,17 @@ int ipc_addid(struct ipc_ids* ids, struct kern_ipc_perm* new, int size)
266 if (ids->in_use >= size) 266 if (ids->in_use >= size)
267 return -ENOSPC; 267 return -ENOSPC;
268 268
269 spin_lock_init(&new->lock);
270 new->deleted = 0;
271 rcu_read_lock();
272 spin_lock(&new->lock);
273
269 err = idr_get_new(&ids->ipcs_idr, new, &id); 274 err = idr_get_new(&ids->ipcs_idr, new, &id);
270 if (err) 275 if (err) {
276 spin_unlock(&new->lock);
277 rcu_read_unlock();
271 return err; 278 return err;
279 }
272 280
273 ids->in_use++; 281 ids->in_use++;
274 282
@@ -280,10 +288,6 @@ int ipc_addid(struct ipc_ids* ids, struct kern_ipc_perm* new, int size)
280 ids->seq = 0; 288 ids->seq = 0;
281 289
282 new->id = ipc_buildid(id, new->seq); 290 new->id = ipc_buildid(id, new->seq);
283 spin_lock_init(&new->lock);
284 new->deleted = 0;
285 rcu_read_lock();
286 spin_lock(&new->lock);
287 return id; 291 return id;
288} 292}
289 293
diff --git a/kernel/Makefile b/kernel/Makefile
index 19fad003b19d..03a45e7e87b7 100644
--- a/kernel/Makefile
+++ b/kernel/Makefile
@@ -21,6 +21,10 @@ CFLAGS_REMOVE_cgroup-debug.o = -pg
21CFLAGS_REMOVE_sched_clock.o = -pg 21CFLAGS_REMOVE_sched_clock.o = -pg
22CFLAGS_REMOVE_sched.o = -pg 22CFLAGS_REMOVE_sched.o = -pg
23endif 23endif
24ifdef CONFIG_FUNCTION_RET_TRACER
25CFLAGS_REMOVE_extable.o = -pg # For __kernel_text_address()
26CFLAGS_REMOVE_module.o = -pg # For __module_text_address()
27endif
24 28
25obj-$(CONFIG_FREEZER) += freezer.o 29obj-$(CONFIG_FREEZER) += freezer.o
26obj-$(CONFIG_PROFILING) += profile.o 30obj-$(CONFIG_PROFILING) += profile.o
diff --git a/kernel/cgroup.c b/kernel/cgroup.c
index 358e77564e6f..fe00b3b983a8 100644
--- a/kernel/cgroup.c
+++ b/kernel/cgroup.c
@@ -2039,10 +2039,13 @@ int cgroupstats_build(struct cgroupstats *stats, struct dentry *dentry)
2039 struct cgroup *cgrp; 2039 struct cgroup *cgrp;
2040 struct cgroup_iter it; 2040 struct cgroup_iter it;
2041 struct task_struct *tsk; 2041 struct task_struct *tsk;
2042
2042 /* 2043 /*
2043 * Validate dentry by checking the superblock operations 2044 * Validate dentry by checking the superblock operations,
2045 * and make sure it's a directory.
2044 */ 2046 */
2045 if (dentry->d_sb->s_op != &cgroup_ops) 2047 if (dentry->d_sb->s_op != &cgroup_ops ||
2048 !S_ISDIR(dentry->d_inode->i_mode))
2046 goto err; 2049 goto err;
2047 2050
2048 ret = 0; 2051 ret = 0;
@@ -2472,10 +2475,7 @@ static int cgroup_rmdir(struct inode *unused_dir, struct dentry *dentry)
2472 mutex_unlock(&cgroup_mutex); 2475 mutex_unlock(&cgroup_mutex);
2473 return -EBUSY; 2476 return -EBUSY;
2474 } 2477 }
2475 2478 mutex_unlock(&cgroup_mutex);
2476 parent = cgrp->parent;
2477 root = cgrp->root;
2478 sb = root->sb;
2479 2479
2480 /* 2480 /*
2481 * Call pre_destroy handlers of subsys. Notify subsystems 2481 * Call pre_destroy handlers of subsys. Notify subsystems
@@ -2483,7 +2483,14 @@ static int cgroup_rmdir(struct inode *unused_dir, struct dentry *dentry)
2483 */ 2483 */
2484 cgroup_call_pre_destroy(cgrp); 2484 cgroup_call_pre_destroy(cgrp);
2485 2485
2486 if (cgroup_has_css_refs(cgrp)) { 2486 mutex_lock(&cgroup_mutex);
2487 parent = cgrp->parent;
2488 root = cgrp->root;
2489 sb = root->sb;
2490
2491 if (atomic_read(&cgrp->count)
2492 || !list_empty(&cgrp->children)
2493 || cgroup_has_css_refs(cgrp)) {
2487 mutex_unlock(&cgroup_mutex); 2494 mutex_unlock(&cgroup_mutex);
2488 return -EBUSY; 2495 return -EBUSY;
2489 } 2496 }
diff --git a/kernel/cpuset.c b/kernel/cpuset.c
index 81fc6791a296..da7ff6137f37 100644
--- a/kernel/cpuset.c
+++ b/kernel/cpuset.c
@@ -36,6 +36,7 @@
36#include <linux/list.h> 36#include <linux/list.h>
37#include <linux/mempolicy.h> 37#include <linux/mempolicy.h>
38#include <linux/mm.h> 38#include <linux/mm.h>
39#include <linux/memory.h>
39#include <linux/module.h> 40#include <linux/module.h>
40#include <linux/mount.h> 41#include <linux/mount.h>
41#include <linux/namei.h> 42#include <linux/namei.h>
@@ -2015,12 +2016,23 @@ static int cpuset_track_online_cpus(struct notifier_block *unused_nb,
2015 * Call this routine anytime after node_states[N_HIGH_MEMORY] changes. 2016 * Call this routine anytime after node_states[N_HIGH_MEMORY] changes.
2016 * See also the previous routine cpuset_track_online_cpus(). 2017 * See also the previous routine cpuset_track_online_cpus().
2017 */ 2018 */
2018void cpuset_track_online_nodes(void) 2019static int cpuset_track_online_nodes(struct notifier_block *self,
2020 unsigned long action, void *arg)
2019{ 2021{
2020 cgroup_lock(); 2022 cgroup_lock();
2021 top_cpuset.mems_allowed = node_states[N_HIGH_MEMORY]; 2023 switch (action) {
2022 scan_for_empty_cpusets(&top_cpuset); 2024 case MEM_ONLINE:
2025 top_cpuset.mems_allowed = node_states[N_HIGH_MEMORY];
2026 break;
2027 case MEM_OFFLINE:
2028 top_cpuset.mems_allowed = node_states[N_HIGH_MEMORY];
2029 scan_for_empty_cpusets(&top_cpuset);
2030 break;
2031 default:
2032 break;
2033 }
2023 cgroup_unlock(); 2034 cgroup_unlock();
2035 return NOTIFY_OK;
2024} 2036}
2025#endif 2037#endif
2026 2038
@@ -2036,6 +2048,7 @@ void __init cpuset_init_smp(void)
2036 top_cpuset.mems_allowed = node_states[N_HIGH_MEMORY]; 2048 top_cpuset.mems_allowed = node_states[N_HIGH_MEMORY];
2037 2049
2038 hotcpu_notifier(cpuset_track_online_cpus, 0); 2050 hotcpu_notifier(cpuset_track_online_cpus, 0);
2051 hotplug_memory_notifier(cpuset_track_online_nodes, 10);
2039} 2052}
2040 2053
2041/** 2054/**
diff --git a/kernel/exit.c b/kernel/exit.c
index 2d8be7ebb0f7..35c8ec2ba03a 100644
--- a/kernel/exit.c
+++ b/kernel/exit.c
@@ -53,6 +53,10 @@
53#include <asm/pgtable.h> 53#include <asm/pgtable.h>
54#include <asm/mmu_context.h> 54#include <asm/mmu_context.h>
55 55
56DEFINE_TRACE(sched_process_free);
57DEFINE_TRACE(sched_process_exit);
58DEFINE_TRACE(sched_process_wait);
59
56static void exit_mm(struct task_struct * tsk); 60static void exit_mm(struct task_struct * tsk);
57 61
58static inline int task_detached(struct task_struct *p) 62static inline int task_detached(struct task_struct *p)
diff --git a/kernel/fork.c b/kernel/fork.c
index 2a372a0e206f..ac62f43ee430 100644
--- a/kernel/fork.c
+++ b/kernel/fork.c
@@ -80,6 +80,8 @@ DEFINE_PER_CPU(unsigned long, process_counts) = 0;
80 80
81__cacheline_aligned DEFINE_RWLOCK(tasklist_lock); /* outer */ 81__cacheline_aligned DEFINE_RWLOCK(tasklist_lock); /* outer */
82 82
83DEFINE_TRACE(sched_process_fork);
84
83int nr_processes(void) 85int nr_processes(void)
84{ 86{
85 int cpu; 87 int cpu;
diff --git a/kernel/kallsyms.c b/kernel/kallsyms.c
index 5072cf1685a2..7b8b0f21a5b1 100644
--- a/kernel/kallsyms.c
+++ b/kernel/kallsyms.c
@@ -304,17 +304,24 @@ int sprint_symbol(char *buffer, unsigned long address)
304 char *modname; 304 char *modname;
305 const char *name; 305 const char *name;
306 unsigned long offset, size; 306 unsigned long offset, size;
307 char namebuf[KSYM_NAME_LEN]; 307 int len;
308 308
309 name = kallsyms_lookup(address, &size, &offset, &modname, namebuf); 309 name = kallsyms_lookup(address, &size, &offset, &modname, buffer);
310 if (!name) 310 if (!name)
311 return sprintf(buffer, "0x%lx", address); 311 return sprintf(buffer, "0x%lx", address);
312 312
313 if (name != buffer)
314 strcpy(buffer, name);
315 len = strlen(buffer);
316 buffer += len;
317
313 if (modname) 318 if (modname)
314 return sprintf(buffer, "%s+%#lx/%#lx [%s]", name, offset, 319 len += sprintf(buffer, "+%#lx/%#lx [%s]",
315 size, modname); 320 offset, size, modname);
316 else 321 else
317 return sprintf(buffer, "%s+%#lx/%#lx", name, offset, size); 322 len += sprintf(buffer, "+%#lx/%#lx", offset, size);
323
324 return len;
318} 325}
319 326
320/* Look up a kernel symbol and print it to the kernel messages. */ 327/* Look up a kernel symbol and print it to the kernel messages. */
diff --git a/kernel/kthread.c b/kernel/kthread.c
index 8e7a7ce3ed0a..4fbc456f393d 100644
--- a/kernel/kthread.c
+++ b/kernel/kthread.c
@@ -21,6 +21,9 @@ static DEFINE_SPINLOCK(kthread_create_lock);
21static LIST_HEAD(kthread_create_list); 21static LIST_HEAD(kthread_create_list);
22struct task_struct *kthreadd_task; 22struct task_struct *kthreadd_task;
23 23
24DEFINE_TRACE(sched_kthread_stop);
25DEFINE_TRACE(sched_kthread_stop_ret);
26
24struct kthread_create_info 27struct kthread_create_info
25{ 28{
26 /* Information passed to kthread() from kthreadd. */ 29 /* Information passed to kthread() from kthreadd. */
diff --git a/kernel/marker.c b/kernel/marker.c
index e9c6b2bc9400..ea54f2647868 100644
--- a/kernel/marker.c
+++ b/kernel/marker.c
@@ -43,6 +43,7 @@ static DEFINE_MUTEX(markers_mutex);
43 */ 43 */
44#define MARKER_HASH_BITS 6 44#define MARKER_HASH_BITS 6
45#define MARKER_TABLE_SIZE (1 << MARKER_HASH_BITS) 45#define MARKER_TABLE_SIZE (1 << MARKER_HASH_BITS)
46static struct hlist_head marker_table[MARKER_TABLE_SIZE];
46 47
47/* 48/*
48 * Note about RCU : 49 * Note about RCU :
@@ -64,11 +65,10 @@ struct marker_entry {
64 void *oldptr; 65 void *oldptr;
65 int rcu_pending; 66 int rcu_pending;
66 unsigned char ptype:1; 67 unsigned char ptype:1;
68 unsigned char format_allocated:1;
67 char name[0]; /* Contains name'\0'format'\0' */ 69 char name[0]; /* Contains name'\0'format'\0' */
68}; 70};
69 71
70static struct hlist_head marker_table[MARKER_TABLE_SIZE];
71
72/** 72/**
73 * __mark_empty_function - Empty probe callback 73 * __mark_empty_function - Empty probe callback
74 * @probe_private: probe private data 74 * @probe_private: probe private data
@@ -81,7 +81,7 @@ static struct hlist_head marker_table[MARKER_TABLE_SIZE];
81 * though the function pointer change and the marker enabling are two distinct 81 * though the function pointer change and the marker enabling are two distinct
82 * operations that modifies the execution flow of preemptible code. 82 * operations that modifies the execution flow of preemptible code.
83 */ 83 */
84void __mark_empty_function(void *probe_private, void *call_private, 84notrace void __mark_empty_function(void *probe_private, void *call_private,
85 const char *fmt, va_list *args) 85 const char *fmt, va_list *args)
86{ 86{
87} 87}
@@ -97,7 +97,8 @@ EXPORT_SYMBOL_GPL(__mark_empty_function);
97 * need to put a full smp_rmb() in this branch. This is why we do not use 97 * need to put a full smp_rmb() in this branch. This is why we do not use
98 * rcu_dereference() for the pointer read. 98 * rcu_dereference() for the pointer read.
99 */ 99 */
100void marker_probe_cb(const struct marker *mdata, void *call_private, ...) 100notrace void marker_probe_cb(const struct marker *mdata,
101 void *call_private, ...)
101{ 102{
102 va_list args; 103 va_list args;
103 char ptype; 104 char ptype;
@@ -107,7 +108,7 @@ void marker_probe_cb(const struct marker *mdata, void *call_private, ...)
107 * sure the teardown of the callbacks can be done correctly when they 108 * sure the teardown of the callbacks can be done correctly when they
108 * are in modules and they insure RCU read coherency. 109 * are in modules and they insure RCU read coherency.
109 */ 110 */
110 rcu_read_lock_sched(); 111 rcu_read_lock_sched_notrace();
111 ptype = mdata->ptype; 112 ptype = mdata->ptype;
112 if (likely(!ptype)) { 113 if (likely(!ptype)) {
113 marker_probe_func *func; 114 marker_probe_func *func;
@@ -145,7 +146,7 @@ void marker_probe_cb(const struct marker *mdata, void *call_private, ...)
145 va_end(args); 146 va_end(args);
146 } 147 }
147 } 148 }
148 rcu_read_unlock_sched(); 149 rcu_read_unlock_sched_notrace();
149} 150}
150EXPORT_SYMBOL_GPL(marker_probe_cb); 151EXPORT_SYMBOL_GPL(marker_probe_cb);
151 152
@@ -157,12 +158,13 @@ EXPORT_SYMBOL_GPL(marker_probe_cb);
157 * 158 *
158 * Should be connected to markers "MARK_NOARGS". 159 * Should be connected to markers "MARK_NOARGS".
159 */ 160 */
160void marker_probe_cb_noarg(const struct marker *mdata, void *call_private, ...) 161static notrace void marker_probe_cb_noarg(const struct marker *mdata,
162 void *call_private, ...)
161{ 163{
162 va_list args; /* not initialized */ 164 va_list args; /* not initialized */
163 char ptype; 165 char ptype;
164 166
165 rcu_read_lock_sched(); 167 rcu_read_lock_sched_notrace();
166 ptype = mdata->ptype; 168 ptype = mdata->ptype;
167 if (likely(!ptype)) { 169 if (likely(!ptype)) {
168 marker_probe_func *func; 170 marker_probe_func *func;
@@ -195,9 +197,8 @@ void marker_probe_cb_noarg(const struct marker *mdata, void *call_private, ...)
195 multi[i].func(multi[i].probe_private, call_private, 197 multi[i].func(multi[i].probe_private, call_private,
196 mdata->format, &args); 198 mdata->format, &args);
197 } 199 }
198 rcu_read_unlock_sched(); 200 rcu_read_unlock_sched_notrace();
199} 201}
200EXPORT_SYMBOL_GPL(marker_probe_cb_noarg);
201 202
202static void free_old_closure(struct rcu_head *head) 203static void free_old_closure(struct rcu_head *head)
203{ 204{
@@ -416,6 +417,7 @@ static struct marker_entry *add_marker(const char *name, const char *format)
416 e->single.probe_private = NULL; 417 e->single.probe_private = NULL;
417 e->multi = NULL; 418 e->multi = NULL;
418 e->ptype = 0; 419 e->ptype = 0;
420 e->format_allocated = 0;
419 e->refcount = 0; 421 e->refcount = 0;
420 e->rcu_pending = 0; 422 e->rcu_pending = 0;
421 hlist_add_head(&e->hlist, head); 423 hlist_add_head(&e->hlist, head);
@@ -447,6 +449,8 @@ static int remove_marker(const char *name)
447 if (e->single.func != __mark_empty_function) 449 if (e->single.func != __mark_empty_function)
448 return -EBUSY; 450 return -EBUSY;
449 hlist_del(&e->hlist); 451 hlist_del(&e->hlist);
452 if (e->format_allocated)
453 kfree(e->format);
450 /* Make sure the call_rcu has been executed */ 454 /* Make sure the call_rcu has been executed */
451 if (e->rcu_pending) 455 if (e->rcu_pending)
452 rcu_barrier_sched(); 456 rcu_barrier_sched();
@@ -457,57 +461,34 @@ static int remove_marker(const char *name)
457/* 461/*
458 * Set the mark_entry format to the format found in the element. 462 * Set the mark_entry format to the format found in the element.
459 */ 463 */
460static int marker_set_format(struct marker_entry **entry, const char *format) 464static int marker_set_format(struct marker_entry *entry, const char *format)
461{ 465{
462 struct marker_entry *e; 466 entry->format = kstrdup(format, GFP_KERNEL);
463 size_t name_len = strlen((*entry)->name) + 1; 467 if (!entry->format)
464 size_t format_len = strlen(format) + 1;
465
466
467 e = kmalloc(sizeof(struct marker_entry) + name_len + format_len,
468 GFP_KERNEL);
469 if (!e)
470 return -ENOMEM; 468 return -ENOMEM;
471 memcpy(&e->name[0], (*entry)->name, name_len); 469 entry->format_allocated = 1;
472 e->format = &e->name[name_len]; 470
473 memcpy(e->format, format, format_len);
474 if (strcmp(e->format, MARK_NOARGS) == 0)
475 e->call = marker_probe_cb_noarg;
476 else
477 e->call = marker_probe_cb;
478 e->single = (*entry)->single;
479 e->multi = (*entry)->multi;
480 e->ptype = (*entry)->ptype;
481 e->refcount = (*entry)->refcount;
482 e->rcu_pending = 0;
483 hlist_add_before(&e->hlist, &(*entry)->hlist);
484 hlist_del(&(*entry)->hlist);
485 /* Make sure the call_rcu has been executed */
486 if ((*entry)->rcu_pending)
487 rcu_barrier_sched();
488 kfree(*entry);
489 *entry = e;
490 trace_mark(core_marker_format, "name %s format %s", 471 trace_mark(core_marker_format, "name %s format %s",
491 e->name, e->format); 472 entry->name, entry->format);
492 return 0; 473 return 0;
493} 474}
494 475
495/* 476/*
496 * Sets the probe callback corresponding to one marker. 477 * Sets the probe callback corresponding to one marker.
497 */ 478 */
498static int set_marker(struct marker_entry **entry, struct marker *elem, 479static int set_marker(struct marker_entry *entry, struct marker *elem,
499 int active) 480 int active)
500{ 481{
501 int ret; 482 int ret = 0;
502 WARN_ON(strcmp((*entry)->name, elem->name) != 0); 483 WARN_ON(strcmp(entry->name, elem->name) != 0);
503 484
504 if ((*entry)->format) { 485 if (entry->format) {
505 if (strcmp((*entry)->format, elem->format) != 0) { 486 if (strcmp(entry->format, elem->format) != 0) {
506 printk(KERN_NOTICE 487 printk(KERN_NOTICE
507 "Format mismatch for probe %s " 488 "Format mismatch for probe %s "
508 "(%s), marker (%s)\n", 489 "(%s), marker (%s)\n",
509 (*entry)->name, 490 entry->name,
510 (*entry)->format, 491 entry->format,
511 elem->format); 492 elem->format);
512 return -EPERM; 493 return -EPERM;
513 } 494 }
@@ -523,37 +504,67 @@ static int set_marker(struct marker_entry **entry, struct marker *elem,
523 * pass from a "safe" callback (with argument) to an "unsafe" 504 * pass from a "safe" callback (with argument) to an "unsafe"
524 * callback (does not set arguments). 505 * callback (does not set arguments).
525 */ 506 */
526 elem->call = (*entry)->call; 507 elem->call = entry->call;
527 /* 508 /*
528 * Sanity check : 509 * Sanity check :
529 * We only update the single probe private data when the ptr is 510 * We only update the single probe private data when the ptr is
530 * set to a _non_ single probe! (0 -> 1 and N -> 1, N != 1) 511 * set to a _non_ single probe! (0 -> 1 and N -> 1, N != 1)
531 */ 512 */
532 WARN_ON(elem->single.func != __mark_empty_function 513 WARN_ON(elem->single.func != __mark_empty_function
533 && elem->single.probe_private 514 && elem->single.probe_private != entry->single.probe_private
534 != (*entry)->single.probe_private && 515 && !elem->ptype);
535 !elem->ptype); 516 elem->single.probe_private = entry->single.probe_private;
536 elem->single.probe_private = (*entry)->single.probe_private;
537 /* 517 /*
538 * Make sure the private data is valid when we update the 518 * Make sure the private data is valid when we update the
539 * single probe ptr. 519 * single probe ptr.
540 */ 520 */
541 smp_wmb(); 521 smp_wmb();
542 elem->single.func = (*entry)->single.func; 522 elem->single.func = entry->single.func;
543 /* 523 /*
544 * We also make sure that the new probe callbacks array is consistent 524 * We also make sure that the new probe callbacks array is consistent
545 * before setting a pointer to it. 525 * before setting a pointer to it.
546 */ 526 */
547 rcu_assign_pointer(elem->multi, (*entry)->multi); 527 rcu_assign_pointer(elem->multi, entry->multi);
548 /* 528 /*
549 * Update the function or multi probe array pointer before setting the 529 * Update the function or multi probe array pointer before setting the
550 * ptype. 530 * ptype.
551 */ 531 */
552 smp_wmb(); 532 smp_wmb();
553 elem->ptype = (*entry)->ptype; 533 elem->ptype = entry->ptype;
534
535 if (elem->tp_name && (active ^ elem->state)) {
536 WARN_ON(!elem->tp_cb);
537 /*
538 * It is ok to directly call the probe registration because type
539 * checking has been done in the __trace_mark_tp() macro.
540 */
541
542 if (active) {
543 /*
544 * try_module_get should always succeed because we hold
545 * lock_module() to get the tp_cb address.
546 */
547 ret = try_module_get(__module_text_address(
548 (unsigned long)elem->tp_cb));
549 BUG_ON(!ret);
550 ret = tracepoint_probe_register_noupdate(
551 elem->tp_name,
552 elem->tp_cb);
553 } else {
554 ret = tracepoint_probe_unregister_noupdate(
555 elem->tp_name,
556 elem->tp_cb);
557 /*
558 * tracepoint_probe_update_all() must be called
559 * before the module containing tp_cb is unloaded.
560 */
561 module_put(__module_text_address(
562 (unsigned long)elem->tp_cb));
563 }
564 }
554 elem->state = active; 565 elem->state = active;
555 566
556 return 0; 567 return ret;
557} 568}
558 569
559/* 570/*
@@ -564,7 +575,24 @@ static int set_marker(struct marker_entry **entry, struct marker *elem,
564 */ 575 */
565static void disable_marker(struct marker *elem) 576static void disable_marker(struct marker *elem)
566{ 577{
578 int ret;
579
567 /* leave "call" as is. It is known statically. */ 580 /* leave "call" as is. It is known statically. */
581 if (elem->tp_name && elem->state) {
582 WARN_ON(!elem->tp_cb);
583 /*
584 * It is ok to directly call the probe registration because type
585 * checking has been done in the __trace_mark_tp() macro.
586 */
587 ret = tracepoint_probe_unregister_noupdate(elem->tp_name,
588 elem->tp_cb);
589 WARN_ON(ret);
590 /*
591 * tracepoint_probe_update_all() must be called
592 * before the module containing tp_cb is unloaded.
593 */
594 module_put(__module_text_address((unsigned long)elem->tp_cb));
595 }
568 elem->state = 0; 596 elem->state = 0;
569 elem->single.func = __mark_empty_function; 597 elem->single.func = __mark_empty_function;
570 /* Update the function before setting the ptype */ 598 /* Update the function before setting the ptype */
@@ -594,8 +622,7 @@ void marker_update_probe_range(struct marker *begin,
594 for (iter = begin; iter < end; iter++) { 622 for (iter = begin; iter < end; iter++) {
595 mark_entry = get_marker(iter->name); 623 mark_entry = get_marker(iter->name);
596 if (mark_entry) { 624 if (mark_entry) {
597 set_marker(&mark_entry, iter, 625 set_marker(mark_entry, iter, !!mark_entry->refcount);
598 !!mark_entry->refcount);
599 /* 626 /*
600 * ignore error, continue 627 * ignore error, continue
601 */ 628 */
@@ -629,6 +656,7 @@ static void marker_update_probes(void)
629 marker_update_probe_range(__start___markers, __stop___markers); 656 marker_update_probe_range(__start___markers, __stop___markers);
630 /* Markers in modules. */ 657 /* Markers in modules. */
631 module_update_markers(); 658 module_update_markers();
659 tracepoint_probe_update_all();
632} 660}
633 661
634/** 662/**
@@ -657,7 +685,7 @@ int marker_probe_register(const char *name, const char *format,
657 ret = PTR_ERR(entry); 685 ret = PTR_ERR(entry);
658 } else if (format) { 686 } else if (format) {
659 if (!entry->format) 687 if (!entry->format)
660 ret = marker_set_format(&entry, format); 688 ret = marker_set_format(entry, format);
661 else if (strcmp(entry->format, format)) 689 else if (strcmp(entry->format, format))
662 ret = -EPERM; 690 ret = -EPERM;
663 } 691 }
@@ -676,10 +704,11 @@ int marker_probe_register(const char *name, const char *format,
676 goto end; 704 goto end;
677 } 705 }
678 mutex_unlock(&markers_mutex); 706 mutex_unlock(&markers_mutex);
679 marker_update_probes(); /* may update entry */ 707 marker_update_probes();
680 mutex_lock(&markers_mutex); 708 mutex_lock(&markers_mutex);
681 entry = get_marker(name); 709 entry = get_marker(name);
682 WARN_ON(!entry); 710 if (!entry)
711 goto end;
683 if (entry->rcu_pending) 712 if (entry->rcu_pending)
684 rcu_barrier_sched(); 713 rcu_barrier_sched();
685 entry->oldptr = old; 714 entry->oldptr = old;
@@ -720,7 +749,7 @@ int marker_probe_unregister(const char *name,
720 rcu_barrier_sched(); 749 rcu_barrier_sched();
721 old = marker_entry_remove_probe(entry, probe, probe_private); 750 old = marker_entry_remove_probe(entry, probe, probe_private);
722 mutex_unlock(&markers_mutex); 751 mutex_unlock(&markers_mutex);
723 marker_update_probes(); /* may update entry */ 752 marker_update_probes();
724 mutex_lock(&markers_mutex); 753 mutex_lock(&markers_mutex);
725 entry = get_marker(name); 754 entry = get_marker(name);
726 if (!entry) 755 if (!entry)
@@ -801,10 +830,11 @@ int marker_probe_unregister_private_data(marker_probe_func *probe,
801 rcu_barrier_sched(); 830 rcu_barrier_sched();
802 old = marker_entry_remove_probe(entry, NULL, probe_private); 831 old = marker_entry_remove_probe(entry, NULL, probe_private);
803 mutex_unlock(&markers_mutex); 832 mutex_unlock(&markers_mutex);
804 marker_update_probes(); /* may update entry */ 833 marker_update_probes();
805 mutex_lock(&markers_mutex); 834 mutex_lock(&markers_mutex);
806 entry = get_marker_from_private_data(probe, probe_private); 835 entry = get_marker_from_private_data(probe, probe_private);
807 WARN_ON(!entry); 836 if (!entry)
837 goto end;
808 if (entry->rcu_pending) 838 if (entry->rcu_pending)
809 rcu_barrier_sched(); 839 rcu_barrier_sched();
810 entry->oldptr = old; 840 entry->oldptr = old;
@@ -848,8 +878,6 @@ void *marker_get_private_data(const char *name, marker_probe_func *probe,
848 if (!e->ptype) { 878 if (!e->ptype) {
849 if (num == 0 && e->single.func == probe) 879 if (num == 0 && e->single.func == probe)
850 return e->single.probe_private; 880 return e->single.probe_private;
851 else
852 break;
853 } else { 881 } else {
854 struct marker_probe_closure *closure; 882 struct marker_probe_closure *closure;
855 int match = 0; 883 int match = 0;
@@ -861,8 +889,42 @@ void *marker_get_private_data(const char *name, marker_probe_func *probe,
861 return closure[i].probe_private; 889 return closure[i].probe_private;
862 } 890 }
863 } 891 }
892 break;
864 } 893 }
865 } 894 }
866 return ERR_PTR(-ENOENT); 895 return ERR_PTR(-ENOENT);
867} 896}
868EXPORT_SYMBOL_GPL(marker_get_private_data); 897EXPORT_SYMBOL_GPL(marker_get_private_data);
898
899#ifdef CONFIG_MODULES
900
901int marker_module_notify(struct notifier_block *self,
902 unsigned long val, void *data)
903{
904 struct module *mod = data;
905
906 switch (val) {
907 case MODULE_STATE_COMING:
908 marker_update_probe_range(mod->markers,
909 mod->markers + mod->num_markers);
910 break;
911 case MODULE_STATE_GOING:
912 marker_update_probe_range(mod->markers,
913 mod->markers + mod->num_markers);
914 break;
915 }
916 return 0;
917}
918
919struct notifier_block marker_module_nb = {
920 .notifier_call = marker_module_notify,
921 .priority = 0,
922};
923
924static int init_markers(void)
925{
926 return register_module_notifier(&marker_module_nb);
927}
928__initcall(init_markers);
929
930#endif /* CONFIG_MODULES */
diff --git a/kernel/module.c b/kernel/module.c
index 1f4cc00e0c20..89bcf7c1327d 100644
--- a/kernel/module.c
+++ b/kernel/module.c
@@ -2184,24 +2184,15 @@ static noinline struct module *load_module(void __user *umod,
2184 struct mod_debug *debug; 2184 struct mod_debug *debug;
2185 unsigned int num_debug; 2185 unsigned int num_debug;
2186 2186
2187#ifdef CONFIG_MARKERS
2188 marker_update_probe_range(mod->markers,
2189 mod->markers + mod->num_markers);
2190#endif
2191 debug = section_objs(hdr, sechdrs, secstrings, "__verbose", 2187 debug = section_objs(hdr, sechdrs, secstrings, "__verbose",
2192 sizeof(*debug), &num_debug); 2188 sizeof(*debug), &num_debug);
2193 dynamic_printk_setup(debug, num_debug); 2189 dynamic_printk_setup(debug, num_debug);
2194
2195#ifdef CONFIG_TRACEPOINTS
2196 tracepoint_update_probe_range(mod->tracepoints,
2197 mod->tracepoints + mod->num_tracepoints);
2198#endif
2199 } 2190 }
2200 2191
2201 /* sechdrs[0].sh_size is always zero */ 2192 /* sechdrs[0].sh_size is always zero */
2202 mseg = section_objs(hdr, sechdrs, secstrings, "__mcount_loc", 2193 mseg = section_objs(hdr, sechdrs, secstrings, "__mcount_loc",
2203 sizeof(*mseg), &num_mcount); 2194 sizeof(*mseg), &num_mcount);
2204 ftrace_init_module(mseg, mseg + num_mcount); 2195 ftrace_init_module(mod, mseg, mseg + num_mcount);
2205 2196
2206 err = module_finalize(hdr, sechdrs, mod); 2197 err = module_finalize(hdr, sechdrs, mod);
2207 if (err < 0) 2198 if (err < 0)
diff --git a/kernel/sched.c b/kernel/sched.c
index 9b1e79371c20..4de56108c86f 100644
--- a/kernel/sched.c
+++ b/kernel/sched.c
@@ -118,6 +118,12 @@
118 */ 118 */
119#define RUNTIME_INF ((u64)~0ULL) 119#define RUNTIME_INF ((u64)~0ULL)
120 120
121DEFINE_TRACE(sched_wait_task);
122DEFINE_TRACE(sched_wakeup);
123DEFINE_TRACE(sched_wakeup_new);
124DEFINE_TRACE(sched_switch);
125DEFINE_TRACE(sched_migrate_task);
126
121#ifdef CONFIG_SMP 127#ifdef CONFIG_SMP
122/* 128/*
123 * Divide a load by a sched group cpu_power : (load / sg->__cpu_power) 129 * Divide a load by a sched group cpu_power : (load / sg->__cpu_power)
diff --git a/kernel/signal.c b/kernel/signal.c
index 4530fc654455..e9afe63da24b 100644
--- a/kernel/signal.c
+++ b/kernel/signal.c
@@ -41,6 +41,8 @@
41 41
42static struct kmem_cache *sigqueue_cachep; 42static struct kmem_cache *sigqueue_cachep;
43 43
44DEFINE_TRACE(sched_signal_send);
45
44static void __user *sig_handler(struct task_struct *t, int sig) 46static void __user *sig_handler(struct task_struct *t, int sig)
45{ 47{
46 return t->sighand->action[sig - 1].sa.sa_handler; 48 return t->sighand->action[sig - 1].sa.sa_handler;
diff --git a/kernel/sys_ni.c b/kernel/sys_ni.c
index a77b27b11b04..e14a23281707 100644
--- a/kernel/sys_ni.c
+++ b/kernel/sys_ni.c
@@ -31,7 +31,7 @@ cond_syscall(sys_socketpair);
31cond_syscall(sys_bind); 31cond_syscall(sys_bind);
32cond_syscall(sys_listen); 32cond_syscall(sys_listen);
33cond_syscall(sys_accept); 33cond_syscall(sys_accept);
34cond_syscall(sys_paccept); 34cond_syscall(sys_accept4);
35cond_syscall(sys_connect); 35cond_syscall(sys_connect);
36cond_syscall(sys_getsockname); 36cond_syscall(sys_getsockname);
37cond_syscall(sys_getpeername); 37cond_syscall(sys_getpeername);
diff --git a/kernel/sysctl.c b/kernel/sysctl.c
index 9d048fa2d902..65d4a9ba79e4 100644
--- a/kernel/sysctl.c
+++ b/kernel/sysctl.c
@@ -484,6 +484,16 @@ static struct ctl_table kern_table[] = {
484 .proc_handler = &ftrace_enable_sysctl, 484 .proc_handler = &ftrace_enable_sysctl,
485 }, 485 },
486#endif 486#endif
487#ifdef CONFIG_TRACING
488 {
489 .ctl_name = CTL_UNNUMBERED,
490 .procname = "ftrace_dump_on_oops",
491 .data = &ftrace_dump_on_oops,
492 .maxlen = sizeof(int),
493 .mode = 0644,
494 .proc_handler = &proc_dointvec,
495 },
496#endif
487#ifdef CONFIG_MODULES 497#ifdef CONFIG_MODULES
488 { 498 {
489 .ctl_name = KERN_MODPROBE, 499 .ctl_name = KERN_MODPROBE,
diff --git a/kernel/trace/Kconfig b/kernel/trace/Kconfig
index 33dbefd471e8..b8378fad29a3 100644
--- a/kernel/trace/Kconfig
+++ b/kernel/trace/Kconfig
@@ -9,6 +9,16 @@ config NOP_TRACER
9config HAVE_FUNCTION_TRACER 9config HAVE_FUNCTION_TRACER
10 bool 10 bool
11 11
12config HAVE_FUNCTION_RET_TRACER
13 bool
14
15config HAVE_FUNCTION_TRACE_MCOUNT_TEST
16 bool
17 help
18 This gets selected when the arch tests the function_trace_stop
19 variable at the mcount call site. Otherwise, this variable
20 is tested by the called function.
21
12config HAVE_DYNAMIC_FTRACE 22config HAVE_DYNAMIC_FTRACE
13 bool 23 bool
14 24
@@ -47,6 +57,16 @@ config FUNCTION_TRACER
47 (the bootup default), then the overhead of the instructions is very 57 (the bootup default), then the overhead of the instructions is very
48 small and not measurable even in micro-benchmarks. 58 small and not measurable even in micro-benchmarks.
49 59
60config FUNCTION_RET_TRACER
61 bool "Kernel Function return Tracer"
62 depends on HAVE_FUNCTION_RET_TRACER
63 depends on FUNCTION_TRACER
64 help
65 Enable the kernel to trace a function at its return.
66 It's first purpose is to trace the duration of functions.
67 This is done by setting the current return address on the thread
68 info structure of the current task.
69
50config IRQSOFF_TRACER 70config IRQSOFF_TRACER
51 bool "Interrupts-off Latency Tracer" 71 bool "Interrupts-off Latency Tracer"
52 default n 72 default n
@@ -138,6 +158,44 @@ config BOOT_TRACER
138 selected, because the self-tests are an initcall as well and that 158 selected, because the self-tests are an initcall as well and that
139 would invalidate the boot trace. ) 159 would invalidate the boot trace. )
140 160
161config TRACE_BRANCH_PROFILING
162 bool "Trace likely/unlikely profiler"
163 depends on DEBUG_KERNEL
164 select TRACING
165 help
166 This tracer profiles all the the likely and unlikely macros
167 in the kernel. It will display the results in:
168
169 /debugfs/tracing/profile_likely
170 /debugfs/tracing/profile_unlikely
171
172 Note: this will add a significant overhead, only turn this
173 on if you need to profile the system's use of these macros.
174
175 Say N if unsure.
176
177config TRACING_BRANCHES
178 bool
179 help
180 Selected by tracers that will trace the likely and unlikely
181 conditions. This prevents the tracers themselves from being
182 profiled. Profiling the tracing infrastructure can only happen
183 when the likelys and unlikelys are not being traced.
184
185config BRANCH_TRACER
186 bool "Trace likely/unlikely instances"
187 depends on TRACE_BRANCH_PROFILING
188 select TRACING_BRANCHES
189 help
190 This traces the events of likely and unlikely condition
191 calls in the kernel. The difference between this and the
192 "Trace likely/unlikely profiler" is that this is not a
193 histogram of the callers, but actually places the calling
194 events into a running trace buffer to see when and where the
195 events happened, as well as their results.
196
197 Say N if unsure.
198
141config STACK_TRACER 199config STACK_TRACER
142 bool "Trace max stack" 200 bool "Trace max stack"
143 depends on HAVE_FUNCTION_TRACER 201 depends on HAVE_FUNCTION_TRACER
diff --git a/kernel/trace/Makefile b/kernel/trace/Makefile
index c8228b1a49e9..1a8c9259dc69 100644
--- a/kernel/trace/Makefile
+++ b/kernel/trace/Makefile
@@ -10,6 +10,11 @@ CFLAGS_trace_selftest_dynamic.o = -pg
10obj-y += trace_selftest_dynamic.o 10obj-y += trace_selftest_dynamic.o
11endif 11endif
12 12
13# If unlikely tracing is enabled, do not trace these files
14ifdef CONFIG_TRACING_BRANCHES
15KBUILD_CFLAGS += -DDISABLE_BRANCH_PROFILING
16endif
17
13obj-$(CONFIG_FUNCTION_TRACER) += libftrace.o 18obj-$(CONFIG_FUNCTION_TRACER) += libftrace.o
14obj-$(CONFIG_RING_BUFFER) += ring_buffer.o 19obj-$(CONFIG_RING_BUFFER) += ring_buffer.o
15 20
@@ -24,5 +29,7 @@ obj-$(CONFIG_NOP_TRACER) += trace_nop.o
24obj-$(CONFIG_STACK_TRACER) += trace_stack.o 29obj-$(CONFIG_STACK_TRACER) += trace_stack.o
25obj-$(CONFIG_MMIOTRACE) += trace_mmiotrace.o 30obj-$(CONFIG_MMIOTRACE) += trace_mmiotrace.o
26obj-$(CONFIG_BOOT_TRACER) += trace_boot.o 31obj-$(CONFIG_BOOT_TRACER) += trace_boot.o
32obj-$(CONFIG_FUNCTION_RET_TRACER) += trace_functions_return.o
33obj-$(CONFIG_TRACE_BRANCH_PROFILING) += trace_branch.o
27 34
28libftrace-y := ftrace.o 35libftrace-y := ftrace.o
diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c
index e60205722d0c..f212da486689 100644
--- a/kernel/trace/ftrace.c
+++ b/kernel/trace/ftrace.c
@@ -47,6 +47,12 @@
47int ftrace_enabled __read_mostly; 47int ftrace_enabled __read_mostly;
48static int last_ftrace_enabled; 48static int last_ftrace_enabled;
49 49
50/* Quick disabling of function tracer. */
51int function_trace_stop;
52
53/* By default, current tracing type is normal tracing. */
54enum ftrace_tracing_type_t ftrace_tracing_type = FTRACE_TYPE_ENTER;
55
50/* 56/*
51 * ftrace_disabled is set when an anomaly is discovered. 57 * ftrace_disabled is set when an anomaly is discovered.
52 * ftrace_disabled is much stronger than ftrace_enabled. 58 * ftrace_disabled is much stronger than ftrace_enabled.
@@ -63,6 +69,7 @@ static struct ftrace_ops ftrace_list_end __read_mostly =
63 69
64static struct ftrace_ops *ftrace_list __read_mostly = &ftrace_list_end; 70static struct ftrace_ops *ftrace_list __read_mostly = &ftrace_list_end;
65ftrace_func_t ftrace_trace_function __read_mostly = ftrace_stub; 71ftrace_func_t ftrace_trace_function __read_mostly = ftrace_stub;
72ftrace_func_t __ftrace_trace_function __read_mostly = ftrace_stub;
66 73
67static void ftrace_list_func(unsigned long ip, unsigned long parent_ip) 74static void ftrace_list_func(unsigned long ip, unsigned long parent_ip)
68{ 75{
@@ -88,7 +95,22 @@ static void ftrace_list_func(unsigned long ip, unsigned long parent_ip)
88void clear_ftrace_function(void) 95void clear_ftrace_function(void)
89{ 96{
90 ftrace_trace_function = ftrace_stub; 97 ftrace_trace_function = ftrace_stub;
98 __ftrace_trace_function = ftrace_stub;
99}
100
101#ifndef CONFIG_HAVE_FUNCTION_TRACE_MCOUNT_TEST
102/*
103 * For those archs that do not test ftrace_trace_stop in their
104 * mcount call site, we need to do it from C.
105 */
106static void ftrace_test_stop_func(unsigned long ip, unsigned long parent_ip)
107{
108 if (function_trace_stop)
109 return;
110
111 __ftrace_trace_function(ip, parent_ip);
91} 112}
113#endif
92 114
93static int __register_ftrace_function(struct ftrace_ops *ops) 115static int __register_ftrace_function(struct ftrace_ops *ops)
94{ 116{
@@ -110,10 +132,18 @@ static int __register_ftrace_function(struct ftrace_ops *ops)
110 * For one func, simply call it directly. 132 * For one func, simply call it directly.
111 * For more than one func, call the chain. 133 * For more than one func, call the chain.
112 */ 134 */
135#ifdef CONFIG_HAVE_FUNCTION_TRACE_MCOUNT_TEST
113 if (ops->next == &ftrace_list_end) 136 if (ops->next == &ftrace_list_end)
114 ftrace_trace_function = ops->func; 137 ftrace_trace_function = ops->func;
115 else 138 else
116 ftrace_trace_function = ftrace_list_func; 139 ftrace_trace_function = ftrace_list_func;
140#else
141 if (ops->next == &ftrace_list_end)
142 __ftrace_trace_function = ops->func;
143 else
144 __ftrace_trace_function = ftrace_list_func;
145 ftrace_trace_function = ftrace_test_stop_func;
146#endif
117 } 147 }
118 148
119 spin_unlock(&ftrace_lock); 149 spin_unlock(&ftrace_lock);
@@ -152,8 +182,7 @@ static int __unregister_ftrace_function(struct ftrace_ops *ops)
152 182
153 if (ftrace_enabled) { 183 if (ftrace_enabled) {
154 /* If we only have one func left, then call that directly */ 184 /* If we only have one func left, then call that directly */
155 if (ftrace_list == &ftrace_list_end || 185 if (ftrace_list->next == &ftrace_list_end)
156 ftrace_list->next == &ftrace_list_end)
157 ftrace_trace_function = ftrace_list->func; 186 ftrace_trace_function = ftrace_list->func;
158 } 187 }
159 188
@@ -308,7 +337,7 @@ ftrace_record_ip(unsigned long ip)
308{ 337{
309 struct dyn_ftrace *rec; 338 struct dyn_ftrace *rec;
310 339
311 if (!ftrace_enabled || ftrace_disabled) 340 if (ftrace_disabled)
312 return NULL; 341 return NULL;
313 342
314 rec = ftrace_alloc_dyn_node(ip); 343 rec = ftrace_alloc_dyn_node(ip);
@@ -322,107 +351,138 @@ ftrace_record_ip(unsigned long ip)
322 return rec; 351 return rec;
323} 352}
324 353
325#define FTRACE_ADDR ((long)(ftrace_caller)) 354static void print_ip_ins(const char *fmt, unsigned char *p)
355{
356 int i;
357
358 printk(KERN_CONT "%s", fmt);
359
360 for (i = 0; i < MCOUNT_INSN_SIZE; i++)
361 printk(KERN_CONT "%s%02x", i ? ":" : "", p[i]);
362}
363
364static void ftrace_bug(int failed, unsigned long ip)
365{
366 switch (failed) {
367 case -EFAULT:
368 FTRACE_WARN_ON_ONCE(1);
369 pr_info("ftrace faulted on modifying ");
370 print_ip_sym(ip);
371 break;
372 case -EINVAL:
373 FTRACE_WARN_ON_ONCE(1);
374 pr_info("ftrace failed to modify ");
375 print_ip_sym(ip);
376 print_ip_ins(" actual: ", (unsigned char *)ip);
377 printk(KERN_CONT "\n");
378 break;
379 case -EPERM:
380 FTRACE_WARN_ON_ONCE(1);
381 pr_info("ftrace faulted on writing ");
382 print_ip_sym(ip);
383 break;
384 default:
385 FTRACE_WARN_ON_ONCE(1);
386 pr_info("ftrace faulted on unknown error ");
387 print_ip_sym(ip);
388 }
389}
390
326 391
327static int 392static int
328__ftrace_replace_code(struct dyn_ftrace *rec, 393__ftrace_replace_code(struct dyn_ftrace *rec, int enable)
329 unsigned char *old, unsigned char *new, int enable)
330{ 394{
331 unsigned long ip, fl; 395 unsigned long ip, fl;
396 unsigned long ftrace_addr;
397
398#ifdef CONFIG_FUNCTION_RET_TRACER
399 if (ftrace_tracing_type == FTRACE_TYPE_ENTER)
400 ftrace_addr = (unsigned long)ftrace_caller;
401 else
402 ftrace_addr = (unsigned long)ftrace_return_caller;
403#else
404 ftrace_addr = (unsigned long)ftrace_caller;
405#endif
332 406
333 ip = rec->ip; 407 ip = rec->ip;
334 408
335 if (ftrace_filtered && enable) { 409 /*
410 * If this record is not to be traced and
411 * it is not enabled then do nothing.
412 *
413 * If this record is not to be traced and
414 * it is enabled then disabled it.
415 *
416 */
417 if (rec->flags & FTRACE_FL_NOTRACE) {
418 if (rec->flags & FTRACE_FL_ENABLED)
419 rec->flags &= ~FTRACE_FL_ENABLED;
420 else
421 return 0;
422
423 } else if (ftrace_filtered && enable) {
336 /* 424 /*
337 * If filtering is on: 425 * Filtering is on:
338 *
339 * If this record is set to be filtered and
340 * is enabled then do nothing.
341 *
342 * If this record is set to be filtered and
343 * it is not enabled, enable it.
344 *
345 * If this record is not set to be filtered
346 * and it is not enabled do nothing.
347 *
348 * If this record is set not to trace then
349 * do nothing.
350 *
351 * If this record is set not to trace and
352 * it is enabled then disable it.
353 *
354 * If this record is not set to be filtered and
355 * it is enabled, disable it.
356 */ 426 */
357 427
358 fl = rec->flags & (FTRACE_FL_FILTER | FTRACE_FL_NOTRACE | 428 fl = rec->flags & (FTRACE_FL_FILTER | FTRACE_FL_ENABLED);
359 FTRACE_FL_ENABLED);
360 429
361 if ((fl == (FTRACE_FL_FILTER | FTRACE_FL_ENABLED)) || 430 /* Record is filtered and enabled, do nothing */
362 (fl == (FTRACE_FL_FILTER | FTRACE_FL_NOTRACE)) || 431 if (fl == (FTRACE_FL_FILTER | FTRACE_FL_ENABLED))
363 !fl || (fl == FTRACE_FL_NOTRACE))
364 return 0; 432 return 0;
365 433
366 /* 434 /* Record is not filtered and is not enabled do nothing */
367 * If it is enabled disable it, 435 if (!fl)
368 * otherwise enable it! 436 return 0;
369 */ 437
370 if (fl & FTRACE_FL_ENABLED) { 438 /* Record is not filtered but enabled, disable it */
371 /* swap new and old */ 439 if (fl == FTRACE_FL_ENABLED)
372 new = old;
373 old = ftrace_call_replace(ip, FTRACE_ADDR);
374 rec->flags &= ~FTRACE_FL_ENABLED; 440 rec->flags &= ~FTRACE_FL_ENABLED;
375 } else { 441 else
376 new = ftrace_call_replace(ip, FTRACE_ADDR); 442 /* Otherwise record is filtered but not enabled, enable it */
377 rec->flags |= FTRACE_FL_ENABLED; 443 rec->flags |= FTRACE_FL_ENABLED;
378 }
379 } else { 444 } else {
445 /* Disable or not filtered */
380 446
381 if (enable) { 447 if (enable) {
382 /* 448 /* if record is enabled, do nothing */
383 * If this record is set not to trace and is
384 * not enabled, do nothing.
385 */
386 fl = rec->flags & (FTRACE_FL_NOTRACE | FTRACE_FL_ENABLED);
387 if (fl == FTRACE_FL_NOTRACE)
388 return 0;
389
390 new = ftrace_call_replace(ip, FTRACE_ADDR);
391 } else
392 old = ftrace_call_replace(ip, FTRACE_ADDR);
393
394 if (enable) {
395 if (rec->flags & FTRACE_FL_ENABLED) 449 if (rec->flags & FTRACE_FL_ENABLED)
396 return 0; 450 return 0;
451
397 rec->flags |= FTRACE_FL_ENABLED; 452 rec->flags |= FTRACE_FL_ENABLED;
453
398 } else { 454 } else {
455
456 /* if record is not enabled do nothing */
399 if (!(rec->flags & FTRACE_FL_ENABLED)) 457 if (!(rec->flags & FTRACE_FL_ENABLED))
400 return 0; 458 return 0;
459
401 rec->flags &= ~FTRACE_FL_ENABLED; 460 rec->flags &= ~FTRACE_FL_ENABLED;
402 } 461 }
403 } 462 }
404 463
405 return ftrace_modify_code(ip, old, new); 464 if (rec->flags & FTRACE_FL_ENABLED)
465 return ftrace_make_call(rec, ftrace_addr);
466 else
467 return ftrace_make_nop(NULL, rec, ftrace_addr);
406} 468}
407 469
408static void ftrace_replace_code(int enable) 470static void ftrace_replace_code(int enable)
409{ 471{
410 int i, failed; 472 int i, failed;
411 unsigned char *new = NULL, *old = NULL;
412 struct dyn_ftrace *rec; 473 struct dyn_ftrace *rec;
413 struct ftrace_page *pg; 474 struct ftrace_page *pg;
414 475
415 if (enable)
416 old = ftrace_nop_replace();
417 else
418 new = ftrace_nop_replace();
419
420 for (pg = ftrace_pages_start; pg; pg = pg->next) { 476 for (pg = ftrace_pages_start; pg; pg = pg->next) {
421 for (i = 0; i < pg->index; i++) { 477 for (i = 0; i < pg->index; i++) {
422 rec = &pg->records[i]; 478 rec = &pg->records[i];
423 479
424 /* don't modify code that has already faulted */ 480 /*
425 if (rec->flags & FTRACE_FL_FAILED) 481 * Skip over free records and records that have
482 * failed.
483 */
484 if (rec->flags & FTRACE_FL_FREE ||
485 rec->flags & FTRACE_FL_FAILED)
426 continue; 486 continue;
427 487
428 /* ignore updates to this record's mcount site */ 488 /* ignore updates to this record's mcount site */
@@ -433,68 +493,30 @@ static void ftrace_replace_code(int enable)
433 unfreeze_record(rec); 493 unfreeze_record(rec);
434 } 494 }
435 495
436 failed = __ftrace_replace_code(rec, old, new, enable); 496 failed = __ftrace_replace_code(rec, enable);
437 if (failed && (rec->flags & FTRACE_FL_CONVERTED)) { 497 if (failed && (rec->flags & FTRACE_FL_CONVERTED)) {
438 rec->flags |= FTRACE_FL_FAILED; 498 rec->flags |= FTRACE_FL_FAILED;
439 if ((system_state == SYSTEM_BOOTING) || 499 if ((system_state == SYSTEM_BOOTING) ||
440 !core_kernel_text(rec->ip)) { 500 !core_kernel_text(rec->ip)) {
441 ftrace_free_rec(rec); 501 ftrace_free_rec(rec);
442 } 502 } else
503 ftrace_bug(failed, rec->ip);
443 } 504 }
444 } 505 }
445 } 506 }
446} 507}
447 508
448static void print_ip_ins(const char *fmt, unsigned char *p)
449{
450 int i;
451
452 printk(KERN_CONT "%s", fmt);
453
454 for (i = 0; i < MCOUNT_INSN_SIZE; i++)
455 printk(KERN_CONT "%s%02x", i ? ":" : "", p[i]);
456}
457
458static int 509static int
459ftrace_code_disable(struct dyn_ftrace *rec) 510ftrace_code_disable(struct module *mod, struct dyn_ftrace *rec)
460{ 511{
461 unsigned long ip; 512 unsigned long ip;
462 unsigned char *nop, *call;
463 int ret; 513 int ret;
464 514
465 ip = rec->ip; 515 ip = rec->ip;
466 516
467 nop = ftrace_nop_replace(); 517 ret = ftrace_make_nop(mod, rec, mcount_addr);
468 call = ftrace_call_replace(ip, mcount_addr);
469
470 ret = ftrace_modify_code(ip, call, nop);
471 if (ret) { 518 if (ret) {
472 switch (ret) { 519 ftrace_bug(ret, ip);
473 case -EFAULT:
474 FTRACE_WARN_ON_ONCE(1);
475 pr_info("ftrace faulted on modifying ");
476 print_ip_sym(ip);
477 break;
478 case -EINVAL:
479 FTRACE_WARN_ON_ONCE(1);
480 pr_info("ftrace failed to modify ");
481 print_ip_sym(ip);
482 print_ip_ins(" expected: ", call);
483 print_ip_ins(" actual: ", (unsigned char *)ip);
484 print_ip_ins(" replace: ", nop);
485 printk(KERN_CONT "\n");
486 break;
487 case -EPERM:
488 FTRACE_WARN_ON_ONCE(1);
489 pr_info("ftrace faulted on writing ");
490 print_ip_sym(ip);
491 break;
492 default:
493 FTRACE_WARN_ON_ONCE(1);
494 pr_info("ftrace faulted on unknown error ");
495 print_ip_sym(ip);
496 }
497
498 rec->flags |= FTRACE_FL_FAILED; 520 rec->flags |= FTRACE_FL_FAILED;
499 return 0; 521 return 0;
500 } 522 }
@@ -522,7 +544,7 @@ static void ftrace_run_update_code(int command)
522} 544}
523 545
524static ftrace_func_t saved_ftrace_func; 546static ftrace_func_t saved_ftrace_func;
525static int ftrace_start; 547static int ftrace_start_up;
526static DEFINE_MUTEX(ftrace_start_lock); 548static DEFINE_MUTEX(ftrace_start_lock);
527 549
528static void ftrace_startup(void) 550static void ftrace_startup(void)
@@ -533,9 +555,8 @@ static void ftrace_startup(void)
533 return; 555 return;
534 556
535 mutex_lock(&ftrace_start_lock); 557 mutex_lock(&ftrace_start_lock);
536 ftrace_start++; 558 ftrace_start_up++;
537 if (ftrace_start == 1) 559 command |= FTRACE_ENABLE_CALLS;
538 command |= FTRACE_ENABLE_CALLS;
539 560
540 if (saved_ftrace_func != ftrace_trace_function) { 561 if (saved_ftrace_func != ftrace_trace_function) {
541 saved_ftrace_func = ftrace_trace_function; 562 saved_ftrace_func = ftrace_trace_function;
@@ -558,8 +579,8 @@ static void ftrace_shutdown(void)
558 return; 579 return;
559 580
560 mutex_lock(&ftrace_start_lock); 581 mutex_lock(&ftrace_start_lock);
561 ftrace_start--; 582 ftrace_start_up--;
562 if (!ftrace_start) 583 if (!ftrace_start_up)
563 command |= FTRACE_DISABLE_CALLS; 584 command |= FTRACE_DISABLE_CALLS;
564 585
565 if (saved_ftrace_func != ftrace_trace_function) { 586 if (saved_ftrace_func != ftrace_trace_function) {
@@ -585,8 +606,8 @@ static void ftrace_startup_sysctl(void)
585 mutex_lock(&ftrace_start_lock); 606 mutex_lock(&ftrace_start_lock);
586 /* Force update next time */ 607 /* Force update next time */
587 saved_ftrace_func = NULL; 608 saved_ftrace_func = NULL;
588 /* ftrace_start is true if we want ftrace running */ 609 /* ftrace_start_up is true if we want ftrace running */
589 if (ftrace_start) 610 if (ftrace_start_up)
590 command |= FTRACE_ENABLE_CALLS; 611 command |= FTRACE_ENABLE_CALLS;
591 612
592 ftrace_run_update_code(command); 613 ftrace_run_update_code(command);
@@ -601,8 +622,8 @@ static void ftrace_shutdown_sysctl(void)
601 return; 622 return;
602 623
603 mutex_lock(&ftrace_start_lock); 624 mutex_lock(&ftrace_start_lock);
604 /* ftrace_start is true if ftrace is running */ 625 /* ftrace_start_up is true if ftrace is running */
605 if (ftrace_start) 626 if (ftrace_start_up)
606 command |= FTRACE_DISABLE_CALLS; 627 command |= FTRACE_DISABLE_CALLS;
607 628
608 ftrace_run_update_code(command); 629 ftrace_run_update_code(command);
@@ -613,7 +634,7 @@ static cycle_t ftrace_update_time;
613static unsigned long ftrace_update_cnt; 634static unsigned long ftrace_update_cnt;
614unsigned long ftrace_update_tot_cnt; 635unsigned long ftrace_update_tot_cnt;
615 636
616static int ftrace_update_code(void) 637static int ftrace_update_code(struct module *mod)
617{ 638{
618 struct dyn_ftrace *p, *t; 639 struct dyn_ftrace *p, *t;
619 cycle_t start, stop; 640 cycle_t start, stop;
@@ -630,7 +651,7 @@ static int ftrace_update_code(void)
630 list_del_init(&p->list); 651 list_del_init(&p->list);
631 652
632 /* convert record (i.e, patch mcount-call with NOP) */ 653 /* convert record (i.e, patch mcount-call with NOP) */
633 if (ftrace_code_disable(p)) { 654 if (ftrace_code_disable(mod, p)) {
634 p->flags |= FTRACE_FL_CONVERTED; 655 p->flags |= FTRACE_FL_CONVERTED;
635 ftrace_update_cnt++; 656 ftrace_update_cnt++;
636 } else 657 } else
@@ -734,6 +755,9 @@ t_next(struct seq_file *m, void *v, loff_t *pos)
734 ((iter->flags & FTRACE_ITER_FAILURES) && 755 ((iter->flags & FTRACE_ITER_FAILURES) &&
735 !(rec->flags & FTRACE_FL_FAILED)) || 756 !(rec->flags & FTRACE_FL_FAILED)) ||
736 757
758 ((iter->flags & FTRACE_ITER_FILTER) &&
759 !(rec->flags & FTRACE_FL_FILTER)) ||
760
737 ((iter->flags & FTRACE_ITER_NOTRACE) && 761 ((iter->flags & FTRACE_ITER_NOTRACE) &&
738 !(rec->flags & FTRACE_FL_NOTRACE))) { 762 !(rec->flags & FTRACE_FL_NOTRACE))) {
739 rec = NULL; 763 rec = NULL;
@@ -1186,7 +1210,7 @@ ftrace_regex_release(struct inode *inode, struct file *file, int enable)
1186 1210
1187 mutex_lock(&ftrace_sysctl_lock); 1211 mutex_lock(&ftrace_sysctl_lock);
1188 mutex_lock(&ftrace_start_lock); 1212 mutex_lock(&ftrace_start_lock);
1189 if (iter->filtered && ftrace_start && ftrace_enabled) 1213 if (ftrace_start_up && ftrace_enabled)
1190 ftrace_run_update_code(FTRACE_ENABLE_CALLS); 1214 ftrace_run_update_code(FTRACE_ENABLE_CALLS);
1191 mutex_unlock(&ftrace_start_lock); 1215 mutex_unlock(&ftrace_start_lock);
1192 mutex_unlock(&ftrace_sysctl_lock); 1216 mutex_unlock(&ftrace_sysctl_lock);
@@ -1273,7 +1297,8 @@ static __init int ftrace_init_debugfs(void)
1273 1297
1274fs_initcall(ftrace_init_debugfs); 1298fs_initcall(ftrace_init_debugfs);
1275 1299
1276static int ftrace_convert_nops(unsigned long *start, 1300static int ftrace_convert_nops(struct module *mod,
1301 unsigned long *start,
1277 unsigned long *end) 1302 unsigned long *end)
1278{ 1303{
1279 unsigned long *p; 1304 unsigned long *p;
@@ -1284,23 +1309,32 @@ static int ftrace_convert_nops(unsigned long *start,
1284 p = start; 1309 p = start;
1285 while (p < end) { 1310 while (p < end) {
1286 addr = ftrace_call_adjust(*p++); 1311 addr = ftrace_call_adjust(*p++);
1312 /*
1313 * Some architecture linkers will pad between
1314 * the different mcount_loc sections of different
1315 * object files to satisfy alignments.
1316 * Skip any NULL pointers.
1317 */
1318 if (!addr)
1319 continue;
1287 ftrace_record_ip(addr); 1320 ftrace_record_ip(addr);
1288 } 1321 }
1289 1322
1290 /* disable interrupts to prevent kstop machine */ 1323 /* disable interrupts to prevent kstop machine */
1291 local_irq_save(flags); 1324 local_irq_save(flags);
1292 ftrace_update_code(); 1325 ftrace_update_code(mod);
1293 local_irq_restore(flags); 1326 local_irq_restore(flags);
1294 mutex_unlock(&ftrace_start_lock); 1327 mutex_unlock(&ftrace_start_lock);
1295 1328
1296 return 0; 1329 return 0;
1297} 1330}
1298 1331
1299void ftrace_init_module(unsigned long *start, unsigned long *end) 1332void ftrace_init_module(struct module *mod,
1333 unsigned long *start, unsigned long *end)
1300{ 1334{
1301 if (ftrace_disabled || start == end) 1335 if (ftrace_disabled || start == end)
1302 return; 1336 return;
1303 ftrace_convert_nops(start, end); 1337 ftrace_convert_nops(mod, start, end);
1304} 1338}
1305 1339
1306extern unsigned long __start_mcount_loc[]; 1340extern unsigned long __start_mcount_loc[];
@@ -1330,7 +1364,8 @@ void __init ftrace_init(void)
1330 1364
1331 last_ftrace_enabled = ftrace_enabled = 1; 1365 last_ftrace_enabled = ftrace_enabled = 1;
1332 1366
1333 ret = ftrace_convert_nops(__start_mcount_loc, 1367 ret = ftrace_convert_nops(NULL,
1368 __start_mcount_loc,
1334 __stop_mcount_loc); 1369 __stop_mcount_loc);
1335 1370
1336 return; 1371 return;
@@ -1386,10 +1421,17 @@ int register_ftrace_function(struct ftrace_ops *ops)
1386 return -1; 1421 return -1;
1387 1422
1388 mutex_lock(&ftrace_sysctl_lock); 1423 mutex_lock(&ftrace_sysctl_lock);
1424
1425 if (ftrace_tracing_type == FTRACE_TYPE_RETURN) {
1426 ret = -EBUSY;
1427 goto out;
1428 }
1429
1389 ret = __register_ftrace_function(ops); 1430 ret = __register_ftrace_function(ops);
1390 ftrace_startup(); 1431 ftrace_startup();
1391 mutex_unlock(&ftrace_sysctl_lock);
1392 1432
1433out:
1434 mutex_unlock(&ftrace_sysctl_lock);
1393 return ret; 1435 return ret;
1394} 1436}
1395 1437
@@ -1454,3 +1496,48 @@ ftrace_enable_sysctl(struct ctl_table *table, int write,
1454 return ret; 1496 return ret;
1455} 1497}
1456 1498
1499#ifdef CONFIG_FUNCTION_RET_TRACER
1500
1501/* The callback that hooks the return of a function */
1502trace_function_return_t ftrace_function_return =
1503 (trace_function_return_t)ftrace_stub;
1504
1505int register_ftrace_return(trace_function_return_t func)
1506{
1507 int ret = 0;
1508
1509 mutex_lock(&ftrace_sysctl_lock);
1510
1511 /*
1512 * Don't launch return tracing if normal function
1513 * tracing is already running.
1514 */
1515 if (ftrace_trace_function != ftrace_stub) {
1516 ret = -EBUSY;
1517 goto out;
1518 }
1519
1520 ftrace_tracing_type = FTRACE_TYPE_RETURN;
1521 ftrace_function_return = func;
1522 ftrace_startup();
1523
1524out:
1525 mutex_unlock(&ftrace_sysctl_lock);
1526 return ret;
1527}
1528
1529void unregister_ftrace_return(void)
1530{
1531 mutex_lock(&ftrace_sysctl_lock);
1532
1533 ftrace_function_return = (trace_function_return_t)ftrace_stub;
1534 ftrace_shutdown();
1535 /* Restore normal tracing type */
1536 ftrace_tracing_type = FTRACE_TYPE_ENTER;
1537
1538 mutex_unlock(&ftrace_sysctl_lock);
1539}
1540#endif
1541
1542
1543
diff --git a/kernel/trace/ring_buffer.c b/kernel/trace/ring_buffer.c
index 036456cbb4f7..85ced143c2c4 100644
--- a/kernel/trace/ring_buffer.c
+++ b/kernel/trace/ring_buffer.c
@@ -45,6 +45,8 @@ void tracing_off(void)
45 ring_buffers_off = 1; 45 ring_buffers_off = 1;
46} 46}
47 47
48#include "trace.h"
49
48/* Up this if you want to test the TIME_EXTENTS and normalization */ 50/* Up this if you want to test the TIME_EXTENTS and normalization */
49#define DEBUG_SHIFT 0 51#define DEBUG_SHIFT 0
50 52
@@ -187,7 +189,8 @@ static inline int test_time_stamp(u64 delta)
187struct ring_buffer_per_cpu { 189struct ring_buffer_per_cpu {
188 int cpu; 190 int cpu;
189 struct ring_buffer *buffer; 191 struct ring_buffer *buffer;
190 spinlock_t lock; 192 spinlock_t reader_lock; /* serialize readers */
193 raw_spinlock_t lock;
191 struct lock_class_key lock_key; 194 struct lock_class_key lock_key;
192 struct list_head pages; 195 struct list_head pages;
193 struct buffer_page *head_page; /* read from head */ 196 struct buffer_page *head_page; /* read from head */
@@ -221,32 +224,16 @@ struct ring_buffer_iter {
221 u64 read_stamp; 224 u64 read_stamp;
222}; 225};
223 226
227/* buffer may be either ring_buffer or ring_buffer_per_cpu */
224#define RB_WARN_ON(buffer, cond) \ 228#define RB_WARN_ON(buffer, cond) \
225 do { \ 229 ({ \
226 if (unlikely(cond)) { \ 230 int _____ret = unlikely(cond); \
227 atomic_inc(&buffer->record_disabled); \ 231 if (_____ret) { \
228 WARN_ON(1); \
229 } \
230 } while (0)
231
232#define RB_WARN_ON_RET(buffer, cond) \
233 do { \
234 if (unlikely(cond)) { \
235 atomic_inc(&buffer->record_disabled); \
236 WARN_ON(1); \
237 return -1; \
238 } \
239 } while (0)
240
241#define RB_WARN_ON_ONCE(buffer, cond) \
242 do { \
243 static int once; \
244 if (unlikely(cond) && !once) { \
245 once++; \
246 atomic_inc(&buffer->record_disabled); \ 232 atomic_inc(&buffer->record_disabled); \
247 WARN_ON(1); \ 233 WARN_ON(1); \
248 } \ 234 } \
249 } while (0) 235 _____ret; \
236 })
250 237
251/** 238/**
252 * check_pages - integrity check of buffer pages 239 * check_pages - integrity check of buffer pages
@@ -260,14 +247,18 @@ static int rb_check_pages(struct ring_buffer_per_cpu *cpu_buffer)
260 struct list_head *head = &cpu_buffer->pages; 247 struct list_head *head = &cpu_buffer->pages;
261 struct buffer_page *page, *tmp; 248 struct buffer_page *page, *tmp;
262 249
263 RB_WARN_ON_RET(cpu_buffer, head->next->prev != head); 250 if (RB_WARN_ON(cpu_buffer, head->next->prev != head))
264 RB_WARN_ON_RET(cpu_buffer, head->prev->next != head); 251 return -1;
252 if (RB_WARN_ON(cpu_buffer, head->prev->next != head))
253 return -1;
265 254
266 list_for_each_entry_safe(page, tmp, head, list) { 255 list_for_each_entry_safe(page, tmp, head, list) {
267 RB_WARN_ON_RET(cpu_buffer, 256 if (RB_WARN_ON(cpu_buffer,
268 page->list.next->prev != &page->list); 257 page->list.next->prev != &page->list))
269 RB_WARN_ON_RET(cpu_buffer, 258 return -1;
270 page->list.prev->next != &page->list); 259 if (RB_WARN_ON(cpu_buffer,
260 page->list.prev->next != &page->list))
261 return -1;
271 } 262 }
272 263
273 return 0; 264 return 0;
@@ -324,7 +315,8 @@ rb_allocate_cpu_buffer(struct ring_buffer *buffer, int cpu)
324 315
325 cpu_buffer->cpu = cpu; 316 cpu_buffer->cpu = cpu;
326 cpu_buffer->buffer = buffer; 317 cpu_buffer->buffer = buffer;
327 spin_lock_init(&cpu_buffer->lock); 318 spin_lock_init(&cpu_buffer->reader_lock);
319 cpu_buffer->lock = (raw_spinlock_t)__RAW_SPIN_LOCK_UNLOCKED;
328 INIT_LIST_HEAD(&cpu_buffer->pages); 320 INIT_LIST_HEAD(&cpu_buffer->pages);
329 321
330 page = kzalloc_node(ALIGN(sizeof(*page), cache_line_size()), 322 page = kzalloc_node(ALIGN(sizeof(*page), cache_line_size()),
@@ -473,13 +465,15 @@ rb_remove_pages(struct ring_buffer_per_cpu *cpu_buffer, unsigned nr_pages)
473 synchronize_sched(); 465 synchronize_sched();
474 466
475 for (i = 0; i < nr_pages; i++) { 467 for (i = 0; i < nr_pages; i++) {
476 BUG_ON(list_empty(&cpu_buffer->pages)); 468 if (RB_WARN_ON(cpu_buffer, list_empty(&cpu_buffer->pages)))
469 return;
477 p = cpu_buffer->pages.next; 470 p = cpu_buffer->pages.next;
478 page = list_entry(p, struct buffer_page, list); 471 page = list_entry(p, struct buffer_page, list);
479 list_del_init(&page->list); 472 list_del_init(&page->list);
480 free_buffer_page(page); 473 free_buffer_page(page);
481 } 474 }
482 BUG_ON(list_empty(&cpu_buffer->pages)); 475 if (RB_WARN_ON(cpu_buffer, list_empty(&cpu_buffer->pages)))
476 return;
483 477
484 rb_reset_cpu(cpu_buffer); 478 rb_reset_cpu(cpu_buffer);
485 479
@@ -501,7 +495,8 @@ rb_insert_pages(struct ring_buffer_per_cpu *cpu_buffer,
501 synchronize_sched(); 495 synchronize_sched();
502 496
503 for (i = 0; i < nr_pages; i++) { 497 for (i = 0; i < nr_pages; i++) {
504 BUG_ON(list_empty(pages)); 498 if (RB_WARN_ON(cpu_buffer, list_empty(pages)))
499 return;
505 p = pages->next; 500 p = pages->next;
506 page = list_entry(p, struct buffer_page, list); 501 page = list_entry(p, struct buffer_page, list);
507 list_del_init(&page->list); 502 list_del_init(&page->list);
@@ -562,7 +557,10 @@ int ring_buffer_resize(struct ring_buffer *buffer, unsigned long size)
562 if (size < buffer_size) { 557 if (size < buffer_size) {
563 558
564 /* easy case, just free pages */ 559 /* easy case, just free pages */
565 BUG_ON(nr_pages >= buffer->pages); 560 if (RB_WARN_ON(buffer, nr_pages >= buffer->pages)) {
561 mutex_unlock(&buffer->mutex);
562 return -1;
563 }
566 564
567 rm_pages = buffer->pages - nr_pages; 565 rm_pages = buffer->pages - nr_pages;
568 566
@@ -581,7 +579,11 @@ int ring_buffer_resize(struct ring_buffer *buffer, unsigned long size)
581 * add these pages to the cpu_buffers. Otherwise we just free 579 * add these pages to the cpu_buffers. Otherwise we just free
582 * them all and return -ENOMEM; 580 * them all and return -ENOMEM;
583 */ 581 */
584 BUG_ON(nr_pages <= buffer->pages); 582 if (RB_WARN_ON(buffer, nr_pages <= buffer->pages)) {
583 mutex_unlock(&buffer->mutex);
584 return -1;
585 }
586
585 new_pages = nr_pages - buffer->pages; 587 new_pages = nr_pages - buffer->pages;
586 588
587 for_each_buffer_cpu(buffer, cpu) { 589 for_each_buffer_cpu(buffer, cpu) {
@@ -604,7 +606,10 @@ int ring_buffer_resize(struct ring_buffer *buffer, unsigned long size)
604 rb_insert_pages(cpu_buffer, &pages, new_pages); 606 rb_insert_pages(cpu_buffer, &pages, new_pages);
605 } 607 }
606 608
607 BUG_ON(!list_empty(&pages)); 609 if (RB_WARN_ON(buffer, !list_empty(&pages))) {
610 mutex_unlock(&buffer->mutex);
611 return -1;
612 }
608 613
609 out: 614 out:
610 buffer->pages = nr_pages; 615 buffer->pages = nr_pages;
@@ -617,6 +622,7 @@ int ring_buffer_resize(struct ring_buffer *buffer, unsigned long size)
617 list_del_init(&page->list); 622 list_del_init(&page->list);
618 free_buffer_page(page); 623 free_buffer_page(page);
619 } 624 }
625 mutex_unlock(&buffer->mutex);
620 return -ENOMEM; 626 return -ENOMEM;
621} 627}
622 628
@@ -692,7 +698,8 @@ static void rb_update_overflow(struct ring_buffer_per_cpu *cpu_buffer)
692 head += rb_event_length(event)) { 698 head += rb_event_length(event)) {
693 699
694 event = __rb_page_index(cpu_buffer->head_page, head); 700 event = __rb_page_index(cpu_buffer->head_page, head);
695 BUG_ON(rb_null_event(event)); 701 if (RB_WARN_ON(cpu_buffer, rb_null_event(event)))
702 return;
696 /* Only count data entries */ 703 /* Only count data entries */
697 if (event->type != RINGBUF_TYPE_DATA) 704 if (event->type != RINGBUF_TYPE_DATA)
698 continue; 705 continue;
@@ -745,8 +752,9 @@ rb_set_commit_event(struct ring_buffer_per_cpu *cpu_buffer,
745 addr &= PAGE_MASK; 752 addr &= PAGE_MASK;
746 753
747 while (cpu_buffer->commit_page->page != (void *)addr) { 754 while (cpu_buffer->commit_page->page != (void *)addr) {
748 RB_WARN_ON(cpu_buffer, 755 if (RB_WARN_ON(cpu_buffer,
749 cpu_buffer->commit_page == cpu_buffer->tail_page); 756 cpu_buffer->commit_page == cpu_buffer->tail_page))
757 return;
750 cpu_buffer->commit_page->commit = 758 cpu_buffer->commit_page->commit =
751 cpu_buffer->commit_page->write; 759 cpu_buffer->commit_page->write;
752 rb_inc_page(cpu_buffer, &cpu_buffer->commit_page); 760 rb_inc_page(cpu_buffer, &cpu_buffer->commit_page);
@@ -893,7 +901,8 @@ __rb_reserve_next(struct ring_buffer_per_cpu *cpu_buffer,
893 if (write > BUF_PAGE_SIZE) { 901 if (write > BUF_PAGE_SIZE) {
894 struct buffer_page *next_page = tail_page; 902 struct buffer_page *next_page = tail_page;
895 903
896 spin_lock_irqsave(&cpu_buffer->lock, flags); 904 local_irq_save(flags);
905 __raw_spin_lock(&cpu_buffer->lock);
897 906
898 rb_inc_page(cpu_buffer, &next_page); 907 rb_inc_page(cpu_buffer, &next_page);
899 908
@@ -901,7 +910,8 @@ __rb_reserve_next(struct ring_buffer_per_cpu *cpu_buffer,
901 reader_page = cpu_buffer->reader_page; 910 reader_page = cpu_buffer->reader_page;
902 911
903 /* we grabbed the lock before incrementing */ 912 /* we grabbed the lock before incrementing */
904 RB_WARN_ON(cpu_buffer, next_page == reader_page); 913 if (RB_WARN_ON(cpu_buffer, next_page == reader_page))
914 goto out_unlock;
905 915
906 /* 916 /*
907 * If for some reason, we had an interrupt storm that made 917 * If for some reason, we had an interrupt storm that made
@@ -969,7 +979,8 @@ __rb_reserve_next(struct ring_buffer_per_cpu *cpu_buffer,
969 rb_set_commit_to_write(cpu_buffer); 979 rb_set_commit_to_write(cpu_buffer);
970 } 980 }
971 981
972 spin_unlock_irqrestore(&cpu_buffer->lock, flags); 982 __raw_spin_unlock(&cpu_buffer->lock);
983 local_irq_restore(flags);
973 984
974 /* fail and let the caller try again */ 985 /* fail and let the caller try again */
975 return ERR_PTR(-EAGAIN); 986 return ERR_PTR(-EAGAIN);
@@ -977,7 +988,8 @@ __rb_reserve_next(struct ring_buffer_per_cpu *cpu_buffer,
977 988
978 /* We reserved something on the buffer */ 989 /* We reserved something on the buffer */
979 990
980 BUG_ON(write > BUF_PAGE_SIZE); 991 if (RB_WARN_ON(cpu_buffer, write > BUF_PAGE_SIZE))
992 return NULL;
981 993
982 event = __rb_page_index(tail_page, tail); 994 event = __rb_page_index(tail_page, tail);
983 rb_update_event(event, type, length); 995 rb_update_event(event, type, length);
@@ -992,7 +1004,8 @@ __rb_reserve_next(struct ring_buffer_per_cpu *cpu_buffer,
992 return event; 1004 return event;
993 1005
994 out_unlock: 1006 out_unlock:
995 spin_unlock_irqrestore(&cpu_buffer->lock, flags); 1007 __raw_spin_unlock(&cpu_buffer->lock);
1008 local_irq_restore(flags);
996 return NULL; 1009 return NULL;
997} 1010}
998 1011
@@ -1075,10 +1088,8 @@ rb_reserve_next_event(struct ring_buffer_per_cpu *cpu_buffer,
1075 * storm or we have something buggy. 1088 * storm or we have something buggy.
1076 * Bail! 1089 * Bail!
1077 */ 1090 */
1078 if (unlikely(++nr_loops > 1000)) { 1091 if (RB_WARN_ON(cpu_buffer, ++nr_loops > 1000))
1079 RB_WARN_ON(cpu_buffer, 1);
1080 return NULL; 1092 return NULL;
1081 }
1082 1093
1083 ts = ring_buffer_time_stamp(cpu_buffer->cpu); 1094 ts = ring_buffer_time_stamp(cpu_buffer->cpu);
1084 1095
@@ -1181,8 +1192,7 @@ ring_buffer_lock_reserve(struct ring_buffer *buffer,
1181 return NULL; 1192 return NULL;
1182 1193
1183 /* If we are tracing schedule, we don't want to recurse */ 1194 /* If we are tracing schedule, we don't want to recurse */
1184 resched = need_resched(); 1195 resched = ftrace_preempt_disable();
1185 preempt_disable_notrace();
1186 1196
1187 cpu = raw_smp_processor_id(); 1197 cpu = raw_smp_processor_id();
1188 1198
@@ -1213,10 +1223,7 @@ ring_buffer_lock_reserve(struct ring_buffer *buffer,
1213 return event; 1223 return event;
1214 1224
1215 out: 1225 out:
1216 if (resched) 1226 ftrace_preempt_enable(resched);
1217 preempt_enable_notrace();
1218 else
1219 preempt_enable_notrace();
1220 return NULL; 1227 return NULL;
1221} 1228}
1222 1229
@@ -1258,12 +1265,9 @@ int ring_buffer_unlock_commit(struct ring_buffer *buffer,
1258 /* 1265 /*
1259 * Only the last preempt count needs to restore preemption. 1266 * Only the last preempt count needs to restore preemption.
1260 */ 1267 */
1261 if (preempt_count() == 1) { 1268 if (preempt_count() == 1)
1262 if (per_cpu(rb_need_resched, cpu)) 1269 ftrace_preempt_enable(per_cpu(rb_need_resched, cpu));
1263 preempt_enable_no_resched_notrace(); 1270 else
1264 else
1265 preempt_enable_notrace();
1266 } else
1267 preempt_enable_no_resched_notrace(); 1271 preempt_enable_no_resched_notrace();
1268 1272
1269 return 0; 1273 return 0;
@@ -1299,8 +1303,7 @@ int ring_buffer_write(struct ring_buffer *buffer,
1299 if (atomic_read(&buffer->record_disabled)) 1303 if (atomic_read(&buffer->record_disabled))
1300 return -EBUSY; 1304 return -EBUSY;
1301 1305
1302 resched = need_resched(); 1306 resched = ftrace_preempt_disable();
1303 preempt_disable_notrace();
1304 1307
1305 cpu = raw_smp_processor_id(); 1308 cpu = raw_smp_processor_id();
1306 1309
@@ -1326,10 +1329,7 @@ int ring_buffer_write(struct ring_buffer *buffer,
1326 1329
1327 ret = 0; 1330 ret = 0;
1328 out: 1331 out:
1329 if (resched) 1332 ftrace_preempt_enable(resched);
1330 preempt_enable_no_resched_notrace();
1331 else
1332 preempt_enable_notrace();
1333 1333
1334 return ret; 1334 return ret;
1335} 1335}
@@ -1488,14 +1488,7 @@ unsigned long ring_buffer_overruns(struct ring_buffer *buffer)
1488 return overruns; 1488 return overruns;
1489} 1489}
1490 1490
1491/** 1491static void rb_iter_reset(struct ring_buffer_iter *iter)
1492 * ring_buffer_iter_reset - reset an iterator
1493 * @iter: The iterator to reset
1494 *
1495 * Resets the iterator, so that it will start from the beginning
1496 * again.
1497 */
1498void ring_buffer_iter_reset(struct ring_buffer_iter *iter)
1499{ 1492{
1500 struct ring_buffer_per_cpu *cpu_buffer = iter->cpu_buffer; 1493 struct ring_buffer_per_cpu *cpu_buffer = iter->cpu_buffer;
1501 1494
@@ -1514,6 +1507,23 @@ void ring_buffer_iter_reset(struct ring_buffer_iter *iter)
1514} 1507}
1515 1508
1516/** 1509/**
1510 * ring_buffer_iter_reset - reset an iterator
1511 * @iter: The iterator to reset
1512 *
1513 * Resets the iterator, so that it will start from the beginning
1514 * again.
1515 */
1516void ring_buffer_iter_reset(struct ring_buffer_iter *iter)
1517{
1518 struct ring_buffer_per_cpu *cpu_buffer = iter->cpu_buffer;
1519 unsigned long flags;
1520
1521 spin_lock_irqsave(&cpu_buffer->reader_lock, flags);
1522 rb_iter_reset(iter);
1523 spin_unlock_irqrestore(&cpu_buffer->reader_lock, flags);
1524}
1525
1526/**
1517 * ring_buffer_iter_empty - check if an iterator has no more to read 1527 * ring_buffer_iter_empty - check if an iterator has no more to read
1518 * @iter: The iterator to check 1528 * @iter: The iterator to check
1519 */ 1529 */
@@ -1596,7 +1606,8 @@ rb_get_reader_page(struct ring_buffer_per_cpu *cpu_buffer)
1596 unsigned long flags; 1606 unsigned long flags;
1597 int nr_loops = 0; 1607 int nr_loops = 0;
1598 1608
1599 spin_lock_irqsave(&cpu_buffer->lock, flags); 1609 local_irq_save(flags);
1610 __raw_spin_lock(&cpu_buffer->lock);
1600 1611
1601 again: 1612 again:
1602 /* 1613 /*
@@ -1605,8 +1616,7 @@ rb_get_reader_page(struct ring_buffer_per_cpu *cpu_buffer)
1605 * a case where we will loop three times. There should be no 1616 * a case where we will loop three times. There should be no
1606 * reason to loop four times (that I know of). 1617 * reason to loop four times (that I know of).
1607 */ 1618 */
1608 if (unlikely(++nr_loops > 3)) { 1619 if (RB_WARN_ON(cpu_buffer, ++nr_loops > 3)) {
1609 RB_WARN_ON(cpu_buffer, 1);
1610 reader = NULL; 1620 reader = NULL;
1611 goto out; 1621 goto out;
1612 } 1622 }
@@ -1618,8 +1628,9 @@ rb_get_reader_page(struct ring_buffer_per_cpu *cpu_buffer)
1618 goto out; 1628 goto out;
1619 1629
1620 /* Never should we have an index greater than the size */ 1630 /* Never should we have an index greater than the size */
1621 RB_WARN_ON(cpu_buffer, 1631 if (RB_WARN_ON(cpu_buffer,
1622 cpu_buffer->reader_page->read > rb_page_size(reader)); 1632 cpu_buffer->reader_page->read > rb_page_size(reader)))
1633 goto out;
1623 1634
1624 /* check if we caught up to the tail */ 1635 /* check if we caught up to the tail */
1625 reader = NULL; 1636 reader = NULL;
@@ -1658,7 +1669,8 @@ rb_get_reader_page(struct ring_buffer_per_cpu *cpu_buffer)
1658 goto again; 1669 goto again;
1659 1670
1660 out: 1671 out:
1661 spin_unlock_irqrestore(&cpu_buffer->lock, flags); 1672 __raw_spin_unlock(&cpu_buffer->lock);
1673 local_irq_restore(flags);
1662 1674
1663 return reader; 1675 return reader;
1664} 1676}
@@ -1672,7 +1684,8 @@ static void rb_advance_reader(struct ring_buffer_per_cpu *cpu_buffer)
1672 reader = rb_get_reader_page(cpu_buffer); 1684 reader = rb_get_reader_page(cpu_buffer);
1673 1685
1674 /* This function should not be called when buffer is empty */ 1686 /* This function should not be called when buffer is empty */
1675 BUG_ON(!reader); 1687 if (RB_WARN_ON(cpu_buffer, !reader))
1688 return;
1676 1689
1677 event = rb_reader_event(cpu_buffer); 1690 event = rb_reader_event(cpu_buffer);
1678 1691
@@ -1699,7 +1712,9 @@ static void rb_advance_iter(struct ring_buffer_iter *iter)
1699 * Check if we are at the end of the buffer. 1712 * Check if we are at the end of the buffer.
1700 */ 1713 */
1701 if (iter->head >= rb_page_size(iter->head_page)) { 1714 if (iter->head >= rb_page_size(iter->head_page)) {
1702 BUG_ON(iter->head_page == cpu_buffer->commit_page); 1715 if (RB_WARN_ON(buffer,
1716 iter->head_page == cpu_buffer->commit_page))
1717 return;
1703 rb_inc_iter(iter); 1718 rb_inc_iter(iter);
1704 return; 1719 return;
1705 } 1720 }
@@ -1712,8 +1727,10 @@ static void rb_advance_iter(struct ring_buffer_iter *iter)
1712 * This should not be called to advance the header if we are 1727 * This should not be called to advance the header if we are
1713 * at the tail of the buffer. 1728 * at the tail of the buffer.
1714 */ 1729 */
1715 BUG_ON((iter->head_page == cpu_buffer->commit_page) && 1730 if (RB_WARN_ON(cpu_buffer,
1716 (iter->head + length > rb_commit_index(cpu_buffer))); 1731 (iter->head_page == cpu_buffer->commit_page) &&
1732 (iter->head + length > rb_commit_index(cpu_buffer))))
1733 return;
1717 1734
1718 rb_update_iter_read_stamp(iter, event); 1735 rb_update_iter_read_stamp(iter, event);
1719 1736
@@ -1725,17 +1742,8 @@ static void rb_advance_iter(struct ring_buffer_iter *iter)
1725 rb_advance_iter(iter); 1742 rb_advance_iter(iter);
1726} 1743}
1727 1744
1728/** 1745static struct ring_buffer_event *
1729 * ring_buffer_peek - peek at the next event to be read 1746rb_buffer_peek(struct ring_buffer *buffer, int cpu, u64 *ts)
1730 * @buffer: The ring buffer to read
1731 * @cpu: The cpu to peak at
1732 * @ts: The timestamp counter of this event.
1733 *
1734 * This will return the event that will be read next, but does
1735 * not consume the data.
1736 */
1737struct ring_buffer_event *
1738ring_buffer_peek(struct ring_buffer *buffer, int cpu, u64 *ts)
1739{ 1747{
1740 struct ring_buffer_per_cpu *cpu_buffer; 1748 struct ring_buffer_per_cpu *cpu_buffer;
1741 struct ring_buffer_event *event; 1749 struct ring_buffer_event *event;
@@ -1756,10 +1764,8 @@ ring_buffer_peek(struct ring_buffer *buffer, int cpu, u64 *ts)
1756 * can have. Nesting 10 deep of interrupts is clearly 1764 * can have. Nesting 10 deep of interrupts is clearly
1757 * an anomaly. 1765 * an anomaly.
1758 */ 1766 */
1759 if (unlikely(++nr_loops > 10)) { 1767 if (RB_WARN_ON(cpu_buffer, ++nr_loops > 10))
1760 RB_WARN_ON(cpu_buffer, 1);
1761 return NULL; 1768 return NULL;
1762 }
1763 1769
1764 reader = rb_get_reader_page(cpu_buffer); 1770 reader = rb_get_reader_page(cpu_buffer);
1765 if (!reader) 1771 if (!reader)
@@ -1797,16 +1803,8 @@ ring_buffer_peek(struct ring_buffer *buffer, int cpu, u64 *ts)
1797 return NULL; 1803 return NULL;
1798} 1804}
1799 1805
1800/** 1806static struct ring_buffer_event *
1801 * ring_buffer_iter_peek - peek at the next event to be read 1807rb_iter_peek(struct ring_buffer_iter *iter, u64 *ts)
1802 * @iter: The ring buffer iterator
1803 * @ts: The timestamp counter of this event.
1804 *
1805 * This will return the event that will be read next, but does
1806 * not increment the iterator.
1807 */
1808struct ring_buffer_event *
1809ring_buffer_iter_peek(struct ring_buffer_iter *iter, u64 *ts)
1810{ 1808{
1811 struct ring_buffer *buffer; 1809 struct ring_buffer *buffer;
1812 struct ring_buffer_per_cpu *cpu_buffer; 1810 struct ring_buffer_per_cpu *cpu_buffer;
@@ -1828,10 +1826,8 @@ ring_buffer_iter_peek(struct ring_buffer_iter *iter, u64 *ts)
1828 * can have. Nesting 10 deep of interrupts is clearly 1826 * can have. Nesting 10 deep of interrupts is clearly
1829 * an anomaly. 1827 * an anomaly.
1830 */ 1828 */
1831 if (unlikely(++nr_loops > 10)) { 1829 if (RB_WARN_ON(cpu_buffer, ++nr_loops > 10))
1832 RB_WARN_ON(cpu_buffer, 1);
1833 return NULL; 1830 return NULL;
1834 }
1835 1831
1836 if (rb_per_cpu_empty(cpu_buffer)) 1832 if (rb_per_cpu_empty(cpu_buffer))
1837 return NULL; 1833 return NULL;
@@ -1868,6 +1864,51 @@ ring_buffer_iter_peek(struct ring_buffer_iter *iter, u64 *ts)
1868} 1864}
1869 1865
1870/** 1866/**
1867 * ring_buffer_peek - peek at the next event to be read
1868 * @buffer: The ring buffer to read
1869 * @cpu: The cpu to peak at
1870 * @ts: The timestamp counter of this event.
1871 *
1872 * This will return the event that will be read next, but does
1873 * not consume the data.
1874 */
1875struct ring_buffer_event *
1876ring_buffer_peek(struct ring_buffer *buffer, int cpu, u64 *ts)
1877{
1878 struct ring_buffer_per_cpu *cpu_buffer = buffer->buffers[cpu];
1879 struct ring_buffer_event *event;
1880 unsigned long flags;
1881
1882 spin_lock_irqsave(&cpu_buffer->reader_lock, flags);
1883 event = rb_buffer_peek(buffer, cpu, ts);
1884 spin_unlock_irqrestore(&cpu_buffer->reader_lock, flags);
1885
1886 return event;
1887}
1888
1889/**
1890 * ring_buffer_iter_peek - peek at the next event to be read
1891 * @iter: The ring buffer iterator
1892 * @ts: The timestamp counter of this event.
1893 *
1894 * This will return the event that will be read next, but does
1895 * not increment the iterator.
1896 */
1897struct ring_buffer_event *
1898ring_buffer_iter_peek(struct ring_buffer_iter *iter, u64 *ts)
1899{
1900 struct ring_buffer_per_cpu *cpu_buffer = iter->cpu_buffer;
1901 struct ring_buffer_event *event;
1902 unsigned long flags;
1903
1904 spin_lock_irqsave(&cpu_buffer->reader_lock, flags);
1905 event = rb_iter_peek(iter, ts);
1906 spin_unlock_irqrestore(&cpu_buffer->reader_lock, flags);
1907
1908 return event;
1909}
1910
1911/**
1871 * ring_buffer_consume - return an event and consume it 1912 * ring_buffer_consume - return an event and consume it
1872 * @buffer: The ring buffer to get the next event from 1913 * @buffer: The ring buffer to get the next event from
1873 * 1914 *
@@ -1878,19 +1919,24 @@ ring_buffer_iter_peek(struct ring_buffer_iter *iter, u64 *ts)
1878struct ring_buffer_event * 1919struct ring_buffer_event *
1879ring_buffer_consume(struct ring_buffer *buffer, int cpu, u64 *ts) 1920ring_buffer_consume(struct ring_buffer *buffer, int cpu, u64 *ts)
1880{ 1921{
1881 struct ring_buffer_per_cpu *cpu_buffer; 1922 struct ring_buffer_per_cpu *cpu_buffer = buffer->buffers[cpu];
1882 struct ring_buffer_event *event; 1923 struct ring_buffer_event *event;
1924 unsigned long flags;
1883 1925
1884 if (!cpu_isset(cpu, buffer->cpumask)) 1926 if (!cpu_isset(cpu, buffer->cpumask))
1885 return NULL; 1927 return NULL;
1886 1928
1887 event = ring_buffer_peek(buffer, cpu, ts); 1929 spin_lock_irqsave(&cpu_buffer->reader_lock, flags);
1930
1931 event = rb_buffer_peek(buffer, cpu, ts);
1888 if (!event) 1932 if (!event)
1889 return NULL; 1933 goto out;
1890 1934
1891 cpu_buffer = buffer->buffers[cpu];
1892 rb_advance_reader(cpu_buffer); 1935 rb_advance_reader(cpu_buffer);
1893 1936
1937 out:
1938 spin_unlock_irqrestore(&cpu_buffer->reader_lock, flags);
1939
1894 return event; 1940 return event;
1895} 1941}
1896 1942
@@ -1927,9 +1973,11 @@ ring_buffer_read_start(struct ring_buffer *buffer, int cpu)
1927 atomic_inc(&cpu_buffer->record_disabled); 1973 atomic_inc(&cpu_buffer->record_disabled);
1928 synchronize_sched(); 1974 synchronize_sched();
1929 1975
1930 spin_lock_irqsave(&cpu_buffer->lock, flags); 1976 spin_lock_irqsave(&cpu_buffer->reader_lock, flags);
1931 ring_buffer_iter_reset(iter); 1977 __raw_spin_lock(&cpu_buffer->lock);
1932 spin_unlock_irqrestore(&cpu_buffer->lock, flags); 1978 rb_iter_reset(iter);
1979 __raw_spin_unlock(&cpu_buffer->lock);
1980 spin_unlock_irqrestore(&cpu_buffer->reader_lock, flags);
1933 1981
1934 return iter; 1982 return iter;
1935} 1983}
@@ -1961,12 +2009,17 @@ struct ring_buffer_event *
1961ring_buffer_read(struct ring_buffer_iter *iter, u64 *ts) 2009ring_buffer_read(struct ring_buffer_iter *iter, u64 *ts)
1962{ 2010{
1963 struct ring_buffer_event *event; 2011 struct ring_buffer_event *event;
2012 struct ring_buffer_per_cpu *cpu_buffer = iter->cpu_buffer;
2013 unsigned long flags;
1964 2014
1965 event = ring_buffer_iter_peek(iter, ts); 2015 spin_lock_irqsave(&cpu_buffer->reader_lock, flags);
2016 event = rb_iter_peek(iter, ts);
1966 if (!event) 2017 if (!event)
1967 return NULL; 2018 goto out;
1968 2019
1969 rb_advance_iter(iter); 2020 rb_advance_iter(iter);
2021 out:
2022 spin_unlock_irqrestore(&cpu_buffer->reader_lock, flags);
1970 2023
1971 return event; 2024 return event;
1972} 2025}
@@ -2015,11 +2068,15 @@ void ring_buffer_reset_cpu(struct ring_buffer *buffer, int cpu)
2015 if (!cpu_isset(cpu, buffer->cpumask)) 2068 if (!cpu_isset(cpu, buffer->cpumask))
2016 return; 2069 return;
2017 2070
2018 spin_lock_irqsave(&cpu_buffer->lock, flags); 2071 spin_lock_irqsave(&cpu_buffer->reader_lock, flags);
2072
2073 __raw_spin_lock(&cpu_buffer->lock);
2019 2074
2020 rb_reset_cpu(cpu_buffer); 2075 rb_reset_cpu(cpu_buffer);
2021 2076
2022 spin_unlock_irqrestore(&cpu_buffer->lock, flags); 2077 __raw_spin_unlock(&cpu_buffer->lock);
2078
2079 spin_unlock_irqrestore(&cpu_buffer->reader_lock, flags);
2023} 2080}
2024 2081
2025/** 2082/**
diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
index 697eda36b86a..4ee6f0375222 100644
--- a/kernel/trace/trace.c
+++ b/kernel/trace/trace.c
@@ -43,6 +43,29 @@
43unsigned long __read_mostly tracing_max_latency = (cycle_t)ULONG_MAX; 43unsigned long __read_mostly tracing_max_latency = (cycle_t)ULONG_MAX;
44unsigned long __read_mostly tracing_thresh; 44unsigned long __read_mostly tracing_thresh;
45 45
46/* For tracers that don't implement custom flags */
47static struct tracer_opt dummy_tracer_opt[] = {
48 { }
49};
50
51static struct tracer_flags dummy_tracer_flags = {
52 .val = 0,
53 .opts = dummy_tracer_opt
54};
55
56static int dummy_set_flag(u32 old_flags, u32 bit, int set)
57{
58 return 0;
59}
60
61/*
62 * Kill all tracing for good (never come back).
63 * It is initialized to 1 but will turn to zero if the initialization
64 * of the tracer is successful. But that is the only place that sets
65 * this back to zero.
66 */
67int tracing_disabled = 1;
68
46static DEFINE_PER_CPU(local_t, ftrace_cpu_disabled); 69static DEFINE_PER_CPU(local_t, ftrace_cpu_disabled);
47 70
48static inline void ftrace_disable_cpu(void) 71static inline void ftrace_disable_cpu(void)
@@ -62,7 +85,36 @@ static cpumask_t __read_mostly tracing_buffer_mask;
62#define for_each_tracing_cpu(cpu) \ 85#define for_each_tracing_cpu(cpu) \
63 for_each_cpu_mask(cpu, tracing_buffer_mask) 86 for_each_cpu_mask(cpu, tracing_buffer_mask)
64 87
65static int tracing_disabled = 1; 88/*
89 * ftrace_dump_on_oops - variable to dump ftrace buffer on oops
90 *
91 * If there is an oops (or kernel panic) and the ftrace_dump_on_oops
92 * is set, then ftrace_dump is called. This will output the contents
93 * of the ftrace buffers to the console. This is very useful for
94 * capturing traces that lead to crashes and outputing it to a
95 * serial console.
96 *
97 * It is default off, but you can enable it with either specifying
98 * "ftrace_dump_on_oops" in the kernel command line, or setting
99 * /proc/sys/kernel/ftrace_dump_on_oops to true.
100 */
101int ftrace_dump_on_oops;
102
103static int tracing_set_tracer(char *buf);
104
105static int __init set_ftrace(char *str)
106{
107 tracing_set_tracer(str);
108 return 1;
109}
110__setup("ftrace", set_ftrace);
111
112static int __init set_ftrace_dump_on_oops(char *str)
113{
114 ftrace_dump_on_oops = 1;
115 return 1;
116}
117__setup("ftrace_dump_on_oops", set_ftrace_dump_on_oops);
66 118
67long 119long
68ns2usecs(cycle_t nsec) 120ns2usecs(cycle_t nsec)
@@ -112,6 +164,19 @@ static DEFINE_PER_CPU(struct trace_array_cpu, max_data);
112/* tracer_enabled is used to toggle activation of a tracer */ 164/* tracer_enabled is used to toggle activation of a tracer */
113static int tracer_enabled = 1; 165static int tracer_enabled = 1;
114 166
167/**
168 * tracing_is_enabled - return tracer_enabled status
169 *
170 * This function is used by other tracers to know the status
171 * of the tracer_enabled flag. Tracers may use this function
172 * to know if it should enable their features when starting
173 * up. See irqsoff tracer for an example (start_irqsoff_tracer).
174 */
175int tracing_is_enabled(void)
176{
177 return tracer_enabled;
178}
179
115/* function tracing enabled */ 180/* function tracing enabled */
116int ftrace_function_enabled; 181int ftrace_function_enabled;
117 182
@@ -153,8 +218,9 @@ static DEFINE_MUTEX(trace_types_lock);
153/* trace_wait is a waitqueue for tasks blocked on trace_poll */ 218/* trace_wait is a waitqueue for tasks blocked on trace_poll */
154static DECLARE_WAIT_QUEUE_HEAD(trace_wait); 219static DECLARE_WAIT_QUEUE_HEAD(trace_wait);
155 220
156/* trace_flags holds iter_ctrl options */ 221/* trace_flags holds trace_options default values */
157unsigned long trace_flags = TRACE_ITER_PRINT_PARENT; 222unsigned long trace_flags = TRACE_ITER_PRINT_PARENT | TRACE_ITER_PRINTK |
223 TRACE_ITER_ANNOTATE;
158 224
159/** 225/**
160 * trace_wake_up - wake up tasks waiting for trace input 226 * trace_wake_up - wake up tasks waiting for trace input
@@ -193,13 +259,6 @@ unsigned long nsecs_to_usecs(unsigned long nsecs)
193 return nsecs / 1000; 259 return nsecs / 1000;
194} 260}
195 261
196/*
197 * TRACE_ITER_SYM_MASK masks the options in trace_flags that
198 * control the output of kernel symbols.
199 */
200#define TRACE_ITER_SYM_MASK \
201 (TRACE_ITER_PRINT_PARENT|TRACE_ITER_SYM_OFFSET|TRACE_ITER_SYM_ADDR)
202
203/* These must match the bit postions in trace_iterator_flags */ 262/* These must match the bit postions in trace_iterator_flags */
204static const char *trace_options[] = { 263static const char *trace_options[] = {
205 "print-parent", 264 "print-parent",
@@ -213,6 +272,9 @@ static const char *trace_options[] = {
213 "stacktrace", 272 "stacktrace",
214 "sched-tree", 273 "sched-tree",
215 "ftrace_printk", 274 "ftrace_printk",
275 "ftrace_preempt",
276 "branch",
277 "annotate",
216 NULL 278 NULL
217}; 279};
218 280
@@ -470,7 +532,15 @@ int register_tracer(struct tracer *type)
470 return -1; 532 return -1;
471 } 533 }
472 534
535 /*
536 * When this gets called we hold the BKL which means that
537 * preemption is disabled. Various trace selftests however
538 * need to disable and enable preemption for successful tests.
539 * So we drop the BKL here and grab it after the tests again.
540 */
541 unlock_kernel();
473 mutex_lock(&trace_types_lock); 542 mutex_lock(&trace_types_lock);
543
474 for (t = trace_types; t; t = t->next) { 544 for (t = trace_types; t; t = t->next) {
475 if (strcmp(type->name, t->name) == 0) { 545 if (strcmp(type->name, t->name) == 0) {
476 /* already found */ 546 /* already found */
@@ -481,11 +551,18 @@ int register_tracer(struct tracer *type)
481 } 551 }
482 } 552 }
483 553
554 if (!type->set_flag)
555 type->set_flag = &dummy_set_flag;
556 if (!type->flags)
557 type->flags = &dummy_tracer_flags;
558 else
559 if (!type->flags->opts)
560 type->flags->opts = dummy_tracer_opt;
561
484#ifdef CONFIG_FTRACE_STARTUP_TEST 562#ifdef CONFIG_FTRACE_STARTUP_TEST
485 if (type->selftest) { 563 if (type->selftest) {
486 struct tracer *saved_tracer = current_trace; 564 struct tracer *saved_tracer = current_trace;
487 struct trace_array *tr = &global_trace; 565 struct trace_array *tr = &global_trace;
488 int saved_ctrl = tr->ctrl;
489 int i; 566 int i;
490 /* 567 /*
491 * Run a selftest on this tracer. 568 * Run a selftest on this tracer.
@@ -494,25 +571,23 @@ int register_tracer(struct tracer *type)
494 * internal tracing to verify that everything is in order. 571 * internal tracing to verify that everything is in order.
495 * If we fail, we do not register this tracer. 572 * If we fail, we do not register this tracer.
496 */ 573 */
497 for_each_tracing_cpu(i) { 574 for_each_tracing_cpu(i)
498 tracing_reset(tr, i); 575 tracing_reset(tr, i);
499 } 576
500 current_trace = type; 577 current_trace = type;
501 tr->ctrl = 0;
502 /* the test is responsible for initializing and enabling */ 578 /* the test is responsible for initializing and enabling */
503 pr_info("Testing tracer %s: ", type->name); 579 pr_info("Testing tracer %s: ", type->name);
504 ret = type->selftest(type, tr); 580 ret = type->selftest(type, tr);
505 /* the test is responsible for resetting too */ 581 /* the test is responsible for resetting too */
506 current_trace = saved_tracer; 582 current_trace = saved_tracer;
507 tr->ctrl = saved_ctrl;
508 if (ret) { 583 if (ret) {
509 printk(KERN_CONT "FAILED!\n"); 584 printk(KERN_CONT "FAILED!\n");
510 goto out; 585 goto out;
511 } 586 }
512 /* Only reset on passing, to avoid touching corrupted buffers */ 587 /* Only reset on passing, to avoid touching corrupted buffers */
513 for_each_tracing_cpu(i) { 588 for_each_tracing_cpu(i)
514 tracing_reset(tr, i); 589 tracing_reset(tr, i);
515 } 590
516 printk(KERN_CONT "PASSED\n"); 591 printk(KERN_CONT "PASSED\n");
517 } 592 }
518#endif 593#endif
@@ -525,6 +600,7 @@ int register_tracer(struct tracer *type)
525 600
526 out: 601 out:
527 mutex_unlock(&trace_types_lock); 602 mutex_unlock(&trace_types_lock);
603 lock_kernel();
528 604
529 return ret; 605 return ret;
530} 606}
@@ -581,6 +657,76 @@ static void trace_init_cmdlines(void)
581 cmdline_idx = 0; 657 cmdline_idx = 0;
582} 658}
583 659
660static int trace_stop_count;
661static DEFINE_SPINLOCK(tracing_start_lock);
662
663/**
664 * tracing_start - quick start of the tracer
665 *
666 * If tracing is enabled but was stopped by tracing_stop,
667 * this will start the tracer back up.
668 */
669void tracing_start(void)
670{
671 struct ring_buffer *buffer;
672 unsigned long flags;
673
674 if (tracing_disabled)
675 return;
676
677 spin_lock_irqsave(&tracing_start_lock, flags);
678 if (--trace_stop_count)
679 goto out;
680
681 if (trace_stop_count < 0) {
682 /* Someone screwed up their debugging */
683 WARN_ON_ONCE(1);
684 trace_stop_count = 0;
685 goto out;
686 }
687
688
689 buffer = global_trace.buffer;
690 if (buffer)
691 ring_buffer_record_enable(buffer);
692
693 buffer = max_tr.buffer;
694 if (buffer)
695 ring_buffer_record_enable(buffer);
696
697 ftrace_start();
698 out:
699 spin_unlock_irqrestore(&tracing_start_lock, flags);
700}
701
702/**
703 * tracing_stop - quick stop of the tracer
704 *
705 * Light weight way to stop tracing. Use in conjunction with
706 * tracing_start.
707 */
708void tracing_stop(void)
709{
710 struct ring_buffer *buffer;
711 unsigned long flags;
712
713 ftrace_stop();
714 spin_lock_irqsave(&tracing_start_lock, flags);
715 if (trace_stop_count++)
716 goto out;
717
718 buffer = global_trace.buffer;
719 if (buffer)
720 ring_buffer_record_disable(buffer);
721
722 buffer = max_tr.buffer;
723 if (buffer)
724 ring_buffer_record_disable(buffer);
725
726 out:
727 spin_unlock_irqrestore(&tracing_start_lock, flags);
728}
729
584void trace_stop_cmdline_recording(void); 730void trace_stop_cmdline_recording(void);
585 731
586static void trace_save_cmdline(struct task_struct *tsk) 732static void trace_save_cmdline(struct task_struct *tsk)
@@ -691,6 +837,36 @@ trace_function(struct trace_array *tr, struct trace_array_cpu *data,
691 ring_buffer_unlock_commit(tr->buffer, event, irq_flags); 837 ring_buffer_unlock_commit(tr->buffer, event, irq_flags);
692} 838}
693 839
840#ifdef CONFIG_FUNCTION_RET_TRACER
841static void __trace_function_return(struct trace_array *tr,
842 struct trace_array_cpu *data,
843 struct ftrace_retfunc *trace,
844 unsigned long flags,
845 int pc)
846{
847 struct ring_buffer_event *event;
848 struct ftrace_ret_entry *entry;
849 unsigned long irq_flags;
850
851 if (unlikely(local_read(&__get_cpu_var(ftrace_cpu_disabled))))
852 return;
853
854 event = ring_buffer_lock_reserve(global_trace.buffer, sizeof(*entry),
855 &irq_flags);
856 if (!event)
857 return;
858 entry = ring_buffer_event_data(event);
859 tracing_generic_entry_update(&entry->ent, flags, pc);
860 entry->ent.type = TRACE_FN_RET;
861 entry->ip = trace->func;
862 entry->parent_ip = trace->ret;
863 entry->rettime = trace->rettime;
864 entry->calltime = trace->calltime;
865 entry->overrun = trace->overrun;
866 ring_buffer_unlock_commit(global_trace.buffer, event, irq_flags);
867}
868#endif
869
694void 870void
695ftrace(struct trace_array *tr, struct trace_array_cpu *data, 871ftrace(struct trace_array *tr, struct trace_array_cpu *data,
696 unsigned long ip, unsigned long parent_ip, unsigned long flags, 872 unsigned long ip, unsigned long parent_ip, unsigned long flags,
@@ -841,26 +1017,28 @@ ftrace_special(unsigned long arg1, unsigned long arg2, unsigned long arg3)
841{ 1017{
842 struct trace_array *tr = &global_trace; 1018 struct trace_array *tr = &global_trace;
843 struct trace_array_cpu *data; 1019 struct trace_array_cpu *data;
1020 unsigned long flags;
844 int cpu; 1021 int cpu;
845 int pc; 1022 int pc;
846 1023
847 if (tracing_disabled || !tr->ctrl) 1024 if (tracing_disabled)
848 return; 1025 return;
849 1026
850 pc = preempt_count(); 1027 pc = preempt_count();
851 preempt_disable_notrace(); 1028 local_irq_save(flags);
852 cpu = raw_smp_processor_id(); 1029 cpu = raw_smp_processor_id();
853 data = tr->data[cpu]; 1030 data = tr->data[cpu];
854 1031
855 if (likely(!atomic_read(&data->disabled))) 1032 if (likely(atomic_inc_return(&data->disabled) == 1))
856 ftrace_trace_special(tr, data, arg1, arg2, arg3, pc); 1033 ftrace_trace_special(tr, data, arg1, arg2, arg3, pc);
857 1034
858 preempt_enable_notrace(); 1035 atomic_dec(&data->disabled);
1036 local_irq_restore(flags);
859} 1037}
860 1038
861#ifdef CONFIG_FUNCTION_TRACER 1039#ifdef CONFIG_FUNCTION_TRACER
862static void 1040static void
863function_trace_call(unsigned long ip, unsigned long parent_ip) 1041function_trace_call_preempt_only(unsigned long ip, unsigned long parent_ip)
864{ 1042{
865 struct trace_array *tr = &global_trace; 1043 struct trace_array *tr = &global_trace;
866 struct trace_array_cpu *data; 1044 struct trace_array_cpu *data;
@@ -873,8 +1051,7 @@ function_trace_call(unsigned long ip, unsigned long parent_ip)
873 return; 1051 return;
874 1052
875 pc = preempt_count(); 1053 pc = preempt_count();
876 resched = need_resched(); 1054 resched = ftrace_preempt_disable();
877 preempt_disable_notrace();
878 local_save_flags(flags); 1055 local_save_flags(flags);
879 cpu = raw_smp_processor_id(); 1056 cpu = raw_smp_processor_id();
880 data = tr->data[cpu]; 1057 data = tr->data[cpu];
@@ -884,12 +1061,63 @@ function_trace_call(unsigned long ip, unsigned long parent_ip)
884 trace_function(tr, data, ip, parent_ip, flags, pc); 1061 trace_function(tr, data, ip, parent_ip, flags, pc);
885 1062
886 atomic_dec(&data->disabled); 1063 atomic_dec(&data->disabled);
887 if (resched) 1064 ftrace_preempt_enable(resched);
888 preempt_enable_no_resched_notrace(); 1065}
889 else 1066
890 preempt_enable_notrace(); 1067static void
1068function_trace_call(unsigned long ip, unsigned long parent_ip)
1069{
1070 struct trace_array *tr = &global_trace;
1071 struct trace_array_cpu *data;
1072 unsigned long flags;
1073 long disabled;
1074 int cpu;
1075 int pc;
1076
1077 if (unlikely(!ftrace_function_enabled))
1078 return;
1079
1080 /*
1081 * Need to use raw, since this must be called before the
1082 * recursive protection is performed.
1083 */
1084 local_irq_save(flags);
1085 cpu = raw_smp_processor_id();
1086 data = tr->data[cpu];
1087 disabled = atomic_inc_return(&data->disabled);
1088
1089 if (likely(disabled == 1)) {
1090 pc = preempt_count();
1091 trace_function(tr, data, ip, parent_ip, flags, pc);
1092 }
1093
1094 atomic_dec(&data->disabled);
1095 local_irq_restore(flags);
891} 1096}
892 1097
1098#ifdef CONFIG_FUNCTION_RET_TRACER
1099void trace_function_return(struct ftrace_retfunc *trace)
1100{
1101 struct trace_array *tr = &global_trace;
1102 struct trace_array_cpu *data;
1103 unsigned long flags;
1104 long disabled;
1105 int cpu;
1106 int pc;
1107
1108 raw_local_irq_save(flags);
1109 cpu = raw_smp_processor_id();
1110 data = tr->data[cpu];
1111 disabled = atomic_inc_return(&data->disabled);
1112 if (likely(disabled == 1)) {
1113 pc = preempt_count();
1114 __trace_function_return(tr, data, trace, flags, pc);
1115 }
1116 atomic_dec(&data->disabled);
1117 raw_local_irq_restore(flags);
1118}
1119#endif /* CONFIG_FUNCTION_RET_TRACER */
1120
893static struct ftrace_ops trace_ops __read_mostly = 1121static struct ftrace_ops trace_ops __read_mostly =
894{ 1122{
895 .func = function_trace_call, 1123 .func = function_trace_call,
@@ -898,9 +1126,14 @@ static struct ftrace_ops trace_ops __read_mostly =
898void tracing_start_function_trace(void) 1126void tracing_start_function_trace(void)
899{ 1127{
900 ftrace_function_enabled = 0; 1128 ftrace_function_enabled = 0;
1129
1130 if (trace_flags & TRACE_ITER_PREEMPTONLY)
1131 trace_ops.func = function_trace_call_preempt_only;
1132 else
1133 trace_ops.func = function_trace_call;
1134
901 register_ftrace_function(&trace_ops); 1135 register_ftrace_function(&trace_ops);
902 if (tracer_enabled) 1136 ftrace_function_enabled = 1;
903 ftrace_function_enabled = 1;
904} 1137}
905 1138
906void tracing_stop_function_trace(void) 1139void tracing_stop_function_trace(void)
@@ -912,6 +1145,7 @@ void tracing_stop_function_trace(void)
912 1145
913enum trace_file_type { 1146enum trace_file_type {
914 TRACE_FILE_LAT_FMT = 1, 1147 TRACE_FILE_LAT_FMT = 1,
1148 TRACE_FILE_ANNOTATE = 2,
915}; 1149};
916 1150
917static void trace_iterator_increment(struct trace_iterator *iter, int cpu) 1151static void trace_iterator_increment(struct trace_iterator *iter, int cpu)
@@ -1047,10 +1281,6 @@ static void *s_start(struct seq_file *m, loff_t *pos)
1047 1281
1048 atomic_inc(&trace_record_cmdline_disabled); 1282 atomic_inc(&trace_record_cmdline_disabled);
1049 1283
1050 /* let the tracer grab locks here if needed */
1051 if (current_trace->start)
1052 current_trace->start(iter);
1053
1054 if (*pos != iter->pos) { 1284 if (*pos != iter->pos) {
1055 iter->ent = NULL; 1285 iter->ent = NULL;
1056 iter->cpu = 0; 1286 iter->cpu = 0;
@@ -1077,14 +1307,7 @@ static void *s_start(struct seq_file *m, loff_t *pos)
1077 1307
1078static void s_stop(struct seq_file *m, void *p) 1308static void s_stop(struct seq_file *m, void *p)
1079{ 1309{
1080 struct trace_iterator *iter = m->private;
1081
1082 atomic_dec(&trace_record_cmdline_disabled); 1310 atomic_dec(&trace_record_cmdline_disabled);
1083
1084 /* let the tracer release locks here if needed */
1085 if (current_trace && current_trace == iter->trace && iter->trace->stop)
1086 iter->trace->stop(iter);
1087
1088 mutex_unlock(&trace_types_lock); 1311 mutex_unlock(&trace_types_lock);
1089} 1312}
1090 1313
@@ -1143,7 +1366,7 @@ seq_print_sym_offset(struct trace_seq *s, const char *fmt,
1143# define IP_FMT "%016lx" 1366# define IP_FMT "%016lx"
1144#endif 1367#endif
1145 1368
1146static int 1369int
1147seq_print_ip_sym(struct trace_seq *s, unsigned long ip, unsigned long sym_flags) 1370seq_print_ip_sym(struct trace_seq *s, unsigned long ip, unsigned long sym_flags)
1148{ 1371{
1149 int ret; 1372 int ret;
@@ -1338,6 +1561,23 @@ void trace_seq_print_cont(struct trace_seq *s, struct trace_iterator *iter)
1338 trace_seq_putc(s, '\n'); 1561 trace_seq_putc(s, '\n');
1339} 1562}
1340 1563
1564static void test_cpu_buff_start(struct trace_iterator *iter)
1565{
1566 struct trace_seq *s = &iter->seq;
1567
1568 if (!(trace_flags & TRACE_ITER_ANNOTATE))
1569 return;
1570
1571 if (!(iter->iter_flags & TRACE_FILE_ANNOTATE))
1572 return;
1573
1574 if (cpu_isset(iter->cpu, iter->started))
1575 return;
1576
1577 cpu_set(iter->cpu, iter->started);
1578 trace_seq_printf(s, "##### CPU %u buffer started ####\n", iter->cpu);
1579}
1580
1341static enum print_line_t 1581static enum print_line_t
1342print_lat_fmt(struct trace_iterator *iter, unsigned int trace_idx, int cpu) 1582print_lat_fmt(struct trace_iterator *iter, unsigned int trace_idx, int cpu)
1343{ 1583{
@@ -1357,6 +1597,8 @@ print_lat_fmt(struct trace_iterator *iter, unsigned int trace_idx, int cpu)
1357 if (entry->type == TRACE_CONT) 1597 if (entry->type == TRACE_CONT)
1358 return TRACE_TYPE_HANDLED; 1598 return TRACE_TYPE_HANDLED;
1359 1599
1600 test_cpu_buff_start(iter);
1601
1360 next_entry = find_next_entry(iter, NULL, &next_ts); 1602 next_entry = find_next_entry(iter, NULL, &next_ts);
1361 if (!next_entry) 1603 if (!next_entry)
1362 next_ts = iter->ts; 1604 next_ts = iter->ts;
@@ -1448,6 +1690,18 @@ print_lat_fmt(struct trace_iterator *iter, unsigned int trace_idx, int cpu)
1448 trace_seq_print_cont(s, iter); 1690 trace_seq_print_cont(s, iter);
1449 break; 1691 break;
1450 } 1692 }
1693 case TRACE_BRANCH: {
1694 struct trace_branch *field;
1695
1696 trace_assign_type(field, entry);
1697
1698 trace_seq_printf(s, "[%s] %s:%s:%d\n",
1699 field->correct ? " ok " : " MISS ",
1700 field->func,
1701 field->file,
1702 field->line);
1703 break;
1704 }
1451 default: 1705 default:
1452 trace_seq_printf(s, "Unknown type %d\n", entry->type); 1706 trace_seq_printf(s, "Unknown type %d\n", entry->type);
1453 } 1707 }
@@ -1472,6 +1726,8 @@ static enum print_line_t print_trace_fmt(struct trace_iterator *iter)
1472 if (entry->type == TRACE_CONT) 1726 if (entry->type == TRACE_CONT)
1473 return TRACE_TYPE_HANDLED; 1727 return TRACE_TYPE_HANDLED;
1474 1728
1729 test_cpu_buff_start(iter);
1730
1475 comm = trace_find_cmdline(iter->ent->pid); 1731 comm = trace_find_cmdline(iter->ent->pid);
1476 1732
1477 t = ns2usecs(iter->ts); 1733 t = ns2usecs(iter->ts);
@@ -1581,6 +1837,22 @@ static enum print_line_t print_trace_fmt(struct trace_iterator *iter)
1581 trace_seq_print_cont(s, iter); 1837 trace_seq_print_cont(s, iter);
1582 break; 1838 break;
1583 } 1839 }
1840 case TRACE_FN_RET: {
1841 return print_return_function(iter);
1842 break;
1843 }
1844 case TRACE_BRANCH: {
1845 struct trace_branch *field;
1846
1847 trace_assign_type(field, entry);
1848
1849 trace_seq_printf(s, "[%s] %s:%s:%d\n",
1850 field->correct ? " ok " : " MISS ",
1851 field->func,
1852 field->file,
1853 field->line);
1854 break;
1855 }
1584 } 1856 }
1585 return TRACE_TYPE_HANDLED; 1857 return TRACE_TYPE_HANDLED;
1586} 1858}
@@ -1899,6 +2171,11 @@ __tracing_open(struct inode *inode, struct file *file, int *ret)
1899 iter->trace = current_trace; 2171 iter->trace = current_trace;
1900 iter->pos = -1; 2172 iter->pos = -1;
1901 2173
2174 /* Annotate start of buffers if we had overruns */
2175 if (ring_buffer_overruns(iter->tr->buffer))
2176 iter->iter_flags |= TRACE_FILE_ANNOTATE;
2177
2178
1902 for_each_tracing_cpu(cpu) { 2179 for_each_tracing_cpu(cpu) {
1903 2180
1904 iter->buffer_iter[cpu] = 2181 iter->buffer_iter[cpu] =
@@ -1917,10 +2194,7 @@ __tracing_open(struct inode *inode, struct file *file, int *ret)
1917 m->private = iter; 2194 m->private = iter;
1918 2195
1919 /* stop the trace while dumping */ 2196 /* stop the trace while dumping */
1920 if (iter->tr->ctrl) { 2197 tracing_stop();
1921 tracer_enabled = 0;
1922 ftrace_function_enabled = 0;
1923 }
1924 2198
1925 if (iter->trace && iter->trace->open) 2199 if (iter->trace && iter->trace->open)
1926 iter->trace->open(iter); 2200 iter->trace->open(iter);
@@ -1936,6 +2210,7 @@ __tracing_open(struct inode *inode, struct file *file, int *ret)
1936 ring_buffer_read_finish(iter->buffer_iter[cpu]); 2210 ring_buffer_read_finish(iter->buffer_iter[cpu]);
1937 } 2211 }
1938 mutex_unlock(&trace_types_lock); 2212 mutex_unlock(&trace_types_lock);
2213 kfree(iter);
1939 2214
1940 return ERR_PTR(-ENOMEM); 2215 return ERR_PTR(-ENOMEM);
1941} 2216}
@@ -1965,14 +2240,7 @@ int tracing_release(struct inode *inode, struct file *file)
1965 iter->trace->close(iter); 2240 iter->trace->close(iter);
1966 2241
1967 /* reenable tracing if it was previously enabled */ 2242 /* reenable tracing if it was previously enabled */
1968 if (iter->tr->ctrl) { 2243 tracing_start();
1969 tracer_enabled = 1;
1970 /*
1971 * It is safe to enable function tracing even if it
1972 * isn't used
1973 */
1974 ftrace_function_enabled = 1;
1975 }
1976 mutex_unlock(&trace_types_lock); 2244 mutex_unlock(&trace_types_lock);
1977 2245
1978 seq_release(inode, file); 2246 seq_release(inode, file);
@@ -2188,13 +2456,16 @@ static struct file_operations tracing_cpumask_fops = {
2188}; 2456};
2189 2457
2190static ssize_t 2458static ssize_t
2191tracing_iter_ctrl_read(struct file *filp, char __user *ubuf, 2459tracing_trace_options_read(struct file *filp, char __user *ubuf,
2192 size_t cnt, loff_t *ppos) 2460 size_t cnt, loff_t *ppos)
2193{ 2461{
2462 int i;
2194 char *buf; 2463 char *buf;
2195 int r = 0; 2464 int r = 0;
2196 int len = 0; 2465 int len = 0;
2197 int i; 2466 u32 tracer_flags = current_trace->flags->val;
2467 struct tracer_opt *trace_opts = current_trace->flags->opts;
2468
2198 2469
2199 /* calulate max size */ 2470 /* calulate max size */
2200 for (i = 0; trace_options[i]; i++) { 2471 for (i = 0; trace_options[i]; i++) {
@@ -2202,6 +2473,15 @@ tracing_iter_ctrl_read(struct file *filp, char __user *ubuf,
2202 len += 3; /* "no" and space */ 2473 len += 3; /* "no" and space */
2203 } 2474 }
2204 2475
2476 /*
2477 * Increase the size with names of options specific
2478 * of the current tracer.
2479 */
2480 for (i = 0; trace_opts[i].name; i++) {
2481 len += strlen(trace_opts[i].name);
2482 len += 3; /* "no" and space */
2483 }
2484
2205 /* +2 for \n and \0 */ 2485 /* +2 for \n and \0 */
2206 buf = kmalloc(len + 2, GFP_KERNEL); 2486 buf = kmalloc(len + 2, GFP_KERNEL);
2207 if (!buf) 2487 if (!buf)
@@ -2214,6 +2494,15 @@ tracing_iter_ctrl_read(struct file *filp, char __user *ubuf,
2214 r += sprintf(buf + r, "no%s ", trace_options[i]); 2494 r += sprintf(buf + r, "no%s ", trace_options[i]);
2215 } 2495 }
2216 2496
2497 for (i = 0; trace_opts[i].name; i++) {
2498 if (tracer_flags & trace_opts[i].bit)
2499 r += sprintf(buf + r, "%s ",
2500 trace_opts[i].name);
2501 else
2502 r += sprintf(buf + r, "no%s ",
2503 trace_opts[i].name);
2504 }
2505
2217 r += sprintf(buf + r, "\n"); 2506 r += sprintf(buf + r, "\n");
2218 WARN_ON(r >= len + 2); 2507 WARN_ON(r >= len + 2);
2219 2508
@@ -2224,13 +2513,48 @@ tracing_iter_ctrl_read(struct file *filp, char __user *ubuf,
2224 return r; 2513 return r;
2225} 2514}
2226 2515
2516/* Try to assign a tracer specific option */
2517static int set_tracer_option(struct tracer *trace, char *cmp, int neg)
2518{
2519 struct tracer_flags *trace_flags = trace->flags;
2520 struct tracer_opt *opts = NULL;
2521 int ret = 0, i = 0;
2522 int len;
2523
2524 for (i = 0; trace_flags->opts[i].name; i++) {
2525 opts = &trace_flags->opts[i];
2526 len = strlen(opts->name);
2527
2528 if (strncmp(cmp, opts->name, len) == 0) {
2529 ret = trace->set_flag(trace_flags->val,
2530 opts->bit, !neg);
2531 break;
2532 }
2533 }
2534 /* Not found */
2535 if (!trace_flags->opts[i].name)
2536 return -EINVAL;
2537
2538 /* Refused to handle */
2539 if (ret)
2540 return ret;
2541
2542 if (neg)
2543 trace_flags->val &= ~opts->bit;
2544 else
2545 trace_flags->val |= opts->bit;
2546
2547 return 0;
2548}
2549
2227static ssize_t 2550static ssize_t
2228tracing_iter_ctrl_write(struct file *filp, const char __user *ubuf, 2551tracing_trace_options_write(struct file *filp, const char __user *ubuf,
2229 size_t cnt, loff_t *ppos) 2552 size_t cnt, loff_t *ppos)
2230{ 2553{
2231 char buf[64]; 2554 char buf[64];
2232 char *cmp = buf; 2555 char *cmp = buf;
2233 int neg = 0; 2556 int neg = 0;
2557 int ret;
2234 int i; 2558 int i;
2235 2559
2236 if (cnt >= sizeof(buf)) 2560 if (cnt >= sizeof(buf))
@@ -2257,11 +2581,13 @@ tracing_iter_ctrl_write(struct file *filp, const char __user *ubuf,
2257 break; 2581 break;
2258 } 2582 }
2259 } 2583 }
2260 /* 2584
2261 * If no option could be set, return an error: 2585 /* If no option could be set, test the specific tracer options */
2262 */ 2586 if (!trace_options[i]) {
2263 if (!trace_options[i]) 2587 ret = set_tracer_option(current_trace, cmp, neg);
2264 return -EINVAL; 2588 if (ret)
2589 return ret;
2590 }
2265 2591
2266 filp->f_pos += cnt; 2592 filp->f_pos += cnt;
2267 2593
@@ -2270,8 +2596,8 @@ tracing_iter_ctrl_write(struct file *filp, const char __user *ubuf,
2270 2596
2271static struct file_operations tracing_iter_fops = { 2597static struct file_operations tracing_iter_fops = {
2272 .open = tracing_open_generic, 2598 .open = tracing_open_generic,
2273 .read = tracing_iter_ctrl_read, 2599 .read = tracing_trace_options_read,
2274 .write = tracing_iter_ctrl_write, 2600 .write = tracing_trace_options_write,
2275}; 2601};
2276 2602
2277static const char readme_msg[] = 2603static const char readme_msg[] =
@@ -2285,9 +2611,9 @@ static const char readme_msg[] =
2285 "# echo sched_switch > /debug/tracing/current_tracer\n" 2611 "# echo sched_switch > /debug/tracing/current_tracer\n"
2286 "# cat /debug/tracing/current_tracer\n" 2612 "# cat /debug/tracing/current_tracer\n"
2287 "sched_switch\n" 2613 "sched_switch\n"
2288 "# cat /debug/tracing/iter_ctrl\n" 2614 "# cat /debug/tracing/trace_options\n"
2289 "noprint-parent nosym-offset nosym-addr noverbose\n" 2615 "noprint-parent nosym-offset nosym-addr noverbose\n"
2290 "# echo print-parent > /debug/tracing/iter_ctrl\n" 2616 "# echo print-parent > /debug/tracing/trace_options\n"
2291 "# echo 1 > /debug/tracing/tracing_enabled\n" 2617 "# echo 1 > /debug/tracing/tracing_enabled\n"
2292 "# cat /debug/tracing/trace > /tmp/trace.txt\n" 2618 "# cat /debug/tracing/trace > /tmp/trace.txt\n"
2293 "echo 0 > /debug/tracing/tracing_enabled\n" 2619 "echo 0 > /debug/tracing/tracing_enabled\n"
@@ -2310,11 +2636,10 @@ static ssize_t
2310tracing_ctrl_read(struct file *filp, char __user *ubuf, 2636tracing_ctrl_read(struct file *filp, char __user *ubuf,
2311 size_t cnt, loff_t *ppos) 2637 size_t cnt, loff_t *ppos)
2312{ 2638{
2313 struct trace_array *tr = filp->private_data;
2314 char buf[64]; 2639 char buf[64];
2315 int r; 2640 int r;
2316 2641
2317 r = sprintf(buf, "%ld\n", tr->ctrl); 2642 r = sprintf(buf, "%u\n", tracer_enabled);
2318 return simple_read_from_buffer(ubuf, cnt, ppos, buf, r); 2643 return simple_read_from_buffer(ubuf, cnt, ppos, buf, r);
2319} 2644}
2320 2645
@@ -2342,16 +2667,18 @@ tracing_ctrl_write(struct file *filp, const char __user *ubuf,
2342 val = !!val; 2667 val = !!val;
2343 2668
2344 mutex_lock(&trace_types_lock); 2669 mutex_lock(&trace_types_lock);
2345 if (tr->ctrl ^ val) { 2670 if (tracer_enabled ^ val) {
2346 if (val) 2671 if (val) {
2347 tracer_enabled = 1; 2672 tracer_enabled = 1;
2348 else 2673 if (current_trace->start)
2674 current_trace->start(tr);
2675 tracing_start();
2676 } else {
2349 tracer_enabled = 0; 2677 tracer_enabled = 0;
2350 2678 tracing_stop();
2351 tr->ctrl = val; 2679 if (current_trace->stop)
2352 2680 current_trace->stop(tr);
2353 if (current_trace && current_trace->ctrl_update) 2681 }
2354 current_trace->ctrl_update(tr);
2355 } 2682 }
2356 mutex_unlock(&trace_types_lock); 2683 mutex_unlock(&trace_types_lock);
2357 2684
@@ -2377,29 +2704,11 @@ tracing_set_trace_read(struct file *filp, char __user *ubuf,
2377 return simple_read_from_buffer(ubuf, cnt, ppos, buf, r); 2704 return simple_read_from_buffer(ubuf, cnt, ppos, buf, r);
2378} 2705}
2379 2706
2380static ssize_t 2707static int tracing_set_tracer(char *buf)
2381tracing_set_trace_write(struct file *filp, const char __user *ubuf,
2382 size_t cnt, loff_t *ppos)
2383{ 2708{
2384 struct trace_array *tr = &global_trace; 2709 struct trace_array *tr = &global_trace;
2385 struct tracer *t; 2710 struct tracer *t;
2386 char buf[max_tracer_type_len+1]; 2711 int ret = 0;
2387 int i;
2388 size_t ret;
2389
2390 ret = cnt;
2391
2392 if (cnt > max_tracer_type_len)
2393 cnt = max_tracer_type_len;
2394
2395 if (copy_from_user(&buf, ubuf, cnt))
2396 return -EFAULT;
2397
2398 buf[cnt] = 0;
2399
2400 /* strip ending whitespace. */
2401 for (i = cnt - 1; i > 0 && isspace(buf[i]); i--)
2402 buf[i] = 0;
2403 2712
2404 mutex_lock(&trace_types_lock); 2713 mutex_lock(&trace_types_lock);
2405 for (t = trace_types; t; t = t->next) { 2714 for (t = trace_types; t; t = t->next) {
@@ -2413,18 +2722,52 @@ tracing_set_trace_write(struct file *filp, const char __user *ubuf,
2413 if (t == current_trace) 2722 if (t == current_trace)
2414 goto out; 2723 goto out;
2415 2724
2725 trace_branch_disable();
2416 if (current_trace && current_trace->reset) 2726 if (current_trace && current_trace->reset)
2417 current_trace->reset(tr); 2727 current_trace->reset(tr);
2418 2728
2419 current_trace = t; 2729 current_trace = t;
2420 if (t->init) 2730 if (t->init) {
2421 t->init(tr); 2731 ret = t->init(tr);
2732 if (ret)
2733 goto out;
2734 }
2422 2735
2736 trace_branch_enable(tr);
2423 out: 2737 out:
2424 mutex_unlock(&trace_types_lock); 2738 mutex_unlock(&trace_types_lock);
2425 2739
2426 if (ret > 0) 2740 return ret;
2427 filp->f_pos += ret; 2741}
2742
2743static ssize_t
2744tracing_set_trace_write(struct file *filp, const char __user *ubuf,
2745 size_t cnt, loff_t *ppos)
2746{
2747 char buf[max_tracer_type_len+1];
2748 int i;
2749 size_t ret;
2750 int err;
2751
2752 ret = cnt;
2753
2754 if (cnt > max_tracer_type_len)
2755 cnt = max_tracer_type_len;
2756
2757 if (copy_from_user(&buf, ubuf, cnt))
2758 return -EFAULT;
2759
2760 buf[cnt] = 0;
2761
2762 /* strip ending whitespace. */
2763 for (i = cnt - 1; i > 0 && isspace(buf[i]); i--)
2764 buf[i] = 0;
2765
2766 err = tracing_set_tracer(buf);
2767 if (err)
2768 return err;
2769
2770 filp->f_pos += ret;
2428 2771
2429 return ret; 2772 return ret;
2430} 2773}
@@ -2491,6 +2834,10 @@ static int tracing_open_pipe(struct inode *inode, struct file *filp)
2491 return -ENOMEM; 2834 return -ENOMEM;
2492 2835
2493 mutex_lock(&trace_types_lock); 2836 mutex_lock(&trace_types_lock);
2837
2838 /* trace pipe does not show start of buffer */
2839 cpus_setall(iter->started);
2840
2494 iter->tr = &global_trace; 2841 iter->tr = &global_trace;
2495 iter->trace = current_trace; 2842 iter->trace = current_trace;
2496 filp->private_data = iter; 2843 filp->private_data = iter;
@@ -2666,7 +3013,7 @@ tracing_entries_read(struct file *filp, char __user *ubuf,
2666 char buf[64]; 3013 char buf[64];
2667 int r; 3014 int r;
2668 3015
2669 r = sprintf(buf, "%lu\n", tr->entries); 3016 r = sprintf(buf, "%lu\n", tr->entries >> 10);
2670 return simple_read_from_buffer(ubuf, cnt, ppos, buf, r); 3017 return simple_read_from_buffer(ubuf, cnt, ppos, buf, r);
2671} 3018}
2672 3019
@@ -2677,7 +3024,6 @@ tracing_entries_write(struct file *filp, const char __user *ubuf,
2677 unsigned long val; 3024 unsigned long val;
2678 char buf[64]; 3025 char buf[64];
2679 int ret, cpu; 3026 int ret, cpu;
2680 struct trace_array *tr = filp->private_data;
2681 3027
2682 if (cnt >= sizeof(buf)) 3028 if (cnt >= sizeof(buf))
2683 return -EINVAL; 3029 return -EINVAL;
@@ -2697,12 +3043,7 @@ tracing_entries_write(struct file *filp, const char __user *ubuf,
2697 3043
2698 mutex_lock(&trace_types_lock); 3044 mutex_lock(&trace_types_lock);
2699 3045
2700 if (tr->ctrl) { 3046 tracing_stop();
2701 cnt = -EBUSY;
2702 pr_info("ftrace: please disable tracing"
2703 " before modifying buffer size\n");
2704 goto out;
2705 }
2706 3047
2707 /* disable all cpu buffers */ 3048 /* disable all cpu buffers */
2708 for_each_tracing_cpu(cpu) { 3049 for_each_tracing_cpu(cpu) {
@@ -2712,6 +3053,9 @@ tracing_entries_write(struct file *filp, const char __user *ubuf,
2712 atomic_inc(&max_tr.data[cpu]->disabled); 3053 atomic_inc(&max_tr.data[cpu]->disabled);
2713 } 3054 }
2714 3055
3056 /* value is in KB */
3057 val <<= 10;
3058
2715 if (val != global_trace.entries) { 3059 if (val != global_trace.entries) {
2716 ret = ring_buffer_resize(global_trace.buffer, val); 3060 ret = ring_buffer_resize(global_trace.buffer, val);
2717 if (ret < 0) { 3061 if (ret < 0) {
@@ -2750,6 +3094,7 @@ tracing_entries_write(struct file *filp, const char __user *ubuf,
2750 atomic_dec(&max_tr.data[cpu]->disabled); 3094 atomic_dec(&max_tr.data[cpu]->disabled);
2751 } 3095 }
2752 3096
3097 tracing_start();
2753 max_tr.entries = global_trace.entries; 3098 max_tr.entries = global_trace.entries;
2754 mutex_unlock(&trace_types_lock); 3099 mutex_unlock(&trace_types_lock);
2755 3100
@@ -2772,9 +3117,8 @@ tracing_mark_write(struct file *filp, const char __user *ubuf,
2772{ 3117{
2773 char *buf; 3118 char *buf;
2774 char *end; 3119 char *end;
2775 struct trace_array *tr = &global_trace;
2776 3120
2777 if (!tr->ctrl || tracing_disabled) 3121 if (tracing_disabled)
2778 return -EINVAL; 3122 return -EINVAL;
2779 3123
2780 if (cnt > TRACE_BUF_SIZE) 3124 if (cnt > TRACE_BUF_SIZE)
@@ -2840,22 +3184,38 @@ static struct file_operations tracing_mark_fops = {
2840 3184
2841#ifdef CONFIG_DYNAMIC_FTRACE 3185#ifdef CONFIG_DYNAMIC_FTRACE
2842 3186
3187int __weak ftrace_arch_read_dyn_info(char *buf, int size)
3188{
3189 return 0;
3190}
3191
2843static ssize_t 3192static ssize_t
2844tracing_read_long(struct file *filp, char __user *ubuf, 3193tracing_read_dyn_info(struct file *filp, char __user *ubuf,
2845 size_t cnt, loff_t *ppos) 3194 size_t cnt, loff_t *ppos)
2846{ 3195{
3196 static char ftrace_dyn_info_buffer[1024];
3197 static DEFINE_MUTEX(dyn_info_mutex);
2847 unsigned long *p = filp->private_data; 3198 unsigned long *p = filp->private_data;
2848 char buf[64]; 3199 char *buf = ftrace_dyn_info_buffer;
3200 int size = ARRAY_SIZE(ftrace_dyn_info_buffer);
2849 int r; 3201 int r;
2850 3202
2851 r = sprintf(buf, "%ld\n", *p); 3203 mutex_lock(&dyn_info_mutex);
3204 r = sprintf(buf, "%ld ", *p);
2852 3205
2853 return simple_read_from_buffer(ubuf, cnt, ppos, buf, r); 3206 r += ftrace_arch_read_dyn_info(buf+r, (size-1)-r);
3207 buf[r++] = '\n';
3208
3209 r = simple_read_from_buffer(ubuf, cnt, ppos, buf, r);
3210
3211 mutex_unlock(&dyn_info_mutex);
3212
3213 return r;
2854} 3214}
2855 3215
2856static struct file_operations tracing_read_long_fops = { 3216static struct file_operations tracing_dyn_info_fops = {
2857 .open = tracing_open_generic, 3217 .open = tracing_open_generic,
2858 .read = tracing_read_long, 3218 .read = tracing_read_dyn_info,
2859}; 3219};
2860#endif 3220#endif
2861 3221
@@ -2896,10 +3256,10 @@ static __init int tracer_init_debugfs(void)
2896 if (!entry) 3256 if (!entry)
2897 pr_warning("Could not create debugfs 'tracing_enabled' entry\n"); 3257 pr_warning("Could not create debugfs 'tracing_enabled' entry\n");
2898 3258
2899 entry = debugfs_create_file("iter_ctrl", 0644, d_tracer, 3259 entry = debugfs_create_file("trace_options", 0644, d_tracer,
2900 NULL, &tracing_iter_fops); 3260 NULL, &tracing_iter_fops);
2901 if (!entry) 3261 if (!entry)
2902 pr_warning("Could not create debugfs 'iter_ctrl' entry\n"); 3262 pr_warning("Could not create debugfs 'trace_options' entry\n");
2903 3263
2904 entry = debugfs_create_file("tracing_cpumask", 0644, d_tracer, 3264 entry = debugfs_create_file("tracing_cpumask", 0644, d_tracer,
2905 NULL, &tracing_cpumask_fops); 3265 NULL, &tracing_cpumask_fops);
@@ -2949,11 +3309,11 @@ static __init int tracer_init_debugfs(void)
2949 pr_warning("Could not create debugfs " 3309 pr_warning("Could not create debugfs "
2950 "'trace_pipe' entry\n"); 3310 "'trace_pipe' entry\n");
2951 3311
2952 entry = debugfs_create_file("trace_entries", 0644, d_tracer, 3312 entry = debugfs_create_file("buffer_size_kb", 0644, d_tracer,
2953 &global_trace, &tracing_entries_fops); 3313 &global_trace, &tracing_entries_fops);
2954 if (!entry) 3314 if (!entry)
2955 pr_warning("Could not create debugfs " 3315 pr_warning("Could not create debugfs "
2956 "'trace_entries' entry\n"); 3316 "'buffer_size_kb' entry\n");
2957 3317
2958 entry = debugfs_create_file("trace_marker", 0220, d_tracer, 3318 entry = debugfs_create_file("trace_marker", 0220, d_tracer,
2959 NULL, &tracing_mark_fops); 3319 NULL, &tracing_mark_fops);
@@ -2964,7 +3324,7 @@ static __init int tracer_init_debugfs(void)
2964#ifdef CONFIG_DYNAMIC_FTRACE 3324#ifdef CONFIG_DYNAMIC_FTRACE
2965 entry = debugfs_create_file("dyn_ftrace_total_info", 0444, d_tracer, 3325 entry = debugfs_create_file("dyn_ftrace_total_info", 0444, d_tracer,
2966 &ftrace_update_tot_cnt, 3326 &ftrace_update_tot_cnt,
2967 &tracing_read_long_fops); 3327 &tracing_dyn_info_fops);
2968 if (!entry) 3328 if (!entry)
2969 pr_warning("Could not create debugfs " 3329 pr_warning("Could not create debugfs "
2970 "'dyn_ftrace_total_info' entry\n"); 3330 "'dyn_ftrace_total_info' entry\n");
@@ -2987,7 +3347,7 @@ int trace_vprintk(unsigned long ip, const char *fmt, va_list args)
2987 unsigned long flags, irq_flags; 3347 unsigned long flags, irq_flags;
2988 int cpu, len = 0, size, pc; 3348 int cpu, len = 0, size, pc;
2989 3349
2990 if (!tr->ctrl || tracing_disabled) 3350 if (tracing_disabled)
2991 return 0; 3351 return 0;
2992 3352
2993 pc = preempt_count(); 3353 pc = preempt_count();
@@ -3045,7 +3405,8 @@ EXPORT_SYMBOL_GPL(__ftrace_printk);
3045static int trace_panic_handler(struct notifier_block *this, 3405static int trace_panic_handler(struct notifier_block *this,
3046 unsigned long event, void *unused) 3406 unsigned long event, void *unused)
3047{ 3407{
3048 ftrace_dump(); 3408 if (ftrace_dump_on_oops)
3409 ftrace_dump();
3049 return NOTIFY_OK; 3410 return NOTIFY_OK;
3050} 3411}
3051 3412
@@ -3061,7 +3422,8 @@ static int trace_die_handler(struct notifier_block *self,
3061{ 3422{
3062 switch (val) { 3423 switch (val) {
3063 case DIE_OOPS: 3424 case DIE_OOPS:
3064 ftrace_dump(); 3425 if (ftrace_dump_on_oops)
3426 ftrace_dump();
3065 break; 3427 break;
3066 default: 3428 default:
3067 break; 3429 break;
@@ -3102,7 +3464,6 @@ trace_printk_seq(struct trace_seq *s)
3102 trace_seq_reset(s); 3464 trace_seq_reset(s);
3103} 3465}
3104 3466
3105
3106void ftrace_dump(void) 3467void ftrace_dump(void)
3107{ 3468{
3108 static DEFINE_SPINLOCK(ftrace_dump_lock); 3469 static DEFINE_SPINLOCK(ftrace_dump_lock);
@@ -3220,7 +3581,6 @@ __init static int tracer_alloc_buffers(void)
3220#endif 3581#endif
3221 3582
3222 /* All seems OK, enable tracing */ 3583 /* All seems OK, enable tracing */
3223 global_trace.ctrl = tracer_enabled;
3224 tracing_disabled = 0; 3584 tracing_disabled = 0;
3225 3585
3226 atomic_notifier_chain_register(&panic_notifier_list, 3586 atomic_notifier_chain_register(&panic_notifier_list,
diff --git a/kernel/trace/trace.h b/kernel/trace/trace.h
index 8465ad052707..2cb12fd98f6b 100644
--- a/kernel/trace/trace.h
+++ b/kernel/trace/trace.h
@@ -8,6 +8,7 @@
8#include <linux/ring_buffer.h> 8#include <linux/ring_buffer.h>
9#include <linux/mmiotrace.h> 9#include <linux/mmiotrace.h>
10#include <linux/ftrace.h> 10#include <linux/ftrace.h>
11#include <trace/boot.h>
11 12
12enum trace_type { 13enum trace_type {
13 __TRACE_FIRST_TYPE = 0, 14 __TRACE_FIRST_TYPE = 0,
@@ -21,7 +22,10 @@ enum trace_type {
21 TRACE_SPECIAL, 22 TRACE_SPECIAL,
22 TRACE_MMIO_RW, 23 TRACE_MMIO_RW,
23 TRACE_MMIO_MAP, 24 TRACE_MMIO_MAP,
24 TRACE_BOOT, 25 TRACE_BRANCH,
26 TRACE_BOOT_CALL,
27 TRACE_BOOT_RET,
28 TRACE_FN_RET,
25 29
26 __TRACE_LAST_TYPE 30 __TRACE_LAST_TYPE
27}; 31};
@@ -48,6 +52,16 @@ struct ftrace_entry {
48 unsigned long ip; 52 unsigned long ip;
49 unsigned long parent_ip; 53 unsigned long parent_ip;
50}; 54};
55
56/* Function return entry */
57struct ftrace_ret_entry {
58 struct trace_entry ent;
59 unsigned long ip;
60 unsigned long parent_ip;
61 unsigned long long calltime;
62 unsigned long long rettime;
63 unsigned long overrun;
64};
51extern struct tracer boot_tracer; 65extern struct tracer boot_tracer;
52 66
53/* 67/*
@@ -112,9 +126,24 @@ struct trace_mmiotrace_map {
112 struct mmiotrace_map map; 126 struct mmiotrace_map map;
113}; 127};
114 128
115struct trace_boot { 129struct trace_boot_call {
116 struct trace_entry ent; 130 struct trace_entry ent;
117 struct boot_trace initcall; 131 struct boot_trace_call boot_call;
132};
133
134struct trace_boot_ret {
135 struct trace_entry ent;
136 struct boot_trace_ret boot_ret;
137};
138
139#define TRACE_FUNC_SIZE 30
140#define TRACE_FILE_SIZE 20
141struct trace_branch {
142 struct trace_entry ent;
143 unsigned line;
144 char func[TRACE_FUNC_SIZE+1];
145 char file[TRACE_FILE_SIZE+1];
146 char correct;
118}; 147};
119 148
120/* 149/*
@@ -172,7 +201,6 @@ struct trace_iterator;
172struct trace_array { 201struct trace_array {
173 struct ring_buffer *buffer; 202 struct ring_buffer *buffer;
174 unsigned long entries; 203 unsigned long entries;
175 long ctrl;
176 int cpu; 204 int cpu;
177 cycle_t time_start; 205 cycle_t time_start;
178 struct task_struct *waiter; 206 struct task_struct *waiter;
@@ -218,7 +246,10 @@ extern void __ftrace_bad_type(void);
218 TRACE_MMIO_RW); \ 246 TRACE_MMIO_RW); \
219 IF_ASSIGN(var, ent, struct trace_mmiotrace_map, \ 247 IF_ASSIGN(var, ent, struct trace_mmiotrace_map, \
220 TRACE_MMIO_MAP); \ 248 TRACE_MMIO_MAP); \
221 IF_ASSIGN(var, ent, struct trace_boot, TRACE_BOOT); \ 249 IF_ASSIGN(var, ent, struct trace_boot_call, TRACE_BOOT_CALL);\
250 IF_ASSIGN(var, ent, struct trace_boot_ret, TRACE_BOOT_RET);\
251 IF_ASSIGN(var, ent, struct trace_branch, TRACE_BRANCH); \
252 IF_ASSIGN(var, ent, struct ftrace_ret_entry, TRACE_FN_RET);\
222 __ftrace_bad_type(); \ 253 __ftrace_bad_type(); \
223 } while (0) 254 } while (0)
224 255
@@ -229,29 +260,55 @@ enum print_line_t {
229 TRACE_TYPE_UNHANDLED = 2 /* Relay to other output functions */ 260 TRACE_TYPE_UNHANDLED = 2 /* Relay to other output functions */
230}; 261};
231 262
263
264/*
265 * An option specific to a tracer. This is a boolean value.
266 * The bit is the bit index that sets its value on the
267 * flags value in struct tracer_flags.
268 */
269struct tracer_opt {
270 const char *name; /* Will appear on the trace_options file */
271 u32 bit; /* Mask assigned in val field in tracer_flags */
272};
273
274/*
275 * The set of specific options for a tracer. Your tracer
276 * have to set the initial value of the flags val.
277 */
278struct tracer_flags {
279 u32 val;
280 struct tracer_opt *opts;
281};
282
283/* Makes more easy to define a tracer opt */
284#define TRACER_OPT(s, b) .name = #s, .bit = b
285
232/* 286/*
233 * A specific tracer, represented by methods that operate on a trace array: 287 * A specific tracer, represented by methods that operate on a trace array:
234 */ 288 */
235struct tracer { 289struct tracer {
236 const char *name; 290 const char *name;
237 void (*init)(struct trace_array *tr); 291 /* Your tracer should raise a warning if init fails */
292 int (*init)(struct trace_array *tr);
238 void (*reset)(struct trace_array *tr); 293 void (*reset)(struct trace_array *tr);
294 void (*start)(struct trace_array *tr);
295 void (*stop)(struct trace_array *tr);
239 void (*open)(struct trace_iterator *iter); 296 void (*open)(struct trace_iterator *iter);
240 void (*pipe_open)(struct trace_iterator *iter); 297 void (*pipe_open)(struct trace_iterator *iter);
241 void (*close)(struct trace_iterator *iter); 298 void (*close)(struct trace_iterator *iter);
242 void (*start)(struct trace_iterator *iter);
243 void (*stop)(struct trace_iterator *iter);
244 ssize_t (*read)(struct trace_iterator *iter, 299 ssize_t (*read)(struct trace_iterator *iter,
245 struct file *filp, char __user *ubuf, 300 struct file *filp, char __user *ubuf,
246 size_t cnt, loff_t *ppos); 301 size_t cnt, loff_t *ppos);
247 void (*ctrl_update)(struct trace_array *tr);
248#ifdef CONFIG_FTRACE_STARTUP_TEST 302#ifdef CONFIG_FTRACE_STARTUP_TEST
249 int (*selftest)(struct tracer *trace, 303 int (*selftest)(struct tracer *trace,
250 struct trace_array *tr); 304 struct trace_array *tr);
251#endif 305#endif
252 enum print_line_t (*print_line)(struct trace_iterator *iter); 306 enum print_line_t (*print_line)(struct trace_iterator *iter);
307 /* If you handled the flag setting, return 0 */
308 int (*set_flag)(u32 old_flags, u32 bit, int set);
253 struct tracer *next; 309 struct tracer *next;
254 int print_max; 310 int print_max;
311 struct tracer_flags *flags;
255}; 312};
256 313
257struct trace_seq { 314struct trace_seq {
@@ -279,8 +336,11 @@ struct trace_iterator {
279 unsigned long iter_flags; 336 unsigned long iter_flags;
280 loff_t pos; 337 loff_t pos;
281 long idx; 338 long idx;
339
340 cpumask_t started;
282}; 341};
283 342
343int tracing_is_enabled(void);
284void trace_wake_up(void); 344void trace_wake_up(void);
285void tracing_reset(struct trace_array *tr, int cpu); 345void tracing_reset(struct trace_array *tr, int cpu);
286int tracing_open_generic(struct inode *inode, struct file *filp); 346int tracing_open_generic(struct inode *inode, struct file *filp);
@@ -320,9 +380,14 @@ void trace_function(struct trace_array *tr,
320 unsigned long ip, 380 unsigned long ip,
321 unsigned long parent_ip, 381 unsigned long parent_ip,
322 unsigned long flags, int pc); 382 unsigned long flags, int pc);
383void
384trace_function_return(struct ftrace_retfunc *trace);
323 385
324void tracing_start_cmdline_record(void); 386void tracing_start_cmdline_record(void);
325void tracing_stop_cmdline_record(void); 387void tracing_stop_cmdline_record(void);
388void tracing_sched_switch_assign_trace(struct trace_array *tr);
389void tracing_stop_sched_switch_record(void);
390void tracing_start_sched_switch_record(void);
326int register_tracer(struct tracer *type); 391int register_tracer(struct tracer *type);
327void unregister_tracer(struct tracer *type); 392void unregister_tracer(struct tracer *type);
328 393
@@ -383,12 +448,18 @@ extern int trace_selftest_startup_sched_switch(struct tracer *trace,
383 struct trace_array *tr); 448 struct trace_array *tr);
384extern int trace_selftest_startup_sysprof(struct tracer *trace, 449extern int trace_selftest_startup_sysprof(struct tracer *trace,
385 struct trace_array *tr); 450 struct trace_array *tr);
451extern int trace_selftest_startup_branch(struct tracer *trace,
452 struct trace_array *tr);
386#endif /* CONFIG_FTRACE_STARTUP_TEST */ 453#endif /* CONFIG_FTRACE_STARTUP_TEST */
387 454
388extern void *head_page(struct trace_array_cpu *data); 455extern void *head_page(struct trace_array_cpu *data);
389extern int trace_seq_printf(struct trace_seq *s, const char *fmt, ...); 456extern int trace_seq_printf(struct trace_seq *s, const char *fmt, ...);
390extern void trace_seq_print_cont(struct trace_seq *s, 457extern void trace_seq_print_cont(struct trace_seq *s,
391 struct trace_iterator *iter); 458 struct trace_iterator *iter);
459
460extern int
461seq_print_ip_sym(struct trace_seq *s, unsigned long ip,
462 unsigned long sym_flags);
392extern ssize_t trace_seq_to_user(struct trace_seq *s, char __user *ubuf, 463extern ssize_t trace_seq_to_user(struct trace_seq *s, char __user *ubuf,
393 size_t cnt); 464 size_t cnt);
394extern long ns2usecs(cycle_t nsec); 465extern long ns2usecs(cycle_t nsec);
@@ -396,6 +467,17 @@ extern int trace_vprintk(unsigned long ip, const char *fmt, va_list args);
396 467
397extern unsigned long trace_flags; 468extern unsigned long trace_flags;
398 469
470/* Standard output formatting function used for function return traces */
471#ifdef CONFIG_FUNCTION_RET_TRACER
472extern enum print_line_t print_return_function(struct trace_iterator *iter);
473#else
474static inline enum print_line_t
475print_return_function(struct trace_iterator *iter)
476{
477 return TRACE_TYPE_UNHANDLED;
478}
479#endif
480
399/* 481/*
400 * trace_iterator_flags is an enumeration that defines bit 482 * trace_iterator_flags is an enumeration that defines bit
401 * positions into trace_flags that controls the output. 483 * positions into trace_flags that controls the output.
@@ -415,8 +497,90 @@ enum trace_iterator_flags {
415 TRACE_ITER_STACKTRACE = 0x100, 497 TRACE_ITER_STACKTRACE = 0x100,
416 TRACE_ITER_SCHED_TREE = 0x200, 498 TRACE_ITER_SCHED_TREE = 0x200,
417 TRACE_ITER_PRINTK = 0x400, 499 TRACE_ITER_PRINTK = 0x400,
500 TRACE_ITER_PREEMPTONLY = 0x800,
501 TRACE_ITER_BRANCH = 0x1000,
502 TRACE_ITER_ANNOTATE = 0x2000,
418}; 503};
419 504
505/*
506 * TRACE_ITER_SYM_MASK masks the options in trace_flags that
507 * control the output of kernel symbols.
508 */
509#define TRACE_ITER_SYM_MASK \
510 (TRACE_ITER_PRINT_PARENT|TRACE_ITER_SYM_OFFSET|TRACE_ITER_SYM_ADDR)
511
420extern struct tracer nop_trace; 512extern struct tracer nop_trace;
421 513
514/**
515 * ftrace_preempt_disable - disable preemption scheduler safe
516 *
517 * When tracing can happen inside the scheduler, there exists
518 * cases that the tracing might happen before the need_resched
519 * flag is checked. If this happens and the tracer calls
520 * preempt_enable (after a disable), a schedule might take place
521 * causing an infinite recursion.
522 *
523 * To prevent this, we read the need_recshed flag before
524 * disabling preemption. When we want to enable preemption we
525 * check the flag, if it is set, then we call preempt_enable_no_resched.
526 * Otherwise, we call preempt_enable.
527 *
528 * The rational for doing the above is that if need resched is set
529 * and we have yet to reschedule, we are either in an atomic location
530 * (where we do not need to check for scheduling) or we are inside
531 * the scheduler and do not want to resched.
532 */
533static inline int ftrace_preempt_disable(void)
534{
535 int resched;
536
537 resched = need_resched();
538 preempt_disable_notrace();
539
540 return resched;
541}
542
543/**
544 * ftrace_preempt_enable - enable preemption scheduler safe
545 * @resched: the return value from ftrace_preempt_disable
546 *
547 * This is a scheduler safe way to enable preemption and not miss
548 * any preemption checks. The disabled saved the state of preemption.
549 * If resched is set, then we were either inside an atomic or
550 * are inside the scheduler (we would have already scheduled
551 * otherwise). In this case, we do not want to call normal
552 * preempt_enable, but preempt_enable_no_resched instead.
553 */
554static inline void ftrace_preempt_enable(int resched)
555{
556 if (resched)
557 preempt_enable_no_resched_notrace();
558 else
559 preempt_enable_notrace();
560}
561
562#ifdef CONFIG_BRANCH_TRACER
563extern int enable_branch_tracing(struct trace_array *tr);
564extern void disable_branch_tracing(void);
565static inline int trace_branch_enable(struct trace_array *tr)
566{
567 if (trace_flags & TRACE_ITER_BRANCH)
568 return enable_branch_tracing(tr);
569 return 0;
570}
571static inline void trace_branch_disable(void)
572{
573 /* due to races, always disable */
574 disable_branch_tracing();
575}
576#else
577static inline int trace_branch_enable(struct trace_array *tr)
578{
579 return 0;
580}
581static inline void trace_branch_disable(void)
582{
583}
584#endif /* CONFIG_BRANCH_TRACER */
585
422#endif /* _LINUX_KERNEL_TRACE_H */ 586#endif /* _LINUX_KERNEL_TRACE_H */
diff --git a/kernel/trace/trace_boot.c b/kernel/trace/trace_boot.c
index d0a5e50eeff2..a4fa2c57e34e 100644
--- a/kernel/trace/trace_boot.c
+++ b/kernel/trace/trace_boot.c
@@ -13,73 +13,117 @@
13#include "trace.h" 13#include "trace.h"
14 14
15static struct trace_array *boot_trace; 15static struct trace_array *boot_trace;
16static int trace_boot_enabled; 16static bool pre_initcalls_finished;
17 17
18 18/* Tells the boot tracer that the pre_smp_initcalls are finished.
19/* Should be started after do_pre_smp_initcalls() in init/main.c */ 19 * So we are ready .
20 * It doesn't enable sched events tracing however.
21 * You have to call enable_boot_trace to do so.
22 */
20void start_boot_trace(void) 23void start_boot_trace(void)
21{ 24{
22 trace_boot_enabled = 1; 25 pre_initcalls_finished = true;
23} 26}
24 27
25void stop_boot_trace(void) 28void enable_boot_trace(void)
26{ 29{
27 trace_boot_enabled = 0; 30 if (pre_initcalls_finished)
31 tracing_start_sched_switch_record();
28} 32}
29 33
30void reset_boot_trace(struct trace_array *tr) 34void disable_boot_trace(void)
31{ 35{
32 stop_boot_trace(); 36 if (pre_initcalls_finished)
37 tracing_stop_sched_switch_record();
33} 38}
34 39
35static void boot_trace_init(struct trace_array *tr) 40static void reset_boot_trace(struct trace_array *tr)
36{ 41{
37 int cpu; 42 int cpu;
38 boot_trace = tr;
39 43
40 trace_boot_enabled = 0; 44 tr->time_start = ftrace_now(tr->cpu);
45
46 for_each_online_cpu(cpu)
47 tracing_reset(tr, cpu);
48}
49
50static int boot_trace_init(struct trace_array *tr)
51{
52 int cpu;
53 boot_trace = tr;
41 54
42 for_each_cpu_mask(cpu, cpu_possible_map) 55 for_each_cpu_mask(cpu, cpu_possible_map)
43 tracing_reset(tr, cpu); 56 tracing_reset(tr, cpu);
57
58 tracing_sched_switch_assign_trace(tr);
59 return 0;
44} 60}
45 61
46static void boot_trace_ctrl_update(struct trace_array *tr) 62static enum print_line_t
63initcall_call_print_line(struct trace_iterator *iter)
47{ 64{
48 if (tr->ctrl) 65 struct trace_entry *entry = iter->ent;
49 start_boot_trace(); 66 struct trace_seq *s = &iter->seq;
67 struct trace_boot_call *field;
68 struct boot_trace_call *call;
69 u64 ts;
70 unsigned long nsec_rem;
71 int ret;
72
73 trace_assign_type(field, entry);
74 call = &field->boot_call;
75 ts = iter->ts;
76 nsec_rem = do_div(ts, 1000000000);
77
78 ret = trace_seq_printf(s, "[%5ld.%09ld] calling %s @ %i\n",
79 (unsigned long)ts, nsec_rem, call->func, call->caller);
80
81 if (!ret)
82 return TRACE_TYPE_PARTIAL_LINE;
50 else 83 else
51 stop_boot_trace(); 84 return TRACE_TYPE_HANDLED;
52} 85}
53 86
54static enum print_line_t initcall_print_line(struct trace_iterator *iter) 87static enum print_line_t
88initcall_ret_print_line(struct trace_iterator *iter)
55{ 89{
56 int ret;
57 struct trace_entry *entry = iter->ent; 90 struct trace_entry *entry = iter->ent;
58 struct trace_boot *field = (struct trace_boot *)entry;
59 struct boot_trace *it = &field->initcall;
60 struct trace_seq *s = &iter->seq; 91 struct trace_seq *s = &iter->seq;
61 struct timespec calltime = ktime_to_timespec(it->calltime); 92 struct trace_boot_ret *field;
62 struct timespec rettime = ktime_to_timespec(it->rettime); 93 struct boot_trace_ret *init_ret;
63 94 u64 ts;
64 if (entry->type == TRACE_BOOT) { 95 unsigned long nsec_rem;
65 ret = trace_seq_printf(s, "[%5ld.%09ld] calling %s @ %i\n", 96 int ret;
66 calltime.tv_sec, 97
67 calltime.tv_nsec, 98 trace_assign_type(field, entry);
68 it->func, it->caller); 99 init_ret = &field->boot_ret;
69 if (!ret) 100 ts = iter->ts;
70 return TRACE_TYPE_PARTIAL_LINE; 101 nsec_rem = do_div(ts, 1000000000);
71 102
72 ret = trace_seq_printf(s, "[%5ld.%09ld] initcall %s " 103 ret = trace_seq_printf(s, "[%5ld.%09ld] initcall %s "
73 "returned %d after %lld msecs\n", 104 "returned %d after %llu msecs\n",
74 rettime.tv_sec, 105 (unsigned long) ts,
75 rettime.tv_nsec, 106 nsec_rem,
76 it->func, it->result, it->duration); 107 init_ret->func, init_ret->result, init_ret->duration);
77 108
78 if (!ret) 109 if (!ret)
79 return TRACE_TYPE_PARTIAL_LINE; 110 return TRACE_TYPE_PARTIAL_LINE;
111 else
80 return TRACE_TYPE_HANDLED; 112 return TRACE_TYPE_HANDLED;
113}
114
115static enum print_line_t initcall_print_line(struct trace_iterator *iter)
116{
117 struct trace_entry *entry = iter->ent;
118
119 switch (entry->type) {
120 case TRACE_BOOT_CALL:
121 return initcall_call_print_line(iter);
122 case TRACE_BOOT_RET:
123 return initcall_ret_print_line(iter);
124 default:
125 return TRACE_TYPE_UNHANDLED;
81 } 126 }
82 return TRACE_TYPE_UNHANDLED;
83} 127}
84 128
85struct tracer boot_tracer __read_mostly = 129struct tracer boot_tracer __read_mostly =
@@ -87,27 +131,53 @@ struct tracer boot_tracer __read_mostly =
87 .name = "initcall", 131 .name = "initcall",
88 .init = boot_trace_init, 132 .init = boot_trace_init,
89 .reset = reset_boot_trace, 133 .reset = reset_boot_trace,
90 .ctrl_update = boot_trace_ctrl_update,
91 .print_line = initcall_print_line, 134 .print_line = initcall_print_line,
92}; 135};
93 136
94void trace_boot(struct boot_trace *it, initcall_t fn) 137void trace_boot_call(struct boot_trace_call *bt, initcall_t fn)
95{ 138{
96 struct ring_buffer_event *event; 139 struct ring_buffer_event *event;
97 struct trace_boot *entry; 140 struct trace_boot_call *entry;
98 struct trace_array_cpu *data;
99 unsigned long irq_flags; 141 unsigned long irq_flags;
100 struct trace_array *tr = boot_trace; 142 struct trace_array *tr = boot_trace;
101 143
102 if (!trace_boot_enabled) 144 if (!pre_initcalls_finished)
103 return; 145 return;
104 146
105 /* Get its name now since this function could 147 /* Get its name now since this function could
106 * disappear because it is in the .init section. 148 * disappear because it is in the .init section.
107 */ 149 */
108 sprint_symbol(it->func, (unsigned long)fn); 150 sprint_symbol(bt->func, (unsigned long)fn);
151 preempt_disable();
152
153 event = ring_buffer_lock_reserve(tr->buffer, sizeof(*entry),
154 &irq_flags);
155 if (!event)
156 goto out;
157 entry = ring_buffer_event_data(event);
158 tracing_generic_entry_update(&entry->ent, 0, 0);
159 entry->ent.type = TRACE_BOOT_CALL;
160 entry->boot_call = *bt;
161 ring_buffer_unlock_commit(tr->buffer, event, irq_flags);
162
163 trace_wake_up();
164
165 out:
166 preempt_enable();
167}
168
169void trace_boot_ret(struct boot_trace_ret *bt, initcall_t fn)
170{
171 struct ring_buffer_event *event;
172 struct trace_boot_ret *entry;
173 unsigned long irq_flags;
174 struct trace_array *tr = boot_trace;
175
176 if (!pre_initcalls_finished)
177 return;
178
179 sprint_symbol(bt->func, (unsigned long)fn);
109 preempt_disable(); 180 preempt_disable();
110 data = tr->data[smp_processor_id()];
111 181
112 event = ring_buffer_lock_reserve(tr->buffer, sizeof(*entry), 182 event = ring_buffer_lock_reserve(tr->buffer, sizeof(*entry),
113 &irq_flags); 183 &irq_flags);
@@ -115,8 +185,8 @@ void trace_boot(struct boot_trace *it, initcall_t fn)
115 goto out; 185 goto out;
116 entry = ring_buffer_event_data(event); 186 entry = ring_buffer_event_data(event);
117 tracing_generic_entry_update(&entry->ent, 0, 0); 187 tracing_generic_entry_update(&entry->ent, 0, 0);
118 entry->ent.type = TRACE_BOOT; 188 entry->ent.type = TRACE_BOOT_RET;
119 entry->initcall = *it; 189 entry->boot_ret = *bt;
120 ring_buffer_unlock_commit(tr->buffer, event, irq_flags); 190 ring_buffer_unlock_commit(tr->buffer, event, irq_flags);
121 191
122 trace_wake_up(); 192 trace_wake_up();
diff --git a/kernel/trace/trace_branch.c b/kernel/trace/trace_branch.c
new file mode 100644
index 000000000000..23f9b02ce967
--- /dev/null
+++ b/kernel/trace/trace_branch.c
@@ -0,0 +1,321 @@
1/*
2 * unlikely profiler
3 *
4 * Copyright (C) 2008 Steven Rostedt <srostedt@redhat.com>
5 */
6#include <linux/kallsyms.h>
7#include <linux/seq_file.h>
8#include <linux/spinlock.h>
9#include <linux/debugfs.h>
10#include <linux/uaccess.h>
11#include <linux/module.h>
12#include <linux/ftrace.h>
13#include <linux/hash.h>
14#include <linux/fs.h>
15#include <asm/local.h>
16#include "trace.h"
17
18#ifdef CONFIG_BRANCH_TRACER
19
20static int branch_tracing_enabled __read_mostly;
21static DEFINE_MUTEX(branch_tracing_mutex);
22static struct trace_array *branch_tracer;
23
24static void
25probe_likely_condition(struct ftrace_branch_data *f, int val, int expect)
26{
27 struct trace_array *tr = branch_tracer;
28 struct ring_buffer_event *event;
29 struct trace_branch *entry;
30 unsigned long flags, irq_flags;
31 int cpu, pc;
32 const char *p;
33
34 /*
35 * I would love to save just the ftrace_likely_data pointer, but
36 * this code can also be used by modules. Ugly things can happen
37 * if the module is unloaded, and then we go and read the
38 * pointer. This is slower, but much safer.
39 */
40
41 if (unlikely(!tr))
42 return;
43
44 raw_local_irq_save(flags);
45 cpu = raw_smp_processor_id();
46 if (atomic_inc_return(&tr->data[cpu]->disabled) != 1)
47 goto out;
48
49 event = ring_buffer_lock_reserve(tr->buffer, sizeof(*entry),
50 &irq_flags);
51 if (!event)
52 goto out;
53
54 pc = preempt_count();
55 entry = ring_buffer_event_data(event);
56 tracing_generic_entry_update(&entry->ent, flags, pc);
57 entry->ent.type = TRACE_BRANCH;
58
59 /* Strip off the path, only save the file */
60 p = f->file + strlen(f->file);
61 while (p >= f->file && *p != '/')
62 p--;
63 p++;
64
65 strncpy(entry->func, f->func, TRACE_FUNC_SIZE);
66 strncpy(entry->file, p, TRACE_FILE_SIZE);
67 entry->func[TRACE_FUNC_SIZE] = 0;
68 entry->file[TRACE_FILE_SIZE] = 0;
69 entry->line = f->line;
70 entry->correct = val == expect;
71
72 ring_buffer_unlock_commit(tr->buffer, event, irq_flags);
73
74 out:
75 atomic_dec(&tr->data[cpu]->disabled);
76 raw_local_irq_restore(flags);
77}
78
79static inline
80void trace_likely_condition(struct ftrace_branch_data *f, int val, int expect)
81{
82 if (!branch_tracing_enabled)
83 return;
84
85 probe_likely_condition(f, val, expect);
86}
87
88int enable_branch_tracing(struct trace_array *tr)
89{
90 int ret = 0;
91
92 mutex_lock(&branch_tracing_mutex);
93 branch_tracer = tr;
94 /*
95 * Must be seen before enabling. The reader is a condition
96 * where we do not need a matching rmb()
97 */
98 smp_wmb();
99 branch_tracing_enabled++;
100 mutex_unlock(&branch_tracing_mutex);
101
102 return ret;
103}
104
105void disable_branch_tracing(void)
106{
107 mutex_lock(&branch_tracing_mutex);
108
109 if (!branch_tracing_enabled)
110 goto out_unlock;
111
112 branch_tracing_enabled--;
113
114 out_unlock:
115 mutex_unlock(&branch_tracing_mutex);
116}
117
118static void start_branch_trace(struct trace_array *tr)
119{
120 enable_branch_tracing(tr);
121}
122
123static void stop_branch_trace(struct trace_array *tr)
124{
125 disable_branch_tracing();
126}
127
128static int branch_trace_init(struct trace_array *tr)
129{
130 int cpu;
131
132 for_each_online_cpu(cpu)
133 tracing_reset(tr, cpu);
134
135 start_branch_trace(tr);
136 return 0;
137}
138
139static void branch_trace_reset(struct trace_array *tr)
140{
141 stop_branch_trace(tr);
142}
143
144struct tracer branch_trace __read_mostly =
145{
146 .name = "branch",
147 .init = branch_trace_init,
148 .reset = branch_trace_reset,
149#ifdef CONFIG_FTRACE_SELFTEST
150 .selftest = trace_selftest_startup_branch,
151#endif
152};
153
154__init static int init_branch_trace(void)
155{
156 return register_tracer(&branch_trace);
157}
158
159device_initcall(init_branch_trace);
160#else
161static inline
162void trace_likely_condition(struct ftrace_branch_data *f, int val, int expect)
163{
164}
165#endif /* CONFIG_BRANCH_TRACER */
166
167void ftrace_likely_update(struct ftrace_branch_data *f, int val, int expect)
168{
169 /*
170 * I would love to have a trace point here instead, but the
171 * trace point code is so inundated with unlikely and likely
172 * conditions that the recursive nightmare that exists is too
173 * much to try to get working. At least for now.
174 */
175 trace_likely_condition(f, val, expect);
176
177 /* FIXME: Make this atomic! */
178 if (val == expect)
179 f->correct++;
180 else
181 f->incorrect++;
182}
183EXPORT_SYMBOL(ftrace_likely_update);
184
185struct ftrace_pointer {
186 void *start;
187 void *stop;
188};
189
190static void *
191t_next(struct seq_file *m, void *v, loff_t *pos)
192{
193 struct ftrace_pointer *f = m->private;
194 struct ftrace_branch_data *p = v;
195
196 (*pos)++;
197
198 if (v == (void *)1)
199 return f->start;
200
201 ++p;
202
203 if ((void *)p >= (void *)f->stop)
204 return NULL;
205
206 return p;
207}
208
209static void *t_start(struct seq_file *m, loff_t *pos)
210{
211 void *t = (void *)1;
212 loff_t l = 0;
213
214 for (; t && l < *pos; t = t_next(m, t, &l))
215 ;
216
217 return t;
218}
219
220static void t_stop(struct seq_file *m, void *p)
221{
222}
223
224static int t_show(struct seq_file *m, void *v)
225{
226 struct ftrace_branch_data *p = v;
227 const char *f;
228 unsigned long percent;
229
230 if (v == (void *)1) {
231 seq_printf(m, " correct incorrect %% "
232 " Function "
233 " File Line\n"
234 " ------- --------- - "
235 " -------- "
236 " ---- ----\n");
237 return 0;
238 }
239
240 /* Only print the file, not the path */
241 f = p->file + strlen(p->file);
242 while (f >= p->file && *f != '/')
243 f--;
244 f++;
245
246 if (p->correct) {
247 percent = p->incorrect * 100;
248 percent /= p->correct + p->incorrect;
249 } else
250 percent = p->incorrect ? 100 : 0;
251
252 seq_printf(m, "%8lu %8lu %3lu ", p->correct, p->incorrect, percent);
253 seq_printf(m, "%-30.30s %-20.20s %d\n", p->func, f, p->line);
254 return 0;
255}
256
257static struct seq_operations tracing_likely_seq_ops = {
258 .start = t_start,
259 .next = t_next,
260 .stop = t_stop,
261 .show = t_show,
262};
263
264static int tracing_likely_open(struct inode *inode, struct file *file)
265{
266 int ret;
267
268 ret = seq_open(file, &tracing_likely_seq_ops);
269 if (!ret) {
270 struct seq_file *m = file->private_data;
271 m->private = (void *)inode->i_private;
272 }
273
274 return ret;
275}
276
277static struct file_operations tracing_likely_fops = {
278 .open = tracing_likely_open,
279 .read = seq_read,
280 .llseek = seq_lseek,
281};
282
283extern unsigned long __start_likely_profile[];
284extern unsigned long __stop_likely_profile[];
285extern unsigned long __start_unlikely_profile[];
286extern unsigned long __stop_unlikely_profile[];
287
288static struct ftrace_pointer ftrace_likely_pos = {
289 .start = __start_likely_profile,
290 .stop = __stop_likely_profile,
291};
292
293static struct ftrace_pointer ftrace_unlikely_pos = {
294 .start = __start_unlikely_profile,
295 .stop = __stop_unlikely_profile,
296};
297
298static __init int ftrace_branch_init(void)
299{
300 struct dentry *d_tracer;
301 struct dentry *entry;
302
303 d_tracer = tracing_init_dentry();
304
305 entry = debugfs_create_file("profile_likely", 0444, d_tracer,
306 &ftrace_likely_pos,
307 &tracing_likely_fops);
308 if (!entry)
309 pr_warning("Could not create debugfs 'profile_likely' entry\n");
310
311 entry = debugfs_create_file("profile_unlikely", 0444, d_tracer,
312 &ftrace_unlikely_pos,
313 &tracing_likely_fops);
314 if (!entry)
315 pr_warning("Could not create debugfs"
316 " 'profile_unlikely' entry\n");
317
318 return 0;
319}
320
321device_initcall(ftrace_branch_init);
diff --git a/kernel/trace/trace_functions.c b/kernel/trace/trace_functions.c
index 0f85a64003d3..e74f6d0a3216 100644
--- a/kernel/trace/trace_functions.c
+++ b/kernel/trace/trace_functions.c
@@ -42,24 +42,20 @@ static void stop_function_trace(struct trace_array *tr)
42 tracing_stop_cmdline_record(); 42 tracing_stop_cmdline_record();
43} 43}
44 44
45static void function_trace_init(struct trace_array *tr) 45static int function_trace_init(struct trace_array *tr)
46{ 46{
47 if (tr->ctrl) 47 start_function_trace(tr);
48 start_function_trace(tr); 48 return 0;
49} 49}
50 50
51static void function_trace_reset(struct trace_array *tr) 51static void function_trace_reset(struct trace_array *tr)
52{ 52{
53 if (tr->ctrl) 53 stop_function_trace(tr);
54 stop_function_trace(tr);
55} 54}
56 55
57static void function_trace_ctrl_update(struct trace_array *tr) 56static void function_trace_start(struct trace_array *tr)
58{ 57{
59 if (tr->ctrl) 58 function_reset(tr);
60 start_function_trace(tr);
61 else
62 stop_function_trace(tr);
63} 59}
64 60
65static struct tracer function_trace __read_mostly = 61static struct tracer function_trace __read_mostly =
@@ -67,7 +63,7 @@ static struct tracer function_trace __read_mostly =
67 .name = "function", 63 .name = "function",
68 .init = function_trace_init, 64 .init = function_trace_init,
69 .reset = function_trace_reset, 65 .reset = function_trace_reset,
70 .ctrl_update = function_trace_ctrl_update, 66 .start = function_trace_start,
71#ifdef CONFIG_FTRACE_SELFTEST 67#ifdef CONFIG_FTRACE_SELFTEST
72 .selftest = trace_selftest_startup_function, 68 .selftest = trace_selftest_startup_function,
73#endif 69#endif
diff --git a/kernel/trace/trace_functions_return.c b/kernel/trace/trace_functions_return.c
new file mode 100644
index 000000000000..e00d64509c9c
--- /dev/null
+++ b/kernel/trace/trace_functions_return.c
@@ -0,0 +1,98 @@
1/*
2 *
3 * Function return tracer.
4 * Copyright (c) 2008 Frederic Weisbecker <fweisbec@gmail.com>
5 * Mostly borrowed from function tracer which
6 * is Copyright (c) Steven Rostedt <srostedt@redhat.com>
7 *
8 */
9#include <linux/debugfs.h>
10#include <linux/uaccess.h>
11#include <linux/ftrace.h>
12#include <linux/fs.h>
13
14#include "trace.h"
15
16
17#define TRACE_RETURN_PRINT_OVERRUN 0x1
18static struct tracer_opt trace_opts[] = {
19 /* Display overruns or not */
20 { TRACER_OPT(overrun, TRACE_RETURN_PRINT_OVERRUN) },
21 { } /* Empty entry */
22};
23
24static struct tracer_flags tracer_flags = {
25 .val = 0, /* Don't display overruns by default */
26 .opts = trace_opts
27};
28
29
30static int return_trace_init(struct trace_array *tr)
31{
32 int cpu;
33 for_each_online_cpu(cpu)
34 tracing_reset(tr, cpu);
35
36 return register_ftrace_return(&trace_function_return);
37}
38
39static void return_trace_reset(struct trace_array *tr)
40{
41 unregister_ftrace_return();
42}
43
44
45enum print_line_t
46print_return_function(struct trace_iterator *iter)
47{
48 struct trace_seq *s = &iter->seq;
49 struct trace_entry *entry = iter->ent;
50 struct ftrace_ret_entry *field;
51 int ret;
52
53 if (entry->type == TRACE_FN_RET) {
54 trace_assign_type(field, entry);
55 ret = trace_seq_printf(s, "%pF -> ", (void *)field->parent_ip);
56 if (!ret)
57 return TRACE_TYPE_PARTIAL_LINE;
58
59 ret = seq_print_ip_sym(s, field->ip,
60 trace_flags & TRACE_ITER_SYM_MASK);
61 if (!ret)
62 return TRACE_TYPE_PARTIAL_LINE;
63
64 ret = trace_seq_printf(s, " (%llu ns)",
65 field->rettime - field->calltime);
66 if (!ret)
67 return TRACE_TYPE_PARTIAL_LINE;
68
69 if (tracer_flags.val & TRACE_RETURN_PRINT_OVERRUN) {
70 ret = trace_seq_printf(s, " (Overruns: %lu)",
71 field->overrun);
72 if (!ret)
73 return TRACE_TYPE_PARTIAL_LINE;
74 }
75
76 ret = trace_seq_printf(s, "\n");
77 if (!ret)
78 return TRACE_TYPE_PARTIAL_LINE;
79
80 return TRACE_TYPE_HANDLED;
81 }
82 return TRACE_TYPE_UNHANDLED;
83}
84
85static struct tracer return_trace __read_mostly = {
86 .name = "return",
87 .init = return_trace_init,
88 .reset = return_trace_reset,
89 .print_line = print_return_function,
90 .flags = &tracer_flags,
91};
92
93static __init int init_return_trace(void)
94{
95 return register_tracer(&return_trace);
96}
97
98device_initcall(init_return_trace);
diff --git a/kernel/trace/trace_irqsoff.c b/kernel/trace/trace_irqsoff.c
index 9c74071c10e0..7c2e326bbc8b 100644
--- a/kernel/trace/trace_irqsoff.c
+++ b/kernel/trace/trace_irqsoff.c
@@ -353,15 +353,28 @@ void trace_preempt_off(unsigned long a0, unsigned long a1)
353} 353}
354#endif /* CONFIG_PREEMPT_TRACER */ 354#endif /* CONFIG_PREEMPT_TRACER */
355 355
356/*
357 * save_tracer_enabled is used to save the state of the tracer_enabled
358 * variable when we disable it when we open a trace output file.
359 */
360static int save_tracer_enabled;
361
356static void start_irqsoff_tracer(struct trace_array *tr) 362static void start_irqsoff_tracer(struct trace_array *tr)
357{ 363{
358 register_ftrace_function(&trace_ops); 364 register_ftrace_function(&trace_ops);
359 tracer_enabled = 1; 365 if (tracing_is_enabled()) {
366 tracer_enabled = 1;
367 save_tracer_enabled = 1;
368 } else {
369 tracer_enabled = 0;
370 save_tracer_enabled = 0;
371 }
360} 372}
361 373
362static void stop_irqsoff_tracer(struct trace_array *tr) 374static void stop_irqsoff_tracer(struct trace_array *tr)
363{ 375{
364 tracer_enabled = 0; 376 tracer_enabled = 0;
377 save_tracer_enabled = 0;
365 unregister_ftrace_function(&trace_ops); 378 unregister_ftrace_function(&trace_ops);
366} 379}
367 380
@@ -370,53 +383,55 @@ static void __irqsoff_tracer_init(struct trace_array *tr)
370 irqsoff_trace = tr; 383 irqsoff_trace = tr;
371 /* make sure that the tracer is visible */ 384 /* make sure that the tracer is visible */
372 smp_wmb(); 385 smp_wmb();
373 386 start_irqsoff_tracer(tr);
374 if (tr->ctrl)
375 start_irqsoff_tracer(tr);
376} 387}
377 388
378static void irqsoff_tracer_reset(struct trace_array *tr) 389static void irqsoff_tracer_reset(struct trace_array *tr)
379{ 390{
380 if (tr->ctrl) 391 stop_irqsoff_tracer(tr);
381 stop_irqsoff_tracer(tr);
382} 392}
383 393
384static void irqsoff_tracer_ctrl_update(struct trace_array *tr) 394static void irqsoff_tracer_start(struct trace_array *tr)
385{ 395{
386 if (tr->ctrl) 396 tracer_enabled = 1;
387 start_irqsoff_tracer(tr); 397 save_tracer_enabled = 1;
388 else 398}
389 stop_irqsoff_tracer(tr); 399
400static void irqsoff_tracer_stop(struct trace_array *tr)
401{
402 tracer_enabled = 0;
403 save_tracer_enabled = 0;
390} 404}
391 405
392static void irqsoff_tracer_open(struct trace_iterator *iter) 406static void irqsoff_tracer_open(struct trace_iterator *iter)
393{ 407{
394 /* stop the trace while dumping */ 408 /* stop the trace while dumping */
395 if (iter->tr->ctrl) 409 tracer_enabled = 0;
396 stop_irqsoff_tracer(iter->tr);
397} 410}
398 411
399static void irqsoff_tracer_close(struct trace_iterator *iter) 412static void irqsoff_tracer_close(struct trace_iterator *iter)
400{ 413{
401 if (iter->tr->ctrl) 414 /* restart tracing */
402 start_irqsoff_tracer(iter->tr); 415 tracer_enabled = save_tracer_enabled;
403} 416}
404 417
405#ifdef CONFIG_IRQSOFF_TRACER 418#ifdef CONFIG_IRQSOFF_TRACER
406static void irqsoff_tracer_init(struct trace_array *tr) 419static int irqsoff_tracer_init(struct trace_array *tr)
407{ 420{
408 trace_type = TRACER_IRQS_OFF; 421 trace_type = TRACER_IRQS_OFF;
409 422
410 __irqsoff_tracer_init(tr); 423 __irqsoff_tracer_init(tr);
424 return 0;
411} 425}
412static struct tracer irqsoff_tracer __read_mostly = 426static struct tracer irqsoff_tracer __read_mostly =
413{ 427{
414 .name = "irqsoff", 428 .name = "irqsoff",
415 .init = irqsoff_tracer_init, 429 .init = irqsoff_tracer_init,
416 .reset = irqsoff_tracer_reset, 430 .reset = irqsoff_tracer_reset,
431 .start = irqsoff_tracer_start,
432 .stop = irqsoff_tracer_stop,
417 .open = irqsoff_tracer_open, 433 .open = irqsoff_tracer_open,
418 .close = irqsoff_tracer_close, 434 .close = irqsoff_tracer_close,
419 .ctrl_update = irqsoff_tracer_ctrl_update,
420 .print_max = 1, 435 .print_max = 1,
421#ifdef CONFIG_FTRACE_SELFTEST 436#ifdef CONFIG_FTRACE_SELFTEST
422 .selftest = trace_selftest_startup_irqsoff, 437 .selftest = trace_selftest_startup_irqsoff,
@@ -428,11 +443,12 @@ static struct tracer irqsoff_tracer __read_mostly =
428#endif 443#endif
429 444
430#ifdef CONFIG_PREEMPT_TRACER 445#ifdef CONFIG_PREEMPT_TRACER
431static void preemptoff_tracer_init(struct trace_array *tr) 446static int preemptoff_tracer_init(struct trace_array *tr)
432{ 447{
433 trace_type = TRACER_PREEMPT_OFF; 448 trace_type = TRACER_PREEMPT_OFF;
434 449
435 __irqsoff_tracer_init(tr); 450 __irqsoff_tracer_init(tr);
451 return 0;
436} 452}
437 453
438static struct tracer preemptoff_tracer __read_mostly = 454static struct tracer preemptoff_tracer __read_mostly =
@@ -440,9 +456,10 @@ static struct tracer preemptoff_tracer __read_mostly =
440 .name = "preemptoff", 456 .name = "preemptoff",
441 .init = preemptoff_tracer_init, 457 .init = preemptoff_tracer_init,
442 .reset = irqsoff_tracer_reset, 458 .reset = irqsoff_tracer_reset,
459 .start = irqsoff_tracer_start,
460 .stop = irqsoff_tracer_stop,
443 .open = irqsoff_tracer_open, 461 .open = irqsoff_tracer_open,
444 .close = irqsoff_tracer_close, 462 .close = irqsoff_tracer_close,
445 .ctrl_update = irqsoff_tracer_ctrl_update,
446 .print_max = 1, 463 .print_max = 1,
447#ifdef CONFIG_FTRACE_SELFTEST 464#ifdef CONFIG_FTRACE_SELFTEST
448 .selftest = trace_selftest_startup_preemptoff, 465 .selftest = trace_selftest_startup_preemptoff,
@@ -456,11 +473,12 @@ static struct tracer preemptoff_tracer __read_mostly =
456#if defined(CONFIG_IRQSOFF_TRACER) && \ 473#if defined(CONFIG_IRQSOFF_TRACER) && \
457 defined(CONFIG_PREEMPT_TRACER) 474 defined(CONFIG_PREEMPT_TRACER)
458 475
459static void preemptirqsoff_tracer_init(struct trace_array *tr) 476static int preemptirqsoff_tracer_init(struct trace_array *tr)
460{ 477{
461 trace_type = TRACER_IRQS_OFF | TRACER_PREEMPT_OFF; 478 trace_type = TRACER_IRQS_OFF | TRACER_PREEMPT_OFF;
462 479
463 __irqsoff_tracer_init(tr); 480 __irqsoff_tracer_init(tr);
481 return 0;
464} 482}
465 483
466static struct tracer preemptirqsoff_tracer __read_mostly = 484static struct tracer preemptirqsoff_tracer __read_mostly =
@@ -468,9 +486,10 @@ static struct tracer preemptirqsoff_tracer __read_mostly =
468 .name = "preemptirqsoff", 486 .name = "preemptirqsoff",
469 .init = preemptirqsoff_tracer_init, 487 .init = preemptirqsoff_tracer_init,
470 .reset = irqsoff_tracer_reset, 488 .reset = irqsoff_tracer_reset,
489 .start = irqsoff_tracer_start,
490 .stop = irqsoff_tracer_stop,
471 .open = irqsoff_tracer_open, 491 .open = irqsoff_tracer_open,
472 .close = irqsoff_tracer_close, 492 .close = irqsoff_tracer_close,
473 .ctrl_update = irqsoff_tracer_ctrl_update,
474 .print_max = 1, 493 .print_max = 1,
475#ifdef CONFIG_FTRACE_SELFTEST 494#ifdef CONFIG_FTRACE_SELFTEST
476 .selftest = trace_selftest_startup_preemptirqsoff, 495 .selftest = trace_selftest_startup_preemptirqsoff,
diff --git a/kernel/trace/trace_mmiotrace.c b/kernel/trace/trace_mmiotrace.c
index f28484618ff0..433d650eda9f 100644
--- a/kernel/trace/trace_mmiotrace.c
+++ b/kernel/trace/trace_mmiotrace.c
@@ -30,34 +30,29 @@ static void mmio_reset_data(struct trace_array *tr)
30 tracing_reset(tr, cpu); 30 tracing_reset(tr, cpu);
31} 31}
32 32
33static void mmio_trace_init(struct trace_array *tr) 33static int mmio_trace_init(struct trace_array *tr)
34{ 34{
35 pr_debug("in %s\n", __func__); 35 pr_debug("in %s\n", __func__);
36 mmio_trace_array = tr; 36 mmio_trace_array = tr;
37 if (tr->ctrl) { 37
38 mmio_reset_data(tr); 38 mmio_reset_data(tr);
39 enable_mmiotrace(); 39 enable_mmiotrace();
40 } 40 return 0;
41} 41}
42 42
43static void mmio_trace_reset(struct trace_array *tr) 43static void mmio_trace_reset(struct trace_array *tr)
44{ 44{
45 pr_debug("in %s\n", __func__); 45 pr_debug("in %s\n", __func__);
46 if (tr->ctrl) 46
47 disable_mmiotrace(); 47 disable_mmiotrace();
48 mmio_reset_data(tr); 48 mmio_reset_data(tr);
49 mmio_trace_array = NULL; 49 mmio_trace_array = NULL;
50} 50}
51 51
52static void mmio_trace_ctrl_update(struct trace_array *tr) 52static void mmio_trace_start(struct trace_array *tr)
53{ 53{
54 pr_debug("in %s\n", __func__); 54 pr_debug("in %s\n", __func__);
55 if (tr->ctrl) { 55 mmio_reset_data(tr);
56 mmio_reset_data(tr);
57 enable_mmiotrace();
58 } else {
59 disable_mmiotrace();
60 }
61} 56}
62 57
63static int mmio_print_pcidev(struct trace_seq *s, const struct pci_dev *dev) 58static int mmio_print_pcidev(struct trace_seq *s, const struct pci_dev *dev)
@@ -298,10 +293,10 @@ static struct tracer mmio_tracer __read_mostly =
298 .name = "mmiotrace", 293 .name = "mmiotrace",
299 .init = mmio_trace_init, 294 .init = mmio_trace_init,
300 .reset = mmio_trace_reset, 295 .reset = mmio_trace_reset,
296 .start = mmio_trace_start,
301 .pipe_open = mmio_pipe_open, 297 .pipe_open = mmio_pipe_open,
302 .close = mmio_close, 298 .close = mmio_close,
303 .read = mmio_read, 299 .read = mmio_read,
304 .ctrl_update = mmio_trace_ctrl_update,
305 .print_line = mmio_print_line, 300 .print_line = mmio_print_line,
306}; 301};
307 302
diff --git a/kernel/trace/trace_nop.c b/kernel/trace/trace_nop.c
index 4592b4862515..b9767acd30ac 100644
--- a/kernel/trace/trace_nop.c
+++ b/kernel/trace/trace_nop.c
@@ -12,6 +12,27 @@
12 12
13#include "trace.h" 13#include "trace.h"
14 14
15/* Our two options */
16enum {
17 TRACE_NOP_OPT_ACCEPT = 0x1,
18 TRACE_NOP_OPT_REFUSE = 0x2
19};
20
21/* Options for the tracer (see trace_options file) */
22static struct tracer_opt nop_opts[] = {
23 /* Option that will be accepted by set_flag callback */
24 { TRACER_OPT(test_nop_accept, TRACE_NOP_OPT_ACCEPT) },
25 /* Option that will be refused by set_flag callback */
26 { TRACER_OPT(test_nop_refuse, TRACE_NOP_OPT_REFUSE) },
27 { } /* Always set a last empty entry */
28};
29
30static struct tracer_flags nop_flags = {
31 /* You can check your flags value here when you want. */
32 .val = 0, /* By default: all flags disabled */
33 .opts = nop_opts
34};
35
15static struct trace_array *ctx_trace; 36static struct trace_array *ctx_trace;
16 37
17static void start_nop_trace(struct trace_array *tr) 38static void start_nop_trace(struct trace_array *tr)
@@ -24,7 +45,7 @@ static void stop_nop_trace(struct trace_array *tr)
24 /* Nothing to do! */ 45 /* Nothing to do! */
25} 46}
26 47
27static void nop_trace_init(struct trace_array *tr) 48static int nop_trace_init(struct trace_array *tr)
28{ 49{
29 int cpu; 50 int cpu;
30 ctx_trace = tr; 51 ctx_trace = tr;
@@ -32,33 +53,53 @@ static void nop_trace_init(struct trace_array *tr)
32 for_each_online_cpu(cpu) 53 for_each_online_cpu(cpu)
33 tracing_reset(tr, cpu); 54 tracing_reset(tr, cpu);
34 55
35 if (tr->ctrl) 56 start_nop_trace(tr);
36 start_nop_trace(tr); 57 return 0;
37} 58}
38 59
39static void nop_trace_reset(struct trace_array *tr) 60static void nop_trace_reset(struct trace_array *tr)
40{ 61{
41 if (tr->ctrl) 62 stop_nop_trace(tr);
42 stop_nop_trace(tr);
43} 63}
44 64
45static void nop_trace_ctrl_update(struct trace_array *tr) 65/* It only serves as a signal handler and a callback to
66 * accept or refuse tthe setting of a flag.
67 * If you don't implement it, then the flag setting will be
68 * automatically accepted.
69 */
70static int nop_set_flag(u32 old_flags, u32 bit, int set)
46{ 71{
47 /* When starting a new trace, reset the buffers */ 72 /*
48 if (tr->ctrl) 73 * Note that you don't need to update nop_flags.val yourself.
49 start_nop_trace(tr); 74 * The tracing Api will do it automatically if you return 0
50 else 75 */
51 stop_nop_trace(tr); 76 if (bit == TRACE_NOP_OPT_ACCEPT) {
77 printk(KERN_DEBUG "nop_test_accept flag set to %d: we accept."
78 " Now cat trace_options to see the result\n",
79 set);
80 return 0;
81 }
82
83 if (bit == TRACE_NOP_OPT_REFUSE) {
84 printk(KERN_DEBUG "nop_test_refuse flag set to %d: we refuse."
85 "Now cat trace_options to see the result\n",
86 set);
87 return -EINVAL;
88 }
89
90 return 0;
52} 91}
53 92
93
54struct tracer nop_trace __read_mostly = 94struct tracer nop_trace __read_mostly =
55{ 95{
56 .name = "nop", 96 .name = "nop",
57 .init = nop_trace_init, 97 .init = nop_trace_init,
58 .reset = nop_trace_reset, 98 .reset = nop_trace_reset,
59 .ctrl_update = nop_trace_ctrl_update,
60#ifdef CONFIG_FTRACE_SELFTEST 99#ifdef CONFIG_FTRACE_SELFTEST
61 .selftest = trace_selftest_startup_nop, 100 .selftest = trace_selftest_startup_nop,
62#endif 101#endif
102 .flags = &nop_flags,
103 .set_flag = nop_set_flag
63}; 104};
64 105
diff --git a/kernel/trace/trace_sched_switch.c b/kernel/trace/trace_sched_switch.c
index b8f56beb1a62..863390557b44 100644
--- a/kernel/trace/trace_sched_switch.c
+++ b/kernel/trace/trace_sched_switch.c
@@ -16,7 +16,8 @@
16 16
17static struct trace_array *ctx_trace; 17static struct trace_array *ctx_trace;
18static int __read_mostly tracer_enabled; 18static int __read_mostly tracer_enabled;
19static atomic_t sched_ref; 19static int sched_ref;
20static DEFINE_MUTEX(sched_register_mutex);
20 21
21static void 22static void
22probe_sched_switch(struct rq *__rq, struct task_struct *prev, 23probe_sched_switch(struct rq *__rq, struct task_struct *prev,
@@ -27,7 +28,7 @@ probe_sched_switch(struct rq *__rq, struct task_struct *prev,
27 int cpu; 28 int cpu;
28 int pc; 29 int pc;
29 30
30 if (!atomic_read(&sched_ref)) 31 if (!sched_ref)
31 return; 32 return;
32 33
33 tracing_record_cmdline(prev); 34 tracing_record_cmdline(prev);
@@ -123,20 +124,18 @@ static void tracing_sched_unregister(void)
123 124
124static void tracing_start_sched_switch(void) 125static void tracing_start_sched_switch(void)
125{ 126{
126 long ref; 127 mutex_lock(&sched_register_mutex);
127 128 if (!(sched_ref++))
128 ref = atomic_inc_return(&sched_ref);
129 if (ref == 1)
130 tracing_sched_register(); 129 tracing_sched_register();
130 mutex_unlock(&sched_register_mutex);
131} 131}
132 132
133static void tracing_stop_sched_switch(void) 133static void tracing_stop_sched_switch(void)
134{ 134{
135 long ref; 135 mutex_lock(&sched_register_mutex);
136 136 if (!(--sched_ref))
137 ref = atomic_dec_and_test(&sched_ref);
138 if (ref)
139 tracing_sched_unregister(); 137 tracing_sched_unregister();
138 mutex_unlock(&sched_register_mutex);
140} 139}
141 140
142void tracing_start_cmdline_record(void) 141void tracing_start_cmdline_record(void)
@@ -149,40 +148,86 @@ void tracing_stop_cmdline_record(void)
149 tracing_stop_sched_switch(); 148 tracing_stop_sched_switch();
150} 149}
151 150
151/**
152 * tracing_start_sched_switch_record - start tracing context switches
153 *
154 * Turns on context switch tracing for a tracer.
155 */
156void tracing_start_sched_switch_record(void)
157{
158 if (unlikely(!ctx_trace)) {
159 WARN_ON(1);
160 return;
161 }
162
163 tracing_start_sched_switch();
164
165 mutex_lock(&sched_register_mutex);
166 tracer_enabled++;
167 mutex_unlock(&sched_register_mutex);
168}
169
170/**
171 * tracing_stop_sched_switch_record - start tracing context switches
172 *
173 * Turns off context switch tracing for a tracer.
174 */
175void tracing_stop_sched_switch_record(void)
176{
177 mutex_lock(&sched_register_mutex);
178 tracer_enabled--;
179 WARN_ON(tracer_enabled < 0);
180 mutex_unlock(&sched_register_mutex);
181
182 tracing_stop_sched_switch();
183}
184
185/**
186 * tracing_sched_switch_assign_trace - assign a trace array for ctx switch
187 * @tr: trace array pointer to assign
188 *
189 * Some tracers might want to record the context switches in their
190 * trace. This function lets those tracers assign the trace array
191 * to use.
192 */
193void tracing_sched_switch_assign_trace(struct trace_array *tr)
194{
195 ctx_trace = tr;
196}
197
152static void start_sched_trace(struct trace_array *tr) 198static void start_sched_trace(struct trace_array *tr)
153{ 199{
154 sched_switch_reset(tr); 200 sched_switch_reset(tr);
155 tracing_start_cmdline_record(); 201 tracing_start_sched_switch_record();
156 tracer_enabled = 1;
157} 202}
158 203
159static void stop_sched_trace(struct trace_array *tr) 204static void stop_sched_trace(struct trace_array *tr)
160{ 205{
161 tracer_enabled = 0; 206 tracing_stop_sched_switch_record();
162 tracing_stop_cmdline_record();
163} 207}
164 208
165static void sched_switch_trace_init(struct trace_array *tr) 209static int sched_switch_trace_init(struct trace_array *tr)
166{ 210{
167 ctx_trace = tr; 211 ctx_trace = tr;
168 212 start_sched_trace(tr);
169 if (tr->ctrl) 213 return 0;
170 start_sched_trace(tr);
171} 214}
172 215
173static void sched_switch_trace_reset(struct trace_array *tr) 216static void sched_switch_trace_reset(struct trace_array *tr)
174{ 217{
175 if (tr->ctrl) 218 if (sched_ref)
176 stop_sched_trace(tr); 219 stop_sched_trace(tr);
177} 220}
178 221
179static void sched_switch_trace_ctrl_update(struct trace_array *tr) 222static void sched_switch_trace_start(struct trace_array *tr)
180{ 223{
181 /* When starting a new trace, reset the buffers */ 224 sched_switch_reset(tr);
182 if (tr->ctrl) 225 tracing_start_sched_switch();
183 start_sched_trace(tr); 226}
184 else 227
185 stop_sched_trace(tr); 228static void sched_switch_trace_stop(struct trace_array *tr)
229{
230 tracing_stop_sched_switch();
186} 231}
187 232
188static struct tracer sched_switch_trace __read_mostly = 233static struct tracer sched_switch_trace __read_mostly =
@@ -190,7 +235,8 @@ static struct tracer sched_switch_trace __read_mostly =
190 .name = "sched_switch", 235 .name = "sched_switch",
191 .init = sched_switch_trace_init, 236 .init = sched_switch_trace_init,
192 .reset = sched_switch_trace_reset, 237 .reset = sched_switch_trace_reset,
193 .ctrl_update = sched_switch_trace_ctrl_update, 238 .start = sched_switch_trace_start,
239 .stop = sched_switch_trace_stop,
194#ifdef CONFIG_FTRACE_SELFTEST 240#ifdef CONFIG_FTRACE_SELFTEST
195 .selftest = trace_selftest_startup_sched_switch, 241 .selftest = trace_selftest_startup_sched_switch,
196#endif 242#endif
@@ -198,14 +244,6 @@ static struct tracer sched_switch_trace __read_mostly =
198 244
199__init static int init_sched_switch_trace(void) 245__init static int init_sched_switch_trace(void)
200{ 246{
201 int ret = 0;
202
203 if (atomic_read(&sched_ref))
204 ret = tracing_sched_register();
205 if (ret) {
206 pr_info("error registering scheduler trace\n");
207 return ret;
208 }
209 return register_tracer(&sched_switch_trace); 247 return register_tracer(&sched_switch_trace);
210} 248}
211device_initcall(init_sched_switch_trace); 249device_initcall(init_sched_switch_trace);
diff --git a/kernel/trace/trace_sched_wakeup.c b/kernel/trace/trace_sched_wakeup.c
index 3ae93f16b565..0067b49746c1 100644
--- a/kernel/trace/trace_sched_wakeup.c
+++ b/kernel/trace/trace_sched_wakeup.c
@@ -50,8 +50,7 @@ wakeup_tracer_call(unsigned long ip, unsigned long parent_ip)
50 return; 50 return;
51 51
52 pc = preempt_count(); 52 pc = preempt_count();
53 resched = need_resched(); 53 resched = ftrace_preempt_disable();
54 preempt_disable_notrace();
55 54
56 cpu = raw_smp_processor_id(); 55 cpu = raw_smp_processor_id();
57 data = tr->data[cpu]; 56 data = tr->data[cpu];
@@ -81,15 +80,7 @@ wakeup_tracer_call(unsigned long ip, unsigned long parent_ip)
81 out: 80 out:
82 atomic_dec(&data->disabled); 81 atomic_dec(&data->disabled);
83 82
84 /* 83 ftrace_preempt_enable(resched);
85 * To prevent recursion from the scheduler, if the
86 * resched flag was set before we entered, then
87 * don't reschedule.
88 */
89 if (resched)
90 preempt_enable_no_resched_notrace();
91 else
92 preempt_enable_notrace();
93} 84}
94 85
95static struct ftrace_ops trace_ops __read_mostly = 86static struct ftrace_ops trace_ops __read_mostly =
@@ -271,6 +262,12 @@ out:
271 atomic_dec(&wakeup_trace->data[cpu]->disabled); 262 atomic_dec(&wakeup_trace->data[cpu]->disabled);
272} 263}
273 264
265/*
266 * save_tracer_enabled is used to save the state of the tracer_enabled
267 * variable when we disable it when we open a trace output file.
268 */
269static int save_tracer_enabled;
270
274static void start_wakeup_tracer(struct trace_array *tr) 271static void start_wakeup_tracer(struct trace_array *tr)
275{ 272{
276 int ret; 273 int ret;
@@ -309,7 +306,13 @@ static void start_wakeup_tracer(struct trace_array *tr)
309 306
310 register_ftrace_function(&trace_ops); 307 register_ftrace_function(&trace_ops);
311 308
312 tracer_enabled = 1; 309 if (tracing_is_enabled()) {
310 tracer_enabled = 1;
311 save_tracer_enabled = 1;
312 } else {
313 tracer_enabled = 0;
314 save_tracer_enabled = 0;
315 }
313 316
314 return; 317 return;
315fail_deprobe_wake_new: 318fail_deprobe_wake_new:
@@ -321,49 +324,53 @@ fail_deprobe:
321static void stop_wakeup_tracer(struct trace_array *tr) 324static void stop_wakeup_tracer(struct trace_array *tr)
322{ 325{
323 tracer_enabled = 0; 326 tracer_enabled = 0;
327 save_tracer_enabled = 0;
324 unregister_ftrace_function(&trace_ops); 328 unregister_ftrace_function(&trace_ops);
325 unregister_trace_sched_switch(probe_wakeup_sched_switch); 329 unregister_trace_sched_switch(probe_wakeup_sched_switch);
326 unregister_trace_sched_wakeup_new(probe_wakeup); 330 unregister_trace_sched_wakeup_new(probe_wakeup);
327 unregister_trace_sched_wakeup(probe_wakeup); 331 unregister_trace_sched_wakeup(probe_wakeup);
328} 332}
329 333
330static void wakeup_tracer_init(struct trace_array *tr) 334static int wakeup_tracer_init(struct trace_array *tr)
331{ 335{
332 wakeup_trace = tr; 336 wakeup_trace = tr;
333 337 start_wakeup_tracer(tr);
334 if (tr->ctrl) 338 return 0;
335 start_wakeup_tracer(tr);
336} 339}
337 340
338static void wakeup_tracer_reset(struct trace_array *tr) 341static void wakeup_tracer_reset(struct trace_array *tr)
339{ 342{
340 if (tr->ctrl) { 343 stop_wakeup_tracer(tr);
341 stop_wakeup_tracer(tr); 344 /* make sure we put back any tasks we are tracing */
342 /* make sure we put back any tasks we are tracing */ 345 wakeup_reset(tr);
343 wakeup_reset(tr); 346}
344 } 347
348static void wakeup_tracer_start(struct trace_array *tr)
349{
350 wakeup_reset(tr);
351 tracer_enabled = 1;
352 save_tracer_enabled = 1;
345} 353}
346 354
347static void wakeup_tracer_ctrl_update(struct trace_array *tr) 355static void wakeup_tracer_stop(struct trace_array *tr)
348{ 356{
349 if (tr->ctrl) 357 tracer_enabled = 0;
350 start_wakeup_tracer(tr); 358 save_tracer_enabled = 0;
351 else
352 stop_wakeup_tracer(tr);
353} 359}
354 360
355static void wakeup_tracer_open(struct trace_iterator *iter) 361static void wakeup_tracer_open(struct trace_iterator *iter)
356{ 362{
357 /* stop the trace while dumping */ 363 /* stop the trace while dumping */
358 if (iter->tr->ctrl) 364 tracer_enabled = 0;
359 stop_wakeup_tracer(iter->tr);
360} 365}
361 366
362static void wakeup_tracer_close(struct trace_iterator *iter) 367static void wakeup_tracer_close(struct trace_iterator *iter)
363{ 368{
364 /* forget about any processes we were recording */ 369 /* forget about any processes we were recording */
365 if (iter->tr->ctrl) 370 if (save_tracer_enabled) {
366 start_wakeup_tracer(iter->tr); 371 wakeup_reset(iter->tr);
372 tracer_enabled = 1;
373 }
367} 374}
368 375
369static struct tracer wakeup_tracer __read_mostly = 376static struct tracer wakeup_tracer __read_mostly =
@@ -371,9 +378,10 @@ static struct tracer wakeup_tracer __read_mostly =
371 .name = "wakeup", 378 .name = "wakeup",
372 .init = wakeup_tracer_init, 379 .init = wakeup_tracer_init,
373 .reset = wakeup_tracer_reset, 380 .reset = wakeup_tracer_reset,
381 .start = wakeup_tracer_start,
382 .stop = wakeup_tracer_stop,
374 .open = wakeup_tracer_open, 383 .open = wakeup_tracer_open,
375 .close = wakeup_tracer_close, 384 .close = wakeup_tracer_close,
376 .ctrl_update = wakeup_tracer_ctrl_update,
377 .print_max = 1, 385 .print_max = 1,
378#ifdef CONFIG_FTRACE_SELFTEST 386#ifdef CONFIG_FTRACE_SELFTEST
379 .selftest = trace_selftest_startup_wakeup, 387 .selftest = trace_selftest_startup_wakeup,
diff --git a/kernel/trace/trace_selftest.c b/kernel/trace/trace_selftest.c
index 90bc752a7580..88c8eb70f54a 100644
--- a/kernel/trace/trace_selftest.c
+++ b/kernel/trace/trace_selftest.c
@@ -13,6 +13,7 @@ static inline int trace_valid_entry(struct trace_entry *entry)
13 case TRACE_STACK: 13 case TRACE_STACK:
14 case TRACE_PRINT: 14 case TRACE_PRINT:
15 case TRACE_SPECIAL: 15 case TRACE_SPECIAL:
16 case TRACE_BRANCH:
16 return 1; 17 return 1;
17 } 18 }
18 return 0; 19 return 0;
@@ -51,7 +52,7 @@ static int trace_test_buffer(struct trace_array *tr, unsigned long *count)
51 int cpu, ret = 0; 52 int cpu, ret = 0;
52 53
53 /* Don't allow flipping of max traces now */ 54 /* Don't allow flipping of max traces now */
54 raw_local_irq_save(flags); 55 local_irq_save(flags);
55 __raw_spin_lock(&ftrace_max_lock); 56 __raw_spin_lock(&ftrace_max_lock);
56 57
57 cnt = ring_buffer_entries(tr->buffer); 58 cnt = ring_buffer_entries(tr->buffer);
@@ -62,7 +63,7 @@ static int trace_test_buffer(struct trace_array *tr, unsigned long *count)
62 break; 63 break;
63 } 64 }
64 __raw_spin_unlock(&ftrace_max_lock); 65 __raw_spin_unlock(&ftrace_max_lock);
65 raw_local_irq_restore(flags); 66 local_irq_restore(flags);
66 67
67 if (count) 68 if (count)
68 *count = cnt; 69 *count = cnt;
@@ -70,6 +71,11 @@ static int trace_test_buffer(struct trace_array *tr, unsigned long *count)
70 return ret; 71 return ret;
71} 72}
72 73
74static inline void warn_failed_init_tracer(struct tracer *trace, int init_ret)
75{
76 printk(KERN_WARNING "Failed to init %s tracer, init returned %d\n",
77 trace->name, init_ret);
78}
73#ifdef CONFIG_FUNCTION_TRACER 79#ifdef CONFIG_FUNCTION_TRACER
74 80
75#ifdef CONFIG_DYNAMIC_FTRACE 81#ifdef CONFIG_DYNAMIC_FTRACE
@@ -110,8 +116,11 @@ int trace_selftest_startup_dynamic_tracing(struct tracer *trace,
110 ftrace_set_filter(func_name, strlen(func_name), 1); 116 ftrace_set_filter(func_name, strlen(func_name), 1);
111 117
112 /* enable tracing */ 118 /* enable tracing */
113 tr->ctrl = 1; 119 ret = trace->init(tr);
114 trace->init(tr); 120 if (ret) {
121 warn_failed_init_tracer(trace, ret);
122 goto out;
123 }
115 124
116 /* Sleep for a 1/10 of a second */ 125 /* Sleep for a 1/10 of a second */
117 msleep(100); 126 msleep(100);
@@ -134,13 +143,13 @@ int trace_selftest_startup_dynamic_tracing(struct tracer *trace,
134 msleep(100); 143 msleep(100);
135 144
136 /* stop the tracing. */ 145 /* stop the tracing. */
137 tr->ctrl = 0; 146 tracing_stop();
138 trace->ctrl_update(tr);
139 ftrace_enabled = 0; 147 ftrace_enabled = 0;
140 148
141 /* check the trace buffer */ 149 /* check the trace buffer */
142 ret = trace_test_buffer(tr, &count); 150 ret = trace_test_buffer(tr, &count);
143 trace->reset(tr); 151 trace->reset(tr);
152 tracing_start();
144 153
145 /* we should only have one item */ 154 /* we should only have one item */
146 if (!ret && count != 1) { 155 if (!ret && count != 1) {
@@ -148,6 +157,7 @@ int trace_selftest_startup_dynamic_tracing(struct tracer *trace,
148 ret = -1; 157 ret = -1;
149 goto out; 158 goto out;
150 } 159 }
160
151 out: 161 out:
152 ftrace_enabled = save_ftrace_enabled; 162 ftrace_enabled = save_ftrace_enabled;
153 tracer_enabled = save_tracer_enabled; 163 tracer_enabled = save_tracer_enabled;
@@ -180,18 +190,22 @@ trace_selftest_startup_function(struct tracer *trace, struct trace_array *tr)
180 ftrace_enabled = 1; 190 ftrace_enabled = 1;
181 tracer_enabled = 1; 191 tracer_enabled = 1;
182 192
183 tr->ctrl = 1; 193 ret = trace->init(tr);
184 trace->init(tr); 194 if (ret) {
195 warn_failed_init_tracer(trace, ret);
196 goto out;
197 }
198
185 /* Sleep for a 1/10 of a second */ 199 /* Sleep for a 1/10 of a second */
186 msleep(100); 200 msleep(100);
187 /* stop the tracing. */ 201 /* stop the tracing. */
188 tr->ctrl = 0; 202 tracing_stop();
189 trace->ctrl_update(tr);
190 ftrace_enabled = 0; 203 ftrace_enabled = 0;
191 204
192 /* check the trace buffer */ 205 /* check the trace buffer */
193 ret = trace_test_buffer(tr, &count); 206 ret = trace_test_buffer(tr, &count);
194 trace->reset(tr); 207 trace->reset(tr);
208 tracing_start();
195 209
196 if (!ret && !count) { 210 if (!ret && !count) {
197 printk(KERN_CONT ".. no entries found .."); 211 printk(KERN_CONT ".. no entries found ..");
@@ -223,8 +237,12 @@ trace_selftest_startup_irqsoff(struct tracer *trace, struct trace_array *tr)
223 int ret; 237 int ret;
224 238
225 /* start the tracing */ 239 /* start the tracing */
226 tr->ctrl = 1; 240 ret = trace->init(tr);
227 trace->init(tr); 241 if (ret) {
242 warn_failed_init_tracer(trace, ret);
243 return ret;
244 }
245
228 /* reset the max latency */ 246 /* reset the max latency */
229 tracing_max_latency = 0; 247 tracing_max_latency = 0;
230 /* disable interrupts for a bit */ 248 /* disable interrupts for a bit */
@@ -232,13 +250,13 @@ trace_selftest_startup_irqsoff(struct tracer *trace, struct trace_array *tr)
232 udelay(100); 250 udelay(100);
233 local_irq_enable(); 251 local_irq_enable();
234 /* stop the tracing. */ 252 /* stop the tracing. */
235 tr->ctrl = 0; 253 tracing_stop();
236 trace->ctrl_update(tr);
237 /* check both trace buffers */ 254 /* check both trace buffers */
238 ret = trace_test_buffer(tr, NULL); 255 ret = trace_test_buffer(tr, NULL);
239 if (!ret) 256 if (!ret)
240 ret = trace_test_buffer(&max_tr, &count); 257 ret = trace_test_buffer(&max_tr, &count);
241 trace->reset(tr); 258 trace->reset(tr);
259 tracing_start();
242 260
243 if (!ret && !count) { 261 if (!ret && !count) {
244 printk(KERN_CONT ".. no entries found .."); 262 printk(KERN_CONT ".. no entries found ..");
@@ -259,9 +277,26 @@ trace_selftest_startup_preemptoff(struct tracer *trace, struct trace_array *tr)
259 unsigned long count; 277 unsigned long count;
260 int ret; 278 int ret;
261 279
280 /*
281 * Now that the big kernel lock is no longer preemptable,
282 * and this is called with the BKL held, it will always
283 * fail. If preemption is already disabled, simply
284 * pass the test. When the BKL is removed, or becomes
285 * preemptible again, we will once again test this,
286 * so keep it in.
287 */
288 if (preempt_count()) {
289 printk(KERN_CONT "can not test ... force ");
290 return 0;
291 }
292
262 /* start the tracing */ 293 /* start the tracing */
263 tr->ctrl = 1; 294 ret = trace->init(tr);
264 trace->init(tr); 295 if (ret) {
296 warn_failed_init_tracer(trace, ret);
297 return ret;
298 }
299
265 /* reset the max latency */ 300 /* reset the max latency */
266 tracing_max_latency = 0; 301 tracing_max_latency = 0;
267 /* disable preemption for a bit */ 302 /* disable preemption for a bit */
@@ -269,13 +304,13 @@ trace_selftest_startup_preemptoff(struct tracer *trace, struct trace_array *tr)
269 udelay(100); 304 udelay(100);
270 preempt_enable(); 305 preempt_enable();
271 /* stop the tracing. */ 306 /* stop the tracing. */
272 tr->ctrl = 0; 307 tracing_stop();
273 trace->ctrl_update(tr);
274 /* check both trace buffers */ 308 /* check both trace buffers */
275 ret = trace_test_buffer(tr, NULL); 309 ret = trace_test_buffer(tr, NULL);
276 if (!ret) 310 if (!ret)
277 ret = trace_test_buffer(&max_tr, &count); 311 ret = trace_test_buffer(&max_tr, &count);
278 trace->reset(tr); 312 trace->reset(tr);
313 tracing_start();
279 314
280 if (!ret && !count) { 315 if (!ret && !count) {
281 printk(KERN_CONT ".. no entries found .."); 316 printk(KERN_CONT ".. no entries found ..");
@@ -296,9 +331,25 @@ trace_selftest_startup_preemptirqsoff(struct tracer *trace, struct trace_array *
296 unsigned long count; 331 unsigned long count;
297 int ret; 332 int ret;
298 333
334 /*
335 * Now that the big kernel lock is no longer preemptable,
336 * and this is called with the BKL held, it will always
337 * fail. If preemption is already disabled, simply
338 * pass the test. When the BKL is removed, or becomes
339 * preemptible again, we will once again test this,
340 * so keep it in.
341 */
342 if (preempt_count()) {
343 printk(KERN_CONT "can not test ... force ");
344 return 0;
345 }
346
299 /* start the tracing */ 347 /* start the tracing */
300 tr->ctrl = 1; 348 ret = trace->init(tr);
301 trace->init(tr); 349 if (ret) {
350 warn_failed_init_tracer(trace, ret);
351 goto out;
352 }
302 353
303 /* reset the max latency */ 354 /* reset the max latency */
304 tracing_max_latency = 0; 355 tracing_max_latency = 0;
@@ -312,27 +363,30 @@ trace_selftest_startup_preemptirqsoff(struct tracer *trace, struct trace_array *
312 local_irq_enable(); 363 local_irq_enable();
313 364
314 /* stop the tracing. */ 365 /* stop the tracing. */
315 tr->ctrl = 0; 366 tracing_stop();
316 trace->ctrl_update(tr);
317 /* check both trace buffers */ 367 /* check both trace buffers */
318 ret = trace_test_buffer(tr, NULL); 368 ret = trace_test_buffer(tr, NULL);
319 if (ret) 369 if (ret) {
370 tracing_start();
320 goto out; 371 goto out;
372 }
321 373
322 ret = trace_test_buffer(&max_tr, &count); 374 ret = trace_test_buffer(&max_tr, &count);
323 if (ret) 375 if (ret) {
376 tracing_start();
324 goto out; 377 goto out;
378 }
325 379
326 if (!ret && !count) { 380 if (!ret && !count) {
327 printk(KERN_CONT ".. no entries found .."); 381 printk(KERN_CONT ".. no entries found ..");
328 ret = -1; 382 ret = -1;
383 tracing_start();
329 goto out; 384 goto out;
330 } 385 }
331 386
332 /* do the test by disabling interrupts first this time */ 387 /* do the test by disabling interrupts first this time */
333 tracing_max_latency = 0; 388 tracing_max_latency = 0;
334 tr->ctrl = 1; 389 tracing_start();
335 trace->ctrl_update(tr);
336 preempt_disable(); 390 preempt_disable();
337 local_irq_disable(); 391 local_irq_disable();
338 udelay(100); 392 udelay(100);
@@ -341,8 +395,7 @@ trace_selftest_startup_preemptirqsoff(struct tracer *trace, struct trace_array *
341 local_irq_enable(); 395 local_irq_enable();
342 396
343 /* stop the tracing. */ 397 /* stop the tracing. */
344 tr->ctrl = 0; 398 tracing_stop();
345 trace->ctrl_update(tr);
346 /* check both trace buffers */ 399 /* check both trace buffers */
347 ret = trace_test_buffer(tr, NULL); 400 ret = trace_test_buffer(tr, NULL);
348 if (ret) 401 if (ret)
@@ -358,6 +411,7 @@ trace_selftest_startup_preemptirqsoff(struct tracer *trace, struct trace_array *
358 411
359 out: 412 out:
360 trace->reset(tr); 413 trace->reset(tr);
414 tracing_start();
361 tracing_max_latency = save_max; 415 tracing_max_latency = save_max;
362 416
363 return ret; 417 return ret;
@@ -423,8 +477,12 @@ trace_selftest_startup_wakeup(struct tracer *trace, struct trace_array *tr)
423 wait_for_completion(&isrt); 477 wait_for_completion(&isrt);
424 478
425 /* start the tracing */ 479 /* start the tracing */
426 tr->ctrl = 1; 480 ret = trace->init(tr);
427 trace->init(tr); 481 if (ret) {
482 warn_failed_init_tracer(trace, ret);
483 return ret;
484 }
485
428 /* reset the max latency */ 486 /* reset the max latency */
429 tracing_max_latency = 0; 487 tracing_max_latency = 0;
430 488
@@ -448,8 +506,7 @@ trace_selftest_startup_wakeup(struct tracer *trace, struct trace_array *tr)
448 msleep(100); 506 msleep(100);
449 507
450 /* stop the tracing. */ 508 /* stop the tracing. */
451 tr->ctrl = 0; 509 tracing_stop();
452 trace->ctrl_update(tr);
453 /* check both trace buffers */ 510 /* check both trace buffers */
454 ret = trace_test_buffer(tr, NULL); 511 ret = trace_test_buffer(tr, NULL);
455 if (!ret) 512 if (!ret)
@@ -457,6 +514,7 @@ trace_selftest_startup_wakeup(struct tracer *trace, struct trace_array *tr)
457 514
458 515
459 trace->reset(tr); 516 trace->reset(tr);
517 tracing_start();
460 518
461 tracing_max_latency = save_max; 519 tracing_max_latency = save_max;
462 520
@@ -480,16 +538,20 @@ trace_selftest_startup_sched_switch(struct tracer *trace, struct trace_array *tr
480 int ret; 538 int ret;
481 539
482 /* start the tracing */ 540 /* start the tracing */
483 tr->ctrl = 1; 541 ret = trace->init(tr);
484 trace->init(tr); 542 if (ret) {
543 warn_failed_init_tracer(trace, ret);
544 return ret;
545 }
546
485 /* Sleep for a 1/10 of a second */ 547 /* Sleep for a 1/10 of a second */
486 msleep(100); 548 msleep(100);
487 /* stop the tracing. */ 549 /* stop the tracing. */
488 tr->ctrl = 0; 550 tracing_stop();
489 trace->ctrl_update(tr);
490 /* check the trace buffer */ 551 /* check the trace buffer */
491 ret = trace_test_buffer(tr, &count); 552 ret = trace_test_buffer(tr, &count);
492 trace->reset(tr); 553 trace->reset(tr);
554 tracing_start();
493 555
494 if (!ret && !count) { 556 if (!ret && !count) {
495 printk(KERN_CONT ".. no entries found .."); 557 printk(KERN_CONT ".. no entries found ..");
@@ -508,17 +570,48 @@ trace_selftest_startup_sysprof(struct tracer *trace, struct trace_array *tr)
508 int ret; 570 int ret;
509 571
510 /* start the tracing */ 572 /* start the tracing */
511 tr->ctrl = 1; 573 ret = trace->init(tr);
512 trace->init(tr); 574 if (ret) {
575 warn_failed_init_tracer(trace, ret);
576 return 0;
577 }
578
513 /* Sleep for a 1/10 of a second */ 579 /* Sleep for a 1/10 of a second */
514 msleep(100); 580 msleep(100);
515 /* stop the tracing. */ 581 /* stop the tracing. */
516 tr->ctrl = 0; 582 tracing_stop();
517 trace->ctrl_update(tr);
518 /* check the trace buffer */ 583 /* check the trace buffer */
519 ret = trace_test_buffer(tr, &count); 584 ret = trace_test_buffer(tr, &count);
520 trace->reset(tr); 585 trace->reset(tr);
586 tracing_start();
521 587
522 return ret; 588 return ret;
523} 589}
524#endif /* CONFIG_SYSPROF_TRACER */ 590#endif /* CONFIG_SYSPROF_TRACER */
591
592#ifdef CONFIG_BRANCH_TRACER
593int
594trace_selftest_startup_branch(struct tracer *trace, struct trace_array *tr)
595{
596 unsigned long count;
597 int ret;
598
599 /* start the tracing */
600 ret = trace->init(tr);
601 if (ret) {
602 warn_failed_init_tracer(trace, ret);
603 return ret;
604 }
605
606 /* Sleep for a 1/10 of a second */
607 msleep(100);
608 /* stop the tracing. */
609 tracing_stop();
610 /* check the trace buffer */
611 ret = trace_test_buffer(tr, &count);
612 trace->reset(tr);
613 tracing_start();
614
615 return ret;
616}
617#endif /* CONFIG_BRANCH_TRACER */
diff --git a/kernel/trace/trace_stack.c b/kernel/trace/trace_stack.c
index be682b62fe58..fde3be15c642 100644
--- a/kernel/trace/trace_stack.c
+++ b/kernel/trace/trace_stack.c
@@ -107,8 +107,7 @@ stack_trace_call(unsigned long ip, unsigned long parent_ip)
107 if (unlikely(!ftrace_enabled || stack_trace_disabled)) 107 if (unlikely(!ftrace_enabled || stack_trace_disabled))
108 return; 108 return;
109 109
110 resched = need_resched(); 110 resched = ftrace_preempt_disable();
111 preempt_disable_notrace();
112 111
113 cpu = raw_smp_processor_id(); 112 cpu = raw_smp_processor_id();
114 /* no atomic needed, we only modify this variable by this cpu */ 113 /* no atomic needed, we only modify this variable by this cpu */
@@ -120,10 +119,7 @@ stack_trace_call(unsigned long ip, unsigned long parent_ip)
120 out: 119 out:
121 per_cpu(trace_active, cpu)--; 120 per_cpu(trace_active, cpu)--;
122 /* prevent recursion in schedule */ 121 /* prevent recursion in schedule */
123 if (resched) 122 ftrace_preempt_enable(resched);
124 preempt_enable_no_resched_notrace();
125 else
126 preempt_enable_notrace();
127} 123}
128 124
129static struct ftrace_ops trace_ops __read_mostly = 125static struct ftrace_ops trace_ops __read_mostly =
@@ -184,11 +180,16 @@ static struct file_operations stack_max_size_fops = {
184static void * 180static void *
185t_next(struct seq_file *m, void *v, loff_t *pos) 181t_next(struct seq_file *m, void *v, loff_t *pos)
186{ 182{
187 long i = (long)m->private; 183 long i;
188 184
189 (*pos)++; 185 (*pos)++;
190 186
191 i++; 187 if (v == SEQ_START_TOKEN)
188 i = 0;
189 else {
190 i = *(long *)v;
191 i++;
192 }
192 193
193 if (i >= max_stack_trace.nr_entries || 194 if (i >= max_stack_trace.nr_entries ||
194 stack_dump_trace[i] == ULONG_MAX) 195 stack_dump_trace[i] == ULONG_MAX)
@@ -201,12 +202,15 @@ t_next(struct seq_file *m, void *v, loff_t *pos)
201 202
202static void *t_start(struct seq_file *m, loff_t *pos) 203static void *t_start(struct seq_file *m, loff_t *pos)
203{ 204{
204 void *t = &m->private; 205 void *t = SEQ_START_TOKEN;
205 loff_t l = 0; 206 loff_t l = 0;
206 207
207 local_irq_disable(); 208 local_irq_disable();
208 __raw_spin_lock(&max_stack_lock); 209 __raw_spin_lock(&max_stack_lock);
209 210
211 if (*pos == 0)
212 return SEQ_START_TOKEN;
213
210 for (; t && l < *pos; t = t_next(m, t, &l)) 214 for (; t && l < *pos; t = t_next(m, t, &l))
211 ; 215 ;
212 216
@@ -235,10 +239,10 @@ static int trace_lookup_stack(struct seq_file *m, long i)
235 239
236static int t_show(struct seq_file *m, void *v) 240static int t_show(struct seq_file *m, void *v)
237{ 241{
238 long i = *(long *)v; 242 long i;
239 int size; 243 int size;
240 244
241 if (i < 0) { 245 if (v == SEQ_START_TOKEN) {
242 seq_printf(m, " Depth Size Location" 246 seq_printf(m, " Depth Size Location"
243 " (%d entries)\n" 247 " (%d entries)\n"
244 " ----- ---- --------\n", 248 " ----- ---- --------\n",
@@ -246,6 +250,8 @@ static int t_show(struct seq_file *m, void *v)
246 return 0; 250 return 0;
247 } 251 }
248 252
253 i = *(long *)v;
254
249 if (i >= max_stack_trace.nr_entries || 255 if (i >= max_stack_trace.nr_entries ||
250 stack_dump_trace[i] == ULONG_MAX) 256 stack_dump_trace[i] == ULONG_MAX)
251 return 0; 257 return 0;
@@ -275,10 +281,6 @@ static int stack_trace_open(struct inode *inode, struct file *file)
275 int ret; 281 int ret;
276 282
277 ret = seq_open(file, &stack_trace_seq_ops); 283 ret = seq_open(file, &stack_trace_seq_ops);
278 if (!ret) {
279 struct seq_file *m = file->private_data;
280 m->private = (void *)-1;
281 }
282 284
283 return ret; 285 return ret;
284} 286}
diff --git a/kernel/trace/trace_sysprof.c b/kernel/trace/trace_sysprof.c
index 9587d3bcba55..54960edb96d0 100644
--- a/kernel/trace/trace_sysprof.c
+++ b/kernel/trace/trace_sysprof.c
@@ -261,27 +261,17 @@ static void stop_stack_trace(struct trace_array *tr)
261 mutex_unlock(&sample_timer_lock); 261 mutex_unlock(&sample_timer_lock);
262} 262}
263 263
264static void stack_trace_init(struct trace_array *tr) 264static int stack_trace_init(struct trace_array *tr)
265{ 265{
266 sysprof_trace = tr; 266 sysprof_trace = tr;
267 267
268 if (tr->ctrl) 268 start_stack_trace(tr);
269 start_stack_trace(tr); 269 return 0;
270} 270}
271 271
272static void stack_trace_reset(struct trace_array *tr) 272static void stack_trace_reset(struct trace_array *tr)
273{ 273{
274 if (tr->ctrl) 274 stop_stack_trace(tr);
275 stop_stack_trace(tr);
276}
277
278static void stack_trace_ctrl_update(struct trace_array *tr)
279{
280 /* When starting a new trace, reset the buffers */
281 if (tr->ctrl)
282 start_stack_trace(tr);
283 else
284 stop_stack_trace(tr);
285} 275}
286 276
287static struct tracer stack_trace __read_mostly = 277static struct tracer stack_trace __read_mostly =
@@ -289,7 +279,6 @@ static struct tracer stack_trace __read_mostly =
289 .name = "sysprof", 279 .name = "sysprof",
290 .init = stack_trace_init, 280 .init = stack_trace_init,
291 .reset = stack_trace_reset, 281 .reset = stack_trace_reset,
292 .ctrl_update = stack_trace_ctrl_update,
293#ifdef CONFIG_FTRACE_SELFTEST 282#ifdef CONFIG_FTRACE_SELFTEST
294 .selftest = trace_selftest_startup_sysprof, 283 .selftest = trace_selftest_startup_sysprof,
295#endif 284#endif
diff --git a/kernel/tracepoint.c b/kernel/tracepoint.c
index af8c85664882..79602740bbb5 100644
--- a/kernel/tracepoint.c
+++ b/kernel/tracepoint.c
@@ -43,6 +43,7 @@ static DEFINE_MUTEX(tracepoints_mutex);
43 */ 43 */
44#define TRACEPOINT_HASH_BITS 6 44#define TRACEPOINT_HASH_BITS 6
45#define TRACEPOINT_TABLE_SIZE (1 << TRACEPOINT_HASH_BITS) 45#define TRACEPOINT_TABLE_SIZE (1 << TRACEPOINT_HASH_BITS)
46static struct hlist_head tracepoint_table[TRACEPOINT_TABLE_SIZE];
46 47
47/* 48/*
48 * Note about RCU : 49 * Note about RCU :
@@ -54,40 +55,43 @@ struct tracepoint_entry {
54 struct hlist_node hlist; 55 struct hlist_node hlist;
55 void **funcs; 56 void **funcs;
56 int refcount; /* Number of times armed. 0 if disarmed. */ 57 int refcount; /* Number of times armed. 0 if disarmed. */
57 struct rcu_head rcu;
58 void *oldptr;
59 unsigned char rcu_pending:1;
60 char name[0]; 58 char name[0];
61}; 59};
62 60
63static struct hlist_head tracepoint_table[TRACEPOINT_TABLE_SIZE]; 61struct tp_probes {
62 union {
63 struct rcu_head rcu;
64 struct list_head list;
65 } u;
66 void *probes[0];
67};
64 68
65static void free_old_closure(struct rcu_head *head) 69static inline void *allocate_probes(int count)
66{ 70{
67 struct tracepoint_entry *entry = container_of(head, 71 struct tp_probes *p = kmalloc(count * sizeof(void *)
68 struct tracepoint_entry, rcu); 72 + sizeof(struct tp_probes), GFP_KERNEL);
69 kfree(entry->oldptr); 73 return p == NULL ? NULL : p->probes;
70 /* Make sure we free the data before setting the pending flag to 0 */
71 smp_wmb();
72 entry->rcu_pending = 0;
73} 74}
74 75
75static void tracepoint_entry_free_old(struct tracepoint_entry *entry, void *old) 76static void rcu_free_old_probes(struct rcu_head *head)
76{ 77{
77 if (!old) 78 kfree(container_of(head, struct tp_probes, u.rcu));
78 return; 79}
79 entry->oldptr = old; 80
80 entry->rcu_pending = 1; 81static inline void release_probes(void *old)
81 /* write rcu_pending before calling the RCU callback */ 82{
82 smp_wmb(); 83 if (old) {
83 call_rcu_sched(&entry->rcu, free_old_closure); 84 struct tp_probes *tp_probes = container_of(old,
85 struct tp_probes, probes[0]);
86 call_rcu_sched(&tp_probes->u.rcu, rcu_free_old_probes);
87 }
84} 88}
85 89
86static void debug_print_probes(struct tracepoint_entry *entry) 90static void debug_print_probes(struct tracepoint_entry *entry)
87{ 91{
88 int i; 92 int i;
89 93
90 if (!tracepoint_debug) 94 if (!tracepoint_debug || !entry->funcs)
91 return; 95 return;
92 96
93 for (i = 0; entry->funcs[i]; i++) 97 for (i = 0; entry->funcs[i]; i++)
@@ -111,12 +115,13 @@ tracepoint_entry_add_probe(struct tracepoint_entry *entry, void *probe)
111 return ERR_PTR(-EEXIST); 115 return ERR_PTR(-EEXIST);
112 } 116 }
113 /* + 2 : one for new probe, one for NULL func */ 117 /* + 2 : one for new probe, one for NULL func */
114 new = kzalloc((nr_probes + 2) * sizeof(void *), GFP_KERNEL); 118 new = allocate_probes(nr_probes + 2);
115 if (new == NULL) 119 if (new == NULL)
116 return ERR_PTR(-ENOMEM); 120 return ERR_PTR(-ENOMEM);
117 if (old) 121 if (old)
118 memcpy(new, old, nr_probes * sizeof(void *)); 122 memcpy(new, old, nr_probes * sizeof(void *));
119 new[nr_probes] = probe; 123 new[nr_probes] = probe;
124 new[nr_probes + 1] = NULL;
120 entry->refcount = nr_probes + 1; 125 entry->refcount = nr_probes + 1;
121 entry->funcs = new; 126 entry->funcs = new;
122 debug_print_probes(entry); 127 debug_print_probes(entry);
@@ -132,7 +137,7 @@ tracepoint_entry_remove_probe(struct tracepoint_entry *entry, void *probe)
132 old = entry->funcs; 137 old = entry->funcs;
133 138
134 if (!old) 139 if (!old)
135 return NULL; 140 return ERR_PTR(-ENOENT);
136 141
137 debug_print_probes(entry); 142 debug_print_probes(entry);
138 /* (N -> M), (N > 1, M >= 0) probes */ 143 /* (N -> M), (N > 1, M >= 0) probes */
@@ -151,13 +156,13 @@ tracepoint_entry_remove_probe(struct tracepoint_entry *entry, void *probe)
151 int j = 0; 156 int j = 0;
152 /* N -> M, (N > 1, M > 0) */ 157 /* N -> M, (N > 1, M > 0) */
153 /* + 1 for NULL */ 158 /* + 1 for NULL */
154 new = kzalloc((nr_probes - nr_del + 1) 159 new = allocate_probes(nr_probes - nr_del + 1);
155 * sizeof(void *), GFP_KERNEL);
156 if (new == NULL) 160 if (new == NULL)
157 return ERR_PTR(-ENOMEM); 161 return ERR_PTR(-ENOMEM);
158 for (i = 0; old[i]; i++) 162 for (i = 0; old[i]; i++)
159 if ((probe && old[i] != probe)) 163 if ((probe && old[i] != probe))
160 new[j++] = old[i]; 164 new[j++] = old[i];
165 new[nr_probes - nr_del] = NULL;
161 entry->refcount = nr_probes - nr_del; 166 entry->refcount = nr_probes - nr_del;
162 entry->funcs = new; 167 entry->funcs = new;
163 } 168 }
@@ -215,7 +220,6 @@ static struct tracepoint_entry *add_tracepoint(const char *name)
215 memcpy(&e->name[0], name, name_len); 220 memcpy(&e->name[0], name, name_len);
216 e->funcs = NULL; 221 e->funcs = NULL;
217 e->refcount = 0; 222 e->refcount = 0;
218 e->rcu_pending = 0;
219 hlist_add_head(&e->hlist, head); 223 hlist_add_head(&e->hlist, head);
220 return e; 224 return e;
221} 225}
@@ -224,32 +228,10 @@ static struct tracepoint_entry *add_tracepoint(const char *name)
224 * Remove the tracepoint from the tracepoint hash table. Must be called with 228 * Remove the tracepoint from the tracepoint hash table. Must be called with
225 * mutex_lock held. 229 * mutex_lock held.
226 */ 230 */
227static int remove_tracepoint(const char *name) 231static inline void remove_tracepoint(struct tracepoint_entry *e)
228{ 232{
229 struct hlist_head *head;
230 struct hlist_node *node;
231 struct tracepoint_entry *e;
232 int found = 0;
233 size_t len = strlen(name) + 1;
234 u32 hash = jhash(name, len-1, 0);
235
236 head = &tracepoint_table[hash & (TRACEPOINT_TABLE_SIZE - 1)];
237 hlist_for_each_entry(e, node, head, hlist) {
238 if (!strcmp(name, e->name)) {
239 found = 1;
240 break;
241 }
242 }
243 if (!found)
244 return -ENOENT;
245 if (e->refcount)
246 return -EBUSY;
247 hlist_del(&e->hlist); 233 hlist_del(&e->hlist);
248 /* Make sure the call_rcu_sched has been executed */
249 if (e->rcu_pending)
250 rcu_barrier_sched();
251 kfree(e); 234 kfree(e);
252 return 0;
253} 235}
254 236
255/* 237/*
@@ -280,6 +262,7 @@ static void set_tracepoint(struct tracepoint_entry **entry,
280static void disable_tracepoint(struct tracepoint *elem) 262static void disable_tracepoint(struct tracepoint *elem)
281{ 263{
282 elem->state = 0; 264 elem->state = 0;
265 rcu_assign_pointer(elem->funcs, NULL);
283} 266}
284 267
285/** 268/**
@@ -320,6 +303,23 @@ static void tracepoint_update_probes(void)
320 module_update_tracepoints(); 303 module_update_tracepoints();
321} 304}
322 305
306static void *tracepoint_add_probe(const char *name, void *probe)
307{
308 struct tracepoint_entry *entry;
309 void *old;
310
311 entry = get_tracepoint(name);
312 if (!entry) {
313 entry = add_tracepoint(name);
314 if (IS_ERR(entry))
315 return entry;
316 }
317 old = tracepoint_entry_add_probe(entry, probe);
318 if (IS_ERR(old) && !entry->refcount)
319 remove_tracepoint(entry);
320 return old;
321}
322
323/** 323/**
324 * tracepoint_probe_register - Connect a probe to a tracepoint 324 * tracepoint_probe_register - Connect a probe to a tracepoint
325 * @name: tracepoint name 325 * @name: tracepoint name
@@ -330,44 +330,36 @@ static void tracepoint_update_probes(void)
330 */ 330 */
331int tracepoint_probe_register(const char *name, void *probe) 331int tracepoint_probe_register(const char *name, void *probe)
332{ 332{
333 struct tracepoint_entry *entry;
334 int ret = 0;
335 void *old; 333 void *old;
336 334
337 mutex_lock(&tracepoints_mutex); 335 mutex_lock(&tracepoints_mutex);
338 entry = get_tracepoint(name); 336 old = tracepoint_add_probe(name, probe);
339 if (!entry) {
340 entry = add_tracepoint(name);
341 if (IS_ERR(entry)) {
342 ret = PTR_ERR(entry);
343 goto end;
344 }
345 }
346 /*
347 * If we detect that a call_rcu_sched is pending for this tracepoint,
348 * make sure it's executed now.
349 */
350 if (entry->rcu_pending)
351 rcu_barrier_sched();
352 old = tracepoint_entry_add_probe(entry, probe);
353 if (IS_ERR(old)) {
354 ret = PTR_ERR(old);
355 goto end;
356 }
357 mutex_unlock(&tracepoints_mutex); 337 mutex_unlock(&tracepoints_mutex);
338 if (IS_ERR(old))
339 return PTR_ERR(old);
340
358 tracepoint_update_probes(); /* may update entry */ 341 tracepoint_update_probes(); /* may update entry */
359 mutex_lock(&tracepoints_mutex); 342 release_probes(old);
360 entry = get_tracepoint(name); 343 return 0;
361 WARN_ON(!entry);
362 if (entry->rcu_pending)
363 rcu_barrier_sched();
364 tracepoint_entry_free_old(entry, old);
365end:
366 mutex_unlock(&tracepoints_mutex);
367 return ret;
368} 344}
369EXPORT_SYMBOL_GPL(tracepoint_probe_register); 345EXPORT_SYMBOL_GPL(tracepoint_probe_register);
370 346
347static void *tracepoint_remove_probe(const char *name, void *probe)
348{
349 struct tracepoint_entry *entry;
350 void *old;
351
352 entry = get_tracepoint(name);
353 if (!entry)
354 return ERR_PTR(-ENOENT);
355 old = tracepoint_entry_remove_probe(entry, probe);
356 if (IS_ERR(old))
357 return old;
358 if (!entry->refcount)
359 remove_tracepoint(entry);
360 return old;
361}
362
371/** 363/**
372 * tracepoint_probe_unregister - Disconnect a probe from a tracepoint 364 * tracepoint_probe_unregister - Disconnect a probe from a tracepoint
373 * @name: tracepoint name 365 * @name: tracepoint name
@@ -380,38 +372,104 @@ EXPORT_SYMBOL_GPL(tracepoint_probe_register);
380 */ 372 */
381int tracepoint_probe_unregister(const char *name, void *probe) 373int tracepoint_probe_unregister(const char *name, void *probe)
382{ 374{
383 struct tracepoint_entry *entry;
384 void *old; 375 void *old;
385 int ret = -ENOENT;
386 376
387 mutex_lock(&tracepoints_mutex); 377 mutex_lock(&tracepoints_mutex);
388 entry = get_tracepoint(name); 378 old = tracepoint_remove_probe(name, probe);
389 if (!entry)
390 goto end;
391 if (entry->rcu_pending)
392 rcu_barrier_sched();
393 old = tracepoint_entry_remove_probe(entry, probe);
394 if (!old) {
395 printk(KERN_WARNING "Warning: Trying to unregister a probe"
396 "that doesn't exist\n");
397 goto end;
398 }
399 mutex_unlock(&tracepoints_mutex); 379 mutex_unlock(&tracepoints_mutex);
380 if (IS_ERR(old))
381 return PTR_ERR(old);
382
400 tracepoint_update_probes(); /* may update entry */ 383 tracepoint_update_probes(); /* may update entry */
384 release_probes(old);
385 return 0;
386}
387EXPORT_SYMBOL_GPL(tracepoint_probe_unregister);
388
389static LIST_HEAD(old_probes);
390static int need_update;
391
392static void tracepoint_add_old_probes(void *old)
393{
394 need_update = 1;
395 if (old) {
396 struct tp_probes *tp_probes = container_of(old,
397 struct tp_probes, probes[0]);
398 list_add(&tp_probes->u.list, &old_probes);
399 }
400}
401
402/**
403 * tracepoint_probe_register_noupdate - register a probe but not connect
404 * @name: tracepoint name
405 * @probe: probe handler
406 *
407 * caller must call tracepoint_probe_update_all()
408 */
409int tracepoint_probe_register_noupdate(const char *name, void *probe)
410{
411 void *old;
412
401 mutex_lock(&tracepoints_mutex); 413 mutex_lock(&tracepoints_mutex);
402 entry = get_tracepoint(name); 414 old = tracepoint_add_probe(name, probe);
403 if (!entry) 415 if (IS_ERR(old)) {
404 goto end; 416 mutex_unlock(&tracepoints_mutex);
405 if (entry->rcu_pending) 417 return PTR_ERR(old);
406 rcu_barrier_sched(); 418 }
407 tracepoint_entry_free_old(entry, old); 419 tracepoint_add_old_probes(old);
408 remove_tracepoint(name); /* Ignore busy error message */
409 ret = 0;
410end:
411 mutex_unlock(&tracepoints_mutex); 420 mutex_unlock(&tracepoints_mutex);
412 return ret; 421 return 0;
413} 422}
414EXPORT_SYMBOL_GPL(tracepoint_probe_unregister); 423EXPORT_SYMBOL_GPL(tracepoint_probe_register_noupdate);
424
425/**
426 * tracepoint_probe_unregister_noupdate - remove a probe but not disconnect
427 * @name: tracepoint name
428 * @probe: probe function pointer
429 *
430 * caller must call tracepoint_probe_update_all()
431 */
432int tracepoint_probe_unregister_noupdate(const char *name, void *probe)
433{
434 void *old;
435
436 mutex_lock(&tracepoints_mutex);
437 old = tracepoint_remove_probe(name, probe);
438 if (IS_ERR(old)) {
439 mutex_unlock(&tracepoints_mutex);
440 return PTR_ERR(old);
441 }
442 tracepoint_add_old_probes(old);
443 mutex_unlock(&tracepoints_mutex);
444 return 0;
445}
446EXPORT_SYMBOL_GPL(tracepoint_probe_unregister_noupdate);
447
448/**
449 * tracepoint_probe_update_all - update tracepoints
450 */
451void tracepoint_probe_update_all(void)
452{
453 LIST_HEAD(release_probes);
454 struct tp_probes *pos, *next;
455
456 mutex_lock(&tracepoints_mutex);
457 if (!need_update) {
458 mutex_unlock(&tracepoints_mutex);
459 return;
460 }
461 if (!list_empty(&old_probes))
462 list_replace_init(&old_probes, &release_probes);
463 need_update = 0;
464 mutex_unlock(&tracepoints_mutex);
465
466 tracepoint_update_probes();
467 list_for_each_entry_safe(pos, next, &release_probes, u.list) {
468 list_del(&pos->u.list);
469 call_rcu_sched(&pos->u.rcu, rcu_free_old_probes);
470 }
471}
472EXPORT_SYMBOL_GPL(tracepoint_probe_update_all);
415 473
416/** 474/**
417 * tracepoint_get_iter_range - Get a next tracepoint iterator given a range. 475 * tracepoint_get_iter_range - Get a next tracepoint iterator given a range.
@@ -483,3 +541,36 @@ void tracepoint_iter_reset(struct tracepoint_iter *iter)
483 iter->tracepoint = NULL; 541 iter->tracepoint = NULL;
484} 542}
485EXPORT_SYMBOL_GPL(tracepoint_iter_reset); 543EXPORT_SYMBOL_GPL(tracepoint_iter_reset);
544
545#ifdef CONFIG_MODULES
546
547int tracepoint_module_notify(struct notifier_block *self,
548 unsigned long val, void *data)
549{
550 struct module *mod = data;
551
552 switch (val) {
553 case MODULE_STATE_COMING:
554 tracepoint_update_probe_range(mod->tracepoints,
555 mod->tracepoints + mod->num_tracepoints);
556 break;
557 case MODULE_STATE_GOING:
558 tracepoint_update_probe_range(mod->tracepoints,
559 mod->tracepoints + mod->num_tracepoints);
560 break;
561 }
562 return 0;
563}
564
565struct notifier_block tracepoint_module_nb = {
566 .notifier_call = tracepoint_module_notify,
567 .priority = 0,
568};
569
570static int init_tracepoints(void)
571{
572 return register_module_notifier(&tracepoint_module_nb);
573}
574__initcall(init_tracepoints);
575
576#endif /* CONFIG_MODULES */
diff --git a/lib/scatterlist.c b/lib/scatterlist.c
index 8d2688ff1352..b7b449dafbe5 100644
--- a/lib/scatterlist.c
+++ b/lib/scatterlist.c
@@ -395,7 +395,7 @@ void sg_miter_stop(struct sg_mapping_iter *miter)
395 WARN_ON(!irqs_disabled()); 395 WARN_ON(!irqs_disabled());
396 kunmap_atomic(miter->addr, KM_BIO_SRC_IRQ); 396 kunmap_atomic(miter->addr, KM_BIO_SRC_IRQ);
397 } else 397 } else
398 kunmap(miter->addr); 398 kunmap(miter->page);
399 399
400 miter->page = NULL; 400 miter->page = NULL;
401 miter->addr = NULL; 401 miter->addr = NULL;
diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c
index 6837a1014372..b5b2b15085a8 100644
--- a/mm/memory_hotplug.c
+++ b/mm/memory_hotplug.c
@@ -22,7 +22,6 @@
22#include <linux/highmem.h> 22#include <linux/highmem.h>
23#include <linux/vmalloc.h> 23#include <linux/vmalloc.h>
24#include <linux/ioport.h> 24#include <linux/ioport.h>
25#include <linux/cpuset.h>
26#include <linux/delay.h> 25#include <linux/delay.h>
27#include <linux/migrate.h> 26#include <linux/migrate.h>
28#include <linux/page-isolation.h> 27#include <linux/page-isolation.h>
@@ -498,8 +497,6 @@ int add_memory(int nid, u64 start, u64 size)
498 /* we online node here. we can't roll back from here. */ 497 /* we online node here. we can't roll back from here. */
499 node_set_online(nid); 498 node_set_online(nid);
500 499
501 cpuset_track_online_nodes();
502
503 if (new_pgdat) { 500 if (new_pgdat) {
504 ret = register_one_node(nid); 501 ret = register_one_node(nid);
505 /* 502 /*
diff --git a/mm/migrate.c b/mm/migrate.c
index 385db89f0c33..1e0d6b237f44 100644
--- a/mm/migrate.c
+++ b/mm/migrate.c
@@ -522,15 +522,12 @@ static int writeout(struct address_space *mapping, struct page *page)
522 remove_migration_ptes(page, page); 522 remove_migration_ptes(page, page);
523 523
524 rc = mapping->a_ops->writepage(page, &wbc); 524 rc = mapping->a_ops->writepage(page, &wbc);
525 if (rc < 0)
526 /* I/O Error writing */
527 return -EIO;
528 525
529 if (rc != AOP_WRITEPAGE_ACTIVATE) 526 if (rc != AOP_WRITEPAGE_ACTIVATE)
530 /* unlocked. Relock */ 527 /* unlocked. Relock */
531 lock_page(page); 528 lock_page(page);
532 529
533 return -EAGAIN; 530 return (rc < 0) ? -EIO : -EAGAIN;
534} 531}
535 532
536/* 533/*
diff --git a/mm/vmalloc.c b/mm/vmalloc.c
index ba6b0f5f7fac..30f826d484f0 100644
--- a/mm/vmalloc.c
+++ b/mm/vmalloc.c
@@ -324,14 +324,14 @@ static struct vmap_area *alloc_vmap_area(unsigned long size,
324 324
325 BUG_ON(size & ~PAGE_MASK); 325 BUG_ON(size & ~PAGE_MASK);
326 326
327 addr = ALIGN(vstart, align);
328
329 va = kmalloc_node(sizeof(struct vmap_area), 327 va = kmalloc_node(sizeof(struct vmap_area),
330 gfp_mask & GFP_RECLAIM_MASK, node); 328 gfp_mask & GFP_RECLAIM_MASK, node);
331 if (unlikely(!va)) 329 if (unlikely(!va))
332 return ERR_PTR(-ENOMEM); 330 return ERR_PTR(-ENOMEM);
333 331
334retry: 332retry:
333 addr = ALIGN(vstart, align);
334
335 spin_lock(&vmap_area_lock); 335 spin_lock(&vmap_area_lock);
336 /* XXX: could have a last_hole cache */ 336 /* XXX: could have a last_hole cache */
337 n = vmap_area_root.rb_node; 337 n = vmap_area_root.rb_node;
@@ -362,7 +362,7 @@ retry:
362 goto found; 362 goto found;
363 } 363 }
364 364
365 while (addr + size >= first->va_start && addr + size <= vend) { 365 while (addr + size > first->va_start && addr + size <= vend) {
366 addr = ALIGN(first->va_end + PAGE_SIZE, align); 366 addr = ALIGN(first->va_end + PAGE_SIZE, align);
367 367
368 n = rb_next(&first->rb_node); 368 n = rb_next(&first->rb_node);
@@ -522,13 +522,24 @@ static void __purge_vmap_area_lazy(unsigned long *start, unsigned long *end,
522} 522}
523 523
524/* 524/*
525 * Kick off a purge of the outstanding lazy areas. Don't bother if somebody
526 * is already purging.
527 */
528static void try_purge_vmap_area_lazy(void)
529{
530 unsigned long start = ULONG_MAX, end = 0;
531
532 __purge_vmap_area_lazy(&start, &end, 0, 0);
533}
534
535/*
525 * Kick off a purge of the outstanding lazy areas. 536 * Kick off a purge of the outstanding lazy areas.
526 */ 537 */
527static void purge_vmap_area_lazy(void) 538static void purge_vmap_area_lazy(void)
528{ 539{
529 unsigned long start = ULONG_MAX, end = 0; 540 unsigned long start = ULONG_MAX, end = 0;
530 541
531 __purge_vmap_area_lazy(&start, &end, 0, 0); 542 __purge_vmap_area_lazy(&start, &end, 1, 0);
532} 543}
533 544
534/* 545/*
@@ -539,7 +550,7 @@ static void free_unmap_vmap_area(struct vmap_area *va)
539 va->flags |= VM_LAZY_FREE; 550 va->flags |= VM_LAZY_FREE;
540 atomic_add((va->va_end - va->va_start) >> PAGE_SHIFT, &vmap_lazy_nr); 551 atomic_add((va->va_end - va->va_start) >> PAGE_SHIFT, &vmap_lazy_nr);
541 if (unlikely(atomic_read(&vmap_lazy_nr) > lazy_max_pages())) 552 if (unlikely(atomic_read(&vmap_lazy_nr) > lazy_max_pages()))
542 purge_vmap_area_lazy(); 553 try_purge_vmap_area_lazy();
543} 554}
544 555
545static struct vmap_area *find_vmap_area(unsigned long addr) 556static struct vmap_area *find_vmap_area(unsigned long addr)
diff --git a/mm/vmscan.c b/mm/vmscan.c
index c141b3e78071..7ea1440b53db 100644
--- a/mm/vmscan.c
+++ b/mm/vmscan.c
@@ -623,6 +623,8 @@ static unsigned long shrink_page_list(struct list_head *page_list,
623 * Try to allocate it some swap space here. 623 * Try to allocate it some swap space here.
624 */ 624 */
625 if (PageAnon(page) && !PageSwapCache(page)) { 625 if (PageAnon(page) && !PageSwapCache(page)) {
626 if (!(sc->gfp_mask & __GFP_IO))
627 goto keep_locked;
626 switch (try_to_munlock(page)) { 628 switch (try_to_munlock(page)) {
627 case SWAP_FAIL: /* shouldn't happen */ 629 case SWAP_FAIL: /* shouldn't happen */
628 case SWAP_AGAIN: 630 case SWAP_AGAIN:
@@ -634,6 +636,7 @@ static unsigned long shrink_page_list(struct list_head *page_list,
634 } 636 }
635 if (!add_to_swap(page, GFP_ATOMIC)) 637 if (!add_to_swap(page, GFP_ATOMIC))
636 goto activate_locked; 638 goto activate_locked;
639 may_enter_fs = 1;
637 } 640 }
638#endif /* CONFIG_SWAP */ 641#endif /* CONFIG_SWAP */
639 642
@@ -1386,9 +1389,9 @@ static void get_scan_ratio(struct zone *zone, struct scan_control *sc,
1386 file_prio = 200 - sc->swappiness; 1389 file_prio = 200 - sc->swappiness;
1387 1390
1388 /* 1391 /*
1389 * anon recent_rotated[0] 1392 * The amount of pressure on anon vs file pages is inversely
1390 * %anon = 100 * ----------- / ----------------- * IO cost 1393 * proportional to the fraction of recently scanned pages on
1391 * anon + file rotate_sum 1394 * each list that were recently referenced and in active use.
1392 */ 1395 */
1393 ap = (anon_prio + 1) * (zone->recent_scanned[0] + 1); 1396 ap = (anon_prio + 1) * (zone->recent_scanned[0] + 1);
1394 ap /= zone->recent_rotated[0] + 1; 1397 ap /= zone->recent_rotated[0] + 1;
diff --git a/net/compat.c b/net/compat.c
index 6ce1a1cadcc0..a3a2ba0fac08 100644
--- a/net/compat.c
+++ b/net/compat.c
@@ -725,7 +725,7 @@ EXPORT_SYMBOL(compat_mc_getsockopt);
725static unsigned char nas[19]={AL(0),AL(3),AL(3),AL(3),AL(2),AL(3), 725static unsigned char nas[19]={AL(0),AL(3),AL(3),AL(3),AL(2),AL(3),
726 AL(3),AL(3),AL(4),AL(4),AL(4),AL(6), 726 AL(3),AL(3),AL(4),AL(4),AL(4),AL(6),
727 AL(6),AL(2),AL(5),AL(5),AL(3),AL(3), 727 AL(6),AL(2),AL(5),AL(5),AL(3),AL(3),
728 AL(6)}; 728 AL(4)};
729#undef AL 729#undef AL
730 730
731asmlinkage long compat_sys_sendmsg(int fd, struct compat_msghdr __user *msg, unsigned flags) 731asmlinkage long compat_sys_sendmsg(int fd, struct compat_msghdr __user *msg, unsigned flags)
@@ -738,52 +738,13 @@ asmlinkage long compat_sys_recvmsg(int fd, struct compat_msghdr __user *msg, uns
738 return sys_recvmsg(fd, (struct msghdr __user *)msg, flags | MSG_CMSG_COMPAT); 738 return sys_recvmsg(fd, (struct msghdr __user *)msg, flags | MSG_CMSG_COMPAT);
739} 739}
740 740
741asmlinkage long compat_sys_paccept(int fd, struct sockaddr __user *upeer_sockaddr,
742 int __user *upeer_addrlen,
743 const compat_sigset_t __user *sigmask,
744 compat_size_t sigsetsize, int flags)
745{
746 compat_sigset_t ss32;
747 sigset_t ksigmask, sigsaved;
748 int ret;
749
750 if (sigmask) {
751 if (sigsetsize != sizeof(compat_sigset_t))
752 return -EINVAL;
753 if (copy_from_user(&ss32, sigmask, sizeof(ss32)))
754 return -EFAULT;
755 sigset_from_compat(&ksigmask, &ss32);
756
757 sigdelsetmask(&ksigmask, sigmask(SIGKILL)|sigmask(SIGSTOP));
758 sigprocmask(SIG_SETMASK, &ksigmask, &sigsaved);
759 }
760
761 ret = do_accept(fd, upeer_sockaddr, upeer_addrlen, flags);
762
763 if (ret == -ERESTARTNOHAND) {
764 /*
765 * Don't restore the signal mask yet. Let do_signal() deliver
766 * the signal on the way back to userspace, before the signal
767 * mask is restored.
768 */
769 if (sigmask) {
770 memcpy(&current->saved_sigmask, &sigsaved,
771 sizeof(sigsaved));
772 set_restore_sigmask();
773 }
774 } else if (sigmask)
775 sigprocmask(SIG_SETMASK, &sigsaved, NULL);
776
777 return ret;
778}
779
780asmlinkage long compat_sys_socketcall(int call, u32 __user *args) 741asmlinkage long compat_sys_socketcall(int call, u32 __user *args)
781{ 742{
782 int ret; 743 int ret;
783 u32 a[6]; 744 u32 a[6];
784 u32 a0, a1; 745 u32 a0, a1;
785 746
786 if (call < SYS_SOCKET || call > SYS_PACCEPT) 747 if (call < SYS_SOCKET || call > SYS_ACCEPT4)
787 return -EINVAL; 748 return -EINVAL;
788 if (copy_from_user(a, args, nas[call])) 749 if (copy_from_user(a, args, nas[call]))
789 return -EFAULT; 750 return -EFAULT;
@@ -804,7 +765,7 @@ asmlinkage long compat_sys_socketcall(int call, u32 __user *args)
804 ret = sys_listen(a0, a1); 765 ret = sys_listen(a0, a1);
805 break; 766 break;
806 case SYS_ACCEPT: 767 case SYS_ACCEPT:
807 ret = do_accept(a0, compat_ptr(a1), compat_ptr(a[2]), 0); 768 ret = sys_accept4(a0, compat_ptr(a1), compat_ptr(a[2]), 0);
808 break; 769 break;
809 case SYS_GETSOCKNAME: 770 case SYS_GETSOCKNAME:
810 ret = sys_getsockname(a0, compat_ptr(a1), compat_ptr(a[2])); 771 ret = sys_getsockname(a0, compat_ptr(a1), compat_ptr(a[2]));
@@ -844,9 +805,8 @@ asmlinkage long compat_sys_socketcall(int call, u32 __user *args)
844 case SYS_RECVMSG: 805 case SYS_RECVMSG:
845 ret = compat_sys_recvmsg(a0, compat_ptr(a1), a[2]); 806 ret = compat_sys_recvmsg(a0, compat_ptr(a1), a[2]);
846 break; 807 break;
847 case SYS_PACCEPT: 808 case SYS_ACCEPT4:
848 ret = compat_sys_paccept(a0, compat_ptr(a1), compat_ptr(a[2]), 809 ret = sys_accept4(a0, compat_ptr(a1), compat_ptr(a[2]), a[3]);
849 compat_ptr(a[3]), a[4], a[5]);
850 break; 810 break;
851 default: 811 default:
852 ret = -EINVAL; 812 ret = -EINVAL;
diff --git a/net/core/pktgen.c b/net/core/pktgen.c
index a47f5bad110d..8997e912aaaf 100644
--- a/net/core/pktgen.c
+++ b/net/core/pktgen.c
@@ -1973,13 +1973,7 @@ static void pktgen_setup_inject(struct pktgen_dev *pkt_dev)
1973 1973
1974 /* make sure that we don't pick a non-existing transmit queue */ 1974 /* make sure that we don't pick a non-existing transmit queue */
1975 ntxq = pkt_dev->odev->real_num_tx_queues; 1975 ntxq = pkt_dev->odev->real_num_tx_queues;
1976 if (ntxq > num_online_cpus() && (pkt_dev->flags & F_QUEUE_MAP_CPU)) { 1976
1977 printk(KERN_WARNING "pktgen: WARNING: QUEUE_MAP_CPU "
1978 "disabled because CPU count (%d) exceeds number "
1979 "of tx queues (%d) on %s\n", num_online_cpus(), ntxq,
1980 pkt_dev->odev->name);
1981 pkt_dev->flags &= ~F_QUEUE_MAP_CPU;
1982 }
1983 if (ntxq <= pkt_dev->queue_map_min) { 1977 if (ntxq <= pkt_dev->queue_map_min) {
1984 printk(KERN_WARNING "pktgen: WARNING: Requested " 1978 printk(KERN_WARNING "pktgen: WARNING: Requested "
1985 "queue_map_min (zero-based) (%d) exceeds valid range " 1979 "queue_map_min (zero-based) (%d) exceeds valid range "
@@ -2202,6 +2196,7 @@ static void set_cur_queue_map(struct pktgen_dev *pkt_dev)
2202 } 2196 }
2203 pkt_dev->cur_queue_map = t; 2197 pkt_dev->cur_queue_map = t;
2204 } 2198 }
2199 pkt_dev->cur_queue_map = pkt_dev->cur_queue_map % pkt_dev->odev->real_num_tx_queues;
2205} 2200}
2206 2201
2207/* Increment/randomize headers according to flags and current values 2202/* Increment/randomize headers according to flags and current values
diff --git a/net/ipv4/af_inet.c b/net/ipv4/af_inet.c
index 1fbff5fa4241..1aa2dc9e380e 100644
--- a/net/ipv4/af_inet.c
+++ b/net/ipv4/af_inet.c
@@ -1117,6 +1117,7 @@ int inet_sk_rebuild_header(struct sock *sk)
1117 }, 1117 },
1118 }, 1118 },
1119 .proto = sk->sk_protocol, 1119 .proto = sk->sk_protocol,
1120 .flags = inet_sk_flowi_flags(sk),
1120 .uli_u = { 1121 .uli_u = {
1121 .ports = { 1122 .ports = {
1122 .sport = inet->sport, 1123 .sport = inet->sport,
diff --git a/net/ipv4/ipmr.c b/net/ipv4/ipmr.c
index b42e082cc170..25924b1eb2ef 100644
--- a/net/ipv4/ipmr.c
+++ b/net/ipv4/ipmr.c
@@ -1945,13 +1945,14 @@ int __init ip_mr_init(void)
1945 goto proc_cache_fail; 1945 goto proc_cache_fail;
1946#endif 1946#endif
1947 return 0; 1947 return 0;
1948reg_notif_fail:
1949 kmem_cache_destroy(mrt_cachep);
1950#ifdef CONFIG_PROC_FS 1948#ifdef CONFIG_PROC_FS
1951proc_vif_fail:
1952 unregister_netdevice_notifier(&ip_mr_notifier);
1953proc_cache_fail: 1949proc_cache_fail:
1954 proc_net_remove(&init_net, "ip_mr_vif"); 1950 proc_net_remove(&init_net, "ip_mr_vif");
1951proc_vif_fail:
1952 unregister_netdevice_notifier(&ip_mr_notifier);
1955#endif 1953#endif
1954reg_notif_fail:
1955 del_timer(&ipmr_expire_timer);
1956 kmem_cache_destroy(mrt_cachep);
1956 return err; 1957 return err;
1957} 1958}
diff --git a/net/ipv4/udp.c b/net/ipv4/udp.c
index cf02701ced48..98c1fd09be88 100644
--- a/net/ipv4/udp.c
+++ b/net/ipv4/udp.c
@@ -633,6 +633,7 @@ int udp_sendmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg,
633 .saddr = saddr, 633 .saddr = saddr,
634 .tos = tos } }, 634 .tos = tos } },
635 .proto = sk->sk_protocol, 635 .proto = sk->sk_protocol,
636 .flags = inet_sk_flowi_flags(sk),
636 .uli_u = { .ports = 637 .uli_u = { .ports =
637 { .sport = inet->sport, 638 { .sport = inet->sport,
638 .dport = dport } } }; 639 .dport = dport } } };
diff --git a/net/ipv6/ip6mr.c b/net/ipv6/ip6mr.c
index 52a7eb0e2c2c..0524769632e7 100644
--- a/net/ipv6/ip6mr.c
+++ b/net/ipv6/ip6mr.c
@@ -224,7 +224,7 @@ static struct file_operations ip6mr_vif_fops = {
224 .open = ip6mr_vif_open, 224 .open = ip6mr_vif_open,
225 .read = seq_read, 225 .read = seq_read,
226 .llseek = seq_lseek, 226 .llseek = seq_lseek,
227 .release = seq_release, 227 .release = seq_release_private,
228}; 228};
229 229
230static void *ipmr_mfc_seq_start(struct seq_file *seq, loff_t *pos) 230static void *ipmr_mfc_seq_start(struct seq_file *seq, loff_t *pos)
@@ -338,7 +338,7 @@ static struct file_operations ip6mr_mfc_fops = {
338 .open = ipmr_mfc_open, 338 .open = ipmr_mfc_open,
339 .read = seq_read, 339 .read = seq_read,
340 .llseek = seq_lseek, 340 .llseek = seq_lseek,
341 .release = seq_release, 341 .release = seq_release_private,
342}; 342};
343#endif 343#endif
344 344
diff --git a/net/ipv6/proc.c b/net/ipv6/proc.c
index 07f0b76e7427..97c17fdd6f75 100644
--- a/net/ipv6/proc.c
+++ b/net/ipv6/proc.c
@@ -132,7 +132,7 @@ static struct snmp_mib snmp6_udplite6_list[] = {
132 132
133static void snmp6_seq_show_icmpv6msg(struct seq_file *seq, void **mib) 133static void snmp6_seq_show_icmpv6msg(struct seq_file *seq, void **mib)
134{ 134{
135 static char name[32]; 135 char name[32];
136 int i; 136 int i;
137 137
138 /* print by name -- deprecated items */ 138 /* print by name -- deprecated items */
@@ -144,7 +144,7 @@ static void snmp6_seq_show_icmpv6msg(struct seq_file *seq, void **mib)
144 p = icmp6type2name[icmptype]; 144 p = icmp6type2name[icmptype];
145 if (!p) /* don't print un-named types here */ 145 if (!p) /* don't print un-named types here */
146 continue; 146 continue;
147 (void) snprintf(name, sizeof(name)-1, "Icmp6%s%s", 147 snprintf(name, sizeof(name), "Icmp6%s%s",
148 i & 0x100 ? "Out" : "In", p); 148 i & 0x100 ? "Out" : "In", p);
149 seq_printf(seq, "%-32s\t%lu\n", name, 149 seq_printf(seq, "%-32s\t%lu\n", name,
150 snmp_fold_field(mib, i)); 150 snmp_fold_field(mib, i));
@@ -157,7 +157,7 @@ static void snmp6_seq_show_icmpv6msg(struct seq_file *seq, void **mib)
157 val = snmp_fold_field(mib, i); 157 val = snmp_fold_field(mib, i);
158 if (!val) 158 if (!val)
159 continue; 159 continue;
160 (void) snprintf(name, sizeof(name)-1, "Icmp6%sType%u", 160 snprintf(name, sizeof(name), "Icmp6%sType%u",
161 i & 0x100 ? "Out" : "In", i & 0xff); 161 i & 0x100 ? "Out" : "In", i & 0xff);
162 seq_printf(seq, "%-32s\t%lu\n", name, val); 162 seq_printf(seq, "%-32s\t%lu\n", name, val);
163 } 163 }
diff --git a/net/mac80211/mlme.c b/net/mac80211/mlme.c
index 14d165f0df75..409bb7716236 100644
--- a/net/mac80211/mlme.c
+++ b/net/mac80211/mlme.c
@@ -2560,25 +2560,3 @@ void ieee80211_mlme_notify_scan_completed(struct ieee80211_local *local)
2560 ieee80211_restart_sta_timer(sdata); 2560 ieee80211_restart_sta_timer(sdata);
2561 rcu_read_unlock(); 2561 rcu_read_unlock();
2562} 2562}
2563
2564/* driver notification call */
2565void ieee80211_notify_mac(struct ieee80211_hw *hw,
2566 enum ieee80211_notification_types notif_type)
2567{
2568 struct ieee80211_local *local = hw_to_local(hw);
2569 struct ieee80211_sub_if_data *sdata;
2570
2571 switch (notif_type) {
2572 case IEEE80211_NOTIFY_RE_ASSOC:
2573 rtnl_lock();
2574 list_for_each_entry(sdata, &local->interfaces, list) {
2575 if (sdata->vif.type != NL80211_IFTYPE_STATION)
2576 continue;
2577
2578 ieee80211_sta_req_auth(sdata, &sdata->u.sta);
2579 }
2580 rtnl_unlock();
2581 break;
2582 }
2583}
2584EXPORT_SYMBOL(ieee80211_notify_mac);
diff --git a/net/phonet/af_phonet.c b/net/phonet/af_phonet.c
index 7ab30f668b5a..9d211f12582b 100644
--- a/net/phonet/af_phonet.c
+++ b/net/phonet/af_phonet.c
@@ -33,9 +33,30 @@
33#include <net/phonet/phonet.h> 33#include <net/phonet/phonet.h>
34#include <net/phonet/pn_dev.h> 34#include <net/phonet/pn_dev.h>
35 35
36static struct net_proto_family phonet_proto_family; 36/* Transport protocol registration */
37static struct phonet_protocol *phonet_proto_get(int protocol); 37static struct phonet_protocol *proto_tab[PHONET_NPROTO] __read_mostly;
38static inline void phonet_proto_put(struct phonet_protocol *pp); 38static DEFINE_SPINLOCK(proto_tab_lock);
39
40static struct phonet_protocol *phonet_proto_get(int protocol)
41{
42 struct phonet_protocol *pp;
43
44 if (protocol >= PHONET_NPROTO)
45 return NULL;
46
47 spin_lock(&proto_tab_lock);
48 pp = proto_tab[protocol];
49 if (pp && !try_module_get(pp->prot->owner))
50 pp = NULL;
51 spin_unlock(&proto_tab_lock);
52
53 return pp;
54}
55
56static inline void phonet_proto_put(struct phonet_protocol *pp)
57{
58 module_put(pp->prot->owner);
59}
39 60
40/* protocol family functions */ 61/* protocol family functions */
41 62
@@ -375,10 +396,6 @@ static struct packet_type phonet_packet_type = {
375 .func = phonet_rcv, 396 .func = phonet_rcv,
376}; 397};
377 398
378/* Transport protocol registration */
379static struct phonet_protocol *proto_tab[PHONET_NPROTO] __read_mostly;
380static DEFINE_SPINLOCK(proto_tab_lock);
381
382int __init_or_module phonet_proto_register(int protocol, 399int __init_or_module phonet_proto_register(int protocol,
383 struct phonet_protocol *pp) 400 struct phonet_protocol *pp)
384{ 401{
@@ -412,27 +429,6 @@ void phonet_proto_unregister(int protocol, struct phonet_protocol *pp)
412} 429}
413EXPORT_SYMBOL(phonet_proto_unregister); 430EXPORT_SYMBOL(phonet_proto_unregister);
414 431
415static struct phonet_protocol *phonet_proto_get(int protocol)
416{
417 struct phonet_protocol *pp;
418
419 if (protocol >= PHONET_NPROTO)
420 return NULL;
421
422 spin_lock(&proto_tab_lock);
423 pp = proto_tab[protocol];
424 if (pp && !try_module_get(pp->prot->owner))
425 pp = NULL;
426 spin_unlock(&proto_tab_lock);
427
428 return pp;
429}
430
431static inline void phonet_proto_put(struct phonet_protocol *pp)
432{
433 module_put(pp->prot->owner);
434}
435
436/* Module registration */ 432/* Module registration */
437static int __init phonet_init(void) 433static int __init phonet_init(void)
438{ 434{
diff --git a/net/sched/sch_api.c b/net/sched/sch_api.c
index b16ad2972c6b..6ab4a2f92ca0 100644
--- a/net/sched/sch_api.c
+++ b/net/sched/sch_api.c
@@ -417,6 +417,8 @@ static int qdisc_dump_stab(struct sk_buff *skb, struct qdisc_size_table *stab)
417 struct nlattr *nest; 417 struct nlattr *nest;
418 418
419 nest = nla_nest_start(skb, TCA_STAB); 419 nest = nla_nest_start(skb, TCA_STAB);
420 if (nest == NULL)
421 goto nla_put_failure;
420 NLA_PUT(skb, TCA_STAB_BASE, sizeof(stab->szopts), &stab->szopts); 422 NLA_PUT(skb, TCA_STAB_BASE, sizeof(stab->szopts), &stab->szopts);
421 nla_nest_end(skb, nest); 423 nla_nest_end(skb, nest);
422 424
diff --git a/net/sched/sch_generic.c b/net/sched/sch_generic.c
index 93cd30ce6501..cdcd16fcfeda 100644
--- a/net/sched/sch_generic.c
+++ b/net/sched/sch_generic.c
@@ -270,6 +270,8 @@ static void dev_watchdog_down(struct net_device *dev)
270void netif_carrier_on(struct net_device *dev) 270void netif_carrier_on(struct net_device *dev)
271{ 271{
272 if (test_and_clear_bit(__LINK_STATE_NOCARRIER, &dev->state)) { 272 if (test_and_clear_bit(__LINK_STATE_NOCARRIER, &dev->state)) {
273 if (dev->reg_state == NETREG_UNINITIALIZED)
274 return;
273 linkwatch_fire_event(dev); 275 linkwatch_fire_event(dev);
274 if (netif_running(dev)) 276 if (netif_running(dev))
275 __netdev_watchdog_up(dev); 277 __netdev_watchdog_up(dev);
@@ -285,8 +287,11 @@ EXPORT_SYMBOL(netif_carrier_on);
285 */ 287 */
286void netif_carrier_off(struct net_device *dev) 288void netif_carrier_off(struct net_device *dev)
287{ 289{
288 if (!test_and_set_bit(__LINK_STATE_NOCARRIER, &dev->state)) 290 if (!test_and_set_bit(__LINK_STATE_NOCARRIER, &dev->state)) {
291 if (dev->reg_state == NETREG_UNINITIALIZED)
292 return;
289 linkwatch_fire_event(dev); 293 linkwatch_fire_event(dev);
294 }
290} 295}
291EXPORT_SYMBOL(netif_carrier_off); 296EXPORT_SYMBOL(netif_carrier_off);
292 297
diff --git a/net/socket.c b/net/socket.c
index 57550c3bcabe..92764d836891 100644
--- a/net/socket.c
+++ b/net/socket.c
@@ -1426,8 +1426,8 @@ asmlinkage long sys_listen(int fd, int backlog)
1426 * clean when we restucture accept also. 1426 * clean when we restucture accept also.
1427 */ 1427 */
1428 1428
1429long do_accept(int fd, struct sockaddr __user *upeer_sockaddr, 1429asmlinkage long sys_accept4(int fd, struct sockaddr __user *upeer_sockaddr,
1430 int __user *upeer_addrlen, int flags) 1430 int __user *upeer_addrlen, int flags)
1431{ 1431{
1432 struct socket *sock, *newsock; 1432 struct socket *sock, *newsock;
1433 struct file *newfile; 1433 struct file *newfile;
@@ -1510,66 +1510,10 @@ out_fd:
1510 goto out_put; 1510 goto out_put;
1511} 1511}
1512 1512
1513#if 0
1514#ifdef HAVE_SET_RESTORE_SIGMASK
1515asmlinkage long sys_paccept(int fd, struct sockaddr __user *upeer_sockaddr,
1516 int __user *upeer_addrlen,
1517 const sigset_t __user *sigmask,
1518 size_t sigsetsize, int flags)
1519{
1520 sigset_t ksigmask, sigsaved;
1521 int ret;
1522
1523 if (sigmask) {
1524 /* XXX: Don't preclude handling different sized sigset_t's. */
1525 if (sigsetsize != sizeof(sigset_t))
1526 return -EINVAL;
1527 if (copy_from_user(&ksigmask, sigmask, sizeof(ksigmask)))
1528 return -EFAULT;
1529
1530 sigdelsetmask(&ksigmask, sigmask(SIGKILL)|sigmask(SIGSTOP));
1531 sigprocmask(SIG_SETMASK, &ksigmask, &sigsaved);
1532 }
1533
1534 ret = do_accept(fd, upeer_sockaddr, upeer_addrlen, flags);
1535
1536 if (ret < 0 && signal_pending(current)) {
1537 /*
1538 * Don't restore the signal mask yet. Let do_signal() deliver
1539 * the signal on the way back to userspace, before the signal
1540 * mask is restored.
1541 */
1542 if (sigmask) {
1543 memcpy(&current->saved_sigmask, &sigsaved,
1544 sizeof(sigsaved));
1545 set_restore_sigmask();
1546 }
1547 } else if (sigmask)
1548 sigprocmask(SIG_SETMASK, &sigsaved, NULL);
1549
1550 return ret;
1551}
1552#else
1553asmlinkage long sys_paccept(int fd, struct sockaddr __user *upeer_sockaddr,
1554 int __user *upeer_addrlen,
1555 const sigset_t __user *sigmask,
1556 size_t sigsetsize, int flags)
1557{
1558 /* The platform does not support restoring the signal mask in the
1559 * return path. So we do not allow using paccept() with a signal
1560 * mask. */
1561 if (sigmask)
1562 return -EINVAL;
1563
1564 return do_accept(fd, upeer_sockaddr, upeer_addrlen, flags);
1565}
1566#endif
1567#endif
1568
1569asmlinkage long sys_accept(int fd, struct sockaddr __user *upeer_sockaddr, 1513asmlinkage long sys_accept(int fd, struct sockaddr __user *upeer_sockaddr,
1570 int __user *upeer_addrlen) 1514 int __user *upeer_addrlen)
1571{ 1515{
1572 return do_accept(fd, upeer_sockaddr, upeer_addrlen, 0); 1516 return sys_accept4(fd, upeer_sockaddr, upeer_addrlen, 0);
1573} 1517}
1574 1518
1575/* 1519/*
@@ -2096,7 +2040,7 @@ static const unsigned char nargs[19]={
2096 AL(0),AL(3),AL(3),AL(3),AL(2),AL(3), 2040 AL(0),AL(3),AL(3),AL(3),AL(2),AL(3),
2097 AL(3),AL(3),AL(4),AL(4),AL(4),AL(6), 2041 AL(3),AL(3),AL(4),AL(4),AL(4),AL(6),
2098 AL(6),AL(2),AL(5),AL(5),AL(3),AL(3), 2042 AL(6),AL(2),AL(5),AL(5),AL(3),AL(3),
2099 AL(6) 2043 AL(4)
2100}; 2044};
2101 2045
2102#undef AL 2046#undef AL
@@ -2115,7 +2059,7 @@ asmlinkage long sys_socketcall(int call, unsigned long __user *args)
2115 unsigned long a0, a1; 2059 unsigned long a0, a1;
2116 int err; 2060 int err;
2117 2061
2118 if (call < 1 || call > SYS_PACCEPT) 2062 if (call < 1 || call > SYS_ACCEPT4)
2119 return -EINVAL; 2063 return -EINVAL;
2120 2064
2121 /* copy_from_user should be SMP safe. */ 2065 /* copy_from_user should be SMP safe. */
@@ -2143,9 +2087,8 @@ asmlinkage long sys_socketcall(int call, unsigned long __user *args)
2143 err = sys_listen(a0, a1); 2087 err = sys_listen(a0, a1);
2144 break; 2088 break;
2145 case SYS_ACCEPT: 2089 case SYS_ACCEPT:
2146 err = 2090 err = sys_accept4(a0, (struct sockaddr __user *)a1,
2147 do_accept(a0, (struct sockaddr __user *)a1, 2091 (int __user *)a[2], 0);
2148 (int __user *)a[2], 0);
2149 break; 2092 break;
2150 case SYS_GETSOCKNAME: 2093 case SYS_GETSOCKNAME:
2151 err = 2094 err =
@@ -2192,12 +2135,9 @@ asmlinkage long sys_socketcall(int call, unsigned long __user *args)
2192 case SYS_RECVMSG: 2135 case SYS_RECVMSG:
2193 err = sys_recvmsg(a0, (struct msghdr __user *)a1, a[2]); 2136 err = sys_recvmsg(a0, (struct msghdr __user *)a1, a[2]);
2194 break; 2137 break;
2195 case SYS_PACCEPT: 2138 case SYS_ACCEPT4:
2196 err = 2139 err = sys_accept4(a0, (struct sockaddr __user *)a1,
2197 sys_paccept(a0, (struct sockaddr __user *)a1, 2140 (int __user *)a[2], a[3]);
2198 (int __user *)a[2],
2199 (const sigset_t __user *) a[3],
2200 a[4], a[5]);
2201 break; 2141 break;
2202 default: 2142 default:
2203 err = -EINVAL; 2143 err = -EINVAL;
diff --git a/net/sunrpc/auth_generic.c b/net/sunrpc/auth_generic.c
index 744b79fdcb19..4028502f0528 100644
--- a/net/sunrpc/auth_generic.c
+++ b/net/sunrpc/auth_generic.c
@@ -133,13 +133,29 @@ static int
133generic_match(struct auth_cred *acred, struct rpc_cred *cred, int flags) 133generic_match(struct auth_cred *acred, struct rpc_cred *cred, int flags)
134{ 134{
135 struct generic_cred *gcred = container_of(cred, struct generic_cred, gc_base); 135 struct generic_cred *gcred = container_of(cred, struct generic_cred, gc_base);
136 int i;
136 137
137 if (gcred->acred.uid != acred->uid || 138 if (gcred->acred.uid != acred->uid ||
138 gcred->acred.gid != acred->gid || 139 gcred->acred.gid != acred->gid ||
139 gcred->acred.group_info != acred->group_info ||
140 gcred->acred.machine_cred != acred->machine_cred) 140 gcred->acred.machine_cred != acred->machine_cred)
141 return 0; 141 goto out_nomatch;
142
143 /* Optimisation in the case where pointers are identical... */
144 if (gcred->acred.group_info == acred->group_info)
145 goto out_match;
146
147 /* Slow path... */
148 if (gcred->acred.group_info->ngroups != acred->group_info->ngroups)
149 goto out_nomatch;
150 for (i = 0; i < gcred->acred.group_info->ngroups; i++) {
151 if (GROUP_AT(gcred->acred.group_info, i) !=
152 GROUP_AT(acred->group_info, i))
153 goto out_nomatch;
154 }
155out_match:
142 return 1; 156 return 1;
157out_nomatch:
158 return 0;
143} 159}
144 160
145void __init rpc_init_generic_auth(void) 161void __init rpc_init_generic_auth(void)
diff --git a/samples/tracepoints/tp-samples-trace.h b/samples/tracepoints/tp-samples-trace.h
index 0216b55bd640..01724e04c556 100644
--- a/samples/tracepoints/tp-samples-trace.h
+++ b/samples/tracepoints/tp-samples-trace.h
@@ -4,10 +4,10 @@
4#include <linux/proc_fs.h> /* for struct inode and struct file */ 4#include <linux/proc_fs.h> /* for struct inode and struct file */
5#include <linux/tracepoint.h> 5#include <linux/tracepoint.h>
6 6
7DEFINE_TRACE(subsys_event, 7DECLARE_TRACE(subsys_event,
8 TPPROTO(struct inode *inode, struct file *file), 8 TPPROTO(struct inode *inode, struct file *file),
9 TPARGS(inode, file)); 9 TPARGS(inode, file));
10DEFINE_TRACE(subsys_eventb, 10DECLARE_TRACE(subsys_eventb,
11 TPPROTO(void), 11 TPPROTO(void),
12 TPARGS()); 12 TPARGS());
13#endif 13#endif
diff --git a/samples/tracepoints/tracepoint-probe-sample.c b/samples/tracepoints/tracepoint-probe-sample.c
index 55abfdda4bd4..e3a964889dc7 100644
--- a/samples/tracepoints/tracepoint-probe-sample.c
+++ b/samples/tracepoints/tracepoint-probe-sample.c
@@ -46,6 +46,7 @@ void __exit tp_sample_trace_exit(void)
46{ 46{
47 unregister_trace_subsys_eventb(probe_subsys_eventb); 47 unregister_trace_subsys_eventb(probe_subsys_eventb);
48 unregister_trace_subsys_event(probe_subsys_event); 48 unregister_trace_subsys_event(probe_subsys_event);
49 tracepoint_synchronize_unregister();
49} 50}
50 51
51module_exit(tp_sample_trace_exit); 52module_exit(tp_sample_trace_exit);
diff --git a/samples/tracepoints/tracepoint-probe-sample2.c b/samples/tracepoints/tracepoint-probe-sample2.c
index 5e9fcf4afffe..685a5acb4562 100644
--- a/samples/tracepoints/tracepoint-probe-sample2.c
+++ b/samples/tracepoints/tracepoint-probe-sample2.c
@@ -33,6 +33,7 @@ module_init(tp_sample_trace_init);
33void __exit tp_sample_trace_exit(void) 33void __exit tp_sample_trace_exit(void)
34{ 34{
35 unregister_trace_subsys_event(probe_subsys_event); 35 unregister_trace_subsys_event(probe_subsys_event);
36 tracepoint_synchronize_unregister();
36} 37}
37 38
38module_exit(tp_sample_trace_exit); 39module_exit(tp_sample_trace_exit);
diff --git a/samples/tracepoints/tracepoint-sample.c b/samples/tracepoints/tracepoint-sample.c
index 4ae4b7fcc043..00d169792a3e 100644
--- a/samples/tracepoints/tracepoint-sample.c
+++ b/samples/tracepoints/tracepoint-sample.c
@@ -13,6 +13,9 @@
13#include <linux/proc_fs.h> 13#include <linux/proc_fs.h>
14#include "tp-samples-trace.h" 14#include "tp-samples-trace.h"
15 15
16DEFINE_TRACE(subsys_event);
17DEFINE_TRACE(subsys_eventb);
18
16struct proc_dir_entry *pentry_example; 19struct proc_dir_entry *pentry_example;
17 20
18static int my_open(struct inode *inode, struct file *file) 21static int my_open(struct inode *inode, struct file *file)
diff --git a/scripts/Makefile.build b/scripts/Makefile.build
index 468fbc9016c7..7a176773af85 100644
--- a/scripts/Makefile.build
+++ b/scripts/Makefile.build
@@ -198,16 +198,10 @@ cmd_modversions = \
198 fi; 198 fi;
199endif 199endif
200 200
201ifdef CONFIG_64BIT
202arch_bits = 64
203else
204arch_bits = 32
205endif
206
207ifdef CONFIG_FTRACE_MCOUNT_RECORD 201ifdef CONFIG_FTRACE_MCOUNT_RECORD
208cmd_record_mcount = perl $(srctree)/scripts/recordmcount.pl \ 202cmd_record_mcount = perl $(srctree)/scripts/recordmcount.pl "$(ARCH)" \
209 "$(ARCH)" "$(arch_bits)" "$(OBJDUMP)" "$(OBJCOPY)" "$(CC)" "$(LD)" \ 203 "$(if $(CONFIG_64BIT),64,32)" \
210 "$(NM)" "$(RM)" "$(MV)" "$(@)"; 204 "$(OBJDUMP)" "$(OBJCOPY)" "$(CC)" "$(LD)" "$(NM)" "$(RM)" "$(MV)" "$(@)";
211endif 205endif
212 206
213define rule_cc_o_c 207define rule_cc_o_c
diff --git a/scripts/bootgraph.pl b/scripts/bootgraph.pl
index d2c61efc216f..f0af9aa9b243 100644
--- a/scripts/bootgraph.pl
+++ b/scripts/bootgraph.pl
@@ -78,11 +78,13 @@ while (<>) {
78} 78}
79 79
80if ($count == 0) { 80if ($count == 0) {
81 print "No data found in the dmesg. Make sure that 'printk.time=1' and\n"; 81 print STDERR <<END;
82 print "'initcall_debug' are passed on the kernel command line.\n\n"; 82No data found in the dmesg. Make sure that 'printk.time=1' and
83 print "Usage: \n"; 83'initcall_debug' are passed on the kernel command line.
84 print " dmesg | perl scripts/bootgraph.pl > output.svg\n\n"; 84Usage:
85 exit; 85 dmesg | perl scripts/bootgraph.pl > output.svg
86END
87 exit 1;
86} 88}
87 89
88print "<?xml version=\"1.0\" standalone=\"no\"?> \n"; 90print "<?xml version=\"1.0\" standalone=\"no\"?> \n";
@@ -109,8 +111,8 @@ my $stylecounter = 0;
109my %rows; 111my %rows;
110my $rowscount = 1; 112my $rowscount = 1;
111my @initcalls = sort { $start{$a} <=> $start{$b} } keys(%start); 113my @initcalls = sort { $start{$a} <=> $start{$b} } keys(%start);
112my $key; 114
113foreach $key (@initcalls) { 115foreach my $key (@initcalls) {
114 my $duration = $end{$key} - $start{$key}; 116 my $duration = $end{$key} - $start{$key};
115 117
116 if ($duration >= $threshold) { 118 if ($duration >= $threshold) {
diff --git a/scripts/recordmcount.pl b/scripts/recordmcount.pl
index 6b9fe3eb8360..eeac71c87c66 100755
--- a/scripts/recordmcount.pl
+++ b/scripts/recordmcount.pl
@@ -134,6 +134,7 @@ my $section_regex; # Find the start of a section
134my $function_regex; # Find the name of a function 134my $function_regex; # Find the name of a function
135 # (return offset and func name) 135 # (return offset and func name)
136my $mcount_regex; # Find the call site to mcount (return offset) 136my $mcount_regex; # Find the call site to mcount (return offset)
137my $alignment; # The .align value to use for $mcount_section
137 138
138if ($arch eq "x86") { 139if ($arch eq "x86") {
139 if ($bits == 64) { 140 if ($bits == 64) {
@@ -148,6 +149,7 @@ if ($arch eq "x86_64") {
148 $function_regex = "^([0-9a-fA-F]+)\\s+<(.*?)>:"; 149 $function_regex = "^([0-9a-fA-F]+)\\s+<(.*?)>:";
149 $mcount_regex = "^\\s*([0-9a-fA-F]+):.*\\smcount([+-]0x[0-9a-zA-Z]+)?\$"; 150 $mcount_regex = "^\\s*([0-9a-fA-F]+):.*\\smcount([+-]0x[0-9a-zA-Z]+)?\$";
150 $type = ".quad"; 151 $type = ".quad";
152 $alignment = 8;
151 153
152 # force flags for this arch 154 # force flags for this arch
153 $ld .= " -m elf_x86_64"; 155 $ld .= " -m elf_x86_64";
@@ -160,6 +162,7 @@ if ($arch eq "x86_64") {
160 $function_regex = "^([0-9a-fA-F]+)\\s+<(.*?)>:"; 162 $function_regex = "^([0-9a-fA-F]+)\\s+<(.*?)>:";
161 $mcount_regex = "^\\s*([0-9a-fA-F]+):.*\\smcount\$"; 163 $mcount_regex = "^\\s*([0-9a-fA-F]+):.*\\smcount\$";
162 $type = ".long"; 164 $type = ".long";
165 $alignment = 4;
163 166
164 # force flags for this arch 167 # force flags for this arch
165 $ld .= " -m elf_i386"; 168 $ld .= " -m elf_i386";
@@ -288,6 +291,7 @@ sub update_funcs
288 open(FILE, ">$mcount_s") || die "can't create $mcount_s\n"; 291 open(FILE, ">$mcount_s") || die "can't create $mcount_s\n";
289 $opened = 1; 292 $opened = 1;
290 print FILE "\t.section $mcount_section,\"a\",\@progbits\n"; 293 print FILE "\t.section $mcount_section,\"a\",\@progbits\n";
294 print FILE "\t.align $alignment\n";
291 } 295 }
292 printf FILE "\t%s %s + %d\n", $type, $ref_func, $offsets[$i] - $offset; 296 printf FILE "\t%s %s + %d\n", $type, $ref_func, $offsets[$i] - $offset;
293 } 297 }
diff --git a/scripts/tracing/draw_functrace.py b/scripts/tracing/draw_functrace.py
new file mode 100644
index 000000000000..902f9a992620
--- /dev/null
+++ b/scripts/tracing/draw_functrace.py
@@ -0,0 +1,130 @@
1#!/usr/bin/python
2
3"""
4Copyright 2008 (c) Frederic Weisbecker <fweisbec@gmail.com>
5Licensed under the terms of the GNU GPL License version 2
6
7This script parses a trace provided by the function tracer in
8kernel/trace/trace_functions.c
9The resulted trace is processed into a tree to produce a more human
10view of the call stack by drawing textual but hierarchical tree of
11calls. Only the functions's names and the the call time are provided.
12
13Usage:
14 Be sure that you have CONFIG_FUNCTION_TRACER
15 # mkdir /debugfs
16 # mount -t debug debug /debug
17 # echo function > /debug/tracing/current_tracer
18 $ cat /debug/tracing/trace_pipe > ~/raw_trace_func
19 Wait some times but not too much, the script is a bit slow.
20 Break the pipe (Ctrl + Z)
21 $ scripts/draw_functrace.py < raw_trace_func > draw_functrace
22 Then you have your drawn trace in draw_functrace
23"""
24
25
26import sys, re
27
28class CallTree:
29 """ This class provides a tree representation of the functions
30 call stack. If a function has no parent in the kernel (interrupt,
31 syscall, kernel thread...) then it is attached to a virtual parent
32 called ROOT.
33 """
34 ROOT = None
35
36 def __init__(self, func, time = None, parent = None):
37 self._func = func
38 self._time = time
39 if parent is None:
40 self._parent = CallTree.ROOT
41 else:
42 self._parent = parent
43 self._children = []
44
45 def calls(self, func, calltime):
46 """ If a function calls another one, call this method to insert it
47 into the tree at the appropriate place.
48 @return: A reference to the newly created child node.
49 """
50 child = CallTree(func, calltime, self)
51 self._children.append(child)
52 return child
53
54 def getParent(self, func):
55 """ Retrieve the last parent of the current node that
56 has the name given by func. If this function is not
57 on a parent, then create it as new child of root
58 @return: A reference to the parent.
59 """
60 tree = self
61 while tree != CallTree.ROOT and tree._func != func:
62 tree = tree._parent
63 if tree == CallTree.ROOT:
64 child = CallTree.ROOT.calls(func, None)
65 return child
66 return tree
67
68 def __repr__(self):
69 return self.__toString("", True)
70
71 def __toString(self, branch, lastChild):
72 if self._time is not None:
73 s = "%s----%s (%s)\n" % (branch, self._func, self._time)
74 else:
75 s = "%s----%s\n" % (branch, self._func)
76
77 i = 0
78 if lastChild:
79 branch = branch[:-1] + " "
80 while i < len(self._children):
81 if i != len(self._children) - 1:
82 s += "%s" % self._children[i].__toString(branch +\
83 " |", False)
84 else:
85 s += "%s" % self._children[i].__toString(branch +\
86 " |", True)
87 i += 1
88 return s
89
90class BrokenLineException(Exception):
91 """If the last line is not complete because of the pipe breakage,
92 we want to stop the processing and ignore this line.
93 """
94 pass
95
96class CommentLineException(Exception):
97 """ If the line is a comment (as in the beginning of the trace file),
98 just ignore it.
99 """
100 pass
101
102
103def parseLine(line):
104 line = line.strip()
105 if line.startswith("#"):
106 raise CommentLineException
107 m = re.match("[^]]+?\\] +([0-9.]+): (\\w+) <-(\\w+)", line)
108 if m is None:
109 raise BrokenLineException
110 return (m.group(1), m.group(2), m.group(3))
111
112
113def main():
114 CallTree.ROOT = CallTree("Root (Nowhere)", None, None)
115 tree = CallTree.ROOT
116
117 for line in sys.stdin:
118 try:
119 calltime, callee, caller = parseLine(line)
120 except BrokenLineException:
121 break
122 except CommentLineException:
123 continue
124 tree = tree.getParent(caller)
125 tree = tree.calls(callee, calltime)
126
127 print CallTree.ROOT
128
129if __name__ == "__main__":
130 main()