From patchwork Tue Jun 9 13:37:03 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Kiszka X-Patchwork-Id: 29014 Received: from vger.kernel.org (vger.kernel.org [209.132.176.167]) by demeter.kernel.org (8.14.2/8.14.2) with ESMTP id n59DbSiQ007733 for ; Tue, 9 Jun 2009 13:37:28 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754016AbZFINhU (ORCPT ); Tue, 9 Jun 2009 09:37:20 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1753049AbZFINhU (ORCPT ); Tue, 9 Jun 2009 09:37:20 -0400 Received: from gecko.sbs.de ([194.138.37.40]:18517 "EHLO gecko.sbs.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751130AbZFINhT (ORCPT ); Tue, 9 Jun 2009 09:37:19 -0400 Received: from mail1.sbs.de (localhost [127.0.0.1]) by gecko.sbs.de (8.12.11.20060308/8.12.11) with ESMTP id n59Db4ZL031790; Tue, 9 Jun 2009 15:37:04 +0200 Received: from [139.25.109.167] (mchn012c.ww002.siemens.net [139.25.109.167] (may be forged)) by mail1.sbs.de (8.12.11.20060308/8.12.11) with ESMTP id n59Db3oh031755; Tue, 9 Jun 2009 15:37:04 +0200 Message-ID: <4A2E657F.8080908@siemens.com> Date: Tue, 09 Jun 2009 15:37:03 +0200 From: Jan Kiszka User-Agent: Mozilla/5.0 (X11; U; Linux i686 (x86_64); de; rv:1.8.1.12) Gecko/20080226 SUSE/2.0.0.12-1.1 Thunderbird/2.0.0.12 Mnenhy/0.7.5.666 MIME-Version: 1.0 To: Avi Kivity CC: kvm-devel , Marcelo Tosatti Subject: [PATCH v2 2/2] kvm: x86: Drop useless atomic test from timer function References: <4A2E2B3B.5020408@siemens.com> In-Reply-To: <4A2E2B3B.5020408@siemens.com> Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org The current code tries to optimize the setting of KVM_REQ_PENDING_TIMER but used atomic_inc_and_test - which always returns true unless pending had the invalid value of -1 on entry. This patch drops the test part preserving the original semantic but expressing it less confusingly. Signed-off-by: Jan Kiszka --- arch/x86/kvm/timer.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) -- To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/arch/x86/kvm/timer.c b/arch/x86/kvm/timer.c index 36054e9..8dd1a55 100644 --- a/arch/x86/kvm/timer.c +++ b/arch/x86/kvm/timer.c @@ -15,9 +15,9 @@ static int __kvm_timer_fn(struct kvm_vcpu *vcpu, struct kvm_timer *ktimer) * case anyway. */ if (ktimer->reinject || !atomic_read(&ktimer->pending)) { + atomic_inc(&ktimer->pending); /* FIXME: this code should not know anything about vcpus */ - if (!atomic_inc_and_test(&ktimer->pending)) - set_bit(KVM_REQ_PENDING_TIMER, &vcpu->requests); + set_bit(KVM_REQ_PENDING_TIMER, &vcpu->requests); } if (waitqueue_active(q))