MCPcopy Create free account
hub / github.com/apache/impala / SnapshotCopy

Method SnapshotCopy

be/src/kudu/util/kernel_stack_watchdog.cc:236–254  ·  view source on GitHub ↗

Optimistic concurrency control approach to snapshot the value of another thread's TLS, even though that thread might be changing it. Called by the watchdog thread to see if a target thread is currently in the middle of a watched section.

Source from the content-addressed store, hash-verified

234// Called by the watchdog thread to see if a target thread is currently in the
235// middle of a watched section.
236void KernelStackWatchdog::TLS::Data::SnapshotCopy(Data* copy) const {
237 while (true) {
238 Atomic32 v_0 = base::subtle::Acquire_Load(&seq_lock_);
239 if (v_0 & 1) {
240 // If the value is odd, then the thread is in the middle of modifying
241 // its TLS, and we have to spin.
242 base::subtle::PauseCPU();
243 continue;
244 }
245 ANNOTATE_IGNORE_READS_BEGIN();
246 memcpy(copy, this, sizeof(*copy));
247 ANNOTATE_IGNORE_READS_END();
248 Atomic32 v_1 = base::subtle::Release_Load(&seq_lock_);
249
250 // If the value hasn't changed since we started the copy, then
251 // we know that the copy was a consistent snapshot.
252 if (v_1 == v_0) break;
253 }
254}
255
256} // namespace kudu

Callers 1

RunThreadMethod · 0.80

Calls 3

PauseCPUFunction · 0.85
Acquire_LoadFunction · 0.50
Release_LoadFunction · 0.50

Tested by

no test coverage detected