From mboxrd@z Thu Jan 1 00:00:00 1970 From: Radim =?utf-8?B?S3LEjW3DocWZ?= Subject: Re: [PATCH 1/3] kvm: memslots: track id_to_index changes during the insertion sort Date: Fri, 14 Nov 2014 15:44:22 +0100 Message-ID: <20141114144422.GC6801@potion.brq.redhat.com> References: <1415963522-5255-1-git-send-email-pbonzini@redhat.com> <1415963522-5255-2-git-send-email-pbonzini@redhat.com> <20141114133500.GA10593@potion.brq.redhat.com> <546611E5.2090209@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, yoshikawa_takuya_b1@lab.ntt.co.jp, imammedo@redhat.com To: Paolo Bonzini Return-path: Content-Disposition: inline In-Reply-To: <546611E5.2090209@redhat.com> Sender: linux-kernel-owner@vger.kernel.org List-Id: kvm.vger.kernel.org 2014-11-14 15:29+0100, Paolo Bonzini: > On 14/11/2014 14:35, Radim Kr=C4=8Dm=C3=A1=C5=99 wrote: > > We are replacing in a sorted array, so the the direction of our > > traversal doesn't change, (and we could lose one tab level here,) > >=20 > > if (new->npages < mslots[i].npages) { > > while (i < (KVM_MEM_SLOTS_NUM - 1) && > > new->npages < mslots[i + 1].npages) { > > mslots[i] =3D mslots[i + 1]; > > slots->id_to_index[mslots[i].id] =3D i; > > i++; > > } > > else if (new->npages > mslots[i].npages) > > while (i > 0 && > > new->npages > mslots[i - 1].npages) { > > mslots[i] =3D mslots[i - 1]; > > slots->id_to_index[mslots[i].id] =3D i; > > i--; > > } > >=20 > > (I guess you don't want me to abstract these two loops further :) >=20 > Right. You do not need the "else if" as long as you keep the outer "= if > (new->npages !=3D mslots[i].npages)". True, I'm just an indentation hater. > > (We'll have to change it into an interval tree, or something, if th= e > > number of slots rises anyway.) >=20 > I don't think that's needed, actually. gfn_to_page and gfn_to_memslo= t > are very rarely in the profiles with EPT. Ah, that replaces my reply to Igor, thanks.