mirror of
https://github.com/ruby/ruby.git
synced 2026-01-26 12:14:51 +00:00
Extract vm_locked_by_ractor_p
This introduces a new method to encapsulate checking whether the current Ractor owns the vm->ractor.sync lock. This allows us to disable TSan on it since that operation should be safe, and still get validation of other uses.
This commit is contained in:
parent
7465e169da
commit
3ad2019259
@ -30,13 +30,6 @@ race:check_reserved_signal_
|
||||
|
||||
race_top:rb_check_deadlock
|
||||
|
||||
# lock_owner
|
||||
race_top:thread_sched_setup_running_threads
|
||||
race_top:vm_lock_enter
|
||||
race_top:rb_ec_vm_lock_rec
|
||||
race_top:vm_lock_enter
|
||||
race_top:vm_locked
|
||||
|
||||
# vm->ractor.sched.grq_cnt++
|
||||
race_top:ractor_sched_enq
|
||||
race_top:ractor_sched_deq
|
||||
|
||||
11
vm_core.h
11
vm_core.h
@ -2065,12 +2065,21 @@ void rb_ec_vm_lock_rec_release(const rb_execution_context_t *ec,
|
||||
unsigned int recorded_lock_rec,
|
||||
unsigned int current_lock_rec);
|
||||
|
||||
/* This technically is a data race, as it's checked without the lock, however we
|
||||
* check against a value only our own thread will write. */
|
||||
NO_SANITIZE("thread", static inline bool
|
||||
vm_locked_by_ractor_p(rb_vm_t *vm, rb_ractor_t *cr))
|
||||
{
|
||||
VM_ASSERT(cr == GET_RACTOR());
|
||||
return vm->ractor.sync.lock_owner == cr;
|
||||
}
|
||||
|
||||
static inline unsigned int
|
||||
rb_ec_vm_lock_rec(const rb_execution_context_t *ec)
|
||||
{
|
||||
rb_vm_t *vm = rb_ec_vm_ptr(ec);
|
||||
|
||||
if (vm->ractor.sync.lock_owner != rb_ec_ractor_ptr(ec)) {
|
||||
if (!vm_locked_by_ractor_p(vm, rb_ec_ractor_ptr(ec))) {
|
||||
return 0;
|
||||
}
|
||||
else {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user