Received: by 10.223.185.116 with SMTP id b49csp4172821wrg; Tue, 6 Mar 2018 11:00:43 -0800 (PST) X-Google-Smtp-Source: AG47ELtPTuzhHCE9UubQwQpdy+IeHAj71xeB2mWGJBWVJ9UjSzXB9f2UhNNqpFuQikwClu2LsTZM X-Received: by 10.99.8.4 with SMTP id 4mr15980350pgi.289.1520362843153; Tue, 06 Mar 2018 11:00:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1520362843; cv=none; d=google.com; s=arc-20160816; b=JnKRbTi/VIae+HdOZiLqbWlu4qcXPTAS5pPoWgKqooTwJnz+VJfZVxWum4nNXpCMy0 XL0vMP1d50uzC5h8QtD9SYIckOWRPh9UyBBPESy2nd9NwYEUO+heOLrHWdI48o0S/QOq +zCW8TJtfXxTKrB/AFl/egmBjPY9ZFNf63M0AzGe3emSRHmvx/eAuUUmfFIU/MKyzL3G IhZtIvFNrdQDxcTFdmfOaFIWhZZxcBO2xcS5QPNarEJOGp2SNTn7vyN/Bk7iwmshCmVI ES5aYRvz/Lh9I+ZpX0WtEQ/kawPBEWs1JPn7HbAp9AfI20i2tJ0YvQeYI4ZDLRVxua8M co3g== 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:arc-authentication-results; bh=klK2ZgnWW8IEp/L6CE0hkqsnwxt2ip6e26kuVBvW40U=; b=l28gABo8sCcrDSx7xoL5Jsg40VEfnILfE8l9JUpJov7ix5xZBF+7Wps6Om0KK+tc7Z yc+4GoCycSHbb3j9HQ4lUrSRKSEZDJjYC7vzG8wuEpNVUy8w0osq3iREHtuMfKTdFqer madwUeptv3Fe+OxfairRt3LYSUXpwI0gYWK/rwTwGjzSVmTdPwqg0XO+nyN6GHSTqG28 yDAmtRd8+ZnTmdGDEpKG4oOuFDru3yW/uisMkVbTeq87NtP2UmMHPjH5UsOhHaxrKd0d RmYkg4g77vfhST3qiepDz3TC9xsiyi6CifqSK9uR6bE1TRmW0zPJV6NfhsP2ouPabb6q DE5w== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=u/ueFkUs; 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 m37-v6si11398455plg.372.2018.03.06.11.00.28; Tue, 06 Mar 2018 11:00:43 -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; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=u/ueFkUs; 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 S932972AbeCFS7B (ORCPT + 99 others); Tue, 6 Mar 2018 13:59:01 -0500 Received: from bombadil.infradead.org ([198.137.202.133]:60568 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932865AbeCFS65 (ORCPT ); Tue, 6 Mar 2018 13:58:57 -0500 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=klK2ZgnWW8IEp/L6CE0hkqsnwxt2ip6e26kuVBvW40U=; b=u/ueFkUsOe2unYEKNj3VysXGW nuV9URnRfXE5lCSHGpVu/JyAvFHQIsyi57mnPqRPSCf3im6awpPdKtTgTBo6gfShZr2xuEEp6xNkI /xorTFG593ibqtJIOx6lC7pkFQgcqIATuDAAVFr+y8PnyMxExt/e7V/BatwizKzBYwC8XP/UyzfEK HleXkaTUueQiJlRpL3yv5WK2SsGkTeSHkbXjqyAqYfDmzz+PazTzpWlKi44PDjXybMYrkxH9X6hKp lcYVrNeHEvZydsr/wmqz6iNLeWbJRLEx/qFLz7dnsd6HGmc2NQs3z9o/mLV9J7H3Zn3JxUXmJUMR6 HoOuKBDOw==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=hirez.programming.kicks-ass.net) by bombadil.infradead.org with esmtpsa (Exim 4.89 #1 (Red Hat Linux)) id 1etHnY-0006IQ-Rr; Tue, 06 Mar 2018 18:58:53 +0000 Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id 35CDE2029FA14; Tue, 6 Mar 2018 19:58:51 +0100 (CET) Date: Tue, 6 Mar 2018 19:58:51 +0100 From: Peter Zijlstra To: Patrick Bellasi 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: <20180306185851.GG25201@hirez.programming.kicks-ass.net> References: <20180222170153.673-1-patrick.bellasi@arm.com> <20180222170153.673-2-patrick.bellasi@arm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180222170153.673-2-patrick.bellasi@arm.com> User-Agent: Mutt/1.9.2 (2017-12-15) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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? Should we put a max in enqueue to avoid this?