Messages in this thread |  | | From | John Stultz <> | | Date | Thu, 4 Jan 2024 19:12:36 -0800 | | Subject | Re: [PATCH v7 21/23] sched: Add find_exec_ctx helper |
| |
On Fri, Dec 22, 2023 at 3:57 AM Metin Kaya <metin.kaya@arm.com> wrote: > On 20/12/2023 12:18 am, John Stultz wrote: > > diff --git a/kernel/sched/core.c b/kernel/sched/core.c > > index 0c212dcd4b7a..77a79d5f829a 100644 > > --- a/kernel/sched/core.c > > +++ b/kernel/sched/core.c > > @@ -3896,6 +3896,48 @@ static void activate_blocked_entities(struct rq *target_rq, > > } > > raw_spin_unlock_irqrestore(&owner->blocked_lock, flags); > > } > > + > > +static inline bool task_queued_on_rq(struct rq *rq, struct task_struct *task) > > +{ > > + if (!task_on_rq_queued(task)) > > + return false; > > + smp_rmb(); > > + if (task_rq(task) != rq) > > + return false; > > + smp_rmb(); > > + if (!task_on_rq_queued(task)) > > + return false; > > * Super-nit: we may want to have empty lines between `if` blocks and > before/after `smp_rmb()` calls.
Done.
> * I did not understand why we call `task_on_rq_queued(task)` twice. > Should we have an explanatory comment before the function definition?
Yeah. I'll put a better comment on my todo there.
> > diff --git a/kernel/sched/cpupri.c b/kernel/sched/cpupri.c > > index 15e947a3ded7..53be78afdd07 100644 > > --- a/kernel/sched/cpupri.c > > +++ b/kernel/sched/cpupri.c > > @@ -96,12 +96,17 @@ static inline int __cpupri_find(struct cpupri *cp, struct task_struct *p, > > if (skip) > > return 0; > > > > - if (cpumask_any_and(&p->cpus_mask, vec->mask) >= nr_cpu_ids) > > + if ((p && cpumask_any_and(&p->cpus_mask, vec->mask) >= nr_cpu_ids) || > > + (!p && cpumask_any(vec->mask) >= nr_cpu_ids)) > > return 0; > > > > if (lowest_mask) { > > - cpumask_and(lowest_mask, &p->cpus_mask, vec->mask); > > - cpumask_and(lowest_mask, lowest_mask, cpu_active_mask); > > + if (p) { > > + cpumask_and(lowest_mask, &p->cpus_mask, vec->mask); > > + cpumask_and(lowest_mask, lowest_mask, cpu_active_mask); > > + } else { > > + cpumask_copy(lowest_mask, vec->mask); > > + } > > I think changes in `cpupri.c` should be part of previous (`sched: Push > execution and scheduler context split into deadline and rt paths`) > patch. Because they don't seem to be related with find_exec_ctx()?
So, it's here only because find_exec_ctx() can return null, so we have to have the null p checks.
I'll think a bit if we can avoid it here.
> > @@ -2169,12 +2175,17 @@ static int find_later_rq(struct task_struct *sched_ctx, struct task_struct *exec > > /* Locks the rq it finds */ > > static struct rq *find_lock_later_rq(struct task_struct *task, struct rq *rq) > > { > > + struct task_struct *exec_ctx; > > struct rq *later_rq = NULL; > > int tries; > > int cpu; > > > > for (tries = 0; tries < DL_MAX_TRIES; tries++) { > > - cpu = find_later_rq(task, task); > > + exec_ctx = find_exec_ctx(rq, task); > > + if (!exec_ctx) > > + break; > > + > > + cpu = find_later_rq(task, exec_ctx); > > > > Super-nit: this empty line should be removed to keep logically connected > lines closer.
Done.
> > +#ifdef CONFIG_SCHED_PROXY_EXEC > > +struct task_struct *find_exec_ctx(struct rq *rq, struct task_struct *p); > > +#else /* !CONFIG_SCHED_PROXY_EXEC */ > > +static inline > > +struct task_struct *find_exec_ctx(struct rq *rq, struct task_struct *p) > > +{ > > + return p; > > +} > > +#endif /* CONFIG_SCHED_PROXY_EXEC */ > > #endif > > Nit: `#ifdef CONFIG_SMP` block becomes bigger after this hunk. We should > append `/* CONFIG_SMP */` to this line, IMHO. >
Done.
Thanks for the feedback! -john
|  |