From: Dan Magenheimer Subject: RE: [RFC] Replacing Xen's xmalloc engine and(?) API Date: Sun, 12 Oct 2008 10:31:39 -0700 (PDT) Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=Windows-1252 Content-Transfer-Encoding: quoted-printable Return-path: 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: Keir Fraser , "Xen-Devel (E-mail)" Cc: Diwaker Gupta , nitingupta910@gmail.com, kurt.hackel@oracle.com List-Id: xen-devel@lists.xenproject.org > >> This sounds crazy to me. xmalloc() should work like malloc(). > >=20 > > While I agree completely in principle, abstractions can be costly. > > In this case, the fact that xmalloc(PAGE_SIZE-1) actually uses > > 2*PAGE_SIZE of space (and fails even if there are lots of free > > pages but no pair of contiguous pages) is an undocumented=20 > consequence > > of the underlying implementation... which is not entirely > > unreasonable in user-land but is IMHO questionable in the guts > > of a hypervisor where memory shouldn't be accidentally wasted. > >=20 > > To date, Xen hasn't focused much on optimizing memory usage but > > I think that will change over the next year or two. >=20 > This wastage should be empirically measured by=20 > instrumentation and then > optimisations made where worthwhile. That is somewhat=20 > orthogonal to the > issue of what represents a sensible interface to xmalloc(),=20 > except to say > that I would generally prefer a more sophisticated and=20 > efficient mechanism > behind a simple interface, rather than punt complexity into=20 > callers (by > making the costs hidden by the simple interface excessive and hence > unusable; or by complicating the interface with weird constraints). Fair enough. I will mimic the xmalloc API then. However, I *would* like to export (via #define in xmalloc.h or function call or something) the definition of DELTA (e.g. the xmalloc space overhead) so my caller-side code can avoid the wastage. I never want to accidentally xmalloc two pages when heap-alloc'ing one page will do. > My point in bringing up SLUB is that I assume it's an=20 > allocator designed to > work reasonably well across a range of allocation-request-size > distributions, including those containing requests of size > x-pages-minus-a-bit. I'd rather have a more complicated=20 > allocator than a > more complicated xmalloc() interface. I'm no slab/slub expert but I think the interface only works well with fixed-size objects and when several of the fixed-size objects can be crammed into a single page. I have a large set of objects that are essentially random in size (but all less than or equal to a page). Dan