From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:49555) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZMb9l-0005ej-Aj for qemu-devel@nongnu.org; Tue, 04 Aug 2015 08:17:22 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZMb9k-0006Lj-6b for qemu-devel@nongnu.org; Tue, 04 Aug 2015 08:17:21 -0400 Received: from hall.aurel32.net ([2001:bc8:30d7:100::1]:40797) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZMb9k-0006LR-1B for qemu-devel@nongnu.org; Tue, 04 Aug 2015 08:17:20 -0400 Date: Tue, 4 Aug 2015 14:17:16 +0200 From: Aurelien Jarno Message-ID: <20150804121716.GA8303@aurel32.net> References: <1438593291-27109-1-git-send-email-alex.bennee@linaro.org> <1438593291-27109-5-git-send-email-alex.bennee@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-15 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable In-Reply-To: <1438593291-27109-5-git-send-email-alex.bennee@linaro.org> Subject: Re: [Qemu-devel] [PATCH v4 04/11] qemu-log: Avoid function call for disabled qemu_log_mask logging List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Alex =?iso-8859-15?Q?Benn=E9e?= Cc: Peter Maydell , qemu-trivial@nongnu.org, qemu-devel@nongnu.org, crosthwaitepeter@gmail.com, pbonzini@redhat.com, rth@twiddle.net On 2015-08-03 10:14, Alex Benn=E9e wrote: > From: Peter Maydell >=20 > Make qemu_log_mask() a macro which only calls the function to > do the actual work if the logging is enabled. This avoids making > a function call in possible fast paths where logging is disabled. >=20 > Signed-off-by: Peter Maydell > Signed-off-by: Alex Benn=E9e > Reviewed-by: Andreas F=E4rber >=20 > --- > v4 > - fix s-o-b tags, add r-b tag > --- > include/qemu/log.h | 13 ++++++++++--- > qemu-log.c | 11 ----------- > 2 files changed, 10 insertions(+), 14 deletions(-) >=20 > diff --git a/include/qemu/log.h b/include/qemu/log.h > index f880e66..b80f8f5 100644 > --- a/include/qemu/log.h > +++ b/include/qemu/log.h > @@ -65,10 +65,17 @@ qemu_log_vprintf(const char *fmt, va_list va) > } > } > =20 > -/* log only if a bit is set on the current loglevel mask > +/* log only if a bit is set on the current loglevel mask: > + * @mask: bit to check in the mask > + * @fmt: printf-style format string > + * @args: optional arguments for format string > */ > -void GCC_FMT_ATTR(2, 3) qemu_log_mask(int mask, const char *fmt, ...); > - > +#define qemu_log_mask(MASK, FMT, ...) \ > + do { \ > + if (unlikely(qemu_loglevel_mask(MASK))) { \ > + qemu_log(FMT, ## __VA_ARGS__); \ > + } \ > + } while (0) > =20 > /* Special cases: */ > =20 > diff --git a/qemu-log.c b/qemu-log.c > index be8405e..7036076 100644 > --- a/qemu-log.c > +++ b/qemu-log.c > @@ -36,17 +36,6 @@ void qemu_log(const char *fmt, ...) > va_end(ap); > } > =20 > -void qemu_log_mask(int mask, const char *fmt, ...) > -{ > - va_list ap; > - > - va_start(ap, fmt); > - if ((qemu_loglevel & mask) && qemu_logfile) { > - vfprintf(qemu_logfile, fmt, ap); > - } > - va_end(ap); > -} > - > /* enable or disable low levels log */ > void do_qemu_set_log(int log_flags, bool use_own_buffers) > { Good idea. Reviewed-by: Aurelien Jarno --=20 Aurelien Jarno GPG: 4096R/1DDD8C9B aurelien@aurel32.net http://www.aurel32.net