From mboxrd@z Thu Jan 1 00:00:00 1970 From: Paolo Bonzini Subject: Re: [PATCH 5/5] kvm: optimize GFN to memslot lookup with large slots amount Date: Tue, 02 Dec 2014 19:45:21 +0100 Message-ID: <547E08C1.3090708@redhat.com> References: <1417454967-4465-1-git-send-email-imammedo@redhat.com> <1417454967-4465-6-git-send-email-imammedo@redhat.com> <20141202173350.GA11312@potion.brq.redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: QUOTED-PRINTABLE Cc: linux-kernel@vger.kernel.org, kvm@vger.kernel.org To: =?UTF-8?B?UmFkaW0gS3LEjW3DocWZ?= , Igor Mammedov Return-path: In-Reply-To: <20141202173350.GA11312@potion.brq.redhat.com> Sender: linux-kernel-owner@vger.kernel.org List-Id: kvm.vger.kernel.org On 02/12/2014 18:33, Radim Kr=C4=8Dm=C3=A1=C5=99 wrote: >> > + while (start < end) { >> > + slot =3D start + (end - start) / 2; >> > + >> > + if (gfn >=3D memslots[slot].base_gfn) > (Even thought division is costly, I think that checking here if 'slot= ' > is the one we want wouldn't help very much.) >=20 Division by an unsigned is just a right shift. Division by signed integer is a right shift + conditional move. We can change / 2 to explicit >> 1, or change start and end to unsigned, or both. Paolo