Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp3407266imm; Thu, 17 May 2018 08:17:25 -0700 (PDT) X-Google-Smtp-Source: AB8JxZrUgW4xDS1ZUOYO/gBVPoxiCcURSuFZ3QEU+CjTaTa+wHaufmBq1HEkUcEAzCn4RQYtO6Uo X-Received: by 2002:a17:902:7146:: with SMTP id u6-v6mr5475873plm.289.1526570244972; Thu, 17 May 2018 08:17:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526570244; cv=none; d=google.com; s=arc-20160816; b=RmhIxNM9fAfbH/PdcHFhX8yDqlHRFZtNAASJNdiz3ZiFCf/0eBVl7iByFgb1aFfbOB 7ijc1xmNPmBT51HgCOX3fRP4enRmDtEdkjkNGDr3o9vE/gymwHsCFRFmhgh8oS25nVeL v5Ap5oVq9vOhrffLU+t4KCHyWJKudxNBXcG+bijOzVtV5r6kxJeW/haImQd9CT7i1KuO YnbphDTY6gRDH/zmwdiHKLWJ0EAqdEph2L9DSuy2kup9tESeIvL8HWVICd6ptWIDAe4t jVUEA3s5YuC8Igjl53kpfYogiei1xM2EixhiYFbqjcYl2c0q7EpKK+/dg3x2gvQxCi9h D3cg== 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=ZHrt4U4n+dS25+PF0B5tmg2IC4K8DaRxxFRqo7QeaqM=; b=cC8gWgwmUcu4yo9foqvxQV9/jNKJaLiSEClNZGTxY+HhBvoIv5Kh4akGoi6CzUiX4l ezgzHVpIJeGf42qjtVaE7hbEUzWUFFgFDBwsRIvM+Q4yeBKqcq3VlpyPrA8cDYGG/oZf eZ8y17WPC3naxv0MkuVfBZEwgRHq5xQC1YW2JhjeSg6U7tM9CrUUO36EbJOc1zP2QnR+ NLxA7PLHnmbHqklFlmvTu7vE6lDRro9xDDFKh5Rn3DkmBTXMqqtk1z7crT3oB7ovxsl4 1zCMv1LUzV46w8TMRJw2lF3oydZFmpX/0bBBvjk/VhyVKzf3ObL4SO6fZPEwF4WEBb4I H9fw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@joelfernandes.org header.s=google header.b=YWHC3YUb; 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 f13-v6si4286088pgp.168.2018.05.17.08.17.09; Thu, 17 May 2018 08:17:24 -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=pass header.i=@joelfernandes.org header.s=google header.b=YWHC3YUb; 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 S1752030AbeEQPRF (ORCPT + 99 others); Thu, 17 May 2018 11:17:05 -0400 Received: from mail-pl0-f68.google.com ([209.85.160.68]:36906 "EHLO mail-pl0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751468AbeEQPRD (ORCPT ); Thu, 17 May 2018 11:17:03 -0400 Received: by mail-pl0-f68.google.com with SMTP id w19-v6so2733554plq.4 for ; Thu, 17 May 2018 08:17:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=joelfernandes.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=ZHrt4U4n+dS25+PF0B5tmg2IC4K8DaRxxFRqo7QeaqM=; b=YWHC3YUbZ06QBmli3O1dsZCzLLRBL4MVHLAEn30DUTxcPH/K6Y4x9JbtP62Ph3RWjD IRmCrXHefqiJoxZkcEMX0o7xxvKj+oV93yfjRi/wzGeZIEeVPA8QLHCtoUoL85rSby12 yTQtTHjJ+aacTT9SdEhEJ/xJMMgVJ9taKVgGM= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=ZHrt4U4n+dS25+PF0B5tmg2IC4K8DaRxxFRqo7QeaqM=; b=dGBAlSE55v/5OI3L8FlyHw89RLJHqk0J92Ej08Zz+cXQq8flFwZEHkrRoYNLnRJkev 5Qc01ABnxkniNG/0Rzo9agQkv/p2sym2KI8SCiq4zjsfUN5ShUTtbRvPLoEvM9WgnLfN E2khBDd2lTZ6N4pSQJQrypxH/azCyaGMRRsE/ky9LI3YIhSBguOJ9iKEmGkYcWFy9Yqa gaM1GkAPlGUmCjnxZrslbCGBS7MLA1A9YvD0p2JKiV8kXiYpkVGaAZpa9ybk7Slt/STv OePtanq+0OU8m0z8qTpO7j0BgicpJbIMjKUpW6GowRQYkDNcncU0wA+x8TaK1oWKlgXz XgMA== X-Gm-Message-State: ALKqPweDPLLFdgYVnzoLnJGu4wyz+xWo6sb6EG58qnDzBFF5tMkFQIEd 2P3jARiBBrfJAnb3CHHSNJBiyw== X-Received: by 2002:a17:902:8217:: with SMTP id x23-v6mr5512810pln.380.1526570223151; Thu, 17 May 2018 08:17:03 -0700 (PDT) Received: from localhost ([2620:0:1000:1600:3122:ea9c:d178:eb]) by smtp.gmail.com with ESMTPSA id 65-v6sm6993613pgh.87.2018.05.17.08.17.01 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 17 May 2018 08:17:02 -0700 (PDT) Date: Thu, 17 May 2018 08:17:01 -0700 From: Joel Fernandes To: Patrick Bellasi Cc: linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, Ingo Molnar , Peter Zijlstra , "Rafael J . Wysocki" , Viresh Kumar , Vincent Guittot , Dietmar Eggemann , Morten Rasmussen , Juri Lelli , Joel Fernandes , Todd Kjos , kernel-team@android.com, Steve Muckle Subject: Re: [PATCH 3/3] sched/fair: schedutil: explicit update only when required Message-ID: <20180517151701.GC162290@joelaf.mtv.corp.google.com> References: <20180510150553.28122-1-patrick.bellasi@arm.com> <20180510150553.28122-4-patrick.bellasi@arm.com> <20180513060443.GB64158@joelaf.mtv.corp.google.com> <20180513062538.GA116730@joelaf.mtv.corp.google.com> <20180514163206.GF30654@e110439-lin> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180514163206.GF30654@e110439-lin> 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 Hi Patrick, On Mon, May 14, 2018 at 05:32:06PM +0100, Patrick Bellasi wrote: > On 12-May 23:25, Joel Fernandes wrote: > > On Sat, May 12, 2018 at 11:04:43PM -0700, Joel Fernandes wrote: > > > On Thu, May 10, 2018 at 04:05:53PM +0100, Patrick Bellasi wrote: > > > > Schedutil updates for FAIR tasks are triggered implicitly each time a > > > > cfs_rq's utilization is updated via cfs_rq_util_change(), currently > > > > called by update_cfs_rq_load_avg(), when the utilization of a cfs_rq has > > > > changed, and {attach,detach}_entity_load_avg(). > > > > > > > > This design is based on the idea that "we should callback schedutil > > > > frequently enough" to properly update the CPU frequency at every > > > > utilization change. However, such an integration strategy has also > > > > some downsides: > > > > > > I agree making the call explicit would make schedutil integration easier so > > > that's really awesome. However I also fear that if some path in the fair > > > class in the future changes the utilization but forgets to update schedutil > > > explicitly (because they forgot to call the explicit public API) then the > > > schedutil update wouldn't go through. In this case the previous design of > > > doing the schedutil update in the wrapper kind of was a nice to have > > I cannot see right now other possible future paths where we can > actually change the utilization signal without considering that, > eventually, we should call an existing API to update schedutil if it > makes sense. > > What I can see more likely instead, also because it already happened a > couple of time, is that because of code changes in fair.c we end up > calling (implicitly) schedutil with a wrong utilization value. > > To note this kind of broken dependency it has already been more > difficult than possibly noticing an update of the utilization without > a corresponding explicit call of the public API. Ok, we are in agreement this is a good thing to do :) > > > > @@ -5397,9 +5366,27 @@ enqueue_task_fair(struct rq *rq, struct task_struct *p, int flags) > > > > update_cfs_group(se); > > > > } > > > > > > > > - if (!se) > > > > + /* The task is visible from the root cfs_rq */ > > > > + if (!se) { > > > > + unsigned int flags = 0; > > > > + > > > > add_nr_running(rq, 1); > > > > > > > > + if (p->in_iowait) > > > > + flags |= SCHED_CPUFREQ_IOWAIT; > > > > + > > > > + /* > > > > + * !last_update_time means we've passed through > > > > + * migrate_task_rq_fair() indicating we migrated. > > > > + * > > > > + * IOW we're enqueueing a task on a new CPU. > > > > + */ > > > > + if (!p->se.avg.last_update_time) > > > > + flags |= SCHED_CPUFREQ_MIGRATION; > > > > + > > > > + cpufreq_update_util(rq, flags); > > > > + } > > > > + > > > > hrtick_update(rq); > > > > } > > > > > > > > @@ -5456,10 +5443,12 @@ static void dequeue_task_fair(struct rq *rq, struct task_struct *p, int flags) > > > > update_cfs_group(se); > > > > } > > > > > > > > + /* The task is no more visible from the root cfs_rq */ > > > > if (!se) > > > > sub_nr_running(rq, 1); > > > > > > > > util_est_dequeue(&rq->cfs, p, task_sleep); > > > > + cpufreq_update_util(rq, 0); > > > > > > One question about this change. In enqueue, throttle and unthrottle - you are > > > conditionally calling cpufreq_update_util incase the task was > > > visible/not-visible in the hierarchy. > > > > > > But in dequeue you're unconditionally calling it. Seems a bit inconsistent. > > > Is this because of util_est or something? Could you add a comment here > > > explaining why this is so? > > > > The big question I have is incase se != NULL, then its still visible at the > > root RQ level. > > My understanding it that you get !se at dequeue time when we are > dequeuing a task from a throttled RQ. Isn't it? I don't think so? !se means the RQ is not throttled. > Thus, this means you are dequeuing a throttled task, I guess for > example because of a migration. > However, the point is that a task dequeue from a throttled RQ _is > already_ not visible from the root RQ, because of the sub_nr_running() > done by throttle_cfs_rq(). Yes that's what I was wondering, so my point was if its already not visible, then why call schedutil. I felt call schedutil only if its visible like you were doing for the other paths. > > > In that case should we still call the util_est_dequeue and the > > cpufreq_update_util? > > I had a better look at the different code paths and I've possibly come > up with some interesting observations. Lemme try to resume theme here. > > First of all, we need to distinguish from estimated utilization > updates and schedutil updates, since they respond to two very > different goals. I agree with your assessments below and about not calling cpufreq when CPU is about to idle. thanks! - Joel