Merge branch 'tracing-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git...
authorLinus Torvalds <torvalds@linux-foundation.org>
Sun, 5 Apr 2009 18:04:19 +0000 (11:04 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Sun, 5 Apr 2009 18:04:19 +0000 (11:04 -0700)
* 'tracing-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip: (413 commits)
  tracing, net: fix net tree and tracing tree merge interaction
  tracing, powerpc: fix powerpc tree and tracing tree interaction
  ring-buffer: do not remove reader page from list on ring buffer free
  function-graph: allow unregistering twice
  trace: make argument 'mem' of trace_seq_putmem() const
  tracing: add missing 'extern' keywords to trace_output.h
  tracing: provide trace_seq_reserve()
  blktrace: print out BLK_TN_MESSAGE properly
  blktrace: extract duplidate code
  blktrace: fix memory leak when freeing struct blk_io_trace
  blktrace: fix blk_probes_ref chaos
  blktrace: make classic output more classic
  blktrace: fix off-by-one bug
  blktrace: fix the original blktrace
  blktrace: fix a race when creating blk_tree_root in debugfs
  blktrace: fix timestamp in binary output
  tracing, Text Edit Lock: cleanup
  tracing: filter fix for TRACE_EVENT_FORMAT events
  ftrace: Using FTRACE_WARN_ON() to check "freed record" in ftrace_release()
  x86: kretprobe-booster interrupt emulation code fix
  ...

Fix up trivial conflicts in
 arch/parisc/include/asm/ftrace.h
 include/linux/memory.h
 kernel/extable.c
 kernel/module.c

21 files changed:
1  2 
Documentation/kernel-parameters.txt
MAINTAINERS
arch/ia64/kernel/Makefile
arch/ia64/kernel/entry.S
arch/x86/Kconfig
arch/x86/kernel/process.c
arch/x86/kernel/ptrace.c
include/linux/kernel.h
include/linux/memory.h
include/linux/module.h
include/linux/sched.h
include/linux/syscalls.h
init/Kconfig
kernel/extable.c
kernel/module.c
kernel/relay.c
kernel/sched.c
kernel/softirq.c
kernel/trace/Kconfig
kernel/workqueue.c
mm/slab.c

@@@ -50,6 -50,7 +50,7 @@@ parameter is applicable
        ISAPNP  ISA PnP code is enabled.
        ISDN    Appropriate ISDN support is enabled.
        JOY     Appropriate joystick support is enabled.
+       KMEMTRACE kmemtrace is enabled.
        LIBATA  Libata driver is enabled
        LP      Printer support is enabled.
        LOOP    Loopback device support is enabled.
@@@ -617,9 -618,6 +618,9 @@@ and is between 256 and 4096 characters
  
        debug_objects   [KNL] Enable object debugging
  
 +      no_debug_objects
 +                      [KNL] Disable object debugging
 +
        debugpat        [X86] Enable PAT debugging
  
        decnet.addr=    [HW,NET]
                        use the HighMem zone if it exists, and the Normal
                        zone if it does not.
  
+       kmemtrace.enable=       [KNL,KMEMTRACE] Format: { yes | no }
+                               Controls whether kmemtrace is enabled
+                               at boot-time.
+       kmemtrace.subbufs=n     [KNL,KMEMTRACE] Overrides the number of
+                       subbufs kmemtrace's relay channel has. Set this
+                       higher than default (KMEMTRACE_N_SUBBUFS in code) if
+                       you experience buffer overruns.
        movablecore=nn[KMG]     [KNL,X86-32,IA-64,PPC,X86-64] This parameter
                        is similar to kernelcore except it specifies the
                        amount of memory used for migratable allocations.
  
        noclflush       [BUGS=X86] Don't use the CLFLUSH instruction
  
 -      nohlt           [BUGS=ARM,SH]
 +      nohlt           [BUGS=ARM,SH] Tells the kernel that the sleep(SH) or
 +                      wfi(ARM) instruction doesn't work correctly and not to
 +                      use it. This is also useful when using JTAG debugger.
  
        no-hlt          [BUGS=X86-32] Tells the kernel that the hlt
                        instruction doesn't work correctly and not to
        nosoftlockup    [KNL] Disable the soft-lockup detector.
  
        noswapaccount   [KNL] Disable accounting of swap in memory resource
 -                      controller. (See Documentation/controllers/memory.txt)
 +                      controller. (See Documentation/cgroups/memory.txt)
  
        nosync          [HW,M68K] Disables sync negotiation for all devices.
  
  
        relax_domain_level=
                        [KNL, SMP] Set scheduler's default relax_domain_level.
 -                      See Documentation/cpusets.txt.
 +                      See Documentation/cgroups/cpusets.txt.
  
        reserve=        [KNL,BUGS] Force the kernel to ignore some iomem area
  
  
        tp720=          [HW,PS2]
  
+       trace_buf_size=nn[KMG] [ftrace] will set tracing buffer size.
        trix=           [HW,OSS] MediaTrix AudioTrix Pro
                        Format:
                        <io>,<irq>,<dma>,<dma2>,<sb_io>,<sb_irq>,<sb_dma>,<mpu_io>,<mpu_irq>
diff --combined MAINTAINERS
@@@ -1763,12 -1763,6 +1763,12 @@@ M:    viro@zeniv.linux.org.u
  L:    linux-fsdevel@vger.kernel.org
  S:    Maintained
  
 +FINTEK F75375S HARDWARE MONITOR AND FAN CONTROLLER DRIVER
 +P:    Riku Voipio
 +M:    riku.vipio@iki.fi
 +L:    lm-sensors@lm-sensors.org
 +S:    Maintained
 +
  FIREWIRE SUBSYSTEM (drivers/firewire, <linux/firewire*.h>)
  P:    Kristian Hoegsberg, Stefan Richter
  M:    krh@redhat.com, stefanr@s5r6.in-berlin.de
@@@ -1951,12 -1945,6 +1951,12 @@@ L:    lm-sensors@lm-sensors.or
  W:    http://www.kernel.org/pub/linux/kernel/people/fseidel/hdaps/
  S:    Maintained
  
 +HYPERVISOR VIRTUAL CONSOLE DRIVER
 +L:    linuxppc-dev@ozlabs.org
 +L:    linux-kernel@vger.kernel.org
 +S:    Odd Fixes
 +F:    drivers/char/hvc_*
 +
  GSPCA FINEPIX SUBDRIVER
  P:    Frank Zago
  M:    frank@zago.net
@@@ -2654,6 -2642,12 +2654,12 @@@ M:    jason.wessel@windriver.co
  L:    kgdb-bugreport@lists.sourceforge.net
  S:    Maintained
  
+ KMEMTRACE
+ P:    Eduard - Gabriel Munteanu
+ M:    eduard.munteanu@linux360.ro
+ L:    linux-kernel@vger.kernel.org
+ S:    Maintained
  KPROBES
  P:    Ananth N Mavinakayanahalli
  M:    ananth@in.ibm.com
@@@ -2924,12 -2918,6 +2930,12 @@@ M:    buytenh@marvell.co
  L:    netdev@vger.kernel.org
  S:    Supported
  
 +MARVELL SOC MMC/SD/SDIO CONTROLLER DRIVER
 +P:    Nicolas Pitre
 +M:    nico@cam.org
 +L:    linux-kernel@vger.kernel.org
 +S:    Maintained
 +
  MARVELL YUKON / SYSKONNECT DRIVER
  P:    Mirko Lindner
  M:    mlindner@syskonnect.de
@@@ -3116,7 -3104,7 +3122,7 @@@ M:      shemminger@linux-foundation.or
  L:    netem@lists.linux-foundation.org
  S:    Maintained
  
 -NETERION (S2IO) Xframe 10GbE DRIVER
 +NETERION (S2IO) 10GbE DRIVER (xframe/vxge)
  P:    Ramkrishna Vepa
  M:    ram.vepa@neterion.com
  P:    Rastapur Santosh
@@@ -3125,11 -3113,8 +3131,11 @@@ P:    Sivakumar Subraman
  M:    sivakumar.subramani@neterion.com
  P:    Sreenivasa Honnur
  M:    sreenivasa.honnur@neterion.com
 +P:    Anil Murthy
 +M:    anil.murthy@neterion.com
  L:    netdev@vger.kernel.org
 -W:    http://trac.neterion.com/cgi-bin/trac.cgi/wiki/TitleIndex?anonymous
 +W:    http://trac.neterion.com/cgi-bin/trac.cgi/wiki/Linux?Anonymous
 +W:    http://trac.neterion.com/cgi-bin/trac.cgi/wiki/X3100Linux?Anonymous
  S:    Supported
  
  NETFILTER/IPTABLES/IPCHAINS
@@@ -3420,11 -3405,6 +3426,11 @@@ P:    Jim Cromi
  M:    jim.cromie@gmail.com
  S:    Maintained
  
 +PCA9532 LED DRIVER
 +P:    Riku Voipio
 +M:    riku.voipio@iki.fi
 +S:    Maintained
 +
  PCI ERROR RECOVERY
  P:    Linas Vepstas
  M:    linas@austin.ibm.com
@@@ -3922,14 -3902,7 +3928,14 @@@ S:    Maintaine
  SECURE DIGITAL HOST CONTROLLER INTERFACE (SDHCI) DRIVER
  P:    Pierre Ossman
  M:    drzeus-sdhci@drzeus.cx
 -L:    sdhci-devel@list.drzeus.cx
 +L:    sdhci-devel@lists.ossman.eu
 +S:    Maintained
 +
 +SECURE DIGITAL HOST CONTROLLER INTERFACE, OPEN FIRMWARE BINDINGS (SDHCI-OF)
 +P:    Anton Vorontsov
 +M:    avorontsov@ru.mvista.com
 +L:    linuxppc-dev@ozlabs.org
 +L:    sdhci-devel@lists.ossman.eu
  S:    Maintained
  
  SECURITY SUBSYSTEM
@@@ -4407,11 -4380,6 +4413,11 @@@ L:    tlinux-users@tce.toshiba-dme.co.j
  W:    http://www.buzzard.org.uk/toshiba/
  S:    Maintained
  
 +TMIO MMC DRIVER
 +P:    Ian Molton
 +M:    ian@mnementh.co.uk
 +S:    Maintained
 +
  TPM DEVICE DRIVER
  P:    Debora Velarde
  M:    debora@linux.vnet.ibm.com
@@@ -4876,7 -4844,7 +4882,7 @@@ M:      lrg@slimlogic.co.u
  P:    Mark Brown
  M:    broonie@opensource.wolfsonmicro.com
  W:    http://opensource.wolfsonmicro.com/node/15
 -W:    http://www.slimlogic.co.uk/?page_id=5
 +W:    http://www.slimlogic.co.uk/?p=48
  T:    git kernel.org/pub/scm/linux/kernel/git/lrg/voltage-2.6.git
  S:    Supported
  
@@@ -4998,8 -4966,7 +5004,8 @@@ S:      Supporte
  
  XFS FILESYSTEM
  P:    Silicon Graphics Inc
 -P:    Bill O'Donnell
 +P:    Felix Blyakher
 +M:    felixb@sgi.com
  M:    xfs-masters@oss.sgi.com
  L:    xfs@oss.sgi.com
  W:    http://oss.sgi.com/projects/xfs
@@@ -2,10 -2,14 +2,14 @@@
  # Makefile for the linux kernel.
  #
  
+ ifdef CONFIG_DYNAMIC_FTRACE
+ CFLAGS_REMOVE_ftrace.o = -pg
+ endif
  extra-y       := head.o init_task.o vmlinux.lds
  
  obj-y := acpi.o entry.o efi.o efi_stub.o gate-data.o fsys.o ia64_ksyms.o irq.o irq_ia64.o     \
 -       irq_lsapic.o ivt.o machvec.o pal.o patch.o process.o perfmon.o ptrace.o sal.o          \
 +       irq_lsapic.o ivt.o machvec.o pal.o paravirt_patchlist.o patch.o process.o perfmon.o ptrace.o sal.o             \
         salinfo.o setup.o signal.o sys_ia64.o time.o traps.o unaligned.o \
         unwind.o mca.o mca_asm.o topology.o dma-mapping.o
  
@@@ -28,6 -32,7 +32,7 @@@ obj-$(CONFIG_IA64_CYCLONE)    += cyclone.
  obj-$(CONFIG_CPU_FREQ)                += cpufreq/
  obj-$(CONFIG_IA64_MCA_RECOVERY)       += mca_recovery.o
  obj-$(CONFIG_KPROBES)         += kprobes.o jprobes.o
+ obj-$(CONFIG_DYNAMIC_FTRACE)  += ftrace.o
  obj-$(CONFIG_KEXEC)           += machine_kexec.o relocate_kernel.o crash.o
  obj-$(CONFIG_CRASH_DUMP)      += crash_dump.o
  obj-$(CONFIG_IA64_UNCACHED_ALLOCATOR) += uncached.o
@@@ -36,8 -41,7 +41,8 @@@ obj-$(CONFIG_PCI_MSI)         += msi_ia64.
  mca_recovery-y                        += mca_drv.o mca_drv_asm.o
  obj-$(CONFIG_IA64_MC_ERR_INJECT)+= err_inject.o
  
 -obj-$(CONFIG_PARAVIRT)                += paravirt.o paravirtentry.o
 +obj-$(CONFIG_PARAVIRT)                += paravirt.o paravirtentry.o \
 +                                 paravirt_patch.o
  
  obj-$(CONFIG_IA64_ESI)                += esi.o
  ifneq ($(CONFIG_IA64_ESI),)
@@@ -46,13 -50,35 +51,13 @@@ endi
  obj-$(CONFIG_DMAR)            += pci-dma.o
  obj-$(CONFIG_SWIOTLB)         += pci-swiotlb.o
  
 -# The gate DSO image is built using a special linker script.
 -targets += gate.so gate-syms.o
 -
 -extra-y += gate.so gate-syms.o gate.lds gate.o
 -
  # fp_emulate() expects f2-f5,f16-f31 to contain the user-level state.
  CFLAGS_traps.o  += -mfixed-range=f2-f5,f16-f31
  
 -CPPFLAGS_gate.lds := -P -C -U$(ARCH)
 -
 -quiet_cmd_gate = GATE $@
 -      cmd_gate = $(CC) -nostdlib $(GATECFLAGS_$(@F)) -Wl,-T,$(filter-out FORCE,$^) -o $@
 -
 -GATECFLAGS_gate.so = -shared -s -Wl,-soname=linux-gate.so.1 \
 -                   $(call ld-option, -Wl$(comma)--hash-style=sysv)
 -$(obj)/gate.so: $(obj)/gate.lds $(obj)/gate.o FORCE
 -      $(call if_changed,gate)
 -
 -$(obj)/built-in.o: $(obj)/gate-syms.o
 -$(obj)/built-in.o: ld_flags += -R $(obj)/gate-syms.o
 -
 -GATECFLAGS_gate-syms.o = -r
 -$(obj)/gate-syms.o: $(obj)/gate.lds $(obj)/gate.o FORCE
 -      $(call if_changed,gate)
 -
 -# gate-data.o contains the gate DSO image as data in section .data.gate.
 -# We must build gate.so before we can assemble it.
 -# Note: kbuild does not track this dependency due to usage of .incbin
 -$(obj)/gate-data.o: $(obj)/gate.so
 +# The gate DSO image is built using a special linker script.
 +include $(srctree)/arch/ia64/kernel/Makefile.gate
 +# tell compiled for native
 +CPPFLAGS_gate.lds += -D__IA64_GATE_PARAVIRTUALIZED_NATIVE
  
  # Calculate NR_IRQ = max(IA64_NATIVE_NR_IRQS, XEN_NR_IRQS, ...) based on config
  define sed-y
@@@ -88,9 -114,9 +93,9 @@@ include/asm-ia64/nr-irqs.h: arch/$(SRCA
  clean-files += $(objtree)/include/asm-ia64/nr-irqs.h
  
  #
 -# native ivt.S and entry.S
 +# native ivt.S, entry.S and fsys.S
  #
 -ASM_PARAVIRT_OBJS = ivt.o entry.o
 +ASM_PARAVIRT_OBJS = ivt.o entry.o fsys.o
  define paravirtualized_native
  AFLAGS_$(1) += -D__IA64_ASM_PARAVIRTUALIZED_NATIVE
  AFLAGS_pvchk-sed-$(1) += -D__IA64_ASM_PARAVIRTUALIZED_PVCHECK
diff --combined arch/ia64/kernel/entry.S
@@@ -47,6 -47,7 +47,7 @@@
  #include <asm/processor.h>
  #include <asm/thread_info.h>
  #include <asm/unistd.h>
+ #include <asm/ftrace.h>
  
  #include "minstate.h"
  
@@@ -735,7 -736,7 +736,7 @@@ GLOBAL_ENTRY(__paravirt_leave_syscall
  __paravirt_work_processed_syscall:
  #ifdef CONFIG_VIRT_CPU_ACCOUNTING
        adds r2=PT(LOADRS)+16,r12
 -(pUStk)       mov.m r22=ar.itc                        // fetch time at leave
 +      MOV_FROM_ITC(pUStk, p9, r22, r19)       // fetch time at leave
        adds r18=TI_FLAGS+IA64_TASK_SIZE,r13
        ;;
  (p6)  ld4 r31=[r18]                           // load current_thread_info()->flags
@@@ -984,7 -985,7 +985,7 @@@ GLOBAL_ENTRY(__paravirt_leave_kernel
  #ifdef CONFIG_VIRT_CPU_ACCOUNTING
        .pred.rel.mutex pUStk,pKStk
        MOV_FROM_PSR(pKStk, r22, r29)   // M2 read PSR now that interrupts are disabled
 -(pUStk)       mov.m r22=ar.itc        // M  fetch time at leave
 +      MOV_FROM_ITC(pUStk, p9, r22, r29)       // M  fetch time at leave
        nop.i 0
        ;;
  #else
@@@ -1404,6 -1405,105 +1405,105 @@@ GLOBAL_ENTRY(unw_init_running
        br.ret.sptk.many rp
  END(unw_init_running)
  
+ #ifdef CONFIG_FUNCTION_TRACER
+ #ifdef CONFIG_DYNAMIC_FTRACE
+ GLOBAL_ENTRY(_mcount)
+       br ftrace_stub
+ END(_mcount)
+ .here:
+       br.ret.sptk.many b0
+ GLOBAL_ENTRY(ftrace_caller)
+       alloc out0 = ar.pfs, 8, 0, 4, 0
+       mov out3 = r0
+       ;;
+       mov out2 = b0
+       add r3 = 0x20, r3
+       mov out1 = r1;
+       br.call.sptk.many b0 = ftrace_patch_gp
+       //this might be called from module, so we must patch gp
+ ftrace_patch_gp:
+       movl gp=__gp
+       mov b0 = r3
+       ;;
+ .global ftrace_call;
+ ftrace_call:
+ {
+       .mlx
+       nop.m 0x0
+       movl r3 = .here;;
+ }
+       alloc loc0 = ar.pfs, 4, 4, 2, 0
+       ;;
+       mov loc1 = b0
+       mov out0 = b0
+       mov loc2 = r8
+       mov loc3 = r15
+       ;;
+       adds out0 = -MCOUNT_INSN_SIZE, out0
+       mov out1 = in2
+       mov b6 = r3
+       br.call.sptk.many b0 = b6
+       ;;
+       mov ar.pfs = loc0
+       mov b0 = loc1
+       mov r8 = loc2
+       mov r15 = loc3
+       br ftrace_stub
+       ;;
+ END(ftrace_caller)
+ #else
+ GLOBAL_ENTRY(_mcount)
+       movl r2 = ftrace_stub
+       movl r3 = ftrace_trace_function;;
+       ld8 r3 = [r3];;
+       ld8 r3 = [r3];;
+       cmp.eq p7,p0 = r2, r3
+ (p7)  br.sptk.many ftrace_stub
+       ;;
+       alloc loc0 = ar.pfs, 4, 4, 2, 0
+       ;;
+       mov loc1 = b0
+       mov out0 = b0
+       mov loc2 = r8
+       mov loc3 = r15
+       ;;
+       adds out0 = -MCOUNT_INSN_SIZE, out0
+       mov out1 = in2
+       mov b6 = r3
+       br.call.sptk.many b0 = b6
+       ;;
+       mov ar.pfs = loc0
+       mov b0 = loc1
+       mov r8 = loc2
+       mov r15 = loc3
+       br ftrace_stub
+       ;;
+ END(_mcount)
+ #endif
+ GLOBAL_ENTRY(ftrace_stub)
+       mov r3 = b0
+       movl r2 = _mcount_ret_helper
+       ;;
+       mov b6 = r2
+       mov b7 = r3
+       br.ret.sptk.many b6
+ _mcount_ret_helper:
+       mov b0 = r42
+       mov r1 = r41
+       mov ar.pfs = r40
+       br b7
+ END(ftrace_stub)
+ #endif /* CONFIG_FUNCTION_TRACER */
        .rodata
        .align 8
        .globl sys_call_table
diff --combined arch/x86/Kconfig
@@@ -34,6 -34,8 +34,8 @@@ config X8
        select HAVE_FUNCTION_TRACER
        select HAVE_FUNCTION_GRAPH_TRACER
        select HAVE_FUNCTION_TRACE_MCOUNT_TEST
+       select HAVE_FTRACE_NMI_ENTER if DYNAMIC_FTRACE
+       select HAVE_FTRACE_SYSCALLS
        select HAVE_KVM
        select HAVE_ARCH_KGDB
        select HAVE_ARCH_TRACEHOOK
@@@ -1144,7 -1146,7 +1146,7 @@@ config NODES_SHIF
        depends on NEED_MULTIPLE_NODES
        ---help---
          Specify the maximum number of NUMA Nodes available on the target
 -        system.  Increases memory reserved to accomodate various tables.
 +        system.  Increases memory reserved to accommodate various tables.
  
  config HAVE_ARCH_BOOTMEM
        def_bool y
@@@ -1322,7 -1324,7 +1324,7 @@@ config MTRR_SANITIZE
          add writeback entries.
  
          Can be disabled with disable_mtrr_cleanup on the kernel command line.
 -        The largest mtrr entry size for a continous block can be set with
 +        The largest mtrr entry size for a continuous block can be set with
          mtrr_chunk_size.
  
          If unsure, say Y.
@@@ -1837,8 -1839,8 +1839,8 @@@ config PCI_MMCONFI
  
  config DMAR
        bool "Support for DMA Remapping Devices (EXPERIMENTAL)"
 -      depends on X86_64 && PCI_MSI && ACPI && EXPERIMENTAL
 -      ---help---
 +      depends on PCI_MSI && ACPI && EXPERIMENTAL
 +      help
          DMA remapping (DMAR) devices support enables independent address
          translations for Direct Memory Access (DMA) from devices.
          These DMA remapping devices are reported via ACPI tables
@@@ -8,7 -8,7 +8,7 @@@
  #include <linux/module.h>
  #include <linux/pm.h>
  #include <linux/clockchips.h>
- #include <linux/ftrace.h>
+ #include <trace/power.h>
  #include <asm/system.h>
  #include <asm/apic.h>
  #include <asm/idle.h>
@@@ -22,6 -22,9 +22,9 @@@ EXPORT_SYMBOL(idle_nomwait)
  
  struct kmem_cache *task_xstate_cachep;
  
+ DEFINE_TRACE(power_start);
+ DEFINE_TRACE(power_end);
  int arch_dup_task_struct(struct task_struct *dst, struct task_struct *src)
  {
        *dst = *src;
@@@ -325,7 -328,7 +328,7 @@@ void stop_this_cpu(void *dummy
        /*
         * Remove this CPU:
         */
 -      cpu_clear(smp_processor_id(), cpu_online_map);
 +      set_cpu_online(smp_processor_id(), false);
        disable_local_APIC();
  
        for (;;) {
@@@ -475,13 -478,12 +478,13 @@@ static int __cpuinit check_c1e_idle(con
        return 1;
  }
  
 -static cpumask_t c1e_mask = CPU_MASK_NONE;
 +static cpumask_var_t c1e_mask;
  static int c1e_detected;
  
  void c1e_remove_cpu(int cpu)
  {
 -      cpu_clear(cpu, c1e_mask);
 +      if (c1e_mask != NULL)
 +              cpumask_clear_cpu(cpu, c1e_mask);
  }
  
  /*
@@@ -510,8 -512,8 +513,8 @@@ static void c1e_idle(void
        if (c1e_detected) {
                int cpu = smp_processor_id();
  
 -              if (!cpu_isset(cpu, c1e_mask)) {
 -                      cpu_set(cpu, c1e_mask);
 +              if (!cpumask_test_cpu(cpu, c1e_mask)) {
 +                      cpumask_set_cpu(cpu, c1e_mask);
                        /*
                         * Force broadcast so ACPI can not interfere. Needs
                         * to run with interrupts enabled as it uses
@@@ -563,15 -565,6 +566,15 @@@ void __cpuinit select_idle_routine(cons
                pm_idle = default_idle;
  }
  
 +void __init init_c1e_mask(void)
 +{
 +      /* If we're using c1e_idle, we need to allocate c1e_mask. */
 +      if (pm_idle == c1e_idle) {
 +              alloc_cpumask_var(&c1e_mask, GFP_KERNEL);
 +              cpumask_clear(c1e_mask);
 +      }
 +}
 +
  static int __init idle_setup(char *str)
  {
        if (!str)
diff --combined arch/x86/kernel/ptrace.c
@@@ -21,6 -21,7 +21,7 @@@
  #include <linux/audit.h>
  #include <linux/seccomp.h>
  #include <linux/signal.h>
+ #include <linux/ftrace.h>
  
  #include <asm/uaccess.h>
  #include <asm/pgtable.h>
@@@ -1415,6 -1416,9 +1416,9 @@@ asmregparm long syscall_trace_enter(str
            tracehook_report_syscall_entry(regs))
                ret = -1L;
  
+       if (unlikely(test_thread_flag(TIF_SYSCALL_FTRACE)))
+               ftrace_syscall_enter(regs);
        if (unlikely(current->audit_context)) {
                if (IS_IA32)
                        audit_syscall_entry(AUDIT_ARCH_I386,
@@@ -1438,6 -1442,9 +1442,9 @@@ asmregparm void syscall_trace_leave(str
        if (unlikely(current->audit_context))
                audit_syscall_exit(AUDITSC_RESULT(regs->ax), regs->ax);
  
+       if (unlikely(test_thread_flag(TIF_SYSCALL_FTRACE)))
+               ftrace_syscall_exit(regs);
        if (test_thread_flag(TIF_SYSCALL_TRACE))
                tracehook_report_syscall_exit(regs, 0);
  
         * system call instruction.
         */
        if (test_thread_flag(TIF_SINGLESTEP) &&
 -          tracehook_consider_fatal_signal(current, SIGTRAP, SIG_DFL))
 +          tracehook_consider_fatal_signal(current, SIGTRAP))
                send_sigtrap(current, regs, 0, TRAP_BRKPT);
  }
diff --combined include/linux/kernel.h
@@@ -255,7 -255,6 +255,7 @@@ extern bool printk_timed_ratelimit(unsi
        }                                       \
  })
  
 +void log_buf_kexec_setup(void);
  #else
  static inline int vprintk(const char *s, va_list args)
        __attribute__ ((format (printf, 1, 0)));
@@@ -271,9 -270,6 +271,9 @@@ static inline bool printk_timed_ratelim
  /* No effect, but we still get type checking even in the !PRINTK case: */
  #define printk_once(x...) printk(x)
  
 +static inline void log_buf_kexec_setup(void)
 +{
 +}
  #endif
  
  extern int printk_needs_cpu(int cpu);
@@@ -392,6 -388,139 +392,139 @@@ static inline char *pack_hex_byte(char 
  #endif
  
  /*
+  * General tracing related utility functions - trace_printk(),
+  * tracing_on/tracing_off and tracing_start()/tracing_stop
+  *
+  * Use tracing_on/tracing_off when you want to quickly turn on or off
+  * tracing. It simply enables or disables the recording of the trace events.
+  * This also corresponds to the user space debugfs/tracing/tracing_on
+  * file, which gives a means for the kernel and userspace to interact.
+  * Place a tracing_off() in the kernel where you want tracing to end.
+  * From user space, examine the trace, and then echo 1 > tracing_on
+  * to continue tracing.
+  *
+  * tracing_stop/tracing_start has slightly more overhead. It is used
+  * by things like suspend to ram where disabling the recording of the
+  * trace is not enough, but tracing must actually stop because things
+  * like calling smp_processor_id() may crash the system.
+  *
+  * Most likely, you want to use tracing_on/tracing_off.
+  */
+ #ifdef CONFIG_RING_BUFFER
+ void tracing_on(void);
+ void tracing_off(void);
+ /* trace_off_permanent stops recording with no way to bring it back */
+ void tracing_off_permanent(void);
+ int tracing_is_on(void);
+ #else
+ static inline void tracing_on(void) { }
+ static inline void tracing_off(void) { }
+ static inline void tracing_off_permanent(void) { }
+ static inline int tracing_is_on(void) { return 0; }
+ #endif
+ #ifdef CONFIG_TRACING
+ extern void tracing_start(void);
+ extern void tracing_stop(void);
+ extern void ftrace_off_permanent(void);
+ extern void
+ ftrace_special(unsigned long arg1, unsigned long arg2, unsigned long arg3);
+ static inline void __attribute__ ((format (printf, 1, 2)))
+ ____trace_printk_check_format(const char *fmt, ...)
+ {
+ }
+ #define __trace_printk_check_format(fmt, args...)                     \
+ do {                                                                  \
+       if (0)                                                          \
+               ____trace_printk_check_format(fmt, ##args);             \
+ } while (0)
+ /**
+  * trace_printk - printf formatting in the ftrace buffer
+  * @fmt: the printf format for printing
+  *
+  * Note: __trace_printk is an internal function for trace_printk and
+  *       the @ip is passed in via the trace_printk macro.
+  *
+  * This function allows a kernel developer to debug fast path sections
+  * that printk is not appropriate for. By scattering in various
+  * printk like tracing in the code, a developer can quickly see
+  * where problems are occurring.
+  *
+  * This is intended as a debugging tool for the developer only.
+  * Please refrain from leaving trace_printks scattered around in
+  * your code.
+  */
+ #define trace_printk(fmt, args...)                                    \
+ do {                                                                  \
+       __trace_printk_check_format(fmt, ##args);                       \
+       if (__builtin_constant_p(fmt)) {                                \
+               static const char *trace_printk_fmt                     \
+                 __attribute__((section("__trace_printk_fmt"))) =      \
+                       __builtin_constant_p(fmt) ? fmt : NULL;         \
+                                                                       \
+               __trace_bprintk(_THIS_IP_, trace_printk_fmt, ##args);   \
+       } else                                                          \
+               __trace_printk(_THIS_IP_, fmt, ##args);         \
+ } while (0)
+ extern int
+ __trace_bprintk(unsigned long ip, const char *fmt, ...)
+       __attribute__ ((format (printf, 2, 3)));
+ extern int
+ __trace_printk(unsigned long ip, const char *fmt, ...)
+       __attribute__ ((format (printf, 2, 3)));
+ /*
+  * The double __builtin_constant_p is because gcc will give us an error
+  * if we try to allocate the static variable to fmt if it is not a
+  * constant. Even with the outer if statement.
+  */
+ #define ftrace_vprintk(fmt, vargs)                                    \
+ do {                                                                  \
+       if (__builtin_constant_p(fmt)) {                                \
+               static const char *trace_printk_fmt                     \
+                 __attribute__((section("__trace_printk_fmt"))) =      \
+                       __builtin_constant_p(fmt) ? fmt : NULL;         \
+                                                                       \
+               __ftrace_vbprintk(_THIS_IP_, trace_printk_fmt, vargs);  \
+       } else                                                          \
+               __ftrace_vprintk(_THIS_IP_, fmt, vargs);                \
+ } while (0)
+ extern int
+ __ftrace_vbprintk(unsigned long ip, const char *fmt, va_list ap);
+ extern int
+ __ftrace_vprintk(unsigned long ip, const char *fmt, va_list ap);
+ extern void ftrace_dump(void);
+ #else
+ static inline void
+ ftrace_special(unsigned long arg1, unsigned long arg2, unsigned long arg3) { }
+ static inline int
+ trace_printk(const char *fmt, ...) __attribute__ ((format (printf, 1, 2)));
+ static inline void tracing_start(void) { }
+ static inline void tracing_stop(void) { }
+ static inline void ftrace_off_permanent(void) { }
+ static inline int
+ trace_printk(const char *fmt, ...)
+ {
+       return 0;
+ }
+ static inline int
+ ftrace_vprintk(const char *fmt, va_list ap)
+ {
+       return 0;
+ }
+ static inline void ftrace_dump(void) { }
+ #endif /* CONFIG_TRACING */
+ /*
   *      Display an IP address in readable format.
   */
  
diff --combined include/linux/memory.h
@@@ -100,14 -100,9 +100,20 @@@ enum mem_add_context { BOOT, HOTPLUG }
  #endif
  
  /*
 + * 'struct memory_accessor' is a generic interface to provide
 + * in-kernel access to persistent memory such as i2c or SPI EEPROMs
 + */
 +struct memory_accessor {
 +      ssize_t (*read)(struct memory_accessor *, char *buf, off_t offset,
 +                      size_t count);
 +      ssize_t (*write)(struct memory_accessor *, const char *buf,
 +                       off_t offset, size_t count);
 +};
 +
++/*
+  * Kernel text modification mutex, used for code patching. Users of this lock
+  * can sleep.
+  */
+ extern struct mutex text_mutex;
  #endif /* _LINUX_MEMORY_H_ */
diff --combined include/linux/module.h
@@@ -248,10 -248,6 +248,10 @@@ struct modul
        const unsigned long *crcs;
        unsigned int num_syms;
  
 +      /* Kernel parameters. */
 +      struct kernel_param *kp;
 +      unsigned int num_kp;
 +
        /* GPL-only exported symbols. */
        unsigned int num_gpl_syms;
        const struct kernel_symbol *gpl_syms;
        unsigned int num_tracepoints;
  #endif
  
+ #ifdef CONFIG_TRACING
+       const char **trace_bprintk_fmt_start;
+       unsigned int num_trace_bprintk_fmt;
+ #endif
  #ifdef CONFIG_MODULE_UNLOAD
        /* What modules depend on me? */
        struct list_head modules_which_use_me;
  #define MODULE_ARCH_INIT {}
  #endif
  
 +extern struct mutex module_mutex;
 +
  /* FIXME: It'd be nice to isolate modules during init, too, so they
     aren't used before they (may) fail.  But presently too much code
     (IDE & SCSI) require entry into the module during init.*/
@@@ -364,10 -363,10 +369,10 @@@ static inline int module_is_live(struc
        return mod->state != MODULE_STATE_GOING;
  }
  
 -/* Is this address in a module? (second is with no locks, for oops) */
 -struct module *module_text_address(unsigned long addr);
  struct module *__module_text_address(unsigned long addr);
 -int is_module_address(unsigned long addr);
 +struct module *__module_address(unsigned long addr);
 +bool is_module_address(unsigned long addr);
 +bool is_module_text_address(unsigned long addr);
  
  static inline int within_module_core(unsigned long addr, struct module *mod)
  {
@@@ -381,31 -380,6 +386,31 @@@ static inline int within_module_init(un
               addr < (unsigned long)mod->module_init + mod->init_size;
  }
  
 +/* Search for module by name: must hold module_mutex. */
 +struct module *find_module(const char *name);
 +
 +struct symsearch {
 +      const struct kernel_symbol *start, *stop;
 +      const unsigned long *crcs;
 +      enum {
 +              NOT_GPL_ONLY,
 +              GPL_ONLY,
 +              WILL_BE_GPL_ONLY,
 +      } licence;
 +      bool unused;
 +};
 +
 +/* Search for an exported symbol by name. */
 +const struct kernel_symbol *find_symbol(const char *name,
 +                                      struct module **owner,
 +                                      const unsigned long **crc,
 +                                      bool gplok,
 +                                      bool warn);
 +
 +/* Walk the exported symbol table */
 +bool each_symbol(bool (*fn)(const struct symsearch *arr, struct module *owner,
 +                          unsigned int symnum, void *data), void *data);
 +
  /* Returns 0 and fills in value, defined and namebuf, or -ERANGE if
     symnum out of range. */
  int module_get_kallsym(unsigned int symnum, unsigned long *value, char *type,
  /* Look for this name: can be of form module:name. */
  unsigned long module_kallsyms_lookup_name(const char *name);
  
 +int module_kallsyms_on_each_symbol(int (*fn)(void *, const char *,
 +                                           struct module *, unsigned long),
 +                                 void *data);
 +
  extern void __module_put_and_exit(struct module *mod, long code)
        __attribute__((noreturn));
  #define module_put_and_exit(code) __module_put_and_exit(THIS_MODULE, code);
@@@ -479,7 -449,6 +484,7 @@@ static inline void __module_get(struct 
  #define symbol_put_addr(p) do { } while(0)
  
  #endif /* CONFIG_MODULE_UNLOAD */
 +int use_module(struct module *a, struct module *b);
  
  /* This is a #define so the string doesn't get put in every .o file */
  #define module_name(mod)                      \
@@@ -526,24 -495,21 +531,24 @@@ search_module_extables(unsigned long ad
        return NULL;
  }
  
 -/* Is this address in a module? */
 -static inline struct module *module_text_address(unsigned long addr)
 +static inline struct module *__module_address(unsigned long addr)
  {
        return NULL;
  }
  
 -/* Is this address in a module? (don't take a lock, we're oopsing) */
  static inline struct module *__module_text_address(unsigned long addr)
  {
        return NULL;
  }
  
 -static inline int is_module_address(unsigned long addr)
 +static inline bool is_module_address(unsigned long addr)
  {
 -      return 0;
 +      return false;
 +}
 +
 +static inline bool is_module_text_address(unsigned long addr)
 +{
 +      return false;
  }
  
  /* Get/put a kernel symbol (calls should be symmetric) */
@@@ -598,14 -564,6 +603,14 @@@ static inline unsigned long module_kall
        return 0;
  }
  
 +static inline int module_kallsyms_on_each_symbol(int (*fn)(void *, const char *,
 +                                                         struct module *,
 +                                                         unsigned long),
 +                                               void *data)
 +{
 +      return 0;
 +}
 +
  static inline int register_module_notifier(struct notifier_block * nb)
  {
        /* no events will happen anyway, so this can always succeed */
diff --combined include/linux/sched.h
@@@ -68,7 -68,7 +68,7 @@@ struct sched_param 
  #include <linux/smp.h>
  #include <linux/sem.h>
  #include <linux/signal.h>
 -#include <linux/fs_struct.h>
 +#include <linux/path.h>
  #include <linux/compiler.h>
  #include <linux/completion.h>
  #include <linux/pid.h>
@@@ -97,7 -97,6 +97,7 @@@ struct futex_pi_state
  struct robust_list_head;
  struct bio;
  struct bts_tracer;
 +struct fs_struct;
  
  /*
   * List of flags we want to share for kernel threads,
@@@ -138,6 -137,8 +138,8 @@@ extern unsigned long nr_uninterruptible
  extern unsigned long nr_active(void);
  extern unsigned long nr_iowait(void);
  
+ extern unsigned long get_parent_ip(unsigned long addr);
  struct seq_file;
  struct cfs_rq;
  struct task_group;
@@@ -548,8 -549,25 +550,8 @@@ struct signal_struct 
  
        struct list_head cpu_timers[3];
  
 -      /* job control IDs */
 -
 -      /*
 -       * pgrp and session fields are deprecated.
 -       * use the task_session_Xnr and task_pgrp_Xnr routines below
 -       */
 -
 -      union {
 -              pid_t pgrp __deprecated;
 -              pid_t __pgrp;
 -      };
 -
        struct pid *tty_old_pgrp;
  
 -      union {
 -              pid_t session __deprecated;
 -              pid_t __session;
 -      };
 -
        /* boolean value for session group leader */
        int leader;
  
@@@ -1405,6 -1423,8 +1407,8 @@@ struct task_struct 
        int curr_ret_stack;
        /* Stack of return addresses for return function tracing */
        struct ftrace_ret_stack *ret_stack;
+       /* time stamp for last schedule */
+       unsigned long long ftrace_timestamp;
        /*
         * Number of functions that haven't been traced
         * because of depth overrun.
@@@ -1453,6 -1473,16 +1457,6 @@@ static inline int rt_task(struct task_s
        return rt_prio(p->prio);
  }
  
 -static inline void set_task_session(struct task_struct *tsk, pid_t session)
 -{
 -      tsk->signal->__session = session;
 -}
 -
 -static inline void set_task_pgrp(struct task_struct *tsk, pid_t pgrp)
 -{
 -      tsk->signal->__pgrp = pgrp;
 -}
 -
  static inline struct pid *task_pid(struct task_struct *task)
  {
        return task->pids[PIDTYPE_PID].pid;
@@@ -1463,11 -1493,6 +1467,11 @@@ static inline struct pid *task_tgid(str
        return task->group_leader->pids[PIDTYPE_PID].pid;
  }
  
 +/*
 + * Without tasklist or rcu lock it is not safe to dereference
 + * the result of task_pgrp/task_session even if task == current,
 + * we can race with another thread doing sys_setsid/sys_setpgid.
 + */
  static inline struct pid *task_pgrp(struct task_struct *task)
  {
        return task->group_leader->pids[PIDTYPE_PGID].pid;
@@@ -1493,23 -1518,17 +1497,23 @@@ struct pid_namespace
   *
   * see also pid_nr() etc in include/linux/pid.h
   */
 +pid_t __task_pid_nr_ns(struct task_struct *task, enum pid_type type,
 +                      struct pid_namespace *ns);
  
  static inline pid_t task_pid_nr(struct task_struct *tsk)
  {
        return tsk->pid;
  }
  
 -pid_t task_pid_nr_ns(struct task_struct *tsk, struct pid_namespace *ns);
 +static inline pid_t task_pid_nr_ns(struct task_struct *tsk,
 +                                      struct pid_namespace *ns)
 +{
 +      return __task_pid_nr_ns(tsk, PIDTYPE_PID, ns);
 +}
  
  static inline pid_t task_pid_vnr(struct task_struct *tsk)
  {
 -      return pid_vnr(task_pid(tsk));
 +      return __task_pid_nr_ns(tsk, PIDTYPE_PID, NULL);
  }
  
  
@@@ -1526,34 -1545,31 +1530,34 @@@ static inline pid_t task_tgid_vnr(struc
  }
  
  
 -static inline pid_t task_pgrp_nr(struct task_struct *tsk)
 +static inline pid_t task_pgrp_nr_ns(struct task_struct *tsk,
 +                                      struct pid_namespace *ns)
  {
 -      return tsk->signal->__pgrp;
 +      return __task_pid_nr_ns(tsk, PIDTYPE_PGID, ns);
  }
  
 -pid_t task_pgrp_nr_ns(struct task_struct *tsk, struct pid_namespace *ns);
 -
  static inline pid_t task_pgrp_vnr(struct task_struct *tsk)
  {
 -      return pid_vnr(task_pgrp(tsk));
 +      return __task_pid_nr_ns(tsk, PIDTYPE_PGID, NULL);
  }
  
  
 -static inline pid_t task_session_nr(struct task_struct *tsk)
 +static inline pid_t task_session_nr_ns(struct task_struct *tsk,
 +                                      struct pid_namespace *ns)
  {
 -      return tsk->signal->__session;
 +      return __task_pid_nr_ns(tsk, PIDTYPE_SID, ns);
  }
  
 -pid_t task_session_nr_ns(struct task_struct *tsk, struct pid_namespace *ns);
 -
  static inline pid_t task_session_vnr(struct task_struct *tsk)
  {
 -      return pid_vnr(task_session(tsk));
 +      return __task_pid_nr_ns(tsk, PIDTYPE_SID, NULL);
  }
  
 +/* obsolete, do not use */
 +static inline pid_t task_pgrp_nr(struct task_struct *tsk)
 +{
 +      return task_pgrp_nr_ns(tsk, &init_pid_ns);
 +}
  
  /**
   * pid_alive - check that a task structure is not stale
@@@ -1963,8 -1979,7 +1967,8 @@@ extern void mm_release(struct task_stru
  /* Allocate a new mm structure and copy contents from tsk->mm */
  extern struct mm_struct *dup_mm(struct task_struct *tsk);
  
 -extern int  copy_thread(int, unsigned long, unsigned long, unsigned long, struct task_struct *, struct pt_regs *);
 +extern int copy_thread(unsigned long, unsigned long, unsigned long,
 +                      struct task_struct *, struct pt_regs *);
  extern void flush_thread(void);
  extern void exit_thread(void);
  
@@@ -2049,11 -2064,6 +2053,11 @@@ static inline int thread_group_empty(st
  #define delay_group_leader(p) \
                (thread_group_leader(p) && !thread_group_empty(p))
  
 +static inline int task_detached(struct task_struct *p)
 +{
 +      return p->exit_signal == -1;
 +}
 +
  /*
   * Protects ->fs, ->files, ->mm, ->group_info, ->comm, keyring
   * subscriptions and synchronises with wait4().  Also used in procfs.  Also
diff --combined include/linux/syscalls.h
@@@ -65,6 -65,7 +65,7 @@@ struct old_linux_dirent
  #include <asm/signal.h>
  #include <linux/quota.h>
  #include <linux/key.h>
+ #include <linux/ftrace.h>
  
  #define __SC_DECL1(t1, a1)    t1 a1
  #define __SC_DECL2(t2, a2, ...) t2 a2, __SC_DECL1(__VA_ARGS__)
  #define __SC_TEST5(t5, a5, ...)       __SC_TEST(t5); __SC_TEST4(__VA_ARGS__)
  #define __SC_TEST6(t6, a6, ...)       __SC_TEST(t6); __SC_TEST5(__VA_ARGS__)
  
+ #ifdef CONFIG_FTRACE_SYSCALLS
+ #define __SC_STR_ADECL1(t, a)         #a
+ #define __SC_STR_ADECL2(t, a, ...)    #a, __SC_STR_ADECL1(__VA_ARGS__)
+ #define __SC_STR_ADECL3(t, a, ...)    #a, __SC_STR_ADECL2(__VA_ARGS__)
+ #define __SC_STR_ADECL4(t, a, ...)    #a, __SC_STR_ADECL3(__VA_ARGS__)
+ #define __SC_STR_ADECL5(t, a, ...)    #a, __SC_STR_ADECL4(__VA_ARGS__)
+ #define __SC_STR_ADECL6(t, a, ...)    #a, __SC_STR_ADECL5(__VA_ARGS__)
+ #define __SC_STR_TDECL1(t, a)         #t
+ #define __SC_STR_TDECL2(t, a, ...)    #t, __SC_STR_TDECL1(__VA_ARGS__)
+ #define __SC_STR_TDECL3(t, a, ...)    #t, __SC_STR_TDECL2(__VA_ARGS__)
+ #define __SC_STR_TDECL4(t, a, ...)    #t, __SC_STR_TDECL3(__VA_ARGS__)
+ #define __SC_STR_TDECL5(t, a, ...)    #t, __SC_STR_TDECL4(__VA_ARGS__)
+ #define __SC_STR_TDECL6(t, a, ...)    #t, __SC_STR_TDECL5(__VA_ARGS__)
+ #define SYSCALL_METADATA(sname, nb)                           \
+       static const struct syscall_metadata __used             \
+         __attribute__((__aligned__(4)))                       \
+         __attribute__((section("__syscalls_metadata")))       \
+         __syscall_meta_##sname = {                            \
+               .name           = "sys"#sname,                  \
+               .nb_args        = nb,                           \
+               .types          = types_##sname,                \
+               .args           = args_##sname,                 \
+       }
+ #define SYSCALL_DEFINE0(sname)                                        \
+       static const struct syscall_metadata __used             \
+         __attribute__((__aligned__(4)))                       \
+         __attribute__((section("__syscalls_metadata")))       \
+         __syscall_meta_##sname = {                            \
+               .name           = "sys_"#sname,                 \
+               .nb_args        = 0,                            \
+       };                                                      \
+       asmlinkage long sys_##sname(void)
+ #else
  #define SYSCALL_DEFINE0(name)    asmlinkage long sys_##name(void)
+ #endif
  #define SYSCALL_DEFINE1(name, ...) SYSCALL_DEFINEx(1, _##name, __VA_ARGS__)
  #define SYSCALL_DEFINE2(name, ...) SYSCALL_DEFINEx(2, _##name, __VA_ARGS__)
  #define SYSCALL_DEFINE3(name, ...) SYSCALL_DEFINEx(3, _##name, __VA_ARGS__)
  #endif
  #endif
  
+ #ifdef CONFIG_FTRACE_SYSCALLS
+ #define SYSCALL_DEFINEx(x, sname, ...)                                \
+       static const char *types_##sname[] = {                  \
+               __SC_STR_TDECL##x(__VA_ARGS__)                  \
+       };                                                      \
+       static const char *args_##sname[] = {                   \
+               __SC_STR_ADECL##x(__VA_ARGS__)                  \
+       };                                                      \
+       SYSCALL_METADATA(sname, x);                             \
+       __SYSCALL_DEFINEx(x, sname, __VA_ARGS__)
+ #else
+ #define SYSCALL_DEFINEx(x, sname, ...)                                \
+       __SYSCALL_DEFINEx(x, sname, __VA_ARGS__)
+ #endif
  #ifdef CONFIG_HAVE_SYSCALL_WRAPPERS
  
  #define SYSCALL_DEFINE(name) static inline long SYSC_##name
- #define SYSCALL_DEFINEx(x, name, ...)                                 \
+ #define __SYSCALL_DEFINEx(x, name, ...)                                       \
        asmlinkage long sys##name(__SC_DECL##x(__VA_ARGS__));           \
        static inline long SYSC##name(__SC_DECL##x(__VA_ARGS__));       \
        asmlinkage long SyS##name(__SC_LONG##x(__VA_ARGS__))            \
  #else /* CONFIG_HAVE_SYSCALL_WRAPPERS */
  
  #define SYSCALL_DEFINE(name) asmlinkage long sys_##name
- #define SYSCALL_DEFINEx(x, name, ...)                                 \
+ #define __SYSCALL_DEFINEx(x, name, ...)                                       \
        asmlinkage long sys##name(__SC_DECL##x(__VA_ARGS__))
  
  #endif /* CONFIG_HAVE_SYSCALL_WRAPPERS */
@@@ -461,10 -517,6 +517,10 @@@ asmlinkage long sys_pread64(unsigned in
                            size_t count, loff_t pos);
  asmlinkage long sys_pwrite64(unsigned int fd, const char __user *buf,
                             size_t count, loff_t pos);
 +asmlinkage long sys_preadv(unsigned long fd, const struct iovec __user *vec,
 +                         unsigned long vlen, unsigned long pos_l, unsigned long pos_h);
 +asmlinkage long sys_pwritev(unsigned long fd, const struct iovec __user *vec,
 +                          unsigned long vlen, unsigned long pos_l, unsigned long pos_h);
  asmlinkage long sys_getcwd(char __user *buf, unsigned long size);
  asmlinkage long sys_mkdir(const char __user *pathname, int mode);
  asmlinkage long sys_chdir(const char __user *filename);
diff --combined init/Kconfig
@@@ -531,7 -531,7 +531,7 @@@ config CGROUP_DEVIC
  
  config CPUSETS
        bool "Cpuset support"
 -      depends on SMP && CGROUPS
 +      depends on CGROUPS
        help
          This option will let you create and manage CPUSETs which
          allow dynamically partitioning a system into sets of CPUs and
@@@ -565,7 -565,7 +565,7 @@@ config CGROUP_MEM_RES_CTL
        select MM_OWNER
        help
          Provides a memory resource controller that manages both anonymous
 -        memory and page cache. (See Documentation/controllers/memory.txt)
 +        memory and page cache. (See Documentation/cgroups/memory.txt)
  
          Note that setting this option increases fixed memory overhead
          associated with each page of memory in the system. By this,
@@@ -597,8 -597,6 +597,8 @@@ config CGROUP_MEM_RES_CTLR_SWA
          is disabled by boot option, this will be automatically disabled and
          there will be no overhead from this. Even when you set this config=y,
          if boot option "noswapaccount" is set, swap will not be accounted.
 +        Now, memory usage of swap_cgroup is 2 bytes per entry. If swap page
 +        size is 4096bytes, 512k per 1Gbytes of swap.
  
  endif # CGROUPS
  
@@@ -689,7 -687,7 +689,7 @@@ config PID_N
        depends on NAMESPACES && EXPERIMENTAL
        help
          Support process id namespaces.  This allows having multiple
 -        process with the same pid as long as they are in different
 +        processes with the same pid as long as they are in different
          pid namespaces.  This is a building block of containers.
  
          Unless you want to work with an experimental feature
@@@ -954,7 -952,7 +954,7 @@@ config COMPAT_BR
          Randomizing heap placement makes heap exploits harder, but it
          also breaks ancient binaries (including anything libc5 based).
          This option changes the bootup default to heap randomization
 -        disabled, and can be overriden runtime by setting
 +        disabled, and can be overridden at runtime by setting
          /proc/sys/kernel/randomize_va_space to 2.
  
          On non-ancient distros (post-2000 ones) N is usually a safe choice.
@@@ -1007,25 -1005,13 +1007,25 @@@ config TRACEPOINT
  
  config MARKERS
        bool "Activate markers"
-       depends on TRACEPOINTS
+       select TRACEPOINTS
        help
          Place an empty function call at each marker site. Can be
          dynamically changed for a probe function.
  
  source "arch/Kconfig"
  
 +config SLOW_WORK
 +      default n
 +      bool "Enable slow work thread pool"
 +      help
 +        The slow work thread pool provides a number of dynamically allocated
 +        threads that can be used by the kernel to perform operations that
 +        take a relatively long time.
 +
 +        An example of this would be CacheFiles doing a path lookup followed
 +        by a series of mkdirs and a create call, all of which have to touch
 +        disk.
 +
  endmenu               # General setup
  
  config HAVE_GENERIC_DMA_COHERENT
@@@ -1124,7 -1110,7 +1124,7 @@@ config INIT_ALL_POSSIBL
          cpu_possible_map, some of them chose to initialize cpu_possible_map
          with all 1s, and others with all 0s.  When they were centralised,
          it was better to provide this option than to break all the archs
 -        and have several arch maintainers persuing me down dark alleys.
 +        and have several arch maintainers pursuing me down dark alleys.
  
  config STOP_MACHINE
        bool
diff --combined kernel/extable.c
      along with this program; if not, write to the Free Software
      Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
+ #include <linux/ftrace.h>
+ #include <linux/memory.h>
  #include <linux/module.h>
+ #include <linux/mutex.h>
  #include <linux/init.h>
- #include <linux/ftrace.h>
- #include <asm/uaccess.h>
  #include <asm/sections.h>
+ #include <asm/uaccess.h>
+ /*
+  * mutex protecting text section modification (dynamic code patching).
+  * some users need to sleep (allocating memory...) while they hold this lock.
+  *
+  * NOT exported to modules - patching kernel text is a really delicate matter.
+  */
+ DEFINE_MUTEX(text_mutex);
  
  extern struct exception_table_entry __start___ex_table[];
  extern struct exception_table_entry __stop___ex_table[];
@@@ -41,50 -52,31 +52,50 @@@ const struct exception_table_entry *sea
        return e;
  }
  
- __notrace_funcgraph int core_kernel_text(unsigned long addr)
 +static inline int init_kernel_text(unsigned long addr)
 +{
 +      if (addr >= (unsigned long)_sinittext &&
 +          addr <= (unsigned long)_einittext)
 +              return 1;
 +      return 0;
 +}
 +
+ int core_kernel_text(unsigned long addr)
  {
        if (addr >= (unsigned long)_stext &&
            addr <= (unsigned long)_etext)
                return 1;
  
        if (system_state == SYSTEM_BOOTING &&
 -          addr >= (unsigned long)_sinittext &&
 -          addr <= (unsigned long)_einittext)
 +          init_kernel_text(addr))
                return 1;
        return 0;
  }
  
__notrace_funcgraph int __kernel_text_address(unsigned long addr)
+ int __kernel_text_address(unsigned long addr)
  {
        if (core_kernel_text(addr))
                return 1;
 -      return __module_text_address(addr) != NULL;
 +      if (is_module_text_address(addr))
 +              return 1;
 +      /*
 +       * There might be init symbols in saved stacktraces.
 +       * Give those symbols a chance to be printed in
 +       * backtraces (such as lockdep traces).
 +       *
 +       * Since we are after the module-symbols check, there's
 +       * no danger of address overlap:
 +       */
 +      if (init_kernel_text(addr))
 +              return 1;
 +      return 0;
  }
  
  int kernel_text_address(unsigned long addr)
  {
        if (core_kernel_text(addr))
                return 1;
 -      return module_text_address(addr) != NULL;
 +      return is_module_text_address(addr);
  }
  
  /*
@@@ -100,5 -92,5 +111,5 @@@ int func_ptr_is_kernel_text(void *ptr
        addr = (unsigned long) dereference_function_descriptor(ptr);
        if (core_kernel_text(addr))
                return 1;
 -      return module_text_address(addr) != NULL;
 +      return is_module_text_address(addr);
  }
diff --combined kernel/module.c
@@@ -68,8 -68,7 +68,8 @@@
  
  /* List of modules, protected by module_mutex or preempt_disable
   * (delete uses stop_machine/add uses RCU list operations). */
 -static DEFINE_MUTEX(module_mutex);
 +DEFINE_MUTEX(module_mutex);
 +EXPORT_SYMBOL_GPL(module_mutex);
  static LIST_HEAD(modules);
  
  /* Waiting for a module to finish initializing? */
@@@ -77,7 -76,7 +77,7 @@@ static DECLARE_WAIT_QUEUE_HEAD(module_w
  
  static BLOCKING_NOTIFIER_HEAD(module_notify_list);
  
 -/* Bounds of module allocation, for speeding __module_text_address */
 +/* Bounds of module allocation, for speeding __module_address */
  static unsigned long module_addr_min = -1UL, module_addr_max = 0;
  
  int register_module_notifier(struct notifier_block * nb)
@@@ -187,6 -186,17 +187,6 @@@ extern const unsigned long __start___kc
  #define symversion(base, idx) ((base != NULL) ? ((base) + (idx)) : NULL)
  #endif
  
 -struct symsearch {
 -      const struct kernel_symbol *start, *stop;
 -      const unsigned long *crcs;
 -      enum {
 -              NOT_GPL_ONLY,
 -              GPL_ONLY,
 -              WILL_BE_GPL_ONLY,
 -      } licence;
 -      bool unused;
 -};
 -
  static bool each_symbol_in_section(const struct symsearch *arr,
                                   unsigned int arrsize,
                                   struct module *owner,
  }
  
  /* Returns true as soon as fn returns true, otherwise false. */
 -static bool each_symbol(bool (*fn)(const struct symsearch *arr,
 -                                 struct module *owner,
 -                                 unsigned int symnum, void *data),
 -                      void *data)
 +bool each_symbol(bool (*fn)(const struct symsearch *arr, struct module *owner,
 +                          unsigned int symnum, void *data), void *data)
  {
        struct module *mod;
        const struct symsearch arr[] = {
        }
        return false;
  }
 +EXPORT_SYMBOL_GPL(each_symbol);
  
  struct find_symbol_arg {
        /* Input */
        /* Output */
        struct module *owner;
        const unsigned long *crc;
 -      unsigned long value;
 +      const struct kernel_symbol *sym;
  };
  
  static bool find_symbol_in_section(const struct symsearch *syms,
  
        fsa->owner = owner;
        fsa->crc = symversion(syms->crcs, symnum);
 -      fsa->value = syms->start[symnum].value;
 +      fsa->sym = &syms->start[symnum];
        return true;
  }
  
 -/* Find a symbol, return value, (optional) crc and (optional) module
 - * which owns it */
 -static unsigned long find_symbol(const char *name,
 -                               struct module **owner,
 -                               const unsigned long **crc,
 -                               bool gplok,
 -                               bool warn)
 +/* Find a symbol and return it, along with, (optional) crc and
 + * (optional) module which owns it */
 +const struct kernel_symbol *find_symbol(const char *name,
 +                                      struct module **owner,
 +                                      const unsigned long **crc,
 +                                      bool gplok,
 +                                      bool warn)
  {
        struct find_symbol_arg fsa;
  
                        *owner = fsa.owner;
                if (crc)
                        *crc = fsa.crc;
 -              return fsa.value;
 +              return fsa.sym;
        }
  
        DEBUGP("Failed to find symbol %s\n", name);
 -      return -ENOENT;
 +      return NULL;
  }
 +EXPORT_SYMBOL_GPL(find_symbol);
  
  /* Search for module by name: must hold module_mutex. */
 -static struct module *find_module(const char *name)
 +struct module *find_module(const char *name)
  {
        struct module *mod;
  
        }
        return NULL;
  }
 +EXPORT_SYMBOL_GPL(find_module);
  
  #ifdef CONFIG_SMP
  
@@@ -632,7 -641,7 +632,7 @@@ static int already_uses(struct module *
  }
  
  /* Module a uses b */
 -static int use_module(struct module *a, struct module *b)
 +int use_module(struct module *a, struct module *b)
  {
        struct module_use *use;
        int no_warn, err;
        no_warn = sysfs_create_link(b->holders_dir, &a->mkobj.kobj, a->name);
        return 1;
  }
 +EXPORT_SYMBOL_GPL(use_module);
  
  /* Clear the unload stuff of the module. */
  static void module_unload_free(struct module *mod)
@@@ -886,7 -894,7 +886,7 @@@ void __symbol_put(const char *symbol
        struct module *owner;
  
        preempt_disable();
 -      if (IS_ERR_VALUE(find_symbol(symbol, &owner, NULL, true, false)))
 +      if (!find_symbol(symbol, &owner, NULL, true, false))
                BUG();
        module_put(owner);
        preempt_enable();
@@@ -900,10 -908,8 +900,10 @@@ void symbol_put_addr(void *addr
        if (core_kernel_text((unsigned long)addr))
                return;
  
 -      if (!(modaddr = module_text_address((unsigned long)addr)))
 -              BUG();
 +      /* module_text_address is safe here: we're supposed to have reference
 +       * to module from symbol_get, so it can't go away. */
 +      modaddr = __module_text_address((unsigned long)addr);
 +      BUG_ON(!modaddr);
        module_put(modaddr);
  }
  EXPORT_SYMBOL_GPL(symbol_put_addr);
@@@ -943,11 -949,10 +943,11 @@@ static inline void module_unload_free(s
  {
  }
  
 -static inline int use_module(struct module *a, struct module *b)
 +int use_module(struct module *a, struct module *b)
  {
        return strong_try_module_get(b) == 0;
  }
 +EXPORT_SYMBOL_GPL(use_module);
  
  static inline void module_unload_init(struct module *mod)
  {
@@@ -990,12 -995,12 +990,12 @@@ static struct module_attribute *modinfo
  
  static const char vermagic[] = VERMAGIC_STRING;
  
 -static int try_to_force_load(struct module *mod, const char *symname)
 +static int try_to_force_load(struct module *mod, const char *reason)
  {
  #ifdef CONFIG_MODULE_FORCE_LOAD
        if (!test_taint(TAINT_FORCED_MODULE))
 -              printk("%s: no version for \"%s\" found: kernel tainted.\n",
 -                     mod->name, symname);
 +              printk(KERN_WARNING "%s: %s: kernel tainted.\n",
 +                     mod->name, reason);
        add_taint_module(mod, TAINT_FORCED_MODULE);
        return 0;
  #else
@@@ -1052,9 -1057,9 +1052,9 @@@ static inline int check_modstruct_versi
  {
        const unsigned long *crc;
  
 -      if (IS_ERR_VALUE(find_symbol("struct_module", NULL, &crc, true, false)))
 +      if (!find_symbol("module_layout", NULL, &crc, true, false))
                BUG();
 -      return check_version(sechdrs, versindex, "struct_module", mod, crc);
 +      return check_version(sechdrs, versindex, "module_layout", mod, crc);
  }
  
  /* First part is kernel version, which we ignore if module has crcs. */
@@@ -1093,25 -1098,25 +1093,25 @@@ static inline int same_magic(const cha
  
  /* Resolve a symbol for this module.  I.e. if we find one, record usage.
     Must be holding module_mutex. */
 -static unsigned long resolve_symbol(Elf_Shdr *sechdrs,
 -                                  unsigned int versindex,
 -                                  const char *name,
 -                                  struct module *mod)
 +static const struct kernel_symbol *resolve_symbol(Elf_Shdr *sechdrs,
 +                                                unsigned int versindex,
 +                                                const char *name,
 +                                                struct module *mod)
  {
        struct module *owner;
 -      unsigned long ret;
 +      const struct kernel_symbol *sym;
        const unsigned long *crc;
  
 -      ret = find_symbol(name, &owner, &crc,
 +      sym = find_symbol(name, &owner, &crc,
                          !(mod->taints & (1 << TAINT_PROPRIETARY_MODULE)), true);
 -      if (!IS_ERR_VALUE(ret)) {
 -              /* use_module can fail due to OOM,
 -                 or module initialization or unloading */
 +      /* use_module can fail due to OOM,
 +         or module initialization or unloading */
 +      if (sym) {
                if (!check_version(sechdrs, versindex, name, mod, crc) ||
                    !use_module(mod, owner))
 -                      ret = -EINVAL;
 +                      sym = NULL;
        }
 -      return ret;
 +      return sym;
  }
  
  /*
@@@ -1486,9 -1491,6 +1486,9 @@@ static void free_module(struct module *
        /* Module unload stuff */
        module_unload_free(mod);
  
 +      /* Free any allocated parameters. */
 +      destroy_params(mod->kp, mod->num_kp);
 +
        /* release any pointers to mcount in this module */
        ftrace_release(mod->module_core, mod->core_size);
  
  void *__symbol_get(const char *symbol)
  {
        struct module *owner;
 -      unsigned long value;
 +      const struct kernel_symbol *sym;
  
        preempt_disable();
 -      value = find_symbol(symbol, &owner, NULL, true, true);
 -      if (IS_ERR_VALUE(value))
 -              value = 0;
 -      else if (strong_try_module_get(owner))
 -              value = 0;
 +      sym = find_symbol(symbol, &owner, NULL, true, true);
 +      if (sym && strong_try_module_get(owner))
 +              sym = NULL;
        preempt_enable();
  
 -      return (void *)value;
 +      return sym ? (void *)sym->value : NULL;
  }
  EXPORT_SYMBOL_GPL(__symbol_get);
  
@@@ -1547,7 -1551,8 +1547,7 @@@ static int verify_export_symbols(struc
  
        for (i = 0; i < ARRAY_SIZE(arr); i++) {
                for (s = arr[i].sym; s < arr[i].sym + arr[i].num; s++) {
 -                      if (!IS_ERR_VALUE(find_symbol(s->name, &owner,
 -                                                    NULL, true, false))) {
 +                      if (find_symbol(s->name, &owner, NULL, true, false)) {
                                printk(KERN_ERR
                                       "%s: exports duplicate symbol %s"
                                       " (owned by %s)\n",
@@@ -1571,7 -1576,6 +1571,7 @@@ static int simplify_symbols(Elf_Shdr *s
        unsigned long secbase;
        unsigned int i, n = sechdrs[symindex].sh_size / sizeof(Elf_Sym);
        int ret = 0;
 +      const struct kernel_symbol *ksym;
  
        for (i = 1; i < n; i++) {
                switch (sym[i].st_shndx) {
                        break;
  
                case SHN_UNDEF:
 -                      sym[i].st_value
 -                        = resolve_symbol(sechdrs, versindex,
 -                                         strtab + sym[i].st_name, mod);
 -
 +                      ksym = resolve_symbol(sechdrs, versindex,
 +                                            strtab + sym[i].st_name, mod);
                        /* Ok if resolved.  */
 -                      if (!IS_ERR_VALUE(sym[i].st_value))
 +                      if (ksym) {
 +                              sym[i].st_value = ksym->value;
                                break;
 +                      }
 +
                        /* Ok if weak.  */
                        if (ELF_ST_BIND(sym[i].st_info) == STB_WEAK)
                                break;
@@@ -1673,7 -1676,8 +1673,7 @@@ static void layout_sections(struct modu
                        if ((s->sh_flags & masks[m][0]) != masks[m][0]
                            || (s->sh_flags & masks[m][1])
                            || s->sh_entsize != ~0UL
 -                          || strncmp(secstrings + s->sh_name,
 -                                     ".init", 5) == 0)
 +                          || strstarts(secstrings + s->sh_name, ".init"))
                                continue;
                        s->sh_entsize = get_offset(mod, &mod->core_size, s, i);
                        DEBUGP("\t%s\n", secstrings + s->sh_name);
                        if ((s->sh_flags & masks[m][0]) != masks[m][0]
                            || (s->sh_flags & masks[m][1])
                            || s->sh_entsize != ~0UL
 -                          || strncmp(secstrings + s->sh_name,
 -                                     ".init", 5) != 0)
 +                          || !strstarts(secstrings + s->sh_name, ".init"))
                                continue;
                        s->sh_entsize = (get_offset(mod, &mod->init_size, s, i)
                                         | INIT_OFFSET_MASK);
@@@ -1823,7 -1828,8 +1823,7 @@@ static char elf_type(const Elf_Sym *sym
                else
                        return 'b';
        }
 -      if (strncmp(secstrings + sechdrs[sym->st_shndx].sh_name,
 -                  ".debug", strlen(".debug")) == 0)
 +      if (strstarts(secstrings + sechdrs[sym->st_shndx].sh_name, ".debug"))
                return 'n';
        return '?';
  }
@@@ -1892,7 -1898,8 +1892,7 @@@ static noinline struct module *load_mod
        unsigned int symindex = 0;
        unsigned int strindex = 0;
        unsigned int modindex, versindex, infoindex, pcpuindex;
 -      unsigned int num_kp, num_mcount;
 -      struct kernel_param *kp;
 +      unsigned int num_mcount;
        struct module *mod;
        long err = 0;
        void *percpu = NULL, *ptr = NULL; /* Stops spurious gcc warning */
        if (len > 64 * 1024 * 1024 || (hdr = vmalloc(len)) == NULL)
                return ERR_PTR(-ENOMEM);
  
 -      /* Create stop_machine threads since the error path relies on
 -       * a non-failing stop_machine call. */
 -      err = stop_machine_create();
 -      if (err)
 -              goto free_hdr;
 -
        if (copy_from_user(hdr, umod, len) != 0) {
                err = -EFAULT;
                goto free_hdr;
                }
  #ifndef CONFIG_MODULE_UNLOAD
                /* Don't load .exit sections */
 -              if (strncmp(secstrings+sechdrs[i].sh_name, ".exit", 5) == 0)
 +              if (strstarts(secstrings+sechdrs[i].sh_name, ".exit"))
                        sechdrs[i].sh_flags &= ~(unsigned long)SHF_ALLOC;
  #endif
 +              /* Don't keep __versions around; it's just for loading. */
 +              if (strcmp(secstrings + sechdrs[i].sh_name, "__versions") == 0)
 +                      sechdrs[i].sh_flags &= ~(unsigned long)SHF_ALLOC;
        }
  
        modindex = find_sec(hdr, sechdrs, secstrings,
        modmagic = get_modinfo(sechdrs, infoindex, "vermagic");
        /* This is allowed: modprobe --force will invalidate it. */
        if (!modmagic) {
 -              err = try_to_force_load(mod, "magic");
 +              err = try_to_force_load(mod, "bad vermagic");
                if (err)
                        goto free_hdr;
        } else if (!same_magic(modmagic, vermagic, versindex)) {
  
        /* Now we've got everything in the final locations, we can
         * find optional sections. */
 -      kp = section_objs(hdr, sechdrs, secstrings, "__param", sizeof(*kp),
 -                        &num_kp);
 +      mod->kp = section_objs(hdr, sechdrs, secstrings, "__param",
 +                             sizeof(*mod->kp), &mod->num_kp);
        mod->syms = section_objs(hdr, sechdrs, secstrings, "__ksymtab",
                                 sizeof(*mod->syms), &mod->num_syms);
        mod->crcs = section_addr(hdr, sechdrs, secstrings, "__kcrctab");
            || (mod->num_unused_gpl_syms && !mod->unused_gpl_crcs)
  #endif
                ) {
 -              printk(KERN_WARNING "%s: No versions for exported symbols.\n", mod->name);
 -              err = try_to_force_load(mod, "nocrc");
 +              err = try_to_force_load(mod,
 +                                      "no versions for exported symbols");
                if (err)
                        goto cleanup;
        }
         */
        list_add_rcu(&mod->list, &modules);
  
 -      err = parse_args(mod->name, mod->args, kp, num_kp, NULL);
 +      err = parse_args(mod->name, mod->args, mod->kp, mod->num_kp, NULL);
        if (err < 0)
                goto unlink;
  
 -      err = mod_sysfs_setup(mod, kp, num_kp);
 +      err = mod_sysfs_setup(mod, mod->kp, mod->num_kp);
        if (err < 0)
                goto unlink;
        add_sect_attrs(mod, hdr->e_shnum, secstrings, sechdrs);
        /* Get rid of temporary copy */
        vfree(hdr);
  
 -      stop_machine_destroy();
        /* Done! */
        return mod;
  
   unlink:
 -      stop_machine(__unlink_module, mod, NULL);
 +      /* Unlink carefully: kallsyms could be walking list. */
 +      list_del_rcu(&mod->list);
 +      synchronize_sched();
        module_arch_cleanup(mod);
   cleanup:
        kobject_del(&mod->mkobj.kobj);
        ftrace_release(mod->module_core, mod->core_size);
   free_unload:
        module_unload_free(mod);
 - free_init:
  #if defined(CONFIG_MODULE_UNLOAD) && defined(CONFIG_SMP)
 + free_init:
        percpu_modfree(mod->refptr);
  #endif
        module_free(mod, mod->module_init);
        kfree(args);
   free_hdr:
        vfree(hdr);
 -      stop_machine_destroy();
        return ERR_PTR(err);
  
   truncated:
@@@ -2599,25 -2609,6 +2599,25 @@@ unsigned long module_kallsyms_lookup_na
        preempt_enable();
        return ret;
  }
 +
 +int module_kallsyms_on_each_symbol(int (*fn)(void *, const char *,
 +                                           struct module *, unsigned long),
 +                                 void *data)
 +{
 +      struct module *mod;
 +      unsigned int i;
 +      int ret;
 +
 +      list_for_each_entry(mod, &modules, list) {
 +              for (i = 0; i < mod->num_symtab; i++) {
 +                      ret = fn(data, mod->strtab + mod->symtab[i].st_name,
 +                               mod, mod->symtab[i].st_value);
 +                      if (ret != 0)
 +                              return ret;
 +              }
 +      }
 +      return 0;
 +}
  #endif /* CONFIG_KALLSYMS */
  
  static char *module_flags(struct module *mod, char *buf)
@@@ -2753,31 -2744,29 +2753,31 @@@ const struct exception_table_entry *sea
  }
  
  /*
 - * Is this a valid module address?
 + * is_module_address - is this address inside a module?
 + * @addr: the address to check.
 + *
 + * See is_module_text_address() if you simply want to see if the address
 + * is code (not data).
   */
 -int is_module_address(unsigned long addr)
 +bool is_module_address(unsigned long addr)
  {
 -      struct module *mod;
 +      bool ret;
  
        preempt_disable();
 -
 -      list_for_each_entry_rcu(mod, &modules, list) {
 -              if (within_module_core(addr, mod)) {
 -                      preempt_enable();
 -                      return 1;
 -              }
 -      }
 -
 +      ret = __module_address(addr) != NULL;
        preempt_enable();
  
 -      return 0;
 +      return ret;
  }
  
 -
 -/* Is this a valid kernel address? */
 -struct module *__module_text_address(unsigned long addr)
 +/*
 + * __module_address - get the module which contains an address.
 + * @addr: the address.
 + *
 + * Must be called with preempt disabled or module mutex held so that
 + * module doesn't get freed during this.
 + */
- __notrace_funcgraph struct module *__module_address(unsigned long addr)
++struct module *__module_address(unsigned long addr)
  {
        struct module *mod;
  
                return NULL;
  
        list_for_each_entry_rcu(mod, &modules, list)
 -              if (within(addr, mod->module_init, mod->init_text_size)
 -                  || within(addr, mod->module_core, mod->core_text_size))
 +              if (within_module_core(addr, mod)
 +                  || within_module_init(addr, mod))
                        return mod;
        return NULL;
  }
 +EXPORT_SYMBOL_GPL(__module_address);
  
 -struct module *module_text_address(unsigned long addr)
 +/*
 + * is_module_text_address - is this address inside module code?
 + * @addr: the address to check.
 + *
 + * See is_module_address() if you simply want to see if the address is
 + * anywhere in a module.  See kernel_text_address() for testing if an
 + * address corresponds to kernel or module code.
 + */
 +bool is_module_text_address(unsigned long addr)
  {
 -      struct module *mod;
 +      bool ret;
  
        preempt_disable();
 -      mod = __module_text_address(addr);
 +      ret = __module_text_address(addr) != NULL;
        preempt_enable();
  
 +      return ret;
 +}
 +
 +/*
 + * __module_text_address - get the module whose code contains an address.
 + * @addr: the address.
 + *
 + * Must be called with preempt disabled or module mutex held so that
 + * module doesn't get freed during this.
 + */
 +struct module *__module_text_address(unsigned long addr)
 +{
 +      struct module *mod = __module_address(addr);
 +      if (mod) {
 +              /* Make sure it's within the text section. */
 +              if (!within(addr, mod->module_init, mod->init_text_size)
 +                  && !within(addr, mod->module_core, mod->core_text_size))
 +                      mod = NULL;
 +      }
        return mod;
  }
 +EXPORT_SYMBOL_GPL(__module_text_address);
  
  /* Don't grab lock, we're oopsing. */
  void print_modules(void)
  }
  
  #ifdef CONFIG_MODVERSIONS
 -/* Generate the signature for struct module here, too, for modversions. */
 -void struct_module(struct module *mod) { return; }
 -EXPORT_SYMBOL(struct_module);
 +/* Generate the signature for all relevant module structures here.
 + * If these change, we don't want to try to parse the module. */
 +void module_layout(struct module *mod,
 +                 struct modversion_info *ver,
 +                 struct kernel_param *kp,
 +                 struct kernel_symbol *ks,
 +                 struct marker *marker,
 +                 struct tracepoint *tp)
 +{
 +}
 +EXPORT_SYMBOL(module_layout);
  #endif
  
  #ifdef CONFIG_MARKERS
diff --combined kernel/relay.c
@@@ -677,9 -677,7 +677,7 @@@ int relay_late_setup_files(struct rcha
         */
        for_each_online_cpu(i) {
                if (unlikely(!chan->buf[i])) {
-                       printk(KERN_ERR "relay_late_setup_files: CPU %u "
-                                       "has no buffer, it must have!\n", i);
-                       BUG();
+                       WARN_ONCE(1, KERN_ERR "CPU has no buffer!\n");
                        err = -EINVAL;
                        break;
                }
@@@ -797,15 -795,13 +795,15 @@@ void relay_subbufs_consumed(struct rcha
        if (!chan)
                return;
  
 -      if (cpu >= NR_CPUS || !chan->buf[cpu])
 +      if (cpu >= NR_CPUS || !chan->buf[cpu] ||
 +                                      subbufs_consumed > chan->n_subbufs)
                return;
  
        buf = chan->buf[cpu];
 -      buf->subbufs_consumed += subbufs_consumed;
 -      if (buf->subbufs_consumed > buf->subbufs_produced)
 +      if (subbufs_consumed > buf->subbufs_produced - buf->subbufs_consumed)
                buf->subbufs_consumed = buf->subbufs_produced;
 +      else
 +              buf->subbufs_consumed += subbufs_consumed;
  }
  EXPORT_SYMBOL_GPL(relay_subbufs_consumed);
  
diff --combined kernel/sched.c
@@@ -1110,7 -1110,7 +1110,7 @@@ static void hrtick_start(struct rq *rq
        if (rq == this_rq()) {
                hrtimer_restart(timer);
        } else if (!rq->hrtick_csd_pending) {
 -              __smp_call_function_single(cpu_of(rq), &rq->hrtick_csd);
 +              __smp_call_function_single(cpu_of(rq), &rq->hrtick_csd, 0);
                rq->hrtick_csd_pending = 1;
        }
  }
@@@ -3818,23 -3818,19 +3818,23 @@@ find_busiest_queue(struct sched_group *
   */
  #define MAX_PINNED_INTERVAL   512
  
 +/* Working cpumask for load_balance and load_balance_newidle. */
 +static DEFINE_PER_CPU(cpumask_var_t, load_balance_tmpmask);
 +
  /*
   * Check this_cpu to ensure it is balanced within domain. Attempt to move
   * tasks if there is an imbalance.
   */
  static int load_balance(int this_cpu, struct rq *this_rq,
                        struct sched_domain *sd, enum cpu_idle_type idle,
 -                      int *balance, struct cpumask *cpus)
 +                      int *balance)
  {
        int ld_moved, all_pinned = 0, active_balance = 0, sd_idle = 0;
        struct sched_group *group;
        unsigned long imbalance;
        struct rq *busiest;
        unsigned long flags;
 +      struct cpumask *cpus = __get_cpu_var(load_balance_tmpmask);
  
        cpumask_setall(cpus);
  
@@@ -3989,7 -3985,8 +3989,7 @@@ out
   * this_rq is locked.
   */
  static int
 -load_balance_newidle(int this_cpu, struct rq *this_rq, struct sched_domain *sd,
 -                      struct cpumask *cpus)
 +load_balance_newidle(int this_cpu, struct rq *this_rq, struct sched_domain *sd)
  {
        struct sched_group *group;
        struct rq *busiest = NULL;
        int ld_moved = 0;
        int sd_idle = 0;
        int all_pinned = 0;
 +      struct cpumask *cpus = __get_cpu_var(load_balance_tmpmask);
  
        cpumask_setall(cpus);
  
@@@ -4138,6 -4134,10 +4138,6 @@@ static void idle_balance(int this_cpu, 
        struct sched_domain *sd;
        int pulled_task = 0;
        unsigned long next_balance = jiffies + HZ;
 -      cpumask_var_t tmpmask;
 -
 -      if (!alloc_cpumask_var(&tmpmask, GFP_ATOMIC))
 -              return;
  
        for_each_domain(this_cpu, sd) {
                unsigned long interval;
                if (sd->flags & SD_BALANCE_NEWIDLE)
                        /* If we've pulled tasks over stop searching: */
                        pulled_task = load_balance_newidle(this_cpu, this_rq,
 -                                                         sd, tmpmask);
 +                                                         sd);
  
                interval = msecs_to_jiffies(sd->balance_interval);
                if (time_after(next_balance, sd->last_balance + interval))
                 */
                this_rq->next_balance = next_balance;
        }
 -      free_cpumask_var(tmpmask);
  }
  
  /*
@@@ -4312,6 -4313,11 +4312,6 @@@ static void rebalance_domains(int cpu, 
        unsigned long next_balance = jiffies + 60*HZ;
        int update_next_balance = 0;
        int need_serialize;
 -      cpumask_var_t tmp;
 -
 -      /* Fails alloc?  Rebalancing probably not a priority right now. */
 -      if (!alloc_cpumask_var(&tmp, GFP_ATOMIC))
 -              return;
  
        for_each_domain(cpu, sd) {
                if (!(sd->flags & SD_LOAD_BALANCE))
                }
  
                if (time_after_eq(jiffies, sd->last_balance + interval)) {
 -                      if (load_balance(cpu, rq, sd, idle, &balance, tmp)) {
 +                      if (load_balance(cpu, rq, sd, idle, &balance)) {
                                /*
                                 * We've pulled tasks over so either we're no
                                 * longer idle, or one of our SMT siblings is
@@@ -4370,6 -4376,8 +4370,6 @@@ out
         */
        if (likely(update_next_balance))
                rq->next_balance = next_balance;
 -
 -      free_cpumask_var(tmp);
  }
  
  /*
@@@ -4773,10 -4781,7 +4773,7 @@@ void scheduler_tick(void
  #endif
  }
  
- #if defined(CONFIG_PREEMPT) && (defined(CONFIG_DEBUG_PREEMPT) || \
-                               defined(CONFIG_PREEMPT_TRACER))
- static inline unsigned long get_parent_ip(unsigned long addr)
+ unsigned long get_parent_ip(unsigned long addr)
  {
        if (in_lock_functions(addr)) {
                addr = CALLER_ADDR2;
        return addr;
  }
  
+ #if defined(CONFIG_PREEMPT) && (defined(CONFIG_DEBUG_PREEMPT) || \
+                               defined(CONFIG_PREEMPT_TRACER))
  void __kprobes add_preempt_count(int val)
  {
  #ifdef CONFIG_DEBUG_PREEMPT
@@@ -7720,7 -7728,7 +7720,7 @@@ cpu_to_core_group(int cpu, const struc
  {
        int group;
  
 -      cpumask_and(mask, &per_cpu(cpu_sibling_map, cpu), cpu_map);
 +      cpumask_and(mask, topology_thread_cpumask(cpu), cpu_map);
        group = cpumask_first(mask);
        if (sg)
                *sg = &per_cpu(sched_group_core, group).sg;
@@@ -7749,7 -7757,7 +7749,7 @@@ cpu_to_phys_group(int cpu, const struc
        cpumask_and(mask, cpu_coregroup_mask(cpu), cpu_map);
        group = cpumask_first(mask);
  #elif defined(CONFIG_SCHED_SMT)
 -      cpumask_and(mask, &per_cpu(cpu_sibling_map, cpu), cpu_map);
 +      cpumask_and(mask, topology_thread_cpumask(cpu), cpu_map);
        group = cpumask_first(mask);
  #else
        group = cpu;
@@@ -8092,7 -8100,7 +8092,7 @@@ static int __build_sched_domains(const 
                SD_INIT(sd, SIBLING);
                set_domain_attribute(sd, attr);
                cpumask_and(sched_domain_span(sd),
 -                          &per_cpu(cpu_sibling_map, i), cpu_map);
 +                          topology_thread_cpumask(i), cpu_map);
                sd->parent = p;
                p->child = sd;
                cpu_to_cpu_group(i, cpu_map, &sd->groups, tmpmask);
        /* Set up CPU (sibling) groups */
        for_each_cpu(i, cpu_map) {
                cpumask_and(this_sibling_map,
 -                          &per_cpu(cpu_sibling_map, i), cpu_map);
 +                          topology_thread_cpumask(i), cpu_map);
                if (i != cpumask_first(this_sibling_map))
                        continue;
  
@@@ -8779,9 -8787,6 +8779,9 @@@ void __init sched_init(void
  #ifdef CONFIG_USER_SCHED
        alloc_size *= 2;
  #endif
 +#ifdef CONFIG_CPUMASK_OFFSTACK
 +      alloc_size += num_possible_cpus() * cpumask_size();
 +#endif
        /*
         * As sched_init() is called before page_alloc is setup,
         * we use alloc_bootmem().
                ptr += nr_cpu_ids * sizeof(void **);
  #endif /* CONFIG_USER_SCHED */
  #endif /* CONFIG_RT_GROUP_SCHED */
 +#ifdef CONFIG_CPUMASK_OFFSTACK
 +              for_each_possible_cpu(i) {
 +                      per_cpu(load_balance_tmpmask, i) = (void *)ptr;
 +                      ptr += cpumask_size();
 +              }
 +#endif /* CONFIG_CPUMASK_OFFSTACK */
        }
  
  #ifdef CONFIG_SMP
diff --combined kernel/softirq.c
  #include <linux/freezer.h>
  #include <linux/kthread.h>
  #include <linux/rcupdate.h>
+ #include <linux/ftrace.h>
  #include <linux/smp.h>
  #include <linux/tick.h>
+ #include <trace/irq.h>
  
  #include <asm/irq.h>
  /*
@@@ -52,6 -54,11 +54,11 @@@ static struct softirq_action softirq_ve
  
  static DEFINE_PER_CPU(struct task_struct *, ksoftirqd);
  
+ char *softirq_to_name[NR_SOFTIRQS] = {
+       "HI", "TIMER", "NET_TX", "NET_RX", "BLOCK",
+       "TASKLET", "SCHED", "HRTIMER",  "RCU"
+ };
  /*
   * we cannot loop indefinitely here to avoid userspace starvation,
   * but we also don't want to introduce a worst case 1/HZ latency
@@@ -79,13 -86,23 +86,23 @@@ static void __local_bh_disable(unsigne
        WARN_ON_ONCE(in_irq());
  
        raw_local_irq_save(flags);
-       add_preempt_count(SOFTIRQ_OFFSET);
+       /*
+        * The preempt tracer hooks into add_preempt_count and will break
+        * lockdep because it calls back into lockdep after SOFTIRQ_OFFSET
+        * is set and before current->softirq_enabled is cleared.
+        * We must manually increment preempt_count here and manually
+        * call the trace_preempt_off later.
+        */
+       preempt_count() += SOFTIRQ_OFFSET;
        /*
         * Were softirqs turned off above:
         */
        if (softirq_count() == SOFTIRQ_OFFSET)
                trace_softirqs_off(ip);
        raw_local_irq_restore(flags);
+       if (preempt_count() == SOFTIRQ_OFFSET)
+               trace_preempt_off(CALLER_ADDR0, get_parent_ip(CALLER_ADDR1));
  }
  #else /* !CONFIG_TRACE_IRQFLAGS */
  static inline void __local_bh_disable(unsigned long ip)
@@@ -169,6 -186,9 +186,9 @@@ EXPORT_SYMBOL(local_bh_enable_ip)
   */
  #define MAX_SOFTIRQ_RESTART 10
  
+ DEFINE_TRACE(softirq_entry);
+ DEFINE_TRACE(softirq_exit);
  asmlinkage void __do_softirq(void)
  {
        struct softirq_action *h;
@@@ -195,12 -215,14 +215,14 @@@ restart
                if (pending & 1) {
                        int prev_count = preempt_count();
  
+                       trace_softirq_entry(h, softirq_vec);
                        h->action(h);
+                       trace_softirq_exit(h, softirq_vec);
                        if (unlikely(prev_count != preempt_count())) {
-                               printk(KERN_ERR "huh, entered softirq %td %p"
+                               printk(KERN_ERR "huh, entered softirq %td %s %p"
                                       "with preempt_count %08x,"
                                       " exited with %08x?\n", h - softirq_vec,
+                                      softirq_to_name[h - softirq_vec],
                                       h->action, prev_count, preempt_count());
                                preempt_count() = prev_count;
                        }
@@@ -496,7 -518,7 +518,7 @@@ static int __try_remote_softirq(struct 
                cp->flags = 0;
                cp->priv = softirq;
  
 -              __smp_call_function_single(cpu, cp);
 +              __smp_call_function_single(cpu, cp, 0);
                return 0;
        }
        return 1;
diff --combined kernel/trace/Kconfig
@@@ -9,6 -9,9 +9,9 @@@ config USER_STACKTRACE_SUPPOR
  config NOP_TRACER
        bool
  
+ config HAVE_FTRACE_NMI_ENTER
+       bool
  config HAVE_FUNCTION_TRACER
        bool
  
@@@ -31,12 -34,20 +34,20 @@@ config HAVE_FTRACE_MCOUNT_RECOR
  config HAVE_HW_BRANCH_TRACER
        bool
  
+ config HAVE_FTRACE_SYSCALLS
+       bool
  config TRACER_MAX_TRACE
        bool
  
  config RING_BUFFER
        bool
  
+ config FTRACE_NMI_ENTER
+        bool
+        depends on HAVE_FTRACE_NMI_ENTER
+        default y
  config TRACING
        bool
        select DEBUG_FS
        select STACKTRACE if STACKTRACE_SUPPORT
        select TRACEPOINTS
        select NOP_TRACER
+       select BINARY_PRINTF
+ #
+ # Minimum requirements an architecture has to meet for us to
+ # be able to offer generic tracing facilities:
+ #
+ config TRACING_SUPPORT
+       bool
+       # PPC32 has no irqflags tracing support, but it can use most of the
+       # tracers anyway, they were tested to build and work. Note that new
+       # exceptions to this list aren't welcomed, better implement the
+       # irqflags tracing for your architecture.
+       depends on TRACE_IRQFLAGS_SUPPORT || PPC32
+       depends on STACKTRACE_SUPPORT
+       default y
+ if TRACING_SUPPORT
  
  menu "Tracers"
  
  config FUNCTION_TRACER
        bool "Kernel Function Tracer"
        depends on HAVE_FUNCTION_TRACER
-       depends on DEBUG_KERNEL
        select FRAME_POINTER
        select KALLSYMS
        select TRACING
@@@ -72,17 -99,17 +99,16 @@@ config FUNCTION_GRAPH_TRACE
        help
          Enable the kernel to trace a function at both its return
          and its entry.
 -        It's first purpose is to trace the duration of functions and
 -        draw a call graph for each thread with some informations like
 -        the return value.
 -        This is done by setting the current return address on the current
 -        task structure into a stack of calls.
 +        Its first purpose is to trace the duration of functions and
 +        draw a call graph for each thread with some information like
 +        the return value. This is done by setting the current return 
 +        address on the current task structure into a stack of calls.
  
  config IRQSOFF_TRACER
        bool "Interrupts-off Latency Tracer"
        default n
        depends on TRACE_IRQFLAGS_SUPPORT
        depends on GENERIC_TIME
-       depends on DEBUG_KERNEL
        select TRACE_IRQFLAGS
        select TRACING
        select TRACER_MAX_TRACE
@@@ -105,7 -132,6 +131,6 @@@ config PREEMPT_TRACE
        default n
        depends on GENERIC_TIME
        depends on PREEMPT
-       depends on DEBUG_KERNEL
        select TRACING
        select TRACER_MAX_TRACE
        help
@@@ -126,13 -152,13 +151,13 @@@ config SYSPROF_TRACE
        bool "Sysprof Tracer"
        depends on X86
        select TRACING
+       select CONTEXT_SWITCH_TRACER
        help
          This tracer provides the trace needed by the 'Sysprof' userspace
          tool.
  
  config SCHED_TRACER
        bool "Scheduling Latency Tracer"
-       depends on DEBUG_KERNEL
        select TRACING
        select CONTEXT_SWITCH_TRACER
        select TRACER_MAX_TRACE
  
  config CONTEXT_SWITCH_TRACER
        bool "Trace process context switches"
-       depends on DEBUG_KERNEL
        select TRACING
        select MARKERS
        help
          This tracer gets called from the context switch and records
          all switching of tasks.
  
+ config EVENT_TRACER
+       bool "Trace various events in the kernel"
+       select TRACING
+       help
+         This tracer hooks to various trace points in the kernel
+         allowing the user to pick and choose which trace point they
+         want to trace.
+ config FTRACE_SYSCALLS
+       bool "Trace syscalls"
+       depends on HAVE_FTRACE_SYSCALLS
+       select TRACING
+       select KALLSYMS
+       help
+         Basic tracer to catch the syscall entry and exit events.
  config BOOT_TRACER
        bool "Trace boot initcalls"
-       depends on DEBUG_KERNEL
        select TRACING
        select CONTEXT_SWITCH_TRACER
        help
          representation of the delays during initcalls - but the raw
          /debug/tracing/trace text output is readable too.
  
-         ( Note that tracing self tests can't be enabled if this tracer is
-           selected, because the self-tests are an initcall as well and that
-           would invalidate the boot trace. )
+         You must pass in ftrace=initcall to the kernel command line
+         to enable this on bootup.
  
  config TRACE_BRANCH_PROFILING
        bool "Trace likely/unlikely profiler"
-       depends on DEBUG_KERNEL
        select TRACING
        help
          This tracer profiles all the the likely and unlikely macros
@@@ -223,7 -261,6 +260,6 @@@ config BRANCH_TRACE
  
  config POWER_TRACER
        bool "Trace power consumption behavior"
-       depends on DEBUG_KERNEL
        depends on X86
        select TRACING
        help
  config STACK_TRACER
        bool "Trace max stack"
        depends on HAVE_FUNCTION_TRACER
-       depends on DEBUG_KERNEL
        select FUNCTION_TRACER
        select STACKTRACE
        select KALLSYMS
@@@ -265,11 -301,66 +300,66 @@@ config HW_BRANCH_TRACE
          This tracer records all branches on the system in a circular
          buffer giving access to the last N branches for each cpu.
  
+ config KMEMTRACE
+       bool "Trace SLAB allocations"
+       select TRACING
+       help
+         kmemtrace provides tracing for slab allocator functions, such as
+         kmalloc, kfree, kmem_cache_alloc, kmem_cache_free etc.. Collected
+         data is then fed to the userspace application in order to analyse
+         allocation hotspots, internal fragmentation and so on, making it
+         possible to see how well an allocator performs, as well as debug
+         and profile kernel code.
+         This requires an userspace application to use. See
+         Documentation/vm/kmemtrace.txt for more information.
+         Saying Y will make the kernel somewhat larger and slower. However,
+         if you disable kmemtrace at run-time or boot-time, the performance
+         impact is minimal (depending on the arch the kernel is built for).
+         If unsure, say N.
+ config WORKQUEUE_TRACER
+       bool "Trace workqueues"
+       select TRACING
+       help
+         The workqueue tracer provides some statistical informations
+           about each cpu workqueue thread such as the number of the
+           works inserted and executed since their creation. It can help
+           to evaluate the amount of work each of them have to perform.
+           For example it can help a developer to decide whether he should
+           choose a per cpu workqueue instead of a singlethreaded one.
+ config BLK_DEV_IO_TRACE
+       bool "Support for tracing block io actions"
+       depends on SYSFS
+       depends on BLOCK
+       select RELAY
+       select DEBUG_FS
+       select TRACEPOINTS
+       select TRACING
+       select STACKTRACE
+       help
+         Say Y here if you want to be able to trace the block layer actions
+         on a given queue. Tracing allows you to see any traffic happening
+         on a block device queue. For more information (and the userspace
+         support tools needed), fetch the blktrace tools from:
+         git://git.kernel.dk/blktrace.git
+         Tracing also is possible using the ftrace interface, e.g.:
+           echo 1 > /sys/block/sda/sda1/trace/enable
+           echo blk > /sys/kernel/debug/tracing/current_tracer
+           cat /sys/kernel/debug/tracing/trace_pipe
+         If unsure, say N.
  config DYNAMIC_FTRACE
        bool "enable/disable ftrace tracepoints dynamically"
        depends on FUNCTION_TRACER
        depends on HAVE_DYNAMIC_FTRACE
-       depends on DEBUG_KERNEL
        default y
        help
           This option will modify all the calls to ftrace dynamically
@@@ -295,7 -386,7 +385,7 @@@ config FTRACE_SELFTES
  
  config FTRACE_STARTUP_TEST
        bool "Perform a startup test on ftrace"
-       depends on TRACING && DEBUG_KERNEL && !BOOT_TRACER
+       depends on TRACING
        select FTRACE_SELFTEST
        help
          This option performs a series of startup tests on ftrace. On bootup
  
  config MMIOTRACE
        bool "Memory mapped IO tracing"
-       depends on HAVE_MMIOTRACE_SUPPORT && DEBUG_KERNEL && PCI
+       depends on HAVE_MMIOTRACE_SUPPORT && PCI
        select TRACING
        help
          Mmiotrace traces Memory Mapped I/O access and is meant for
@@@ -327,3 -418,6 +417,6 @@@ config MMIOTRACE_TES
          Say N, unless you absolutely know what you are doing.
  
  endmenu
+ endif # TRACING_SUPPORT
diff --combined kernel/workqueue.c
@@@ -33,6 -33,7 +33,7 @@@
  #include <linux/kallsyms.h>
  #include <linux/debug_locks.h>
  #include <linux/lockdep.h>
+ #include <trace/workqueue.h>
  
  /*
   * The per-CPU workqueue (if single thread, we always use the first
@@@ -48,6 -49,8 +49,6 @@@ struct cpu_workqueue_struct 
  
        struct workqueue_struct *wq;
        struct task_struct *thread;
 -
 -      int run_depth;          /* Detect run_workqueue() recursion depth */
  } ____cacheline_aligned;
  
  /*
@@@ -123,9 -126,13 +124,13 @@@ struct cpu_workqueue_struct *get_wq_dat
        return (void *) (atomic_long_read(&work->data) & WORK_STRUCT_WQ_DATA_MASK);
  }
  
+ DEFINE_TRACE(workqueue_insertion);
  static void insert_work(struct cpu_workqueue_struct *cwq,
                        struct work_struct *work, struct list_head *head)
  {
+       trace_workqueue_insertion(cwq->thread, work);
        set_wq_data(work, cwq);
        /*
         * Ensure that we get the right work->data if we see the
@@@ -257,9 -264,18 +262,11 @@@ int queue_delayed_work_on(int cpu, stru
  }
  EXPORT_SYMBOL_GPL(queue_delayed_work_on);
  
+ DEFINE_TRACE(workqueue_execution);
  static void run_workqueue(struct cpu_workqueue_struct *cwq)
  {
        spin_lock_irq(&cwq->lock);
 -      cwq->run_depth++;
 -      if (cwq->run_depth > 3) {
 -              /* morton gets to eat his hat */
 -              printk("%s: recursion depth exceeded: %d\n",
 -                      __func__, cwq->run_depth);
 -              dump_stack();
 -      }
        while (!list_empty(&cwq->worklist)) {
                struct work_struct *work = list_entry(cwq->worklist.next,
                                                struct work_struct, entry);
                 */
                struct lockdep_map lockdep_map = work->lockdep_map;
  #endif
+               trace_workqueue_execution(cwq->thread, work);
                cwq->current_work = work;
                list_del_init(cwq->worklist.next);
                spin_unlock_irq(&cwq->lock);
                spin_lock_irq(&cwq->lock);
                cwq->current_work = NULL;
        }
 -      cwq->run_depth--;
        spin_unlock_irq(&cwq->lock);
  }
  
@@@ -358,20 -375,29 +365,20 @@@ static void insert_wq_barrier(struct cp
  
  static int flush_cpu_workqueue(struct cpu_workqueue_struct *cwq)
  {
 -      int active;
 -
 -      if (cwq->thread == current) {
 -              /*
 -               * Probably keventd trying to flush its own queue. So simply run
 -               * it by hand rather than deadlocking.
 -               */
 -              run_workqueue(cwq);
 -              active = 1;
 -      } else {
 -              struct wq_barrier barr;
 +      int active = 0;
 +      struct wq_barrier barr;
  
 -              active = 0;
 -              spin_lock_irq(&cwq->lock);
 -              if (!list_empty(&cwq->worklist) || cwq->current_work != NULL) {
 -                      insert_wq_barrier(cwq, &barr, &cwq->worklist);
 -                      active = 1;
 -              }
 -              spin_unlock_irq(&cwq->lock);
 +      WARN_ON(cwq->thread == current);
  
 -              if (active)
 -                      wait_for_completion(&barr.done);
 +      spin_lock_irq(&cwq->lock);
 +      if (!list_empty(&cwq->worklist) || cwq->current_work != NULL) {
 +              insert_wq_barrier(cwq, &barr, &cwq->worklist);
 +              active = 1;
        }
 +      spin_unlock_irq(&cwq->lock);
 +
 +      if (active)
 +              wait_for_completion(&barr.done);
  
        return active;
  }
@@@ -746,6 -772,8 +753,8 @@@ init_cpu_workqueue(struct workqueue_str
        return cwq;
  }
  
+ DEFINE_TRACE(workqueue_creation);
  static int create_workqueue_thread(struct cpu_workqueue_struct *cwq, int cpu)
  {
        struct sched_param param = { .sched_priority = MAX_RT_PRIO-1 };
                sched_setscheduler_nocheck(p, SCHED_FIFO, &param);
        cwq->thread = p;
  
+       trace_workqueue_creation(cwq->thread, cpu);
        return 0;
  }
  
@@@ -849,6 -879,8 +860,8 @@@ struct workqueue_struct *__create_workq
  }
  EXPORT_SYMBOL_GPL(__create_workqueue_key);
  
+ DEFINE_TRACE(workqueue_destruction);
  static void cleanup_workqueue_thread(struct cpu_workqueue_struct *cwq)
  {
        /*
         * checks list_empty(), and a "normal" queue_work() can't use
         * a dead CPU.
         */
+       trace_workqueue_destruction(cwq->thread);
        kthread_stop(cwq->thread);
        cwq->thread = NULL;
  }
diff --combined mm/slab.c
+++ b/mm/slab.c
  #include      <linux/cpu.h>
  #include      <linux/sysctl.h>
  #include      <linux/module.h>
+ #include      <trace/kmemtrace.h>
  #include      <linux/rcupdate.h>
  #include      <linux/string.h>
  #include      <linux/uaccess.h>
@@@ -568,6 -569,14 +569,14 @@@ static void **dbg_userword(struct kmem_
  
  #endif
  
+ #ifdef CONFIG_KMEMTRACE
+ size_t slab_buffer_size(struct kmem_cache *cachep)
+ {
+       return cachep->buffer_size;
+ }
+ EXPORT_SYMBOL(slab_buffer_size);
+ #endif
  /*
   * Do not go above this order unless 0 objects fit into the slab.
   */
@@@ -1160,7 -1169,7 +1169,7 @@@ static void __cpuinit cpuup_canceled(lo
        struct kmem_cache *cachep;
        struct kmem_list3 *l3 = NULL;
        int node = cpu_to_node(cpu);
 -      node_to_cpumask_ptr(mask, node);
 +      const struct cpumask *mask = cpumask_of_node(node);
  
        list_for_each_entry(cachep, &cache_chain, next) {
                struct array_cache *nc;
@@@ -3554,10 -3563,23 +3563,23 @@@ static inline void __cache_free(struct 
   */
  void *kmem_cache_alloc(struct kmem_cache *cachep, gfp_t flags)
  {
-       return __cache_alloc(cachep, flags, __builtin_return_address(0));
+       void *ret = __cache_alloc(cachep, flags, __builtin_return_address(0));
+       kmemtrace_mark_alloc(KMEMTRACE_TYPE_CACHE, _RET_IP_, ret,
+                            obj_size(cachep), cachep->buffer_size, flags);
+       return ret;
  }
  EXPORT_SYMBOL(kmem_cache_alloc);
  
+ #ifdef CONFIG_KMEMTRACE
+ void *kmem_cache_alloc_notrace(struct kmem_cache *cachep, gfp_t flags)
+ {
+       return __cache_alloc(cachep, flags, __builtin_return_address(0));
+ }
+ EXPORT_SYMBOL(kmem_cache_alloc_notrace);
+ #endif
  /**
   * kmem_ptr_validate - check if an untrusted pointer might be a slab entry.
   * @cachep: the cache we're checking against
  #ifdef CONFIG_NUMA
  void *kmem_cache_alloc_node(struct kmem_cache *cachep, gfp_t flags, int nodeid)
  {
-       return __cache_alloc_node(cachep, flags, nodeid,
-                       __builtin_return_address(0));
+       void *ret = __cache_alloc_node(cachep, flags, nodeid,
+                                      __builtin_return_address(0));
+       kmemtrace_mark_alloc_node(KMEMTRACE_TYPE_CACHE, _RET_IP_, ret,
+                                 obj_size(cachep), cachep->buffer_size,
+                                 flags, nodeid);
+       return ret;
  }
  EXPORT_SYMBOL(kmem_cache_alloc_node);
  
+ #ifdef CONFIG_KMEMTRACE
+ void *kmem_cache_alloc_node_notrace(struct kmem_cache *cachep,
+                                   gfp_t flags,
+                                   int nodeid)
+ {
+       return __cache_alloc_node(cachep, flags, nodeid,
+                                 __builtin_return_address(0));
+ }
+ EXPORT_SYMBOL(kmem_cache_alloc_node_notrace);
+ #endif
  static __always_inline void *
  __do_kmalloc_node(size_t size, gfp_t flags, int node, void *caller)
  {
        struct kmem_cache *cachep;
+       void *ret;
  
        cachep = kmem_find_general_cachep(size, flags);
        if (unlikely(ZERO_OR_NULL_PTR(cachep)))
                return cachep;
-       return kmem_cache_alloc_node(cachep, flags, node);
+       ret = kmem_cache_alloc_node_notrace(cachep, flags, node);
+       kmemtrace_mark_alloc_node(KMEMTRACE_TYPE_KMALLOC,
+                                 (unsigned long) caller, ret,
+                                 size, cachep->buffer_size, flags, node);
+       return ret;
  }
  
- #ifdef CONFIG_DEBUG_SLAB
+ #if defined(CONFIG_DEBUG_SLAB) || defined(CONFIG_KMEMTRACE)
  void *__kmalloc_node(size_t size, gfp_t flags, int node)
  {
        return __do_kmalloc_node(size, flags, node,
@@@ -3651,6 -3697,7 +3697,7 @@@ static __always_inline void *__do_kmall
                                          void *caller)
  {
        struct kmem_cache *cachep;
+       void *ret;
  
        /* If you want to save a few bytes .text space: replace
         * __ with kmem_.
        cachep = __find_general_cachep(size, flags);
        if (unlikely(ZERO_OR_NULL_PTR(cachep)))
                return cachep;
-       return __cache_alloc(cachep, flags, caller);
+       ret = __cache_alloc(cachep, flags, caller);
+       kmemtrace_mark_alloc(KMEMTRACE_TYPE_KMALLOC,
+                            (unsigned long) caller, ret,
+                            size, cachep->buffer_size, flags);
+       return ret;
  }
  
  
- #ifdef CONFIG_DEBUG_SLAB
+ #if defined(CONFIG_DEBUG_SLAB) || defined(CONFIG_KMEMTRACE)
  void *__kmalloc(size_t size, gfp_t flags)
  {
        return __do_kmalloc(size, flags, __builtin_return_address(0));
@@@ -3703,6 -3756,8 +3756,8 @@@ void kmem_cache_free(struct kmem_cache 
                debug_check_no_obj_freed(objp, obj_size(cachep));
        __cache_free(cachep, objp);
        local_irq_restore(flags);
+       kmemtrace_mark_free(KMEMTRACE_TYPE_CACHE, _RET_IP_, objp);
  }
  EXPORT_SYMBOL(kmem_cache_free);
  
@@@ -3729,6 -3784,8 +3784,8 @@@ void kfree(const void *objp
        debug_check_no_obj_freed(objp, obj_size(c));
        __cache_free(c, (void *)objp);
        local_irq_restore(flags);
+       kmemtrace_mark_free(KMEMTRACE_TYPE_KMALLOC, _RET_IP_, objp);
  }
  EXPORT_SYMBOL(kfree);
  
@@@ -3992,7 -4049,8 +4049,7 @@@ static void cache_reap(struct work_stru
        struct kmem_cache *searchp;
        struct kmem_list3 *l3;
        int node = numa_node_id();
 -      struct delayed_work *work =
 -              container_of(w, struct delayed_work, work);
 +      struct delayed_work *work = to_delayed_work(w);
  
        if (!mutex_trylock(&cache_chain_mutex))
                /* Give up. Setup the next iteration. */