Hello Yifei, Thanks for the revision. I checked the diff. simpler_thread_setrun() now sets the bitmap bit under the run queue lock, and both run_queue_enqueue() and rem_runq() use runq_index(). The new checkrq() check catches both a missing bit for a nonempty queue and a stale bit for an empty one.
This addresses my earlier review comments. My review was static. Have you also tested the eventcount wakeup path on a uniprocessor build with DEBUG enabled? Best regards, Alperen Erkan On Thu, Nov 26, 2026 at 5:40 PM Donjuanplatinum <[email protected]> wrote: > Alperen Erkan <[email protected]> writes: > > > Hello, > > > > I reviewed the bitmap changes and found two points concerning how the > scheduler keeps the bitmap > > consistent with > > the underlying queues. This was a static review. > > > > 1. Direct enqueue in kern/eventcount.c > > > > Could you confirm whether simpler_thread_setrun() is still present in > the target revision? In the GNU > > Mach source > > I checked, the uniprocessor eventcount wakeup path can insert a thread > directly into > > master_processor->runq using > > enqueue_head(). It updates low and count under the run queue lock. The > patch adds bitmap updates to > > the enqueue > > macros in sched_prim.c, but does not cover this separate path. > > > > If that path is present, inserting the only runnable thread into an > empty local run queue leaves count equal > > to one and the > > bitmap empty. choose_thread() would then reach panic("choose_thread: > bitmap/count > > mismatch"). The corresponding > > bit should be set under the same lock as the insertion. > > > Sure, indeed, I have missed this file, now added. > > 2. Queue index used by rem_runq() > > > > run_queue_enqueue bounds its local whichq to NRQS - 1 when the supplied > priority is out of range. The > > new removal code > > indexes rq->runq with th->sched_pri directly. Since the enqueue fallback > changes only whichq, > > removal can inspect a queue > > head outside the array and leave the bit for the actual queue set. > > > > Please use the same priority-to-index calculation for insertion and > removal. A small shared helper would > > keep the two paths consistent. > > > > It would also be useful to extend the existing DEBUG check in checkrq() > to compare each bitmap bit with > > the corresponding > > queue’s occupancy while the lock is held. That would catch a missed > bitmap update at the point where the > > queue is checked, > > before a later scheduling decision depends on it. > > > I have updated, added a helper for mapping priorities and also extended > checkrq(). > > > -- > Donjuanplatinum, Yifei Yao <[email protected]> > GPG: 1C9E EEE5 4C8E D5A8 3039 1C87 A9F6 8632 D259 40E6 > 满堂兮美人 忽独与余兮目成 >
