Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp5482847imu; Tue, 13 Nov 2018 07:15:59 -0800 (PST) X-Google-Smtp-Source: AJdET5fGjPNLMfeQQ+oq1WkNmFC+zwAviDRiA+S3NGBFCUHlLp1t4EKBW9p1pp+mP+6TUU9huKsz X-Received: by 2002:a63:4456:: with SMTP id t22mr4596308pgk.0.1542122159067; Tue, 13 Nov 2018 07:15:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542122159; cv=none; d=google.com; s=arc-20160816; b=rlRhrOY0LhjMLX2ArX7hK1WXf5qHYCX+g5vZdZdskfhS13+loi66lTdM+Rssjzm+r7 6DfTFv+HvgisAUe3055DV0iLIrcJO9IOvOTxjoZ5+2WKF/fw2DN6yg4Gt6yja1iaSyMX SKT/KYB2+NEEMrn06f6TVCnFnKG90pRczPYqbyF+CGQIhaI5rFdh/KtnVZzWdKsZCYU7 RG0G8nSXpEe3545z1Fb7+t4BDwOiIudlMSmlDzfQ1WfiALgwroyYizk/TK+Xs982pU0k Wrz+4p+PrH6e4SyebDGtN8yCenwKONEnmtmJ4eT5cVUiBJWTmYRhX622J+cWuNw94iPs gYeA== 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; bh=IHVnXQPR4bQW+3G6GptFOpkjafUxnUUD2qAO1kOs3nY=; b=dAO7MbAvr7AqJvj1bCtM4Jx46QcpaIXh+biLkulalSpfNYVQ2s3M5dSyfv5grFwd6s RevPkMr/FXrqyiDB1EtSzfh/SmYoF5Tc+M0lYRWZTwXbGekYjRu/Usc6ElE9b1d5vgHD 5P8+XYOhbWPkL8r3iq96eiIWqWgZePr3CXDPd48x6MxpJDyU/HMiYGLNMEUGJyA7N+T/ qm0WVG71v6K6tKDs+nqMRuDK47C0KvtZ2Yw80Is6jeTY/X/8hoz44QCIbjD2NueOXx4A y67Bn14wWaZYJbUHvwg+fHBynkGCWtZOrsSMIRCYqYEACVLiSjT/tuaYKi5gVdXmNW44 eY7w== 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 z126-v6si22775933pfb.280.2018.11.13.07.15.21; Tue, 13 Nov 2018 07:15:59 -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 S1732771AbeKNBNA (ORCPT + 99 others); Tue, 13 Nov 2018 20:13:00 -0500 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70]:58026 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732000AbeKNBNA (ORCPT ); Tue, 13 Nov 2018 20:13:00 -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 0C361A78; Tue, 13 Nov 2018 07:14:26 -0800 (PST) Received: from darkstar (usa-sjc-mx-foss1.foss.arm.com [217.140.101.70]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 764DF3F5BD; Tue, 13 Nov 2018 07:14:25 -0800 (PST) Date: Tue, 13 Nov 2018 07:14:24 -0800 From: Patrick Bellasi To: Peter Zijlstra Cc: linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, Ingo Molnar , Tejun Heo , "Rafael J . Wysocki" , Vincent Guittot , Viresh Kumar , Paul Turner , Quentin Perret , Dietmar Eggemann , Morten Rasmussen , Juri Lelli , Todd Kjos , Joel Fernandes , Steve Muckle , Suren Baghdasaryan Subject: Re: [PATCH v5 06/15] sched/core: uclamp: enforce last task UCLAMP_MAX Message-ID: <20181113151424.GB7681@darkstar> References: <20181029183311.29175-1-patrick.bellasi@arm.com> <20181029183311.29175-8-patrick.bellasi@arm.com> <20181111170848.GB3038@worktop> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20181111170848.GB3038@worktop> User-Agent: Mutt/1.9.4 (2018-02-28) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 11-Nov 18:08, Peter Zijlstra wrote: > On Mon, Oct 29, 2018 at 06:33:01PM +0000, Patrick Bellasi wrote: > > When a util_max clamped task sleeps, its clamp constraints are removed > > from the CPU. However, the blocked utilization on that CPU can still be > > higher than the max clamp value enforced while that task was running. > > > > The release of a util_max clamp when a CPU is going to be idle could > > thus allow unwanted CPU frequency increases while tasks are not > > running. This can happen, for example, when a frequency update is > > triggered from another CPU of the same frequency domain. > > In this case, when we aggregate the utilization of all the CPUs in a > > shared frequency domain, schedutil can still see the full not clamped > > blocked utilization of all the CPUs and thus, eventually, increase the > > frequency. > > > @@ -810,6 +811,28 @@ static inline void uclamp_cpu_update(struct rq *rq, unsigned int clamp_id) > > if (max_value >= SCHED_CAPACITY_SCALE) > > break; > > } > > + > > + /* > > + * Just for the UCLAMP_MAX value, in case there are no RUNNABLE > > + * task, we want to keep the CPU clamped to the last task's clamp > > + * value. This is to avoid frequency spikes to MAX when one CPU, with > > + * an high blocked utilization, sleeps and another CPU, in the same > > + * frequency domain, do not see anymore the clamp on the first CPU. > > + * > > + * The UCLAMP_FLAG_IDLE is set whenever we detect, from the above > > + * loop, that there are no more RUNNABLE taks on that CPU. > > + * In this case we enforce the CPU util_max to that of the last > > + * dequeued task. > > + */ > > + if (max_value < 0) { > > + if (clamp_id == UCLAMP_MAX) { > > + rq->uclamp.flags |= UCLAMP_FLAG_IDLE; > > + max_value = last_clamp_value; > > + } else { > > + max_value = uclamp_none(UCLAMP_MIN); > > + } > > + } > > + > > rq->uclamp.value[clamp_id] = max_value; > > } > > *groan*, so it could be jet-lag, but I find the comment really hard to > understand. > > Would not something like: > > /* > * Avoid blocked utilization pushing up the frequency when we go > * idle (which drops the max-clamp) by retaining the last known > * max-clamp. > */ > > Be more clear? It works: short and effective... will update in v6. Thanks. -- #include Patrick Bellasi