From patchwork Tue Nov 5 18:49:45 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thara Gopinath X-Patchwork-Id: 178553 Delivered-To: patch@linaro.org Received: by 2002:a92:38d5:0:0:0:0:0 with SMTP id g82csp1151927ilf; Tue, 5 Nov 2019 10:50:30 -0800 (PST) X-Google-Smtp-Source: APXvYqxaMpgayYUs+AGW9dCYGQVqbH9ncoO/gkQH6mzOOw4NIoJYkTB+m1ykYJNuQqr6ZDbFqneq X-Received: by 2002:a17:906:c801:: with SMTP id cx1mr31481899ejb.266.1572979830202; Tue, 05 Nov 2019 10:50:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1572979830; cv=none; d=google.com; s=arc-20160816; b=ujTjd65Dt3VmHGEdAEb2jxW7zaq1LFK5/VrJEG/k/5idoma0HmBWhg56kEXJxFRGhT Tk4dLXF1ziE5OhKmXp90mH7xaQDJeUjImtva5VsZ56FAy8K/F51cnvK1f3OmdfNfzRd0 ndu9vmKDCsV+VDjpcPaczZyZlpzCoFYoEALOXCr6Lip3utWAtUcBGjNZFyv6S3lxbMjj PSji64reYsFj/ChqArtHLiEFGx21Tlui5XE8aWv7XaLP9NFsU2J4Hb+Yi0md4mf4i9wj KkuJUfqIJWHpXK578wCnneo2KfC1tVXUZsy8aySpePvSXoUi4+tACxyX4UPaHuSUFL2n 2E6g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=CG7OyLBYjzLCAG4H5jKpLvvKWoPx2TvWNE2pLKqlhn0=; b=ue7IxdUrA8VovjYXEqDM2W4KMyPGiTPylMFBWn+LgQuVWZPrwozYC5k7BUqa/QW8ss 0MgHvi58zMCPTCdZEkynkAf+lFcSBUYw1+YIL+t5KR6gulgme8uomXzA/ikNC4lHCBhB FQX96DfRvhXimP3BbdblA7Q4TC8HG8Qh4mQHQ1RgJ6GVyxUUOd1aVtJMsw6TrZvc4zb1 FAV38vsTsq2hcYTJa9UOcax2/Uz6M0af6yPzVvSi+0W60dYpwcIxqRT0FeDvb8AB4OHt Ez1N6faJVdeg3X/VSDVZAPNK50ZijjFgodR9WSVVcvK/NnUPckVBv9FnbQxtwip0w8Cz V0lA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=hgKe8F71; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id nj2si13921473ejb.233.2019.11.05.10.50.29; Tue, 05 Nov 2019 10:50:30 -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=pass header.i=@linaro.org header.s=google header.b=hgKe8F71; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2390848AbfKESuC (ORCPT + 26 others); Tue, 5 Nov 2019 13:50:02 -0500 Received: from mail-qk1-f195.google.com ([209.85.222.195]:44881 "EHLO mail-qk1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2390827AbfKESt4 (ORCPT ); Tue, 5 Nov 2019 13:49:56 -0500 Received: by mail-qk1-f195.google.com with SMTP id m16so21790562qki.11 for ; Tue, 05 Nov 2019 10:49:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=CG7OyLBYjzLCAG4H5jKpLvvKWoPx2TvWNE2pLKqlhn0=; b=hgKe8F71HOeu6/wF3M0ARl/hvxLi5HrtK8or4YBExUXSTvdLLvtOAh05PUb8C1dedy eeuIG9u2ICb//KPinErDIy/g4ZueCX6OiIJE9VQfLO+tiZXXV7sGiu0mb96wRO/4Q1Sj +3V91qEqItS3wkCi8gVNXz5CUTK9t+yWcrUbKQ5O4/pGgVrM9gduZpaQDOThrDixS0BN CDm6npYX2Cr03ox8aqEOzpQQgt3sXiI/vdHLiC35dq2kfbR0VAP5h2kTBFPe2pr/v5CQ 9pq6Lg5B6IUu/mTfqWEsPFHY0cOWvEwDowTMrcHnmwxv3XO4frTHhJ+aIDlj0nAS6CDp hRsQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=CG7OyLBYjzLCAG4H5jKpLvvKWoPx2TvWNE2pLKqlhn0=; b=nlqjBx5p7aE87LWDgLdp1NPa0ml9SoZWn7X5KnPONI6NYA+7Kk2A8Y4xhXzhraAyfu q4sCdq4b6j++FgYpGW5XZ21irvu7WR3j/3CfvxN0FZXXYwNQEYbInuhNwXNt4MSWrcLj KsbowpMCwtTe3GgJaByrS4lcWVdZtfwLsPrB43eY3McNEPs70qNLOXVxIOOkdI8+pkUA SKMsV/+mK0NGh6rpIHbC9JQ0e52Q1dUHHL7q7wr7zvylY88nVUDo9jWW8NziwSffZFWp QqOXkJajtpxyBhypWwUyCL2wn575sU59fBJjLzqqeW3AYOp5RPxwLQO1VZWakTBgX5hG bgsw== X-Gm-Message-State: APjAAAXNslJSilynUALFzwDrPBgDDkq7MvUoF3pppIFeCeJ2tBW1c8cX cXgfa+r24MS76Y48bCiKxAhxBA== X-Received: by 2002:a37:4f4e:: with SMTP id d75mr8315091qkb.490.1572979794552; Tue, 05 Nov 2019 10:49:54 -0800 (PST) Received: from Thara-Work-Ubuntu.fios-router.home (pool-71-255-246-27.washdc.fios.verizon.net. [71.255.246.27]) by smtp.googlemail.com with ESMTPSA id j7sm6832565qkd.46.2019.11.05.10.49.53 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 05 Nov 2019 10:49:53 -0800 (PST) From: Thara Gopinath To: mingo@redhat.com, peterz@infradead.org, ionela.voinescu@arm.com, vincent.guittot@linaro.org, rui.zhang@intel.com, edubezval@gmail.com, qperret@google.com Cc: linux-kernel@vger.kernel.org, amit.kachhap@gmail.com, javi.merino@kernel.org, daniel.lezcano@linaro.org Subject: [Patch v5 5/6] thermal/cpu-cooling: Update thermal pressure in case of a maximum frequency capping Date: Tue, 5 Nov 2019 13:49:45 -0500 Message-Id: <1572979786-20361-6-git-send-email-thara.gopinath@linaro.org> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1572979786-20361-1-git-send-email-thara.gopinath@linaro.org> References: <1572979786-20361-1-git-send-email-thara.gopinath@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- v4->v5: - fixed issues in update_sched_max_capacity comment header. - Updated update_sched_max_capacity to calculate maximum available capacity. drivers/thermal/cpu_cooling.c | 36 ++++++++++++++++++++++++++++++++++-- 1 file changed, 34 insertions(+), 2 deletions(-) -- 2.1.4 diff --git a/drivers/thermal/cpu_cooling.c b/drivers/thermal/cpu_cooling.c index 391f397..c65b7c4 100644 --- a/drivers/thermal/cpu_cooling.c +++ b/drivers/thermal/cpu_cooling.c @@ -218,6 +218,27 @@ static u32 cpu_power_to_freq(struct cpufreq_cooling_device *cpufreq_cdev, } /** + * update_sched_max_capacity - update scheduler about change in cpu + * max frequency. + * @cpus: list of cpus whose max capacity needs udating in scheduler. + * @cur_max_freq: current maximum frequency. + * @max_freq: highest possible frequency. + */ +static void update_sched_max_capacity(struct cpumask *cpus, + unsigned int cur_max_freq, + unsigned int max_freq) +{ + int cpu; + unsigned long capacity; + + for_each_cpu(cpu, cpus) { + capacity = cur_max_freq * arch_scale_cpu_capacity(cpu); + capacity /= max_freq; + update_thermal_pressure(cpu, capacity); + } +} + +/** * get_load() - get load for a cpu since last updated * @cpufreq_cdev: &struct cpufreq_cooling_device for this cpu * @cpu: cpu number @@ -320,6 +341,7 @@ static int cpufreq_set_cur_state(struct thermal_cooling_device *cdev, unsigned long state) { struct cpufreq_cooling_device *cpufreq_cdev = cdev->devdata; + int ret; /* Request state should be less than max_level */ if (WARN_ON(state > cpufreq_cdev->max_level)) @@ -331,8 +353,18 @@ 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); + } + + return ret; } /**