Received: by 2002:a5b:505:0:0:0:0:0 with SMTP id o5csp576829ybp; Fri, 4 Oct 2019 01:20:32 -0700 (PDT) X-Google-Smtp-Source: APXvYqxpeenAt1PMwJf4EtQwq6fMbxjebwyX9R7vT89j9Z03kHuujnzxR+0KkVtvK8yceAzDmBQz X-Received: by 2002:a17:906:768f:: with SMTP id o15mr11259360ejm.42.1570177232299; Fri, 04 Oct 2019 01:20:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1570177232; cv=none; d=google.com; s=arc-20160816; b=Vfuxqb8KxvqoRllcLIAjseiuZ7RWVOSgL87CEQIZ5tz2vpyf/tfu8h5xfFPF88eAch zru6xDvoTwwrRF3jJTcNHdJI5k3Vx5gfCAyQmwl00lUYK9hYfLEnaIiq3l9y15jWma7y e45Xy5iVyru/oQ+TRRFXtJ7QEEqUbE7xK7CwleWlZpUzRqAX0oZOmhO+zDazNw++7eEG GAmBFN8JyncRhrpYw/1OghaRemtPuHUF01MNFNXxqFPYPed/unBAr2MFf1f4cbuAmKwM eob1Drt8Wq9sCdvMl5ZyVxu2UC3eFePnw+pC1tw0tiC4uG/CEUo1+VihTlIhpLW1JQhT tdpg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=Dy91jyVSjW4qxGQdzn8yE1swZtKNSAfH4LU1ptogRUE=; b=bwapqZmzS8mtRdGdYoBn9RSo0oKdwvmecPmYgV6Ga47c82LcIGemrn0L+oZA1z9AU2 dg8hKPN6PL8Tm4V1yA/S6HpjYBRGrTblDfThFICdE/X5OHNw+CUefz84UNyG8yppNUov X3jPCK/hhP1iGZinZuqy6NTQctswn62f6/cikfYQNq/tZIbnFcmvFh140Fr3QGCkv5u9 gX4DTWE9H8Whxynm4OmLohSVhzqttUod8HFpgLYo+rf4ET+1UoNGsDe/AoOUBsXnMK1q 0rAarg/PiTq/7dxkZFmyWDiZF9qCpaPLgfjzbDCYs/eEbnRknvZrpWaMTWXxgOtrDNIn g59A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=CIsyivs3; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h26si2526886ejx.177.2019.10.04.01.20.08; Fri, 04 Oct 2019 01:20:32 -0700 (PDT) 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; dkim=pass header.i=@kernel.org header.s=default header.b=CIsyivs3; 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 S2388218AbfJDGLo (ORCPT + 99 others); Fri, 4 Oct 2019 02:11:44 -0400 Received: from mail.kernel.org ([198.145.29.99]:44642 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387618AbfJDGLo (ORCPT ); Fri, 4 Oct 2019 02:11:44 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 9299520862; Fri, 4 Oct 2019 06:11:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1570169502; bh=DABffYYFWZJ/GYY032Yu0DYAxWMtO3AA6U+PIER5Nr8=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=CIsyivs3KtWJDHOX21tQgHy0KSmpz5Z2ABW61LdDfxgsijTULgDd7Du7RxT031zXk a8rKMo3iPnzbjeF3JD30ekihAIL0nzD5p8y4N/gTpQktIiQrE0dVwgb784q5/1wOnr 8tBV0NGA/7FL0f+nCW9k8+LLoyMfMjdnlStdKDaE= Date: Fri, 4 Oct 2019 08:11:39 +0200 From: Greg KH To: Xuewei Zhang Cc: Phil Auld , Peter Zijlstra , Ingo Molnar , Juri Lelli , Vincent Guittot , Dietmar Eggemann , Steven Rostedt , Ben Segall , Mel Gorman , Anton Blanchard , Linus Torvalds , Thomas Gleixner , linux-kernel@vger.kernel.org, stable@vger.kernel.org, trivial@kernel.org Subject: Re: [PATCH] sched/fair: scale quota and period without losing quota/period ratio precision Message-ID: <20191004061139.GA845981@kroah.com> References: <20191004001243.140897-1-xueweiz@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20191004001243.140897-1-xueweiz@google.com> User-Agent: Mutt/1.12.2 (2019-09-21) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Oct 03, 2019 at 05:12:43PM -0700, Xuewei Zhang wrote: > quota/period ratio is used to ensure a child task group won't get more > bandwidth than the parent task group, and is calculated as: > normalized_cfs_quota() = [(quota_us << 20) / period_us] > > If the quota/period ratio was changed during this scaling due to > precision loss, it will cause inconsistency between parent and child > task groups. See below example: > A userspace container manager (kubelet) does three operations: > 1) Create a parent cgroup, set quota to 1,000us and period to 10,000us. > 2) Create a few children cgroups. > 3) Set quota to 1,000us and period to 10,000us on a child cgroup. > > These operations are expected to succeed. However, if the scaling of > 147/128 happens before step 3), quota and period of the parent cgroup > will be changed: > new_quota: 1148437ns, 1148us > new_period: 11484375ns, 11484us > > And when step 3) comes in, the ratio of the child cgroup will be 104857, > which will be larger than the parent cgroup ratio (104821), and will > fail. > > Scaling them by a factor of 2 will fix the problem. > > Fixes: 2e8e19226398 ("sched/fair: Limit sched_cfs_period_timer() loop to avoid hard lockup") > Signed-off-by: Xuewei Zhang > --- > kernel/sched/fair.c | 36 ++++++++++++++++++++++-------------- > 1 file changed, 22 insertions(+), 14 deletions(-) > This is not the correct way to submit patches for inclusion in the stable kernel tree. Please read: https://www.kernel.org/doc/html/latest/process/stable-kernel-rules.html for how to do this properly.