us words indicate that some queue is empty. + */ +static inline bool +runq_sw_is_empty(struct runq *rq, int idx) +{ + return (runq_sw_apply(rq, idx, &runq_sw_is_empty_op)); +} + +/* + * Returns whether a particular queue is empty. + */ +bool +runq_is_queue_empty(struct runq *rq, int idx) +{ + + return (runq_sw_is_empty(rq, idx)); +} + /* * Add the thread to the queue specified by its priority, and set the * corresponding status bit. diff --git a/sys/kern/sched_ule.c b/sys/kern/sched_ule.c index 8fdc71c21e64..d8abb911a887 100644 --- a/sys/kern/sched_ule.c +++ b/sys/kern/sched_ule.c @@ -2605,7 +2605,7 @@ sched_clock(struct thread *td, int cnt) */ if (tdq->tdq_idx == tdq->tdq_ridx) { tdq->tdq_idx = (tdq->tdq_idx + 1) % RQ_NQS; - if (TAILQ_EMPTY(&tdq->tdq_timeshare.rq_queues[tdq->tdq_ridx])) + if (runq_is_queue_empty(&tdq->tdq_timeshare, tdq->tdq_ridx)) tdq->tdq_ridx = tdq->tdq_idx; } ts = td_get_sched(td); diff --git a/sys/sys/runq.h b/sys/sys/runq.h index c570dd25503b..5156a7d8c307 100644 --- a/sys/sys/runq.h +++ b/sys/sys/runq.h @@ -98,6 +98,7 @@ struct runq { }; void runq_init(struct runq *); +bool runq_is_queue_empty(struct runq *, int _idx); void runq_add(struct runq *, struct thread *, int _flags); void runq_add_idx(struct runq *, struct thread *, int _idx, int _flags); bool runq_remove(struct runq *, struct thread *);