From mboxrd@z Thu Jan 1 00:00:00 1970 From: Dave Scott Subject: Re: [PATCH] linux_gntshr_munmap: munmap takes a length, not a page count Date: Wed, 3 Sep 2014 16:49:58 +0000 Message-ID: <83BA6B8C-3438-460F-8757-D9F22D4F85D0@citrix.com> References: <1409573807-15801-1-git-send-email-dave.scott@citrix.com> <1409752879.23789.29.camel@kazak.uk.xensource.com> <10A87768-4C5B-4870-939A-55E9B6E83977@citrix.com> Mime-Version: 1.0 Content-Type: text/plain; charset="windows-1252" Content-Transfer-Encoding: quoted-printable Return-path: Received: from mail6.bemta14.messagelabs.com ([193.109.254.103]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1XPDkv-0000yJ-4A for xen-devel@lists.xenproject.org; Wed, 03 Sep 2014 16:50:01 +0000 In-Reply-To: <10A87768-4C5B-4870-939A-55E9B6E83977@citrix.com> Content-Language: en-US Content-ID: <2C3C032B7DB3BE4BB77BF55FBC8B2E55@citrix.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Ian Campbell Cc: "xen-devel@lists.xenproject.org" , Stefano Stabellini , David Vrabel , Ian Jackson List-Id: xen-devel@lists.xenproject.org On 3 Sep 2014, at 16:48, David Scott wrote: > = > On 3 Sep 2014, at 15:01, Ian Campbell wrote: > = >> On Mon, 2014-09-01 at 13:16 +0100, David Scott wrote: >>> This fixes a bug where if a client shares more than 1 page, the >>> munmap call fails to clean up everything. A process which does >>> a lot of sharing and unsharing can run out of resources. >> = >> The doc comment on xc_gntshr_munmap does say count is in pages, so your >> change is correct but all of the in tree callers seem to pass a number >> of bytes not a number of pages. i.e. everything in tools/libvchan passes >> n*PAGE_SIZE. > = > Good point. > = >> So I don't think this change is complete without also updating those. > = > I=92ll resubmit with the in-tree callers fixed. Also it looks like xc_gnttab_munmap (gnttab not gntshr) uses pages in both = the API and implementation, but libvchan is supplying bytes. I=92ll fix vch= an here too. Dave > = > Thanks, > Dave > = >> = >> Ian. >> = >>> = >>> Signed-off-by: David Scott >>> --- >>> tools/libxc/xc_linux_osdep.c | 2 +- >>> 1 file changed, 1 insertion(+), 1 deletion(-) >>> = >>> diff --git a/tools/libxc/xc_linux_osdep.c b/tools/libxc/xc_linux_osdep.c >>> index 86bff3e..a19e4b6 100644 >>> --- a/tools/libxc/xc_linux_osdep.c >>> +++ b/tools/libxc/xc_linux_osdep.c >>> @@ -847,7 +847,7 @@ static void *linux_gntshr_share_pages(xc_gntshr *xc= h, xc_osdep_handle h, >>> static int linux_gntshr_munmap(xc_gntshr *xcg, xc_osdep_handle h, >>> void *start_address, uint32_t count) >>> { >>> - return munmap(start_address, count); >>> + return munmap(start_address, count * XC_PAGE_SIZE); >>> } >>> = >>> static struct xc_osdep_ops linux_gntshr_ops =3D { >> = >> = > =