Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp6685316ybl; Mon, 23 Dec 2019 09:57:06 -0800 (PST) X-Google-Smtp-Source: APXvYqySvQTedtge7KmPIIIbC/kFXohh4hxX5/UwvuF2zSMCnK5QQOtFlSxD3UYy4GZFWhBPZkdD X-Received: by 2002:a9d:7a97:: with SMTP id l23mr29934481otn.34.1577123826459; Mon, 23 Dec 2019 09:57:06 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1577123826; cv=none; d=google.com; s=arc-20160816; b=yfQdzjtxu2N0b0aWxar79+5zhzyuC1eP39wqmpxyfJiU7FsjsKh0OGqnBXfc2iXUHd X7LJmYRaygqgMbFHA3VwZbwv7SHLNJQrbSxJkd1JDfmK6GiGRK+IH8C07ADW2/anBZYo vCo8kBCcZZi9FeSeT1OUE4nfu3+mAbZ1r2shTgefzMNcnxB/bqKRLowbbXKWAYqpbgtf OdcX/66dm/UsE9cJqTdaMTt/xDDtNzsO2wZJsOyLfb03tk3Q9iAk2GLQc6w2iz8JxAqY jykVhEmcYZh8v0noI4uHpraaMs3R/qLws4bzKfyzX6GXFIcN40c2/+ssT8C632SI82ir oChA== 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=W84wNda26q8GT7mL+KUhCSB8l2hBlpqOlZLRWwhjB6A=; b=kvWFoPtZgrYbKgx0bCrzuzjThnweshIWgwdHwqgf53cd+ka3Roy7Xc+RfFbeutSZYG OnsBGJ9C40ehSVTaw6ihYkxEXM7ZQe/gNc+dhAgpMaj/n9wnz9PbGALxIe4scKBag2BT WU5J7FoyuacZFDaX5lxitl3kKVkCVIcU8edChs7o4FC2s/TkmH38++35JRD+GGjdcySt JIrs/SCtRoAVowi0mmA96bKrI/6GxjP4GURWl0w81RjHqp59N2w/V8qqnmqS6KOpsJc8 CHUCWhL8mehtRnrPHWPn8NZjhLlWULfswjBsIBuJ8wVM7NcK8Lpt02j5HzFnhWwpWo/o kM+g== 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 v12si711517otf.84.2019.12.23.09.56.54; Mon, 23 Dec 2019 09:57:06 -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 S1726821AbfLWRzB (ORCPT + 99 others); Mon, 23 Dec 2019 12:55:01 -0500 Received: from foss.arm.com ([217.140.110.172]:47528 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726754AbfLWRzA (ORCPT ); Mon, 23 Dec 2019 12:55:00 -0500 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id DC0D3328; Mon, 23 Dec 2019 09:54:59 -0800 (PST) Received: from localhost (e108754-lin.cambridge.arm.com [10.1.198.81]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 7DA573F68F; Mon, 23 Dec 2019 09:54:59 -0800 (PST) Date: Mon, 23 Dec 2019 17:54:58 +0000 From: Ionela Voinescu To: Thara Gopinath Cc: mingo@redhat.com, peterz@infradead.org, vincent.guittot@linaro.org, rui.zhang@intel.com, qperret@google.com, daniel.lezcano@linaro.org, viresh.kumar@linaro.org, linux-kernel@vger.kernel.org, amit.kachhap@gmail.com, javi.merino@kernel.org, amit.kucheria@verdurent.com Subject: Re: [Patch v6 6/7] thermal/cpu-cooling: Update thermal pressure in case of a maximum frequency capping Message-ID: <20191223175458.GC31446@arm.com> References: <1576123908-12105-1-git-send-email-thara.gopinath@linaro.org> <1576123908-12105-7-git-send-email-thara.gopinath@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1576123908-12105-7-git-send-email-thara.gopinath@linaro.org> 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 Wednesday 11 Dec 2019 at 23:11:47 (-0500), Thara Gopinath wrote: [...] > @@ -430,6 +430,10 @@ static int cpufreq_set_cur_state(struct thermal_cooling_device *cdev, > unsigned long state) > { > struct cpufreq_cooling_device *cpufreq_cdev = cdev->devdata; > + struct cpumask *cpus; > + unsigned int frequency; > + unsigned long capacity; > + int ret; > > /* Request state should be less than max_level */ > if (WARN_ON(state > cpufreq_cdev->max_level)) > @@ -441,8 +445,19 @@ static int cpufreq_set_cur_state(struct thermal_cooling_device *cdev, > > cpufreq_cdev->cpufreq_state = state; > > - return freq_qos_update_request(&cpufreq_cdev->qos_req, > - get_state_freq(cpufreq_cdev, state)); > + frequency = get_state_freq(cpufreq_cdev, state); > + > + ret = freq_qos_update_request(&cpufreq_cdev->qos_req, frequency); > + > + if (ret > 0) { > + cpus = cpufreq_cdev->policy->cpus; > + capacity = frequency * > + arch_scale_cpu_capacity(cpumask_first(cpus)); > + capacity /= cpufreq_cdev->policy->cpuinfo.max_freq; > + arch_set_thermal_pressure(cpus, capacity); Given that you already get a CPU's capacity (orig) here, why don't you pass thermal pressure directly to arch_set_thermal_pressure, rather than passing the capped capacity and subtracting it later from the same CPU capacity (arch_scale_cpu_capacity)? If my math is correct this would work nicely: pressure = cpufreq_cdev->policy->cpuinfo.max_freq; pressure -= frequency; pressure *= arch_scale_cpu_capacity(cpumask_first(cpus); pressure /= cpufreq_cdev->policy->cpuinfo.max_freq; Thanks, Ionela. > + } > + > + return ret; > } > > /* Bind cpufreq callbacks to thermal cooling device ops */ > -- > 2.1.4 >