Skip to content

Adding munmap_arena_and_reset and calling it to all semispaces when free_all_kore_mem #1201

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 11, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions include/runtime/arena.h
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,20 @@ class arena {
// allocated within an arena.
static char get_arena_semispace_id_of_object(void *ptr);

// Unmaps the current and collection address spaces and resets them and the tripwire.
// This is needed when the client switches thread contexts without properly deallocating
// them. This is not a common use case and shoul be used carefully.
void munmap_arena_and_reset() {
if (current_addr_ptr)
munmap(current_addr_ptr, HYPERBLOCK_SIZE);
if (collection_addr_ptr)
munmap(collection_addr_ptr, HYPERBLOCK_SIZE);

current_addr_ptr = nullptr;
collection_addr_ptr = nullptr;
tripwire = nullptr;
}

private:
void initialize_semispace();
//
Expand Down
4 changes: 4 additions & 0 deletions runtime/collect/collect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
extern "C" {
extern thread_local arena youngspace;
extern thread_local arena oldspace;
extern thread_local arena alwaysgcspace;

char *youngspace_ptr(void);
char *oldspace_ptr(void);
Expand Down Expand Up @@ -345,5 +346,8 @@ void kore_collect(
void free_all_kore_mem() {
kore_collect(nullptr, 0, nullptr, true);
kore_clear();
youngspace.munmap_arena_and_reset();
oldspace.munmap_arena_and_reset();
alwaysgcspace.munmap_arena_and_reset();
}
}