Received: by 2002:ac0:a582:0:0:0:0:0 with SMTP id m2-v6csp5083474imm; Tue, 9 Oct 2018 09:26:10 -0700 (PDT) X-Google-Smtp-Source: ACcGV63FVaiVrf1FFpDX/1gSdy/dpZUYVGXhgk62Fov9b2M3AeVJpKE3y5fXLBEaKt9NDru5i006 X-Received: by 2002:a62:824a:: with SMTP id w71-v6mr30658696pfd.68.1539102370250; Tue, 09 Oct 2018 09:26:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539102370; cv=none; d=google.com; s=arc-20160816; b=w8ZwATkOv1A/4LGu7ZpTc45jYc0fDLfwxivblAuFnjSabIC31v0tdQrq7+sz8uYZnT q9IJjIo4g2TUdB10ONehNrSP95PRIDxmVN/WXOLbHgVCuueRFereKabZugkkH6Deeez2 hlFnxJIyq09pifARnctMHU4h0ywlhCoATb0N9wPZ2f4icIRKlFrTVoOaEbAo/E8VwV1n ckoeouaPdmS4OMnjc2XbAzP8O6IOMM8NpBByHWEI36gab742quXyD+w+GtiEKUyPBunD p0LXWLQ3TAdmkNF3Wb3lxdehitiFTIc4tJ6jx49VjTWjJq9pTxEacOPPVyn09bO9nDYw TvzA== 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=GRe242656I2kSmkisEDP4QURqPrSR1lR6wXda3PHx2M=; b=XpFNFHL0fvri7jKaa/M6Zlmag5XaGwp94YxPoyD5sRMRxgIqk5Hwz8bN0jHKx1isrF /Z9vtekJNSqDJb2zohZiaav67+aV/nLsfVCpYfVWBKB/Kqt+r3wVpBKn6im1Y5PQTpIH i9s1U+nYw9KuTMQYiR1V50HqqrjzpYhIq6lLsM3VtNQfSCZcfWrNaOjjuAqisD4217dd eLate6YrEbhv2IFMZna+lYzNqQPDxyYYWmWl4da25wlwFk59CROSCPcuPytxM8xksW2V lQ0TXUnAKNMzrbgV9utX7PUJmX8FfHF9cXQu5cxZfxZ0JLm/CkFjUWVPx+5DCMMAS2ei N8cw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ER4xWmIG; 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 8-v6si19042439pgr.205.2018.10.09.09.25.54; Tue, 09 Oct 2018 09:26:10 -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=ER4xWmIG; 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 S1727388AbeJIXnD (ORCPT + 99 others); Tue, 9 Oct 2018 19:43:03 -0400 Received: from mail-qt1-f195.google.com ([209.85.160.195]:44785 "EHLO mail-qt1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727363AbeJIXnC (ORCPT ); Tue, 9 Oct 2018 19:43:02 -0400 Received: by mail-qt1-f195.google.com with SMTP id c56-v6so2271565qtd.11 for ; Tue, 09 Oct 2018 09:25:18 -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=GRe242656I2kSmkisEDP4QURqPrSR1lR6wXda3PHx2M=; b=ER4xWmIGGf0H2vl9y2Fj4owD1BLyf9jZ95fW+MYRK+nMMVlkbQWwdinhRQcjqR5zxn PykedBVvjECgPpObatTrDWTvAFhWZwEnfot/r1pOdP7ivf04iIYooC4YU3fO2I0jg7eT F1bCoLNJysWM98qBP8HpCLP3hZcnodWcJAFb4= 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=GRe242656I2kSmkisEDP4QURqPrSR1lR6wXda3PHx2M=; b=EXf1wEa56NdpLBRcpz9IxszTmfuD+7GvRPmV/4a5B590Mc/NH3ZlhSY/ZcAvK1gHGP fjen6SneXh9xYReFFahRVZGm4Y2i+PTndx4yodoqUe77IScd3TAAgyy2/jglo3QIvAl4 p5YHTYPuWqlYPfdEnujefq4UZDez8zC4vb4T5/3pW2XYegVeFE1tLPOUWU9RDe5eoBQv oCGePH2xOfEEKmuOToI3SrwTvbSEPx+2rG8dnjk6A5xaYnRQYYuCpKNFHA4lhk9Wn3vv aUsMNqvgUZQlhGXv3iE60gAVOY6uADxTcD/1DQtjEhIHnttANSzXKVwg3SG3ZvlCsPW+ 3grA== X-Gm-Message-State: ABuFfog9k+ARRMTfQCINHjQYSaQ+VkthlA9W7NMQV0sdea5jz9N0J9q3 9stCre/qHmJsYW6x9aGWV1uuxPQD32WVpA== X-Received: by 2002:ac8:b0d:: with SMTP id e13-v6mr742910qti.375.1539102317526; Tue, 09 Oct 2018 09:25:17 -0700 (PDT) Received: from Thara-Work-Ubuntu.fios-router.home (pool-71-255-245-97.washdc.fios.verizon.net. [71.255.245.97]) by smtp.googlemail.com with ESMTPSA id o7-v6sm10441169qkc.67.2018.10.09.09.25.16 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 09 Oct 2018 09:25:16 -0700 (PDT) From: Thara Gopinath To: linux-kernel@vger.kernel.org, mingo@redhat.com, peterz@infradead.org, rui.zhang@intel.com Cc: gregkh@linuxfoundation.org, rafael@kernel.org, amit.kachhap@gmail.com, viresh.kumar@linaro.org, javi.merino@kernel.org, edubezval@gmail.com, daniel.lezcano@linaro.org, linux-pm@vger.kernel.org, quentin.perret@arm.com, ionela.voinescu@arm.com, vincent.guittot@linaro.org Subject: [RFC PATCH 7/7] thermal/cpu-cooling: Update thermal pressure in case of a maximum frequency capping Date: Tue, 9 Oct 2018 12:25:02 -0400 Message-Id: <1539102302-9057-8-git-send-email-thara.gopinath@linaro.org> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1539102302-9057-1-git-send-email-thara.gopinath@linaro.org> References: <1539102302-9057-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 | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/drivers/thermal/cpu_cooling.c b/drivers/thermal/cpu_cooling.c index dfd2324..da8de66 100644 --- a/drivers/thermal/cpu_cooling.c +++ b/drivers/thermal/cpu_cooling.c @@ -31,6 +31,7 @@ #include #include #include +#include #include @@ -132,6 +133,21 @@ static unsigned long get_level(struct cpufreq_cooling_device *cpufreq_cdev, } /** + * cpufreq_update_sched_max_capacity - update scheduler about change in cpu + * max frequency. + * @policy - cpufreq policy whose max frequency is capped. + */ +static void cpufreq_update_sched_max_capacity(struct cpufreq_policy *policy) +{ + int cpu; + unsigned long capacity = (policy->max << SCHED_CAPACITY_SHIFT) / + policy->cpuinfo.max_freq; + + for_each_cpu(cpu, policy->cpus) + update_maxcap_capacity(cpu, capacity); +} + +/** * cpufreq_thermal_notifier - notifier callback for cpufreq policy change. * @nb: struct notifier_block * with callback info. * @event: value showing cpufreq event for which this function invoked. @@ -175,8 +191,10 @@ static int cpufreq_thermal_notifier(struct notifier_block *nb, */ clipped_freq = cpufreq_cdev->clipped_freq; - if (policy->max > clipped_freq) + if (policy->max > clipped_freq) { cpufreq_verify_within_limits(policy, 0, clipped_freq); + cpufreq_update_sched_max_capacity(policy); + } break; } mutex_unlock(&cooling_list_lock); -- 2.1.4