69 Instance_->finalize();
81 if (!Instance_)
return false;
82 return Instance_->IsInitialized_;
89 {
int status = pthread_mutex_lock(&HelperLock_); assert(!status); }
91 {
int status = pthread_mutex_unlock(&HelperLock_); assert(!status); }
93 int status = pthread_cond_wait(&HelperCondition_, &HelperLock_);
97 {
int status = pthread_cond_signal(&HelperCondition_); assert(!status); }
101 std::memory_order success,
102 std::memory_order failure) {
103 return LogStructureHeaderPtr_->compare_exchange_weak(
104 expected, desired, success, failure);
108 std::memory_order success,
109 std::memory_order failure) {
110 return RecoveryTimeLsp_.compare_exchange_weak(
111 expected, desired, success, failure);
124 void logStore(
void *addr,
size_t sz);
137 void psync(
void *start_addr,
size_t sz);
155 {
return AllDone_.load(std::memory_order_acquire) == 1; }
158 {
return RecoveryTimeLsp_.load(mem_order); }
160 std::memory_order mem_order)
161 { RecoveryTimeLsp_.store(log_ptr, mem_order); }
163 {
return (*LogStructureHeaderPtr_).load(mem_order); }
167 { deleteEntry<LogEntry>(CbLogList_, addr); }
174 { assert(Stats_); Stats_->
print(); }
190 pthread_t HelperThread_;
193 std::atomic<CbListNode<LogEntry>*> CbLogList_;
196 std::atomic<LogStructure*> *LogStructureHeaderPtr_;
199 std::atomic<LogStructure*> RecoveryTimeLsp_;
202 std::atomic<int> AllDone_;
205 pthread_cond_t HelperCondition_;
208 pthread_mutex_t HelperLock_;
218 std::atomic<LockReleaseCount*> LockReleaseHistory_[
kHashTableSize];
230 thread_local
static uint32_t TL_LogCount_;
244 thread_local
static uint64_t TL_GenNum_;
247 thread_local
static LogEntry *TL_LastLogEntry_;
253 thread_local
static intptr_t TL_NumHeldLocks_;
263 thread_local
static bool TL_IsFirstNonCSStmt_;
266 thread_local
static bool TL_ShouldLogNonCSStmt_;
269 thread_local
static uint64_t TL_LogCounter_;
272 thread_local
static SetOfInts *TL_FaseFlushPtr_;
275 thread_local
static SetOfPairs *TL_UniqueLoc_;
291 LogStructureHeaderPtr_{
nullptr},
292 RecoveryTimeLsp_{
nullptr},
295 IsInitialized_{
false}
297 pthread_cond_init(&HelperCondition_,
nullptr);
298 pthread_mutex_init(&HelperLock_,
nullptr);
303 #if defined(_FLUSH_LOCAL_COMMIT) && !defined(DISABLE_FLUSHES) 304 delete TL_FaseFlushPtr_;
305 TL_FaseFlushPtr_ =
nullptr;
314 std::atomic<LastReleaseInfo*> *getLastReleaseRoot(
void *addr) {
315 return ReleaseInfoTab_ + (
316 ((
reinterpret_cast<uint64_t
>(addr)) >>
kShift) &
319 std::atomic<LockReleaseCount*> *getLockReleaseCountRoot(
void *addr) {
320 return LockReleaseHistory_ + (
321 ((
reinterpret_cast<uint64_t
>(addr)) >>
kShift) &
327 void *lock_address,
LogType le_type);
331 void * addr,
size_t size_in_bits);
333 void *addr,
size_t sz,
LogType le_type);
336 void publishLogEntry(
347 void assertOneCacheLine(
LogEntry *le) {
348 #if !defined(_LOG_WITH_NVM_ALLOC) && !defined(_LOG_WITH_MALLOC) 361 void addLogToLastReleaseInfo(
367 void setHappensBeforeForAllocFree(
372 void *addr,
size_t sz);
373 bool doesNeedLogging(
374 void *addr,
size_t sz);
375 bool canElideLogging();
376 void addLockReleaseCount(
377 void *lock_address, uint64_t count);
382 uint64_t removeLockFromUndoInfo(
385 bool isAddrSizePairAlreadySeen(
386 void *addr,
size_t sz);
389 template<
class T>
CbLog<T> *getNewCb(
392 template<
class T> T *getNewSlot(
397 template<
class T>
void deleteSlot(
407 finishAcquire(lock_address, le);
415 finishAcquire(lock_address, le);
423 finishAcquire(lock_address, le);
431 finishAcquire(NULL, le);
437 if (tryLogElision(addr, sz/8))
return;
438 LogEntry *le = createStrLogEntry(addr, sz);
439 finishWrite(le, addr);
445 if (tryLogElision(addr, sz))
return;
447 finishWrite(le, addr);
453 if (tryLogElision(dst, sz))
return;
455 finishWrite(le, dst);
461 if (tryLogElision(dst, sz))
return;
463 finishWrite(le, dst);
469 if (tryLogElision((
void *)dst, sz))
return;
471 finishWrite(le, dst);
477 if (tryLogElision(dst, sz))
return;
479 finishWrite(le, dst);
482 inline LastReleaseInfo *LogMgr::getLastReleaseHeader(
void *lock_address)
484 std::atomic<LastReleaseInfo*> *table_ptr =
485 getLastReleaseRoot(lock_address);
486 return (*table_ptr).load(std::memory_order_acquire);
489 inline LockReleaseCount *LogMgr::getLockReleaseCountHeader(
void *lock_address)
491 std::atomic<LockReleaseCount*> *entry =
492 getLockReleaseCountRoot(lock_address);
493 return (*entry).load(std::memory_order_acquire);
498 #if (!defined(DISABLE_FLUSHES) && !defined(_DISABLE_LOG_FLUSH)) 499 #if defined(_LOG_FLUSH_OPT) Definition: log_configs.hpp:36
bool cmpXchngWeakRecoveryLogPointer(LogStructure *expected, LogStructure *desired, std::memory_order success, std::memory_order failure)
Definition: log_mgr.hpp:106
void logEndDurable()
Definition: log_mgr.cpp:211
void signalLogReady()
Definition: log_mgr.hpp:96
static bool hasInstance()
Definition: log_mgr.hpp:80
void acquireStatsLock()
Definition: log_mgr.hpp:169
void logBeginDurable()
Definition: log_mgr.hpp:426
const uint64_t kHashTableSize
Definition: log_configs.hpp:24
const uint64_t kHashTableMask
Definition: log_configs.hpp:25
void logMemmove(void *dst, size_t sz)
Definition: log_mgr.hpp:458
LogStructure * getRecoveryLogPointer(std::memory_order mem_order) const
Definition: log_mgr.hpp:157
void deleteEntry(LogEntry *addr)
Definition: log_mgr.hpp:166
Definition: log_structure.hpp:30
void collectCacheLines(SetOfInts *cl_set, void *addr, size_t sz)
void acquireLogReadyLock()
Definition: log_mgr.hpp:88
Definition: log_configs.hpp:33
void releaseLock()
Definition: stats.hpp:51
std::map< void *, uint64_t > MapOfLockInfo
Definition: happens_before.hpp:27
LogType
Definition: log_configs.hpp:32
void releaseStatsLock()
Definition: log_mgr.hpp:171
void logMemcpy(void *dst, size_t sz)
Definition: log_mgr.hpp:450
void logRelease(void *)
Entry point into log manager for a lock release.
Definition: log_mgr.cpp:159
const uint32_t kMaxNumPRegions_
Definition: pregion_configs.hpp:29
void waitLogReady()
Definition: log_mgr.hpp:92
Definition: happens_before.hpp:61
void acquireLock()
Definition: stats.hpp:49
uint32_t region_id_t
Definition: pregion_configs.hpp:22
void logRdLock(void *)
Definition: log_mgr.hpp:410
void logStore(void *addr, size_t sz)
Definition: log_mgr.hpp:434
int NVM_IsInOpenPR(void *addr, size_t sz)
Definition: pregion_mgr_api.cpp:90
void logAcquire(void *)
Definition: log_mgr.hpp:402
Definition: log_configs.hpp:35
const int32_t kFlushTableSize
Definition: cache_flush_configs.hpp:22
void print()
Definition: stats.cpp:44
void setRegionId(region_id_t id)
Definition: log_mgr.hpp:85
Definition: log_elision.hpp:24
bool areUserThreadsDone() const
Definition: log_mgr.hpp:154
static LogMgr & createInstance()
Definition: log_mgr.hpp:52
Definition: happens_before.hpp:33
void logRWUnlock(void *)
Definition: log_mgr.cpp:190
bool cmpXchngWeakLogPointer(LogStructure *expected, LogStructure *desired, std::memory_order success, std::memory_order failure)
Definition: log_mgr.hpp:99
LogStructure * createLogStructure(LogEntry *le)
Create a thread specific log header.
Definition: log_entry_create.cpp:226
void logNonTemporal(LogEntry *le, void *addr, size_t sz, LogType le_type)
#define NVM_FLUSH(p)
Definition: atlas_api.h:106
void logMemset(void *addr, size_t sz)
Definition: log_mgr.hpp:442
void psync(void *start_addr, size_t sz)
Definition: generic.cpp:42
void asyncLogFlush(void *p)
Definition: log_configs.hpp:33
void printStats() const
Definition: log_mgr.hpp:173
Definition: log_configs.hpp:34
Definition: log_configs.hpp:35
region_id_t getRegionId() const
Definition: log_mgr.hpp:86
Definition: circular_buffer.hpp:25
static LogMgr & getInstance()
Definition: log_mgr.hpp:75
void flushLogPointer()
Definition: log_mgr.hpp:151
void * helper(void *arg_lsp)
Definition: helper_driver.cpp:33
Definition: log_structure.hpp:77
Definition: circular_buffer.hpp:58
void flushCacheLinesUnconstrained(const SetOfInts &cl_set)
std::set< AddrSizePairType, CmpAddrSizePair > SetOfPairs
Definition: util.hpp:49
const uint32_t kShift
Definition: log_configs.hpp:26
int size(COW_AL *cal)
Definition: cow_array_list.c:183
std::set< uint64_t > SetOfInts
Definition: util.hpp:77
void logStrcat(void *dst, size_t sz)
Definition: log_mgr.hpp:474
void logAlloc(void *addr)
Definition: log_mgr.cpp:229
void releaseLogReadyLock()
Definition: log_mgr.hpp:90
Definition: log_configs.hpp:33
void asyncDataFlush(void *p)
void flushAtEndOfFase()
Definition: generic.cpp:48
void flushCacheLines(const SetOfInts &cl_set)
Definition: log_mgr.hpp:47
void deleteOwnerInfo(LogEntry *le)
Definition: happens_before.cpp:132
void logWrLock(void *)
Definition: log_mgr.hpp:418
void setRecoveryLogPointer(LogStructure *log_ptr, std::memory_order mem_order)
Definition: log_mgr.hpp:159
void asyncMemOpDataFlush(void *dst, size_t sz)
void flushLogUncond(void *)
Definition: log_mgr.hpp:496
Definition: log_configs.hpp:36
void flushRecoveryLogPointer()
Definition: log_mgr.hpp:152
static bool is_on_different_cache_line(void *p1, void *p2)
Definition: pmalloc_util.hpp:109
std::vector< LogEntry * > LogEntryVec
Definition: log_mgr.hpp:45
Definition: atlas_alloc_cpp.hpp:21
static void deleteInstance()
Definition: log_mgr.hpp:67
LogStructure * getLogPointer(std::memory_order mem_order) const
Definition: log_mgr.hpp:162
static LogMgr & createRecoveryInstance()
Definition: log_mgr.hpp:60
void psyncWithAcquireBarrier(void *start_addr, size_t sz)
Definition: generic.cpp:21
Definition: log_configs.hpp:35
void logStrcpy(void *dst, size_t sz)
Definition: log_mgr.hpp:466
void logFree(void *addr)
Definition: log_mgr.cpp:249
#define LAST_LOG_ELEM(p)
Definition: log_structure.hpp:71