[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CANDhNCq4kOCbMn9Pj2jtQUHofzG8qX6u8DFNc-hqas=tBxPWDw@mail.gmail.com>
Date: Thu, 4 Jan 2024 19:12:36 -0800
From: John Stultz <jstultz@...gle.com>
To: Metin Kaya <metin.kaya@....com>
Cc: LKML <linux-kernel@...r.kernel.org>, Joel Fernandes <joelaf@...gle.com>,
Qais Yousef <qyousef@...gle.com>, Ingo Molnar <mingo@...hat.com>,
Peter Zijlstra <peterz@...radead.org>, Juri Lelli <juri.lelli@...hat.com>,
Vincent Guittot <vincent.guittot@...aro.org>, Dietmar Eggemann <dietmar.eggemann@....com>,
Valentin Schneider <vschneid@...hat.com>, Steven Rostedt <rostedt@...dmis.org>,
Ben Segall <bsegall@...gle.com>, Zimuzo Ezeozue <zezeozue@...gle.com>,
Youssef Esmat <youssefesmat@...gle.com>, Mel Gorman <mgorman@...e.de>,
Daniel Bristot de Oliveira <bristot@...hat.com>, Will Deacon <will@...nel.org>, Waiman Long <longman@...hat.com>,
Boqun Feng <boqun.feng@...il.com>, "Paul E. McKenney" <paulmck@...nel.org>,
Xuewen Yan <xuewen.yan94@...il.com>, K Prateek Nayak <kprateek.nayak@....com>,
Thomas Gleixner <tglx@...utronix.de>, kernel-team@...roid.com
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@....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
Powered by blists - more mailing lists