From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Michael S. Tsirkin" Subject: Re: [PATCH -v3] KVM: x86: lapic: Clean up find_highest_vector() and count_vectors() Date: Wed, 5 Sep 2012 12:51:27 +0300 Message-ID: <20120905095126.GA10531@redhat.com> References: <20120830101033.GA19622@redhat.com> <20120830192439.3e088595.yoshikawa.takuya@oss.ntt.co.jp> <20120830104458.GA19997@redhat.com> <20120830213019.82a822da.yoshikawa.takuya@oss.ntt.co.jp> <20120830132131.GB21132@redhat.com> <20120831010956.000856ead3c6f96dbe2bec46@gmail.com> <20120830164923.GA22024@redhat.com> <20120905173031.59581bb9.yoshikawa.takuya@oss.ntt.co.jp> <20120905092649.GD10326@redhat.com> <20120905184026.9aeddbc1.yoshikawa.takuya@oss.ntt.co.jp> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: Takuya Yoshikawa , Marcelo Tosatti , avi@redhat.com, kvm@vger.kernel.org To: Takuya Yoshikawa Return-path: Received: from mx1.redhat.com ([209.132.183.28]:37283 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752771Ab2IEJuH (ORCPT ); Wed, 5 Sep 2012 05:50:07 -0400 Content-Disposition: inline In-Reply-To: <20120905184026.9aeddbc1.yoshikawa.takuya@oss.ntt.co.jp> Sender: kvm-owner@vger.kernel.org List-ID: On Wed, Sep 05, 2012 at 06:40:26PM +0900, Takuya Yoshikawa wrote: > On Wed, 5 Sep 2012 12:26:49 +0300 > "Michael S. Tsirkin" wrote: > > > It's not guaranteed if another thread can modify the bitmap. > > Is this the case here? If yes we need at least ACCESS_ONCE. > > In this patch, using the wrapper function to read out a register > value forces compilers not to do bad things. It's not robust. Compiler is free to optimize it out, and it frequently does that. > But I agree that it is not a good API. > > I would like to use fls() rather than ACCESS_ONCE if it's > really needed. Sure, makes sense. > > > Anyway, I'm now thinking that we do not care about such > > > things here, and can just follow your advice, yes? > > > > Unless you see an issue with it ... > > Although I read the code, I'm not sure. > > But this code is apparently not so critical for performance > that we can simply use fls(). Yes. I guess if it becomes critical we'll need to add a cache anyway. > If I can remove likely() and use proper macros, that's enough > for me. Me too. > Thanks, > Takuya