bootconfig/tracing/ktest: Add ktest examples of testing bootconfig
Steven Rostedt
maintainerRFC PATCH 1/1 bootconfig/tracing/ktest: Add ktest examples of testing bootconfig
From: "Steven Rostedt (VMware)" <[email protected]>
bootconfig is a new feature that appends scripts onto the initrd, and the kernel executes the scripts as an extended kernel command line.
Need to add tests to test that the happened. To test the bootconfig properly, the initrd needs to be updated and the kernel rebooted. ktest is the perfect solution to perform these tests.
Add a example bootconfig.conf in the tools/testing/ktest/examples/include and example bootconfig scripts in tools/testing/ktest/examples/bootconfig and also include verifier scripts that ktest will install on the target and run to make sure that the bootconfig options in the scripts took place after the target rebooted with the new initrd update.
--- .../examples/bootconfigs/boottrace.bconf | 49 +++++++++++ .../examples/bootconfigs/config-bootconfig | 1 + .../ktest/examples/bootconfigs/ftrace.bconf | 82 ++++++++++++++++++ .../examples/bootconfigs/functiongraph.bconf | 15 ++++ .../ktest/examples/bootconfigs/tracing.bconf | 51 +++++++++++ .../examples/bootconfigs/verify-boottrace.sh | 84 +++++++++++++++++++ .../bootconfigs/verify-functiongraph.sh | 61 ++++++++++++++ .../examples/bootconfigs/verify-tracing.sh | 74 ++++++++++++++++ .../ktest/examples/include/bootconfig.conf | 83 ++++++++++++++++++ tools/testing/ktest/examples/kvm.conf | 1 + 10 files changed, 501 insertions(+) create mode 100644 tools/testing/ktest/examples/bootconfigs/boottrace.bconf create mode 100644 tools/testing/ktest/examples/bootconfigs/config-bootconfig create mode 100644 tools/testing/ktest/examples/bootconfigs/ftrace.bconf create mode 100644 tools/testing/ktest/examples/bootconfigs/functiongraph.bconf create mode 100644 tools/testing/ktest/examples/bootconfigs/tracing.bconf create mode 100755 tools/testing/ktest/examples/bootconfigs/verify-boottrace.sh create mode 100755 tools/testing/ktest/examples/bootconfigs/verify-functiongraph.sh create mode 100755 tools/testing/ktest/examples/bootconfigs/verify-tracing.sh create mode 100644 tools/testing/ktest/examples/include/bootconfig.conf
tools/testing/ktest/examples/bootconfigs/boottrace.bconf new file +49 -0
@@ -0,0 +1,49 @@ +ftrace.event { + task.task_newtask { + filter = "pid < 128" + enable + } + kprobes.vfs_read { + probes = "vfs_read $arg1 $arg2" + filter = "common_pid < 200" + enable + } + synthetic.initcall_latency { + fields = "unsigned long func", "u64 lat" + actions = "hist:keys=func.sym,lat:vals=lat:sort=lat" + } + initcall.initcall_start { + actions = "hist:keys=func:ts0=common_timestamp.usecs" + } + initcall.initcall_finish { + actions = "hist:keys=func:lat=common_timestamp.usecs-$ts0:onmatch(initcall.initcall_start).initcall_latency(func,$lat)" + } +} + +ftrace.instance { + foo { + tracer = "function" + ftrace.filters = "user_*" + cpumask = 1 + options = nosym-addr + buffer_size = 512KB + trace_clock = mono + event.signal.signal_deliver.actions=snapshot + } + bar { + tracer = "function" + ftrace.filters = "kernel_*" + cpumask = 2 + trace_clock = x86-tsc + } +} + +ftrace.alloc_snapshot + +kernel { + trace_options = sym-addr + trace_event = "initcall:*" + trace_buf_size = 1M + ftrace = function + ftrace_filter = "vfs*" +}
tools/testing/ktest/examples/bootconfigs/config-bootconfig new file +1 -0
@@ -0,0 +1 @@ +CONFIG_CMDLINE="bootconfig"
tools/testing/ktest/examples/bootconfigs/ftrace.bconf new file +82 -0
82 lines not on this page · raw message
tools/testing/ktest/examples/bootconfigs/functiongraph.bconf new file +15 -0
@@ -0,0 +1,15 @@ +ftrace { + tracing_on = 0 # off by default + tracer = function_graph + event.kprobes { + start_event { + probes = "pci_proc_init" + actions = "traceon" + } + end_event { + probes = "pci_proc_init%return" + actions = "traceoff" + } + } + } +
tools/testing/ktest/examples/bootconfigs/tracing.bconf new file +51 -0
51 lines not on this page · raw message
tools/testing/ktest/examples/bootconfigs/verify-boottrace.sh new file +84 -0
84 lines not on this page · raw message
tools/testing/ktest/examples/bootconfigs/verify-functiongraph.sh new file +61 -0
61 lines not on this page · raw message
tools/testing/ktest/examples/bootconfigs/verify-tracing.sh new file +74 -0
74 lines not on this page · raw message
tools/testing/ktest/examples/include/bootconfig.conf new file +83 -0
83 lines not on this page · raw message
tools/testing/ktest/examples/kvm.conf +1 -0
@@ -90,3 +90,4 @@ INCLUDE include/patchcheck.conf INCLUDE include/tests.conf INCLUDE include/bisect.conf INCLUDE include/min-config.conf +INCLUDE include/bootconfig.conf
Signature · 1 line
2.29.2
Hi Steve,
Quoted 9 lines · On Wed, 16 Jun 2021 17:41:55 -0400 Steven Rostedt <[email protected]> wrote:
From: "Steven Rostedt (VMware)" <[email protected]>
bootconfig is a new feature that appends scripts onto the initrd, and the kernel executes the scripts as an extended kernel command line.
Need to add tests to test that the happened. To test the bootconfig properly, the initrd needs to be updated and the kernel rebooted. ktest is the perfect solution to perform these tests.
Quoted 5 lines
Add a example bootconfig.conf in the
tools/testing/ktest/examples/includeand example bootconfig scripts intools/testing/ktest/examples/bootconfigand also include verifier scripts that ktest will install on the target and run to make sure that the bootconfig options in the scripts took place after the target rebooted with the new initrd update.
Thank you very much for integrate it to ktest!
I gave some experimental bconfs without cleanup.
[..]
Quoted 13 lines
tools/testing/ktest/examples/bootconfigs/config-bootconfig new file +1
-0@@ -0,0 +1 @@ +CONFIG_CMDLINE="bootconfig"tools/testing/ktest/examples/bootconfigs/ftrace.bconf new file +0
-0
tools/testing/ktest/examples/bootconfigs/ftrace.bconf line 1
Quoted 1 line
tools/testing/ktest/examples/bootconfigs/ftrace.bconf new file +1
-0@@ -0,0 +1,82 @@ +#!/bin/sh
This shebang is for the syntax hilighting. Please remove it.
Quoted 5 lines
tools/testing/ktest/examples/bootconfigs/ftrace.bconf new file +5
-0+ +ftrace { + options = "sym-addr", "context-info" + buffer_size = 1MB +}
tools/testing/ktest/examples/bootconfigs/ftrace.bconf line 16
Quoted 10 lines
tools/testing/ktest/examples/bootconfigs/ftrace.bconf new file +10
-0+ +ftrace.event { + # Sample1: Make a histogram for initcall functions + synthetic.initcall_latency { + fields = "unsigned long func", "u64 lat" + hist { + keys = func.sym, lat + vals = lat + sort = lat + }
These event.<GROUP>.<EVENT>.hist block is an experimental syntax (plan A), and not implemented yet.
tools/testing/ktest/examples/bootconfigs/ftrace.bconf line 29
Quoted 13 lines
tools/testing/ktest/examples/bootconfigs/ftrace.bconf new file +13
-0+ } + initcall.initcall_start.hist { + keys = func + var.ts0 = common_timestamp.usecs + } + initcall.initcall_finish.hist { + keys = func + var.lat = common_timestamp.usecs - $ts0 + onmatch { + event = initcall.initcall_start + action = "initcall_latency(func, $lat)" + } + }
So please drop this Sample1.
Quoted 40 lines
tools/testing/ktest/examples/bootconfigs/ftrace.bconf new file +40
-0+ + # Sample2: kmalloc() tracing in read(2) syscall + syscalls.sys_enter_read.enable_event { + event = kmem.kmalloc + count = 1 + } + syscalls.sys_exit_read.disable_event { + event = kmem.kmalloc + } + + # Sample3: Stacktrace at the event + kmem.kmalloc.stacktrace { + count = 5 + filter = 'bytes_req >= 65536' + } + + # Sample4: Take a snapshot + block.block_unplug.snapshot { + count = 1 + filter = nr_rq > 1 + } + + # Sample5: Trace-on/off + block.block_plug.traceon { + filter = nr_rq > 1 + } + block.block_unplug.traceoff { + filter = nr_rq > 1 + } + + # Sample6: onmax + sched.sched_waking { + enable + hist { + keys = pid + ts1 = common_timestamp.usecs + filter = 'comm == "cyclictest"' + } + } + sched.sched_switch {
tools/testing/ktest/examples/bootconfigs/ftrace.bconf line 79
Quoted 10 lines
tools/testing/ktest/examples/bootconfigs/ftrace.bconf new file +10
-0+ enable + hist { + keys = next_pid + var.wakeup_lat = common_timestamp.usecs - $ts1 + onmax { + var = wakeup_lat + action = "save(next_prio,next_comm,prev_pid,prev_prio,prev_comm)" + } + filter = 'next_comm == "cyclictest"' + }
This also an experimental syntax. Please drop Sample 6.
Quoted 45 lines
tools/testing/ktest/examples/bootconfigs/ftrace.bconf new file +3
-0+ } +} +tools/testing/ktest/examples/bootconfigs/functiongraph.bconf new file +15
-0@@ -0,0 +1,15 @@ +ftrace { + tracing_on = 0 # off by default + tracer = function_graph + event.kprobes { + start_event { + probes = "pci_proc_init" + actions = "traceon" + } + end_event { + probes = "pci_proc_init%return" + actions = "traceoff" + } + } + } +tools/testing/ktest/examples/bootconfigs/tracing.bconf new file +15
-0@@ -0,0 +1,51 @@ +ftrace { + tracer = function; + options = event-fork, sym-addr, stacktrace; + buffer_size = 1M; + alloc_snapshot; + trace_clock = global; + events = "task:task_newtask", "initcall:*"; + event.sched.sched_process_exec { + filter = "pid < 128"; + } + event.kprobes.myevent { + probes = "vfs_read $arg1 $arg2", "vfs_write $arg1 $arg2" + } + event.kprobes.myevent2 { + probes = "initrd_load";
tools/testing/ktest/examples/bootconfigs/tracing.bconf line 25
Quoted 10 lines
tools/testing/ktest/examples/bootconfigs/tracing.bconf new file +10
-0+ } + event.kprobes.enable + instance.bar { + event.synthetic.initcall_latency { + fields = "unsigned long func", "u64 lat"; + actions.hist { + keys = func.sym, lat; + vals = lat; + sort = lat; + }
This is another experimental syntax (plan B).
This makes histogram into actions.
tools/testing/ktest/examples/bootconfigs/tracing.bconf line 30
Quoted 5 lines
tools/testing/ktest/examples/bootconfigs/tracing.bconf new file +5
-0+ } + event.initcall { + initcall_start.actions.hist { + keys = func; + ts0 = "common_timestamp.usecs";
But remove "var." from local variable definition.
tools/testing/ktest/examples/bootconfigs/tracing.bconf line 39
Quoted 9 lines
tools/testing/ktest/examples/bootconfigs/tracing.bconf new file +9
-0+ } + initcall_finish.actions.hist { + keys = "func"; + lat = "common_timestamp.usecs-$ts0"; + onmatch = "initcall.initcall_start", + "initcall_latency(func,$lat)"; + } + } + }
Thus, please drop this "instance.bar" block.
tools/testing/ktest/examples/bootconfigs/tracing.bconf line 51
Quoted 12 lines
tools/testing/ktest/examples/bootconfigs/tracing.bconf new file +12
-0+ instance.foo { + tracer = function-graph; + tracing_on = false; + event.workqueue.workqueue_start.actions = "tracing_on"; + event.workqueue.workqueue_end.actions = "tracing_off"; + }; +} +kernel { + tp_printk; + dump_on_oops = 2 + traceoff_on_warning +}
Thank you,
Signature · 1 line
Masami Hiramatsu <[email protected]>
Steven Rostedt
maintainerQuoted 14 lines · On Thu, 17 Jun 2021 11:59:21 +0900 Masami Hiramatsu <[email protected]> wrote:
Hi Steve,
Quoted 9 lines · On Wed, 16 Jun 2021 17:41:55 -0400 Steven Rostedt <[email protected]> wrote:
From: "Steven Rostedt (VMware)" <[email protected]>
bootconfig is a new feature that appends scripts onto the initrd, and the kernel executes the scripts as an extended kernel command line.
Need to add tests to test that the happened. To test the bootconfig properly, the initrd needs to be updated and the kernel rebooted. ktest is the perfect solution to perform these tests.
Quoted 9 lines
Quoted 5 lines
Add a example bootconfig.conf in the
tools/testing/ktest/examples/includeand example bootconfig scripts intools/testing/ktest/examples/bootconfigand also include verifier scripts that ktest will install on the target and run to make sure that the bootconfig options in the scripts took place after the target rebooted with the new initrd update.Thank you very much for integrate it to ktest!
I gave some experimental bconfs without cleanup.
No problem. If I was to take bootconfig patches from you, I had to have a way to test for regressions ;-)
Quoted 6 lines
tools/testing/ktest/examples/bootconfigs/ftrace.bconf line 1
Quoted 4 lines
tools/testing/ktest/examples/bootconfigs/ftrace.bconf new file +1
-0@@ -0,0 +1,82 @@ +#!/bin/shThis shebang is for the syntax hilighting. Please remove it.
OK. I didn't even notice that.
Quoted 11 lines
Quoted 11 lines
tools/testing/ktest/examples/bootconfigs/ftrace.bconf new file +10
-0+ +ftrace { + options = "sym-addr", "context-info" + buffer_size = 1MB +} + +ftrace.event { + # Sample1: Make a histogram for initcall functions + synthetic.initcall_latency { + fields = "unsigned long func", "u64 lat"
Quoted 8 lines
tools/testing/ktest/examples/bootconfigs/ftrace.bconf line 16
Quoted 5 lines
tools/testing/ktest/examples/bootconfigs/ftrace.bconf new file +5
-0+ hist { + keys = func.sym, lat + vals = lat + sort = lat + }These event.<GROUP>.<EVENT>.hist block is an experimental syntax (plan A), and not implemented yet.
I'll remove this then.
Quoted 16 lines
Quoted 4 lines
tools/testing/ktest/examples/bootconfigs/ftrace.bconf new file +3
-0+ } + initcall.initcall_start.hist { + keys = functools/testing/ktest/examples/bootconfigs/ftrace.bconf line 29
Quoted 10 lines
tools/testing/ktest/examples/bootconfigs/ftrace.bconf new file +10
-0+ var.ts0 = common_timestamp.usecs + } + initcall.initcall_finish.hist { + keys = func + var.lat = common_timestamp.usecs - $ts0 + onmatch { + event = initcall.initcall_start + action = "initcall_latency(func, $lat)" + } + }So please drop this Sample1.
OK.
Quoted 45 lines
Quoted 45 lines
tools/testing/ktest/examples/bootconfigs/ftrace.bconf new file +44
-0+ + # Sample2: kmalloc() tracing in read(2) syscall + syscalls.sys_enter_read.enable_event { + event = kmem.kmalloc + count = 1 + } + syscalls.sys_exit_read.disable_event { + event = kmem.kmalloc + } + + # Sample3: Stacktrace at the event + kmem.kmalloc.stacktrace { + count = 5 + filter = 'bytes_req >= 65536' + } + + # Sample4: Take a snapshot + block.block_unplug.snapshot { + count = 1 + filter = nr_rq > 1 + } + + # Sample5: Trace-on/off + block.block_plug.traceon { + filter = nr_rq > 1 + } + block.block_unplug.traceoff { + filter = nr_rq > 1 + } + + # Sample6: onmax + sched.sched_waking { + enable + hist { + keys = pid + ts1 = common_timestamp.usecs + filter = 'comm == "cyclictest"' + } + } + sched.sched_switch { + enable + hist { + keys = next_pid + var.wakeup_lat = common_timestamp.usecs - $ts1
Quoted 8 lines
tools/testing/ktest/examples/bootconfigs/ftrace.bconf line 79
Quoted 6 lines
tools/testing/ktest/examples/bootconfigs/ftrace.bconf new file +6
-0+ onmax { + var = wakeup_lat + action = "save(next_prio,next_comm,prev_pid,prev_prio,prev_comm)" + } + filter = 'next_comm == "cyclictest"' + }This also an experimental syntax. Please drop Sample 6.
OK.
Quoted 51 lines
Quoted 51 lines
tools/testing/ktest/examples/bootconfigs/ftrace.bconf new file +3
-0+ } +} +tools/testing/ktest/examples/bootconfigs/functiongraph.bconf new file +15
-0@@ -0,0 +1,15 @@ +ftrace { + tracing_on = 0 # off by default + tracer = function_graph + event.kprobes { + start_event { + probes = "pci_proc_init" + actions = "traceon" + } + end_event { + probes = "pci_proc_init%return" + actions = "traceoff" + } + } + } +tools/testing/ktest/examples/bootconfigs/tracing.bconf new file +20
-0@@ -0,0 +1,51 @@ +ftrace { + tracer = function; + options = event-fork, sym-addr, stacktrace; + buffer_size = 1M; + alloc_snapshot; + trace_clock = global; + events = "task:task_newtask", "initcall:*"; + event.sched.sched_process_exec { + filter = "pid < 128"; + } + event.kprobes.myevent { + probes = "vfs_read $arg1 $arg2", "vfs_write $arg1 $arg2" + } + event.kprobes.myevent2 { + probes = "initrd_load"; + } + event.kprobes.enable + instance.bar { + event.synthetic.initcall_latency { + fields = "unsigned long func", "u64 lat";
Quoted 8 lines
tools/testing/ktest/examples/bootconfigs/tracing.bconf line 25
Quoted 5 lines
tools/testing/ktest/examples/bootconfigs/tracing.bconf new file +5
-0+ actions.hist { + keys = func.sym, lat; + vals = lat; + sort = lat; + }This is another experimental syntax (plan B).
This makes histogram into actions.
I'll remove it for now.
Quoted 9 lines
tools/testing/ktest/examples/bootconfigs/tracing.bconf line 30
Quoted 6 lines
tools/testing/ktest/examples/bootconfigs/tracing.bconf new file +5
-0+ } + event.initcall { + initcall_start.actions.hist { + keys = func; + ts0 = "common_timestamp.usecs";But remove "var." from local variable definition.
Quoted 11 lines
tools/testing/ktest/examples/bootconfigs/tracing.bconf line 39
Quoted 9 lines
tools/testing/ktest/examples/bootconfigs/tracing.bconf new file +9
-0+ } + initcall_finish.actions.hist { + keys = "func"; + lat = "common_timestamp.usecs-$ts0"; + onmatch = "initcall.initcall_start", + "initcall_latency(func,$lat)"; + } + } + }Thus, please drop this "instance.bar" block.
Will do.
Thanks for the review.
-- Steve
Quoted 17 lines
tools/testing/ktest/examples/bootconfigs/tracing.bconf line 51
Quoted 13 lines
tools/testing/ktest/examples/bootconfigs/tracing.bconf new file +12
-0+ instance.foo { + tracer = function-graph; + tracing_on = false; + event.workqueue.workqueue_start.actions = "tracing_on"; + event.workqueue.workqueue_end.actions = "tracing_off"; + }; +} +kernel { + tp_printk; + dump_on_oops = 2 + traceoff_on_warning +}Thank you,
Steven Rostedt
maintainerQuoted 1 line · On Thu, 17 Jun 2021 11:59:21 +0900 Masami Hiramatsu <[email protected]> wrote:
Quoted 1 line
+++ b/tools/testing/ktest/examples/bootconfigs/ftrace.bconf
I'm trying to get this file to work. But I may just drop it completely.
Quoted 61 lines
Review line 1
Quoted 2 lines
(quoted diff) +1
-0@@ -0,0 +1,82 @@ +#!/bin/shThis shebang is for the syntax hilighting. Please remove it.
Quoted 5 lines
tools/testing/ktest/examples/bootconfigs/ftrace.bconf new file +5
-0+ +ftrace { + options = "sym-addr", "context-info" + buffer_size = 1MB +}tools/testing/ktest/examples/bootconfigs/ftrace.bconf line 16
Quoted 10 lines
tools/testing/ktest/examples/bootconfigs/ftrace.bconf new file +10
-0+ +ftrace.event { + # Sample1: Make a histogram for initcall functions + synthetic.initcall_latency { + fields = "unsigned long func", "u64 lat" + hist { + keys = func.sym, lat + vals = lat + sort = lat + }These event.<GROUP>.<EVENT>.hist block is an experimental syntax (plan A), and not implemented yet.
tools/testing/ktest/examples/bootconfigs/ftrace.bconf line 29
Quoted 13 lines
tools/testing/ktest/examples/bootconfigs/ftrace.bconf new file +13
-0+ } + initcall.initcall_start.hist { + keys = func + var.ts0 = common_timestamp.usecs + } + initcall.initcall_finish.hist { + keys = func + var.lat = common_timestamp.usecs - $ts0 + onmatch { + event = initcall.initcall_start + action = "initcall_latency(func, $lat)" + } + }So please drop this Sample1.
Quoted 21 lines
tools/testing/ktest/examples/bootconfigs/ftrace.bconf new file +21
-0+ + # Sample2: kmalloc() tracing in read(2) syscall + syscalls.sys_enter_read.enable_event { + event = kmem.kmalloc + count = 1 + } + syscalls.sys_exit_read.disable_event { + event = kmem.kmalloc + } + + # Sample3: Stacktrace at the event + kmem.kmalloc.stacktrace { + count = 5 + filter = 'bytes_req >= 65536' + } + + # Sample4: Take a snapshot + block.block_unplug.snapshot { + count = 1 + filter = nr_rq > 1 + }
Quoted 8 lines
tools/testing/ktest/examples/bootconfigs/ftrace.bconf line 58
Quoted 8 lines
tools/testing/ktest/examples/bootconfigs/ftrace.bconf new file +8
-0+ + # Sample5: Trace-on/off + block.block_plug.traceon { + filter = nr_rq > 1 + } + block.block_unplug.traceoff { + filter = nr_rq > 1 + }
None of the above samples do anything.
I'll see if tracing.bconf does anything with the changes.
-- Steve
Quoted 10 lines
Quoted 10 lines
tools/testing/ktest/examples/bootconfigs/ftrace.bconf new file +10
-0+ + # Sample6: onmax + sched.sched_waking { + enable + hist { + keys = pid + ts1 = common_timestamp.usecs + filter = 'comm == "cyclictest"' + } + }