CVSROOT:        /cvs
Module name:    src
Changes by:     [email protected]    2025/12/04 16:15:55

Modified files:
        sys/arch/alpha/alpha: pmap.c 

Log message:
rework how tlb shootdown information is sent between cpus.

this change avoids using a mutex to coordinate work between cpus.

previously every cpu had a list of structs that represented a
shootdown "job" that another cpu might want to send it. these structs
were protected by a per cpu mutex, so if cpu A wanted to send a
shootdown to B, cpu A would take Bs lock, take a job from the free
list, fill it in, queue the job on a pending list, release the
mutex, and then send an IPI to B.

the ipi handler on B would then take the mutex, pop jobs off the
pending list, run them, queue them back on the free list, and then
release its mutex.

in this change there's no mutex, instead each job slot has an
individual "state" field. so if cpu A wants to send a shootdown to
B, A iterates over all the job slots on B and tries cas ops against
the state field to transition it from "idle" to "pending". if cpu
A can take ownership of a job slot on cpu B, it then fills in the
shootdown info, and then sets the job state to "valid" before sending
the IPI to B. setting the state to valid releases As ownership of
the job and gives it to B for processing.

cpu B then iterates over its job slots looking for "valid" states.
if it finds a valid state it'll process the shootdown and then reset
the state back to "idle", making it available for other cpus to try
and use for sending shootdowns with.

so in addition to avoiding the use of a mutex in IPI code, this
also improves concurrency by allowing multiple cpus to queue jobs
on each other without being serialised by the mutex, or being blocked
by the cpu processing it's own jobs submitted by other CPUs.

if there isn't a spare job slot on a cpu, both the old and new code
would fall back to asking the remote cpu to do a global flush. in
the old code this fall back was also protected by the mutex, in the
new code it's more atomic operations.

miod@ has tested this on a dual cpu CS20, and a quad cpu ES40.
i think i was lucky that the weather was cold and he wanted to warm
his space up.
i've tested this on an es45 with 3 cpus.

ok miod@

Reply via email to