Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3177777imu; Sun, 11 Nov 2018 09:09:43 -0800 (PST) X-Google-Smtp-Source: AJdET5eEcUsM9wCTQH/inNXjivKy97wd1GM1Y7TAxO96vRLEyEat8S5ubCFmUBQQ84D+N767VuWD X-Received: by 2002:a17:902:f08f:: with SMTP id go15mr12924411plb.332.1541956183619; Sun, 11 Nov 2018 09:09:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1541956183; cv=none; d=google.com; s=arc-20160816; b=gOmB+tTgD0K0IrsaVtQ8tIQmJAxocSEWgEYuJbhrGNWVTc9+mGE9o+/ayeo90y6MGL A0jjHeaCkup4x/0gpYRfrIf2cSwcFAioFSw9d1p6yy93NgRzBlpC5OFmnpaj9K3upTY1 wLBmhYoUWX+rww8O8iz+OTQOhNlx+MuVLnoVV8xreUtGDhjOdT+xvWZn0bFOrM8sQg5s 0rJGJBekTUfsIbkB2+QIzLwlfO2rBtRE7uqxLKlBWsfge2WrBeIHgycg4eWpZGNZvV8E BUBc68/7KERMSzla+ejmITaXhpFgH7QST016cr6FGeHCXQjkpNtx3X5v1SK8zHKRB3Tv PROw== 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=FwgF1NHpHYmMZCJ+9zD+84bgqqIR0BArF7vCKU69adI=; b=mAP/aEdlLW5yJanuN7xZNPaVht0nwdIz9ZNdrH7O4nArAQyoX+Ye6DKnuJCo61VU+u LqL1CrCysrHVQ4Ad2m+xh2oOr+kbI1JCZNcWPjrgudxDJEJDzKywTQpsCTu9eBgJlg6t G491g96f9rda1tlJxab3+AvF0VSQ8JTNLLBuCTeWIpqMMQJQkZtsxxaKFPkU3zwN5Dr0 l98D1U1DV3FUfrkveLvkvjmh1hlzurR72YI+CT5Hx6X/niYbjSx3Njsqa54AgYrzohFx PyuJEn/P8wDLQDTBAVR/HOSaZtqNwzdj0AN4exZy7S2npl+9OTR+JhlFRKRTTijl0ow9 s9bg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=merlin.20170209 header.b=MgVQdXM9; 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 76-v6si17975898pfa.194.2018.11.11.09.09.23; Sun, 11 Nov 2018 09:09: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=merlin.20170209 header.b=MgVQdXM9; 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 S1729238AbeKLC6F (ORCPT + 99 others); Sun, 11 Nov 2018 21:58:05 -0500 Received: from merlin.infradead.org ([205.233.59.134]:56826 "EHLO merlin.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729193AbeKLC6F (ORCPT ); Sun, 11 Nov 2018 21:58:05 -0500 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=FwgF1NHpHYmMZCJ+9zD+84bgqqIR0BArF7vCKU69adI=; b=MgVQdXM9UyxJ4aaY+EWBeNC2v ABEtELyTWMr7zdWKRLISD+0KvDX4KC4FyjY95S8u8kqoBWZjB2sr7k+igjz2gMxyv89fqb64HbW89 m4xvFkvOCG4A4IE3hwJpKGzBZJhRZLSfLNpUffLQa3bz24uWCjBqQyjrlv2iRsOksRRRJwH0J1tsO X1BdnsYpDG+RzMZYE0vBljknrMGMvHmm7o4fGFDTXkx0Hc39vTKPFyQK4ssSJi47yBO+sohrFe/su WeCUg2IZxMUhoYMXYWqo0nHAOSyK5sQwnY/b4hcIEAOwYcf9COMhIBE7AvrdEpToA31lZq9Exz6Y3 XlydHGOvg==; Received: from [64.114.255.97] (helo=worktop) by merlin.infradead.org with esmtpsa (Exim 4.90_1 #2 (Red Hat Linux)) id 1gLtEA-0000Eo-Ff; Sun, 11 Nov 2018 17:08:51 +0000 Received: by worktop (Postfix, from userid 1000) id D0FD16E061A; Sun, 11 Nov 2018 18:08:48 +0100 (CET) Date: Sun, 11 Nov 2018 18:08:48 +0100 From: Peter Zijlstra To: Patrick Bellasi 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: <20181111170848.GB3038@worktop> References: <20181029183311.29175-1-patrick.bellasi@arm.com> <20181029183311.29175-8-patrick.bellasi@arm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20181029183311.29175-8-patrick.bellasi@arm.com> User-Agent: Mutt/1.5.22.1 (2013-10-16) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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?