All of lore.kernel.org
 help / color / mirror / Atom feed
From: Stefan Hajnoczi <stefanha@redhat.com>
To: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
Cc: kwolf@redhat.com, qemu-block@nongnu.org, michael.roth@amd.com,
	philmd@redhat.com, qemu-devel@nongnu.org, armbru@redhat.com,
	hreitz@redhat.com, pbonzini@redhat.com, jsnow@redhat.com
Subject: Re: [PATCH v2 2/4] scripts/qapi/commands: gen_commands(): add add_trace_points argument
Date: Mon, 10 Jan 2022 16:22:04 +0000	[thread overview]
Message-ID: <YdxdLLNc/Av889nH@stefanha-x1.localdomain> (raw)
In-Reply-To: <20211223110756.699148-3-vsementsov@virtuozzo.com>

[-- Attachment #1: Type: text/plain, Size: 2051 bytes --]

On Thu, Dec 23, 2021 at 12:07:54PM +0100, Vladimir Sementsov-Ogievskiy wrote:
> Add possibility to generate trace points for each qmp command.
> 
> We should generate both trace points and trace-events file, for further
> trace point code generation.
> 
> Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
> ---
>  scripts/qapi/commands.py | 84 ++++++++++++++++++++++++++++++++++------
>  1 file changed, 73 insertions(+), 11 deletions(-)
> 
> diff --git a/scripts/qapi/commands.py b/scripts/qapi/commands.py
> index 21001bbd6b..9691c11f96 100644
> --- a/scripts/qapi/commands.py
> +++ b/scripts/qapi/commands.py
> @@ -53,7 +53,8 @@ def gen_command_decl(name: str,
>  def gen_call(name: str,
>               arg_type: Optional[QAPISchemaObjectType],
>               boxed: bool,
> -             ret_type: Optional[QAPISchemaType]) -> str:
> +             ret_type: Optional[QAPISchemaType],
> +             add_trace_points: bool) -> str:

Please use the term "trace events" instead of "trace points". That's the
term that docs/devel/tracing.rst uses.

> @@ -122,10 +167,14 @@ def gen_marshal_decl(name: str) -> str:
>                   proto=build_marshal_proto(name))
>  
>  
> +def gen_trace(name: str) -> str:
> +    return f'qmp_{c_name(name)}(const char *tag, const char *json) "%s%s"\n'

This trace event is emitted in 3 different ways:
1. For arguments before calling a QMP command.
2. For the error message when the QMP command fails.
3. For the return value when a QMP command succeeds.

This makes parsing the trace akward because you get two events in
succession for a single call and they both have the same name.

Please generate 2 trace events:
1. qmp_enter_<name> <args>
2. qmp_exit_<name> <ret> <succeeded>

(That's similar to how the syscalls Linux kernel trace events work.)

Scripts processing the trace can easily differentiate between enter
(args) and exit (return value) events without parsing or keeping state
to count the second event.

Thanks,
Stefan

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

  reply	other threads:[~2022-01-10 16:24 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-12-23 11:07 [PATCH v2 0/4] trace qmp commands Vladimir Sementsov-Ogievskiy
2021-12-23 11:07 ` [PATCH v2 1/4] jobs: drop qmp_ trace points Vladimir Sementsov-Ogievskiy
2022-01-10 16:05   ` Stefan Hajnoczi
2022-01-11 23:44     ` John Snow
2022-01-12 10:45       ` Stefan Hajnoczi
2021-12-23 11:07 ` [PATCH v2 2/4] scripts/qapi/commands: gen_commands(): add add_trace_points argument Vladimir Sementsov-Ogievskiy
2022-01-10 16:22   ` Stefan Hajnoczi [this message]
2022-01-17  8:46     ` Vladimir Sementsov-Ogievskiy
2022-01-11 23:53   ` John Snow
2022-01-12  0:32     ` John Snow
2022-01-12 10:50       ` Stefan Hajnoczi
2022-01-17  8:45         ` Vladimir Sementsov-Ogievskiy
2022-01-17  9:31           ` Kevin Wolf
2021-12-23 11:07 ` [PATCH v2 3/4] scripts/qapi-gen.py: add --add-trace-points option Vladimir Sementsov-Ogievskiy
2022-01-10 16:22   ` Stefan Hajnoczi
2022-01-12  0:38   ` John Snow
2022-01-17  8:50     ` Vladimir Sementsov-Ogievskiy
2021-12-23 11:07 ` [PATCH v2 4/4] meson: generate trace points for qmp commands Vladimir Sementsov-Ogievskiy
2022-01-10 16:27   ` Stefan Hajnoczi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=YdxdLLNc/Av889nH@stefanha-x1.localdomain \
    --to=stefanha@redhat.com \
    --cc=armbru@redhat.com \
    --cc=hreitz@redhat.com \
    --cc=jsnow@redhat.com \
    --cc=kwolf@redhat.com \
    --cc=michael.roth@amd.com \
    --cc=pbonzini@redhat.com \
    --cc=philmd@redhat.com \
    --cc=qemu-block@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    --cc=vsementsov@virtuozzo.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.