9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
* Re: [9fans] xspanalloc?
@ 2005-01-04  4:15 jmk
  0 siblings, 0 replies; 3+ messages in thread
From: jmk @ 2005-01-04  4:15 UTC (permalink / raw)
  To: 9fans

This is the comment used to be at the beginning
of the alloc code:

/*
 * Plan 9 has two kernel allocators, the x... routines provide a first
 * fit hole allocator which should be used for permanent or large structures.
 * Routines are provided to allocate aligned memory which does not cross
 * arbitrary 2^n boundaries. A second allocator malloc, smalloc, free is
 * a 2n bucket allocator which steals from the x routines. This should
 * be used for small frequently used structures.
 */

That was before the 2n bucket allocator was replaced by the pool allocator.

This comment used to be before the the xspanalloc function:

/*
 * NB. spanalloc memory will cause a panic if free'd
 */

Ron Minnich and Andrey Mirtchovski recently found a bug in the xalloc
code introduced during the conversion to the pool allocator which caused
bad things to happen.


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [9fans] xspanalloc?
  2005-01-04  1:21 ` [9fans] xspanalloc? Tim Newsham
@ 2005-01-04  1:50   ` Russ Cox
  0 siblings, 0 replies; 3+ messages in thread
From: Russ Cox @ 2005-01-04  1:50 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

xspanalloc is intended to be called only a few times
and can stand to leak.  there is now a mallocalign
that takes the same arguments but can be freed.

align says "align this on an n-byte boundary".
span says "don't cross an n-byte boundary".

it's true that align implies span, but it doesn't
make a very good implementation of span.
consider allocating 32 bytes that cannot span
a kilobyte boundary.  there are a lot more choices
than when allocating 32 bytes that are aligned on
a kilobyte boundary.

russ

On Mon, 3 Jan 2005 15:21:33 -1000 (HST), Tim Newsham <newsham@lava.net> wrote:
> I'm not sure I understand the intention of the xspanalloc arguments:
> 
>    void* xspanalloc(ulong size, int align, ulong span);
> 
> It seems like the "align" and "span" arguments are used in similar
> ways.  However, when using the "align" argument, the scrap space
> allocated is never freed.  The "align" case does free up memory
> but also has a 2nd freeing operation that looks strange.  What
> are the semantics of these arguments?
> 
> Tim N.
>


^ permalink raw reply	[flat|nested] 3+ messages in thread

* [9fans] xspanalloc?
  2005-01-03 22:00 [9fans] usb audio devices list on supported pc hardware wiki page Axel Belinfante
@ 2005-01-04  1:21 ` Tim Newsham
  2005-01-04  1:50   ` Russ Cox
  0 siblings, 1 reply; 3+ messages in thread
From: Tim Newsham @ 2005-01-04  1:21 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

I'm not sure I understand the intention of the xspanalloc arguments:

   void* xspanalloc(ulong size, int align, ulong span);

It seems like the "align" and "span" arguments are used in similar
ways.  However, when using the "align" argument, the scrap space
allocated is never freed.  The "align" case does free up memory
but also has a 2nd freeing operation that looks strange.  What
are the semantics of these arguments?

Tim N.


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2005-01-04  4:15 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-01-04  4:15 [9fans] xspanalloc? jmk
  -- strict thread matches above, loose matches on Subject: below --
2005-01-03 22:00 [9fans] usb audio devices list on supported pc hardware wiki page Axel Belinfante
2005-01-04  1:21 ` [9fans] xspanalloc? Tim Newsham
2005-01-04  1:50   ` Russ Cox

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).