From 6a3932ad4661fee014fd104c2c94bb21698e600e Mon Sep 17 00:00:00 2001 From: Vivek Aknurwar Date: Mon, 5 Jun 2023 16:44:11 -0700 Subject: [PATCH] cpufreq: qcom-hw: Add applied thermal pressure to the dcvsh_freq trace Add cpufreq applied thermal pressure to dcvsh_freq trace as it clarifies on applied thermal frequency to the scheduler. Thus helping to understand cpufreq-hw traces better and avoids ambiguity between throttled_freq vs what was applied by/to the scheduler. Change-Id: I5644921cb0a643f30c1bfa8269cd427763a75f33 Signed-off-by: Vivek Aknurwar --- drivers/cpufreq/qcom-cpufreq-hw.c | 13 +++++++------ include/trace/events/dcvsh.h | 13 ++++++++----- 2 files changed, 15 insertions(+), 11 deletions(-) diff --git a/drivers/cpufreq/qcom-cpufreq-hw.c b/drivers/cpufreq/qcom-cpufreq-hw.c index 3967cd8cb3f9..204247a1f180 100644 --- a/drivers/cpufreq/qcom-cpufreq-hw.c +++ b/drivers/cpufreq/qcom-cpufreq-hw.c @@ -424,7 +424,7 @@ static void qcom_lmh_dcvs_notify(struct qcom_cpufreq_data *data) struct cpufreq_policy *policy = data->policy; int cpu = cpumask_first(policy->related_cpus); struct device *dev = get_cpu_device(cpu); - unsigned long freq_hz, throttled_freq; + unsigned long freq_hz, throttled_freq, thermal_pressure; struct dev_pm_opp *opp; if (!dev) @@ -445,8 +445,7 @@ static void qcom_lmh_dcvs_notify(struct qcom_cpufreq_data *data) else dev_pm_opp_put(opp); - throttled_freq = freq_hz / HZ_PER_KHZ; - trace_dcvsh_freq(cpu, qcom_cpufreq_get_freq(cpu), throttled_freq); + throttled_freq = thermal_pressure = freq_hz / HZ_PER_KHZ; /* * In the unlikely case policy is unregistered do not enable @@ -461,7 +460,7 @@ static void qcom_lmh_dcvs_notify(struct qcom_cpufreq_data *data) * for, then stop polling and switch back to interrupt mechanism. */ if (throttled_freq >= qcom_cpufreq_get_freq(cpu)) { - throttled_freq = policy->cpuinfo.max_freq; + thermal_pressure = policy->cpuinfo.max_freq; enable_irq(data->throttle_irq); trace_dcvsh_throttle(cpu, 0); @@ -473,14 +472,16 @@ static void qcom_lmh_dcvs_notify(struct qcom_cpufreq_data *data) * communicated as thermal pressure. */ if (throttled_freq >= data->last_non_boost_freq) - throttled_freq = policy->cpuinfo.max_freq; + thermal_pressure = policy->cpuinfo.max_freq; mod_delayed_work(system_highpri_wq, &data->throttle_work, msecs_to_jiffies(10)); } + trace_dcvsh_freq(cpu, qcom_cpufreq_get_freq(cpu), throttled_freq, thermal_pressure); + /* Update thermal pressure (the boost frequencies are accepted) */ - arch_update_thermal_pressure(policy->related_cpus, throttled_freq); + arch_update_thermal_pressure(policy->related_cpus, thermal_pressure); data->dcvsh_freq_limit = throttled_freq; out: diff --git a/include/trace/events/dcvsh.h b/include/trace/events/dcvsh.h index 54c72bbc7aca..4c7ce0ffcc7f 100644 --- a/include/trace/events/dcvsh.h +++ b/include/trace/events/dcvsh.h @@ -1,6 +1,6 @@ /* SPDX-License-Identifier: GPL-2.0-only */ /* - * Copyright (c) 2022, Qualcomm Innovation Center, Inc. All rights reserved. + * Copyright (c) 2022-2023, Qualcomm Innovation Center, Inc. All rights reserved. */ #undef TRACE_SYSTEM @@ -14,26 +14,29 @@ TRACE_EVENT(dcvsh_freq, TP_PROTO(unsigned long cpu, unsigned long req_freq, - unsigned long throttled_freq), + unsigned long throttled_freq, unsigned long thermal_pressure), - TP_ARGS(cpu, req_freq, throttled_freq), + TP_ARGS(cpu, req_freq, throttled_freq, thermal_pressure), TP_STRUCT__entry( __field(unsigned long, cpu) __field(unsigned long, req_freq) __field(unsigned long, throttled_freq) + __field(unsigned long, thermal_pressure) ), TP_fast_assign( __entry->cpu = cpu; __entry->req_freq = req_freq; __entry->throttled_freq = throttled_freq; + __entry->thermal_pressure = thermal_pressure; ), - TP_printk("cpu:%lu requested_freq:%lu throttled_freq:%lu", + TP_printk("cpu:%lu requested_freq:%lu throttled_freq:%lu thermal_pressure_freq:%lu", __entry->cpu, __entry->req_freq, - __entry->throttled_freq) + __entry->throttled_freq, + __entry->thermal_pressure) ); TRACE_EVENT(dcvsh_throttle,