From patchwork Thu Aug 6 13:36:09 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 504713 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 1617A1402B7 for ; Fri, 7 Aug 2015 00:11:52 +1000 (AEST) Received: from localhost ([::1]:45338 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZNLtc-0008Ec-UD for incoming@patchwork.ozlabs.org; Thu, 06 Aug 2015 10:11:48 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33628) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZNLMc-00045r-0N for qemu-devel@nongnu.org; Thu, 06 Aug 2015 09:37:45 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZNLMb-0003UQ-89 for qemu-devel@nongnu.org; Thu, 06 Aug 2015 09:37:41 -0400 Received: from mx1.redhat.com ([209.132.183.28]:51629) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZNLMY-0003RS-KB; Thu, 06 Aug 2015 09:37:38 -0400 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (Postfix) with ESMTPS id 3C25736B165; Thu, 6 Aug 2015 13:37:38 +0000 (UTC) Received: from donizetti.redhat.com (ovpn-112-80.ams2.redhat.com [10.36.112.80]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t76DaI9Q016488; Thu, 6 Aug 2015 09:37:32 -0400 From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Thu, 6 Aug 2015 15:36:09 +0200 Message-Id: <1438868176-20364-12-git-send-email-pbonzini@redhat.com> In-Reply-To: <1438868176-20364-1-git-send-email-pbonzini@redhat.com> References: <1438868176-20364-1-git-send-email-pbonzini@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: kwolf@redhat.com, famz@redhat.com, stefanha@redhat.com, qemu-block@nongnu.org Subject: [Qemu-devel] [PATCH 11/18] qemu-timer: optimize timerlist_run_timers 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+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org The case of no active timers is relatively common. Check it outside the lock. Signed-off-by: Paolo Bonzini --- qemu-timer.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/qemu-timer.c b/qemu-timer.c index 2463fe6..dc11ab9 100644 --- a/qemu-timer.c +++ b/qemu-timer.c @@ -476,6 +476,10 @@ bool timerlist_run_timers(QEMUTimerList *timer_list) QEMUTimerCB *cb; void *opaque; + if (!atomic_read(&timer_list->active_timers)) { + return false; + } + qemu_event_reset(&timer_list->timers_done_ev); if (!timer_list->clock->enabled) { goto out;