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.

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.

Best regards,
Alperen Erkan
On Mon, Nov 23, 2026 at 11:41 AM Donjuanplatinum <[email protected]>
wrote:

> Samuel Thibault <[email protected]> writes:
>
> >
> > But again, the added complexity of that if + shift + if + += is probably
> > not worth it. Better keep the code simple, it will be easier to read
> > for humans, and the compiler will also probably be at better ease to
> > understand that we are simply looking for a bit, and replace the whole
> > thing with the native operation for this.
> >
> Hi Samuel,
>
> I think thats right, I've changed it and also other review comments.
>
> > else you can set it to i+1, just like above. Better keep the two codes
> > very similar. That could even be factorized into a function or macro.
>
> I've updated it to set runq->low to i + 1 and factorize them as
> suggested. I haven't factored the common code into a macro for now,
> since it is only used in two places as I think.
>
>
> --
> Donjuanplatinum, Yifei Yao <[email protected]>
> GPG: 1C9E EEE5 4C8E D5A8 3039  1C87 A9F6 8632 D259 40E6
> 满堂兮美人 忽独与余兮目成
>

Reply via email to