public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
From: "Radim Krčmář" <rkrcmar@redhat.com>
To: Steven Rostedt <rostedt@goodmis.org>
Cc: Jan Kiszka <jan.kiszka@siemens.com>,
	Paolo Bonzini <pbonzini@redhat.com>, nick <xerofoify@gmail.com>,
	gleb@kernel.org, tglx@linutronix.de, mingo@redhat.com,
	hpa@zytor.com, x86@kernel.org, kvm@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: Another Obsolete Fix me in trace.h?
Date: Mon, 24 Nov 2014 22:49:40 +0100	[thread overview]
Message-ID: <20141124214939.GA6671@potion.brq.redhat.com> (raw)
In-Reply-To: <20141124161901.6266925c@gandalf.local.home>

2014-11-24 16:19-0500, Steven Rostedt:
> On Mon, 24 Nov 2014 22:00:01 +0100
> Radim Krčmář <rkrcmar@redhat.com> wrote:
> 
> > 2014-11-24 11:40+0100, Jan Kiszka:
> > The format string has to be a string literal[1]; we could change it to
> > allow expressions[2], but what we want is almost possible through a
> > direct call to trace_seq_printf()[3].
> > 
> > The raw result would look like
> > 
> >   #define __print(fmt, args...) ({ \
> >   	const char *buf_start = trace_seq_buffer_ptr(p); \
> >   	trace_seq_printf(p, fmt, args); \
> >   	trace_seq_putc(p, '\0'); \
> >   	buf_start; \
> >   	})
> > 
> >   TP_printk("%s%s", [...],
> >             __entry->has_error ? __print("(0x%x)", __entry->error_code) : "")
> > 
> > and would be acceptable if something __print-like made it into a ftrace
> > helper[4].  (Userspace won't be able to nicely print it otherwise.)
> 
> You mean if we add something like a __print_conditional(cond, fmt, ...);

The benefit of _conditional is cleaner code?

(_conditional would be possible as a #define on top of generic print,
 the ternary seems to be parsed correctly.)

> For this case you would have:
> 
>   TP_printk("%s%s", [...],
> 	__print_conditional(__entry->has_error, " (0x%x)", __entry->error_code));
> 
> Where __print_conditional() will return "" when "cond" is false, and
> will return the formatted string otherwise.

(This might introduce 'const char empty[] = ""'.)

> That wouldn't be too hard to implement.

I'll look at the patch tommorrow.

Thanks.

  reply	other threads:[~2014-11-24 21:49 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <5472B5B5.5090201@gmail.com>
2014-11-24 10:12 ` Another Obsolete Fix me in trace.h? Paolo Bonzini
2014-11-24 10:40   ` Jan Kiszka
2014-11-24 21:00     ` Radim Krčmář
2014-11-24 21:19       ` Steven Rostedt
2014-11-24 21:49         ` Radim Krčmář [this message]
2014-11-26 12:40           ` Radim Krčmář
2014-11-26 14:15             ` Steven Rostedt
2014-11-26 14:49               ` Radim Krčmář
2014-11-26 15:23                 ` Steven Rostedt

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=20141124214939.GA6671@potion.brq.redhat.com \
    --to=rkrcmar@redhat.com \
    --cc=gleb@kernel.org \
    --cc=hpa@zytor.com \
    --cc=jan.kiszka@siemens.com \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=rostedt@goodmis.org \
    --cc=tglx@linutronix.de \
    --cc=x86@kernel.org \
    --cc=xerofoify@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox