Skip to content
Closed
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
7 changes: 5 additions & 2 deletions src/pool/pool_disjoint.c
Original file line number Diff line number Diff line change
Expand Up @@ -110,17 +110,20 @@ static slab_t *create_slab(bucket_t *bucket) {
// padding at the end of the slab
slab->slab_size = bucket_slab_alloc_size(bucket);

void *slab_mem_ptr = NULL;
// TODO not true
// NOTE: originally slabs memory were allocated without alignment
// with this registering a slab is simpler and doesn't require multimap
res = umfMemoryProviderAlloc(provider, slab->slab_size, 0, &slab->mem_ptr);
res = umfMemoryProviderAlloc(provider, slab->slab_size, 0, &slab_mem_ptr);
if (res != UMF_RESULT_SUCCESS) {
LOG_ERR("allocation of slab data failed!");
goto free_slab;
}

// raw allocation is not available for user so mark it as inaccessible
utils_annotate_memory_inaccessible(slab->mem_ptr, slab->slab_size);
utils_annotate_memory_inaccessible(slab_mem_ptr, slab->slab_size);

utils_atomic_store_release_ptr(&slab->mem_ptr, slab_mem_ptr);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand this fix. Should slab->mem_ptr always be accessed atomically? Why? This address isn't supposed to change during the lifetime of a slab.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have updated the description of this PR - you can find the full trace there:
It is supposed to be a fix for the following data race:
https://github.com/ldorau/unified-memory-framework/actions/runs/14440708601/job/40490018121

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know how this could fix the problem. In the logs, I can see that thread T7 is reading a value from a slab that is not fully created yet. This is strange as the slab is registered later in pool_register_slab() AFTER the create_slab() finishes.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, I will investigate it deeper


LOG_DEBUG("bucket: %p, slab_size: %zu", (void *)bucket, slab->slab_size);
return slab;
Expand Down
Loading