Messages in this thread | | | Date | Mon, 20 Mar 2023 13:47:01 +0100 | From | Peter Zijlstra <> | Subject | Re: [PATCH] sched/core: Avoid selecting the task that is throttled to run when core-sched enable |
| |
On Thu, Mar 16, 2023 at 04:18:06PM +0800, Hao Jia wrote:
> diff --git a/kernel/sched/core.c b/kernel/sched/core.c > index af017e038b48..27cb06e19b12 100644 > --- a/kernel/sched/core.c > +++ b/kernel/sched/core.c > @@ -261,36 +261,51 @@ void sched_core_dequeue(struct rq *rq, struct task_struct *p, int flags) > resched_curr(rq); > } > > +static int sched_task_is_throttled(struct task_struct *p, int cpu) > { > + if (p->sched_class->task_is_throttled) > + return p->sched_class->task_is_throttled(p, cpu); > > + return 0; > } > > static struct task_struct *sched_core_next(struct task_struct *p, unsigned long cookie) > { > struct rb_node *node = &p->core_node; > + int cpu = task_cpu(p); > + > + do { > + node = rb_next(node); > + if (!node) > + return NULL; > + > + p = container_of(node, struct task_struct, core_node);
I've changed this to __node_2_sc() to match the rest. It looks to have been randomly not using it.
> + if (p->core_cookie != cookie) > + return NULL; > + } while (sched_task_is_throttled(p, cpu)); > + > + return p; > +} > > +/* > + * Find left-most (aka, highest priority) and unthrottled task matching @cookie. > + * If no suitable task is found, NULL will be returned. > + */ > +static struct task_struct *sched_core_find(struct rq *rq, unsigned long cookie) > +{ > + struct task_struct *p; > + struct rb_node *node; > + > + node = rb_find_first((void *)cookie, &rq->core_tree, rb_sched_core_cmp); > if (!node) > return NULL; > > + p = __node_2_sc(node); > + if (!sched_task_is_throttled(p, rq->cpu)) > + return p; > + > + return sched_core_next(p, cookie); > } > > /*
OK, fair enough.
| |