[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] tools/libxengnttab: correct size of allocated memory


  • To: Ian Jackson <ian.jackson@xxxxxxxxxx>
  • From: Roger Pau Monné <roger.pau@xxxxxxxxxx>
  • Date: Wed, 20 May 2020 17:56:21 +0200
  • Authentication-results: esa6.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none
  • Cc: Juergen Gross <jgross@xxxxxxxx>, "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>, Wei Liu <wl@xxxxxxx>
  • Delivery-date: Wed, 20 May 2020 15:56:33 +0000
  • Ironport-sdr: huEG3xWiDCZyS+UsXq1qLYEvn4On/A+8tuklwQxifEsjCpsyoR4RgKAybu41l1kw/ESMuBa/n2 uWRedc87mXLU3kj/MHcPJcayn5uq93XrsfkCKd6dt8spKJDHxn7P/ChTopgPqJkawdMY5QS8vc 6vVNOTBRw93PCkozaEQS7lI0nsVN6RSCqItx3zHc73NUXg1QMMieRe3/YzxYfNHQC9bPd0IuaC nroz7Gu/0CtK/0/O9zjLiVk2Ds1W4I3E83aMwDprihz/GWitkr6eyACPiBgwCoBaZX4epMKQg8 TIA=
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On Wed, May 20, 2020 at 03:49:59PM +0100, Ian Jackson wrote:
> Juergen Gross writes ("[PATCH] tools/libxengnttab: correct size of allocated 
> memory"):
> > The size of the memory allocated for the IOCTL_GNTDEV_MAP_GRANT_REF
> > ioctl() parameters is calculated wrong, which results in too much
> > memory allocated.
> 
> Added Roger to CC.
> 
> Firstly,
> 
> Reviewed-by: Ian Jackson <ian.jackson@xxxxxxxxxxxxx>

For the FreeBSD bits:

Reviewed-by: Roger Pau Monné <roger.pau@xxxxxxxxxx>

> 
> Thank you.
> 
> 
> But, looking at this code, why on earth what the ?
> 
> The FreeBSD code checks to see if it's less than a page and if so uses
> malloc and otherwise uses mmap !  Why not unconditionally use malloc ?
> 
> Likewise, the Linux code has its own mmap-based memory-obtainer.  ISTM
> that malloc is probably going to be better.  Often it will be able to
> give out even a substantial amount without making a syscall.
> 
> Essentially, we have two (similar but not identical) tiny custom
> memory allocators here.  Also, the Linux and FreeBSD code are
> remarkably similar which bothers me.

Right. This is due to the FreeBSD file being mostly a clone of the
Linux one. I agree the duplication could be abstracted away.

I really have no idea why malloc or mmap is used, maybe at some point
requesting regions > PAGE_SIZE was considered faster using mmap
directly?

Thanks, Roger.



 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.