mirror of
https://github.com/torvalds/linux.git
synced 2026-09-22 04:34:03 +02:00
sched_ext: Don't BUG_ON a destroyed DSQ in process_deferred_reenq_users
scx_bpf_dsq_reenq() queues a deferred reenq (dru) that runs from
run_deferred(), not ops.dispatch(). If the DSQ is destroyed before the dru
runs, process_deferred_reenq_users() sees dsq->id == SCX_DSQ_INVALID and
hits the BUG_ON. destroy_dsq() doesn't flush pending drus, so just skip.
tj: Read dsq->id once with READ_ONCE(). Reading it separately in the INVALID
check and the BUG_ON would leave a window where destroy_dsq() can
invalidate the id between the two reads and still trigger the BUG_ON.
Fixes: 84b1a0ea0b ("sched_ext: Implement scx_bpf_dsq_reenq() for user DSQs")
Cc: stable@vger.kernel.org # v7.1+
Signed-off-by: Tao Cui <cuitao@kylinos.cn>
Signed-off-by: Tejun Heo <tj@kernel.org>
This commit is contained in:
parent
56bbc91219
commit
8d8dd8ae89
|
|
@ -4613,7 +4613,7 @@ static void process_deferred_reenq_users(struct rq *rq)
|
|||
|
||||
while (true) {
|
||||
struct scx_dispatch_q *dsq;
|
||||
u64 reenq_flags;
|
||||
u64 dsq_id, reenq_flags;
|
||||
|
||||
scoped_guard (raw_spinlock, &rq->scx.deferred_reenq_lock) {
|
||||
struct scx_deferred_reenq_user *dru =
|
||||
|
|
@ -4636,7 +4636,12 @@ static void process_deferred_reenq_users(struct rq *rq)
|
|||
/* see schedule_dsq_reenq() */
|
||||
smp_mb();
|
||||
|
||||
BUG_ON(dsq->id & SCX_DSQ_FLAG_BUILTIN);
|
||||
/* destroy_dsq() may have raced and invalidated @dsq, nothing to reenq */
|
||||
dsq_id = READ_ONCE(dsq->id);
|
||||
if (unlikely(dsq_id == SCX_DSQ_INVALID))
|
||||
continue;
|
||||
|
||||
BUG_ON(dsq_id & SCX_DSQ_FLAG_BUILTIN);
|
||||
reenq_user(rq, dsq, reenq_flags);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user