From mboxrd@z Thu Jan 1 00:00:00 1970 From: Avi Kivity Subject: Re: [PATCH 4/7] KVM: sort memslots and use binary search to search the right slot Date: Tue, 22 Feb 2011 16:25:23 +0200 Message-ID: <4D63C753.3030906@redhat.com> References: <4D636EF8.60800@cn.fujitsu.com> <4D636FE8.8000505@cn.fujitsu.com> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Cc: Marcelo Tosatti , LKML , KVM , Alex Williamson To: Xiao Guangrong Return-path: In-Reply-To: <4D636FE8.8000505@cn.fujitsu.com> Sender: linux-kernel-owner@vger.kernel.org List-Id: kvm.vger.kernel.org On 02/22/2011 10:12 AM, Xiao Guangrong wrote: > Sort memslots then search the slot with binary search to speed up the > slot searching > I'm not sure if a binary search is the right algorithm here. It introduces a lot of branches which may be mispredicted. Options we've discussed are: - Sort slots by size, use linear search (so the largest slots are found quickly) - Weighted balanced tree http://en.wikipedia.org/wiki/Weight-balanced_tree, use weight == slot size Both options still make the miss case (mmio) slow. We could cache the result of a miss in an spte by using a reserved bit, and checking the page fault error code (or seeing if we get an ept violation or ept misconfiguration), so if we get repeated mmio on a page, we don't need to search the slot list/tree. -- error compiling committee.c: too many arguments to function