ANDROID: sched: add a helper function to change PELT half-life
Add a new helper function and export it for vendor module to dynamically switch to an alternative half-life at runtime. Bug: 195474490 Signed-off-by: JianMin Liu <jian-min.liu@mediatek.com> Change-Id: Ife41997a032fe3384cfa126cbf7aee929c5c11cf
This commit is contained in:
@@ -32,15 +32,16 @@ int pelt_load_avg_period = PELT32_LOAD_AVG_PERIOD;
|
|||||||
int pelt_load_avg_max = PELT32_LOAD_AVG_MAX;
|
int pelt_load_avg_max = PELT32_LOAD_AVG_MAX;
|
||||||
const u32 *pelt_runnable_avg_yN_inv = pelt32_runnable_avg_yN_inv;
|
const u32 *pelt_runnable_avg_yN_inv = pelt32_runnable_avg_yN_inv;
|
||||||
|
|
||||||
static int __init set_pelt(char *str)
|
int get_pelt_halflife(void)
|
||||||
{
|
{
|
||||||
int rc, num;
|
return pelt_load_avg_period;
|
||||||
|
|
||||||
rc = kstrtoint(str, 0, &num);
|
|
||||||
if (rc) {
|
|
||||||
pr_err("%s: kstrtoint failed. rc=%d\n", __func__, rc);
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
EXPORT_SYMBOL_GPL(get_pelt_halflife);
|
||||||
|
|
||||||
|
static int __set_pelt_halflife(void *data)
|
||||||
|
{
|
||||||
|
int rc = 0;
|
||||||
|
int num = *(int *)data;
|
||||||
|
|
||||||
switch (num) {
|
switch (num) {
|
||||||
case PELT8_LOAD_AVG_PERIOD:
|
case PELT8_LOAD_AVG_PERIOD:
|
||||||
@@ -56,12 +57,34 @@ static int __init set_pelt(char *str)
|
|||||||
pr_info("PELT half life is set to %dms\n", num);
|
pr_info("PELT half life is set to %dms\n", num);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
pr_err("Default PELT half life is 32ms\n");
|
rc = -EINVAL;
|
||||||
|
pr_err("Failed to set PELT half life to %dms, the current value is %dms\n",
|
||||||
|
num, pelt_load_avg_period);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return rc;
|
||||||
|
}
|
||||||
|
|
||||||
|
int set_pelt_halflife(int num)
|
||||||
|
{
|
||||||
|
return stop_machine(__set_pelt_halflife, &num, NULL);
|
||||||
|
}
|
||||||
|
EXPORT_SYMBOL_GPL(set_pelt_halflife);
|
||||||
|
|
||||||
|
static int __init set_pelt(char *str)
|
||||||
|
{
|
||||||
|
int rc, num;
|
||||||
|
|
||||||
|
rc = kstrtoint(str, 0, &num);
|
||||||
|
if (rc) {
|
||||||
|
pr_err("%s: kstrtoint failed. rc=%d\n", __func__, rc);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
__set_pelt_halflife(&num);
|
||||||
|
return rc;
|
||||||
|
}
|
||||||
|
|
||||||
early_param("pelt", set_pelt);
|
early_param("pelt", set_pelt);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
Reference in New Issue
Block a user