Skip to content
This repository has been archived by the owner on Jul 16, 2020. It is now read-only.

Commit

Permalink
[EAS.ver.]: cpufreq: schedutil: Use exponential frequency selection
Browse files Browse the repository at this point in the history
As of currently, schedutil takes the maximum CPU frequency, multiplies
it by 1.5 (or + freq / 2), then multiplies that by the current load
ratio. The resulting data is a linear equation, where the maximum CPU
frequency is selected at approximately ~66.667% load. If the load is
anything greater, the maximum CPU frequency is still selected.

The reported load for Android usage allows schedutil to make efficient
frequency changes to maintain throughput, however, perceivable jank is
not accounted for. Some kernel hackers opt for some form on CPU
boosting, whether it be minimum frequency capping, schedtune boosting,
or the use of msm_performance userspace control.

As an alternative idea, schedutil could act upon it's reported load in
an exponential fashion. Placing the load into a square root allows
schedutil to pick higher frequencies more often, especially around the
middle loads. At its highest point, this algorithm can boost frequency
selection by ~1.5x. The benefit of this method over other boosting
concepts is that the minimum and maximum selections are kept in-tact.
This means that at 0% load, schedutil will still pick the lowest
available frequency, and at 100% load, schedutil will still pick the
highest available frequency that is inline with the original algorithm.

We need to use int_sqrt when calculating the square root, which returns
an integer. Unfortunately, we need a ratio in the form of an unsigned
decimal. We need to perform the square root with a scalar and then
divide by the square root of that scalar later to find the square root
of the decimal.

@THEBOSS619: Adapt it to EAS's SchedUtil

Signed-off-by: Tyler Nijmeh <tylernij@gmail.com>
  • Loading branch information
tytydraco authored and THEBOSS619 committed Apr 26, 2020
1 parent 4d87a4f commit c3c897f
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion include/linux/sched/cpufreq.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ void cpufreq_remove_update_util_hook(int cpu);
static inline unsigned long map_util_freq(unsigned long util,
unsigned long freq, unsigned long cap)
{
return (freq + (freq >> 2)) * util / cap;
return (freq + (freq >> 2)) * int_sqrt(util * 100 / cap) / 10;
}

bool cpufreq_this_cpu_can_update(struct cpufreq_policy *policy);
Expand Down

0 comments on commit c3c897f

Please sign in to comment.