mirror of
https://github.com/torvalds/linux.git
synced 2026-11-07 06:17:02 +01:00
sched_ext: Move reject DSQ draining into core
The reject DSQ drain will be generalized for placement failures outside sub-scheduler capability rejection. Move the drain into the core sched_ext implementation first so the subsequent behavioral changes can be reviewed separately. No functional change. Signed-off-by: Andrea Righi <arighi@nvidia.com> Signed-off-by: Tejun Heo <tj@kernel.org>
This commit is contained in:
parent
5f882051ef
commit
cea8b60e4a
|
|
@ -4849,6 +4849,56 @@ static void process_deferred_reenq_users(struct rq *rq)
|
|||
}
|
||||
}
|
||||
|
||||
#ifdef CONFIG_EXT_SUB_SCHED
|
||||
/*
|
||||
* Drain @rq->scx.reject_dsq, reenqueueing each task so the BPF re-decides
|
||||
* from p->scx.reenq_reason_*.
|
||||
*
|
||||
* A task can be re-rejected repeatedly. The reenqueue is bounded per task in
|
||||
* scx_do_enqueue_task(), which ejects the owning sub past SCX_REENQ_MAX_REPEAT.
|
||||
* Rejection can't happen for root.
|
||||
*/
|
||||
static void scx_reenq_reject(struct rq *rq)
|
||||
{
|
||||
LIST_HEAD(tasks);
|
||||
struct task_struct *p, *n;
|
||||
|
||||
lockdep_assert_rq_held(rq);
|
||||
|
||||
if (!scx_has_subs() || list_empty(&rq->scx.reject_dsq.list))
|
||||
return;
|
||||
|
||||
/*
|
||||
* Move to a private list so a task re-rejected by the
|
||||
* scx_do_enqueue_task() below isn't revisited this round.
|
||||
*/
|
||||
list_for_each_entry_safe(p, n, &rq->scx.reject_dsq.list, scx.dsq_list.node) {
|
||||
/* migration_pending tasks should have bypassed to local DSQ */
|
||||
if (WARN_ON_ONCE(p->migration_pending))
|
||||
continue;
|
||||
|
||||
scx_reenq_wait_dispatching(p);
|
||||
scx_dispatch_dequeue(rq, p);
|
||||
|
||||
if (WARN_ON_ONCE(p->scx.flags & SCX_TASK_REENQ_REASON_MASK))
|
||||
p->scx.flags &= ~SCX_TASK_REENQ_REASON_MASK;
|
||||
p->scx.flags |= SCX_TASK_REENQ_CAP;
|
||||
|
||||
list_add_tail(&p->scx.dsq_list.node, &tasks);
|
||||
}
|
||||
|
||||
list_for_each_entry_safe(p, n, &tasks, scx.dsq_list.node) {
|
||||
list_del_init(&p->scx.dsq_list.node);
|
||||
|
||||
scx_do_enqueue_task(rq, p, SCX_ENQ_REENQ, -1);
|
||||
|
||||
p->scx.flags &= ~SCX_TASK_REENQ_REASON_MASK;
|
||||
}
|
||||
}
|
||||
#else
|
||||
static void scx_reenq_reject(struct rq *rq) {}
|
||||
#endif
|
||||
|
||||
static void run_deferred(struct rq *rq)
|
||||
{
|
||||
process_ddsp_deferred_locals(rq);
|
||||
|
|
|
|||
|
|
@ -772,50 +772,6 @@ bool scx_task_reenq_on_cap_revoke(struct rq *rq, struct task_struct *p)
|
|||
return true;
|
||||
}
|
||||
|
||||
/*
|
||||
* Drain @rq->scx.reject_dsq, reenqueueing each task so the BPF re-decides
|
||||
* from p->scx.reenq_reason_*.
|
||||
*
|
||||
* A task can be re-rejected repeatedly. The reenqueue is bounded per task in
|
||||
* scx_do_enqueue_task(), which ejects the owning sub past SCX_REENQ_MAX_REPEAT.
|
||||
* Rejection can't happen for root.
|
||||
*/
|
||||
void __scx_reenq_reject(struct rq *rq)
|
||||
{
|
||||
LIST_HEAD(tasks);
|
||||
struct task_struct *p, *n;
|
||||
|
||||
if (list_empty(&rq->scx.reject_dsq.list))
|
||||
return;
|
||||
|
||||
/*
|
||||
* Move to a private list so a task re-rejected by the
|
||||
* scx_do_enqueue_task() below isn't revisited this round.
|
||||
*/
|
||||
list_for_each_entry_safe(p, n, &rq->scx.reject_dsq.list, scx.dsq_list.node) {
|
||||
/* migration_pending tasks should have bypassed to local DSQ */
|
||||
if (WARN_ON_ONCE(p->migration_pending))
|
||||
continue;
|
||||
|
||||
scx_reenq_wait_dispatching(p);
|
||||
scx_dispatch_dequeue(rq, p);
|
||||
|
||||
if (WARN_ON_ONCE(p->scx.flags & SCX_TASK_REENQ_REASON_MASK))
|
||||
p->scx.flags &= ~SCX_TASK_REENQ_REASON_MASK;
|
||||
p->scx.flags |= SCX_TASK_REENQ_CAP;
|
||||
|
||||
list_add_tail(&p->scx.dsq_list.node, &tasks);
|
||||
}
|
||||
|
||||
list_for_each_entry_safe(p, n, &tasks, scx.dsq_list.node) {
|
||||
list_del_init(&p->scx.dsq_list.node);
|
||||
|
||||
scx_do_enqueue_task(rq, p, SCX_ENQ_REENQ, -1);
|
||||
|
||||
p->scx.flags &= ~SCX_TASK_REENQ_REASON_MASK;
|
||||
}
|
||||
}
|
||||
|
||||
/* record a caps change, see struct scx_caps_updated */
|
||||
static void caps_updated_record(struct scx_pshard *ps, const struct scx_cmask *cids, u64 caps,
|
||||
struct list_head *to_deliver)
|
||||
|
|
|
|||
|
|
@ -37,7 +37,6 @@ void scx_discard_stale_ecaps_syncs(void);
|
|||
struct scx_dispatch_q *__scx_resolve_local_dsq(struct scx_sched *sch, struct rq *rq,
|
||||
struct task_struct *p, u64 *enq_flags);
|
||||
bool scx_task_reenq_on_cap_revoke(struct rq *rq, struct task_struct *p);
|
||||
void __scx_reenq_reject(struct rq *rq);
|
||||
void scx_rescue_charge(struct rq *rq, s64 delta_exec);
|
||||
void scx_rescue_end(struct rq *rq);
|
||||
bool scx_rescue_keep(struct rq *rq, struct task_struct *p);
|
||||
|
|
@ -91,14 +90,6 @@ static inline struct scx_dispatch_q *scx_resolve_local_dsq(struct scx_sched *sch
|
|||
return __scx_resolve_local_dsq(sch, rq, p, enq_flags);
|
||||
}
|
||||
|
||||
static inline void scx_reenq_reject(struct rq *rq)
|
||||
{
|
||||
lockdep_assert_rq_held(rq);
|
||||
|
||||
if (scx_has_subs())
|
||||
__scx_reenq_reject(rq);
|
||||
}
|
||||
|
||||
#else /* CONFIG_EXT_SUB_SCHED */
|
||||
|
||||
static inline struct scx_sched *scx_next_descendant_pre(struct scx_sched *pos, struct scx_sched *root) { return pos ? NULL : root; }
|
||||
|
|
@ -120,7 +111,6 @@ static inline void scx_discard_ecaps_to_sync(s32 cpu, struct scx_sched_pcpu *pcp
|
|||
static inline void scx_discard_stale_ecaps_syncs(void) {}
|
||||
static inline struct scx_dispatch_q *scx_resolve_local_dsq(struct scx_sched *sch, struct rq *rq, struct task_struct *p, u64 *enq_flags) { return &rq->scx.local_dsq; }
|
||||
static inline bool scx_task_reenq_on_cap_revoke(struct rq *rq, struct task_struct *p) { return false; }
|
||||
static inline void scx_reenq_reject(struct rq *rq) {}
|
||||
static inline void scx_rescue_charge(struct rq *rq, s64 delta_exec) {}
|
||||
static inline void scx_rescue_end(struct rq *rq) {}
|
||||
static inline bool scx_rescue_keep(struct rq *rq, struct task_struct *p) { return false; }
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user