History log of /linux-master/samples/ftrace/Makefile
Revision Date Author Comments
(<<< Hide modified files)
(Show modified files >>>)
# b56c68f7 02-Jan-2023 Mark Rutland <mark.rutland@arm.com>

ftrace: Add sample with custom ops

When reworking core ftrace code or architectural ftrace code, it's often
necessary to test/analyse/benchmark a number of ftrace_ops
configurations. This patch adds a module which can be used to explore
some of those configurations.

I'm using this to benchmark various options for changing the way
trampolines and handling of ftrace_ops work on arm64, and ensuring other
architectures aren't adversely affected.

For example, in a QEMU+KVM VM running on a 2GHz Xeon E5-2660
workstation, loading the module in various configurations produces:

| # insmod ftrace-ops.ko
| ftrace_ops: registering:
| relevant ops: 1
| tracee: tracee_relevant [ftrace_ops]
| tracer: ops_func_nop [ftrace_ops]
| irrelevant ops: 0
| tracee: tracee_irrelevant [ftrace_ops]
| tracer: ops_func_nop [ftrace_ops]
| saving registers: NO
| assist recursion: NO
| assist RCU: NO
| ftrace_ops: Attempted 100000 calls to tracee_relevant [ftrace_ops] in 1681558ns (16ns / call)

| # insmod ftrace-ops.ko nr_ops_irrelevant=5
| ftrace_ops: registering:
| relevant ops: 1
| tracee: tracee_relevant [ftrace_ops]
| tracer: ops_func_nop [ftrace_ops]
| irrelevant ops: 5
| tracee: tracee_irrelevant [ftrace_ops]
| tracer: ops_func_nop [ftrace_ops]
| saving registers: NO
| assist recursion: NO
| assist RCU: NO
| ftrace_ops: Attempted 100000 calls to tracee_relevant [ftrace_ops] in 1693042ns (16ns / call)

| # insmod ftrace-ops.ko nr_ops_relevant=2
| ftrace_ops: registering:
| relevant ops: 2
| tracee: tracee_relevant [ftrace_ops]
| tracer: ops_func_nop [ftrace_ops]
| irrelevant ops: 0
| tracee: tracee_irrelevant [ftrace_ops]
| tracer: ops_func_nop [ftrace_ops]
| saving registers: NO
| assist recursion: NO
| assist RCU: NO
| ftrace_ops: Attempted 100000 calls to tracee_relevant [ftrace_ops] in 11965582ns (119ns / call)

| # insmod ftrace-ops.ko save_regs=true
| ftrace_ops: registering:
| relevant ops: 1
| tracee: tracee_relevant [ftrace_ops]
| tracer: ops_func_nop [ftrace_ops]
| irrelevant ops: 0
| tracee: tracee_irrelevant [ftrace_ops]
| tracer: ops_func_nop [ftrace_ops]
| saving registers: YES
| assist recursion: NO
| assist RCU: NO
| ftrace_ops: Attempted 100000 calls to tracee_relevant [ftrace_ops] in 4459624ns (44ns / call)

Link: https://lkml.kernel.org/r/20230103124912.2948963-4-mark.rutland@arm.com

Cc: Florent Revest <revest@chromium.org>
Acked-by: Masami Hiramatsu (Google) <mhiramat@kernel.org>
Signed-off-by: Mark Rutland <mark.rutland@arm.com>
Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>


# e1067a07 06-Dec-2021 Jiri Olsa <jolsa@redhat.com>

ftrace/samples: Add module to test multi direct modify interface

Adding ftrace-direct-multi-modify.ko kernel module that uses
modify_ftrace_direct_multi API. The core functionality is taken
from ftrace-direct-modify.ko kernel module and changed to fit
multi direct interface.

The init function creates kthread that periodically calls
modify_ftrace_direct_multi to change the trampoline address
for the direct ftrace_ops. The ftrace trace_pipe then shows
trace from both trampolines.

Link: https://lkml.kernel.org/r/20211206182032.87248-4-jolsa@kernel.org

Cc: Ingo Molnar <mingo@redhat.com>
Reviewed-by: Heiko Carstens <hca@linux.ibm.com>
Tested-by: Heiko Carstens <hca@linux.ibm.com>
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>


# 503e4510 15-Nov-2021 Heiko Carstens <hca@linux.ibm.com>

ftrace/samples: add missing Kconfig option for ftrace direct multi sample

Currently it is not possible to build the ftrace direct multi example
anymore due to broken config dependencies. Fix this by adding
SAMPLE_FTRACE_DIRECT_MULTI config option.

This broke when merging s390-5.16-1 due to an incorrect merge conflict
resolution proposed by me.

Also rename SAMPLE_FTRACE_MULTI_DIRECT to SAMPLE_FTRACE_DIRECT_MULTI
so it matches the module name.

Fixes: 0b707e572a19 ("Merge tag 's390-5.16-1' of git://git.kernel.org/pub/scm/linux/kernel/git/s390/linux")
Acked-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
Link: https://lore.kernel.org/r/20211115195614.3173346-2-hca@linux.ibm.com
Signed-off-by: Heiko Carstens <hca@linux.ibm.com>


# 0b707e57 06-Nov-2021 Linus Torvalds <torvalds@linux-foundation.org>

Merge tag 's390-5.16-1' of git://git.kernel.org/pub/scm/linux/kernel/git/s390/linux

Pull s390 updates from Vasily Gorbik:

- Add support for ftrace with direct call and ftrace direct call
samples.

- Add support for kernel command lines longer than current 896 bytes
and make its length configurable.

- Add support for BEAR enhancement facility to improve last breaking
event instruction tracking.

- Add kprobes sanity checks and testcases to prevent kprobe in the mid
of an instruction.

- Allow concurrent access to /dev/hwc for the CPUMF users.

- Various ftrace / jump label improvements.

- Convert unwinder tests to KUnit.

- Add s390_iommu_aperture kernel parameter to tweak the limits on
concurrently usable DMA mappings.

- Add ap.useirq AP module option which can be used to disable interrupt
use.

- Add add_disk() error handling support to block device drivers.

- Drop arch specific and use generic implementation of strlcpy and
strrchr.

- Several __pa/__va usages fixes.

- Various cio, crypto, pci, kernel doc and other small fixes and
improvements all over the code.

[ Merge fixup as per https://lore.kernel.org/all/YXAqZ%2FEszRisunQw@osiris/ ]

* tag 's390-5.16-1' of git://git.kernel.org/pub/scm/linux/kernel/git/s390/linux: (63 commits)
s390: make command line configurable
s390: support command lines longer than 896 bytes
s390/kexec_file: move kernel image size check
s390/pci: add s390_iommu_aperture kernel parameter
s390/spinlock: remove incorrect kernel doc indicator
s390/string: use generic strlcpy
s390/string: use generic strrchr
s390/ap: function rework based on compiler warning
s390/cio: make ccw_device_dma_* more robust
s390/vfio-ap: s390/crypto: fix all kernel-doc warnings
s390/hmcdrv: fix kernel doc comments
s390/ap: new module option ap.useirq
s390/cpumf: Allow multiple processes to access /dev/hwc
s390/bitops: return true/false (not 1/0) from bool functions
s390: add support for BEAR enhancement facility
s390: introduce nospec_uses_trampoline()
s390: rename last_break to pgm_last_break
s390/ptrace: add last_break member to pt_regs
s390/sclp: sort out physical vs virtual pointers usage
s390/setup: convert start and end initrd pointers to virtual
...


# 5fae941b 08-Oct-2021 Jiri Olsa <jolsa@redhat.com>

ftrace/samples: Add multi direct interface test module

Adding simple module that uses multi direct interface:

register_ftrace_direct_multi
unregister_ftrace_direct_multi

The init function registers trampoline for 2 functions,
and exit function unregisters them.

Link: https://lkml.kernel.org/r/20211008091336.33616-9-jolsa@kernel.org

Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>

# 89ed4249 20-Nov-2019 Divya Indi <divya.indi@oracle.com>

tracing: Sample module to demonstrate kernel access to Ftrace instances.

This is a sample module to demonstrate the use of the newly introduced and
exported APIs to access Ftrace instances from within the kernel.

Newly introduced APIs used here -

1. Create/Lookup a trace array with the given name.
struct trace_array *trace_array_get_by_name(const char *name)

2. Destroy/Remove a trace array.
int trace_array_destroy(struct trace_array *tr)

4. Enable/Disable trace events:
int trace_array_set_clr_event(struct trace_array *tr, const char *system,
const char *event, bool enable);

Exported APIs -
1. trace_printk equivalent for instances.
int trace_array_printk(struct trace_array *tr,
unsigned long ip, const char *fmt, ...);

2. Helper function.
void trace_printk_init_buffers(void);

3. To decrement the reference counter.
void trace_array_put(struct trace_array *tr)

Sample output(contents of /sys/kernel/tracing/instances/sample-instance)
NOTE: Tracing disabled after ~5 sec)

_-----=> irqs-off
/ _----=> need-resched
| / _---=> hardirq/softirq
|| / _--=> preempt-depth
||| / delay
TASK-PID CPU# |||| TIMESTAMP FUNCTION
| | | |||| | |
sample-instance-1452 [002] .... 49.430948: simple_thread: trace_array_printk: count=0
sample-instance-1452 [002] .... 49.430951: sample_event: count value=0 at jiffies=4294716608
sample-instance-1452 [002] .... 50.454847: simple_thread: trace_array_printk: count=1
sample-instance-1452 [002] .... 50.454849: sample_event: count value=1 at jiffies=4294717632
sample-instance-1452 [002] .... 51.478748: simple_thread: trace_array_printk: count=2
sample-instance-1452 [002] .... 51.478750: sample_event: count value=2 at jiffies=4294718656
sample-instance-1452 [002] .... 52.502652: simple_thread: trace_array_printk: count=3
sample-instance-1452 [002] .... 52.502655: sample_event: count value=3 at jiffies=4294719680
sample-instance-1452 [002] .... 53.526533: simple_thread: trace_array_printk: count=4
sample-instance-1452 [002] .... 53.526535: sample_event: count value=4 at jiffies=4294720704
sample-instance-1452 [002] .... 54.550438: simple_thread: trace_array_printk: count=5
sample-instance-1452 [002] .... 55.574336: simple_thread: trace_array_printk: count=6

Link: http://lkml.kernel.org/r/1574276919-11119-3-git-send-email-divya.indi@oracle.com

Reviewed-by: Aruna Ramakrishna <aruna.ramakrishna@oracle.com>
Signed-off-by: Divya Indi <divya.indi@oracle.com>
[ Moved to samples/ftrace ]
Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>

# ae0cc3b7 14-Nov-2019 Steven Rostedt (VMware) <rostedt@goodmis.org>

ftrace/samples: Add a sample module that implements modify_ftrace_direct()

Add a sample module that tests modify_ftrace_direct(), and this can be used
by the selftests as well.

Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>

# 156473a0 08-Nov-2019 Steven Rostedt (VMware) <rostedt@goodmis.org>

ftrace: Add another example of register_ftrace_direct() use case

Add another module sample that registers a direct trampoline to a function
via register_ftrace_direct(). Having another module that does this allows to
test the use case of multiple direct callers registered, as more than one
direct caller goes into another path, and is needed to perform proper
testing of the register_ftrace_direct() call.

Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>

# b06457c8 08-Nov-2019 Steven Rostedt (VMware) <rostedt@goodmis.org>

ftrace: Add sample module that uses register_ftrace_direct()

Add a sample module that shows a simple use case for
regsiter_ftrace_direct(), and how to use it.

Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>

# 5fae941b 08-Oct-2021 Jiri Olsa <jolsa@redhat.com>

ftrace/samples: Add multi direct interface test module

Adding simple module that uses multi direct interface:

register_ftrace_direct_multi
unregister_ftrace_direct_multi

The init function registers trampoline for 2 functions,
and exit function unregisters them.

Link: https://lkml.kernel.org/r/20211008091336.33616-9-jolsa@kernel.org

Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>


# 89ed4249 20-Nov-2019 Divya Indi <divya.indi@oracle.com>

tracing: Sample module to demonstrate kernel access to Ftrace instances.

This is a sample module to demonstrate the use of the newly introduced and
exported APIs to access Ftrace instances from within the kernel.

Newly introduced APIs used here -

1. Create/Lookup a trace array with the given name.
struct trace_array *trace_array_get_by_name(const char *name)

2. Destroy/Remove a trace array.
int trace_array_destroy(struct trace_array *tr)

4. Enable/Disable trace events:
int trace_array_set_clr_event(struct trace_array *tr, const char *system,
const char *event, bool enable);

Exported APIs -
1. trace_printk equivalent for instances.
int trace_array_printk(struct trace_array *tr,
unsigned long ip, const char *fmt, ...);

2. Helper function.
void trace_printk_init_buffers(void);

3. To decrement the reference counter.
void trace_array_put(struct trace_array *tr)

Sample output(contents of /sys/kernel/tracing/instances/sample-instance)
NOTE: Tracing disabled after ~5 sec)

_-----=> irqs-off
/ _----=> need-resched
| / _---=> hardirq/softirq
|| / _--=> preempt-depth
||| / delay
TASK-PID CPU# |||| TIMESTAMP FUNCTION
| | | |||| | |
sample-instance-1452 [002] .... 49.430948: simple_thread: trace_array_printk: count=0
sample-instance-1452 [002] .... 49.430951: sample_event: count value=0 at jiffies=4294716608
sample-instance-1452 [002] .... 50.454847: simple_thread: trace_array_printk: count=1
sample-instance-1452 [002] .... 50.454849: sample_event: count value=1 at jiffies=4294717632
sample-instance-1452 [002] .... 51.478748: simple_thread: trace_array_printk: count=2
sample-instance-1452 [002] .... 51.478750: sample_event: count value=2 at jiffies=4294718656
sample-instance-1452 [002] .... 52.502652: simple_thread: trace_array_printk: count=3
sample-instance-1452 [002] .... 52.502655: sample_event: count value=3 at jiffies=4294719680
sample-instance-1452 [002] .... 53.526533: simple_thread: trace_array_printk: count=4
sample-instance-1452 [002] .... 53.526535: sample_event: count value=4 at jiffies=4294720704
sample-instance-1452 [002] .... 54.550438: simple_thread: trace_array_printk: count=5
sample-instance-1452 [002] .... 55.574336: simple_thread: trace_array_printk: count=6

Link: http://lkml.kernel.org/r/1574276919-11119-3-git-send-email-divya.indi@oracle.com

Reviewed-by: Aruna Ramakrishna <aruna.ramakrishna@oracle.com>
Signed-off-by: Divya Indi <divya.indi@oracle.com>
[ Moved to samples/ftrace ]
Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>


# ae0cc3b7 14-Nov-2019 Steven Rostedt (VMware) <rostedt@goodmis.org>

ftrace/samples: Add a sample module that implements modify_ftrace_direct()

Add a sample module that tests modify_ftrace_direct(), and this can be used
by the selftests as well.

Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>


# 156473a0 08-Nov-2019 Steven Rostedt (VMware) <rostedt@goodmis.org>

ftrace: Add another example of register_ftrace_direct() use case

Add another module sample that registers a direct trampoline to a function
via register_ftrace_direct(). Having another module that does this allows to
test the use case of multiple direct callers registered, as more than one
direct caller goes into another path, and is needed to perform proper
testing of the register_ftrace_direct() call.

Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>


# b06457c8 08-Nov-2019 Steven Rostedt (VMware) <rostedt@goodmis.org>

ftrace: Add sample module that uses register_ftrace_direct()

Add a sample module that shows a simple use case for
regsiter_ftrace_direct(), and how to use it.

Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>