From patchwork Wed Jan 11 11:29:47 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dietmar Eggemann X-Patchwork-Id: 90847 Delivered-To: patch@linaro.org Received: by 10.140.20.99 with SMTP id 90csp1074009qgi; Wed, 11 Jan 2017 03:29:54 -0800 (PST) X-Received: by 10.99.125.17 with SMTP id y17mr10145995pgc.27.1484134194832; Wed, 11 Jan 2017 03:29:54 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 188si5556778pgd.181.2017.01.11.03.29.54; Wed, 11 Jan 2017 03:29:54 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757430AbdAKL3v (ORCPT + 25 others); Wed, 11 Jan 2017 06:29:51 -0500 Received: from foss.arm.com ([217.140.101.70]:46828 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750955AbdAKL3u (ORCPT ); Wed, 11 Jan 2017 06:29:50 -0500 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 34690AD7; Wed, 11 Jan 2017 03:29:49 -0800 (PST) Received: from [10.1.210.41] (e107985-lin.cambridge.arm.com [10.1.210.41]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 290643F24D; Wed, 11 Jan 2017 03:29:48 -0800 (PST) Subject: Re: [PATCH] sched/fair: fix calc_cfs_shares fixed point arithmetics To: Peter Zijlstra References: <20161219224014.GA28238@var.home> <20161219230713.GD2895@var.home> <20161219232926.GH2895@var.home> <20161219234525.GI2895@var.home> <20161220131557.GN3124@twins.programming.kicks-ass.net> Cc: Samuel Thibault , Paul Turner , LKML , Thomas Gleixner , Ingo Molnar From: Dietmar Eggemann Message-ID: Date: Wed, 11 Jan 2017 11:29:47 +0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.5.1 MIME-Version: 1.0 In-Reply-To: <20161220131557.GN3124@twins.programming.kicks-ass.net> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 20/12/16 13:15, Peter Zijlstra wrote: > On Tue, Dec 20, 2016 at 02:04:34PM +0100, Dietmar Eggemann wrote: >> Hi Samuel, >> >> On 12/20/2016 12:45 AM, Samuel Thibault wrote: >>> Paul Turner, on Mon 19 Dec 2016 15:32:15 -0800, wrote: >>>> On Mon, Dec 19, 2016 at 3:29 PM, Samuel Thibault >>>> wrote: >>>>> Paul Turner, on Mon 19 Dec 2016 15:26:19 -0800, wrote: >> >> [...] >> >>>> The MIN_SHARES you are seeing here is overloaded. >>>> In the unscaled case this needs to be MIN_SHARES, and in the scaled >>>> case, the subdivision of the scaled values must still be >=2. >>> >>> Ok, now I understand. I have to say this overloading is confusing. >>> >>> Samuel >> >> this had been already discussed back in August when I posted the original >> patch. > > Maybe we should put a comment in to avoid getting more of these ;-) > Maybe something like this? Mainly what Paul taught us plus an example from a discussion I had with Vincent. -- >8 -- Subject: [PATCH] sched/fair: Explain why MIN_SHARES isn't scaled in calc_cfs_shares() Signed-off-by: Dietmar Eggemann --- kernel/sched/fair.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) -- 2.11.0 diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c index 6559d197e08a..a0ca9b11b1b3 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -2657,6 +2657,18 @@ static long calc_cfs_shares(struct cfs_rq *cfs_rq, struct task_group *tg) if (tg_weight) shares /= tg_weight; + /* + * MIN_SHARES has to be unscaled here to support per-cpu partitioning + * of a group with small tg->shares value. It is a floor value which is + * assigned as a minimum load.weight to the sched_entity representing + * the group on a cpu. + * + * E.g. on 64-bit for a group with tg->shares of scale_load(15)=15*1024 + * on an 8 core system with 8 tasks each runnable on one cpu shares has + * to be 15*1024*1/8=1920 instead of scale_load(MIN_SHARES)=2*1024. In + * case no task is runnable on a cpu MIN_SHARES=2 should be returned + * instead of 0. + */ if (shares < MIN_SHARES) shares = MIN_SHARES; if (shares > tg->shares)