From: Peter Zijlstra <peterz@infradead.org>
To: Huaixin Chang <changhuaixin@linux.alibaba.com>
Cc: linux-kernel@vger.kernel.org, shanpeic@linux.alibaba.com,
yun.wang@linux.alibaba.com, xlpang@linux.alibaba.com,
mingo@redhat.com, bsegall@google.com, chiluk+linux@indeed.com,
vincent.guittot@linaro.org
Subject: Re: [PATCH v3] sched/fair: Fix race between runtime distribution and assignment
Date: Mon, 30 Mar 2020 12:44:15 +0200 [thread overview]
Message-ID: <20200330104415.GF20696@hirez.programming.kicks-ass.net> (raw)
In-Reply-To: <20200327032625.53856-1-changhuaixin@linux.alibaba.com>
On Fri, Mar 27, 2020 at 11:26:25AM +0800, Huaixin Chang wrote:
> Currently, there is a potential race between distribute_cfs_runtime()
> and assign_cfs_rq_runtime(). Race happens when cfs_b->runtime is read,
> distributes without holding lock and finds out there is not enough
> runtime to charge against after distribution. Because
> assign_cfs_rq_runtime() might be called during distribution, and use
> cfs_b->runtime at the same time.
>
> Fibtest is the tool to test this race. Assume all gcfs_rq is throttled
> and cfs period timer runs, slow threads might run and sleep, returning
> unused cfs_rq runtime and keeping min_cfs_rq_runtime in their local
> pool. If all this happens sufficiently quickly, cfs_b->runtime will drop
> a lot. If runtime distributed is large too, over-use of runtime happens.
>
> A runtime over-using by about 70 percent of quota is seen when we
> test fibtest on a 96-core machine. We run fibtest with 1 fast thread and
> 95 slow threads in test group, configure 10ms quota for this group and
> see the CPU usage of fibtest is 17.0%, which is far more than the
> expected 10%.
>
> On a smaller machine with 32 cores, we also run fibtest with 96
> threads. CPU usage is more than 12%, which is also more than expected
> 10%. This shows that on similar workloads, this race do affect CPU
> bandwidth control.
>
> Solve this by holding lock inside distribute_cfs_runtime().
>
> Fixes: c06f04c70489 ("sched: Fix potential near-infinite distribute_cfs_runtime() loop")
> Signed-off-by: Huaixin Chang <changhuaixin@linux.alibaba.com>
> Reviewed-by: Ben Segall <bsegall@google.com>
Thanks!
prev parent reply other threads:[~2020-03-30 10:44 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-03-25 9:26 [PATCH] alios: sched: Fix race between runtime distribution and assignment Huaixin Chang
2020-03-26 6:56 ` [PATCH v2] " Huaixin Chang
2020-03-26 17:27 ` bsegall
2020-03-27 3:26 ` [PATCH v3] sched/fair: " Huaixin Chang
2020-03-30 10:44 ` Peter Zijlstra [this message]
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=20200330104415.GF20696@hirez.programming.kicks-ass.net \
--to=peterz@infradead.org \
--cc=bsegall@google.com \
--cc=changhuaixin@linux.alibaba.com \
--cc=chiluk+linux@indeed.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=shanpeic@linux.alibaba.com \
--cc=vincent.guittot@linaro.org \
--cc=xlpang@linux.alibaba.com \
--cc=yun.wang@linux.alibaba.com \
/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).