From db51511caadc3185070948158607a80a640a0022 Mon Sep 17 00:00:00 2001 From: Douglas Raillard Date: Fri, 22 Dec 2023 21:09:53 +0100 Subject: [PATCH 1/5] lisa.trace: Remove optional field support in meta events BREAKING CHANGE Remove support for positional field ("__positional") for meta events such as trace_printk@* or userspace@* events. This feature was not used and complexifies parsers for little gain. --- lisa/trace.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/lisa/trace.py b/lisa/trace.py index b584a6c98..8e0e96912 100644 --- a/lisa/trace.py +++ b/lisa/trace.py @@ -1178,11 +1178,10 @@ class TxtTraceParserBase(TraceParserBase): # For each event we don't already know, get the list of all fields available inferred = df.groupby('__event', observed=True, group_keys=False)['split_fields'].apply(infer_fields).to_frame() - inferred['positional_field'] = df.groupby('__event', observed=True, group_keys=False)['pos_fields'].any() def update_desc(desc): new = dict( - positional_field='__positional' if desc['positional_field'] else None, + positional_field=None, fields={ field.decode('ascii'): None for field in desc['split_fields'] @@ -4031,7 +4030,7 @@ class Trace(Loggable, TraceBase): // trace.df_event('trace_printk@event') void foo(void) { - trace_printk("event: optional_positional_field field1=foo field2=42"); + trace_printk("event: field1=foo field2=42"); } * ``trace_printk@func@``: the event name will be the name of the @@ -4041,7 +4040,7 @@ class Trace(Loggable, TraceBase): // trace.df_event('trace_printk@func@foo') void foo(void) { - trace_printk("optional_positional_field field1=foo field2=42") + trace_printk("field1=foo field2=42") } * ``userspace@``: the event is generated by userspace: @@ -4049,7 +4048,7 @@ class Trace(Loggable, TraceBase): .. code-block:: shell # trace.df_event('userspace@event') - echo "event: optional_positional_field field1=foo field2=42" > /sys/kernel/debug/tracing/trace_marker + echo "event: field1=foo field2=42" > /sys/kernel/debug/tracing/trace_marker .. note:: All meta event names are expected to be valid C language identifiers. Usage of other characters will prevent correct -- GitLab From 205c6d4942cf3b8c2f808d4dc3a5dac662ff1219 Mon Sep 17 00:00:00 2001 From: Douglas Raillard Date: Fri, 29 Dec 2023 11:23:58 +0100 Subject: [PATCH 2/5] lisa.trace: Remove trace_printk@func@... support Remove support for trace_printk@func meta event support. It had a number of issues: * Harder to support for new parsers * The function name is not stable due to multiple symbols sometimes covering the same address range * The function name may or may not be what the user expects due to inlining. --- lisa/trace.py | 22 ---------------------- 1 file changed, 22 deletions(-) diff --git a/lisa/trace.py b/lisa/trace.py index 8e0e96912..1a6fed9f2 100644 --- a/lisa/trace.py +++ b/lisa/trace.py @@ -3542,18 +3542,6 @@ class Trace(Loggable, TraceBase): 'bprint': 'buf', 'bputs': 'str', }[source_event] - - # Select on foobar function name with "trace_printk@func@foobar" - func_prefix = 'func@' - if meta_event.startswith(func_prefix): - func_name = meta_event[len(func_prefix):] - df = self.ana.functions.df_resolve_ksym(df, addr_col='ip', name_col='func_name', exact=False) - df = df[df['func_name'] == func_name] - df = df.copy(deep=False) - # Prepend the meta event name so it will be matched - fake_event = meta_event.encode('ascii') + b': ' - df[content_col] = fake_event + df[content_col] - return (df, content_col) _META_EVENT_SOURCE = { @@ -4033,16 +4021,6 @@ class Trace(Loggable, TraceBase): trace_printk("event: field1=foo field2=42"); } - * ``trace_printk@func@``: the event name will be the name of the - function calling trace_printk: - - .. code-block:: C - - // trace.df_event('trace_printk@func@foo') - void foo(void) { - trace_printk("field1=foo field2=42") - } - * ``userspace@``: the event is generated by userspace: .. code-block:: shell -- GitLab From 69add1b69c951cadf3fde74265837158972a4a85 Mon Sep 17 00:00:00 2001 From: Douglas Raillard Date: Fri, 29 Dec 2023 11:30:34 +0100 Subject: [PATCH 3/5] lisa.trace: Restrict trace_printk@myevent supported events In order to support trace_printk meta events more easily in upcoming parsers, restrict the format that is accepted so that: * the format string is only used to infer the format of the event * the variable arguments buffer is used for the values * we must get a bprint, not bputs event --- lisa/trace.py | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/lisa/trace.py b/lisa/trace.py index 1a6fed9f2..6d271120b 100644 --- a/lisa/trace.py +++ b/lisa/trace.py @@ -4010,23 +4010,31 @@ class Trace(Loggable, TraceBase): In addition to actual events, the following formats for meta events are supported: - * ``trace_printk@``: the event will be assumed to be embedded in - textual form inside the field of another event as a string, - typically emitted using the ``trace_printk()`` kernel function: + * ``trace_printk@``: The event format is described by the + ``bprint`` event format string, and the field values are decoded + from the variable arguments buffer. Note that: + + * The field values *must* be in the buffer, i.e. the format + string is only used as the event format, no "literal value" + will be extracted from it. + + * The event *must* have fields. If not, ``trace_printk()`` + will emit a bputs event that will be ignored at the moment. + We need to get a bprint event. .. code-block:: C - // trace.df_event('trace_printk@event') + // trace.df_event('trace_printk@myevent') void foo(void) { - trace_printk("event: field1=foo field2=42"); + trace_printk("myevent: field1=%s field2=%i", "foo", 42); } * ``userspace@``: the event is generated by userspace: .. code-block:: shell - # trace.df_event('userspace@event') - echo "event: field1=foo field2=42" > /sys/kernel/debug/tracing/trace_marker + # trace.df_event('userspace@myevent') + echo "myevent: field1=foo field2=42" > /sys/kernel/debug/tracing/trace_marker .. note:: All meta event names are expected to be valid C language identifiers. Usage of other characters will prevent correct -- GitLab From 9e2e0e57553bb7d02701ff37b4a96a761b254ddc Mon Sep 17 00:00:00 2001 From: Douglas Raillard Date: Mon, 8 Jan 2024 11:40:50 +0000 Subject: [PATCH 4/5] doc/kernel_tests.rst: Fix reStructuredText warning FIX Add a blank line as reST requires to finish a bullet point list. --- doc/kernel_tests.rst | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/doc/kernel_tests.rst b/doc/kernel_tests.rst index 9174c350f..6007426c4 100644 --- a/doc/kernel_tests.rst +++ b/doc/kernel_tests.rst @@ -64,6 +64,10 @@ The shortest path to executing a test from a shell is: # To run a test matching a pattern lisa-test '*test_task_placement' + # For reStructuredText to have its bullet point closing blank line + printf "\n" + + More advanced workflows are described at :ref:`automated-testing-page`. From a python environment -- GitLab From dc37d25c7ccabeaba33313f2d3d93f20028f6486 Mon Sep 17 00:00:00 2001 From: Douglas Raillard Date: Mon, 8 Jan 2024 11:42:58 +0000 Subject: [PATCH 5/5] lisa.trace: Remove trace_printk@ meta event bputs support BREAKING CHANGE trace_printk@... meta events now require a bprint event, bputs is not supported anymore. --- lisa/trace.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/lisa/trace.py b/lisa/trace.py index 6d271120b..f3452527e 100644 --- a/lisa/trace.py +++ b/lisa/trace.py @@ -3540,7 +3540,6 @@ class Trace(Loggable, TraceBase): def _select_trace_printk(self, source_event, meta_event, df): content_col = { 'bprint': 'buf', - 'bputs': 'str', }[source_event] return (df, content_col) @@ -3550,7 +3549,6 @@ class Trace(Loggable, TraceBase): }, 'trace_printk': { 'bprint': _select_trace_printk, - 'bputs': _select_trace_printk, }, } """ -- GitLab