1. 09 Dec, 2018 19 commits
  2. 30 Nov, 2018 6 commits
  3. 28 Nov, 2018 15 commits
    • Pavankumar Kondeti's avatar
      sched, trace: Fix prev_state output in sched_switch tracepoint · 3054426d
      Pavankumar Kondeti authored
      commit 3f5fe9fe ("sched/debug: Fix task state recording/printout")
      tried to fix the problem introduced by a previous commit efb40f58
      ("sched/tracing: Fix trace_sched_switch task-state printing"). However
      the prev_state output in sched_switch is still broken.
      
      task_state_index() uses fls() which considers the LSB as 1. Left
      shifting 1 by this value gives an incorrect mapping to the task state.
      Fix this by decrementing the value returned by __get_task_state()
      before shifting.
      
      Link: http://lkml.kernel.org/r/1540882473-1103-1-git-send-email-pkondeti@codeaurora.org
      
      Cc: stable@vger.kernel.org
      Fixes: 3f5fe9fe ("sched/debug: Fix task state recording/printout")
      Signed-off-by: default avatarPavankumar Kondeti <pkondeti@codeaurora.org>
      Signed-off-by: default avatarSteven Rostedt (VMware) <rostedt@goodmis.org>
      3054426d
    • Steven Rostedt (VMware)'s avatar
      function_graph: Have profiler use curr_ret_stack and not depth · b1b35f2e
      Steven Rostedt (VMware) authored
      The profiler uses trace->depth to find its entry on the ret_stack, but the
      depth may not match the actual location of where its entry is (if an
      interrupt were to preempt the processing of the profiler for another
      function, the depth and the curr_ret_stack will be different).
      
      Have it use the curr_ret_stack as the index to find its ret_stack entry
      instead of using the depth variable, as that is no longer guaranteed to be
      the same.
      
      Cc: stable@kernel.org
      Fixes: 03274a3f ("tracing/fgraph: Adjust fgraph depth before calling trace return callback")
      Reviewed-by: default avatarMasami Hiramatsu <mhiramat@kernel.org>
      Signed-off-by: default avatarSteven Rostedt (VMware) <rostedt@goodmis.org>
      b1b35f2e
    • Steven Rostedt (VMware)'s avatar
      function_graph: Reverse the order of pushing the ret_stack and the callback · 7c6ea35e
      Steven Rostedt (VMware) authored
      The function graph profiler uses the ret_stack to store the "subtime" and
      reuse it by nested functions and also on the return. But the current logic
      has the profiler callback called before the ret_stack is updated, and it is
      just modifying the ret_stack that will later be allocated (it's just lucky
      that the "subtime" is not touched when it is allocated).
      
      This could also cause a crash if we are at the end of the ret_stack when
      this happens.
      
      By reversing the order of the allocating the ret_stack and then calling the
      callbacks attached to a function being traced, the ret_stack entry is no
      longer used before it is allocated.
      
      Cc: stable@kernel.org
      Fixes: 03274a3f ("tracing/fgraph: Adjust fgraph depth before calling trace return callback")
      Reviewed-by: default avatarMasami Hiramatsu <mhiramat@kernel.org>
      Signed-off-by: default avatarSteven Rostedt (VMware) <rostedt@goodmis.org>
      7c6ea35e
    • Steven Rostedt (VMware)'s avatar
      function_graph: Move return callback before update of curr_ret_stack · 552701dd
      Steven Rostedt (VMware) authored
      In the past, curr_ret_stack had two functions. One was to denote the depth
      of the call graph, the other is to keep track of where on the ret_stack the
      data is used. Although they may be slightly related, there are two cases
      where they need to be used differently.
      
      The one case is that it keeps the ret_stack data from being corrupted by an
      interrupt coming in and overwriting the data still in use. The other is just
      to know where the depth of the stack currently is.
      
      The function profiler uses the ret_stack to save a "subtime" variable that
      is part of the data on the ret_stack. If curr_ret_stack is modified too
      early, then this variable can be corrupted.
      
      The "max_depth" option, when set to 1, will record the first functions going
      into the kernel. To see all top functions (when dealing with timings), the
      depth variable needs to be lowered before calling the return hook. But by
      lowering the curr_ret_stack, it makes the data on the ret_stack still being
      used by the return hook susceptible to being overwritten.
      
      Now that there's two variables to handle both cases (curr_ret_depth), we can
      move them to the locations where they can handle both cases.
      
      Cc: stable@kernel.org
      Fixes: 03274a3f ("tracing/fgraph: Adjust fgraph depth before calling trace return callback")
      Reviewed-by: default avatarMasami Hiramatsu <mhiramat@kernel.org>
      Signed-off-by: default avatarSteven Rostedt (VMware) <rostedt@goodmis.org>
      552701dd
    • Steven Rostedt (VMware)'s avatar
      function_graph: Use new curr_ret_depth to manage depth instead of curr_ret_stack · 39eb456d
      Steven Rostedt (VMware) authored
      Currently, the depth of the ret_stack is determined by curr_ret_stack index.
      The issue is that there's a race between setting of the curr_ret_stack and
      calling of the callback attached to the return of the function.
      
      Commit 03274a3f ("tracing/fgraph: Adjust fgraph depth before calling
      trace return callback") moved the calling of the callback to after the
      setting of the curr_ret_stack, even stating that it was safe to do so, when
      in fact, it was the reason there was a barrier() there (yes, I should have
      commented that barrier()).
      
      Not only does the curr_ret_stack keep track of the current call graph depth,
      it also keeps the ret_stack content from being overwritten by new data.
      
      The function profiler, uses the "subtime" variable of ret_stack structure
      and by moving the curr_ret_stack, it allows for interrupts to use the same
      structure it was using, corrupting the data, and breaking the profiler.
      
      To fix this, there needs to be two variables to handle the call stack depth
      and the pointer to where the ret_stack is being used, as they need to change
      at two different locations.
      
      Cc: stable@kernel.org
      Fixes: 03274a3f ("tracing/fgraph: Adjust fgraph depth before calling trace return callback")
      Reviewed-by: default avatarMasami Hiramatsu <mhiramat@kernel.org>
      Signed-off-by: default avatarSteven Rostedt (VMware) <rostedt@goodmis.org>
      39eb456d
    • Steven Rostedt (VMware)'s avatar
      function_graph: Make ftrace_push_return_trace() static · d125f3f8
      Steven Rostedt (VMware) authored
      As all architectures now call function_graph_enter() to do the entry work,
      no architecture should ever call ftrace_push_return_trace(). Make it static.
      
      This is needed to prepare for a fix of a design bug on how the curr_ret_stack
      is used.
      
      Cc: stable@kernel.org
      Fixes: 03274a3f ("tracing/fgraph: Adjust fgraph depth before calling trace return callback")
      Reviewed-by: default avatarMasami Hiramatsu <mhiramat@kernel.org>
      Signed-off-by: default avatarSteven Rostedt (VMware) <rostedt@goodmis.org>
      d125f3f8
    • Steven Rostedt (VMware)'s avatar
      sparc/function_graph: Simplify with function_graph_enter() · 9c4bf5e0
      Steven Rostedt (VMware) authored
      The function_graph_enter() function does the work of calling the function
      graph hook function and the management of the shadow stack, simplifying the
      work done in the architecture dependent prepare_ftrace_return().
      
      Have sparc use the new code, and remove the shadow stack management as well as
      having to set up the trace structure.
      
      This is needed to prepare for a fix of a design bug on how the curr_ret_stack
      is used.
      
      Cc: "David S. Miller" <davem@davemloft.net>
      Cc: sparclinux@vger.kernel.org
      Cc: stable@kernel.org
      Fixes: 03274a3f ("tracing/fgraph: Adjust fgraph depth before calling trace return callback")
      Reviewed-by: default avatarMasami Hiramatsu <mhiramat@kernel.org>
      Signed-off-by: default avatarSteven Rostedt (VMware) <rostedt@goodmis.org>
      9c4bf5e0
    • Steven Rostedt (VMware)'s avatar
      sh/function_graph: Simplify with function_graph_enter() · bc715ee4
      Steven Rostedt (VMware) authored
      The function_graph_enter() function does the work of calling the function
      graph hook function and the management of the shadow stack, simplifying the
      work done in the architecture dependent prepare_ftrace_return().
      
      Have superh use the new code, and remove the shadow stack management as well as
      having to set up the trace structure.
      
      This is needed to prepare for a fix of a design bug on how the curr_ret_stack
      is used.
      
      Cc: Yoshinori Sato <ysato@users.sourceforge.jp>
      Cc: Rich Felker <dalias@libc.org>
      Cc: linux-sh@vger.kernel.org
      Cc: stable@kernel.org
      Fixes: 03274a3f ("tracing/fgraph: Adjust fgraph depth before calling trace return callback")
      Reviewed-by: default avatarMasami Hiramatsu <mhiramat@kernel.org>
      Signed-off-by: default avatarSteven Rostedt (VMware) <rostedt@goodmis.org>
      bc715ee4
    • Steven Rostedt (VMware)'s avatar
      s390/function_graph: Simplify with function_graph_enter() · 18588e14
      Steven Rostedt (VMware) authored
      The function_graph_enter() function does the work of calling the function
      graph hook function and the management of the shadow stack, simplifying the
      work done in the architecture dependent prepare_ftrace_return().
      
      Have s390 use the new code, and remove the shadow stack management as well as
      having to set up the trace structure.
      
      This is needed to prepare for a fix of a design bug on how the curr_ret_stack
      is used.
      Acked-by: default avatarMartin Schwidefsky <schwidefsky@de.ibm.com>
      Cc: Heiko Carstens <heiko.carstens@de.ibm.com>
      Cc: Julian Wiedmann <jwi@linux.ibm.com>
      Cc: linux-s390@vger.kernel.org
      Cc: stable@kernel.org
      Fixes: 03274a3f ("tracing/fgraph: Adjust fgraph depth before calling trace return callback")
      Reviewed-by: default avatarMasami Hiramatsu <mhiramat@kernel.org>
      Signed-off-by: default avatarSteven Rostedt (VMware) <rostedt@goodmis.org>
      18588e14
    • Steven Rostedt (VMware)'s avatar
      riscv/function_graph: Simplify with function_graph_enter() · e949b6db
      Steven Rostedt (VMware) authored
      The function_graph_enter() function does the work of calling the function
      graph hook function and the management of the shadow stack, simplifying the
      work done in the architecture dependent prepare_ftrace_return().
      
      Have riscv use the new code, and remove the shadow stack management as well as
      having to set up the trace structure.
      
      This is needed to prepare for a fix of a design bug on how the curr_ret_stack
      is used.
      
      Cc: Greentime Hu <greentime@andestech.com>
      Cc: Alan Kao <alankao@andestech.com>
      Cc: stable@kernel.org
      Fixes: 03274a3f ("tracing/fgraph: Adjust fgraph depth before calling trace return callback")
      Reviewed-by: default avatarPalmer Dabbelt <palmer@sifive.com>
      Reviewed-by: default avatarMasami Hiramatsu <mhiramat@kernel.org>
      Signed-off-by: default avatarSteven Rostedt (VMware) <rostedt@goodmis.org>
      e949b6db
    • Steven Rostedt (VMware)'s avatar
      powerpc/function_graph: Simplify with function_graph_enter() · fe60522e
      Steven Rostedt (VMware) authored
      The function_graph_enter() function does the work of calling the function
      graph hook function and the management of the shadow stack, simplifying the
      work done in the architecture dependent prepare_ftrace_return().
      
      Have powerpc use the new code, and remove the shadow stack management as well as
      having to set up the trace structure.
      
      This is needed to prepare for a fix of a design bug on how the curr_ret_stack
      is used.
      
      Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
      Cc: Paul Mackerras <paulus@samba.org>
      Cc: Michael Ellerman <mpe@ellerman.id.au>
      Cc: linuxppc-dev@lists.ozlabs.org
      Cc: stable@kernel.org
      Fixes: 03274a3f ("tracing/fgraph: Adjust fgraph depth before calling trace return callback")
      Reviewed-by: default avatarMasami Hiramatsu <mhiramat@kernel.org>
      Signed-off-by: default avatarSteven Rostedt (VMware) <rostedt@goodmis.org>
      fe60522e
    • Steven Rostedt (VMware)'s avatar
      parisc: function_graph: Simplify with function_graph_enter() · a87532c7
      Steven Rostedt (VMware) authored
      The function_graph_enter() function does the work of calling the function
      graph hook function and the management of the shadow stack, simplifying the
      work done in the architecture dependent prepare_ftrace_return().
      
      Have parisc use the new code, and remove the shadow stack management as well as
      having to set up the trace structure.
      
      This is needed to prepare for a fix of a design bug on how the curr_ret_stack
      is used.
      
      Cc: "James E.J. Bottomley" <jejb@parisc-linux.org>
      Cc: Helge Deller <deller@gmx.de>
      Cc: linux-parisc@vger.kernel.org
      Cc: stable@kernel.org
      Fixes: 03274a3f ("tracing/fgraph: Adjust fgraph depth before calling trace return callback")
      Reviewed-by: default avatarMasami Hiramatsu <mhiramat@kernel.org>
      Signed-off-by: default avatarSteven Rostedt (VMware) <rostedt@goodmis.org>
      a87532c7
    • Steven Rostedt (VMware)'s avatar
      nds32: function_graph: Simplify with function_graph_enter() · d48ebb24
      Steven Rostedt (VMware) authored
      The function_graph_enter() function does the work of calling the function
      graph hook function and the management of the shadow stack, simplifying the
      work done in the architecture dependent prepare_ftrace_return().
      
      Have nds32 use the new code, and remove the shadow stack management as well as
      having to set up the trace structure.
      
      This is needed to prepare for a fix of a design bug on how the curr_ret_stack
      is used.
      
      Cc: Greentime Hu <greentime@andestech.com>
      Cc: stable@kernel.org
      Fixes: 03274a3f ("tracing/fgraph: Adjust fgraph depth before calling trace return callback")
      Reviewed-by: default avatarMasami Hiramatsu <mhiramat@kernel.org>
      Signed-off-by: default avatarSteven Rostedt (VMware) <rostedt@goodmis.org>
      d48ebb24
    • Steven Rostedt (VMware)'s avatar
      MIPS: function_graph: Simplify with function_graph_enter() · 8712b27c
      Steven Rostedt (VMware) authored
      The function_graph_enter() function does the work of calling the function
      graph hook function and the management of the shadow stack, simplifying the
      work done in the architecture dependent prepare_ftrace_return().
      
      Have MIPS use the new code, and remove the shadow stack management as well as
      having to set up the trace structure.
      
      This is needed to prepare for a fix of a design bug on how the curr_ret_stack
      is used.
      
      Cc: Ralf Baechle <ralf@linux-mips.org>
      Cc: Paul Burton <paul.burton@mips.com>
      Cc: James Hogan <jhogan@kernel.org>
      Cc: linux-mips@linux-mips.org
      Cc: stable@kernel.org
      Fixes: 03274a3f ("tracing/fgraph: Adjust fgraph depth before calling trace return callback")
      Reviewed-by: default avatarMasami Hiramatsu <mhiramat@kernel.org>
      Signed-off-by: default avatarSteven Rostedt (VMware) <rostedt@goodmis.org>
      8712b27c
    • Steven Rostedt (VMware)'s avatar
      microblaze: function_graph: Simplify with function_graph_enter() · 556763e5
      Steven Rostedt (VMware) authored
      The function_graph_enter() function does the work of calling the function
      graph hook function and the management of the shadow stack, simplifying the
      work done in the architecture dependent prepare_ftrace_return().
      
      Have microblaze use the new code, and remove the shadow stack management as well as
      having to set up the trace structure.
      
      This is needed to prepare for a fix of a design bug on how the curr_ret_stack
      is used.
      
      Cc: Michal Simek <monstr@monstr.eu>
      Cc: stable@kernel.org
      Fixes: 03274a3f ("tracing/fgraph: Adjust fgraph depth before calling trace return callback")
      Reviewed-by: default avatarMasami Hiramatsu <mhiramat@kernel.org>
      Signed-off-by: default avatarSteven Rostedt (VMware) <rostedt@goodmis.org>
      556763e5