From mboxrd@z Thu Jan 1 00:00:00 1970 From: Marcelo Tosatti Subject: Re: [PATCH] KVM: x86: lapic: Fix the misuse of likely() in find_highest_vector() Date: Mon, 27 Aug 2012 17:25:42 -0300 Message-ID: <20120827202542.GA1414@amt.cnet> References: <20120824181549.e1535ae0.yoshikawa.takuya@oss.ntt.co.jp> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: avi@redhat.com, kvm@vger.kernel.org To: Takuya Yoshikawa Return-path: Received: from mx1.redhat.com ([209.132.183.28]:52796 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754632Ab2H0Uya (ORCPT ); Mon, 27 Aug 2012 16:54:30 -0400 Content-Disposition: inline In-Reply-To: <20120824181549.e1535ae0.yoshikawa.takuya@oss.ntt.co.jp> Sender: kvm-owner@vger.kernel.org List-ID: On Fri, Aug 24, 2012 at 06:15:49PM +0900, Takuya Yoshikawa wrote: > Although returning -1 should be likely according to the likely(), > the ASSERT in apic_find_highest_irr() will be triggered in such a case. > It seems that this optimization is not working as expected. > > This patch simplifies the logic to mitigate this issue: search for the > first non-zero word in a for loop and then use __fls() if found. When > nothing found, we are out of the loop, so we can just return -1. Numbers please? > Signed-off-by: Takuya Yoshikawa > --- > arch/x86/kvm/lapic.c | 18 ++++++++++-------- > 1 files changed, 10 insertions(+), 8 deletions(-)