Merge tag 'trace-v5.17-3' of git://git.kernel.org/pub/scm/linux/kernel/git/rostedt...
authorLinus Torvalds <torvalds@linux-foundation.org>
Sun, 23 Jan 2022 06:07:02 +0000 (08:07 +0200)
committerLinus Torvalds <torvalds@linux-foundation.org>
Sun, 23 Jan 2022 06:07:02 +0000 (08:07 +0200)
Pull ftrace fix from Steven Rostedt:
 "Fix s390 breakage from sorting mcount tables.

  The latest merge of the tracing tree sorts the mcount table at build
  time. But s390 appears to do things differently (like always) and
  replaces the sorted table back to the original unsorted one. As the
  ftrace algorithm depends on it being sorted, bad things happen when it
  is not, and s390 experienced those bad things.

  Add a new config to tell the boot if the mcount table is sorted or
  not, and allow s390 to opt out of it"

* tag 'trace-v5.17-3' of git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-trace:
  ftrace: Fix assuming build time sort works for s390

1  2 
kernel/trace/ftrace.c

diff --combined kernel/trace/ftrace.c
index 6163b6f762f73c939064c219cd0b1bcf49f484ef,b01e1fa62193d4eaf70ac39f532e9858aef715cb..f9feb197b2daaf348622665924795a3ae88e4fda
@@@ -5217,7 -5217,6 +5217,7 @@@ int unregister_ftrace_direct(unsigned l
  {
        struct ftrace_direct_func *direct;
        struct ftrace_func_entry *entry;
 +      struct ftrace_hash *hash;
        int ret = -ENODEV;
  
        mutex_lock(&direct_mutex);
        if (!entry)
                goto out_unlock;
  
 -      if (direct_functions->count == 1)
 +      hash = direct_ops.func_hash->filter_hash;
 +      if (hash->count == 1)
                unregister_ftrace_function(&direct_ops);
  
        ret = ftrace_set_filter_ip(&direct_ops, ip, 1, 0);
@@@ -5542,10 -5540,6 +5542,10 @@@ int unregister_ftrace_direct_multi(stru
        err = unregister_ftrace_function(ops);
        remove_direct_functions_hash(hash, addr);
        mutex_unlock(&direct_mutex);
 +
 +      /* cleanup for possible another register call */
 +      ops->func = NULL;
 +      ops->trampoline = 0;
        return err;
  }
  EXPORT_SYMBOL_GPL(unregister_ftrace_direct_multi);
@@@ -6435,10 -6429,10 +6435,10 @@@ static int ftrace_process_locs(struct m
  
        /*
         * Sorting mcount in vmlinux at build time depend on
-        * CONFIG_BUILDTIME_TABLE_SORT, while mcount loc in
+        * CONFIG_BUILDTIME_MCOUNT_SORT, while mcount loc in
         * modules can not be sorted at build time.
         */
-       if (!IS_ENABLED(CONFIG_BUILDTIME_TABLE_SORT) || mod) {
+       if (!IS_ENABLED(CONFIG_BUILDTIME_MCOUNT_SORT) || mod) {
                sort(start, count, sizeof(*start),
                     ftrace_cmp_ips, NULL);
        } else {