From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([140.186.70.92]:34247) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QlgNI-00081O-02 for qemu-devel@nongnu.org; Tue, 26 Jul 2011 08:04:37 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QlgNH-000873-0G for qemu-devel@nongnu.org; Tue, 26 Jul 2011 08:04:35 -0400 Received: from mx1.redhat.com ([209.132.183.28]:26487) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QlgNG-00086v-Jm for qemu-devel@nongnu.org; Tue, 26 Jul 2011 08:04:34 -0400 Message-ID: <4E2EAD4C.1090701@redhat.com> Date: Tue, 26 Jul 2011 15:04:28 +0300 From: Avi Kivity MIME-Version: 1.0 References: <1311679582-11211-1-git-send-email-avi@redhat.com> <1311679582-11211-5-git-send-email-avi@redhat.com> <4E2EA6DA.4000006@redhat.com> <4E2EA71A.7000106@redhat.com> <4E2EAA44.105@redhat.com> In-Reply-To: <4E2EAA44.105@redhat.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH v2 04/23] memory: merge adjacent segments of a single memory region List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Paolo Bonzini Cc: qemu-devel@nongnu.org, kvm@vger.kernel.org On 07/26/2011 02:51 PM, Paolo Bonzini wrote: > On 07/26/2011 01:38 PM, Avi Kivity wrote: >>> >>> if (j != i) { >>> >>>> + memmove(&view->ranges[i], &view->ranges[j], >>>> + (view->nr - j) * sizeof(view->ranges[j])); >>>> + view->nr -= j - i; >>>> + } >>> >>> } >> >> Seems to work both ways? > > Sure, but you're pointlessly memmove-ing memory over itself. I'm not > sure how many segments a single memory region will usually have, but > it's better to be safe. This will never be an issue in practice. We expect to have few FlatRanges (O(100)), simplify() will be called very rarely (never during normal operations; a few dozen times during boot; a few during hotplug); everything is in L1 cache; and the cost will be dwarfed by any calls to kvm (if enabled). -- error compiling committee.c: too many arguments to function