From: cruzzhao <cruzzhao@linux.alibaba.com>
To: Peter Zijlstra <peterz@infradead.org>
Cc: mingo@redhat.com, juri.lelli@redhat.com,
vincent.guittot@linaro.org, dietmar.eggemann@arm.com,
rostedt@goodmis.org, bsegall@google.com, mgorman@suse.de,
bristot@redhat.com, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 1/3] sched/core: Fix the bug that task won't enqueue into core tree when update cookie
Date: Fri, 15 Jul 2022 13:08:23 +0800 [thread overview]
Message-ID: <4107a52c-131e-d683-898d-cdd2c2448137@linux.alibaba.com> (raw)
In-Reply-To: <YsKqf3mnv/aemeuC@hirez.programming.kicks-ass.net>
在 2022/7/4 下午4:53, Peter Zijlstra 写道:
> Subject: sched/core: Fix the bug that task won't enqueue into core tree when update cookie
> From: Cruz Zhao <CruzZhao@linux.alibaba.com>
> Date: Tue, 28 Jun 2022 15:57:23 +0800
>
> From: Cruz Zhao <CruzZhao@linux.alibaba.com>
>
> In function sched_core_update_cookie(), a task will enqueue into the
> core tree only when it enqueued before, that is, if an uncookied task
> is cookied, it will not enqueue into the core tree until it enqueue
> again, which will result in unnecessary force idle.
>
> Here follows the scenario:
> CPU x and CPU y are a pair of SMT siblings.
> 1. Start task a running on CPU x without sleeping, and task b and
> task c running on CPU y without sleeping.
> 2. We create a cookie and share it to task a and task b, and then
> we create another cookie and share it to task c.
> 3. Simpling core_forceidle_sum of task a and b from /proc/PID/sched
>
> And we will find out that core_forceidle_sum of task a takes 30%
> time of the sampling period, which shouldn't happen as task a and b
> have the same cookie.
>
> Then we migrate task a to CPU x', migrate task b and c to CPU y', where
> CPU x' and CPU y' are a pair of SMT siblings, and sampling again, we
> will found out that core_forceidle_sum of task a and b are almost zero.
>
> To solve this problem, we enqueue the task into the core tree if it's
> on rq.
>
> Fixes: 6e33cad0af49("sched: Trivial core scheduling cookie management")
> Signed-off-by: Cruz Zhao <CruzZhao@linux.alibaba.com>
> Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
> Link: https://lkml.kernel.org/r/1656403045-100840-2-git-send-email-CruzZhao@linux.alibaba.com
> ---
> kernel/sched/core_sched.c | 9 +++++----
> 1 file changed, 5 insertions(+), 4 deletions(-)
>
> --- a/kernel/sched/core_sched.c
> +++ b/kernel/sched/core_sched.c
> @@ -56,7 +56,6 @@ static unsigned long sched_core_update_c
> unsigned long old_cookie;
> struct rq_flags rf;
> struct rq *rq;
> - bool enqueued;
>
> rq = task_rq_lock(p, &rf);
>
> @@ -68,14 +67,16 @@ static unsigned long sched_core_update_c
> */
> SCHED_WARN_ON((p->core_cookie || cookie) && !sched_core_enabled(rq));
>
> - enqueued = sched_core_enqueued(p);
> - if (enqueued)
> + if (sched_core_enqueued(p))
> sched_core_dequeue(rq, p, DEQUEUE_SAVE);
>
> old_cookie = p->core_cookie;
> p->core_cookie = cookie;
>
> - if (enqueued)
> + /*
> + * Consider the cases: !prev_cookie and !cookie.
> + */
> + if (cookie && task_on_rq_queued(p))
> sched_core_enqueue(rq, p);
>
> /*
LGTM.
next prev parent reply other threads:[~2022-07-15 5:08 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-06-28 7:57 [PATCH 0/3] sched/core: Optimize load balance of core scheduling Cruz Zhao
2022-06-28 7:57 ` [PATCH 1/3] sched/core: Fix the bug that task won't enqueue into core tree when update cookie Cruz Zhao
2022-07-03 14:19 ` cruzzhao
2022-07-04 8:53 ` Peter Zijlstra
2022-07-14 11:37 ` Peter Zijlstra
2022-07-15 5:08 ` cruzzhao [this message]
2022-07-21 8:44 ` [tip: sched/core] " tip-bot2 for Cruz Zhao
2022-06-28 7:57 ` [PATCH 2/3] sched/core: Introduce nr_running percpu for each cookie Cruz Zhao
2022-07-04 8:56 ` Peter Zijlstra
2022-07-04 9:45 ` Peter Zijlstra
2022-07-06 7:45 ` cruzzhao
2022-06-28 7:57 ` [PATCH 3/3] sched/core: Make tasks with the same cookie pairs on SMT siblings Cruz Zhao
2022-07-04 9:43 ` Peter Zijlstra
2022-07-06 8:03 ` cruzzhao
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=4107a52c-131e-d683-898d-cdd2c2448137@linux.alibaba.com \
--to=cruzzhao@linux.alibaba.com \
--cc=bristot@redhat.com \
--cc=bsegall@google.com \
--cc=dietmar.eggemann@arm.com \
--cc=juri.lelli@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mgorman@suse.de \
--cc=mingo@redhat.com \
--cc=peterz@infradead.org \
--cc=rostedt@goodmis.org \
--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
all inboxes | Powered by JetHome®