Re: [LAD] LV2 realtime safe memory pool extension

From: David Olofson <david@email-addr-hidden>
Date: Fri Nov 09 2007 - 03:38:01 EET

On Friday 09 November 2007, Stefano D'Angelo wrote:
[...]
> > Yes, that's exactly my point, but I think it needs to deal with
> > arbitrary size chunks to actually be able to serve that purpose in
> > real applications.
>
> IIRC the TLSF allocator can do that.

Yes, that's what it does - which is why I suggested it. ;-)

[...]
> > Wouldn't it be more useful with some interface that allows plugins
> > to request memory in a non-blocking manner, and if instant
> > allocation fails, have the host notify the plugin when the memory
> > is available?
> > Basically, a malloc() call that means "If I can't have this memory
> > right away, please expand the pool so I can have it later!"
>
> Mmmm.. I guess it's not easy to resize the pool in a rt-safe way.

Well, not really; you could just wrap the memory manager, adding
a 'manager' field to every chunk. Then you can just throw in another
TLSF manager instance when you need more memory. The 'manager' field
will point the free() wrapper to the correct manager instance.

However, a nice, clean, efficient solution might be a bit harder to
come up with, I think. IIRC, the current TLSF implementations scale
various internal structures and stuff to fit the pool size, so you
can't just bump the "brk limit" later.

Maybe hack TLSF to take a "maximum address span" init argument, so you
can extend the pool as needed up to that limit? You'd just allocate
new blocks with malloc() and instruct the hacked TLSF to extend to
the end of that block, while pre-allocating (throwing away) any holes
caused by unrelated malloc()s.
 

> And even if you have some background thread doing it when it's
> needed, I think it's very hard to do that while plugins are running,
> and so allocating and modifying on that memory.

Yes, that's why you can't realloc() the pool. You really have to add
new blocks of memory to it.

//David Olofson - Programmer, Composer, Open Source Advocate

.------- http://olofson.net - Games, SDL examples -------.
| http://zeespace.net - 2.5D rendering engine |
| http://audiality.org - Music/audio engine |
| http://eel.olofson.net - Real time scripting |
'-- http://www.reologica.se - Rheology instrumentation --'
_______________________________________________
Linux-audio-dev mailing list
Linux-audio-dev@email-addr-hidden
http://lists.linuxaudio.org/mailman/listinfo/linux-audio-dev
Received on Fri Nov 9 04:15:02 2007

This archive was generated by hypermail 2.1.8 : Fri Nov 09 2007 - 04:15:03 EET