From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751943AbcELDgz (ORCPT ); Wed, 11 May 2016 23:36:55 -0400 Received: from mx1.redhat.com ([209.132.183.28]:36455 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751552AbcELDgy (ORCPT ); Wed, 11 May 2016 23:36:54 -0400 Reply-To: xlpang@redhat.com Subject: Re: [PATCH] sched/fair: Fix the wrong throttled clock time for cfs_rq_clock_task() References: <1462885398-14724-1-git-send-email-xlpang@redhat.com> <20160511064929.GC3193@twins.programming.kicks-ass.net> To: Peter Zijlstra , bsegall@google.com Cc: Xunlei Pang , linux-kernel@vger.kernel.org, Juri Lelli , Ingo Molnar , Steven Rostedt , pjt@google.com From: Xunlei Pang Message-ID: <5733FA51.4050509@redhat.com> Date: Thu, 12 May 2016 11:36:49 +0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.2.0 MIME-Version: 1.0 In-Reply-To: <20160511064929.GC3193@twins.programming.kicks-ass.net> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Thu, 12 May 2016 03:36:53 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2016/05/11 at 14:49, Peter Zijlstra wrote: > On Tue, May 10, 2016 at 11:19:44AM -0700, bsegall@google.com wrote: >> Xunlei Pang writes: >> >>> Two minor fixes for cfs_rq_clock_task(). >>> 1) If cfs_rq is currently being throttled, we need to subtract the cfs >>> throttled clock time. >>> >>> 2) Make "throttled_clock_task_time" update SMP unrelated. Now UP cases >>> need it as well. >>> >>> Signed-off-by: Xunlei Pang >>> --- >>> kernel/sched/fair.c | 4 +--- >>> 1 file changed, 1 insertion(+), 3 deletions(-) >>> >>> diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c >>> index 1708729e..fb80a12 100644 >>> --- a/kernel/sched/fair.c >>> +++ b/kernel/sched/fair.c >>> @@ -3655,7 +3655,7 @@ static inline struct cfs_bandwidth *tg_cfs_bandwidth(struct task_group *tg) >>> static inline u64 cfs_rq_clock_task(struct cfs_rq *cfs_rq) >>> { >>> if (unlikely(cfs_rq->throttle_count)) >>> - return cfs_rq->throttled_clock_task; >>> + return cfs_rq->throttled_clock_task - cfs_rq->throttled_clock_task_time; >>> >>> return rq_clock_task(rq_of(cfs_rq)) - cfs_rq->throttled_clock_task_time; >>> } > The alternative is obviously to do the subtraction in > tg_throttle_down(), were we set ->throttled_clock_task. It is possible, but throttled_clock_task is a timestamp, I think doing it here is semantically better. > >>> @@ -3793,13 +3793,11 @@ static int tg_unthrottle_up(struct task_group *tg, void *data) >>> struct cfs_rq *cfs_rq = tg->cfs_rq[cpu_of(rq)]; >>> >>> cfs_rq->throttle_count--; >>> -#ifdef CONFIG_SMP >>> if (!cfs_rq->throttle_count) { >>> /* adjust cfs_rq_clock_task() */ >>> cfs_rq->throttled_clock_task_time += rq_clock_task(rq) - >>> cfs_rq->throttled_clock_task; >>> } >>> -#endif >>> >>> return 0; >>> } >> [Cc: pjt@google.com] >> >> This looks reasonable to me (at least the first part; I'm not >> certain why the CONFIG_SMP ifdef was put in place). > 64660c864f46 ("sched: Prevent interactions with throttled entities") > > Introduced it, because at that time it was about updating shares, which > is only present on SMP. Then: > > f1b17280efbd ("sched: Maintain runnable averages across throttled periods") > > Added the clock thing inside it, and: > > 82958366cfea ("sched: Replace update_shares weight distribution with per-entity computation") > > took out the shares update and left the clock update, resulting in the > current code. > > Thanks, Xunlei