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

Commit

Permalink
Merge branch 'eas/neutrino-msm-fajita-4.9' of https://github.com/0cto…
Browse files Browse the repository at this point in the history
…bot/neutrino-staging into neutrino-msm-fajita-4.9

* eas/neutrino-msm-fajita-4.9: (5 commits)
  sched/tune: Refactor SchedTune Assist code
  cpufreq: schedutil: Expose default rate-limits as config options
  schedutil: follow CAF's initialization
  cpufreq: schedutil: Remove CAF predicted load functionality
  neutrino: Enable SCHEDUTIL_(UP|DOWN)_RATE_LIMIT

Signed-off-by: Adam W. Willis <return.of.octobot@gmail.com>
  • Loading branch information
0ctobot committed Aug 29, 2019
2 parents 46fde8e + 118e504 commit 9d76e6c
Show file tree
Hide file tree
Showing 5 changed files with 74 additions and 96 deletions.
2 changes: 2 additions & 0 deletions arch/arm64/configs/neutrino_defconfig
Original file line number Diff line number Diff line change
Expand Up @@ -662,6 +662,8 @@ CONFIG_CPU_FREQ_GOV_POWERSAVE=y
# CONFIG_CPU_FREQ_GOV_CONSERVATIVE is not set
# CONFIG_CPU_BOOST is not set
CONFIG_CPU_FREQ_GOV_SCHEDUTIL=y
CONFIG_SCHEDUTIL_UP_RATE_LIMIT=500
CONFIG_SCHEDUTIL_DOWN_RATE_LIMIT=20000
CONFIG_CPU_INPUT_BOOST=y
CONFIG_INPUT_BOOST_DURATION_MS=500
CONFIG_WAKE_BOOST_DURATION_MS=1000
Expand Down
18 changes: 18 additions & 0 deletions drivers/cpufreq/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,24 @@ config CPU_FREQ_GOV_SCHEDUTIL

If in doubt, say N.

if CPU_FREQ_GOV_SCHEDUTIL

config SCHEDUTIL_UP_RATE_LIMIT
int "Default up rate-limit for schedutil"
default 500
help
This sets schedutil's default frequency up rate-limit in
microseconds.

config SCHEDUTIL_DOWN_RATE_LIMIT
int "Default down rate-limit for schedutil"
default 20000
help
This sets schedutil's default frequency down rate-limit in
microseconds.

endif

config CPU_INPUT_BOOST
bool "CPU Input Boost"
help
Expand Down
3 changes: 1 addition & 2 deletions init/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -1443,8 +1443,7 @@ config STUNE_ASSIST
depends on SCHED_TUNE
depends on ANDROID
help
This option enables the configuration of default SchedTune
parameters from kernel.
This option enables in-kernel overrides for SchedTune values.

If unsure, say N.

Expand Down
59 changes: 15 additions & 44 deletions kernel/sched/cpufreq_schedutil.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,11 @@
#define cpufreq_driver_fast_switch(x, y) 0
#define cpufreq_enable_fast_switch(x)
#define cpufreq_disable_fast_switch(x)
#define LATENCY_MULTIPLIER (1000)

struct sugov_tunables {
struct gov_attr_set attr_set;
unsigned int up_rate_limit_us;
unsigned int down_rate_limit_us;
bool pl;
bool iowait_boost_enable;
};

Expand Down Expand Up @@ -302,7 +300,7 @@ static void sugov_update_single(struct update_util_data *hook, u64 time,

flags &= ~SCHED_CPUFREQ_RT_DL;

if (!sg_policy->tunables->pl && flags & SCHED_CPUFREQ_PL)
if (flags & SCHED_CPUFREQ_PL)
return;

sugov_set_iowait_boost(sg_cpu, time);
Expand All @@ -313,18 +311,13 @@ static void sugov_update_single(struct update_util_data *hook, u64 time,

busy = sugov_cpu_is_busy(sg_cpu);

raw_spin_lock(&sg_policy->update_lock);
if (flags & SCHED_CPUFREQ_RT_DL) {
/* clear cache when it's bypassed */
sg_policy->cached_raw_freq = 0;
next_f = policy->cpuinfo.max_freq;
} else {
sugov_get_util(&util, &max, sg_cpu->cpu);

sg_cpu->util = util;
sg_cpu->max = max;
sg_cpu->flags = flags;

sugov_iowait_boost(sg_cpu, &util, &max);
next_f = get_next_freq(sg_policy, util, max);
/*
Expand All @@ -338,7 +331,6 @@ static void sugov_update_single(struct update_util_data *hook, u64 time,
}
}
sugov_update_commit(sg_policy, time, next_f);
raw_spin_unlock(&sg_policy->update_lock);
}

static unsigned int sugov_next_freq_shared(struct sugov_cpu *sg_cpu, u64 time)
Expand Down Expand Up @@ -374,7 +366,7 @@ static unsigned int sugov_next_freq_shared(struct sugov_cpu *sg_cpu, u64 time)

j_util = j_sg_cpu->util;
j_max = j_sg_cpu->max;
if (j_util * max >= j_max * util) {
if (j_util * max > j_max * util) {
util = j_util;
max = j_max;
}
Expand All @@ -393,7 +385,7 @@ static void sugov_update_shared(struct update_util_data *hook, u64 time,
unsigned long util, max;
unsigned int next_f;

if (!sg_policy->tunables->pl && flags & SCHED_CPUFREQ_PL)
if (flags & SCHED_CPUFREQ_PL)
return;

sugov_get_util(&util, &max, sg_cpu->cpu);
Expand Down Expand Up @@ -538,23 +530,6 @@ static ssize_t down_rate_limit_us_store(struct gov_attr_set *attr_set,
return count;
}

static ssize_t pl_show(struct gov_attr_set *attr_set, char *buf)
{
struct sugov_tunables *tunables = to_sugov_tunables(attr_set);

return scnprintf(buf, PAGE_SIZE, "%u\n", tunables->pl);
}

static ssize_t pl_store(struct gov_attr_set *attr_set, const char *buf,
size_t count)
{
struct sugov_tunables *tunables = to_sugov_tunables(attr_set);

if (kstrtobool(buf, &tunables->pl))
return -EINVAL;
return count;
}

static ssize_t iowait_boost_enable_show(struct gov_attr_set *attr_set,
char *buf)
{
Expand Down Expand Up @@ -582,13 +557,11 @@ static ssize_t iowait_boost_enable_store(struct gov_attr_set *attr_set,

static struct governor_attr up_rate_limit_us = __ATTR_RW(up_rate_limit_us);
static struct governor_attr down_rate_limit_us = __ATTR_RW(down_rate_limit_us);
static struct governor_attr pl = __ATTR_RW(pl);
static struct governor_attr iowait_boost_enable = __ATTR_RW(iowait_boost_enable);

static struct attribute *sugov_attributes[] = {
&up_rate_limit_us.attr,
&down_rate_limit_us.attr,
&pl.attr,
&iowait_boost_enable.attr,
NULL
};
Expand Down Expand Up @@ -701,7 +674,6 @@ static void sugov_tunables_save(struct cpufreq_policy *policy,
per_cpu(cached_tunables, cpu) = cached;
}

cached->pl = tunables->pl;
cached->up_rate_limit_us = tunables->up_rate_limit_us;
cached->down_rate_limit_us = tunables->down_rate_limit_us;
}
Expand All @@ -723,7 +695,6 @@ static void sugov_tunables_restore(struct cpufreq_policy *policy)
if (!cached)
return;

tunables->pl = cached->pl;
tunables->up_rate_limit_us = cached->up_rate_limit_us;
tunables->down_rate_limit_us = cached->down_rate_limit_us;
sg_policy->up_rate_delay_ns = cached->up_rate_limit_us;
Expand All @@ -735,7 +706,6 @@ static int sugov_init(struct cpufreq_policy *policy)
{
struct sugov_policy *sg_policy;
struct sugov_tunables *tunables;
unsigned int lat;
int ret = 0;

/* State should be equivalent to EXIT */
Expand Down Expand Up @@ -774,19 +744,20 @@ static int sugov_init(struct cpufreq_policy *policy)
goto stop_kthread;
}

tunables->up_rate_limit_us = LATENCY_MULTIPLIER;
tunables->down_rate_limit_us = LATENCY_MULTIPLIER;
lat = policy->cpuinfo.transition_latency / NSEC_PER_USEC;
if (lat) {
tunables->up_rate_limit_us *= lat;
tunables->down_rate_limit_us *= lat;
}
/*
* NOTE:
* intializing up_rate/down_rate to 0 explicitly in kernel
* since WALT expects so by default.
*/
tunables->up_rate_limit_us = 0;
tunables->down_rate_limit_us = 0;

/* Hard-code default tunables */
tunables->up_rate_limit_us = 500;
tunables->down_rate_limit_us = 20000;
tunables->iowait_boost_enable = true;
tunables->up_rate_limit_us =
CONFIG_SCHEDUTIL_UP_RATE_LIMIT;
tunables->down_rate_limit_us =
CONFIG_SCHEDUTIL_DOWN_RATE_LIMIT;

tunables->iowait_boost_enable = true;
policy->governor_data = sg_policy;
sg_policy->tunables = tunables;
stale_ns = sched_ravg_window + (sched_ravg_window >> 3);
Expand Down
88 changes: 38 additions & 50 deletions kernel/sched/tune.c
Original file line number Diff line number Diff line change
Expand Up @@ -971,48 +971,40 @@ boost_slots_release(struct schedtune *st)
#ifdef CONFIG_STUNE_ASSIST
#ifdef CONFIG_SCHED_WALT
static int sched_boost_override_write_wrapper(struct cgroup_subsys_state *css,
struct cftype *cft, u64 override)
struct cftype *cft, u64 override)
{
if (!strcmp(current->comm, "init"))
return 0;

sched_boost_override_write(css, NULL, override);

return 0;
return sched_boost_override_write(css, cft, override);
}

static int sched_colocate_write_wrapper(struct cgroup_subsys_state *css,
struct cftype *cft, u64 colocate)
struct cftype *cft, u64 colocate)
{
if (!strcmp(current->comm, "init"))
return 0;

sched_colocate_write(css, NULL, colocate);

return 0;
return sched_colocate_write(css, cft, colocate);
}
#endif

static int boost_write_wrapper(struct cgroup_subsys_state *css,
struct cftype *cft, s64 boost)
struct cftype *cft, s64 boost)
{
if (!strcmp(current->comm, "init"))
return 0;

boost_write(css, NULL, boost);

return 0;
return boost_write(css, cft, boost);
}

static int prefer_idle_write_wrapper(struct cgroup_subsys_state *css,
struct cftype *cft, u64 prefer_idle)
struct cftype *cft, u64 prefer_idle)
{
if (!strcmp(current->comm, "init"))
return 0;

prefer_idle_write(css, NULL, prefer_idle);

return 0;
return prefer_idle_write(css, cft, prefer_idle);
}
#endif

Expand All @@ -1021,11 +1013,7 @@ static struct cftype files[] = {
{
.name = "sched_boost_no_override",
.read_u64 = sched_boost_override_read,
#ifdef CONFIG_STUNE_ASSIST
.write_u64 = sched_boost_override_write_wrapper,
#else
.write_u64 = sched_boost_override_write,
#endif
},
{
.name = "sched_boost_enabled",
Expand All @@ -1035,30 +1023,18 @@ static struct cftype files[] = {
{
.name = "colocate",
.read_u64 = sched_colocate_read,
#ifdef CONFIG_STUNE_ASSIST
.write_u64 = sched_colocate_write_wrapper,
#else
.write_u64 = sched_colocate_write,
#endif
},
#endif
{
.name = "boost",
.read_s64 = boost_read,
#ifdef CONFIG_STUNE_ASSIST
.write_s64 = boost_write_wrapper,
#else
.write_s64 = boost_write,
#endif
},
{
.name = "prefer_idle",
.read_u64 = prefer_idle_read,
#ifdef CONFIG_STUNE_ASSIST
.write_u64 = prefer_idle_write_wrapper,
#else
.write_u64 = prefer_idle_write,
#endif
},
#ifdef CONFIG_DYNAMIC_STUNE_BOOST
{
Expand Down Expand Up @@ -1093,27 +1069,39 @@ schedtune_boostgroup_init(struct schedtune *st, int idx)
}

#ifdef CONFIG_STUNE_ASSIST
struct st_data {
char *name;
int boost;
bool prefer_idle;
bool colocate;
bool no_override;
};

static void write_default_values(struct cgroup_subsys_state *css)
{
u8 i;
struct groups_data {
char *name;
int boost;
bool prefer_idle;
bool colocate;
bool no_override;
};
struct groups_data groups[3] = {
static struct st_data st_targets[] = {
{ "audio-app", 0, 0, 0, 0 },
{ "background", 0, 0, 0, 0 },
{ "foreground", 0, 1, 0, 0 },
{ "rt", 0, 0, 0, 0 },
{ "top-app", 5, 1, 0, 0 },
{ "foreground", 0, 1, 0, 0 },
{ "background", 0, 0, 0, 0 }};

for (i = 0; i < ARRAY_SIZE(groups); i++) {
if (!strcmp(css->cgroup->kn->name, groups[i].name)) {
boost_write(css, NULL, groups[i].boost);
prefer_idle_write(css, NULL, groups[i].prefer_idle);
sched_colocate_write(css, NULL, groups[i].colocate);
sched_boost_override_write(css, NULL, groups[i].no_override);
};
int i;

for (i = 0; i < ARRAY_SIZE(st_targets); i++) {
struct st_data tgt = st_targets[i];

if (!strcmp(css->cgroup->kn->name, tgt.name)) {
pr_info("stune_assist: setting values for %s: boost=%d prefer_idle=%d colocate=%d no_override=%d\n",
tgt.name, tgt.boost, tgt.prefer_idle,
tgt.colocate, tgt.no_override);

boost_write(css, NULL, tgt.boost);
prefer_idle_write(css, NULL, tgt.prefer_idle);
#ifdef CONFIG_SCHED_WALT
sched_colocate_write(css, NULL, tgt.colocate);
sched_boost_override_write(css, NULL, tgt.no_override);
#endif
}
}
}
Expand Down

0 comments on commit 9d76e6c

Please sign in to comment.