obj-$(CONFIG_X86_64_SMP)      += tsc_sync.o smpcommon.o
  obj-$(CONFIG_X86_TRAMPOLINE)  += trampoline_$(BITS).o
  obj-$(CONFIG_X86_MPPARSE)     += mpparse.o
 -obj-$(CONFIG_X86_LOCAL_APIC)  += apic_$(BITS).o nmi_$(BITS).o
 +obj-$(CONFIG_X86_LOCAL_APIC)  += apic_$(BITS).o nmi.o
  obj-$(CONFIG_X86_IO_APIC)     += io_apic_$(BITS).o
  obj-$(CONFIG_X86_REBOOTFIXUPS)        += reboot_fixups_32.o
+ obj-$(CONFIG_DYNAMIC_FTRACE)  += ftrace.o
  obj-$(CONFIG_KEXEC)           += machine_kexec_$(BITS).o
  obj-$(CONFIG_KEXEC)           += relocate_kernel_$(BITS).o crash.o
  obj-$(CONFIG_CRASH_DUMP)      += crash_dump_$(BITS).o
 
  #include <asm/percpu.h>
  #include <asm/dwarf2.h>
  #include <asm/processor-flags.h>
 -#include "irq_vectors.h"
+ #include <asm/ftrace.h>
 +#include <asm/irq_vectors.h>
  
  /*
   * We use macros for low-level operations which need to be overridden
 
  
                        local_irq_disable();
                        __get_cpu_var(irq_stat).idle_timestamp = jiffies;
 -                      idle();
+                       /* Don't trace irqs off for idle */
+                       stop_critical_timings();
 +                      pm_idle();
+                       start_critical_timings();
                }
                tick_nohz_restart_sched_tick();
                preempt_enable_no_resched();
 
                         */
                        local_irq_disable();
                        enter_idle();
 -                      idle();
+                       /* Don't trace irqs off for idle */
+                       stop_critical_timings();
 +                      pm_idle();
+                       start_critical_timings();
                        /* In many cases the interrupt that ended idle
                           has already called exit_idle. But some idle
                           loops can be woken up without interrupt. */
 
  
  obj-$(CONFIG_SMP) := msr-on-cpu.o
  
 -lib-y := delay_$(BITS).o
 +lib-y := delay.o
+ lib-y += thunk_$(BITS).o
 -lib-y += usercopy_$(BITS).o getuser_$(BITS).o putuser_$(BITS).o
 +lib-y += usercopy_$(BITS).o getuser.o putuser.o
  lib-y += memcpy_$(BITS).o
  
  ifeq ($(CONFIG_X86_32),y)
 
  #else
  
  #ifdef CONFIG_X86_64
- #define ARCH_TRACE_IRQS_ON            call trace_hardirqs_on_thunk
- #define ARCH_TRACE_IRQS_OFF           call trace_hardirqs_off_thunk
 -/*
 - * Currently paravirt can't handle swapgs nicely when we
 - * don't have a stack we can rely on (such as a user space
 - * stack).  So we either find a way around these or just fault
 - * and emulate if a guest tries to call swapgs directly.
 - *
 - * Either way, this is a good way to document that we don't
 - * have a reliable stack. x86_64 only.
 - */
 -#define SWAPGS_UNSAFE_STACK   swapgs
  #define ARCH_LOCKDEP_SYS_EXIT         call lockdep_sys_exit_thunk
  #define ARCH_LOCKDEP_SYS_EXIT_IRQ     \
        TRACE_IRQS_ON; \
 
  #ifndef _LINUX_LINKAGE_H
  #define _LINUX_LINKAGE_H
  
 +#include <linux/compiler.h>
  #include <asm/linkage.h>
  
+ #define notrace __attribute__((no_instrument_function))
+ 
  #ifdef __cplusplus
  #define CPP_ASMLINKAGE extern "C"
  #else
 
  obj-$(CONFIG_TASKSTATS) += taskstats.o tsacct.o
  obj-$(CONFIG_MARKERS) += marker.o
  obj-$(CONFIG_LATENCYTOP) += latencytop.o
+ obj-$(CONFIG_FTRACE) += trace/
+ obj-$(CONFIG_TRACING) += trace/
 +obj-$(CONFIG_SMP) += sched_cpupri.o
  
  ifneq ($(CONFIG_SCHED_NO_NO_OMIT_FRAME_POINTER),y)
  # According to Alan Modra <alan@linuxcare.com.au>, the -fno-omit-frame-pointer is
 
                 * management (if any):
                 */
                p->sched_class->task_new(rq, p);
 -              inc_nr_running(p, rq);
 +              inc_nr_running(rq);
        }
+       trace_mark(kernel_sched_wakeup_new,
+               "pid %d state %ld ## rq %p task %p rq->curr %p",
+               p->pid, p->state, rq, p, rq->curr);
        check_preempt_curr(rq, p);
  #ifdef CONFIG_SMP
        if (p->sched_class->task_wake_up)