From: changhuaixin <changhuaixin@linux.alibaba.com>
To: Peter Zijlstra <peterz@infradead.org>
Cc: changhuaixin <changhuaixin@linux.alibaba.com>,
luca.abeni@santannapisa.it, anderson@cs.unc.edu,
baruah@wustl.edu, Benjamin Segall <bsegall@google.com>,
Dietmar Eggemann <dietmar.eggemann@arm.com>,
dtcccc@linux.alibaba.com, Juri Lelli <juri.lelli@redhat.com>,
khlebnikov@yandex-team.ru,
open list <linux-kernel@vger.kernel.org>,
Mel Gorman <mgorman@suse.de>, Ingo Molnar <mingo@redhat.com>,
Odin Ugedal <odin@uged.al>, Odin Ugedal <odin@ugedal.com>,
pauld@redhead.com, Paul Turner <pjt@google.com>,
Steven Rostedt <rostedt@goodmis.org>,
Shanpei Chen <shanpeic@linux.alibaba.com>,
Tejun Heo <tj@kernel.org>,
tommaso.cucinotta@santannapisa.it,
Vincent Guittot <vincent.guittot@linaro.org>,
xiyou.wangcong@gmail.com
Subject: Re: [PATCH v6 2/3] sched/fair: Add cfs bandwidth burst statistics
Date: Fri, 2 Jul 2021 19:31:54 +0800 [thread overview]
Message-ID: <8D470B39-00F8-4C87-92B8-BA645639AB24@linux.alibaba.com> (raw)
In-Reply-To: <YNnkDnJtliEInwTY@hirez.programming.kicks-ass.net>
> On Jun 28, 2021, at 11:00 PM, Peter Zijlstra <peterz@infradead.org> wrote:
>
> On Mon, Jun 21, 2021 at 05:27:59PM +0800, Huaixin Chang wrote:
>> The following statistics in cpu.stat file is added to show how much workload
>> is making use of cfs_b burst:
>>
>> nr_bursts: number of periods bandwidth burst occurs
>> burst_usec: cumulative wall-time that any cpus has
>> used above quota in respective periods
>>
>> The larger nr_bursts is, the more bursty periods there are. And the larger
>> burst_usec is, the more burst time is used by bursty workload.
>
> That's what it does, but fails to explain why. How is this number
> useful.
>
How about this?
The cfs_b burst feature avoids throttling by allowing bandwidth bursts. When using cfs_b
burst, users configure burst and see if it helps from workload latency and cfs_b interval
statistics like nr_throttled. Also two new statistics are introduced to show the internal of burst featrue
and explain why burst helps or not:
nr_bursts: number of periods bandwidth burst occurs
burst_usec: cumulative wall-time that any cpus has
used above quota in respective periods
>> diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
>> index 53d7cc4d009b..62b73722e510 100644
>> --- a/kernel/sched/fair.c
>> +++ b/kernel/sched/fair.c
>> @@ -4634,11 +4634,22 @@ static inline u64 sched_cfs_bandwidth_slice(void)
>> */
>> void __refill_cfs_bandwidth_runtime(struct cfs_bandwidth *cfs_b)
>> {
>> + u64 runtime;
>> +
>> if (unlikely(cfs_b->quota == RUNTIME_INF))
>> return;
>>
>> + if (cfs_b->runtime_at_period_start > cfs_b->runtime) {
>> + runtime = cfs_b->runtime_at_period_start - cfs_b->runtime;
>
> That comparison is the same as the subtraction; might as well write
> this:
>
>> + if (runtime > cfs_b->quota) {
>> + cfs_b->burst_time += runtime - cfs_b->quota;
>
> Same here.
>
>> + cfs_b->nr_burst++;
>> + }
>> + }
>
>
> Perhaps we can write that like:
>
> s64 runtime = cfs_b->runtime_snapshot - cfs_b->runtime;
> if (runtime > 0) {
> s64 burstime = runtime - cfs_q->quota;
> if (burstime > 0) {
> cfs_b->bust_time += bursttime;
> cfs_b->nr_bursts++;
> }
> }
>
> I was hoping we could get away with something simpler, like maybe:
>
Got it.
> u64 old_runtim = cfs_b->runtime;
>
> cfs_b->runtime += cfs_b->quota
> cfs_b->runtime = min(cfs_b->runtime, cfs_b->quota + cfs_b->burst);
>
> if (cfs_b->runtime - old_runtime > cfs_b->quota)
> cfs_b->nr_bursts++;
>
> Would that be good enough?
>
>
>> +
>> cfs_b->runtime += cfs_b->quota;
>> cfs_b->runtime = min(cfs_b->runtime, cfs_b->quota + cfs_b->burst);
>> + cfs_b->runtime_at_period_start = cfs_b->runtime;
>> }
>>
>> static inline struct cfs_bandwidth *tg_cfs_bandwidth(struct task_group *tg)
>> diff --git a/kernel/sched/sched.h b/kernel/sched/sched.h
>> index d317ca74a48c..b770b553dfbb 100644
>> --- a/kernel/sched/sched.h
>> +++ b/kernel/sched/sched.h
>> @@ -367,6 +367,7 @@ struct cfs_bandwidth {
>> u64 quota;
>> u64 runtime;
>> u64 burst;
>> + u64 runtime_at_period_start;
>> s64 hierarchical_quota;
>
> As per the above, I don't really like that name, runtime_snapshot or
> perhaps runtime_snap is shorter and not less clear. But not having it at
> all would be even better.
next prev parent reply other threads:[~2021-07-02 11:31 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-06-21 9:27 [PATCH v6 0/3] sched/fair: Burstable CFS bandwidth controller Huaixin Chang
2021-06-21 9:27 ` [PATCH v6 1/3] sched/fair: Introduce the burstable CFS controller Huaixin Chang
2021-06-22 13:19 ` Peter Zijlstra
2021-06-22 18:57 ` Benjamin Segall
2021-06-24 8:48 ` changhuaixin
2021-06-24 9:28 ` Peter Zijlstra
2021-06-22 15:27 ` Odin Ugedal
2021-06-23 8:47 ` Peter Zijlstra
2021-06-24 8:45 ` changhuaixin
2021-06-24 7:39 ` [tip: sched/core] " tip-bot2 for Huaixin Chang
2021-06-21 9:27 ` [PATCH v6 2/3] sched/fair: Add cfs bandwidth burst statistics Huaixin Chang
2021-06-28 15:00 ` Peter Zijlstra
2021-06-28 15:12 ` Peter Zijlstra
2021-07-02 11:31 ` changhuaixin [this message]
2021-06-21 9:28 ` [PATCH v6 3/3] sched/fair: Add document for burstable CFS bandwidth Huaixin Chang
2021-06-22 15:26 ` Odin Ugedal
2021-06-22 14:25 ` [PATCH v6 0/3] sched/fair: Burstable CFS bandwidth controller Tejun Heo
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=8D470B39-00F8-4C87-92B8-BA645639AB24@linux.alibaba.com \
--to=changhuaixin@linux.alibaba.com \
--cc=anderson@cs.unc.edu \
--cc=baruah@wustl.edu \
--cc=bsegall@google.com \
--cc=dietmar.eggemann@arm.com \
--cc=dtcccc@linux.alibaba.com \
--cc=juri.lelli@redhat.com \
--cc=khlebnikov@yandex-team.ru \
--cc=linux-kernel@vger.kernel.org \
--cc=luca.abeni@santannapisa.it \
--cc=mgorman@suse.de \
--cc=mingo@redhat.com \
--cc=odin@uged.al \
--cc=odin@ugedal.com \
--cc=pauld@redhead.com \
--cc=peterz@infradead.org \
--cc=pjt@google.com \
--cc=rostedt@goodmis.org \
--cc=shanpeic@linux.alibaba.com \
--cc=tj@kernel.org \
--cc=tommaso.cucinotta@santannapisa.it \
--cc=vincent.guittot@linaro.org \
--cc=xiyou.wangcong@gmail.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
all inboxes | Powered by JetHome®