Received: by 2002:ac0:98c7:0:0:0:0:0 with SMTP id g7-v6csp6443902imd; Wed, 31 Oct 2018 11:47:48 -0700 (PDT) X-Google-Smtp-Source: AJdET5fnNP1U6dkLtmZTDxX/VQ4UCtmHctSDwHvscHqDkUkvAd7zdJwepGPRXRUxIHLhOD2Pjd3K X-Received: by 2002:a62:2cc9:: with SMTP id s192-v6mr4492430pfs.35.1541011668916; Wed, 31 Oct 2018 11:47:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1541011668; cv=none; d=google.com; s=arc-20160816; b=DhtbVL3YejkH+re54Xgu8hQMswDxyYeP5WdStPykX95+TKjViAoN4Lv4V58bBlUHgj 8SX2pUfvAogb8mzzDRtiT6PeDOnFdCj3JV6lURq9Dnr6zWL/2OkJfUBWCH88C/Iorrtz GyTGh3CZK7i3o7GK4kQexJYO0wUifSoCX4+YsZUfYRPlvLJfO0VgQ2NjpjzwoG+iCAEm ACvNmTjH5wsR5OeuE2Xob5tRXT5gZwDId1N+4hll6qQcJcDZl6Lo6CyHp8MyrZ1QRETH fba9Une8n/ZFAUDhVzutdKxTtUPoj2CcOei6475bVHdchXXgPTMmpgR9bs14SPNa2oun gCSQ== 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=Bthulb2HGfO4IV6nzJ1hbBGGuiM1/LLCqnuMNPPB4qE=; b=sak2pLE/J0uuUBAvc7DqpFe0k4lRD2b6MKuOZSPQbXMrzo2FvnhL417NJk1vRa8QLP WncH8wDKVHloyDeVyQ/IvsYAXkOrWcLZcYeNacm5q/t0EPk49DJGfX8qsD5XGOz+KG2z xkW5GGIuF9JAsww3ui0lv601I0gN1WWcgos/9guU42C04EQBRE8foQ+cXA1K3ldUjLZO jNUhwqjcYv0iIZf4HvN9z4V0ZK/Xy3TV4/cIneLAG8h/2BpmOmP0GQhPK5F0eVAJu1dO sxCx8Kb+ah37FWhl7ax6UdfeeJLDAz+UjSzzm/Hy4kGAW76HRFzwNphO5Z9P7vcCPoLm zaAg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=merlin.20170209 header.b=xItPczqo; 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 v123-v6si25825889pfb.65.2018.10.31.11.47.34; Wed, 31 Oct 2018 11:47:48 -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=merlin.20170209 header.b=xItPczqo; 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 S1730384AbeKADo5 (ORCPT + 99 others); Wed, 31 Oct 2018 23:44:57 -0400 Received: from merlin.infradead.org ([205.233.59.134]:42674 "EHLO merlin.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730087AbeKADo4 (ORCPT ); Wed, 31 Oct 2018 23:44:56 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=merlin.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=Bthulb2HGfO4IV6nzJ1hbBGGuiM1/LLCqnuMNPPB4qE=; b=xItPczqo/TfvRwMZwhEZp61mC x8ZWngUYn+wyacvhx/ky1I1EPpDW8qVMpsy9L30QdbL8rNsnMAmsWyT1vXt9K6VTLfcLpBWMHXFTg Q9xu3NWfYRqiBHtJg2ilF4LbZ5mGNEZDVp+JuoOtgPHQ6UB4elVnLQE6efNoQXTgazfPSfc0qBnFF uegDXUvsS7FPeqfQcF9LcpLD1m6OhuZMo4CWqe2b19RVKEFLMelu5LPBxDap3lfyoIrEYREE7m6Nr vBj67GORwcT92Mzm4TWI0hNTEd1ibPXjlh0ZalKcA/dNrhb382Z55S4+ixg8FtsLHtP9sQQhvmlx2 wY1EUgFIA==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=hirez.programming.kicks-ass.net) by merlin.infradead.org with esmtpsa (Exim 4.90_1 #2 (Red Hat Linux)) id 1gHvUh-0006KB-Hh; Wed, 31 Oct 2018 18:45:31 +0000 Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id 0BDCD20297604; Wed, 31 Oct 2018 19:45:28 +0100 (CET) Date: Wed, 31 Oct 2018 19:45:27 +0100 From: Peter Zijlstra To: Patrick Bellasi Cc: linux-kernel@vger.kernel.org, Ingo Molnar , Quentin Perret , Dietmar Eggemann , Morten Rasmussen , Juri Lelli , Todd Kjos , Suren Baghdasaryan , Aaron Lu , Ye Xiaolong , Ingo Molnar Subject: Re: [PATCH] sched/fair: util_est: fix cpu_util_wake for execl Message-ID: <20181031184527.GA3178@hirez.programming.kicks-ass.net> References: <20181030160947.19581-1-patrick.bellasi@arm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20181030160947.19581-1-patrick.bellasi@arm.com> 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 Tue, Oct 30, 2018 at 04:09:47PM +0000, Patrick Bellasi wrote: > Let's fix this by ensuring to always discount the task estimated > utilization from the CPU's estimated utilization when the task is also > the current one. The same benchmark of the bug report, executed on a > dual socket 40 CPUs Intel(R) Xeon(R) CPU E5-2690 v2 @ 3.00GHz machine, > reports these "Execl Throughput" figures (higher the better): Before this we have: /* Discount task's blocked util from CPU's util */ util -= min_t(unsigned int, util, task_util(p)); at the very least that comment is now inaccurate, since @p might not be blocked. > @@ -6258,8 +6267,17 @@ static unsigned long cpu_util_wake(int cpu, struct task_struct *p) > * covered by the following code when estimated utilization is > * enabled. > */ > - if (sched_feat(UTIL_EST)) > - util = max(util, READ_ONCE(cfs_rq->avg.util_est.enqueued)); > + if (sched_feat(UTIL_EST)) { > + unsigned int estimated = > + READ_ONCE(cfs_rq->avg.util_est.enqueued); > + > + if (unlikely(current == p || task_on_rq_queued(p))) { I'm confused by the need for 'current == p', afaict task_on_rq_queued(p) is sufficient -- we've already established task_cpu(p) == cpu earlier. > + estimated -= min_t(unsigned int, estimated, > + (_task_util_est(p) | UTIL_AVG_UNCHANGED)); > + } > + > + util = max(util, estimated); > + } Also, I think it is about time we find a suitable name for: #define xxx(_var, _val) do { \ typeof(_var) var = (_var); \ typeof(_var) val = (_val); \ typeof(_var) res = var - val; \ if (res > var) \ res = 0; \ (_var) = res; \ } while (0) Which is basically sub_positive() but without the READ_ONCE/WRITE_ONCE stuff. We do that: var -= min_t(typeof(var), var, val); pattern _all_ over.