You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
SFTMap implementations cast &self to &mut self for modifying its underlying sft: Vec<&'a (dyn SFT + Sync + 'static)>. This table is accessed by multiple threads, but it needs to be updated occasionally. It is problematic in two ways:
Each element can be read and updated at the same time. This is a data race which has undefined behaviour.
After one thread grows the space, other threads can access the SFT for the extended part while the space that grew the space is still updating the SFT entries. See:
// We need this lock: Othrewise, it is possible that one thread acquires pages in a new chunk, but not yet
One way to solve the first problem is changing the elements of the Vec to AtomicPtr. However, & dyn Trait is 16 bytes in size.
The "double-checked locking" algorithm can be used for data structures that are lazily initialised. I think the use pattern of SFT matches lazy initialisation in certain ways, and may be applicable.
The text was updated successfully, but these errors were encountered:
&dyn Trait can be replaced with AtomicU128. The problem is most likely in HashMap, it has to be replaced with DashMap to allow safe concurrent access. But also, the problem is that Vec can be pushed into which is not really safe as well in multiple threads scenario
Parent: #850
SFTMap implementations cast
&self
to&mut self
for modifying its underlyingsft: Vec<&'a (dyn SFT + Sync + 'static)>
. This table is accessed by multiple threads, but it needs to be updated occasionally. It is problematic in two ways:mmtk-core/src/policy/space.rs
Line 81 in f1a0bb7
One way to solve the first problem is changing the elements of the
Vec
toAtomicPtr
. However,& dyn Trait
is 16 bytes in size.The "double-checked locking" algorithm can be used for data structures that are lazily initialised. I think the use pattern of SFT matches lazy initialisation in certain ways, and may be applicable.
The text was updated successfully, but these errors were encountered: