From patchwork Tue Oct 9 16:25:02 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thara Gopinath X-Patchwork-Id: 148514 Delivered-To: patch@linaro.org Received: by 2002:a2e:8595:0:0:0:0:0 with SMTP id b21-v6csp5109791lji; Tue, 9 Oct 2018 09:25:21 -0700 (PDT) X-Google-Smtp-Source: ACcGV62nrhSKZcSJBRT/L4G4nSDjFRX59Eo50kfj0ueFeBk89iMIgSqjsjJxUITzMVUmjpmdW9/A X-Received: by 2002:a63:2807:: with SMTP id o7-v6mr26087700pgo.155.1539102321284; Tue, 09 Oct 2018 09:25:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539102321; cv=none; d=google.com; s=arc-20160816; b=h0YfODnHWaRobjudrjblrWIL7sStHPRrxCVtyePqUlbjSF8FPgaWcBzsJ1Xo0VxWEZ dNkKWcG0yCddnDpKClbdp5VaVgHxLMxl58ANO2ywG4tXDTWajWIGKIa1efokQx9Gdncj GwTXzw4CaDxlVr2N0KRlC7hEEbm9NXSohEmS9NQKh7gNt+S5KK/+xDL4PN/FGsfdH/IX nQMBx8/5eGAcU4xLQCQ0kl9Xgbg3rGNVmNLVVmsQxdwjbtHDrkephG1gdzibvakcj5NN /nn/7428XPi8q2ZXUuh8nFDSRTc4fQUqyr2sZC2DniHwoLAGiX6NabyB9NefiRHFmgsg XosA== 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=UIFc3U9b1yatdLWujpefxy7t6MQaAgHr+I2D1im9/HuJYIm0sMHFYA4gDWKabCkLWG z9awvlXvlKJrqR86WFD9ofZSY+1QWoScn257QTZcrYbrThYG4t779znrvnR2w0/jmP67 H9J1kVdJXfACBY1adSh2FQKy1dj3iCGrbtzIrhVyPIkeZPJfnNcbiVlu1rd7frXWrtJf Cp3WzGv6Ero0O0YVi+EqvE9VnjpWYyU8GsAZWNjpxCYuh4gKKV1I4MvgOCPiIUTGgN5K wWXtp+niA1tVwBvU4wg6j7HaB+Rk9W/rrbJ1nnr40BCzBzZJdi+EEMIbSOqbThd3wprB 3guw== 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-pm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-pm-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 g6-v6si19960506pgb.408.2018.10.09.09.25.21; Tue, 09 Oct 2018 09:25:21 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-pm-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-pm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-pm-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 S1727370AbeJIXnC (ORCPT + 10 others); Tue, 9 Oct 2018 19:43:02 -0400 Received: from mail-qt1-f193.google.com ([209.85.160.193]:38644 "EHLO mail-qt1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727344AbeJIXnB (ORCPT ); Tue, 9 Oct 2018 19:43:01 -0400 Received: by mail-qt1-f193.google.com with SMTP id l9-v6so2301561qtf.5 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=UjFW8WyzIvmu75UUqKEpPth7e+hCQQcu7PcPeRawyTY5w8m2ScQyFhQABGpQAup7YW gbHaLqD9QdOy4V11nRe33CLxhB3BtBaXeGqaYuL6NX7sL2gZwVIFyziICx7HVq4laadW YIZwVjgnmeP6R+lxPmLLy0cuFnqXKJiHFQmFrZJD4C/NFduggqVlUldMX1JN6f9DUX6Q sn1Kxa/wXQPq36VvWb2unhSEdO01OesoPvKFNtXpRxVnySgdipRUxrvhwVMKXezLU/Np yBYpoM5iMvuA/2d/O5Pg6Ud5oYBBQxeKRcVFBxbNmy+VUDs76MdmH0fkJaTb/C1XeH7h EBOA== X-Gm-Message-State: ABuFfoiYc+8xw+sn2NWUcBUTXvJssRgBh2nsok5HBr7ie4Ybvl37AP83 Uy9ArMXz8MCHf/rVF1BQFolVOw== 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-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@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(-) -- 2.1.4 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);