Home | History | Annotate | Download | only in tsan

Lines Matching refs:SID

43 // Segment ID (SID)      is in range [1, kMaxSID-1]
228 class SID: public ID {
230 explicit SID(T id) : ID(id) {}
231 SID() : ID(0) {}
267 explicit SSID(SID sid) : ID(sid.raw()) {}
276 SID GetSingleton() const {
278 return SID(raw());
401 static uint32_t combine2(SSID a, SID b) {
1707 static bool ProfileSeg(SID sid) {
1708 // return (sid.raw() % (1 << 14)) == 0;
1721 static INLINE uintptr_t *embedded_stack_trace(SID sid) {
1722 DCHECK(sid.valid());
1724 size_t chunk_idx = (unsigned)sid.raw() / kChunkSizeForStacks;
1725 size_t idx = (unsigned)sid.raw() % kChunkSizeForStacks;
1731 static void ensure_space_for_stack_trace(SID sid) {
1733 DCHECK(sid.valid());
1735 size_t chunk_idx = (unsigned)sid.raw() / kChunkSizeForStacks;
1748 static string StackTraceString(SID sid) {
1751 embedded_stack_trace(sid), kSizeOfHistoryStackTrace);
1755 static INLINE void AllocateFreshSegments(size_t n, SID *fresh_sids) {
1763 SID sid = reusable_sids_->back();
1765 Segment *seg = GetInternal(sid);
1769 CHECK(sid.valid());
1770 if (ProfileSeg(sid)) {
1771 Printf("Segment: reused SID %d\n", sid.raw());
1773 fresh_sids[i] = sid;
1786 if (ProfileSeg(SID(n_segments_))) {
1787 Printf("Segment: allocated SID %d\n", n_segments_);
1790 SID sid = fresh_sids[i] = SID(n_segments_);
1792 ensure_space_for_stack_trace(sid);
1799 static INLINE void SetupFreshSid(SID sid, TID tid, VTS *vts,
1803 DCHECK(sid.valid());
1804 Segment *seg = GetInternal(sid);
1814 embedded_stack_trace(sid)[0] = 0;
1818 static INLINE SID AddNewSegment(TID tid, VTS *vts,
1821 SID sid;
1822 AllocateFreshSegments(1, &sid);
1823 SetupFreshSid(sid, tid, vts, rd_lockset, wr_lockset);
1824 return sid;
1827 static bool Alive(SID sid) {
1828 Segment *seg = GetInternal(sid);
1832 static void AssertLive(SID sid, int line) {
1834 if (!(sid.raw() < INTERNAL_ANNOTATE_UNPROTECTED_READ(n_segments_))) {
1835 Printf("Segment::AssertLive: failed on sid=%d n_segments = %dline=%d\n",
1836 sid.raw(), n_segments_, line);
1838 Segment *seg = GetInternal(sid);
1840 Printf("Segment::AssertLive: failed on sid=%d line=%d\n",
1841 sid.raw(), line);
1848 static INLINE Segment *Get(SID sid) {
1849 AssertLive(sid, __LINE__);
1850 Segment *res = GetInternal(sid);
1856 static INLINE void RecycleOneFreshSid(SID sid) {
1857 Segment *seg = GetInternal(sid);
1860 reusable_sids_->push_back(sid);
1861 if (ProfileSeg(sid)) {
1862 Printf("Segment: recycled SID %d\n", sid.raw());
1866 static bool RecycleOneSid(SID sid) {
1868 Segment *seg = GetInternal(sid);
1870 DCHECK(sid.raw() < n_segments_);
1873 RecycleOneFreshSid(sid);
1881 static void INLINE Ref(SID sid, const char *where) {
1882 Segment *seg = GetInternal(sid);
1883 if (ProfileSeg(sid)) {
1884 Printf("SegRef : %d ref=%d %s; tid=%d\n", sid.raw(),
1891 static INLINE intptr_t UnrefNoRecycle(SID sid, const char *where) {
1892 Segment *seg = GetInternal(sid);
1893 if (ProfileSeg(sid)) {
1894 Printf("SegUnref : %d ref=%d %s\n", sid.raw(), seg->seg_ref_count_, where);
1900 static void INLINE Unref(SID sid, const char *where) {
1901 if (UnrefNoRecycle(sid, where) == 0) {
1902 RecycleOneSid(sid);
1913 static string ToString(SID sid) {
1915 snprintf(buff, sizeof(buff), "T%d/S%d", Get(sid)->tid().raw(), sid.raw());
1919 static string ToStringTidOnly(SID sid) {
1921 snprintf(buff, sizeof(buff), "T%d", Get(sid)->tid().raw());
1925 static string ToStringWithLocks(SID sid) {
1927 Segment *seg = Get(sid);
1928 snprintf(buff, sizeof(buff), "T%d/S%d ", seg->tid().raw(), sid.raw());
1934 static bool INLINE HappensBeforeOrSameThread(SID a, SID b) {
1940 static bool INLINE HappensBefore(SID a, SID b) {
1967 Segment *seg = GetInternal(SID(i));
2003 reusable_sids_ = new vector<SID>;
2010 static INLINE Segment *GetInternal(SID sid) {
2011 DCHECK(sid.valid());
2012 DCHECK(sid.raw() < INTERNAL_ANNOTATE_UNPROTECTED_READ(n_segments_));
2013 Segment *res = GetSegmentByIndex(sid.raw());
2026 // One large array of segments. The size is set by a command line (--max-sid)
2040 static vector<SID> *reusable_sids_;
2047 vector<SID> *Segment::reusable_sids_;
2052 static NOINLINE SSID AddSegmentToSS(SSID old_ssid, SID new_sid);
2053 static NOINLINE SSID RemoveSegmentFromSS(SSID old_ssid, SID sid_to_remove);
2055 static INLINE SSID AddSegmentToTupleSS(SSID ssid, SID new_sid);
2056 static INLINE SSID RemoveSegmentFromTupleSS(SSID old_ssid, SID sid_to_remove);
2114 SID sid = this->GetSID(i);
2115 if (sid.raw() == 0) break;
2116 Segment::Unref(sid, "SegmentSet::Recycle");
2203 return "{" + Segment::ToStringTidOnly(SID(ssid.raw())) + "}";
2240 SID GetSID(int32_t i) const {
2246 void SetSID(int32_t i, SID sid) {
2249 sids_[i] = sid;
2252 static SID GetSID(SSID ssid, int32_t i, int line) {
2260 SID sid = Get(ssid)->GetSID(i);
2261 Segment::AssertLive(sid, line);
2262 return sid;
2266 static bool INLINE Contains(SSID ssid, SID seg) {
2275 SID sid = ss->GetSID(i);
2276 if (sid.raw() == 0) break;
2277 if (sid == seg)
2304 // sids_ are filled with zeroes due to SID default CTOR.
2323 DCHECK(sizeof(int32_t) == sizeof(SID));
2336 res_ss->sids_[i] = SID(0);
2350 SID sid = ss->GetSID(i);
2351 if (sid.raw() == 0) break;
2352 Segment::Ref(sid, "SegmentSet::FindExistingOrAlocateAndCopy");
2353 res_ss->SetSID(i, sid);
2380 static INLINE SSID DoubletonSSID(SID sid1, SID sid2) {
2388 static SegmentSet *AddSegmentToTupleSS(SegmentSet *ss, SID new_sid) {
2394 static SegmentSet *Doubleton(SID sid1, SID sid2) {
2405 SID sid1 = ss1->sids_[i],
2419 SID sid1 = ss1->sids_[i],
2511 typedef PairCache<SSID, SID, SSID, 1009, 1> SsidSidToSidCache;
2517 SID sids_[kMaxSegmentSetSize];
2531 SSID SegmentSet::RemoveSegmentFromSS(SSID old_ssid, SID sid_to_remove) {
2542 SID sid = old_ssid.GetSingleton();
2543 if (Segment::HappensBeforeOrSameThread(sid, sid_to_remove))
2562 SSID SegmentSet::AddSegmentToSS(SSID old_ssid, SID new_sid) {
2573 SID old_sid(old_ssid.raw());
2585 // The new segment is in the same thread - just replace the SID.
2591 // happens before the new one - just replace the SID.
2613 SID old_sid(old_ssid.raw());
2633 SSID SegmentSet::RemoveSegmentFromTupleSS(SSID ssid, SID sid_to_remove) {
2641 SID * tmp_sids = tmp.sids_;
2642 CHECK(sizeof(int32_t) == sizeof(SID));
2645 SID sid = ss->GetSID(i);
2646 if (sid.raw() == 0) break;
2647 DCHECK(sid.valid());
2648 Segment::AssertLive(sid, __LINE__);
2649 if (Segment::HappensBeforeOrSameThread(sid, sid_to_remove))
2651 tmp_sids[new_size++] = sid;
2666 SSID SegmentSet::AddSegmentToTupleSS(SSID ssid, SID new_sid) {
2677 SID tmp_sids[kMaxSegmentSetSize + 1];
2678 CHECK(sizeof(int32_t) == sizeof(SID));
2680 // traverse all SID in current ss. tids are ordered.
2682 SID sid = ss->GetSID(i);
2683 if (sid.raw() == 0) break;
2684 DCHECK(sid.valid());
2685 Segment::AssertLive(sid, __LINE__);
2686 const Segment *seg = Segment::Get(sid);
2689 if (sid == new_sid) {
2690 // we are trying to insert a sid which is already there.
2716 if (!Segment::HappensBefore(sid, new_sid)) {
2717 DCHECK(!Segment::HappensBefore(new_sid, sid));
2718 tmp_sids[new_size++] = sid;
2737 SID sid = tmp_sids[i];
2738 if (sid == new_sid) continue;
2773 SID sid1 = GetSID(i);
2778 SID sid2 = GetSID(j);
2807 SID sid = GetSID(ssid, i, __LINE__);
2809 res += Segment::ToStringWithLocks(sid);
2818 SID sid = GetSID(i);
2820 CHECK(sid.valid());
2821 Segment::AssertLive(sid, __LINE__);
2822 res += Segment::ToStringTidOnly(sid).c_str();
2831 SID sid1 = Segment::AddNewSegment(TID(0), VTS::Parse("[0:2;]"), ls, ls);
2832 SID sid2 = Segment::AddNewSegment(TID(1), VTS::Parse("[0:1; 1:1]"), ls, ls);
2833 SID sid3 = Segment::AddNewSegment(TID(2), VTS::Parse("[0:1; 2:1]"), ls, ls);
2834 SID sid4 = Segment::AddNewSegment(TID(3), VTS::Parse("[0:1; 3:1]"), ls, ls);
2835 SID sid5 = Segment::AddNewSegment(TID(4), VTS::Parse("[0:3; 2:2; 3:2;]"),
2837 SID sid6 = Segment::AddNewSegment(TID(4), VTS::Parse("[0:3; 1:2; 2:2; 3:2;]"),
3498 set <SID> all_sids;
3502 SID sid = SegmentSet::GetSID(*it, i, __LINE__);
3503 all_sids.insert(sid);
3508 if (Segment::ProfileSeg(SID(i)) && all_sids.count(SID(i)) == 0) {
3509 // Printf("Segment SID %d: missing in storage; ref=%d\n", i,
3510 // Segment::Get(SID(i))->ref_count());
3815 SID last_access_sid;
3966 void Push(SID sid) {
3967 queue_.push_front(sid);
3968 Segment::Ref(sid, "RecentSegmentsCache::ShortenQueue");
3976 INLINE SID Search(CallStack *curr_stack,
3977 SID curr_sid, /*OUT*/ bool *needs_refill) {
3981 deque<SID>::iterator it = queue_.begin();
3983 SID sid = *it;
3984 Segment::AssertLive(sid, __LINE__);
3985 Segment *seg = Segment::Get(sid);
3987 if (seg->ref_count() == 1 + (sid == curr_sid)) {
3994 return sid;
4003 uintptr_t *emb_trace = Segment::embedded_stack_trace(sid);
4010 return sid;
4015 return SID();
4021 SID sid = queue_.back();
4022 Segment::Unref(sid, "RecentSegmentsCache::ShortenQueue");
4027 deque<SID> queue_;
4395 SID sid() const {
4400 CHECK(sid().valid());
4401 Segment::AssertLive(sid(), __LINE__);
4402 return Segment::Get(sid());
4646 Segment::ToString(sid()).c_str());
4665 vts()->ToString().c_str(), Segment::ToString(sid()).c_str(),
4676 SID new_sid = Segment::AddNewSegment(tid(), new_vts,
4678 SID old_sid = sid();
4687 FillEmbeddedStackTrace(Segment::embedded_stack_trace(sid()));
4691 tid().raw(), sid().raw(), old_sid.raw(),
4696 SID old_sid = sid();
4727 recent_segments_cache_.Push(sid());
4728 GetSomeFreshSids(); // fill the thread-local SID cache.
4740 SID match = recent_segments_cache_.Search(call_stack_, sid(),
4753 FillEmbeddedStackTrace(Segment::embedded_stack_trace(sid()));
4759 SID fresh_sid = fresh_sids_.back();
4766 recent_segments_cache_.Push(sid());
4767 FillEmbeddedStackTrace(Segment::embedded_stack_trace(sid()));
5097 thr->sid_ = SID(); // Reset the old SID so we don't try to read its VTS.
5136 // When creating a new segment on SBLOCK_ENTER, we need to get a fresh SID
5141 INLINE void AddDeadSid(SID sid, const char *where) {
5143 Segment::Unref(sid, where);
5145 if (Segment::UnrefNoRecycle(sid, where) == 0) {
5146 dead_sids_.push_back(sid);
5155 SID sid = dead_sids_[i];
5156 Segment::AssertLive(sid, __LINE__);
5157 DCHECK(Segment::Get(sid)->ref_count() == 0);
5158 Segment::RecycleOneSid(sid);
5193 SID sid_; // Current segment ID.
5221 vector<SID> dead_sids_;
5222 vector<SID> fresh_sids_;
5433 SID sid;
5434 sid(0) { }
5436 Segment *seg() { return Segment::Get(sid); }
5438 string StackTraceString() { return Segment::StackTraceString(sid); }
5747 race_report->last_access_sid = thr->sid();
5754 Segment *seg = Segment::Get(thr->sid());
5772 void PrintConcurrentSegmentSet(SSID ssid, TID tid, SID sid,
5775 set<SID>* concurrent_sids) {
5780 SID concurrent_sid = SegmentSet::GetSID(ssid, s, __LINE__);
5782 if (Segment::HappensBeforeOrSameThread(concurrent_sid, sid)) continue;
5831 string RaceInfoString(uintptr_t pc, set<SID>& concurrent_sids) {
5836 for (set<SID>::iterator it = concurrent_sids.begin();
5856 SID sid = race->last_access_sid;
5894 // Report(" sid=%d; vts=%s\n", thr->sid().raw(),
5900 set<SID> concurrent_sids;
5903 tid, sid, lsid, true, "write(s)", &all_locks,
5907 tid, sid, lsid, false, "read(s)", &all_locks,
6904 SID w1_sid = SegmentSet::GetSID(wr_ssid, w1, __LINE__);
6921 SID r_sid = SegmentSet::GetSID(rd_ssid, r, __LINE__);
6944 SID cur_sid = thr->sid();
7009 SID cur_sid = thr->sid();
7014 SID wr_sid = wr_ssid.GetSingleton();
7047 SID rd_sid = rd_ssid.GetSingleton();
7078 SID wr_sid = wr_ssid.GetSingleton();
7193 SID sid = ssid.GetSingleton();
7194 Segment *seg = Segment::Get(sid);
7197 if (sid == thr->sid()) {
7381 raw_tid(thr), thr->sid().raw(), mop->is_write() ? "wr" : "rd",
7592 info.sid = thr->sid();
7593 Segment::Ref(info.sid, __FUNCTION__);
7597 Segment::ToString(thr->sid()).c_str(),
7651 Segment::Unref(info->sid, __FUNCTION__);
7678 Segment::Unref(h_info->sid, __FUNCTION__);
7777 Segment::ToString(child->sid()).c_str(),
7813 CHECK(parent_thr->sid().valid());
7814 Segment::AssertLive(parent_thr->sid(), __LINE__);
8210 Printf("Error: max-sid should be at least 100000. Exiting\n");
8844 Segment::ToString(thr->sid()).c_str(),
8927 Segment::ToString(thr->sid()).c_str());