On Fri, Jun 20, 2025 at 02:37:19PM +0000, Tanish Desai wrote:
> diff --git a/scripts/tracetool/format/h.py b/scripts/tracetool/format/h.py
> index ea126b07ea..89d54b9aff 100644
> --- a/scripts/tracetool/format/h.py
> +++ b/scripts/tracetool/format/h.py
> @@ -76,13 +76,17 @@ def generate(events, backend, group):
>          out('',
>              'static inline void %(api)s(%(args)s)',
>              '{',
> -            '    if (%(cond)s) {',
> +            api=e.api(),
> +            args=e.args)
> +        
> +        if "disable" not in e.properties:
> +            backend.generate_unconditional(e, group)
> +
> +        out('    if (%(cond)s) {',
>              '        %(api_nocheck)s(%(names)s);',
>              '    }',
>              '}',
> -            api=e.api(),
>              api_nocheck=e.api(e.QEMU_TRACE_NOCHECK),
> -            args=e.args,
>              names=", ".join(e.args.names()),
>              cond=cond)

Two thoughts:

1. nocheck isn't necessary anymore. The body of nocheck could be inlined
   here instead to simplify the generated code.

2. "if (%(cond)s) {" is only useful for backends that implement
   .generate(). For example, if only the dtrace backend is enabled then
   "if (trace_event_get_state(...)) {}" will be emitted unnecessarily.

Maybe backends should have a .condition() interface so that
scripts/tracetool/format/h.py:generate() can first collect a dict[cond]
-> backend. Then it iterates over the map, calling backend.generate()
within "if (%(cond)s) { ... }". That way only the conditions that are
actually needed are generated and multiple backends that have the same
condition will share the same if statement.

Stefan

Attachment: signature.asc
Description: PGP signature

Reply via email to