@@ -25,6 +25,9 @@ struct sugov_policy {
25
25
unsigned int next_freq ;
26
26
unsigned int cached_raw_freq ;
27
27
28
+ /* max CPU capacity, which is equal for all CPUs in freq. domain */
29
+ unsigned long max ;
30
+
28
31
/* The next fields are only needed if fast switch cannot be used: */
29
32
struct irq_work irq_work ;
30
33
struct kthread_work work ;
@@ -48,7 +51,6 @@ struct sugov_cpu {
48
51
49
52
unsigned long util ;
50
53
unsigned long bw_dl ;
51
- unsigned long max ;
52
54
53
55
/* The field below is for single-CPU policies only: */
54
56
#ifdef CONFIG_NO_HZ_COMMON
@@ -158,7 +160,6 @@ static void sugov_get_util(struct sugov_cpu *sg_cpu)
158
160
{
159
161
struct rq * rq = cpu_rq (sg_cpu -> cpu );
160
162
161
- sg_cpu -> max = arch_scale_cpu_capacity (sg_cpu -> cpu );
162
163
sg_cpu -> bw_dl = cpu_bw_dl (rq );
163
164
sg_cpu -> util = effective_cpu_util (sg_cpu -> cpu , cpu_util_cfs (sg_cpu -> cpu ),
164
165
FREQUENCY_UTIL , NULL );
@@ -253,6 +254,7 @@ static void sugov_iowait_boost(struct sugov_cpu *sg_cpu, u64 time,
253
254
*/
254
255
static void sugov_iowait_apply (struct sugov_cpu * sg_cpu , u64 time )
255
256
{
257
+ struct sugov_policy * sg_policy = sg_cpu -> sg_policy ;
256
258
unsigned long boost ;
257
259
258
260
/* No boost currently required */
@@ -280,7 +282,8 @@ static void sugov_iowait_apply(struct sugov_cpu *sg_cpu, u64 time)
280
282
* sg_cpu->util is already in capacity scale; convert iowait_boost
281
283
* into the same scale so we can compare.
282
284
*/
283
- boost = (sg_cpu -> iowait_boost * sg_cpu -> max ) >> SCHED_CAPACITY_SHIFT ;
285
+ boost = sg_cpu -> iowait_boost * sg_policy -> max ;
286
+ boost >>= SCHED_CAPACITY_SHIFT ;
284
287
boost = uclamp_rq_util_with (cpu_rq (sg_cpu -> cpu ), boost , NULL );
285
288
if (sg_cpu -> util < boost )
286
289
sg_cpu -> util = boost ;
@@ -337,7 +340,7 @@ static void sugov_update_single_freq(struct update_util_data *hook, u64 time,
337
340
if (!sugov_update_single_common (sg_cpu , time , flags ))
338
341
return ;
339
342
340
- next_f = get_next_freq (sg_policy , sg_cpu -> util , sg_cpu -> max );
343
+ next_f = get_next_freq (sg_policy , sg_cpu -> util , sg_policy -> max );
341
344
/*
342
345
* Do not reduce the frequency if the CPU has not been idle
343
346
* recently, as the reduction is likely to be premature then.
@@ -373,6 +376,7 @@ static void sugov_update_single_perf(struct update_util_data *hook, u64 time,
373
376
unsigned int flags )
374
377
{
375
378
struct sugov_cpu * sg_cpu = container_of (hook , struct sugov_cpu , update_util );
379
+ struct sugov_policy * sg_policy = sg_cpu -> sg_policy ;
376
380
unsigned long prev_util = sg_cpu -> util ;
377
381
378
382
/*
@@ -399,7 +403,8 @@ static void sugov_update_single_perf(struct update_util_data *hook, u64 time,
399
403
sg_cpu -> util = prev_util ;
400
404
401
405
cpufreq_driver_adjust_perf (sg_cpu -> cpu , map_util_perf (sg_cpu -> bw_dl ),
402
- map_util_perf (sg_cpu -> util ), sg_cpu -> max );
406
+ map_util_perf (sg_cpu -> util ),
407
+ sg_policy -> max );
403
408
404
409
sg_cpu -> sg_policy -> last_freq_update_time = time ;
405
410
}
@@ -408,25 +413,19 @@ static unsigned int sugov_next_freq_shared(struct sugov_cpu *sg_cpu, u64 time)
408
413
{
409
414
struct sugov_policy * sg_policy = sg_cpu -> sg_policy ;
410
415
struct cpufreq_policy * policy = sg_policy -> policy ;
411
- unsigned long util = 0 , max = 1 ;
416
+ unsigned long util = 0 ;
412
417
unsigned int j ;
413
418
414
419
for_each_cpu (j , policy -> cpus ) {
415
420
struct sugov_cpu * j_sg_cpu = & per_cpu (sugov_cpu , j );
416
- unsigned long j_util , j_max ;
417
421
418
422
sugov_get_util (j_sg_cpu );
419
423
sugov_iowait_apply (j_sg_cpu , time );
420
- j_util = j_sg_cpu -> util ;
421
- j_max = j_sg_cpu -> max ;
422
424
423
- if (j_util * max > j_max * util ) {
424
- util = j_util ;
425
- max = j_max ;
426
- }
425
+ util = max (j_sg_cpu -> util , util );
427
426
}
428
427
429
- return get_next_freq (sg_policy , util , max );
428
+ return get_next_freq (sg_policy , util , sg_policy -> max );
430
429
}
431
430
432
431
static void
@@ -752,14 +751,15 @@ static int sugov_start(struct cpufreq_policy *policy)
752
751
{
753
752
struct sugov_policy * sg_policy = policy -> governor_data ;
754
753
void (* uu )(struct update_util_data * data , u64 time , unsigned int flags );
755
- unsigned int cpu ;
754
+ unsigned int cpu = cpumask_first ( policy -> cpus ) ;
756
755
757
756
sg_policy -> freq_update_delay_ns = sg_policy -> tunables -> rate_limit_us * NSEC_PER_USEC ;
758
757
sg_policy -> last_freq_update_time = 0 ;
759
758
sg_policy -> next_freq = 0 ;
760
759
sg_policy -> work_in_progress = false;
761
760
sg_policy -> limits_changed = false;
762
761
sg_policy -> cached_raw_freq = 0 ;
762
+ sg_policy -> max = arch_scale_cpu_capacity (cpu );
763
763
764
764
sg_policy -> need_freq_update = cpufreq_driver_test_flags (CPUFREQ_NEED_UPDATE_LIMITS );
765
765
0 commit comments