1. 10 Dec, 2018 6 commits
  2. 09 Dec, 2018 23 commits
  3. 30 Nov, 2018 6 commits
  4. 28 Nov, 2018 5 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