Merge tag 'trace-v4.19' of git://git.kernel.org/pub/scm/linux/kernel/git/rostedt...
authorLinus Torvalds <torvalds@linux-foundation.org>
Tue, 21 Aug 2018 01:32:00 +0000 (18:32 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Tue, 21 Aug 2018 01:32:00 +0000 (18:32 -0700)
Pull tracing updates from Steven Rostedt:

 - Restructure of lockdep and latency tracers

   This is the biggest change. Joel Fernandes restructured the hooks
   from irqs and preemption disabling and enabling. He got rid of a lot
   of the preprocessor #ifdef mess that they caused.

   He turned both lockdep and the latency tracers to use trace events
   inserted in the preempt/irqs disabling paths. But unfortunately,
   these started to cause issues in corner cases. Thus, parts of the
   code was reverted back to where lockdep and the latency tracers just
   get called directly (without using the trace events). But because the
   original change cleaned up the code very nicely we kept that, as well
   as the trace events for preempt and irqs disabling, but they are
   limited to not being called in NMIs.

 - Have trace events use SRCU for "rcu idle" calls. This was required
   for the preempt/irqs off trace events. But it also had to not allow
   them to be called in NMI context. Waiting till Paul makes an NMI safe
   SRCU API.

 - New notrace SRCU API to allow trace events to use SRCU.

 - Addition of mcount-nop option support

 - SPDX headers replacing GPL templates.

 - Various other fixes and clean ups.

 - Some fixes are marked for stable, but were not fully tested before
   the merge window opened.

* tag 'trace-v4.19' of git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-trace: (44 commits)
  tracing: Fix SPDX format headers to use C++ style comments
  tracing: Add SPDX License format tags to tracing files
  tracing: Add SPDX License format to bpf_trace.c
  blktrace: Add SPDX License format header
  s390/ftrace: Add -mfentry and -mnop-mcount support
  tracing: Add -mcount-nop option support
  tracing: Avoid calling cc-option -mrecord-mcount for every Makefile
  tracing: Handle CC_FLAGS_FTRACE more accurately
  Uprobe: Additional argument arch_uprobe to uprobe_write_opcode()
  Uprobes: Simplify uprobe_register() body
  tracepoints: Free early tracepoints after RCU is initialized
  uprobes: Use synchronize_rcu() not synchronize_sched()
  tracing: Fix synchronizing to event changes with tracepoint_synchronize_unregister()
  ftrace: Remove unused pointer ftrace_swapper_pid
  tracing: More reverting of "tracing: Centralize preemptirq tracepoints and unify their usage"
  tracing/irqsoff: Handle preempt_count for different configs
  tracing: Partial revert of "tracing: Centralize preemptirq tracepoints and unify their usage"
  tracing: irqsoff: Account for additional preempt_disable
  trace: Use rcu_dereference_raw for hooks from trace-event subsystem
  tracing/kprobes: Fix within_notrace_func() to check only notrace functions
  ...

1  2 
Makefile
arch/s390/Kconfig
arch/s390/Makefile
init/main.c
kernel/events/uprobes.c
kernel/sched/core.c
kernel/trace/Kconfig
kernel/trace/blktrace.c
kernel/trace/trace.c
kernel/trace/trace_kprobe.c
scripts/Makefile.build

diff --combined Makefile
index a0650bf79606124437148caac0b055b1fc1fe607,c5b0cd7f3c2a787db966b81b8cd26b5df663a7e9..c13f8b85ba6034283e7397bbb332223d38de8f7d
+++ b/Makefile
@@@ -2,7 -2,7 +2,7 @@@
  VERSION = 4
  PATCHLEVEL = 18
  SUBLEVEL = 0
 -EXTRAVERSION = -rc6
 +EXTRAVERSION =
  NAME = Merciless Moray
  
  # *DOCUMENTATION*
@@@ -224,14 -224,11 +224,14 @@@ clean-targets := %clean mrproper cleand
  no-dot-config-targets := $(clean-targets) \
                         cscope gtags TAGS tags help% %docs check% coccicheck \
                         $(version_h) headers_% archheaders archscripts \
 -                       kernelversion %src-pkg
 +                       %asm-generic kernelversion %src-pkg
 +no-sync-config-targets := $(no-dot-config-targets) install %install \
 +                         kernelrelease
  
 -config-targets := 0
 -mixed-targets  := 0
 -dot-config     := 1
 +config-targets  := 0
 +mixed-targets   := 0
 +dot-config      := 1
 +may-sync-config := 1
  
  ifneq ($(filter $(no-dot-config-targets), $(MAKECMDGOALS)),)
        ifeq ($(filter-out $(no-dot-config-targets), $(MAKECMDGOALS)),)
        endif
  endif
  
 +ifneq ($(filter $(no-sync-config-targets), $(MAKECMDGOALS)),)
 +      ifeq ($(filter-out $(no-sync-config-targets), $(MAKECMDGOALS)),)
 +              may-sync-config := 0
 +      endif
 +endif
 +
 +ifneq ($(KBUILD_EXTMOD),)
 +      may-sync-config := 0
 +endif
 +
  ifeq ($(KBUILD_EXTMOD),)
          ifneq ($(filter config %config,$(MAKECMDGOALS)),)
                  config-targets := 1
@@@ -372,12 -359,11 +372,12 @@@ HOST_LFS_LIBS := $(shell getconf LFS_LI
  
  HOSTCC       = gcc
  HOSTCXX      = g++
 -HOSTCFLAGS   := -Wall -Wmissing-prototypes -Wstrict-prototypes -O2 \
 -              -fomit-frame-pointer -std=gnu89 $(HOST_LFS_CFLAGS)
 -HOSTCXXFLAGS := -O2 $(HOST_LFS_CFLAGS)
 -HOSTLDFLAGS  := $(HOST_LFS_LDFLAGS)
 -HOST_LOADLIBES := $(HOST_LFS_LIBS)
 +KBUILD_HOSTCFLAGS   := -Wall -Wmissing-prototypes -Wstrict-prototypes -O2 \
 +              -fomit-frame-pointer -std=gnu89 $(HOST_LFS_CFLAGS) \
 +              $(HOSTCFLAGS)
 +KBUILD_HOSTCXXFLAGS := -O2 $(HOST_LFS_CFLAGS) $(HOSTCXXFLAGS)
 +KBUILD_HOSTLDFLAGS  := $(HOST_LFS_LDFLAGS) $(HOSTLDFLAGS)
 +KBUILD_HOSTLDLIBS   := $(HOST_LFS_LIBS) $(HOSTLDLIBS)
  
  # Make variables (CC, etc...)
  AS            = $(CROSS_COMPILE)as
@@@ -443,10 -429,10 +443,10 @@@ KBUILD_LDFLAGS_MODULE := -T $(srctree)/
  LDFLAGS :=
  GCC_PLUGINS_CFLAGS :=
  
 -export ARCH SRCARCH CONFIG_SHELL HOSTCC HOSTCFLAGS CROSS_COMPILE AS LD CC
 -export CPP AR NM STRIP OBJCOPY OBJDUMP HOSTLDFLAGS HOST_LOADLIBES
 +export ARCH SRCARCH CONFIG_SHELL HOSTCC KBUILD_HOSTCFLAGS CROSS_COMPILE AS LD CC
 +export CPP AR NM STRIP OBJCOPY OBJDUMP KBUILD_HOSTLDFLAGS KBUILD_HOSTLDLIBS
  export MAKE LEX YACC AWK GENKSYMS INSTALLKERNEL PERL PYTHON PYTHON2 PYTHON3 UTS_MACHINE
 -export HOSTCXX HOSTCXXFLAGS LDFLAGS_MODULE CHECK CHECKFLAGS
 +export HOSTCXX KBUILD_HOSTCXXFLAGS LDFLAGS_MODULE CHECK CHECKFLAGS
  
  export KBUILD_CPPFLAGS NOSTDINC_FLAGS LINUXINCLUDE OBJCOPYFLAGS LDFLAGS
  export KBUILD_CFLAGS CFLAGS_KERNEL CFLAGS_MODULE
@@@ -598,7 -584,7 +598,7 @@@ virt-y             := virt
  endif # KBUILD_EXTMOD
  
  ifeq ($(dot-config),1)
 --include include/config/auto.conf
 +include include/config/auto.conf
  endif
  
  # The all: target is the default when no target is given on the
@@@ -620,7 -606,7 +620,7 @@@ ARCH_CFLAGS :
  include arch/$(SRCARCH)/Makefile
  
  ifeq ($(dot-config),1)
 -ifeq ($(KBUILD_EXTMOD),)
 +ifeq ($(may-sync-config),1)
  # Read in dependencies to all Kconfig* files, make sure to run syncconfig if
  # changes are detected. This should be included after arch/$(SRCARCH)/Makefile
  # because some architectures define CROSS_COMPILE there.
@@@ -635,9 -621,8 +635,9 @@@ $(KCONFIG_CONFIG) include/config/auto.c
  include/config/%.conf: $(KCONFIG_CONFIG) include/config/auto.conf.cmd
        $(Q)$(MAKE) -f $(srctree)/Makefile syncconfig
  else
 -# external modules needs include/generated/autoconf.h and include/config/auto.conf
 -# but do not care if they are up-to-date. Use auto.conf to trigger the test
 +# External modules and some install targets need include/generated/autoconf.h
 +# and include/config/auto.conf but do not care if they are up-to-date.
 +# Use auto.conf to trigger the test
  PHONY += include/config/auto.conf
  
  include/config/auto.conf:
        echo >&2 ;                                                      \
        /bin/false)
  
 -endif # KBUILD_EXTMOD
 -
 -else
 -# Dummy target needed, because used as prerequisite
 -include/config/auto.conf: ;
 +endif # may-sync-config
  endif # $(dot-config)
  
  KBUILD_CFLAGS += $(call cc-option,-fno-delete-null-pointer-checks,)
@@@ -754,12 -743,28 +754,28 @@@ ifdef CONFIG_FUNCTION_TRACE
  ifndef CC_FLAGS_FTRACE
  CC_FLAGS_FTRACE := -pg
  endif
- export CC_FLAGS_FTRACE
+ ifdef CONFIG_FTRACE_MCOUNT_RECORD
+   # gcc 5 supports generating the mcount tables directly
+   ifeq ($(call cc-option-yn,-mrecord-mcount),y)
+     CC_FLAGS_FTRACE   += -mrecord-mcount
+     export CC_USING_RECORD_MCOUNT := 1
+   endif
+   ifdef CONFIG_HAVE_NOP_MCOUNT
+     ifeq ($(call cc-option-yn, -mnop-mcount),y)
+       CC_FLAGS_FTRACE += -mnop-mcount
+       CC_FLAGS_USING  += -DCC_USING_NOP_MCOUNT
+     endif
+   endif
+ endif
  ifdef CONFIG_HAVE_FENTRY
- CC_USING_FENTRY       := $(call cc-option, -mfentry -DCC_USING_FENTRY)
+   ifeq ($(call cc-option-yn, -mfentry),y)
+     CC_FLAGS_FTRACE   += -mfentry
+     CC_FLAGS_USING    += -DCC_USING_FENTRY
+   endif
  endif
- KBUILD_CFLAGS += $(CC_FLAGS_FTRACE) $(CC_USING_FENTRY)
- KBUILD_AFLAGS += $(CC_USING_FENTRY)
+ export CC_FLAGS_FTRACE
+ KBUILD_CFLAGS += $(CC_FLAGS_FTRACE) $(CC_FLAGS_USING)
+ KBUILD_AFLAGS += $(CC_FLAGS_USING)
  ifdef CONFIG_DYNAMIC_FTRACE
        ifdef CONFIG_HAVE_C_RECORDMCOUNT
                BUILD_C_RECORDMCOUNT := y
@@@ -1020,10 -1025,9 +1036,10 @@@ ifdef CONFIG_GDB_SCRIPT
  endif
        +$(call if_changed,link-vmlinux)
  
 -# Build samples along the rest of the kernel
 +# Build samples along the rest of the kernel. This needs headers_install.
  ifdef CONFIG_SAMPLES
  vmlinux-dirs += samples
 +samples: headers_install
  endif
  
  # The actual objects are generated when descending,
@@@ -1045,14 -1049,15 +1061,14 @@@ define filechk_kernel.releas
  endef
  
  # Store (new) KERNELRELEASE string in include/config/kernel.release
 -include/config/kernel.release: include/config/auto.conf FORCE
 +include/config/kernel.release: $(srctree)/Makefile FORCE
        $(call filechk,kernel.release)
  
  # Additional helpers built in scripts/
  # Carefully list dependencies so we do not try to build scripts twice
  # in parallel
  PHONY += scripts
 -scripts: scripts_basic include/config/auto.conf include/config/tristate.conf \
 -       asm-generic gcc-plugins $(autoksyms_h)
 +scripts: scripts_basic asm-generic gcc-plugins $(autoksyms_h)
        $(Q)$(MAKE) $(build)=$(@)
  
  # Things we need to do before we recursively start building the kernel
@@@ -1082,7 -1087,8 +1098,7 @@@ endi
  # that need to depend on updated CONFIG_* values can be checked here.
  prepare2: prepare3 outputmakefile asm-generic
  
 -prepare1: prepare2 $(version_h) $(autoksyms_h) include/generated/utsrelease.h \
 -                   include/config/auto.conf
 +prepare1: prepare2 $(version_h) $(autoksyms_h) include/generated/utsrelease.h
        $(cmd_crmodverdir)
  
  archprepare: archheaders archscripts prepare1 scripts_basic
@@@ -1126,7 -1132,7 +1142,7 @@@ define filechk_version.
        echo '#define KERNEL_VERSION(a,b,c) (((a) << 16) + ((b) << 8) + (c))';)
  endef
  
 -$(version_h): $(srctree)/Makefile FORCE
 +$(version_h): FORCE
        $(call filechk,version.h)
        $(Q)rm -f $(old_version_h)
  
@@@ -1220,7 -1226,7 +1236,7 @@@ modules: $(vmlinux-dirs) $(if $(KBUILD_
  modules.builtin: $(vmlinux-dirs:%=%/modules.builtin)
        $(Q)$(AWK) '!x[$$0]++' $^ > $(objtree)/modules.builtin
  
 -%/modules.builtin: include/config/auto.conf
 +%/modules.builtin: include/config/auto.conf include/config/tristate.conf
        $(Q)$(MAKE) $(modbuiltin)=$*
  
  
diff --combined arch/s390/Kconfig
index a6afa60074cb441c638e352c1e6fbb73f5fc2475,4e914445553e3eb5aa0add5c861360fcb599b9c8..054b29c9a533aa9d89189fd5307e3186fabbe402
@@@ -106,6 -106,7 +106,6 @@@ config S39
        select ARCH_USE_BUILTIN_BSWAP
        select ARCH_USE_CMPXCHG_LOCKREF
        select ARCH_WANTS_DYNAMIC_TASK_STRUCT
 -      select ARCH_WANTS_UBSAN_NO_NULL
        select ARCH_WANT_IPC_PARSE_VERSION
        select BUILDTIME_EXTABLE_SORT
        select CLONE_BACKWARDS2
        select HAVE_DYNAMIC_FTRACE
        select HAVE_DYNAMIC_FTRACE_WITH_REGS
        select HAVE_EFFICIENT_UNALIGNED_ACCESS
+       select HAVE_FENTRY
        select HAVE_FTRACE_MCOUNT_RECORD
        select HAVE_FUNCTION_GRAPH_TRACER
        select HAVE_FUNCTION_TRACER
        select HAVE_FUTEX_CMPXCHG if FUTEX
 -      select HAVE_GCC_PLUGINS
 +      select HAVE_GCC_PLUGINS if BROKEN
        select HAVE_KERNEL_BZIP2
        select HAVE_KERNEL_GZIP
        select HAVE_KERNEL_LZ4
        select HAVE_KERNEL_LZMA
        select HAVE_KERNEL_LZO
 +      select HAVE_KERNEL_UNCOMPRESSED
        select HAVE_KERNEL_XZ
        select HAVE_KPROBES
        select HAVE_KRETPROBES
        select HAVE_MEMBLOCK_NODE_MAP
        select HAVE_MEMBLOCK_PHYS_MAP
        select HAVE_MOD_ARCH_SPECIFIC
+       select HAVE_NOP_MCOUNT
        select HAVE_OPROFILE
        select HAVE_PERF_EVENTS
        select HAVE_REGS_AND_STACK_ACCESS_API
@@@ -184,6 -186,10 +186,6 @@@ config PGTABLE_LEVEL
        int
        default 5
  
 -source "init/Kconfig"
 -
 -source "kernel/Kconfig.freezer"
 -
  source "kernel/livepatch/Kconfig"
  
  menu "Processor type and features"
@@@ -511,6 -517,8 +513,6 @@@ config SCHED_TOPOLOG
          making when dealing with machines that have multi-threading,
          multiple cores or multiple books.
  
 -source kernel/Kconfig.preempt
 -
  source kernel/Kconfig.hz
  
  config KEXEC
@@@ -621,6 -629,8 +623,6 @@@ config FORCE_MAX_ZONEORDE
        int
        default "9"
  
 -source "mm/Kconfig"
 -
  config MAX_PHYSMEM_BITS
        int "Maximum size of supported physical memory in bits (42-53)"
        range 42 53
@@@ -790,6 -800,10 +792,6 @@@ config CRASH_DUM
  
  endmenu
  
 -menu "Executable file formats / Emulations"
 -
 -source "fs/Kconfig.binfmt"
 -
  config SECCOMP
        def_bool y
        prompt "Enable seccomp to safely compute untrusted bytecode"
  
          If unsure, say Y.
  
 -endmenu
 -
  menu "Power Management"
  
  config ARCH_HIBERNATION_POSSIBLE
@@@ -816,16 -832,30 +818,16 @@@ source "kernel/power/Kconfig
  
  endmenu
  
 -source "net/Kconfig"
 -
  config PCMCIA
        def_bool n
  
  config CCW
        def_bool y
  
 -source "drivers/Kconfig"
 -
  config HAVE_PNETID
        tristate
        default (SMC || CCWGROUP)
  
 -source "fs/Kconfig"
 -
 -source "arch/s390/Kconfig.debug"
 -
 -source "security/Kconfig"
 -
 -source "crypto/Kconfig"
 -
 -source "lib/Kconfig"
 -
  menu "Virtualization"
  
  config PFAULT
diff --combined arch/s390/Makefile
index eee6703093c32e884f00bd07554511a8ccb090f6,8498babb5dad3dd284317aaed31e11a5ffc138a3..ba6d122526fb408f858214e4e52da10e50b49490
@@@ -14,18 -14,8 +14,18 @@@ LD_BFD              := elf64-s39
  LDFLAGS               := -m elf64_s390
  KBUILD_AFLAGS_MODULE += -fPIC
  KBUILD_CFLAGS_MODULE += -fPIC
 -KBUILD_CFLAGS += -m64
  KBUILD_AFLAGS += -m64
 +KBUILD_CFLAGS += -m64
 +aflags_dwarf  := -Wa,-gdwarf-2
 +KBUILD_AFLAGS_DECOMPRESSOR := -m64 -D__ASSEMBLY__
 +KBUILD_AFLAGS_DECOMPRESSOR += $(if $(CONFIG_DEBUG_INFO),$(aflags_dwarf))
 +KBUILD_CFLAGS_DECOMPRESSOR := -m64 -O2
 +KBUILD_CFLAGS_DECOMPRESSOR += -DDISABLE_BRANCH_PROFILING -D__NO_FORTIFY
 +KBUILD_CFLAGS_DECOMPRESSOR += -fno-delete-null-pointer-checks -msoft-float
 +KBUILD_CFLAGS_DECOMPRESSOR += -fno-asynchronous-unwind-tables
 +KBUILD_CFLAGS_DECOMPRESSOR += $(call cc-option,-ffreestanding)
 +KBUILD_CFLAGS_DECOMPRESSOR += $(if $(CONFIG_DEBUG_INFO),-g)
 +KBUILD_CFLAGS_DECOMPRESSOR += $(if $(CONFIG_DEBUG_INFO_DWARF4), $(call cc-option, -gdwarf-4,))
  UTS_MACHINE   := s390x
  STACK_SIZE    := 16384
  CHECKFLAGS    += -D__s390__ -D__s390x__
@@@ -62,14 -52,18 +62,14 @@@ cflags-y += -Wa,-I$(srctree)/arch/$(ARC
  #
  cflags-$(CONFIG_FRAME_POINTER) += -fno-optimize-sibling-calls
  
 -# old style option for packed stacks
 -ifeq ($(call cc-option-yn,-mkernel-backchain),y)
 -cflags-$(CONFIG_PACK_STACK)  += -mkernel-backchain -D__PACK_STACK
 -aflags-$(CONFIG_PACK_STACK)  += -D__PACK_STACK
 -endif
 -
 -# new style option for packed stacks
  ifeq ($(call cc-option-yn,-mpacked-stack),y)
  cflags-$(CONFIG_PACK_STACK)  += -mpacked-stack -D__PACK_STACK
  aflags-$(CONFIG_PACK_STACK)  += -D__PACK_STACK
  endif
  
 +KBUILD_AFLAGS_DECOMPRESSOR += $(aflags-y)
 +KBUILD_CFLAGS_DECOMPRESSOR += $(cflags-y)
 +
  ifeq ($(call cc-option-yn,-mstack-size=8192 -mstack-guard=128),y)
  cflags-$(CONFIG_CHECK_STACK) += -mstack-size=$(STACK_SIZE)
  ifneq ($(call cc-option-yn,-mstack-size=8192),y)
@@@ -77,11 -71,8 +77,11 @@@ cflags-$(CONFIG_CHECK_STACK) += -mstack
  endif
  endif
  
 -ifeq ($(call cc-option-yn,-mwarn-dynamicstack),y)
 -cflags-$(CONFIG_WARN_DYNAMIC_STACK) += -mwarn-dynamicstack
 +ifdef CONFIG_WARN_DYNAMIC_STACK
 +  ifeq ($(call cc-option-yn,-mwarn-dynamicstack),y)
 +    KBUILD_CFLAGS += -mwarn-dynamicstack
 +    KBUILD_CFLAGS_DECOMPRESSOR += -mwarn-dynamicstack
 +  endif
  endif
  
  ifdef CONFIG_EXPOLINE
      CC_FLAGS_EXPOLINE += -mindirect-branch-table
      export CC_FLAGS_EXPOLINE
      cflags-y += $(CC_FLAGS_EXPOLINE) -DCC_USING_EXPOLINE
 +    aflags-y += -DCC_USING_EXPOLINE
    endif
  endif
  
  ifdef CONFIG_FUNCTION_TRACER
- # make use of hotpatch feature if the compiler supports it
- cc_hotpatch   := -mhotpatch=0,3
- ifeq ($(call cc-option-yn,$(cc_hotpatch)),y)
- CC_FLAGS_FTRACE := $(cc_hotpatch)
- KBUILD_AFLAGS += -DCC_USING_HOTPATCH
- KBUILD_CFLAGS += -DCC_USING_HOTPATCH
- endif
+   ifeq ($(call cc-option-yn,-mfentry -mnop-mcount),n)
+     # make use of hotpatch feature if the compiler supports it
+     cc_hotpatch       := -mhotpatch=0,3
+     ifeq ($(call cc-option-yn,$(cc_hotpatch)),y)
+       CC_FLAGS_FTRACE := $(cc_hotpatch)
+       KBUILD_AFLAGS   += -DCC_USING_HOTPATCH
+       KBUILD_CFLAGS   += -DCC_USING_HOTPATCH
+     endif
+   endif
  endif
  
  # Test CFI features of binutils
@@@ -112,12 -104,11 +114,12 @@@ KBUILD_CFLAGS   += -mbackchain -msoft-flo
  KBUILD_CFLAGS += -pipe -fno-strength-reduce -Wno-sign-compare
  KBUILD_CFLAGS += -fno-asynchronous-unwind-tables $(cfi)
  KBUILD_AFLAGS += $(aflags-y) $(cfi)
 +export KBUILD_AFLAGS_DECOMPRESSOR
 +export KBUILD_CFLAGS_DECOMPRESSOR
  
  OBJCOPYFLAGS  := -O binary
  
 -head-y                := arch/s390/kernel/head.o
 -head-y                += arch/s390/kernel/head64.o
 +head-y                := arch/s390/kernel/head64.o
  
  # See arch/s390/Kbuild for content of core part of the kernel
  core-y                += arch/s390/
@@@ -132,7 -123,7 +134,7 @@@ boot               := arch/s390/boo
  syscalls      := arch/s390/kernel/syscalls
  tools         := arch/s390/tools
  
 -all: image bzImage
 +all: bzImage
  
  #KBUILD_IMAGE is necessary for packaging targets like rpm-pkg, deb-pkg...
  KBUILD_IMAGE  := $(boot)/bzImage
  install: vmlinux
        $(Q)$(MAKE) $(build)=$(boot) $@
  
 -image bzImage: vmlinux
 +bzImage: vmlinux
        $(Q)$(MAKE) $(build)=$(boot) $(boot)/$@
  
  zfcpdump:
@@@ -163,7 -154,8 +165,7 @@@ archprepare
  
  # Don't use tabs in echo arguments
  define archhelp
 -  echo  '* image           - Kernel image for IPL ($(boot)/image)'
 -  echo        '* bzImage         - Compressed kernel image for IPL ($(boot)/bzImage)'
 +  echo        '* bzImage         - Kernel image for IPL ($(boot)/bzImage)'
    echo        '  install         - Install kernel using'
    echo        '                    (your) ~/bin/$(INSTALLKERNEL) or'
    echo        '                    (distribution) /sbin/$(INSTALLKERNEL) or'
diff --combined init/main.c
index 38c68b593d0d704f103bec42d37b42ca4742673f,5d42e577643ac67e4cd18e74e8994b1159ca8813..b729e1f22838c0834f99edb8ee33b7a60b56cdd0
@@@ -79,7 -79,7 +79,7 @@@
  #include <linux/pti.h>
  #include <linux/blkdev.h>
  #include <linux/elevator.h>
 -#include <linux/sched_clock.h>
 +#include <linux/sched/clock.h>
  #include <linux/sched/task.h>
  #include <linux/sched/task_stack.h>
  #include <linux/context_tracking.h>
@@@ -561,8 -561,8 +561,8 @@@ asmlinkage __visible void __init start_
        setup_command_line(command_line);
        setup_nr_cpu_ids();
        setup_per_cpu_areas();
 -      boot_cpu_state_init();
        smp_prepare_boot_cpu(); /* arch-specific boot-cpu hooks */
 +      boot_cpu_hotplug_init();
  
        build_all_zonelists(NULL);
        page_alloc_init();
        softirq_init();
        timekeeping_init();
        time_init();
 -      sched_clock_postinit();
        printk_safe_init();
        perf_event_init();
        profile_init();
        call_function_init();
        WARN(!irqs_disabled(), "Interrupts were enabled early\n");
        early_boot_irqs_disabled = false;
        local_irq_enable();
  
                panic("Too many boot %s vars at `%s'", panic_later,
                      panic_param);
  
-       lockdep_info();
+       lockdep_init();
  
        /*
         * Need to run this when irqs are enabled, because it wants
        acpi_early_init();
        if (late_time_init)
                late_time_init();
 +      sched_clock_init();
        calibrate_delay();
        pid_idr_init();
        anon_vma_init();
@@@ -1065,13 -1066,6 +1066,13 @@@ static int __ref kernel_init(void *unus
        jump_label_invalidate_initmem();
        free_initmem();
        mark_readonly();
 +
 +      /*
 +       * Kernel mappings are now finalized - update the userspace page-table
 +       * to finalize PTI.
 +       */
 +      pti_finalize();
 +
        system_state = SYSTEM_RUNNING;
        numa_default_policy();
  
diff --combined kernel/events/uprobes.c
index aed1ba56995440b6640c530f0332f1f4ce28b220,c0418ba52ba87d3d4ab7f72574225de3b3c91eb8..3207a4d26849ec3e31b0bee98a8ed8db111e8cfd
@@@ -299,8 -299,8 +299,8 @@@ static int verify_opcode(struct page *p
   * Called with mm->mmap_sem held for write.
   * Return 0 (success) or a negative errno.
   */
- int uprobe_write_opcode(struct mm_struct *mm, unsigned long vaddr,
-                       uprobe_opcode_t opcode)
+ int uprobe_write_opcode(struct arch_uprobe *auprobe, struct mm_struct *mm,
+                       unsigned long vaddr, uprobe_opcode_t opcode)
  {
        struct page *old_page, *new_page;
        struct vm_area_struct *vma;
@@@ -351,7 -351,7 +351,7 @@@ put_old
   */
  int __weak set_swbp(struct arch_uprobe *auprobe, struct mm_struct *mm, unsigned long vaddr)
  {
-       return uprobe_write_opcode(mm, vaddr, UPROBE_SWBP_INSN);
+       return uprobe_write_opcode(auprobe, mm, vaddr, UPROBE_SWBP_INSN);
  }
  
  /**
  int __weak
  set_orig_insn(struct arch_uprobe *auprobe, struct mm_struct *mm, unsigned long vaddr)
  {
-       return uprobe_write_opcode(mm, vaddr, *(uprobe_opcode_t *)&auprobe->insn);
+       return uprobe_write_opcode(auprobe, mm, vaddr,
+                       *(uprobe_opcode_t *)&auprobe->insn);
  }
  
  static struct uprobe *get_uprobe(struct uprobe *uprobe)
@@@ -840,13 -841,8 +841,8 @@@ register_for_each_vma(struct uprobe *up
        return err;
  }
  
- static int __uprobe_register(struct uprobe *uprobe, struct uprobe_consumer *uc)
- {
-       consumer_add(uprobe, uc);
-       return register_for_each_vma(uprobe, uc);
- }
- static void __uprobe_unregister(struct uprobe *uprobe, struct uprobe_consumer *uc)
+ static void
+ __uprobe_unregister(struct uprobe *uprobe, struct uprobe_consumer *uc)
  {
        int err;
  
  }
  
  /*
-  * uprobe_register - register a probe
 - * uprobe_unregister - unregister a already registered probe.
++ * uprobe_unregister - unregister an already registered probe.
+  * @inode: the file in which the probe has to be removed.
+  * @offset: offset from the start of the file.
+  * @uc: identify which probe if multiple probes are colocated.
+  */
+ void uprobe_unregister(struct inode *inode, loff_t offset, struct uprobe_consumer *uc)
+ {
+       struct uprobe *uprobe;
+       uprobe = find_uprobe(inode, offset);
+       if (WARN_ON(!uprobe))
+               return;
+       down_write(&uprobe->register_rwsem);
+       __uprobe_unregister(uprobe, uc);
+       up_write(&uprobe->register_rwsem);
+       put_uprobe(uprobe);
+ }
+ EXPORT_SYMBOL_GPL(uprobe_unregister);
+ /*
+  * __uprobe_register - register a probe
   * @inode: the file in which the probe has to be placed.
   * @offset: offset from the start of the file.
   * @uc: information on howto handle the probe..
   *
-  * Apart from the access refcount, uprobe_register() takes a creation
+  * Apart from the access refcount, __uprobe_register() takes a creation
   * refcount (thro alloc_uprobe) if and only if this @uprobe is getting
   * inserted into the rbtree (i.e first consumer for a @inode:@offset
   * tuple).  Creation refcount stops uprobe_unregister from freeing the
   * @uprobe even before the register operation is complete. Creation
   * refcount is released when the last @uc for the @uprobe
-  * unregisters. Caller of uprobe_register() is required to keep @inode
+  * unregisters. Caller of __uprobe_register() is required to keep @inode
   * (and the containing mount) referenced.
   *
   * Return errno if it cannot successully install probes
   * else return 0 (success)
   */
- int uprobe_register(struct inode *inode, loff_t offset, struct uprobe_consumer *uc)
+ static int __uprobe_register(struct inode *inode, loff_t offset,
+                            struct uprobe_consumer *uc)
  {
        struct uprobe *uprobe;
        int ret;
        down_write(&uprobe->register_rwsem);
        ret = -EAGAIN;
        if (likely(uprobe_is_active(uprobe))) {
-               ret = __uprobe_register(uprobe, uc);
+               consumer_add(uprobe, uc);
+               ret = register_for_each_vma(uprobe, uc);
                if (ret)
                        __uprobe_unregister(uprobe, uc);
        }
                goto retry;
        return ret;
  }
+ int uprobe_register(struct inode *inode, loff_t offset,
+                   struct uprobe_consumer *uc)
+ {
+       return __uprobe_register(inode, offset, uc);
+ }
  EXPORT_SYMBOL_GPL(uprobe_register);
  
  /*
 - * uprobe_apply - unregister a already registered probe.
 + * uprobe_apply - unregister an already registered probe.
   * @inode: the file in which the probe has to be removed.
   * @offset: offset from the start of the file.
   * @uc: consumer which wants to add more or remove some breakpoints
@@@ -946,27 -971,6 +971,6 @@@ int uprobe_apply(struct inode *inode, l
        return ret;
  }
  
- /*
-  * uprobe_unregister - unregister an already registered probe.
-  * @inode: the file in which the probe has to be removed.
-  * @offset: offset from the start of the file.
-  * @uc: identify which probe if multiple probes are colocated.
-  */
- void uprobe_unregister(struct inode *inode, loff_t offset, struct uprobe_consumer *uc)
- {
-       struct uprobe *uprobe;
-       uprobe = find_uprobe(inode, offset);
-       if (WARN_ON(!uprobe))
-               return;
-       down_write(&uprobe->register_rwsem);
-       __uprobe_unregister(uprobe, uc);
-       up_write(&uprobe->register_rwsem);
-       put_uprobe(uprobe);
- }
- EXPORT_SYMBOL_GPL(uprobe_unregister);
  static int unapply_uprobe(struct uprobe *uprobe, struct mm_struct *mm)
  {
        struct vm_area_struct *vma;
@@@ -1403,7 -1407,7 +1407,7 @@@ static struct return_instance *free_ret
  
  /*
   * Called with no locks held.
 - * Called in context of a exiting or a exec-ing thread.
 + * Called in context of an exiting or an exec-ing thread.
   */
  void uprobe_free_utask(struct task_struct *t)
  {
diff --combined kernel/sched/core.c
index 454adf9f81802007ef7165a5b1f79898bc537451,5de1a4343424064d327af3a94ea45dbe3e26e6d1..c89302ddf80794db7897c4a95a0e50531aed5e5c
@@@ -17,8 -17,6 +17,8 @@@
  #include "../workqueue_internal.h"
  #include "../smpboot.h"
  
 +#include "pelt.h"
 +
  #define CREATE_TRACE_POINTS
  #include <trace/events/sched.h>
  
@@@ -46,6 -44,14 +46,6 @@@ const_debug unsigned int sysctl_sched_f
   */
  const_debug unsigned int sysctl_sched_nr_migrate = 32;
  
 -/*
 - * period over which we average the RT time consumption, measured
 - * in ms.
 - *
 - * default: 1s
 - */
 -const_debug unsigned int sysctl_sched_time_avg = MSEC_PER_SEC;
 -
  /*
   * period over which we measure -rt task CPU usage in us.
   * default: 1s
@@@ -177,9 -183,9 +177,9 @@@ static void update_rq_clock_task(struc
  
        rq->clock_task += delta;
  
 -#if defined(CONFIG_IRQ_TIME_ACCOUNTING) || defined(CONFIG_PARAVIRT_TIME_ACCOUNTING)
 +#ifdef HAVE_SCHED_AVG_IRQ
        if ((irq_delta + steal) && sched_feat(NONTASK_CAPACITY))
 -              sched_rt_avg_update(rq, irq_delta + steal);
 +              update_irq_load_avg(rq, irq_delta + steal);
  #endif
  }
  
@@@ -406,8 -412,8 +406,8 @@@ void wake_q_add(struct wake_q_head *hea
         * its already queued (either by us or someone else) and will get the
         * wakeup due to that.
         *
 -       * This cmpxchg() implies a full barrier, which pairs with the write
 -       * barrier implied by the wakeup in wake_up_q().
 +       * This cmpxchg() executes a full barrier, which pairs with the full
 +       * barrier executed by the wakeup in wake_up_q().
         */
        if (cmpxchg(&node->next, NULL, WAKE_Q_TAIL))
                return;
@@@ -435,8 -441,8 +435,8 @@@ void wake_up_q(struct wake_q_head *head
                task->wake_q.next = NULL;
  
                /*
 -               * wake_up_process() implies a wmb() to pair with the queueing
 -               * in wake_q_add() so as not to miss wakeups.
 +               * wake_up_process() executes a full barrier, which pairs with
 +               * the queueing in wake_q_add() so as not to miss wakeups.
                 */
                wake_up_process(task);
                put_task_struct(task);
@@@ -643,6 -649,23 +643,6 @@@ bool sched_can_stop_tick(struct rq *rq
        return true;
  }
  #endif /* CONFIG_NO_HZ_FULL */
 -
 -void sched_avg_update(struct rq *rq)
 -{
 -      s64 period = sched_avg_period();
 -
 -      while ((s64)(rq_clock(rq) - rq->age_stamp) > period) {
 -              /*
 -               * Inline assembly required to prevent the compiler
 -               * optimising this loop into a divmod call.
 -               * See __iter_div_u64_rem() for another example of this.
 -               */
 -              asm("" : "+rm" (rq->age_stamp));
 -              rq->age_stamp += period;
 -              rq->rt_avg /= 2;
 -      }
 -}
 -
  #endif /* CONFIG_SMP */
  
  #if defined(CONFIG_RT_GROUP_SCHED) || (defined(CONFIG_FAIR_GROUP_SCHED) && \
@@@ -1176,7 -1199,6 +1176,7 @@@ void set_task_cpu(struct task_struct *p
        __set_task_cpu(p, new_cpu);
  }
  
 +#ifdef CONFIG_NUMA_BALANCING
  static void __migrate_swap_task(struct task_struct *p, int cpu)
  {
        if (task_on_rq_queued(p)) {
@@@ -1258,17 -1280,16 +1258,17 @@@ unlock
  /*
   * Cross migrate two tasks
   */
 -int migrate_swap(struct task_struct *cur, struct task_struct *p)
 +int migrate_swap(struct task_struct *cur, struct task_struct *p,
 +              int target_cpu, int curr_cpu)
  {
        struct migration_swap_arg arg;
        int ret = -EINVAL;
  
        arg = (struct migration_swap_arg){
                .src_task = cur,
 -              .src_cpu = task_cpu(cur),
 +              .src_cpu = curr_cpu,
                .dst_task = p,
 -              .dst_cpu = task_cpu(p),
 +              .dst_cpu = target_cpu,
        };
  
        if (arg.src_cpu == arg.dst_cpu)
  out:
        return ret;
  }
 +#endif /* CONFIG_NUMA_BALANCING */
  
  /*
   * wait_task_inactive - wait for a thread to unschedule.
@@@ -1859,7 -1879,8 +1859,7 @@@ static void ttwu_queue(struct task_stru
   *     rq(c1)->lock (if not at the same time, then in that order).
   *  C) LOCK of the rq(c1)->lock scheduling in task
   *
 - * Transitivity guarantees that B happens after A and C after B.
 - * Note: we only require RCpc transitivity.
 + * Release/acquire chaining guarantees that B happens after A and C after B.
   * Note: the CPU doing B need not be c0 or c1
   *
   * Example:
   *   UNLOCK rq(0)->lock
   *
   *
 - * However; for wakeups there is a second guarantee we must provide, namely we
 - * must observe the state that lead to our wakeup. That is, not only must our
 - * task observe its own prior state, it must also observe the stores prior to
 - * its wakeup.
 - *
 - * This means that any means of doing remote wakeups must order the CPU doing
 - * the wakeup against the CPU the task is going to end up running on. This,
 - * however, is already required for the regular Program-Order guarantee above,
 - * since the waking CPU is the one issueing the ACQUIRE (smp_cond_load_acquire).
 - *
 + * However, for wakeups there is a second guarantee we must provide, namely we
 + * must ensure that CONDITION=1 done by the caller can not be reordered with
 + * accesses to the task state; see try_to_wake_up() and set_current_state().
   */
  
  /**
   * Atomic against schedule() which would dequeue a task, also see
   * set_current_state().
   *
 + * This function executes a full memory barrier before accessing the task
 + * state; see set_current_state().
 + *
   * Return: %true if @p->state changes (an actual wakeup was done),
   *       %false otherwise.
   */
@@@ -1973,20 -1998,21 +1973,20 @@@ try_to_wake_up(struct task_struct *p, u
         * be possible to, falsely, observe p->on_rq == 0 and get stuck
         * in smp_cond_load_acquire() below.
         *
 -       * sched_ttwu_pending()                 try_to_wake_up()
 -       *   [S] p->on_rq = 1;                  [L] P->state
 -       *       UNLOCK rq->lock  -----.
 -       *                              \
 -       *                               +---   RMB
 -       * schedule()                   /
 -       *       LOCK rq->lock    -----'
 -       *       UNLOCK rq->lock
 +       * sched_ttwu_pending()                 try_to_wake_up()
 +       *   STORE p->on_rq = 1                   LOAD p->state
 +       *   UNLOCK rq->lock
 +       *
 +       * __schedule() (switch to task 'p')
 +       *   LOCK rq->lock                        smp_rmb();
 +       *   smp_mb__after_spinlock();
 +       *   UNLOCK rq->lock
         *
         * [task p]
 -       *   [S] p->state = UNINTERRUPTIBLE     [L] p->on_rq
 +       *   STORE p->state = UNINTERRUPTIBLE     LOAD p->on_rq
         *
 -       * Pairs with the UNLOCK+LOCK on rq->lock from the
 -       * last wakeup of our task and the schedule that got our task
 -       * current.
 +       * Pairs with the LOCK+smp_mb__after_spinlock() on rq->lock in
 +       * __schedule().  See the comment for smp_mb__after_spinlock().
         */
        smp_rmb();
        if (p->on_rq && ttwu_remote(p, wake_flags))
         * One must be running (->on_cpu == 1) in order to remove oneself
         * from the runqueue.
         *
 -       *  [S] ->on_cpu = 1;   [L] ->on_rq
 -       *      UNLOCK rq->lock
 -       *                      RMB
 -       *      LOCK   rq->lock
 -       *  [S] ->on_rq = 0;    [L] ->on_cpu
 +       * __schedule() (switch to task 'p')    try_to_wake_up()
 +       *   STORE p->on_cpu = 1                  LOAD p->on_rq
 +       *   UNLOCK rq->lock
 +       *
 +       * __schedule() (put 'p' to sleep)
 +       *   LOCK rq->lock                        smp_rmb();
 +       *   smp_mb__after_spinlock();
 +       *   STORE p->on_rq = 0                   LOAD p->on_cpu
         *
 -       * Pairs with the full barrier implied in the UNLOCK+LOCK on rq->lock
 -       * from the consecutive calls to schedule(); the first switching to our
 -       * task, the second putting it to sleep.
 +       * Pairs with the LOCK+smp_mb__after_spinlock() on rq->lock in
 +       * __schedule().  See the comment for smp_mb__after_spinlock().
         */
        smp_rmb();
  
@@@ -2116,7 -2140,8 +2116,7 @@@ out
   *
   * Return: 1 if the process was woken up, 0 if it was already running.
   *
 - * It may be assumed that this function implies a write memory barrier before
 - * changing the task state if and only if any tasks are woken up.
 + * This function executes a full memory barrier before accessing the task state.
   */
  int wake_up_process(struct task_struct *p)
  {
@@@ -2292,6 -2317,7 +2292,6 @@@ static inline void init_schedstats(void
  int sched_fork(unsigned long clone_flags, struct task_struct *p)
  {
        unsigned long flags;
 -      int cpu = get_cpu();
  
        __sched_fork(clone_flags, p);
        /*
                p->sched_reset_on_fork = 0;
        }
  
 -      if (dl_prio(p->prio)) {
 -              put_cpu();
 +      if (dl_prio(p->prio))
                return -EAGAIN;
 -      } else if (rt_prio(p->prio)) {
 +      else if (rt_prio(p->prio))
                p->sched_class = &rt_sched_class;
 -      } else {
 +      else
                p->sched_class = &fair_sched_class;
 -      }
  
        init_entity_runnable_average(&p->se);
  
         * We're setting the CPU for the first time, we don't migrate,
         * so use __set_task_cpu().
         */
 -      __set_task_cpu(p, cpu);
 +      __set_task_cpu(p, smp_processor_id());
        if (p->sched_class->task_fork)
                p->sched_class->task_fork(p);
        raw_spin_unlock_irqrestore(&p->pi_lock, flags);
        plist_node_init(&p->pushable_tasks, MAX_PRIO);
        RB_CLEAR_NODE(&p->pushable_dl_tasks);
  #endif
 -
 -      put_cpu();
        return 0;
  }
  
@@@ -3159,7 -3189,7 +3159,7 @@@ static inline void sched_tick_stop(int 
  #endif
  
  #if defined(CONFIG_PREEMPT) && (defined(CONFIG_DEBUG_PREEMPT) || \
-                               defined(CONFIG_PREEMPT_TRACER))
+                               defined(CONFIG_TRACE_PREEMPT_TOGGLE))
  /*
   * If the value passed in is equal to the current preempt count
   * then we just disabled preemption. Start timing the latency.
@@@ -5684,6 -5714,13 +5684,6 @@@ void set_rq_offline(struct rq *rq
        }
  }
  
 -static void set_cpu_rq_start_time(unsigned int cpu)
 -{
 -      struct rq *rq = cpu_rq(cpu);
 -
 -      rq->age_stamp = sched_clock_cpu(cpu);
 -}
 -
  /*
   * used to mark begin/end of suspend/resume:
   */
@@@ -5737,18 -5774,6 +5737,18 @@@ int sched_cpu_activate(unsigned int cpu
        struct rq *rq = cpu_rq(cpu);
        struct rq_flags rf;
  
 +#ifdef CONFIG_SCHED_SMT
 +      /*
 +       * The sched_smt_present static key needs to be evaluated on every
 +       * hotplug event because at boot time SMT might be disabled when
 +       * the number of booted CPUs is limited.
 +       *
 +       * If then later a sibling gets hotplugged, then the key would stay
 +       * off and SMT scheduling would never be functional.
 +       */
 +      if (cpumask_weight(cpu_smt_mask(cpu)) > 1)
 +              static_branch_enable_cpuslocked(&sched_smt_present);
 +#endif
        set_cpu_active(cpu, true);
  
        if (sched_smp_initialized) {
@@@ -5813,6 -5838,7 +5813,6 @@@ static void sched_rq_cpu_starting(unsig
  
  int sched_cpu_starting(unsigned int cpu)
  {
 -      set_cpu_rq_start_time(cpu);
        sched_rq_cpu_starting(cpu);
        sched_tick_start(cpu);
        return 0;
@@@ -5845,6 -5871,22 +5845,6 @@@ int sched_cpu_dying(unsigned int cpu
  }
  #endif
  
 -#ifdef CONFIG_SCHED_SMT
 -DEFINE_STATIC_KEY_FALSE(sched_smt_present);
 -
 -static void sched_init_smt(void)
 -{
 -      /*
 -       * We've enumerated all CPUs and will assume that if any CPU
 -       * has SMT siblings, CPU0 will too.
 -       */
 -      if (cpumask_weight(cpu_smt_mask(0)) > 1)
 -              static_branch_enable(&sched_smt_present);
 -}
 -#else
 -static inline void sched_init_smt(void) { }
 -#endif
 -
  void __init sched_init_smp(void)
  {
        sched_init_numa();
        init_sched_rt_class();
        init_sched_dl_class();
  
 -      sched_init_smt();
 -
        sched_smp_initialized = true;
  }
  
@@@ -5910,6 -5954,7 +5910,6 @@@ void __init sched_init(void
        int i, j;
        unsigned long alloc_size = 0, ptr;
  
 -      sched_clock_init();
        wait_bit_init();
  
  #ifdef CONFIG_FAIR_GROUP_SCHED
  
  #ifdef CONFIG_SMP
        idle_thread_set_boot_cpu();
 -      set_cpu_rq_start_time(smp_processor_id());
  #endif
        init_sched_fair_class();
  
@@@ -6739,16 -6785,6 +6739,16 @@@ static int cpu_cfs_stat_show(struct seq
        seq_printf(sf, "nr_throttled %d\n", cfs_b->nr_throttled);
        seq_printf(sf, "throttled_time %llu\n", cfs_b->throttled_time);
  
 +      if (schedstat_enabled() && tg != &root_task_group) {
 +              u64 ws = 0;
 +              int i;
 +
 +              for_each_possible_cpu(i)
 +                      ws += schedstat_val(tg->se[i]->statistics.wait_sum);
 +
 +              seq_printf(sf, "wait_sum %llu\n", ws);
 +      }
 +
        return 0;
  }
  #endif /* CONFIG_CFS_BANDWIDTH */
diff --combined kernel/trace/Kconfig
index 9a27f146fa1c4b897b5fbe3a47fee40d81a50cd9,fd6754b88f87cfca499ec1dc7549cd8f2449f738..c042a455afc6a109a45ae5b58e360d0dec67bcc2
@@@ -47,6 -47,11 +47,11 @@@ config HAVE_FENTR
        help
          Arch supports the gcc options -pg with -mfentry
  
+ config HAVE_NOP_MCOUNT
+       bool
+       help
+         Arch supports the gcc options -pg with -mrecord-mcount and -nop-mcount
  config HAVE_C_RECORDMCOUNT
        bool
        help
@@@ -82,6 -87,15 +87,15 @@@ config RING_BUFFER_ALLOW_SWA
         Allow the use of ring_buffer_swap_cpu.
         Adds a very slight overhead to tracing when enabled.
  
+ config PREEMPTIRQ_TRACEPOINTS
+       bool
+       depends on TRACE_PREEMPT_TOGGLE || TRACE_IRQFLAGS
+       select TRACING
+       default y
+       help
+         Create preempt/irq toggle tracepoints if needed, so that other parts
+         of the kernel can use them to generate or add hooks to them.
  # All tracer options should select GENERIC_TRACER. For those options that are
  # enabled by all tracers (context switch and event tracer) they select TRACING.
  # This allows those options to appear when no other tracer is selected. But the
@@@ -155,18 -169,20 +169,20 @@@ config FUNCTION_GRAPH_TRACE
          the return value. This is done by setting the current return
          address on the current task structure into a stack of calls.
  
+ config TRACE_PREEMPT_TOGGLE
+       bool
+       help
+         Enables hooks which will be called when preemption is first disabled,
+         and last enabled.
  
  config PREEMPTIRQ_EVENTS
        bool "Enable trace events for preempt and irq disable/enable"
        select TRACE_IRQFLAGS
-       depends on DEBUG_PREEMPT || !PROVE_LOCKING
-       depends on TRACING
+       select TRACE_PREEMPT_TOGGLE if PREEMPT
+       select GENERIC_TRACER
        default n
        help
          Enable tracing of disable and enable events for preemption and irqs.
-         For tracing preempt disable/enable events, DEBUG_PREEMPT must be
-         enabled. For tracing irq disable/enable events, PROVE_LOCKING must
-         be disabled.
  
  config IRQSOFF_TRACER
        bool "Interrupts-off Latency Tracer"
@@@ -203,6 -219,7 +219,7 @@@ config PREEMPT_TRACE
        select RING_BUFFER_ALLOW_SWAP
        select TRACER_SNAPSHOT
        select TRACER_SNAPSHOT_PER_CPU_SWAP
+       select TRACE_PREEMPT_TOGGLE
        help
          This option measures the time spent in preemption-off critical
          sections, with microsecond accuracy.
@@@ -456,6 -473,26 +473,26 @@@ config KPROBE_EVENT
          This option is also required by perf-probe subcommand of perf tools.
          If you want to use perf tools, this option is strongly recommended.
  
+ config KPROBE_EVENTS_ON_NOTRACE
+       bool "Do NOT protect notrace function from kprobe events"
+       depends on KPROBE_EVENTS
+       depends on KPROBES_ON_FTRACE
+       default n
+       help
+         This is only for the developers who want to debug ftrace itself
+         using kprobe events.
+         If kprobes can use ftrace instead of breakpoint, ftrace related
+         functions are protected from kprobe-events to prevent an infinit
+         recursion or any unexpected execution path which leads to a kernel
+         crash.
+         This option disables such protection and allows you to put kprobe
+         events on ftrace functions for debugging ftrace by itself.
+         Note that this might let you shoot yourself in the foot.
+         If unsure, say N.
  config UPROBE_EVENTS
        bool "Enable uprobes-based dynamic events"
        depends on ARCH_SUPPORTS_UPROBES
@@@ -521,7 -558,7 +558,7 @@@ config FUNCTION_PROFILE
          in debugfs called function_profile_enabled which defaults to zero.
          When a 1 is echoed into this file profiling begins, and when a
          zero is entered, profiling stops. A "functions" file is created in
 -        the trace_stats directory; this file shows the list of functions that
 +        the trace_stat directory; this file shows the list of functions that
          have been hit and their counters.
  
          If in doubt, say N.
@@@ -605,7 -642,7 +642,7 @@@ config HIST_TRIGGER
          Inter-event tracing of quantities such as latencies is also
          supported using hist triggers under this option.
  
 -        See Documentation/trace/histogram.txt.
 +        See Documentation/trace/histogram.rst.
          If in doubt, say N.
  
  config MMIOTRACE_TEST
@@@ -687,6 -724,21 +724,21 @@@ config RING_BUFFER_STARTUP_TES
  
         If unsure, say N
  
+ config PREEMPTIRQ_DELAY_TEST
+       tristate "Preempt / IRQ disable delay thread to test latency tracers"
+       depends on m
+       help
+         Select this option to build a test module that can help test latency
+         tracers by executing a preempt or irq disable section with a user
+         configurable delay. The module busy waits for the duration of the
+         critical section.
+         For example, the following invocation forces a one-time irq-disabled
+         critical section for 500us:
+         modprobe preemptirq_delay_test test_mode=irq delay=500000
+         If unsure, say N
  config TRACE_EVAL_MAP_FILE
         bool "Show eval mappings for trace events"
         depends on TRACING
diff --combined kernel/trace/blktrace.c
index b951aa1fac6177cbed5e7a8d19de6a938bc2c241,b82e546083e143c93fa8f832f79322b9e81078ae..2a24a59e99c569bebca133151fb66a4922dabd86
@@@ -1,19 -1,7 +1,7 @@@
+ // SPDX-License-Identifier: GPL-2.0
  /*
   * Copyright (C) 2006 Jens Axboe <axboe@kernel.dk>
   *
-  * This program is free software; you can redistribute it and/or modify
-  * it under the terms of the GNU General Public License version 2 as
-  * published by the Free Software Foundation.
-  *
-  * This program is distributed in the hope that it will be useful,
-  * but WITHOUT ANY WARRANTY; without even the implied warranty of
-  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-  * GNU General Public License for more details.
-  *
-  * You should have received a copy of the GNU General Public License
-  * along with this program; if not, write to the Free Software
-  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
-  *
   */
  #include <linux/kernel.h>
  #include <linux/blkdev.h>
@@@ -494,9 -482,6 +482,9 @@@ static int do_blk_trace_setup(struct re
        if (!buts->buf_size || !buts->buf_nr)
                return -EINVAL;
  
 +      if (!blk_debugfs_root)
 +              return -ENOENT;
 +
        strncpy(buts->name, name, BLKTRACE_BDEV_SIZE);
        buts->name[BLKTRACE_BDEV_SIZE - 1] = '\0';
  
  
        ret = -ENOENT;
  
 -      if (!blk_debugfs_root)
 -              goto err;
 -
        dir = debugfs_lookup(buts->name, blk_debugfs_root);
        if (!dir)
                bt->dir = dir = debugfs_create_dir(buts->name, blk_debugfs_root);
diff --combined kernel/trace/trace.c
index 176debd3481b330b17b4a83e1bfa511887441ca2,4ecd8950b513b2c2db59712eff2909023281ebc3..bf6f1d70484dc02a449fa71b73b753649b698715
@@@ -1,3 -1,4 +1,4 @@@
+ // SPDX-License-Identifier: GPL-2.0
  /*
   * ring buffer based function tracer
   *
@@@ -1087,7 -1088,7 +1088,7 @@@ void disable_trace_on_warning(void
   *
   * Shows real state of the ring buffer if it is enabled or not.
   */
int tracer_tracing_is_on(struct trace_array *tr)
bool tracer_tracing_is_on(struct trace_array *tr)
  {
        if (tr->trace_buffer.buffer)
                return ring_buffer_record_is_on(tr->trace_buffer.buffer);
@@@ -7628,7 -7629,9 +7629,9 @@@ rb_simple_write(struct file *filp, cons
  
        if (buffer) {
                mutex_lock(&trace_types_lock);
-               if (val) {
+               if (!!val == tracer_tracing_is_on(tr)) {
+                       val = 0; /* do nothing */
+               } else if (val) {
                        tracer_tracing_on(tr);
                        if (tr->current_trace->start)
                                tr->current_trace->start(tr);
@@@ -8288,7 -8291,6 +8291,7 @@@ void ftrace_dump(enum ftrace_dump_mode 
        tracing_off();
  
        local_irq_save(flags);
 +      printk_nmi_direct_enter();
  
        /* Simulate the iterator */
        trace_init_global_iter(&iter);
        for_each_tracing_cpu(cpu) {
                atomic_dec(&per_cpu_ptr(iter.trace_buffer->data, cpu)->disabled);
        }
 -      atomic_dec(&dump_running);
 +      atomic_dec(&dump_running);
 +      printk_nmi_direct_exit();
        local_irq_restore(flags);
  }
  EXPORT_SYMBOL_GPL(ftrace_dump);
index e9d99463e5dffe82bcc42f0ea75392d0528ce2fe,65a4157af851a46dd40793e545ad5bca0259c3b3..2bfb2bbeb3d22cb6f2aa475902599eacb8a725a8
@@@ -1,20 -1,9 +1,9 @@@
+ // SPDX-License-Identifier: GPL-2.0
  /*
   * Kprobes-based tracing events
   *
   * Created by Masami Hiramatsu <mhiramat@redhat.com>
   *
-  * This program is free software; you can redistribute it and/or modify
-  * it under the terms of the GNU General Public License version 2 as
-  * published by the Free Software Foundation.
-  *
-  * This program is distributed in the hope that it will be useful,
-  * but WITHOUT ANY WARRANTY; without even the implied warranty of
-  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-  * GNU General Public License for more details.
-  *
-  * You should have received a copy of the GNU General Public License
-  * along with this program; if not, write to the Free Software
-  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
   */
  #define pr_fmt(fmt)   "trace_kprobe: " fmt
  
@@@ -23,6 -12,7 +12,7 @@@
  #include <linux/rculist.h>
  #include <linux/error-injection.h>
  
+ #include "trace_kprobe_selftest.h"
  #include "trace_probe.h"
  
  #define KPROBE_EVENT_SYSTEM "kprobes"
@@@ -87,6 -77,23 +77,23 @@@ static nokprobe_inline unsigned long tr
        return nhit;
  }
  
+ /* Return 0 if it fails to find the symbol address */
+ static nokprobe_inline
+ unsigned long trace_kprobe_address(struct trace_kprobe *tk)
+ {
+       unsigned long addr;
+       if (tk->symbol) {
+               addr = (unsigned long)
+                       kallsyms_lookup_name(trace_kprobe_symbol(tk));
+               if (addr)
+                       addr += tk->rp.kp.offset;
+       } else {
+               addr = (unsigned long)tk->rp.kp.addr;
+       }
+       return addr;
+ }
  bool trace_kprobe_on_func_entry(struct trace_event_call *call)
  {
        struct trace_kprobe *tk = (struct trace_kprobe *)call->data;
  bool trace_kprobe_error_injectable(struct trace_event_call *call)
  {
        struct trace_kprobe *tk = (struct trace_kprobe *)call->data;
-       unsigned long addr;
  
-       if (tk->symbol) {
-               addr = (unsigned long)
-                       kallsyms_lookup_name(trace_kprobe_symbol(tk));
-               addr += tk->rp.kp.offset;
-       } else {
-               addr = (unsigned long)tk->rp.kp.addr;
-       }
-       return within_error_injection_list(addr);
+       return within_error_injection_list(trace_kprobe_address(tk));
  }
  
  static int register_kprobe_event(struct trace_kprobe *tk);
@@@ -393,6 -392,20 +392,20 @@@ static struct trace_kprobe *find_trace_
        return NULL;
  }
  
+ static inline int __enable_trace_kprobe(struct trace_kprobe *tk)
+ {
+       int ret = 0;
+       if (trace_probe_is_registered(&tk->tp) && !trace_kprobe_has_gone(tk)) {
+               if (trace_kprobe_is_return(tk))
+                       ret = enable_kretprobe(&tk->rp);
+               else
+                       ret = enable_kprobe(&tk->rp.kp);
+       }
+       return ret;
+ }
  /*
   * Enable trace_probe
   * if the file is NULL, enable "perf" handler, or enable "trace" handler.
  static int
  enable_trace_kprobe(struct trace_kprobe *tk, struct trace_event_file *file)
  {
-       struct event_file_link *link = NULL;
+       struct event_file_link *link;
        int ret = 0;
  
        if (file) {
                list_add_tail_rcu(&link->list, &tk->tp.files);
  
                tk->tp.flags |= TP_FLAG_TRACE;
-       } else
-               tk->tp.flags |= TP_FLAG_PROFILE;
-       if (trace_probe_is_registered(&tk->tp) && !trace_kprobe_has_gone(tk)) {
-               if (trace_kprobe_is_return(tk))
-                       ret = enable_kretprobe(&tk->rp);
-               else
-                       ret = enable_kprobe(&tk->rp.kp);
-       }
-       if (ret) {
-               if (file) {
-                       /* Notice the if is true on not WARN() */
-                       if (!WARN_ON_ONCE(!link))
-                               list_del_rcu(&link->list);
+               ret = __enable_trace_kprobe(tk);
+               if (ret) {
+                       list_del_rcu(&link->list);
                        kfree(link);
                        tk->tp.flags &= ~TP_FLAG_TRACE;
-               } else {
-                       tk->tp.flags &= ~TP_FLAG_PROFILE;
                }
+       } else {
+               tk->tp.flags |= TP_FLAG_PROFILE;
+               ret = __enable_trace_kprobe(tk);
+               if (ret)
+                       tk->tp.flags &= ~TP_FLAG_PROFILE;
        }
   out:
        return ret;
@@@ -498,6 -503,22 +503,22 @@@ disable_trace_kprobe(struct trace_kprob
        return ret;
  }
  
+ #if defined(CONFIG_KPROBES_ON_FTRACE) && \
+       !defined(CONFIG_KPROBE_EVENTS_ON_NOTRACE)
+ static bool within_notrace_func(struct trace_kprobe *tk)
+ {
+       unsigned long offset, size, addr;
+       addr = trace_kprobe_address(tk);
+       if (!addr || !kallsyms_lookup_size_offset(addr, &size, &offset))
+               return false;
+       return !ftrace_location_range(addr - offset, addr - offset + size);
+ }
+ #else
+ #define within_notrace_func(tk)       (false)
+ #endif
  /* Internal register function - just handle k*probes and flags */
  static int __register_trace_kprobe(struct trace_kprobe *tk)
  {
        if (trace_probe_is_registered(&tk->tp))
                return -EINVAL;
  
+       if (within_notrace_func(tk)) {
+               pr_warn("Could not probe notrace function %s\n",
+                       trace_kprobe_symbol(tk));
+               return -EINVAL;
+       }
        for (i = 0; i < tk->tp.nr_args; i++)
                traceprobe_update_arg(&tk->tp.args[i]);
  
@@@ -1228,11 -1255,16 +1255,11 @@@ kprobe_perf_func(struct trace_kprobe *t
  
                /*
                 * We need to check and see if we modified the pc of the
 -               * pt_regs, and if so clear the kprobe and return 1 so that we
 -               * don't do the single stepping.
 -               * The ftrace kprobe handler leaves it up to us to re-enable
 -               * preemption here before returning if we've modified the ip.
 +               * pt_regs, and if so return 1 so that we don't do the
 +               * single stepping.
                 */
 -              if (orig_ip != instruction_pointer(regs)) {
 -                      reset_current_kprobe();
 -                      preempt_enable_no_resched();
 +              if (orig_ip != instruction_pointer(regs))
                        return 1;
 -              }
                if (!ret)
                        return 0;
        }
@@@ -1547,17 -1579,6 +1574,6 @@@ fs_initcall(init_kprobe_trace)
  
  
  #ifdef CONFIG_FTRACE_STARTUP_TEST
- /*
-  * The "__used" keeps gcc from removing the function symbol
-  * from the kallsyms table. 'noinline' makes sure that there
-  * isn't an inlined version used by the test method below
-  */
- static __used __init noinline int
- kprobe_trace_selftest_target(int a1, int a2, int a3, int a4, int a5, int a6)
- {
-       return a1 + a2 + a3 + a4 + a5 + a6;
- }
  static __init struct trace_event_file *
  find_trace_probe_file(struct trace_kprobe *tk, struct trace_array *tr)
  {
diff --combined scripts/Makefile.build
index 1adaac4e10d8f78ae571ba115729d51727db8fd1,42ecb8cf766636852202c4894b42546095e2d6d9..93b8e24b0e15e5049f0edeb9d8a47e7fa72345b3
@@@ -53,6 -53,13 +53,6 @@@ endi
  
  include scripts/Makefile.lib
  
 -ifdef host-progs
 -ifneq ($(hostprogs-y),$(host-progs))
 -$(warning kbuild: $(obj)/Makefile - Usage of host-progs is deprecated. Please replace with hostprogs-y!)
 -hostprogs-y += $(host-progs)
 -endif
 -endif
 -
  # Do not include host rules unless needed
  ifneq ($(hostprogs-y)$(hostprogs-m)$(hostlibs-y)$(hostlibs-m)$(hostcxxlibs-y)$(hostcxxlibs-m),)
  include scripts/Makefile.host
@@@ -199,11 -206,8 +199,8 @@@ cmd_modversions_c =                                                               
  endif
  
  ifdef CONFIG_FTRACE_MCOUNT_RECORD
- # gcc 5 supports generating the mcount tables directly
- ifneq ($(call cc-option,-mrecord-mcount,y),y)
- KBUILD_CFLAGS += -mrecord-mcount
- else
- # else do it all manually
+ ifndef CC_USING_RECORD_MCOUNT
+ # compiler will not generate __mcount_loc use recordmcount or recordmcount.pl
  ifdef BUILD_C_RECORDMCOUNT
  ifeq ("$(origin RECORDMCOUNT_WARN)", "command line")
    RECORDMCOUNT_FLAGS = -w
@@@ -232,7 -236,7 +229,7 @@@ cmd_record_mcount =                                                
             "$(CC_FLAGS_FTRACE)" ]; then                       \
                $(sub_cmd_record_mcount)                        \
        fi;
- endif # -record-mcount
+ endif # CC_USING_RECORD_MCOUNT
  endif # CONFIG_FTRACE_MCOUNT_RECORD
  
  ifdef CONFIG_STACK_VALIDATION