All of lore.kernel.org
 help / color / mirror / Atom feed
From: Stefan Hajnoczi <stefanha@redhat.com>
To: Tanish Desai <tanishdesai37@gmail.com>
Cc: qemu-devel@nongnu.org, pbonzini@redhat.com, Mads Ynddal <mads@ynddal.dk>
Subject: Re: [PATCH 1/3] trace/syslog: seperate cold paths of tracing functions
Date: Mon, 2 Jun 2025 18:01:19 -0400	[thread overview]
Message-ID: <20250602220119.GA320269@fedora> (raw)
In-Reply-To: <20250601181231.3461-2-tanishdesai37@gmail.com>

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

On Sun, Jun 01, 2025 at 06:12:29PM +0000, Tanish Desai wrote:
> inline: move hot paths from .c to .h for better performance
> Moved frequently used hot paths from the .c file to the .h file to enable inlining
> and improve performance. This approach is inspired by past QEMU optimizations,
> where performance-critical code was inlined based on profiling results.
> 
> Signed-off-by: Tanish Desai <tanishdesai37@gmail.com>
> ---
>  scripts/tracetool/backend/syslog.py | 36 +++++++++++++++++++++++------
>  1 file changed, 29 insertions(+), 7 deletions(-)

This commit description doesn't match what the patch does.

What is the purpose of creating a _syslog_trace_foo() function in the .c
file instead of calling syslog() directly from the .h file?

> 
> diff --git a/scripts/tracetool/backend/syslog.py b/scripts/tracetool/backend/syslog.py
> index 012970f6cc..52b8ff65ea 100644
> --- a/scripts/tracetool/backend/syslog.py
> +++ b/scripts/tracetool/backend/syslog.py
> @@ -21,8 +21,12 @@
>  
>  
>  def generate_h_begin(events, group):
> -    out('#include <syslog.h>',
> -        '')
> +    out('#include <syslog.h>')
> +    for event in events:
> +        out('void _syslog_%(api)s(%(args)s);',
> +            api=event.api(),
> +            args=event.args)
> +    out('')
>  
>  
>  def generate_h(event, group):
> @@ -37,17 +41,35 @@ def generate_h(event, group):
>          cond = "trace_event_get_state(%s)" % ("TRACE_" + event.name.upper())
>  
>      out('    if (%(cond)s) {',
> -        '#line %(event_lineno)d "%(event_filename)s"',
> -        '        syslog(LOG_INFO, "%(name)s " %(fmt)s %(argnames)s);',
> -        '#line %(out_next_lineno)d "%(out_filename)s"',
> +            '       _syslog_%(api)s(%(args)s);',
>          '    }',
>          cond=cond,
>          event_lineno=event.lineno,
>          event_filename=os.path.relpath(event.filename),
>          name=event.name,
>          fmt=event.fmt.rstrip("\n"),
> -        argnames=argnames)
> -
> +        argnames=argnames,
> +        api=event.api(),
> +        args=", ".join(event.args.names()))
> +
> +
> +def generate_c(event, group):
> +        argnames = ", ".join(event.args.names())
> +        if len(event.args) > 0:
> +            argnames = ", " + argnames
> +        out('void _syslog_%(api)s(%(args)s){',
> +        '   #line %(event_lineno)d "%(event_filename)s"',
> +        '            syslog(LOG_INFO, "%(name)s " %(fmt)s %(argnames)s);',
> +        '   #line %(out_next_lineno)d "%(out_filename)s"',
> +        '}',
> +        '',
> +        event_lineno=event.lineno,
> +        event_filename=os.path.relpath(event.filename),
> +        name=event.name,
> +        fmt=event.fmt.rstrip("\n"),
> +        argnames=argnames,
> +        api=event.api(),
> +        args=event.args)    
>  
>  def generate_h_backend_dstate(event, group):
>      out('    trace_event_get_state_dynamic_by_id(%(event_id)s) || \\',
> -- 
> 2.34.1
> 

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

  reply	other threads:[~2025-06-02 22:27 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-06-01 18:12 [PATCH 0/3] trace: seperate cold path of trace Tanish Desai
2025-06-01 18:12 ` [PATCH 1/3] trace/syslog: seperate cold paths of tracing functions Tanish Desai
2025-06-02 22:01   ` Stefan Hajnoczi [this message]
2025-06-05  3:02     ` Tanish Desai
2025-06-01 18:12 ` [PATCH 2/3] trace/ftrace: " Tanish Desai
2025-06-02 22:24   ` Stefan Hajnoczi
2025-06-05 13:57     ` Paolo Bonzini
2025-06-05 18:37       ` Stefan Hajnoczi
2025-06-05 18:49         ` Paolo Bonzini
2025-06-05 19:20           ` Daniel P. Berrangé
2025-06-05 21:24             ` Paolo Bonzini
2025-06-09 18:27           ` Stefan Hajnoczi
2025-06-09 18:50             ` Paolo Bonzini
2025-06-01 18:12 ` [PATCH 3/3] trace/log: seperate cold path " Tanish Desai

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=20250602220119.GA320269@fedora \
    --to=stefanha@redhat.com \
    --cc=mads@ynddal.dk \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=tanishdesai37@gmail.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.