Received: by 2002:a25:d7c1:0:0:0:0:0 with SMTP id o184csp3819322ybg; Mon, 28 Oct 2019 20:16:48 -0700 (PDT) X-Google-Smtp-Source: APXvYqyqXJa9znajzDlSQ5bwU7Kd459vhRxpiFbML10Y/zzgVN2liXRopigKRrWfxYJhmuEIkGOC X-Received: by 2002:a05:6402:1049:: with SMTP id e9mr22915165edu.91.1572319008763; Mon, 28 Oct 2019 20:16:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1572319008; cv=none; d=google.com; s=arc-20160816; b=f6LHD2fJAjrc/FY8XOWOMPX1khQvQfKXfraIr5EW7sI9RYrLNpA140nbLnSxJ6qJWj rdjPD7lWPyvBWe5m3Oeqto/8X0B8Lul5iOhjHmVesz4EqRFQdnud2hK+H/HQHtSe3+Ui 7Bm+t6rSyVu2/mLNRseHWQZSxSEBsktvi/seiUceI/2haXZKTytHEVfTtZ/EwlgOs6nU p4S8j0J0mCDTkrjCdmwm15BJ4Uv1iQIwnsKIfcT3N/N20+U3Wolk8yyn69LAFKKer7jK Qc/8Iqs7iV9mWK18xmWawbbwDjiUezTVR/odGQP7d8P0MC1g1ZX/728/jzzFI9PF7jwC zjrQ== 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=zQuvBEiQv7/Ur7mCHVSdKJIemOFk01eQ56PkcAWxYvo=; b=z9DDA3wcsBOSaapUkvMIkzzqlP7ENaP1kEBWF4JBdqUvuJgJldYgZErkkOVM78m2E2 yPmOR9yb6M2zd77jpzMVfUjzTTolbZ1WJWfh/F6bXTi4bBcCNhFvxQhrK5vXy8BOHivh Mk9dMHEVomB+4Y8idQ3rqM/wZ6fQG/WN9ZDmYvZNMpNG3XWNXDzkeIypior+/Fbc9JOh PszxUFys5Sho1mWK2WJljkwD3d2GBdmPyJMB0TwI4epzCXpWqW6hWegp6Ktw68gYFNEz qL7qVbfXpCdFKtPAN3V5GwpmuiEWiwZR7rbdlMS2rXh2yZhpi0rBRMlCEc/AW1vrDwFr 6AqA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=merlin.20170209 header.b="d/JN3eUo"; 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 s2si9444653edi.413.2019.10.28.20.16.24; Mon, 28 Oct 2019 20:16: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="d/JN3eUo"; 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 S1731144AbfJ1PdY (ORCPT + 99 others); Mon, 28 Oct 2019 11:33:24 -0400 Received: from merlin.infradead.org ([205.233.59.134]:59278 "EHLO merlin.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726411AbfJ1PdX (ORCPT ); Mon, 28 Oct 2019 11:33:23 -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=zQuvBEiQv7/Ur7mCHVSdKJIemOFk01eQ56PkcAWxYvo=; b=d/JN3eUoLJaDDhpwAP87uijIB KwTsU4dw78A51c+/o2xGh0VkNePm6IAWBOLYcQMMgsMqAefslZY4ORtUlhMkE6uXhlpS7q+N1H443 eEjrNkugb/xqmCVjdp5GPKI1EF0DOpskr/9k4bKsEzoJHMtxd+JqgnQDoLMQgyLDR3mHY9tnMIzhR JUut/QFBiRf8cqM1df0uCiQ8x90UCqWXYWpGCoVViLz33FgolZAbxV8TyuY0tOUE1QJYGI4A7ZCrp 8TmxqGAY+T7eLk0OC7zacbDpnGjaQarO/D2onOJ8ju59XpWOcCmDIe7YGOGtBegcGtxnvcAwCrgu1 V2KNKTLvQ==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=noisy.programming.kicks-ass.net) by merlin.infradead.org with esmtpsa (Exim 4.92.3 #3 (Red Hat Linux)) id 1iP719-000346-2j; Mon, 28 Oct 2019 15:33:15 +0000 Received: from hirez.programming.kicks-ass.net (hirez.programming.kicks-ass.net [192.168.1.225]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by noisy.programming.kicks-ass.net (Postfix) with ESMTPS id 7AE05300EBF; Mon, 28 Oct 2019 16:32:13 +0100 (CET) Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id C7E682B4468CB; Mon, 28 Oct 2019 16:33:13 +0100 (CET) Date: Mon, 28 Oct 2019 16:33:13 +0100 From: Peter Zijlstra To: Thara Gopinath Cc: mingo@redhat.com, ionela.voinescu@arm.com, vincent.guittot@linaro.org, rui.zhang@intel.com, edubezval@gmail.com, qperret@google.com, linux-kernel@vger.kernel.org, amit.kachhap@gmail.com, javi.merino@kernel.org, daniel.lezcano@linaro.org Subject: Re: [Patch v4 5/6] thermal/cpu-cooling: Update thermal pressure in case of a maximum frequency capping Message-ID: <20191028153313.GF4097@hirez.programming.kicks-ass.net> References: <1571776465-29763-1-git-send-email-thara.gopinath@linaro.org> <1571776465-29763-6-git-send-email-thara.gopinath@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1571776465-29763-6-git-send-email-thara.gopinath@linaro.org> 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 22, 2019 at 04:34:24PM -0400, Thara Gopinath wrote: > Thermal governors can request for a cpu's maximum supported frequency > to be capped in case of an overheat event. This in turn means that the > maximum capacity available for tasks to run on the particular cpu is > reduced. Delta between the original maximum capacity and capped > maximum capacity is known as thermal pressure. Enable cpufreq cooling > device to update the thermal pressure in event of a capped > maximum frequency. > > Signed-off-by: Thara Gopinath > --- > drivers/thermal/cpu_cooling.c | 31 +++++++++++++++++++++++++++++-- > 1 file changed, 29 insertions(+), 2 deletions(-) > > diff --git a/drivers/thermal/cpu_cooling.c b/drivers/thermal/cpu_cooling.c > index 391f397..2e6a979 100644 > --- a/drivers/thermal/cpu_cooling.c > +++ b/drivers/thermal/cpu_cooling.c > @@ -218,6 +218,23 @@ static u32 cpu_power_to_freq(struct cpufreq_cooling_device *cpufreq_cdev, > } > > /** > + * update_sched_max_capacity - update scheduler about change in cpu > + * max frequency. > + * @policy - cpufreq policy whose max frequency is capped. Uhm, this function doesn't have a @policy argument. > + */ > +static void update_sched_max_capacity(struct cpumask *cpus, > + unsigned int cur_max_freq, > + unsigned int max_freq) > +{ > + int cpu; > + unsigned long capacity = (cur_max_freq << SCHED_CAPACITY_SHIFT) / > + max_freq; check your types and ranges. What units is _freq in and does 'freq * SCHED_CAPACITY' fit in 'unsigned int'? If so, why do you assign it to an 'unsigned long'? > + > + for_each_cpu(cpu, cpus) > + update_thermal_pressure(cpu, capacity); > +} > @@ -331,8 +349,17 @@ static int cpufreq_set_cur_state(struct thermal_cooling_device *cdev, > > cpufreq_cdev->cpufreq_state = state; > > - return dev_pm_qos_update_request(&cpufreq_cdev->qos_req, > - cpufreq_cdev->freq_table[state].frequency); > + ret = dev_pm_qos_update_request > + (&cpufreq_cdev->qos_req, > + cpufreq_cdev->freq_table[state].frequency); > + > + if (ret > 0) > + update_sched_max_capacity > + (cpufreq_cdev->policy->cpus, > + cpufreq_cdev->freq_table[state].frequency, > + cpufreq_cdev->policy->cpuinfo.max_freq); Codingstyle wants that in { }. > + > + return ret; > } > > /** > -- > 2.1.4 >