Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp210843pxf; Wed, 10 Mar 2021 04:42:11 -0800 (PST) X-Google-Smtp-Source: ABdhPJzVDL2GMlxIV1TNLExAu/jMr5djP3vHHifBz2qmFJWSZznbRk+P14pbsok8OYlS2JGDO6l1 X-Received: by 2002:a17:906:a1c8:: with SMTP id bx8mr3297175ejb.381.1615380131592; Wed, 10 Mar 2021 04:42:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1615380131; cv=none; d=google.com; s=arc-20160816; b=UQINL+1T6Sr8xt71HhQFGoI1xwqIXFKXIFxlkJFB3WFZfI4LtrJgNIwZPfWmu/fCcg bCAPviE51YnSf5byBT7qHqiKGtnlZpPoybfUqSqNVFS2fMX4WaQLwKuQSmUMOlDITIjm zlcQinlJoG+PrFWhh4NlxKLvVfY/EjFf09vmQ7aMCmeZ7IsQnuiNN+R92Py9TKR9syhg AxXNua7+2okR6qpfPcIQwrC0A7/UrHpPpi2FUk6pu3uQxVvIqpGanGJiQfhC06VroxSs NwSqZPCjJ8Bg80ptFQTI1uOglknKsSX1vqkQvgHmugcWiN/TQ3W8qqmAc3hkhsew0So+ PRdQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=YXLSNz/4WtUmU/lneglWll+uILsFH1Ed7/OVzx0cvHA=; b=KjC7P6c0BwKGTVejHdhJ8mdydJHj6GRcE8ZhKNXXGCS7lqa7sm9+zJHOK0F/kI5y1F jlIanl08UeWPOTS1ClwiYO3DlkOVfvWjkXpdp86xSfc0BibnVCGIyt6HXI8CtEqrr0Ov 5W4fIod/Yp5RBpyDHFICDl4jdn0zxbKtvBdjec/EK4auEVU+1Dr0H/u1x5lJQlU40T6q dzUCM7Yqd6mMb23iYqmQplzpuSFw8DJwqu0lsIgvImx0g3Pa6l9g0EsMmhAWsmZyQXvC NsCRx8Ev9FE8JE7UVdwN91gW1RRftWVgKks4MHEK/O/MpvkxN8kYQ9+ceSrP6sU12G2C lQXg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=Lz4WnUTw; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id x10si11909190eds.158.2021.03.10.04.41.49; Wed, 10 Mar 2021 04:42:11 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=Lz4WnUTw; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232274AbhCJMkx (ORCPT + 99 others); Wed, 10 Mar 2021 07:40:53 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36230 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231272AbhCJMkm (ORCPT ); Wed, 10 Mar 2021 07:40:42 -0500 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D9D84C061760 for ; Wed, 10 Mar 2021 04:40:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.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; bh=YXLSNz/4WtUmU/lneglWll+uILsFH1Ed7/OVzx0cvHA=; b=Lz4WnUTw+n2jLhOUshnVqFNQYm 5Ht8WsNNrizMH2TUjihR32IxK4gNWEZaD5i7M9FTEcsN/B6cHyjsG0W4hkUvmr3EFXtEO31n5TH9C 7/NJ5Ipl3eEvG6JSMyCilLj672MJ4w+LsXGg29jwv84ygPn53z+ZXP4pHuKPNfqKvJvO/R/Mj0MgJ DDtuHsYShlafszsIjEMe00I4DVfbEwCAgqGzRPGM+00XUBXusVoSHiXQC3AI79XCDSvYLqAPEIEqV IYxtE9Wzu6nKwRhof35XLzWBPt5T1WkZos8g/O6ulpV8HbiAGzUe0sbx0DfbvpRPCF2mVy/BIpLvW v6Cw/rPg==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=noisy.programming.kicks-ass.net) by casper.infradead.org with esmtpsa (Exim 4.94 #2 (Red Hat Linux)) id 1lJy88-003P0t-8A; Wed, 10 Mar 2021 12:40:01 +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 E74F03011F0; Wed, 10 Mar 2021 13:39:49 +0100 (CET) Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id B016920D72075; Wed, 10 Mar 2021 13:39:49 +0100 (CET) Date: Wed, 10 Mar 2021 13:39:49 +0100 From: Peter Zijlstra To: Huaixin Chang Cc: bsegall@google.com, dietmar.eggemann@arm.com, juri.lelli@redhat.com, khlebnikov@yandex-team.ru, linux-kernel@vger.kernel.org, mgorman@suse.de, mingo@redhat.com, pauld@redhead.com, pjt@google.com, rostedt@goodmis.org, shanpeic@linux.alibaba.com, vincent.guittot@linaro.org, xiyou.wangcong@gmail.com Subject: Re: [PATCH v3 1/4] sched/fair: Introduce primitives for CFS bandwidth burst Message-ID: References: <20210121110453.18899-1-changhuaixin@linux.alibaba.com> <20210121110453.18899-2-changhuaixin@linux.alibaba.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210121110453.18899-2-changhuaixin@linux.alibaba.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Jan 21, 2021 at 07:04:50PM +0800, Huaixin Chang wrote: > In this patch, we introduce the notion of CFS bandwidth burst. Unused > "quota" from pervious "periods" might be accumulated and used in the > following "periods". The maximum amount of accumulated bandwidth is > bounded by "burst". And the maximun amount of CPU a group can consume in > a given period is "buffer" which is equivalent to "quota" + "burst in > case that this group has done enough accumulation. > > Signed-off-by: Huaixin Chang > Signed-off-by: Shanpei Chen Not a valid SoB chain. > --- > kernel/sched/core.c | 91 ++++++++++++++++++++++++++++++++++++++++++++-------- > kernel/sched/fair.c | 2 ++ > kernel/sched/sched.h | 2 ++ > 3 files changed, 82 insertions(+), 13 deletions(-) > > diff --git a/kernel/sched/core.c b/kernel/sched/core.c > index e7e453492cff..48d3bad12be2 100644 > --- a/kernel/sched/core.c > +++ b/kernel/sched/core.c > @@ -7895,10 +7895,12 @@ static const u64 max_cfs_runtime = MAX_BW * NSEC_PER_USEC; > > static int __cfs_schedulable(struct task_group *tg, u64 period, u64 runtime); > > -static int tg_set_cfs_bandwidth(struct task_group *tg, u64 period, u64 quota) > +static int tg_set_cfs_bandwidth(struct task_group *tg, u64 period, u64 quota, > + u64 burst) Non standard indentation. > { > int i, ret = 0, runtime_enabled, runtime_was_enabled; > struct cfs_bandwidth *cfs_b = &tg->cfs_bandwidth; > + u64 buffer; > > if (tg == &root_task_group) > return -EINVAL; > @@ -7925,6 +7927,16 @@ static int tg_set_cfs_bandwidth(struct task_group *tg, u64 period, u64 quota) > if (quota != RUNTIME_INF && quota > max_cfs_runtime) > return -EINVAL; > > + /* > + * Bound burst to defend burst against overflow during bandwidth shift. > + */ > + if (burst > max_cfs_runtime) > + return -EINVAL; > + > + if (quota == RUNTIME_INF) > + buffer = RUNTIME_INF; > + else > + buffer = min(max_cfs_runtime, quota + burst); Why do we care about buffer when RUNTIME_INF?