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

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


  • To: Juergen Gross <jgross@xxxxxxxx>
  • From: Ian Jackson <ian.jackson@xxxxxxxxxx>
  • Date: Wed, 20 May 2020 15:49:59 +0100
  • Authentication-results: esa2.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none
  • Cc: "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>, Wei Liu <wl@xxxxxxx>, Roger Pau Monné <roger.pau@xxxxxxxxxx>
  • Delivery-date: Wed, 20 May 2020 14:50:12 +0000
  • Ironport-sdr: Z9Y9y88xAnxg57My9pEQR+PfbEdb7JKaUhhBfu5OWwXLjqx4JP9yQwH7SiSyfbfHfgaiaZ7jEp 5IM0RJ7LqubvuFkknKBHuzVLoHsiEooPkhyIZWzbfl42TMsH41NJzEiAk/0PywaM7Ss6Siv27o jejkRoQUc7n+ho3lAEiwI6Z375EmweYxM0lVMgCMtmjvJu7kmV4PJP729DIiJ5XdLLUQwBuCZ7 3Qlo6pEP8z/5WtWtOOvO7lqRqsOXnOMG72hg+2vGeNxBmyCLTVuT48vKf0mvQGuljZRTMaUfrx tm0=
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

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>

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.

Anyway, these observations are no criticism of Juergen's patch.

Regards,
Ian.



 


Rackspace

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