File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -1996,6 +1996,12 @@ R"(
19961996 if ((possibly_running && th->state == states::RUNNING ) ||
19971997 !th->allow_work_stealing ()) {
19981998 th = th->next ();
1999+ } else if (th->idx != -1 ) {
2000+ // sleeping threads interrupted by another vCPU are inserted to
2001+ // standby q without poping from sleeping q, they can not be stolen.
2002+ th = th->next ();
2003+ // note that migrated threads are also inserted to standby q, but
2004+ // they are not in a sleeping q, so they are able to be stolen.
19992005 } else {
20002006 auto next = th->remove_from_list ();
20012007 stolen.push_back (th); count++;
@@ -2145,7 +2151,13 @@ R"(
21452151 }
21462152 static int do_thread_migrate (thread* th, vcpu_base* vb) {
21472153 assert (vb != th->vcpu );
2148- AtomicRunQ ().remove_from_list (th);
2154+ AtomicRunQ arq;
2155+ SCOPED_LOCK (th->lock );
2156+ if (th->state != READY || th->vcpu != CURRENT ->vcpu ) {
2157+ LOG_ERROR_RETURN (EINVAL , -1 ,
2158+ " thread ` state changed during migrate" , th)
2159+ }
2160+ arq.remove_from_list (th);
21492161 th->get_vcpu ()->nthreads --;
21502162 th->state = STANDBY ;
21512163 auto vcpu = (vcpu_t *)vb;
You can’t perform that action at this time.
0 commit comments