// SPDX-License-Identifier: GPL-2.0 /* * Test module for in-kernel synthetic event creation and generation. * * Copyright (C) 2019 Tom Zanussi <[email protected]> */ #include <linux/module.h> #include <linux/trace_events.h> /* * This module is a simple test of basic functionality for in-kernel * synthetic event creation and generation, the first and second tests * using synth_event_gen_cmd_start() and synth_event_add_field(), the * third uses synth_event_create() to do it all at once with a static * field array. * * Following that are a few examples using the created events to test * various ways of tracing a synthetic event. * * To test, select CONFIG_SYNTH_EVENT_GEN_TEST and build the module. * Then: * * # insmod kernel/trace/synth_event_gen_test.ko * # cat /sys/kernel/tracing/trace * * You should see several events in the trace buffer - * "create_synth_test", "empty_synth_test", and several instances of * "gen_synth_test". * * To remove the events, remove the module: * * # rmmod synth_event_gen_test * */ static struct trace_event_file *create_synth_test; static struct trace_event_file *empty_synth_test; static struct trace_event_file *gen_synth_test; /* * Test to make sure we can create a synthetic event, then add more * fields. */ static int __init test_gen_synth_cmd(void) { … } /* * Test to make sure we can create an initially empty synthetic event, * then add all the fields. */ static int __init test_empty_synth_event(void) { … } static struct synth_field_desc create_synth_test_fields[] = …; /* * Test synthetic event creation all at once from array of field * descriptors. */ static int __init test_create_synth_event(void) { … } /* * Test tracing a synthetic event by reserving trace buffer space, * then filling in fields one after another. */ static int __init test_add_next_synth_val(void) { … } /* * Test tracing a synthetic event by reserving trace buffer space, * then filling in fields using field names, which can be done in any * order. */ static int __init test_add_synth_val(void) { … } /* * Test tracing a synthetic event all at once from array of values. */ static int __init test_trace_synth_event(void) { … } static int __init synth_event_gen_test_init(void) { … } static void __exit synth_event_gen_test_exit(void) { … } module_init(synth_event_gen_test_init) module_exit(synth_event_gen_test_exit) MODULE_AUTHOR(…) …; MODULE_DESCRIPTION(…) …; MODULE_LICENSE(…) …;