summaryrefslogtreecommitdiffstats
path: root/samples
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2022-08-05 09:41:12 -0700
committerLinus Torvalds <torvalds@linux-foundation.org>2022-08-05 09:41:12 -0700
commit965a9d75e3d250088a269e0c903e86fe775b48c6 (patch)
treec274334291740246c3437cf1526d9fc5bfb6d4e8 /samples
parent29b1d469f3f6842ee4115f0b21f018fc44176468 (diff)
parentf1a15b977ff864513133ecb611eb28603d32c1b4 (diff)
downloadlinux-stable-965a9d75e3d250088a269e0c903e86fe775b48c6.tar.gz
linux-stable-965a9d75e3d250088a269e0c903e86fe775b48c6.tar.bz2
linux-stable-965a9d75e3d250088a269e0c903e86fe775b48c6.zip
Merge tag 'trace-v6.0' of git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-trace
Pull tracing updates from Steven Rostedt: - Runtime verification infrastructure This is the biggest change here. It introduces the runtime verification that is necessary for running Linux on safety critical systems. It allows for deterministic automata models to be inserted into the kernel that will attach to tracepoints, where the information on these tracepoints will move the model from state to state. If a state is encountered that does not belong to the model, it will then activate a given reactor, that could just inform the user or even panic the kernel (for which safety critical systems will detect and can recover from). - Two monitor models are also added: Wakeup In Preemptive (WIP - not to be confused with "work in progress"), and Wakeup While Not Running (WWNR). - Added __vstring() helper to the TRACE_EVENT() macro to replace several vsnprintf() usages that were all doing it wrong. - eprobes now can have their event autogenerated when the event name is left off. - The rest is various cleanups and fixes. * tag 'trace-v6.0' of git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-trace: (50 commits) rv: Unlock on error path in rv_unregister_reactor() tracing: Use alignof__(struct {type b;}) instead of offsetof() tracing/eprobe: Show syntax error logs in error_log file scripts/tracing: Fix typo 'the the' in comment tracepoints: It is CONFIG_TRACEPOINTS not CONFIG_TRACEPOINT tracing: Use free_trace_buffer() in allocate_trace_buffers() tracing: Use a struct alignof to determine trace event field alignment rv/reactor: Add the panic reactor rv/reactor: Add the printk reactor rv/monitor: Add the wwnr monitor rv/monitor: Add the wip monitor rv/monitor: Add the wip monitor skeleton created by dot2k Documentation/rv: Add deterministic automata instrumentation documentation Documentation/rv: Add deterministic automata monitor synthesis documentation tools/rv: Add dot2k Documentation/rv: Add deterministic automaton documentation tools/rv: Add dot2c Documentation/rv: Add a basic documentation rv/include: Add instrumentation helper functions rv/include: Add deterministic automata monitor definition via C macros ...
Diffstat (limited to 'samples')
-rw-r--r--samples/trace_events/trace-events-sample.c14
-rw-r--r--samples/trace_events/trace-events-sample.h32
2 files changed, 40 insertions, 6 deletions
diff --git a/samples/trace_events/trace-events-sample.c b/samples/trace_events/trace-events-sample.c
index 4d34dc0b0fee..608c4ae3b08a 100644
--- a/samples/trace_events/trace-events-sample.c
+++ b/samples/trace_events/trace-events-sample.c
@@ -19,9 +19,10 @@ static const char *random_strings[] = {
"One ring to rule them all"
};
-static void simple_thread_func(int cnt)
+static void do_simple_thread_func(int cnt, const char *fmt, ...)
{
unsigned long bitmask[1] = {0xdeadbeefUL};
+ va_list va;
int array[6];
int len = cnt % 5;
int i;
@@ -33,9 +34,13 @@ static void simple_thread_func(int cnt)
array[i] = i + 1;
array[i] = 0;
+ va_start(va, fmt);
+
/* Silly tracepoints */
trace_foo_bar("hello", cnt, array, random_strings[len],
- current->cpus_ptr);
+ current->cpus_ptr, fmt, &va);
+
+ va_end(va);
trace_foo_with_template_simple("HELLO", cnt);
@@ -48,6 +53,11 @@ static void simple_thread_func(int cnt)
trace_foo_rel_loc("Hello __rel_loc", cnt, bitmask);
}
+static void simple_thread_func(int cnt)
+{
+ do_simple_thread_func(cnt, "iter=%d", cnt);
+}
+
static int simple_thread(void *arg)
{
int cnt = 0;
diff --git a/samples/trace_events/trace-events-sample.h b/samples/trace_events/trace-events-sample.h
index cbbbb83beced..1a92226202fc 100644
--- a/samples/trace_events/trace-events-sample.h
+++ b/samples/trace_events/trace-events-sample.h
@@ -141,6 +141,27 @@
* In most cases, the __assign_str() macro will take the same
* parameters as the __string() macro had to declare the string.
*
+ * __vstring: This is similar to __string() but instead of taking a
+ * dynamic length, it takes a variable list va_list 'va' variable.
+ * Some event callers already have a message from parameters saved
+ * in a va_list. Passing in the format and the va_list variable
+ * will save just enough on the ring buffer for that string.
+ * Note, the va variable used is a pointer to a va_list, not
+ * to the va_list directly.
+ *
+ * (va_list *va)
+ *
+ * __vstring(foo, fmt, va) is similar to: vsnprintf(foo, fmt, va)
+ *
+ * To assign the string, use the helper macro __assign_vstr().
+ *
+ * __assign_vstr(foo, fmt, va);
+ *
+ * In most cases, the __assign_vstr() macro will take the same
+ * parameters as the __vstring() macro had to declare the string.
+ * Use __get_str() to retrieve the __vstring() just like it would for
+ * __string().
+ *
* __string_len: This is a helper to a __dynamic_array, but it understands
* that the array has characters in it, and with the combined
* use of __assign_str_len(), it will allocate 'len' + 1 bytes
@@ -256,9 +277,10 @@ TRACE_DEFINE_ENUM(TRACE_SAMPLE_ZOO);
TRACE_EVENT(foo_bar,
TP_PROTO(const char *foo, int bar, const int *lst,
- const char *string, const struct cpumask *mask),
+ const char *string, const struct cpumask *mask,
+ const char *fmt, va_list *va),
- TP_ARGS(foo, bar, lst, string, mask),
+ TP_ARGS(foo, bar, lst, string, mask, fmt, va),
TP_STRUCT__entry(
__array( char, foo, 10 )
@@ -266,6 +288,7 @@ TRACE_EVENT(foo_bar,
__dynamic_array(int, list, __length_of(lst))
__string( str, string )
__bitmask( cpus, num_possible_cpus() )
+ __vstring( vstr, fmt, va )
),
TP_fast_assign(
@@ -274,10 +297,11 @@ TRACE_EVENT(foo_bar,
memcpy(__get_dynamic_array(list), lst,
__length_of(lst) * sizeof(int));
__assign_str(str, string);
+ __assign_vstr(vstr, fmt, va);
__assign_bitmask(cpus, cpumask_bits(mask), num_possible_cpus());
),
- TP_printk("foo %s %d %s %s %s %s (%s)", __entry->foo, __entry->bar,
+ TP_printk("foo %s %d %s %s %s %s (%s) %s", __entry->foo, __entry->bar,
/*
* Notice here the use of some helper functions. This includes:
@@ -321,7 +345,7 @@ TRACE_EVENT(foo_bar,
__print_array(__get_dynamic_array(list),
__get_dynamic_array_len(list) / sizeof(int),
sizeof(int)),
- __get_str(str), __get_bitmask(cpus))
+ __get_str(str), __get_bitmask(cpus), __get_str(vstr))
);
/*