Received: by 10.223.185.116 with SMTP id b49csp4926745wrg; Wed, 7 Mar 2018 03:33:06 -0800 (PST) X-Google-Smtp-Source: AG47ELsAK+CFMZxA7jL7odeE7RWZkTEGWBir7uRxtM3N6LUIUBPp5iSkpQedfVbU3eeSnrk4g32k X-Received: by 2002:a17:902:b109:: with SMTP id q9-v6mr20405709plr.340.1520422386547; Wed, 07 Mar 2018 03:33:06 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1520422386; cv=none; d=google.com; s=arc-20160816; b=DS1GEZQoTaVDsL/HcY9vbW0m/9mvlfnmYkFNJzyblT2u/IWvYhUwg0JRZfbAD9lps1 aJYnydOq50YMTrICCZTUZLPDWKU7lzFpA6aHkJzGiPK70aWV32IJqzu8hOEeBObdL5a2 X60qwKC4Mw8WLGFxkQxg/xGb1M5ZL48Qvcj/yGPefp7OyF4d2U5GRSZsy4RlQq0Y1tpv HBJCZpDDBrejpMG4PLBPwsNdCk7HhfyknRIIVdtoEgRN15EQk0NYudr8jkq48fdRQ1v5 TcPR4smTx09PA/lATmyCnmMwkdKy+UQOLZLSnKhIEx8ObdKJoIBd2lHi02HH4rlq6heh vU9w== 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:arc-authentication-results; bh=0/byevIWj/DpfdWug5QP3fOU9ChWXA+nz+KwMg5qh6M=; b=H5y680ZqNBU6XPPeYwR1oQStKOdO/IkY5P3NNe835jNxP+6/YDGvsip8FK55i96IMq jm32z9OIkglrVprnUQHW7w7XuH7Uv9x70Qw8HfopuIdWm4AJvRMtkZ6Lz+h355ZNnggz 6RcSL/Wfb9jkAf0VaUoC52lsK9GIm+hEv190H+P8QQkcRje0jX1Q6Lo+LFQZYrmK/K2w 9NppnDdKygYAkF0WtjMSXE6/mKmKcQUpIaieSbUnZryf8pmQSr2vMrDZzSQDn2G4SK3x 7VsozwtpSrq8zx1EQp65DTJAxOvnLkHXc7wZcLrVQ3tfyy+aBV/S61jViKNcYeVczfUH W8kA== ARC-Authentication-Results: i=1; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g1si11074231pgc.726.2018.03.07.03.32.51; Wed, 07 Mar 2018 03:33:06 -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 S1754325AbeCGLcA (ORCPT + 99 others); Wed, 7 Mar 2018 06:32:00 -0500 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70]:49098 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751151AbeCGLb7 (ORCPT ); Wed, 7 Mar 2018 06:31:59 -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 DFA9C14; Wed, 7 Mar 2018 03:31:58 -0800 (PST) Received: from e110439-lin (e110439-lin.cambridge.arm.com [10.1.210.68]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 860803F487; Wed, 7 Mar 2018 03:31:56 -0800 (PST) Date: Wed, 7 Mar 2018 11:31:49 +0000 From: Patrick Bellasi To: Peter Zijlstra Cc: linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, Ingo Molnar , "Rafael J . Wysocki" , Viresh Kumar , Vincent Guittot , Paul Turner , Dietmar Eggemann , Morten Rasmussen , Juri Lelli , Todd Kjos , Joel Fernandes , Steve Muckle Subject: Re: [PATCH v5 1/4] sched/fair: add util_est on top of PELT Message-ID: <20180307113149.GA2211@e110439-lin> References: <20180222170153.673-1-patrick.bellasi@arm.com> <20180222170153.673-2-patrick.bellasi@arm.com> <20180306185851.GG25201@hirez.programming.kicks-ass.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180306185851.GG25201@hirez.programming.kicks-ass.net> User-Agent: Mutt/1.5.24 (2015-08-30) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 06-Mar 19:58, Peter Zijlstra wrote: > On Thu, Feb 22, 2018 at 05:01:50PM +0000, Patrick Bellasi wrote: > > +static inline void util_est_enqueue(struct cfs_rq *cfs_rq, > > + struct task_struct *p) > > +{ > > + unsigned int enqueued; > > + > > + if (!sched_feat(UTIL_EST)) > > + return; > > + > > + /* Update root cfs_rq's estimated utilization */ > > + enqueued = READ_ONCE(cfs_rq->avg.util_est.enqueued); > > + enqueued += _task_util_est(p); > > + WRITE_ONCE(cfs_rq->avg.util_est.enqueued, enqueued); > > +} > > > +static inline void util_est_dequeue(struct cfs_rq *cfs_rq, > > + struct task_struct *p, > > + bool task_sleep) > > +{ > > + long last_ewma_diff; > > + struct util_est ue; > > + > > + if (!sched_feat(UTIL_EST)) > > + return; > > + > > + /* > > + * Update root cfs_rq's estimated utilization > > + * > > + * If *p is the last task then the root cfs_rq's estimated utilization > > + * of a CPU is 0 by definition. > > + */ > > + ue.enqueued = 0; > > + if (cfs_rq->nr_running) { > > + ue.enqueued = READ_ONCE(cfs_rq->avg.util_est.enqueued); > > + ue.enqueued -= min_t(unsigned int, ue.enqueued, > > + _task_util_est(p)); > > + } > > + WRITE_ONCE(cfs_rq->avg.util_est.enqueued, ue.enqueued); > > It appears to me this isn't a stable situation and completely relies on > the !nr_running case to recalibrate. If we ensure that doesn't happen > for a significant while the sum can run-away, right? By away you mean go over 1024 or overflow the unsigned int storage? In the first case, I think we don't care about exceeding 1024 since: - we cap to capacity_orig_of in cpu_util_est - by directly reading the cfs_rq->avg.util_est.enqueued we can actually detect conditions in which a CPU is over-saturated. In the second case, with an unsigned int we can enqueue up to few millions of 100% tasks on a single CPU without overflowing. > Should we put a max in enqueue to avoid this? IMO the capping from the cpu_util_est getter should be enough... Maybe I'm missing your point here? -- #include Patrick Bellasi