Hi Paul,

Am 07.11.24 um 18:51 schrieb Paul Boddie:
Hello,

I thought I might as well ask this since the mailing list has been somewhat
active recently. I have been testing some of my software, but after a certain
period of time, I experience errors of the following form:

l4re_kernel: ERROR: more-mem(1000): Cannot provide more memory.
l4re_kernel: ERROR: mmap() called: unimplemented! size=100000

As far as I can tell, uclibc_morecore and mmap in...

pkg/l4re-core/l4re_kernel/server/src/mem.cc

...are respectively responsible for these errors, the former being called by
__malloc_trim, itself called by free in...

pkg/l4re-core/uclibc/lib/contrib/uclibc/libc/stdlib/malloc-standard/free.c

Looking at the uclibc_morecore implementation, it seems that the "program
break" is defined only once, with a dataspace of 64 pages being allocated, and
any subsequent sbrk call will not cause this allocated space to be extended
further. Have I understood this situation correctly?

Yes. The l4re_kernel has a static 64K heap for its own allocations. So far this has been enough and when it is exhausted, it's usually a sign of something going wrong somewhere else.


As always, I assume that I am making some kind of mistake, in this case
probably not deallocating memory when I should be and thus exhausting the
available space.

How long is your application running? Is it doing a lot of (small) allocations and deallocations? The l4re_kernel maintains the memory map for your application. For each entry in this map memory from the heap is used. So in case of a lot of small allocations this map grows and might use all of the heap. However, I would also expect a visible slowdown in your application on each memory de/allocation. Are you seeing any of this?


Are there any convenient ways of monitoring memory allocation
in L4Re?

From the top of my head: Try the `l4re_dbg` flags: Add `l4re_dbg = 0xff` to your application startup in ned as parameter next to the caps table.
example:
https://github.com/kernkonzept/mk/blob/master/conf/examples/x86-fb.cfg#L25


You can also trigger a `debug_dump` of the l4re_kernel's memory map via the Debug_obj::debug() function. I'd try `cap_cast`ing the `L4Re::Env::env()->rm()`/l4re_kernel cap to `L4Re::Debug_obj` and the call the `debug()` function. The `function` parameter is unused in the l4re_kernel (l4re-core/l4re_kernel/server/src/region.cc), so zero or a dummy function should be ok.


So it is a way, if it's a convenient one? Well, .. ;-)


Cheers,
Philipp


--
[email protected] - Tel. 0351-41 883 221
http://www.kernkonzept.com

Kernkonzept GmbH.  Sitz: Dresden.  Amtsgericht Dresden, HRB 31129.
Geschäftsführer: Dr.-Ing. Michael Hohmuth

Attachment: OpenPGP_signature.asc
Description: OpenPGP digital signature

_______________________________________________
l4-hackers mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to