Received: by 2002:a5b:505:0:0:0:0:0 with SMTP id o5csp5529573ybp; Tue, 8 Oct 2019 04:27:50 -0700 (PDT) X-Google-Smtp-Source: APXvYqzRvlz0ItCCcciYOuiXDcbtyJYzEogyAm5CpQ7DxbV2n9yebi7acqAeCyRU09NgUNY17Gmc X-Received: by 2002:a50:d0d5:: with SMTP id g21mr33698740edf.204.1570534070085; Tue, 08 Oct 2019 04:27:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1570534070; cv=none; d=google.com; s=arc-20160816; b=VKadZ1TKPwP9TZYUPJexnb/9Kmjuru5bTzrsgmo2zde1LpOm4HLduICuDOGubbAfRk 89h2BD/HSBSPNoQqopLIrLwHVTJEplv5CQ3CR5QptZlFm6NMI53aBp71JazbWepuDxpd r3F6n8ONa7zMjh3wu74cF+iTv558MX1+d1N8gKPi698ac36ZH1bL3j27pu+pU8CjFZoa 2Jyx2zQTNOgcnysE8VB92uM0Gkviv+uf8lukHuRz8SSg9QFW7lUA1YBjjQvq7rDdyfbB yzE3GmR1g8T7zp4kfgw9hrApOl9jOkV8qTA6DrZ6ipgQzyJYuOg5beksHSKjn6t4myTz rsXw== 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=QzG9uxqVaWu2Py++vRepIVOXKbIJ3yM+1U+4xpiRQXU=; b=1GMlQtUg7Am7QXBiERyfwHBGE91Etsu1HXXALNNjTIP/OMQf0NmMF/+MABd0IL3Veg +7828T+6l1p4Hcn1Vm5vGQm32ivxY6wqWDeGfxPrcLQUNJsqzll1caXVC6Xh8RQCH98q Uko3a0/Ne/k1NQ77+cgNkN4ZbDY8vinRhUcbqNSxIRBKI5H6DZhr+fHY77dLxhxEfQ7u r5kGKjP+CfQjIz9Hp5seQgU3GxmSTeL3jcGwuQaHdaOGOmRWtDhwPcqmPrXAZrktuFu/ PMaMOoPuJi79H4MX4o9ogZ6ndaXRO2U5q+nTTmtEDxbvBmhOYHrkkP7C4wvGVjma7ZhK M3cQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=JjllhKoY; 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 i3si9548992edq.163.2019.10.08.04.27.25; Tue, 08 Oct 2019 04:27:50 -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=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=JjllhKoY; 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 S1730632AbfJHL0j (ORCPT + 99 others); Tue, 8 Oct 2019 07:26:39 -0400 Received: from bombadil.infradead.org ([198.137.202.133]:59516 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729876AbfJHL0j (ORCPT ); Tue, 8 Oct 2019 07:26:39 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=In-Reply-To:Content-Type:MIME-Version :References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=QzG9uxqVaWu2Py++vRepIVOXKbIJ3yM+1U+4xpiRQXU=; b=JjllhKoY7qqd4rYbCBXvE6gNh qv27J0/uXStkQWkcXHLPXLt8u53loVBn+pBWo1PcUzZ3fu4V2+HrhI4ZI0NeclHZ08G5VyLDfxYSz MJb2c6aOEX4oJt/S8dLjXnWe91nzdInaMbOf73mgxpJzaC1UVUnwJCuVKPoTh2RECfbtllWD1RrkU KboP/7ZXTEmrgy3gpWO40uJqIyk+gzGJ8rlRrC1sGts3fXHgUXDEkpCfTTbNir5c5jR2eW69QQ7Ki t2SyUN6vfrkOT8JgqDAtJ72yS6+50BQeE9mSmxUizjg0EXpIopYDHTl1ZBVsqZCIX7vrVbI+kH9ia obuCjHKEA==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=noisy.programming.kicks-ass.net) by bombadil.infradead.org with esmtpsa (Exim 4.92.2 #3 (Red Hat Linux)) id 1iHnd7-0004LE-2M; Tue, 08 Oct 2019 11:26:13 +0000 Received: from hirez.programming.kicks-ass.net (hirez.programming.kicks-ass.net [192.168.1.225]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by noisy.programming.kicks-ass.net (Postfix) with ESMTPS id 513C2305E1D; Tue, 8 Oct 2019 13:25:18 +0200 (CEST) Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id A3C3529BBAD03; Tue, 8 Oct 2019 13:26:09 +0200 (CEST) Date: Tue, 8 Oct 2019 13:26:09 +0200 From: Peter Zijlstra To: Phil Auld Cc: Xuewei Zhang , 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: <20191008112609.GL2294@hirez.programming.kicks-ass.net> References: <20191004001243.140897-1-xueweiz@google.com> <20191007151425.GD22412@pauld.bos.csb> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20191007151425.GD22412@pauld.bos.csb> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Oct 07, 2019 at 11:14:25AM -0400, Phil Auld wrote: > 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 > > > I managed to get it to trigger the second case. It took 50,000 children (20x my initial tests). > > [ 1367.850630] cfs_period_timer[cpu11]: period too short, scaling up (new cfs_period_us = 4340, cfs_quota_us = 250000) > [ 1370.390832] cfs_period_timer[cpu11]: period too short, scaling up (new cfs_period_us = 8680, cfs_quota_us = 500000) > [ 1372.914689] cfs_period_timer[cpu11]: period too short, scaling up (new cfs_period_us = 17360, cfs_quota_us = 1000000) > [ 1375.447431] cfs_period_timer[cpu11]: period too short, scaling up (new cfs_period_us = 34720, cfs_quota_us = 2000000) > [ 1377.982785] cfs_period_timer[cpu11]: period too short, scaling up (new cfs_period_us = 69440, cfs_quota_us = 4000000) > [ 1380.481702] cfs_period_timer[cpu11]: period too short, scaling up (new cfs_period_us = 138880, cfs_quota_us = 8000000) > [ 1382.894692] cfs_period_timer[cpu11]: period too short, scaling up (new cfs_period_us = 277760, cfs_quota_us = 16000000) > [ 1385.264872] cfs_period_timer[cpu11]: period too short, scaling up (new cfs_period_us = 555520, cfs_quota_us = 32000000) > [ 1393.965140] cfs_period_timer[cpu11]: period too short, but cannot scale up without losing precision (cfs_period_us = 555520, cfs_quota_us = 32000000) > > I suspect going higher could cause the original lockup, but that'd be the case with the old code as well. > And this also gets us out of it faster. > > > Tested-by: Phil Auld Thanks!