I have a physical memory which is used for populated managed dataspace, like Dataspace_capability ds = env.ram().alloc(SIZE); void * base_rw = env.rm().attach(ds); memset(base_rw, 0xff, SIZE); env.rm().detach(base_rw);
I use it as backend for mmap and found, that I need to be able to change mapping in the standard way which used for this mmap/munmap interface.
Typically, I want to free a part of this ds, e.g., in the middle of it. Like UUUUUU -> UUUFFU (where Used and Free abbreviation used), keeping mapping and content for all old addresses except freed ones, in the «middle» of area [base_rw, base_rw+SIZE) from above.
How I can do this? Probably after operation I will have 2 ds instead of original one; Anyway, I do not want to loose the content of old ds during this procedure, and want to get rid of copy of old content to new one. Is it possible to split ds in such a way? From code of Region_map_component::detach I see that I can detach only from the beginning of the region.
May be you can point me to the proper example?
Sincerely, Alexander
Hello Alexander,
On Mon, Nov 02, 2020 at 23:55:07 CET, Alexander Tormasov via users wrote:
I have a physical memory which is used for populated managed dataspace, like Dataspace_capability ds = env.ram().alloc(SIZE); void * base_rw = env.rm().attach(ds); memset(base_rw, 0xff, SIZE); env.rm().detach(base_rw);
I use it as backend for mmap and found, that I need to be able to change mapping in the standard way which used for this mmap/munmap interface.
Typically, I want to free a part of this ds, e.g., in the middle of it. Like UUUUUU -> UUUFFU (where Used and Free abbreviation used), keeping mapping and content for all old addresses except freed ones, in the «middle» of area [base_rw, base_rw+SIZE) from above.
How I can do this? Probably after operation I will have 2 ds instead of original one; Anyway, I do not want to loose the content of old ds during this procedure, and want to get rid of copy of old content to new one. Is it possible to split ds in such a way? From code of Region_map_component::detach I see that I can detach only from the beginning of the region.
How about using multiple dataspaces (chunks) in the first place, ie. each U is a separate dataspace and all dataspaces are mapped into a consecutive region in virtual memory?
Greets
Thank you for answering!
Typically, I want to free a part of this ds, e.g., in the middle of it. Like UUUUUU -> UUUFFU (where Used and Free abbreviation used), keeping mapping and content for all old addresses except freed ones, in the «middle» of area [base_rw, base_rw+SIZE) from above.
How about using multiple dataspaces (chunks) in the first place, ie. each U is a separate dataspace and all dataspaces are mapped into a consecutive region in virtual memory?
I assume that granularity will be too high. e.g. every U could correspond to single 4k page, and this will give a high related metadata structures overhead (need to store it for every page). Also, performance will be terrible - imagine that I will try to allocate around 1Gb of ram with "4k pages data spaces» via separate attach_at() and related nested RPC calls…
sorry, this is not working...
any other ideas how to split single ds without copy of the content?
5 нояб. 2020 г., в 12:24, Alexander Tormasov via users users@lists.genode.org написал(а):
Thank you for answering!
Typically, I want to free a part of this ds, e.g., in the middle of it. Like UUUUUU -> UUUFFU (where Used and Free abbreviation used), keeping mapping and content for all old addresses except freed ones, in the «middle» of area [base_rw, base_rw+SIZE) from above.
How about using multiple dataspaces (chunks) in the first place, ie. each U is a separate dataspace and all dataspaces are mapped into a consecutive region in virtual memory?
I assume that granularity will be too high. e.g. every U could correspond to single 4k page, and this will give a high related metadata structures overhead (need to store it for every page). Also, performance will be terrible - imagine that I will try to allocate around 1Gb of ram with "4k pages data spaces» via separate attach_at() and related nested RPC calls…
Alexander,
On Mon, Nov 09, 2020 at 15:03:13 CET, Alexander Tormasov via users wrote:
sorry, this is not working...
any other ideas how to split single ds without copy of the content?
This sounds like you want something not possible (with Genode and maybe also entirely impossible depending on how one reads your statement). I'd like to urge you to reconsider splitting your allocation of dataspaces at a granularity that suits your needs. This way you might identify a sweet spot between allocating to many dataspaces and copying to many bytes. Thinking twice, the granularity could even be dynamic not static.
I understand that this puts the burden of software implementation on your shoulders but Genode does not provide more convenience in this regard.
Cheers
On Mon, 9 Nov 2020 at 14:03, Alexander Tormasov via users users@lists.genode.org wrote:
sorry, this is not working...
any other ideas how to split single ds without copy of the content?
Hi Alexander,
I have used a perhaps crude solution that you might find useful. In RISC OS which is the system I usually code for , it is a bad idea to allocate a lot of small spaces. So I use a "freelist". Simply a list with memory addresses as keys and a notion if area is free or used and size. When application needs mem, it looks at the table. First it tries to find a free slot with >= required size. If none found , add a new entry. If ram isn't needed , just tell the list that it is free. This might give you fragmented space , but it can be programmed to reorganised , and I guess that many times the size of areas will be the same.
Not a Genode specific solution , and not sure if it covers your needs.
Michael