RFC: Allocator: Track core1 allocations #46

Closed
opened 2020-07-08 09:40:08 +08:00 by pca006132 · 1 comment

I'm thinking if we should modify the allocator to track allocations made by 2 cores separately, so that we can free the blocks allocated to core1 after reset, similar to what an OS would do after a process terminates.

The problem with core1 is that we cannot guarantee to be free of memory leaks, due to possible hardware reset requested by the core0 at any time. The user code may also contain bugs or any kind of infinite loop so the kernel would never reaches the destructor.

Using mutex or something to share the reference between two cores, and ask core0 to drop those references when it request a reset for core1 is possible. However, that would be quite complicated, and if core1 is holding the mutex guard during reset/panic that would be a problem as we can no longer guarantee the struct to be in a correct state.

I'm thinking if we should modify the allocator to track allocations made by 2 cores separately, so that we can free the blocks allocated to core1 after reset, similar to what an OS would do after a process terminates. The problem with core1 is that we cannot guarantee to be free of memory leaks, due to possible hardware reset requested by the core0 at any time. The user code may also contain bugs or any kind of infinite loop so the kernel would never reaches the destructor. Using mutex or something to share the reference between two cores, and ask core0 to drop those references when it request a reset for core1 is possible. However, that would be quite complicated, and if core1 is holding the mutex guard during reset/panic that would be a problem as we can no longer guarantee the struct to be in a correct state.

I suppose this is obsolete now - the current route is to have two completely separate allocators, there is never anything allocated by one core and freed by the other.

I suppose this is obsolete now - the current route is to have two completely separate allocators, there is never anything allocated by one core and freed by the other.
Sign in to join this conversation.
No Label
No Milestone
No Assignees
2 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: M-Labs/zynq-rs#46
There is no content yet.