move th->event_serial to rb_thread_sched_item (#15500)

This commit is contained in:
Luke Gruber 2025-12-12 14:24:40 -05:00 committed by GitHub
parent 6147b69587
commit 7909ce2a83
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
Notes: git 2025-12-12 19:25:08 +00:00
Merged-By: luke-gru <luke.gru@gmail.com>
4 changed files with 6 additions and 6 deletions

View File

@ -2988,7 +2988,7 @@ timer_thread_deq_wakeup(rb_vm_t *vm, rb_hrtime_t now, uint32_t *event_serial)
static void
timer_thread_wakeup_thread_locked(struct rb_thread_sched *sched, rb_thread_t *th, uint32_t event_serial)
{
if (sched->running != th && th->event_serial == event_serial) {
if (sched->running != th && th->sched.event_serial == event_serial) {
thread_sched_to_ready_common(sched, th, true, false);
}
}

View File

@ -48,7 +48,7 @@ struct rb_thread_sched_waiting {
struct ccan_list_node node;
};
// per-Thead scheduler helper data
// per-Thread scheduler helper data
struct rb_thread_sched_item {
struct {
struct ccan_list_node ubf;
@ -70,6 +70,7 @@ struct rb_thread_sched_item {
} node;
struct rb_thread_sched_waiting waiting_reason;
uint32_t event_serial;
bool finished;
bool malloc_stack;

View File

@ -65,7 +65,7 @@ thread_sched_wait_events(struct rb_thread_sched *sched, rb_thread_t *th, int fd,
volatile bool timedout = false, need_cancel = false;
uint32_t event_serial = ++th->event_serial; // overflow is okay
uint32_t event_serial = ++th->sched.event_serial; // overflow is okay
if (ubf_set(th, ubf_event_waiting, (void *)th)) {
return false;
@ -81,11 +81,11 @@ thread_sched_wait_events(struct rb_thread_sched *sched, rb_thread_t *th, int fd,
RB_INTERNAL_THREAD_HOOK(RUBY_INTERNAL_THREAD_EVENT_SUSPENDED, th);
if (th->sched.waiting_reason.flags == thread_sched_waiting_none) {
th->event_serial++;
th->sched.event_serial++;
// timer thread has dequeued us already, but it won't try to wake us because we bumped our serial
}
else if (RUBY_VM_INTERRUPTED(th->ec)) {
th->event_serial++; // make sure timer thread doesn't try to wake us
th->sched.event_serial++; // make sure timer thread doesn't try to wake us
need_cancel = true;
}
else {

View File

@ -1130,7 +1130,6 @@ typedef struct rb_thread_struct {
struct rb_thread_sched_item sched;
bool mn_schedulable;
rb_atomic_t serial; // only for RUBY_DEBUG_LOG()
uint32_t event_serial;
VALUE last_status; /* $? */