From patchwork Mon Aug 3 09:14:44 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 51847 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wi0-f197.google.com (mail-wi0-f197.google.com [209.85.212.197]) by patches.linaro.org (Postfix) with ESMTPS id C4867229FD for ; Mon, 3 Aug 2015 09:16:30 +0000 (UTC) Received: by wixh2 with SMTP id h2sf27330680wix.0 for ; Mon, 03 Aug 2015 02:16:30 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:from:to:date:message-id:in-reply-to :references:mime-version:content-type:content-transfer-encoding:cc :subject:precedence:list-id:list-unsubscribe:list-archive:list-post :list-help:list-subscribe:errors-to:sender:x-original-sender :x-original-authentication-results:mailing-list; bh=4hEeoPCTuebvo9tv27IebC8tFs6EZBeg8/90Bs51WVs=; b=E0dVYLLkoZASHDln4A8NIrYuzNNDXo2/DXW+25xCzcLBZikMu6HCIkYdllOwbY3oq5 4nkb79onmmb22BG8RymuQOrxSXN6ZvMmRVz4fWg3UBLccH/n8VIrz4IAdUE9Y/Y7NKMp 0FlUwuCVAgXEjM6CBWgbr8IXts3Qy9hFUYExaiQO9FHAJsHboPm6JBz+phZH1CknFHYW OQ5wSZDg+8FkcEyKBdVWibO+AqXIvkLzb3y4dJ60MDavEUEY+/ucw7bREmlsjcYBfrFH v9fJMo8mlqz59ShP2r+7iRjZMTdLM2eijFOftt5cdj7Oyc7F9PBTUqXwx0AElh6f8FXv dC5Q== X-Gm-Message-State: ALoCoQknjVNB3Ql35X0wufvxGhRzCglD065sWvbH67OPApvNMPKzGbAKkEipLS+1yMoqDgXq2AQw X-Received: by 10.112.16.200 with SMTP id i8mr5290011lbd.20.1438593389756; Mon, 03 Aug 2015 02:16:29 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.45.73 with SMTP id k9ls498945lam.66.gmail; Mon, 03 Aug 2015 02:16:29 -0700 (PDT) X-Received: by 10.112.137.164 with SMTP id qj4mr15654953lbb.105.1438593389471; Mon, 03 Aug 2015 02:16:29 -0700 (PDT) Received: from mail-lb0-f173.google.com (mail-lb0-f173.google.com. [209.85.217.173]) by mx.google.com with ESMTPS id y9si11425163lad.98.2015.08.03.02.16.29 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 03 Aug 2015 02:16:29 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.173 as permitted sender) client-ip=209.85.217.173; Received: by lbbud7 with SMTP id ud7so70416322lbb.3 for ; Mon, 03 Aug 2015 02:16:29 -0700 (PDT) X-Received: by 10.152.26.163 with SMTP id m3mr15841662lag.86.1438593389213; Mon, 03 Aug 2015 02:16:29 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.7.198 with SMTP id l6csp1753990lba; Mon, 3 Aug 2015 02:16:28 -0700 (PDT) X-Received: by 10.107.155.12 with SMTP id d12mr21345208ioe.131.1438593388100; Mon, 03 Aug 2015 02:16:28 -0700 (PDT) Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id k194si13485561ioe.102.2015.08.03.02.16.27 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Mon, 03 Aug 2015 02:16:28 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Received: from localhost ([::1]:58174 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZMBr8-0006QE-Rw for patch@linaro.org; Mon, 03 Aug 2015 05:16:26 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41179) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZMBpr-0005Lc-66 for qemu-devel@nongnu.org; Mon, 03 Aug 2015 05:15:08 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZMBpn-00037F-ID for qemu-devel@nongnu.org; Mon, 03 Aug 2015 05:15:07 -0400 Received: from mail-wi0-f180.google.com ([209.85.212.180]:35781) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZMBpn-00036P-D4 for qemu-devel@nongnu.org; Mon, 03 Aug 2015 05:15:03 -0400 Received: by wibxm9 with SMTP id xm9so111984966wib.0 for ; Mon, 03 Aug 2015 02:15:03 -0700 (PDT) X-Received: by 10.194.23.36 with SMTP id j4mr31485163wjf.105.1438593302573; Mon, 03 Aug 2015 02:15:02 -0700 (PDT) Received: from zen.linaro.local ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id be9sm21840198wjb.26.2015.08.03.02.15.01 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 03 Aug 2015 02:15:01 -0700 (PDT) Received: from zen.linaroharston (localhost [127.0.0.1]) by zen.linaro.local (Postfix) with ESMTP id 7432B3E07A7; Mon, 3 Aug 2015 10:15:00 +0100 (BST) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: qemu-devel@nongnu.org Date: Mon, 3 Aug 2015 10:14:44 +0100 Message-Id: <1438593291-27109-5-git-send-email-alex.bennee@linaro.org> X-Mailer: git-send-email 2.5.0 In-Reply-To: <1438593291-27109-1-git-send-email-alex.bennee@linaro.org> References: <1438593291-27109-1-git-send-email-alex.bennee@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.85.212.180 Cc: Peter Maydell , qemu-trivial@nongnu.org, crosthwaitepeter@gmail.com, pbonzini@redhat.com, =?UTF-8?q?Alex=20Benn=C3=A9e?= , aurelien@aurel32.net, rth@twiddle.net Subject: [Qemu-devel] [PATCH v4 04/11] qemu-log: Avoid function call for disabled qemu_log_mask logging X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: , List-Help: , List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: alex.bennee@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.173 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 From: Peter Maydell 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. Signed-off-by: Peter Maydell Signed-off-by: Alex Bennée Reviewed-by: Andreas Färber --- 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(-) 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) } } -/* 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) /* Special cases: */ 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); } -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) {