From c7f5cb3aea92165d20c4a89ffbee18e3ab03b9a2 Mon Sep 17 00:00:00 2001 From: Luke Gruber Date: Thu, 11 Dec 2025 10:43:41 -0500 Subject: [PATCH] move th->event_serial to rb_thread_sched_item --- thread_pthread.c | 2 +- thread_pthread.h | 3 ++- thread_pthread_mn.c | 6 +++--- vm_core.h | 1 - 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/thread_pthread.c b/thread_pthread.c index 66323598607398..a2e42da13e70b1 100644 --- a/thread_pthread.c +++ b/thread_pthread.c @@ -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); } } diff --git a/thread_pthread.h b/thread_pthread.h index f579e53781a74c..992e9fb0803d67 100644 --- a/thread_pthread.h +++ b/thread_pthread.h @@ -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; diff --git a/thread_pthread_mn.c b/thread_pthread_mn.c index ad4d0915e790b2..5c21f212e4ab37 100644 --- a/thread_pthread_mn.c +++ b/thread_pthread_mn.c @@ -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 { diff --git a/vm_core.h b/vm_core.h index 4195ea5e59c9a4..d391c4258a4337 100644 --- a/vm_core.h +++ b/vm_core.h @@ -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; /* $? */