Re: [PATCH -v3] KVM: x86: lapic: Clean up find_highest_vector() and count_vectors()

2012-09-05 Thread Michael S. Tsirkin
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 wrap

Re: [PATCH -v3] KVM: x86: lapic: Clean up find_highest_vector() and count_vectors()

2012-09-05 Thread Takuya Yoshikawa
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.

Re: [PATCH -v3] KVM: x86: lapic: Clean up find_highest_vector() and count_vectors()

2012-09-05 Thread Michael S. Tsirkin
On Wed, Sep 05, 2012 at 05:30:31PM +0900, Takuya Yoshikawa wrote: > On Thu, 30 Aug 2012 19:49:23 +0300 > "Michael S. Tsirkin" wrote: > > > On Fri, Aug 31, 2012 at 01:09:56AM +0900, Takuya Yoshikawa wrote: > > > On Thu, 30 Aug 2012 16:21:31 +0300 > > > "Michael S. Tsirkin" wrote: > > > > > > >

Re: [PATCH -v3] KVM: x86: lapic: Clean up find_highest_vector() and count_vectors()

2012-09-05 Thread Takuya Yoshikawa
On Thu, 30 Aug 2012 19:49:23 +0300 "Michael S. Tsirkin" wrote: > On Fri, Aug 31, 2012 at 01:09:56AM +0900, Takuya Yoshikawa wrote: > > On Thu, 30 Aug 2012 16:21:31 +0300 > > "Michael S. Tsirkin" wrote: > > > > > > +static u32 apic_read_reg(int reg_off, void *bitmap) > > > > +{ > > > > +

Re: [PATCH -v3] KVM: x86: lapic: Clean up find_highest_vector() and count_vectors()

2012-08-30 Thread Michael S. Tsirkin
On Fri, Aug 31, 2012 at 01:09:56AM +0900, Takuya Yoshikawa wrote: > On Thu, 30 Aug 2012 16:21:31 +0300 > "Michael S. Tsirkin" wrote: > > > > +static u32 apic_read_reg(int reg_off, void *bitmap) > > > +{ > > > + return *((u32 *)(bitmap + reg_off)); > > > +} > > > + > > > > Contrast with apic_set

Re: [PATCH -v3] KVM: x86: lapic: Clean up find_highest_vector() and count_vectors()

2012-08-30 Thread Takuya Yoshikawa
On Thu, 30 Aug 2012 16:21:31 +0300 "Michael S. Tsirkin" wrote: > > +static u32 apic_read_reg(int reg_off, void *bitmap) > > +{ > > + return *((u32 *)(bitmap + reg_off)); > > +} > > + > > Contrast with apic_set_reg which gets apic, > add fact that all callers invoke REG_POS and you will > see

Re: [PATCH -v3] KVM: x86: lapic: Clean up find_highest_vector() and count_vectors()

2012-08-30 Thread Michael S. Tsirkin
On Thu, Aug 30, 2012 at 09:30:19PM +0900, Takuya Yoshikawa wrote: > find_highest_vector() and count_vectors(): > - Instead of using magic values, define and use proper interfaces >to access registers. > > find_highest_vector(): > - Remove likely() which is there only for historical reasons a

[PATCH -v3] KVM: x86: lapic: Clean up find_highest_vector() and count_vectors()

2012-08-30 Thread Takuya Yoshikawa
find_highest_vector() and count_vectors(): - Instead of using magic values, define and use proper interfaces to access registers. find_highest_vector(): - Remove likely() which is there only for historical reasons and not doing correct branch predictions anymore. Using such heuristics