Skip to content

Commit

Permalink
Minor fixes for KW in tbbmalloc (#1124)
Browse files Browse the repository at this point in the history
Signed-off-by: kboyarinov <konstantin.boyarinov@intel.com>
  • Loading branch information
kboyarinov authored Jun 8, 2023
1 parent 50a1320 commit fc18473
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions src/tbbmalloc/backend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,7 @@ FreeBlock *Backend::IndexedBins::getFromBin(int binIdx, BackendSync *sync, size_
try_next:
FreeBlock *fBlock = nullptr;
if (!b->empty()) {
bool locked;
bool locked = false;
MallocMutex::scoped_lock scopedLock(b->tLock, wait, &locked);

if (!locked) {
Expand Down Expand Up @@ -505,7 +505,7 @@ void Backend::IndexedBins::addBlock(int binIdx, FreeBlock *fBlock, size_t /* blo

bool Backend::IndexedBins::tryAddBlock(int binIdx, FreeBlock *fBlock, bool addToTail)
{
bool locked;
bool locked = false;
Bin *b = &freeBins[binIdx];
fBlock->myBin = binIdx;
if (addToTail) {
Expand Down
8 changes: 4 additions & 4 deletions src/tbbmalloc/frontend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ class ThreadId {
return *this;
}
static bool init() { return true; }
#if __TBB_SOURCE_DIRECTLY_INCLUDED
#if __TBB_SOURCE_DIRECTLY_INCLUDED
static void destroy() {}
#endif
};
Expand Down Expand Up @@ -694,7 +694,7 @@ bool AllLocalCaches::cleanup(bool cleanOnlyUnused)

void AllLocalCaches::markUnused()
{
bool locked;
bool locked = false;
MallocMutex::scoped_lock lock(listLock, /*block=*/false, &locked);
if (!locked) // not wait for marking if someone doing something with it
return;
Expand Down Expand Up @@ -1808,7 +1808,7 @@ void TLSData::release()

if (syncOnMailbox) {
// Although, we synchronized on nextPrivatizable inside a block, we still need to
// synchronize on the bin lifetime because the thread releasing an object into the public
// synchronize on the bin lifetime because the thread releasing an object into the public
// free list is touching the bin (mailbox and mailLock)
MallocMutex::scoped_lock scoped_cs(bin[index].mailLock);
}
Expand Down Expand Up @@ -2868,7 +2868,7 @@ void doThreadShutdownNotification(TLSData* tls, bool main_thread)
defaultMemPool->onThreadShutdown(defaultMemPool->getTLS(/*create=*/false));
// Take lock to walk through other pools; but waiting might be dangerous at this point
// (e.g. on Windows the main thread might deadlock)
bool locked;
bool locked = false;
MallocMutex::scoped_lock lock(MemoryPool::memPoolListLock, /*wait=*/!main_thread, &locked);
if (locked) { // the list is safe to process
for (MemoryPool *memPool = defaultMemPool->next; memPool; memPool = memPool->next)
Expand Down

0 comments on commit fc18473

Please sign in to comment.