Received: by 2002:a25:d7c1:0:0:0:0:0 with SMTP id o184csp99711ybg; Tue, 22 Oct 2019 16:52:58 -0700 (PDT) X-Google-Smtp-Source: APXvYqy4ix1eQ+EmYi7bbOwCj2JSK8n56vPJXqDYImHXrzOOjGNLdoErGnqctGl7k2ekuGfC/INA X-Received: by 2002:a17:906:254e:: with SMTP id j14mr4914654ejb.150.1571788378881; Tue, 22 Oct 2019 16:52:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571788378; cv=none; d=google.com; s=arc-20160816; b=XNTHKVcJ+5cnhQ9//n9clw4x7jtlXuBF0Hwa1eNHQX+qm+uzbax4b9/t/LiaXkJN5k 3JI8ljTRsco5Pxd3Z5YGHbbbao93f1tB2QP9U7WSMqy+DvzWkd0cRdFoDg63BnM0w4o3 pL6aWza4UYMHGeU83LQ4MAlShKD/s+E9Csv4IF+wLxEKVgaj0Ae7cXflyeOztyTEtEI2 qmFODxVy9JkzwTjRd2iwCNdP4X2nEodTKYUIkyQCYdGxI/TMS6kQ7SAkUGMh31fgq+Ut lcdozdT/8u0nVqbuMOxVnhHkulWt4Jy9BBmbokAu86N5udXIqUvoiVMjSr2pUVS5KylO xxgQ== 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=UTw/C9YOFOt2girMz7/HTweAfnMneRk1SahAwoeEi/8=; b=FyG2xUwRGuT+vmRJjhA3G043uzRWSnE7u8u0WYxDNUnp0Cq0K1AOdBQJBO6cpguVpT 0zv+kPdtFGo5CWgHXxq7Nv1XQNFofxLTABsqB/sy5Iqd/BnhbVzwTgpIrGYAdlCI7v8p FJ8Kfa5sE3rhZvbLE050J4tiVLjDkJLtV/TkVrCFpx/pfguOt3kFR4GX10/kjkGvANmr M7aAKnSMkdGHNy678dlxui5fmFNIdp3B1ny+A6wXr5UuKzpIh6nr8tNne4AvV6s+SvQU RR/84BNQoQfp9FLAZRCAFTYzGcHNHf7fJyWeTdJ2OvpT+vMfhEnHppb1wL7O+lqI/tLu s/AA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=aGkYnf6z; 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 w32si4387733edc.443.2019.10.22.16.52.35; Tue, 22 Oct 2019 16:52:58 -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=pass header.i=@linaro.org header.s=google header.b=aGkYnf6z; 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 S2389491AbfJVUen (ORCPT + 99 others); Tue, 22 Oct 2019 16:34:43 -0400 Received: from mail-qt1-f195.google.com ([209.85.160.195]:36329 "EHLO mail-qt1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389407AbfJVUeh (ORCPT ); Tue, 22 Oct 2019 16:34:37 -0400 Received: by mail-qt1-f195.google.com with SMTP id d17so14264028qto.3 for ; Tue, 22 Oct 2019 13:34:36 -0700 (PDT) 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=UTw/C9YOFOt2girMz7/HTweAfnMneRk1SahAwoeEi/8=; b=aGkYnf6z5uRBHSkiivv6AM3qIXlIT5VCPXugOf2w1ms7hIEg+Uz/p4OQDtJ/C/avl2 N40dP786qDXUTRM6eF2Xn6o0OQJjAV250vcfoAxxYLL2TS5k18TvLX5TdK8jxS0FoetW h11byvDgqKOwyVDvqkjFFxG3KQUpYzs0UcIwzD83t1lbOWMR8mGPRvTdfmeKHBsY9hsk ChyXQif9WtkMentpyNrEb4QJj2wHAYaOdzrkP550Kqr0182q+oc3tr08V8n/bm9HdKLs NGkdP7VtXme67OU/N6Qun1+Os1vvj0gu4bgzySU8Fnq9h0q9XiBR5sKLDAT0/C6/Ewm3 W+ig== 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=UTw/C9YOFOt2girMz7/HTweAfnMneRk1SahAwoeEi/8=; b=GKQC82juiz8IgpW4Xx6YSuL40x+PBvt6F2aANj+XSGN9Qm4qQaZ8mon7mhgYoMBlfy dThomJ/8HDftETHIy7kD74cxSMAbDIP4okpbhlBpex/ipmdwlRIYKjLZ3ctJSv613N5D uCZhazyMFSlpMy7qFocwy3lSdDTehF3n/2dV7Mgb6bdiQtpuROHFrD5QmZnrG2HMIXoX gbT4H90J1RoiWrEiewCV/mjIuFqpxqPjyg/67zwnX4BM5SJbEQJSasouAZFhmt9QJJPZ OBQDDE1RJIL+3x4KRxmiqkfrhJB2nCu2AelajvJ86b6o3t/nArZjahVTz06G7fhp0xq/ y1TQ== X-Gm-Message-State: APjAAAUQOUAEMLogIBkU1VAJx5VKcY2A6M3G8VgNczeTxVSfcHTGgw9e FUVVDvefCTZCRP21f0IYh39gXA== X-Received: by 2002:a0c:efcd:: with SMTP id a13mr5135070qvt.94.1571776475947; Tue, 22 Oct 2019 13:34:35 -0700 (PDT) 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 r126sm8895038qke.98.2019.10.22.13.34.34 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 22 Oct 2019 13:34:34 -0700 (PDT) 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 v4 5/6] thermal/cpu-cooling: Update thermal pressure in case of a maximum frequency capping Date: Tue, 22 Oct 2019 16:34:24 -0400 Message-Id: <1571776465-29763-6-git-send-email-thara.gopinath@linaro.org> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1571776465-29763-1-git-send-email-thara.gopinath@linaro.org> References: <1571776465-29763-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 --- 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. + */ +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; + + for_each_cpu(cpu, cpus) + 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 +337,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 +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); + + return ret; } /** -- 2.1.4