Re: [PATCH] arm64/mm: Add memory barrier for mm_cid
From: levi.yun
Date: Tue Mar 05 2024 - 13:53:28 EST
Hi will.
We already have a stronger barrier than smp_mb() (dsb ish) in __switch_to().
Is that not sufficient?
IIUC, It's not sufficient with smp_mb() in __switch_to().
Because, it can be broken in sched_mm_cid_remote_clear()
CPU0 in __schedule() CPU1 in
sched_mm_cid_remote_clear()
rq->curr = new_task;
<no barrier>
mm_get_cid remote_clear
- check valid cid and use it. Invalidate CID.
<barrier>
rq->curr (not observed).
unset the cid
(<<BUG).
If change of rq->curr couldn't be observed in sched_mm_cid_remote_clear(),
It could unset actively used cid.
Note that __switch_to()'s smp_mb() is called AFTER switch_mm_cid().
That means before __switch_to(), there's possibility that
sched_mm_cid_remote_clear() couldn't observe new active task,
after it sets lazy_put on active cid used by new active task.