@@ -2582,6 +2582,40 @@ int cpufreq_get_policy(struct cpufreq_policy *policy, unsigned int cpu)
2582
2582
}
2583
2583
EXPORT_SYMBOL (cpufreq_get_policy );
2584
2584
2585
+ DEFINE_PER_CPU (unsigned long, cpufreq_pressure );
2586
+
2587
+ /**
2588
+ * cpufreq_update_pressure() - Update cpufreq pressure for CPUs
2589
+ * @policy: cpufreq policy of the CPUs.
2590
+ *
2591
+ * Update the value of cpufreq pressure for all @cpus in the policy.
2592
+ */
2593
+ static void cpufreq_update_pressure (struct cpufreq_policy * policy )
2594
+ {
2595
+ unsigned long max_capacity , capped_freq , pressure ;
2596
+ u32 max_freq ;
2597
+ int cpu ;
2598
+
2599
+ cpu = cpumask_first (policy -> related_cpus );
2600
+ max_freq = arch_scale_freq_ref (cpu );
2601
+ capped_freq = policy -> max ;
2602
+
2603
+ /*
2604
+ * Handle properly the boost frequencies, which should simply clean
2605
+ * the cpufreq pressure value.
2606
+ */
2607
+ if (max_freq <= capped_freq ) {
2608
+ pressure = 0 ;
2609
+ } else {
2610
+ max_capacity = arch_scale_cpu_capacity (cpu );
2611
+ pressure = max_capacity -
2612
+ mult_frac (max_capacity , capped_freq , max_freq );
2613
+ }
2614
+
2615
+ for_each_cpu (cpu , policy -> related_cpus )
2616
+ WRITE_ONCE (per_cpu (cpufreq_pressure , cpu ), pressure );
2617
+ }
2618
+
2585
2619
/**
2586
2620
* cpufreq_set_policy - Modify cpufreq policy parameters.
2587
2621
* @policy: Policy object to modify.
@@ -2637,6 +2671,8 @@ static int cpufreq_set_policy(struct cpufreq_policy *policy,
2637
2671
policy -> max = __resolve_freq (policy , policy -> max , CPUFREQ_RELATION_H );
2638
2672
trace_cpu_frequency_limits (policy );
2639
2673
2674
+ cpufreq_update_pressure (policy );
2675
+
2640
2676
policy -> cached_target_freq = UINT_MAX ;
2641
2677
2642
2678
pr_debug ("new min and max freqs are %u - %u kHz\n" ,
0 commit comments