All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v5 0/2] function_graph: Support recording and printing the return value of function
@ 2023-03-20 13:16 ` Donglin Peng
  0 siblings, 0 replies; 39+ messages in thread
From: Donglin Peng @ 2023-03-20 13:16 UTC (permalink / raw)
  To: mhiramat, rostedt, linux, mark.rutland, will, catalin.marinas,
	palmer, paul.walmsley, tglx, dave.hansen, x86, mingo, xiehuan09,
	dinghui, huangcun, dolinux.peng
  Cc: linux-trace-kernel, linux-riscv, linux-arm-kernel, linux-kernel,
	Donglin Peng

When using the function_graph tracer to analyze system call failures,
it can be time-consuming to analyze the trace logs and locate the kernel
function that first returns an error. This change aims to simplify the
process by recording the function return value to the 'retval' member of
'ftrace_graph_ent' and printing it when outputing the trace log.

Note that even if a function's return type is void, a return value will
still be printed, so it should be ignored. If you care about this, the
BTF file can be used to obtain the details of function return type. We
can implement a tool to process the trace log and display the return
value based on its actual type.

Here is an example:

...

 1)               |  cgroup_attach_task() {
 1)               |    cgroup_migrate_add_src() {
 1)   1.403 us    |      cset_cgroup_from_root(); /* = 0xffff93fc86f58010 */
 1)   2.154 us    |    } /* cgroup_migrate_add_src = 0xffffb286c1297d00 */
 1) ! 386.538 us  |    cgroup_migrate_prepare_dst(); /* = 0x0 */
 1)               |    cgroup_migrate() {
 1)   0.651 us    |      cgroup_migrate_add_task(); /* = 0xffff93fcfd346c00 */
 1)               |      cgroup_migrate_execute() {
 1)               |        cpu_cgroup_can_attach() {
 1)               |          cgroup_taskset_first() {
 1)   0.732 us    |            cgroup_taskset_next(); /* = 0xffff93fc8fb20000 */
 1)   1.232 us    |          } /* cgroup_taskset_first = 0xffff93fc8fb20000 */
 1)   0.380 us    |          sched_rt_can_attach(); /* = 0x0 */
 1)   2.335 us    |        } /* cpu_cgroup_can_attach = -22 */
 1)   4.369 us    |      } /* cgroup_migrate_execute = -22 */
 1)   7.143 us    |    } /* cgroup_migrate = -22 */
 1)               |    cgroup_migrate_finish() {
 1)   0.411 us    |      put_css_set_locked(); /* = 0x8 */
 1) + 62.397 us   |      put_css_set_locked(); /* = 0x80000001 */
 1) + 64.742 us   |    } /* cgroup_migrate_finish = 0x80000000 */
 1) ! 465.605 us  |  } /* cgroup_attach_task = -22 */

...

After processing the above trace logs using BTF information:

...

 1)               |  cgroup_attach_task() {
 1)               |    cgroup_migrate_add_src() {
 1)   1.403 us    |      cset_cgroup_from_root(); /* = 0xffff93fc86f58010 */
 1)   2.154 us    |    } /* cgroup_migrate_add_src */
 1) ! 386.538 us  |    cgroup_migrate_prepare_dst(); /* = 0 */
 1)               |    cgroup_migrate() {
 1)   0.651 us    |      cgroup_migrate_add_task();
 1)               |      cgroup_migrate_execute() {
 1)               |        cpu_cgroup_can_attach() {
 1)               |          cgroup_taskset_first() {
 1)   0.732 us    |            cgroup_taskset_next(); /* = 0xffff93fc8fb20000 */
 1)   1.232 us    |          } /* cgroup_taskset_first = 0xffff93fc8fb20000 */
 1)   0.380 us    |          sched_rt_can_attach(); /* = 0 */
 1)   2.335 us    |        } /* cpu_cgroup_can_attach = -22 */
 1)   4.369 us    |      } /* cgroup_migrate_execute = -22 */
 1)   7.143 us    |    } /* cgroup_migrate = -22 */
 1)               |    cgroup_migrate_finish() {
 1)   0.411 us    |      put_css_set_locked();
 1) + 62.397 us   |      put_css_set_locked();
 1) + 64.742 us   |    } /* cgroup_migrate_finish */
 1) ! 465.605 us  |  } /* cgroup_attach_task = -22 */

...

Donglin Peng (2):
  function_graph: Support recording and printing the return value of
    function
  tracing: Add documentation for funcgraph-retval and graph_retval_hex

 Documentation/trace/ftrace.rst       | 75 ++++++++++++++++++++++
 arch/arm/Kconfig                     |  1 +
 arch/arm/kernel/entry-ftrace.S       |  8 +++
 arch/arm64/Kconfig                   |  1 +
 arch/arm64/kernel/entry-ftrace.S     |  8 +++
 arch/riscv/Kconfig                   |  1 +
 arch/riscv/kernel/mcount.S           | 12 +++-
 arch/x86/Kconfig                     |  1 +
 arch/x86/kernel/ftrace_32.S          |  8 +++
 arch/x86/kernel/ftrace_64.S          | 10 +++
 include/linux/ftrace.h               |  3 +
 kernel/trace/Kconfig                 |  8 +++
 kernel/trace/fgraph.c                | 25 +++++++-
 kernel/trace/trace.h                 |  2 +
 kernel/trace/trace_entries.h         | 26 ++++++++
 kernel/trace/trace_functions_graph.c | 95 +++++++++++++++++++++++++---
 16 files changed, 272 insertions(+), 12 deletions(-)

-- 
2.25.1


_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

^ permalink raw reply	[flat|nested] 39+ messages in thread

end of thread, other threads:[~2023-03-22  9:03 UTC | newest]

Thread overview: 39+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-03-20 13:16 [PATCH v5 0/2] function_graph: Support recording and printing the return value of function Donglin Peng
2023-03-20 13:16 ` Donglin Peng
2023-03-20 13:16 ` Donglin Peng
2023-03-20 13:16 ` [PATCH v5 1/2] " Donglin Peng
2023-03-20 13:16   ` Donglin Peng
2023-03-20 13:16   ` Donglin Peng
2023-03-21 14:09   ` Florian Kauer
2023-03-21 14:09     ` Florian Kauer
2023-03-21 14:09     ` Florian Kauer
2023-03-21 14:44     ` Steven Rostedt
2023-03-21 14:44       ` Steven Rostedt
2023-03-21 14:44       ` Steven Rostedt
2023-03-21 15:11       ` Florian Kauer
2023-03-21 15:11         ` Florian Kauer
2023-03-21 15:11         ` Florian Kauer
2023-03-22  5:01         ` Donglin Peng
2023-03-22  5:01           ` Donglin Peng
2023-03-22  5:01           ` Donglin Peng
2023-03-21 14:24   ` Mark Rutland
2023-03-21 14:24     ` Mark Rutland
2023-03-21 14:24     ` Mark Rutland
2023-03-22  8:47     ` Donglin Peng
2023-03-22  8:47       ` Donglin Peng
2023-03-22  8:47       ` Donglin Peng
2023-03-21 17:31   ` Russell King (Oracle)
2023-03-21 17:31     ` Russell King (Oracle)
2023-03-21 17:31     ` Russell King (Oracle)
2023-03-22  9:01     ` Donglin Peng
2023-03-22  9:01       ` Donglin Peng
2023-03-22  9:01       ` Donglin Peng
2023-03-20 13:16 ` [PATCH v5 2/2] tracing: Add documentation for funcgraph-retval and graph_retval_hex Donglin Peng
2023-03-20 13:16   ` Donglin Peng
2023-03-20 13:16   ` Donglin Peng
2023-03-21  2:31   ` Ding Hui
2023-03-21  2:31     ` Ding Hui
2023-03-21  2:31     ` Ding Hui
2023-03-21  3:24     ` Donglin Peng
2023-03-21  3:24       ` Donglin Peng
2023-03-21  3:24       ` Donglin Peng

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.