[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <bf413365-9cb3-be9e-18b7-4be52e0fa1cf@yandex-team.ru>
Date: Mon, 14 May 2018 14:05:14 +0300
From: Konstantin Khlebnikov <khlebnikov@...dex-team.ru>
To: Peter Zijlstra <peterz@...radead.org>,
Ingo Molnar <mingo@...hat.com>, linux-kernel@...r.kernel.org
Cc: Ben Segall <bsegall@...gle.com>
Subject: Re: [PATCH] sched: refill quota for current period when refilling
timer activates
On 14.05.2018 13:58, Konstantin Khlebnikov wrote:
> Period timer deactivates if task group has no activity during past period,
> i.e. if were no throttle and runtime from global pool weren't consumed.
> When timer activates back global pool contains unpredictable amount of
> expired runtime allocated long ago. In some cases this works fine and
> task could use it until next refill. But series short execution slices
> could drain all that leftovers because each switch expires local poll.
> In this case task group will be throttled until quota refill.
Attached piece of code allows to reproduce problem.
run
sched-burst 10 10000000 1000000000
in cgroup with
cpu.cfs_period_us = 100000
cpu.cfs_quota_us = 1100000
Series of sched_yield() drains stale runtime from global pool before refilling.
>
> This patch refills quota right at the moment of timer's activation.
>
> Signed-off-by: Konstantin Khlebnikov <khlebnikov@...dex-team.ru>
> ---
> kernel/sched/fair.c | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
> index 79f574dba096..b8d73ed17ff6 100644
> --- a/kernel/sched/fair.c
> +++ b/kernel/sched/fair.c
> @@ -5165,6 +5165,8 @@ void start_cfs_bandwidth(struct cfs_bandwidth *cfs_b)
>
> if (!cfs_b->period_active) {
> cfs_b->period_active = 1;
> + /* refill quota for current period after inactivity */
> + __refill_cfs_bandwidth_runtime(cfs_b);
> hrtimer_forward_now(&cfs_b->period_timer, cfs_b->period);
> hrtimer_start_expires(&cfs_b->period_timer, HRTIMER_MODE_ABS_PINNED);
> }
>
View attachment "sched-burst.c" of type "text/x-csrc" (2071 bytes)
Powered by blists - more mailing lists