From: Samuel Thibault Subject: Re: Re: [Xen-changelog] [xen-unstable] stubdom: mmap on /dev/mem support Date: Wed, 21 Oct 2009 18:13:14 +0200 Message-ID: <20091021161314.GQ4693@const.bordeaux.inria.fr> References: <200910211510.n9LFAGT7019922@xenbits.xensource.com> <20091021153649.GM4693@const.bordeaux.inria.fr> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Return-path: Content-Disposition: inline In-Reply-To: List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: Stefano Stabellini Cc: "xen-devel@lists.xensource.com" , "xen-changelog@lists.xensource.com" List-Id: xen-devel@lists.xenproject.org Optimize mmap(open("/dev/mem")) Set map_frames_ex's stride parameter to 0 and increment to 1 to avoid building an explicit list of mfns. Signed-Off-By: Samuel Thibault diff -r 37829fd7c1e3 extras/mini-os/lib/sys.c --- a/extras/mini-os/lib/sys.c Wed Oct 21 16:08:28 2009 +0100 +++ b/extras/mini-os/lib/sys.c Wed Oct 21 18:10:33 2009 +0200 @@ -1256,11 +1268,8 @@ unsigned long zero = 0; return map_frames_ex(&zero, n, 0, 0, 1, DOMID_SELF, 0, 0); } else if (files[fd].type == FTYPE_MEM) { - int i; - unsigned long mfns[n]; - for (i = 0; i < n; i++) - mfns[i] = ((unsigned long) offset + (i * PAGE_SIZE)) >> PAGE_SHIFT; - return map_frames_ex(mfns, n, 1, 0, 1, DOMID_IO, 0, _PAGE_PRESENT|_PAGE_RW); + unsigned long first_mfn = offset >> PAGE_SHIFT; + return map_frames_ex(&first_mfn, n, 0, 1, 1, DOMID_IO, 0, _PAGE_PRESENT|_PAGE_RW); } else ASSERT(0); }