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
6 changes: 5 additions & 1 deletion src/base_alloc/base_alloc.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2024 Intel Corporation
* Copyright (C) 2024-2025 Intel Corporation
*
* Under the Apache License v2.0 with LLVM Exceptions. See LICENSE.TXT.
* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
Expand Down Expand Up @@ -244,6 +244,8 @@ void *umf_ba_alloc(umf_ba_pool_t *pool) {

utils_mutex_unlock(&pool->metadata.free_lock);

utils_annotate_acquire(chunk);
Copy link
Contributor

Choose a reason for hiding this comment

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

Why it is needed?

Copy link
Contributor

Choose a reason for hiding this comment

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

@ldorau and I noticed similar code in tbb_malloc()/free() (however, in that case, the acquire/release is performed on the entire pool pointer, which could be invalid - ??). Generally, as I understand these calls, when an allocation is ready to be reused in another thread, all writes to it should be completed before returning it as a new allocation.

Copy link
Contributor

Choose a reason for hiding this comment

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

Isn't mutex above all ready introducing full memory barrier?

Copy link
Contributor

Choose a reason for hiding this comment

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

@lplewa +1

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Right, it will not be needed.


return chunk;
}

Expand Down Expand Up @@ -277,6 +279,8 @@ void umf_ba_free(umf_ba_pool_t *pool, void *ptr) {

umf_ba_chunk_t *chunk = (umf_ba_chunk_t *)ptr;

utils_annotate_release(chunk);

utils_mutex_lock(&pool->metadata.free_lock);
assert(pool_contains_pointer(pool, ptr));
chunk->next = pool->metadata.free_list;
Expand Down
Loading