From: Changbin Du <changbin.du@gmail.com>
To: Steven Rostedt <rostedt@goodmis.org>, Ingo Molnar <mingo@redhat.com>
Cc: Jonathan Corbet <corbet@lwn.net>, Jessica Yu <jeyu@kernel.org>,
Thomas Gleixner <tglx@linutronix.de>,
x86@kernel.org, linux-doc@vger.kernel.org,
linux-kernel@vger.kernel.org,
linux-arm-kernel@lists.infradead.org, linux-mips@vger.kernel.org,
linux-parisc@vger.kernel.org, linuxppc-dev@lists.ozlabs.org,
linux-riscv@lists.infradead.org, linux-s390@vger.kernel.org,
linux-sh@vger.kernel.org, sparclinux@vger.kernel.org,
linux-arch@vger.kernel.org, linux-kbuild@vger.kernel.org,
Changbin Du <changbin.du@gmail.com>
Subject: [PATCH 00/11] ftrace: add support for recording function parameters and return value
Date: Sun, 25 Aug 2019 21:23:19 +0800 [thread overview]
Message-ID: <20190825132330.5015-1-changbin.du@gmail.com> (raw)
This series introduces a new ftrace feature CONFIG_FTRACE_FUNC_PROTOTYPE to
record function parameters and return value. It can be enabled/disabled at
runtime by a new trace option "record-funcproto".
To achieve this, we need the function prototype infomation and the location of
parameters. A new tool scripts/ftrace/funcprototype is provided to collect such
necessary infomation and put them into kernel. It walks through the DWARF debug
sections in each object file and output assembly code which defines the function
prototype data. Then the assembly code is built into the original object file.
Here is an example of memremap() function:
.section __funcprotostr, "a"
.P_memremap_0:
.string "offset"
.P_memremap_1:
.string "size"
.P_memremap_2:
.string "flags"
.section __funcproto, "a"
.quad memremap
.byte 0x8
.byte 0x3
.quad .P_memremap_0
.byte 0x8
.byte 0x55
.byte 0x0
.quad .P_memremap_1
.byte 0x8
.byte 0x54
.byte 0x0
.quad .P_memremap_2
.byte 0x8
.byte 0x51
.byte 0x0
Note that currently funcprototype only support global functions. Local functions
can also be supported by using the idea described in recordmcount.pl - temporary
change local functions to global.
The C ABI is arch specific. For arch which supports this feature must
implement a new arch-specific interface arch_fgraph_record_params() and
deliver the return value of function to ftrace core part.
This series only add support for x86_64 platform. Other platforms can be
supported in the future.
Here is an example of the graph trace of function pick_next_task_fair().
Note that we only record the parameter and return value of global
functions.
2) | pick_next_task_fair() {
2) | update_blocked_averages() {
2) 0.765 us | _raw_spin_lock_irqsave(lock=0xffff88807da2b100); /* ret=0x0000000000000082 */
2) 0.944 us | update_rq_clock(rq=0xffff88807da2b100);
2) 0.612 us | __update_load_avg_cfs_rq(now=0x000000251b8516ee, cfs_rq=0xffff8880754f7488); /* ret=0 */
2) 0.654 us | __update_load_avg_se(now=0x000000251b8516ee, cfs_rq=0xffff88807da2b180, se=0xffff88807be2e0d8); /* ret=0 */
2) 0.206 us | __update_load_avg_cfs_rq(now=0x000000251b8516ee, cfs_rq=0xffff88807da2b180); /* ret=0 */
2) | __update_load_avg_cfs_rq(now=0x000000251b8516ee, cfs_rq=0xffff888079b5fb18) {
2) 2.410 us | __accumulate_pelt_segments();
2) 3.103 us | } /* ret=1 */
2) 0.193 us | __update_load_avg_cfs_rq(now=0x000000251b8516ee, cfs_rq=0xffff88807da2b180); /* ret=0 */
2) | update_rt_rq_load_avg(now=0x000000251b8516ee, rq=0xffff88807da2b100, running=0) {
2) 0.258 us | __accumulate_pelt_segments();
2) 1.617 us | } /* ret=1 */
2) | update_dl_rq_load_avg(now=0x000000251b8516ee, rq=0xffff88807da2b100, running=0) {
2) 0.230 us | __accumulate_pelt_segments();
2) 1.511 us | } /* ret=1 */
2) 1.040 us | _raw_spin_unlock_irqrestore(lock=0xffff88807da2b100, flags=0x0000000000000082);
2) + 14.739 us | }
2) | load_balance() {
2) | find_busiest_group() {
2) 0.874 us | update_group_capacity(sd=0xffff88807c1d37d0, cpu=2);
2) 1.761 us | idle_cpu();
2) 0.262 us | idle_cpu();
2) 0.217 us | idle_cpu();
2) 6.338 us | }
2) 8.442 us | }
2) 1.823 us | __msecs_to_jiffies(m=0x00000006); /* ret=0x0000000000000002 */
2) | load_balance() {
2) | find_busiest_group() {
2) 0.434 us | idle_cpu();
2) 0.233 us | idle_cpu();
2) 0.210 us | idle_cpu();
2) 2.308 us | }
2) 2.821 us | }
2) 0.263 us | __msecs_to_jiffies(m=0x00000008); /* ret=0x0000000000000002 */
2) 0.977 us | _raw_spin_lock(lock=0xffff88807da2b100);
2) + 32.262 us | }
The printing rules of each value is:
o For signed value, it is always printed as decimal number.
o For unsigned value,
- For value has size great than 8, it is printed as '{..}'.
- For value has size of 1,2,4,8, it is printed as hexadecimal number.
- If failed to record a parameter, it is printed as '?'.
Changbin Du (11):
ftrace: move recordmcount tools to scripts/ftrace
ftrace: introduce new building tool funcprototype
asm-generic: add generic dwarf definition
ftrace/hash: add private data field
ftrace: create memcache for hash entries
ftrace: process function prototype data in vmlinux and modules
ftrace: prepare arch specific interfaces for function prototype
feature
ftrace: introduce core part of function prototype recording
x86_64: add function prototype recording support
ftrace: add doc for new option record-funcproto
MAINTAINERS: make scripts/ftrace/ maintained
Documentation/trace/ftrace.rst | 6 +
MAINTAINERS | 2 +
arch/arm/kernel/ftrace.c | 2 +-
arch/arm64/kernel/ftrace.c | 2 +-
arch/csky/kernel/ftrace.c | 2 +-
arch/microblaze/kernel/ftrace.c | 2 +-
arch/mips/kernel/ftrace.c | 2 +-
arch/nds32/kernel/ftrace.c | 5 +-
arch/parisc/kernel/ftrace.c | 2 +-
arch/powerpc/kernel/trace/ftrace.c | 2 +-
arch/riscv/kernel/ftrace.c | 2 +-
arch/s390/kernel/ftrace.c | 2 +-
arch/sh/kernel/ftrace.c | 2 +-
arch/sparc/kernel/ftrace.c | 2 +-
arch/x86/Kconfig | 1 +
arch/x86/kernel/ftrace.c | 84 +++-
arch/x86/kernel/ftrace_64.S | 4 +-
include/asm-generic/dwarf.h | 199 +++++++++
include/asm-generic/vmlinux.lds.h | 18 +
include/linux/ftrace.h | 55 ++-
include/linux/module.h | 4 +
kernel/module.c | 25 +-
kernel/trace/Kconfig | 19 +
kernel/trace/fgraph.c | 26 +-
kernel/trace/ftrace.c | 164 +++++++-
kernel/trace/trace.h | 20 +-
kernel/trace/trace_entries.h | 10 +
kernel/trace/trace_functions_graph.c | 108 ++++-
kernel/trace/trace_irqsoff.c | 3 +-
kernel/trace/trace_sched_wakeup.c | 3 +-
scripts/.gitignore | 1 -
scripts/Makefile | 2 +-
scripts/Makefile.build | 28 +-
scripts/ftrace/.gitignore | 6 +
scripts/ftrace/Makefile | 9 +
scripts/ftrace/funcprototype.c | 576 +++++++++++++++++++++++++++
scripts/{ => ftrace}/recordmcount.c | 0
scripts/{ => ftrace}/recordmcount.h | 0
scripts/{ => ftrace}/recordmcount.pl | 0
39 files changed, 1340 insertions(+), 60 deletions(-)
create mode 100644 include/asm-generic/dwarf.h
create mode 100644 scripts/ftrace/.gitignore
create mode 100644 scripts/ftrace/Makefile
create mode 100644 scripts/ftrace/funcprototype.c
rename scripts/{ => ftrace}/recordmcount.c (100%)
rename scripts/{ => ftrace}/recordmcount.h (100%)
rename scripts/{ => ftrace}/recordmcount.pl (100%)
mode change 100755 => 100644
--
2.20.1
next reply other threads:[~2019-08-25 13:23 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-08-25 13:23 Changbin Du [this message]
2019-08-25 13:23 ` [PATCH 01/11] ftrace: move recordmcount tools to scripts/ftrace Changbin Du
2019-08-26 22:44 ` Steven Rostedt
2019-08-28 23:41 ` Changbin Du
2019-08-25 13:23 ` [PATCH 02/11] ftrace: introduce new building tool funcprototype Changbin Du
2019-08-25 13:23 ` [PATCH 03/11] asm-generic: add generic dwarf definition Changbin Du
2019-08-26 7:42 ` Peter Zijlstra
2019-08-26 22:25 ` Changbin Du
2019-08-25 13:23 ` [PATCH 04/11] ftrace/hash: add private data field Changbin Du
2019-08-25 13:23 ` [PATCH 05/11] ftrace: create memcache for hash entries Changbin Du
2019-08-26 7:44 ` Peter Zijlstra
2019-08-26 22:35 ` Changbin Du
2019-08-25 13:23 ` [PATCH 06/11] ftrace: process function prototype data in vmlinux and modules Changbin Du
2019-08-25 13:23 ` [PATCH 07/11] ftrace: prepare arch specific interfaces for function prototype feature Changbin Du
2019-08-25 13:23 ` [PATCH 08/11] ftrace: introduce core part of function prototype recording Changbin Du
2019-08-25 13:23 ` [PATCH 09/11] x86_64: add function prototype recording support Changbin Du
2019-08-25 13:23 ` [PATCH 10/11] ftrace: add doc for new option record-funcproto Changbin Du
2019-08-25 13:23 ` [PATCH 11/11] MAINTAINERS: make scripts/ftrace/ maintained Changbin Du
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190825132330.5015-1-changbin.du@gmail.com \
--to=changbin.du@gmail.com \
--cc=corbet@lwn.net \
--cc=jeyu@kernel.org \
--cc=linux-arch@vger.kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-doc@vger.kernel.org \
--cc=linux-kbuild@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mips@vger.kernel.org \
--cc=linux-parisc@vger.kernel.org \
--cc=linux-riscv@lists.infradead.org \
--cc=linux-s390@vger.kernel.org \
--cc=linux-sh@vger.kernel.org \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=mingo@redhat.com \
--cc=rostedt@goodmis.org \
--cc=sparclinux@vger.kernel.org \
--cc=tglx@linutronix.de \
--cc=x86@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).