@@ -57,7 +57,6 @@ struct sugov_cpu {
5757 unsigned long util_cfs ;
5858 unsigned long util_dl ;
5959 unsigned long max ;
60- unsigned int flags ;
6160
6261 /* The field below is for single-CPU policies only: */
6362#ifdef CONFIG_NO_HZ_COMMON
@@ -183,17 +182,28 @@ static void sugov_get_util(struct sugov_cpu *sg_cpu)
183182
184183static unsigned long sugov_aggregate_util (struct sugov_cpu * sg_cpu )
185184{
185+ struct rq * rq = cpu_rq (sg_cpu -> cpu );
186+ unsigned long util ;
187+
188+ if (rq -> rt .rt_nr_running ) {
189+ util = sg_cpu -> max ;
190+ } else {
191+ util = sg_cpu -> util_dl ;
192+ if (rq -> cfs .h_nr_running )
193+ util += sg_cpu -> util_cfs ;
194+ }
195+
186196 /*
187197 * Ideally we would like to set util_dl as min/guaranteed freq and
188198 * util_cfs + util_dl as requested freq. However, cpufreq is not yet
189199 * ready for such an interface. So, we only do the latter for now.
190200 */
191- return min (sg_cpu -> util_cfs + sg_cpu -> util_dl , sg_cpu -> max );
201+ return min (util , sg_cpu -> max );
192202}
193203
194- static void sugov_set_iowait_boost (struct sugov_cpu * sg_cpu , u64 time )
204+ static void sugov_set_iowait_boost (struct sugov_cpu * sg_cpu , u64 time , unsigned int flags )
195205{
196- if (sg_cpu -> flags & SCHED_CPUFREQ_IOWAIT ) {
206+ if (flags & SCHED_CPUFREQ_IOWAIT ) {
197207 if (sg_cpu -> iowait_boost_pending )
198208 return ;
199209
@@ -262,38 +272,34 @@ static void sugov_update_single(struct update_util_data *hook, u64 time,
262272{
263273 struct sugov_cpu * sg_cpu = container_of (hook , struct sugov_cpu , update_util );
264274 struct sugov_policy * sg_policy = sg_cpu -> sg_policy ;
265- struct cpufreq_policy * policy = sg_policy -> policy ;
266275 unsigned long util , max ;
267276 unsigned int next_f ;
268277 bool busy ;
269278
270- sugov_set_iowait_boost (sg_cpu , time );
279+ sugov_set_iowait_boost (sg_cpu , time , flags );
271280 sg_cpu -> last_update = time ;
272281
273282 if (!sugov_should_update_freq (sg_policy , time ))
274283 return ;
275284
276285 busy = sugov_cpu_is_busy (sg_cpu );
277286
278- if (flags & SCHED_CPUFREQ_RT ) {
279- next_f = policy -> cpuinfo .max_freq ;
280- } else {
281- sugov_get_util (sg_cpu );
282- max = sg_cpu -> max ;
283- util = sugov_aggregate_util (sg_cpu );
284- sugov_iowait_boost (sg_cpu , & util , & max );
285- next_f = get_next_freq (sg_policy , util , max );
286- /*
287- * Do not reduce the frequency if the CPU has not been idle
288- * recently, as the reduction is likely to be premature then.
289- */
290- if (busy && next_f < sg_policy -> next_freq ) {
291- next_f = sg_policy -> next_freq ;
287+ sugov_get_util (sg_cpu );
288+ max = sg_cpu -> max ;
289+ util = sugov_aggregate_util (sg_cpu );
290+ sugov_iowait_boost (sg_cpu , & util , & max );
291+ next_f = get_next_freq (sg_policy , util , max );
292+ /*
293+ * Do not reduce the frequency if the CPU has not been idle
294+ * recently, as the reduction is likely to be premature then.
295+ */
296+ if (busy && next_f < sg_policy -> next_freq ) {
297+ next_f = sg_policy -> next_freq ;
292298
293- /* Reset cached freq as next_freq has changed */
294- sg_policy -> cached_raw_freq = 0 ;
295- }
299+ /* Reset cached freq as next_freq has changed */
300+ sg_policy -> cached_raw_freq = 0 ;
296301 }
302+
297303 sugov_update_commit (sg_policy , time , next_f );
298304}
299305
@@ -309,6 +315,8 @@ static unsigned int sugov_next_freq_shared(struct sugov_cpu *sg_cpu, u64 time)
309315 unsigned long j_util , j_max ;
310316 s64 delta_ns ;
311317
318+ sugov_get_util (j_sg_cpu );
319+
312320 /*
313321 * If the CFS CPU utilization was last updated before the
314322 * previous frequency update and the time elapsed between the
@@ -322,21 +330,15 @@ static unsigned int sugov_next_freq_shared(struct sugov_cpu *sg_cpu, u64 time)
322330 if (delta_ns > TICK_NSEC ) {
323331 j_sg_cpu -> iowait_boost = 0 ;
324332 j_sg_cpu -> iowait_boost_pending = false;
325- j_sg_cpu -> util_cfs = 0 ;
326- if (j_sg_cpu -> util_dl == 0 )
327- continue ;
328333 }
329- if (j_sg_cpu -> flags & SCHED_CPUFREQ_RT )
330- return policy -> cpuinfo .max_freq ;
331334
332335 j_max = j_sg_cpu -> max ;
333336 j_util = sugov_aggregate_util (j_sg_cpu );
337+ sugov_iowait_boost (j_sg_cpu , & j_util , & j_max );
334338 if (j_util * max > j_max * util ) {
335339 util = j_util ;
336340 max = j_max ;
337341 }
338-
339- sugov_iowait_boost (j_sg_cpu , & util , & max );
340342 }
341343
342344 return get_next_freq (sg_policy , util , max );
@@ -351,18 +353,11 @@ sugov_update_shared(struct update_util_data *hook, u64 time, unsigned int flags)
351353
352354 raw_spin_lock (& sg_policy -> update_lock );
353355
354- sugov_get_util (sg_cpu );
355- sg_cpu -> flags = flags ;
356-
357- sugov_set_iowait_boost (sg_cpu , time );
356+ sugov_set_iowait_boost (sg_cpu , time , flags );
358357 sg_cpu -> last_update = time ;
359358
360359 if (sugov_should_update_freq (sg_policy , time )) {
361- if (flags & SCHED_CPUFREQ_RT )
362- next_f = sg_policy -> policy -> cpuinfo .max_freq ;
363- else
364- next_f = sugov_next_freq_shared (sg_cpu , time );
365-
360+ next_f = sugov_next_freq_shared (sg_cpu , time );
366361 sugov_update_commit (sg_policy , time , next_f );
367362 }
368363
@@ -673,7 +668,6 @@ static int sugov_start(struct cpufreq_policy *policy)
673668 memset (sg_cpu , 0 , sizeof (* sg_cpu ));
674669 sg_cpu -> cpu = cpu ;
675670 sg_cpu -> sg_policy = sg_policy ;
676- sg_cpu -> flags = 0 ;
677671 sg_cpu -> iowait_boost_max = policy -> cpuinfo .max_freq ;
678672 }
679673
0 commit comments