From mboxrd@z Thu Jan 1 00:00:00 1970 From: Sasha Levin Subject: Re: [PATCH] MMIO: Make coalesced mmio use a device per zone Date: Tue, 19 Jul 2011 14:45:59 +0300 Message-ID: <1311075959.9174.14.camel@lappy> References: <1311063011-4430-1-git-send-email-levinsasha928@gmail.com> <4E2544F3.9030203@redhat.com> <1311069182.9174.1.camel@lappy> <4E255584.1030003@redhat.com> <1311070673.9174.4.camel@lappy> <4E255D44.8000107@redhat.com> <1311074527.9174.13.camel@lappy> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Cc: kvm@vger.kernel.org, Marcelo Tosatti To: Avi Kivity Return-path: Received: from mail-ww0-f44.google.com ([74.125.82.44]:55236 "EHLO mail-ww0-f44.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752183Ab1GSLqZ (ORCPT ); Tue, 19 Jul 2011 07:46:25 -0400 Received: by wwe5 with SMTP id 5so4104153wwe.1 for ; Tue, 19 Jul 2011 04:46:24 -0700 (PDT) In-Reply-To: <1311074527.9174.13.camel@lappy> Sender: kvm-owner@vger.kernel.org List-ID: On Tue, 2011-07-19 at 14:22 +0300, Sasha Levin wrote: > On Tue, 2011-07-19 at 13:32 +0300, Avi Kivity wrote: > > On 07/19/2011 01:17 PM, Sasha Levin wrote: > > > On Tue, 2011-07-19 at 12:59 +0300, Avi Kivity wrote: > > > > On 07/19/2011 12:53 PM, Sasha Levin wrote: > > > > > > Make these per-guest instead of global. The lock may be contended, and > > > > > > the list shouldn't hold items from different guests (why is it needed, > > > > > > anyway?) > > > > > > > > > > > > > > > > We only need the list for removal, since we only have the range we want > > > > > to remove, and we want to find all devices which contain this range. > > > > > > > > > > > > > All devices in the same guest which contain this range. Your patch > > > > removes devices from all guests. > > > > > > > > > > Yup. I've messed up guest-locality. Will fix. > > > > > > Also, I found this comment when increasing NR_IOBUS_DEVS: > > > > > > /* > > > * It would be nice to use something smarter than a linear search, TBD... > > > * Thankfully we dont expect many devices to register (famous last words :), > > > * so until then it will suffice. At least its abstracted so we can change > > > * in one place. > > > */ > > > > > > Since so far we've registered 5-6 devices, and now it may increase > > > significantly (since we may want to do the same change to ioeventfds, > > > which work the same way) - how would you feel if we make devices > > > register range(s) and do a rbtree lookup instead of a linear search? > > > > > > > It makes sense. In fact your change is a good first step - so far it > > was impossible to to a clever search since the seaching code was not > > aware of the ranges (and could not be, since the single coalesced mmio > > device had multiple ranges). > > > > Rather than an rbtree, I suggest putting all ranges in an array and > > sorting it, then using binary search. > > > > Why array over rbtree? An array would be heavier on register/unregister, > and using rbtree would let us easily eliminate any max device limit we > had so far. > > We've had good experience using interval rbtree in /tools/kvm where we > did PIO and MMIO device mapping using an augmented rbtree which made > range lookups very simple and fast. > Ah, rcu... Array it is :) -- Sasha.