From: Peter Zijlstra <peterz@infradead.org>
To: Tao Zhou <tao.zhou@linux.dev>
Cc: linux-kernel@vger.kernel.org, tglx@linutronix.de,
joel@joelfernandes.org, chris.hyser@oracle.com,
joshdon@google.com, mingo@kernel.org, vincent.guittot@linaro.org,
valentin.schneider@arm.com, mgorman@suse.de
Subject: Re: [PATCH] sched/core: An optimization of pick_next_task() not sure
Date: Mon, 16 Aug 2021 20:52:39 +0200 [thread overview]
Message-ID: <YRqz93crZIS1Mvmy@hirez.programming.kicks-ass.net> (raw)
In-Reply-To: <20210816154401.23919-1-tao.zhou@linux.dev>
On Mon, Aug 16, 2021 at 11:44:01PM +0800, Tao Zhou wrote:
> When find a new candidate max, wipe the stale and start over.
> Goto again: and use the new max to loop to pick the the task.
>
> Here first want to get the max of the core and use this new
> max to loop once to pick the task on each thread.
>
> Not sure this is an optimization and just stop here a little
> and move on..
>
Did you find this retry was an issue on your workload? Or was this from
reading the source?
> ---
> kernel/sched/core.c | 52 +++++++++++++++++----------------------------
> 1 file changed, 20 insertions(+), 32 deletions(-)
>
> diff --git a/kernel/sched/core.c b/kernel/sched/core.c
> index 20ffcc044134..bddcd328df96 100644
> --- a/kernel/sched/core.c
> +++ b/kernel/sched/core.c
> @@ -5403,7 +5403,7 @@ pick_next_task(struct rq *rq, struct task_struct *prev, struct rq_flags *rf)
> const struct sched_class *class;
> const struct cpumask *smt_mask;
> bool fi_before = false;
> - int i, j, cpu, occ = 0;
> + int i, cpu, occ = 0;
> bool need_sync;
>
> if (!sched_core_enabled(rq))
> @@ -5508,11 +5508,27 @@ pick_next_task(struct rq *rq, struct task_struct *prev, struct rq_flags *rf)
> * order.
> */
> for_each_class(class) {
> -again:
> + struct rq *rq_i;
> + struct task_struct *p;
> +
> for_each_cpu_wrap(i, smt_mask, cpu) {
> - struct rq *rq_i = cpu_rq(i);
> - struct task_struct *p;
> + rq_i = cpu_rq(i);
> + p = pick_task(rq_i, class, max, fi_before);
> + /*
> + * If this new candidate is of higher priority than the
> + * previous; and they're incompatible; pick_task makes
> + * sure that p's priority is more than max if it doesn't
> + * match max's cookie. Update max.
> + *
> + * NOTE: this is a linear max-filter and is thus bounded
> + * in execution time.
> + */
> + if (!max || !cookie_match(max, p))
> + max = p;
> + }
>
> + for_each_cpu_wrap(i, smt_mask, cpu) {
> + rq_i = cpu_rq(i);
> if (rq_i->core_pick)
> continue;
>
This now calls pick_task() twice for each CPU, which seems unfortunate;
perhaps add q->core_temp storage to cache that result. Also, since the
first iteration is now explicitly about the max filter, perhaps we
shouuld move that part of pick_task() into the loop and simplify things
further?
next prev parent reply other threads:[~2021-08-16 18:54 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-08-16 15:44 [PATCH] sched/core: An optimization of pick_next_task() not sure Tao Zhou
2021-08-16 18:52 ` Peter Zijlstra [this message]
2021-08-16 19:02 ` Josh Don
2021-08-17 16:45 ` Tao Zhou
2021-08-18 19:23 ` Tao Zhou
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=YRqz93crZIS1Mvmy@hirez.programming.kicks-ass.net \
--to=peterz@infradead.org \
--cc=chris.hyser@oracle.com \
--cc=joel@joelfernandes.org \
--cc=joshdon@google.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mgorman@suse.de \
--cc=mingo@kernel.org \
--cc=tao.zhou@linux.dev \
--cc=tglx@linutronix.de \
--cc=valentin.schneider@arm.com \
--cc=vincent.guittot@linaro.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).